text
stringlengths 28
935k
| meta
stringlengths 137
139
| red_pajama_subset
stringclasses 1
value |
---|---|---|
\section{Introduction}
Outdoor images taken in rainy conditions have limited visibility, which degrades the performance of various applications such as video surveillance and self-driving systems.
Hence, it is essential to recover the degraded images to improve scene visibility and the performance of downstream applications. This paper considers single image deraining.
\begin{figure}[!t]
\centering
\begin{tabular}{c}
\includegraphics[width = 0.99\linewidth]{figs/introduction.pdf}
\end{tabular}
\caption{Results on the real-world image (b-d) and the synthetic Rain200H dataset (e). Our proposed method generates a better deraining result on the real-world image and achieves the best performance-parameter trade-off on the synthetic dataset.
}
\label{fig:introduction}
\end{figure}
A rainy image $O$ can be modeled as a linear combination of a rain-free image $B$ and a rain streaks image $R$:
\begin{equation}
O = B + R.
\label{eq:rainy formation}
\end{equation}
Many deraining approaches have been developed based on this simple rainy image model, including prior-based methods and deep-learning-based methods. Prior-based methods usually explore empirical statistical properties of rain streaks and rain-free images, such as image decomposition~\cite{derain_id_kang}, sparse coding~\cite{derain_dsc_luo,derain_zhang_Sparse_and_Low-Rank}, low-rank representation~\cite{derain_lowrank}, and Gaussian mixture model~\cite{derain_lp_li}.
However, since the priors are based on empirical statistical observations, they do not hold when real-world complex rainy conditions deviate from the simplified assumptions.
Recent years have witnessed the successful application of deep learning methods to image deraining~\cite{derain_ddn_fu,derain_jorder_yang,derain_rescan_li,derain_zhang_did,dualcnn-pan,spic-wang-derain,cvpr20_jiang_mspfn,mm20_wang_dcsfn,derain_mprnet_cvpr21,icassp-wang-derain,PhysicsGAN-pan}.
Most of these methods develop joint learning networks~\cite{derain_zhang_did,derain_cvpr19_hu,cvpr20_jiang_mspfn} or explore multi-scale architectures~\cite{mm20_wang_dcsfn,icme2020_zhu_phy,derain_mprnet_cvpr21} for image deraining.
The methods based on joint learning networks include density-guided multi-stream networks~\cite{derain_zhang_did} and progressive networks motivated by patch similarity and guided by multi-scale architectures~\cite{cvpr20_jiang_mspfn}.
While these methods are able to remove rain streaks with the guiding networks, they do not perform well when the guiding process is not accurately estimated.
In addition, although multi-scale architectures have been demonstrated to be effective, existing methods usually adopt a straightforward way to fuse features from different scales and do not explore the properties of multi-scale features.
Last but not least, existing methods commonly use synthetic datasets to train the deep models due to the lack of well-constructed real-world datasets. However, the gap between synthetic and real data limits the performance of these methods in real-world applications.
Due to the difficulty of single image deraining, how to fully utilize convolutional features from both shallow and deep layers of a deep model and explore multi-scale features are important for rain streaks removal. In addition, it is essential to develop an effective algorithm to improve the deraining performance on real-world images.
To this end, we propose a high-order collaborative network with multi-scale compact constraints and a bidirectional scale-content mining module to remove rain streaks.
The high-order collaborative design allows exploring features from the shallower and deeper layers of different sub-networks collaboratively, while the multi-scale compact constraints are used to effectively learn features from intermediate convolutional layers and the bidirectional scale-content mining module is embedded in an encoder-decoder network to explore features of different scales.
Specifically, the high-order collaborative design contains three sub-networks (bottom, middle, and up) which are learned in a collaborative manner, where the bottom network transmits intermediate features to the middle network which also receives shallower rainy features from the top network and sends back features to the bottom network. The middle and top networks provide deep supervision for the bottom network to better learn and transmit shallow rainy features to higher layers to facilitate deraining. To generate more useful features from a deep network internally, we propose to enforce multi-scale compact constraints on the intermediate layers to learn better features with Laplacian pyramid images.
In addition, we develop a bidirectional scale-content similarity mining module in a down-to-up and up-to-down manner to capture long-range dependencies between features at different scales, which is embedded in an encoder-decoder architecture to explore useful features.
Finally, to improve the model performance on real-world images, we propose a simple yet effective online-update learning approach, to fine-tune the model trained on synthetic datasets using real-world data in a self-supervised manner with a KL-Divergence loss function. The proposed network design and online-update learning approach enable our model to achieve state-of-the-art deraining performance, especially on real-world images, as illustrated in Fig.~\ref{fig:introduction}.
The main contributions of this paper include:
\begin{itemize}
\item We propose a collaborative deraining framework with multi-scale compact constraints to control the learning process in an external and internal manner, with a new bidirectional scale-content similarity mining module to adaptively learn richer feature representations.
\item We present a simple yet effective online-update learning approach to fine-tune the model trained on synthetic datasets to adapt to real rainy conditions in a self-supervised manner for real-world image deraining.
\item We conduct extensive experiments and ablation studies to evaluate the proposed method. The results demonstrate that our method performs favorably against state-of-the-art methods with fewer parameters on both synthetic and real-world datasets.
\end{itemize}
\section{Related Work}
In this section, we briefly review recent works on image deraining, which are based on deep learning, as well as some image restoration methods based on similarity mining.
\subsection{Single Image Deraining}
In recent years, deep-learning-based approaches have dominated the research of image deraining due to the strong representation learning ability of deep neural networks.
\citet{derain_ddn_fu} observe that high-frequency details provide more rain streaks details and less background interference and design a deep detail residual network to learn rain streaks.
Some deraining methods explore the properties of multi-scale images. \citet{mm20_wang_dcsfn} propose a cross-scale framework to fuse features of different scales from sub-networks. \citet{cvpr20_jiang_mspfn} design a multi-scale progressive fusion network to transmit and fuse small-scale features to the original scale based on the similarity of multi-scale images.
Recurrent networks are also used for deraining.
\citet{derain_rescan_li} develop a recurrent squeeze-and-excitation network with dilation convolution to model channel context relation. \citet{derain_prenet_Ren_2019_CVPR} propose a progressive recurrent network to remove rain streaks stage by stage and analyze the effect of inputs, outputs, and loss functions for image deraining. Some non-local methods are based on attention mechanisms. \citet{derain_nledn_li} propose to embed a non-local module to an encoder-decoder framework to capture long-range feature dependency for improving representation learning. \citet{mm20_wang_jdnet} attempt to combine self-attention and scale-aggregation in a self-calibrated network.
Besides, some semi-supervised approaches have been proposed for removing rain streaks in real-world images.
For example, \citet{Derain-cvpr19-semi} develop a semi-supervised transfer learning approach, and \citet{cvpr20_syn2real} design a Gaussian-process-based model that learns on both synthetic and real data.
Different from the above works, our proposed method aims to explore inner structures and useful features of the deraining network in an external and internal manner to train the network for better rain streaks removal. We also propose an effective online-update learning approach to fine-tune the model trained with synthetic data on real data for real-world image deraining.
\subsection{Similarity Mining}
Similarity mining aims to find the most matched content at the feature level.
\citet{sr_cross_scale_mining_Mei} study cross-scale feature mining by exploring the inherent properties of images for single image super-resolution.
\citet{mei2020pyramid} mine the similarity from coarser to finer levels in a multi-scale manner for image restoration. Different from these works that only explore single directional mining (from coarser to finer levels), we in this paper design a bidirectional scale-content similarity mining module to adaptively learn richer features for better deraining.
\begin{figure}[!t]
\begin{center}
\begin{tabular}{c}
\includegraphics[width = 0.99\linewidth]{figs/overall.pdf}
\end{tabular}
\end{center}
\caption{Proposed high-order collaborative networks with multi-scale compact constraints.
Each network module $\mathcal{N}_{mn}$ has a same encoder-decoder structure with the bidirectional scale-content similarity minding module shown in Fig.~\ref{fig: encoder-decoder}.
}
\label{fig: overall}
\end{figure}
\section{Proposed Method}
In this section, we introduce each element of the proposed method including high-order collaborative network, multi-scale compact constraint, encoder-decoder structure with a bidirectional scale-content similarity mining module, supervised loss function, and online-update learning.
\subsection{High-order Collaborative Networks}\label{sec: High-order Collaborative Progressive Network}
How to exploit features from the intermediate layers and different modules in a collaborative manner is important for image restoration.
Here, we design an effective high-order collaborative network\footnote{We regard two-stream networks as collaborative networks and three-stream networks as high-order.} to assist each sub-network to learn features in an external manner for better image deraining.
The overall network structure of the high-order collaborative network is shown in Fig.~\ref{fig: overall}, which consists of three sub-networks with similar structure.
The bottom ($\mathcal{B}$), middle ($\mathcal{M}$), and top ($\mathcal{T}$) sub-networks respectively contain three, two, and one encoder-decoder component with a bidirectional scale-content similarity mining module that will be explained in detail in Sec.~\ref{sec: Scale-content Similarity Mining}.
The three sub-networks can transmit shallower and deeper rainy features to each other in a collaborative manner to improve the performance of the deraining network $\mathcal{B}$.
Note that $\mathcal{M}$ and $\mathcal{T}$ are supervised by ground truth, which can be regarded as a sort of deep supervision in an external manner such that $\mathcal{M}$ and $\mathcal{T}$ can transmit useful features to assist $\mathcal{B}$ to learn better features for deraining.
The three sub-networks are trained by:
\begin{equation}
\begin{array}{ll}
\mathcal{L}_{\text{collaborative}} = \sum_{i=1}^{3}\alpha_{i} \big(-SSIM(\hat{B}_{i}, B)\big),
\end{array}
\label{eq:n0}
\end{equation}
where $\{\hat{B}_{i}\}$ ($ i = 1, 2, 3$) denote the output of networks $\mathcal{B}$, $\mathcal{M}$, and $\mathcal{T}$ respectively, $B$ is the ground truth, and $\alpha_{i}$ are weight parameters.
\subsection{Multi-Scale Compact Constraints}\label{sec: Multi-scale Compact Constraint}
Although the high-order collaborative design enables the bottom sub-network $\mathcal{B}$ to exploit deeper and shallower features from the other two sub-networks, the features of each intermediate convolutional layer are learned without any constraints, making the solution space too large.
To regularize the solution space of intermediate convolutional layers, we design multi-scale compact constraints (MSCC) in an internal manner to enforce the network modules $\mathcal{N}_{11}$, $\mathcal{N}_{12}$, and $\mathcal{N}_{21}$, which are parts of the sub-networks $\mathcal{B}$ and $\mathcal{M}$, to learn more useful features to facilitate image deraining.
The multi-scale compact constraints are motivated by the multi-scale Laplacian images which can better model image structures than the original scale image. We use them to constrain the intermediate convolutional layers of the network.
We first obtain the Laplacian pyramid images and then use the scaled images to
constrain the modules $\mathcal{N}_{11}, \mathcal{N}_{12}, \mathcal{N}_{21}$ as shown in Fig.~\ref{fig: overall}. Specifically,
the multi-scale compact constraints are enforced by:
\begin{equation}
\begin{array}{ll}
\mathcal{L}_{\text{mscc}} = \sum_{j=1}^{2}\beta_{j}\big(-SSIM(\hat{B}_{\frac{1}{2^{j}}}, B_{\frac{1}{2^{j}}})\big),
\end{array}
\label{eq:n0}
\end{equation}
where $\hat{B}_{\frac{1}{2^{j}}}$ are the output of intermediate layers as denoted in Fig.~\ref{fig: overall},
$B_{\frac{1}{2^{j}}}$ are the corresponding $\frac{1}{2^{j}}$ scale Laplacian pyramid rain-free images, and
$\beta_{j}$ are weight parameters.
\subsection{Encoder and Decoder with BiSCSM}\label{sec: Scale-content Similarity Mining}
Further, we develop a bidirectional scale-content similarity mining module (BiSCSM) to explore similar features from different scales, which
is motivated by \citet{Mei_sisr_mining,sr_cross_scale_mining_Mei}. The architecture is shown in Fig.~\ref{fig: encoder-decoder}.
The proposed BiSCSM contains Down-to-Up mining and Up-to-Down mining modules. The Up-to-Down mining module is defines as:
\begin{equation}
\begin{array}{ll}
y_{i,j}^{p \times p} = \frac{1}{\sigma(x,z)}\sum_{g,h} \phi(x^{p \times p}_{i,j},z^{p \times p}_{u,v}) \theta (x_{g,h}^{p \times p}) ,
\end{array}
\label{eq:n0}
\end{equation}
where $\phi(x^{p \times p}_{i,j},z^{p \times p}_{u,v}) = e^{(W_{f}x_{i,j}^{p \times p})^{T}(W_{g}z_{u,v}^{p \times p})}$,
$\theta = W_{\theta}x_{g,h}^{p \times p}$,
$\sigma = \sum_{u,v}\phi(x^{p \times p}_{i,j},z^{p \times p}_{u,v})$,
$y_{i,j}^{p \times p}$ is a $p \times p$ feature patch located at ($i$, $j$), and
$W_{f},W_{g},W_{\theta}$ are learnable filters.
The Down-to-Up mining module is defined similarly as shown in Fig.~\ref{fig: mining module}.
Our proposed BiSCSM is different from the one in \citet{Mei_sisr_mining,sr_cross_scale_mining_Mei} which only mines patch similarity in a single direction. Our Down-to-Up mining and Up-to-Down mining modules enable capturing bidirectional similar content
from large to small scales and from small to large scales to mine rich rainy features.
The BiSCSM is embedded in an encoder-decoder framework as in Fig.~\ref{fig: encoder-decoder} to learn useful features for rain streaks removal.
We also use positional embedding to encode relations among rain streak features.
Finally, we fuse the learned features at difference scales.
\begin{figure}[!t]
\begin{center}
\begin{tabular}{c}
\includegraphics[width = 0.99\linewidth]{figs/encoder-decoder.pdf}
\end{tabular}
\end{center}
\caption{Proposed encoder and decoder with a bidirectional scale-content similarity mining module. The Down-to-Up and Up-to-Down mining modules are shown in Fig.~\ref{fig: mining module}.
}
\label{fig: encoder-decoder}
\end{figure}
\begin{figure}[!t]
\begin{center}
\begin{tabular}{cc}
\includegraphics[width = 0.499\linewidth]{figs/similarity1.pdf} &\hspace{-4mm}
\includegraphics[width = 0.499\linewidth]{figs/similarity2.pdf}
\\
(a) Down-to-Up Mining&\hspace{-4mm} (b) Up-to-Down Mining
\end{tabular}
\end{center}
\vspace{-2mm}
\caption{The scale-content similarity mining modules.
}
\label{fig: mining module}
\end{figure}
\subsection{Supervised Loss Function}\label{Loss Function on Synthetic Datasets}
Based on the above network design, the overall loss function for training on synthetic datasets is:
\begin{equation}
\begin{array}{ll}
\mathcal{L}_{\text{synthetic}} = {\mathcal{L}_{\text{collaborative}}}+ {\mathcal{L}_{\text{mscc}}}.
\end{array}
\label{eq:n0}
\end{equation}
\subsection{Online-update Learning}\label{sec: Online Updating Scheme}
Since a deraining model trained on synthetic data normally does not generalize well to real-world images, we propose an online-update learning approach to fine-tune the model on real-world rainy images.
The key challenges are two-fold. The first is that there are no ground-truth images available for training.
The second is how to keep the training stable and improve the model performance.
To address these issues, we use the derained results of real-world images generated by the model trained on synthetic data as pseudo ground truth and update the pseudo ground truth at each epoch with the fine-tuned model. The loss function is based on Kullback-Leibler divergence and defined as:
\begin{equation}
\begin{array}{ll}
\mathcal{L}_{\text{real}} = \underbrace{||\hat{B}^{k}- \hat{B}^{k-1}||_{1}}_{\text{content term}} +
\underbrace{{\lambda KL_{Loss}(\hat{R}^{k}, \hat{R}^{k-1}_{\text{random}})}}_{\text{regularization term}},
\end{array}
\label{eq:real-world}
\end{equation}
where $\hat{B}^{k}$ and $\hat{B}^{k-1}$ are the deraining results of a real-world rainy image $O$ generated by the model $\mathcal{B}$ at epoch $k$ and $k-1$ respectively. Note that $\hat{B}^{0}$ is the initial deraining result produced by $\mathcal{B}$ after training on synthetic data.
$\hat{R}^{k}= O-\hat{B}^{k}$ is the estimated rain streaks of $O$. $\hat{R}^{k-1}_{\text{random}} = O_{\text{random}}-\hat{B}_{\text{random}}^{k-1}$ is the estimated rain streaks of a randomly selected real-world rainy image $O_{\text{random}}$ and $\hat{B}_{\text{random}}^{k-1}$ is the deraining result of $O_{\text{random}}$ at epoch $k-1$.
The first term of Eq.~(\ref{eq:real-world}) ensures the content of image background consistent between different epochs and keeps the training stable, and the second term is a regularization term that enforces similarity in rain streaks and improves the deraining performance as the training proceeds (see Fig.~\ref{fig: Results on fine-tune manner.}).
The fine-tuning process is illustrated in
Fig.~\ref{fig: The illustration of online updating learning manner.} and described in Alg.~\ref{alg:B}.
\begin{figure}[!t]
\begin{center}
\begin{tabular}{cc}
\includegraphics[width = 0.99\linewidth]{Supp/updating-imgs.pdf}
\end{tabular}
\end{center}
\caption{Proposed online-update learning approach.
}
\label{fig: The illustration of online updating learning manner.}
\end{figure}
\begin{algorithm}[!t]
\caption{Online-update Learning on Real-world Data}
\label{alg:B}
\hspace*{0.02in}{Preparation:}
The initial deraining result $\hat{B}^{0}$ of a real-world image $O$ generated by the model trained on synthetic data.
\\
\hspace*{0.02in}{Input:}
$\{O, \hat{B}^{0}\}$.
\\
\hspace*{0.02in}{Output:}
Derained image \{$\hat{B}$\}.
\begin{algorithmic}[1]
\STATE {While $k$ $\leq$ $\mathrm{Epoch}_{\mathrm{Real}}$ ~do:}
\\
\STATE {\quad \quad Randomly crop training image pairs \{$O, \hat{B}^{k-1}$\}}
\\
\STATE {\quad \quad Randomly select a real-world rainy image $O_{\text{random}}$ and obtain $\hat{R}_{\text{random}}^{k-1} = O_{\text{random}}-\hat{B}_{\text{random}}^{k-1}$}
\\
\STATE {\quad \quad Update the deraining model by Eq.~(\ref{eq:real-world}})
\\
\STATE {\quad \quad Output the current deraining result: \{$\hat{B}^{k}$\} }
\STATE {\quad \quad Update the pseudo ground truth:\{$\hat{B}^{k-1}$\} $\gets$\{$\hat{B}^{k}$\}}
\STATE {\quad \quad $k$ $\gets$ $k+1$}
\STATE {End while}
\end{algorithmic}
\end{algorithm}
\begin{table*}[!t]
\centering
\scalebox{0.865}{
\begin{tabular}{l|cccccccccccccccccccccc}
\hline
\multirow{2}{*}{Methods}
& \multicolumn{2}{c}{Rain200H}
& \multicolumn{2}{c}{Rain200L}
& \multicolumn{2}{c}{Rain1200}
& \multicolumn{2}{c}{Rain1400}
& \multicolumn{2}{c}{Rain12}
& \multirow{2}{*}{\# Param}
\\
& PSNR~$\uparrow$ & SSIM~$\uparrow$& PSNR~$\uparrow$ & SSIM~$\uparrow$& PSNR~$\uparrow$ & SSIM~$\uparrow$& PSNR~$\uparrow$ & SSIM~$\uparrow$& PSNR~$\uparrow$ & SSIM~$\uparrow$ \\
\hline
RESCAN (ECCV'18) & 26.661&0.8419 &36.993&0.9788&32.127&0.9028&30.969&0.9117&32.965& 0.9545 &0.15M
\\
NLEDN (MM'18) &27.315&0.8904 &36.487&0.9792&32.473&0.9198&31.014&0.9206 &33.028& 0.9615&1.01M
\\
SSIR (CVPR'19) &14.420&0.4501&23.476&0.8026&24.427&0.7713&25.772&0.8224&24.138&0.7768&0.06M
\\
PreNet (CVPR'19) & 27.525&0.8663 &34.266&0.9660&30.456&0.8702 &30.984&0.9156 &35.095&0.9400&0.17M
\\
SpaNet (CVPR'19) &25.484 & 0.8584& 36.075 &0.9774 & 27.099& 0.8082& 29.000& 0.8891&33.217& 0.9546&0.28M
\\
DCSFN (MM'20)&28.469& 0.9016 &37.847& 0.9842 &32.275& 0.9228&31.493& 0.9279 &35.803& 0.9683&6.45M
\\
MSPFN (CVPR'20) &25.553& 0.8039 & 30.367& 0.9219 &30.382&0.8860 &31.514& 0.9203 &34.253& 0.9469&21.00M
\\
DRDNet (CVPR'20) &15.102& 0.5028 &37.465&0.9806 &28.386&0.8574 &28.359&0.8574 &25.435& 0.7550 &5.23M
\\
RCDNet (CVPR'20) &28.698& 0.8904 & 38.400 &0.9841 &32.273& 0.9111& 31.016 &0.9164& 31.038 &0.9069 &3.67M
\\
Syn2Real (CVPR'20)&14.495 & 0.4021 &31.035 & 0.9365 &28.812 & 0.8400&28.582 & 0.8586&31.038 & 0.9069 &2.62M
\\
MPRNet (CVPR'21)&29.949 & 0.9151&36.610&0.9785& 33.655 &0.9310 & 32.257 & 0.9325 & 36.578 &0.9696 &3.64M
\\
\hline
Ours &\textbf{29.985}&\textbf{0.9218}&\textbf{39.284} & \textbf{0.9875}&\textbf{33.718}& \textbf{0.9327}&\textbf{32.617}& \textbf{0.9334} &\textbf{36.851} &\textbf{0.9714} & 2.04M
\\
\hline
\end{tabular}}
\caption{Quantitative results on five synthetic datasets.
The best results are marked in \textbf{bold}.
$\uparrow$ denotes higher is better.
}
\label{tab: the results in synthetic datasets}
\end{table*}
\begin{figure*}[!t
\begin{center}
\begin{tabular}{ccccccccc}
\includegraphics[width = 0.104\linewidth]{syn/syn-input-1_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.104\linewidth]{syn/syn-dcsfn-1_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.104\linewidth]{syn/syn-mspfn-1_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.104\linewidth]{syn/syn-drd-1_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.104\linewidth]{syn/syn-rcd-1_.pdf}&\hspace{-4mm}
\includegraphics[width = 0.104\linewidth]{syn/syn-syn2real-1_.pdf}&\hspace{-4mm}
\includegraphics[width = 0.104\linewidth]{syn/syn-mprnet-1_.pdf}&\hspace{-4mm}
\includegraphics[width = 0.104\linewidth]{syn/syn-ours-1_.pdf}&\hspace{-4mm}
\includegraphics[width = 0.104\linewidth]{syn/syn-gt-1_.pdf}
\\
(a) Input &\hspace{-4mm} (b) DCSFN&\hspace{-4mm} (c) MSPFN&\hspace{-4mm} (d) DRDNet&\hspace{-4mm} (e) RCDNet &\hspace{-4mm}(f) Syn2Real&\hspace{-4mm} (g) MPRNet&\hspace{-4mm}(h) Ours &\hspace{-4mm}(i) GT
\\
\end{tabular}
\end{center}
\caption{Comparison with state-of-the-art methods on synthetic datasets.
The proposed network is able to restore better texture.
}
\label{fig:deraining-syn-example}
\end{figure*}
\section{Experiments}
\label{sec: experiments}
We compare the proposed approach with 11 state-of-the-art methods (SOTAs), including
RESCAN~\cite{derain_rescan_li},
NLEDN~\cite{derain_nledn_li},
SSIR~\cite{Derain-cvpr19-semi},
PreNet~\cite{derain_prenet_Ren_2019_CVPR},
SpaNet~\cite{derain_2019_CVPR_spa},
DCSFN~\cite{mm20_wang_dcsfn},
MSPFN~\cite{cvpr20_jiang_mspfn},
DRDNet~\cite{drd_cvpr20_deng},
RCDNet~\cite{cvpr20_wang_rcdnet},
Syn2Real~\cite{cvpr20_syn2real}, and
MPRNet~\cite{derain_mprnet_cvpr21}, on five widely used synthetic datasets and a real-world dataset.
\subsection{Datasets and Evaluation Criteria}
\subsubsection{Synthetic dataset}
We use Rain200H~\cite{derain_jorder_yang}, Rain200L~\cite{derain_jorder_yang},
Rain1200 \cite{derain_zhang_did},
Rain1400~\cite{derain_ddn_fu}, and
Rain12~\cite{derain_lp_li} as the synthetic datasets for training and evaluation.
{Rain200H} is the most challenging dataset, which has 1800 image pairs for training and 200 pairs for testing.
{Rain200L} is the easiest dataset with the same number of training and testing samples as Rain200H.
{Rain1200} has images with heavy, middle, and light rain, and there are 4000 training images and 400 testing images for each density.
{Rain1400} has 12600 training samples and 1400 testing samples.
Since {Rain12} only contains 12 testing samples, we use the model trained on Rain200H to test the deraining results.
We use Rain200H as the dataset for ablation study and analysis.
\subsubsection{Real-world dataset}
\citet{derain_jorder_yang}, \citet{deraining-benchmark-analysis}, and \citet{mm20_wang_jdnet} provide a large body of real-world rainy images. We use them to evaluate the deraining results on real-world data.
\subsubsection{Evaluation criteria}
We use two widely used metrics, peak signal to noise ratio (PSNR)~\cite{PSNR_thu} and structural similarity index measure (SSIM)~\cite{SSIM_wang} to evaluate the quality of restored images on synthetic datasets.
As there are no ground-truth for real-world rainy images, we only compare the results visually.
\subsection{Implementation Details}
We set the number of channels of each convolutional layer except the last one as $20$, and LeakyReLU with $\alpha = 0.2$ is used after each convolutional layer except for the last one.
For the last layer, we use $3 \times 3$ convolution without any activation function in $\mathcal{B}$, $\mathcal{M}$, and $\mathcal{T}$.
We randomly crop $128\times128$ image patches as input, and the batch size is set as $12$.
We use ADAM optimizer~\cite{adam} to train the network.
The initial learning rate is 0.0005, which will be divided by $10$ at the $300$-th and $400$-th epochs, and the model training terminates after $500$ epochs.
We set $\lambda=0.0001$, $\alpha_{1}=1$, $\alpha_{2}=1$, $\alpha_{3}=1$, $\beta_{1}=0.05$, and $\beta_{2}=0.001$.
We train the model for 30 epochs on the real-world dataset, i.e., $\mathrm{Epoch}_{\mathrm{Real}}$ = 30.
Our model is trained with four NVIDIA RTX TITAN GPUs on the Pytorch platform.
\subsection{Results and Analysis on Synthetic Datasets}
\subsubsection{Comparisons with SOTAs on Synthetic Datasets}
Tab.~\ref{tab: the results in synthetic datasets} reports the results of our method and SOTAs on five synthetic datasets.
We can see that our method achieves the best results on all tested datasets in PSNR and SSIM.
We further show some deraining results in Fig.~\ref{fig:deraining-syn-example}.
It can be observed that our method can restore better details and textures and obtain clearer background images, while other approaches hand down some rain streaks or lose some details.
\subsubsection{Analysis on BiSCSM}
We analyze the effect of different components of BiSCSM and report the results in Tab.~\ref{tab:The analysis on basic component of the network.}.
Note that the method ($M_{1}$) does not generate better results if we remove BiSCSM from the encoder-decoder framework.
Furthermore, we replace the Down-to-Up and Up-to-Down operations in BiSCSM by element-wise summation ($M_{2}$) and $1 \times 1$ convolution ($M_{3}$) to fuse features at different scales.
We find that both operations do not perform well compared to the proposed ones, demonstrating the effectiveness of the mining modules.
Fig.~\ref{fig:Before and After denote the visualization feature map before and after BiSCSM.}
visualizes the feature maps before and after BiSCSM.
One can see that the features are significantly enhanced after BiSCSM.
\begin{table}[!t
\scalebox{0.67}{
\centering
\begin{tabular}{lccccccc}
\hline
Experiments& $M_{1}$ &$M_{2}$ & $M_{3}$ & $M_{4}$ &$M_{5}$ &$M_{6}$& $M_{7}$ (Ours) \\
\hline
Sum & \XSolidBrush & \CheckmarkBold & \XSolidBrush & \XSolidBrush &\XSolidBrush & \XSolidBrush &\XSolidBrush \\
Conv$_{1 \times 1}$ &\XSolidBrush &\XSolidBrush & \CheckmarkBold &\XSolidBrush & \XSolidBrush &\XSolidBrush &\XSolidBrush \\
Down-to-Up & \XSolidBrush &\XSolidBrush& \XSolidBrush & \CheckmarkBold&\XSolidBrush &\XSolidBrush&\XSolidBrush \\
Up-to-Down &\XSolidBrush &\XSolidBrush & \XSolidBrush & \XSolidBrush & \CheckmarkBold&\XSolidBrush&\XSolidBrush\\
BiSCSM & \XSolidBrush &\XSolidBrush &\XSolidBrush &\XSolidBrush &\XSolidBrush &\CheckmarkBold& \CheckmarkBold \\
Position&\XSolidBrush &\CheckmarkBold&\CheckmarkBold& \CheckmarkBold &\CheckmarkBold &\XSolidBrush& \CheckmarkBold \\
\hline
PSNR $\uparrow$ & 29.583&29.625 & 29.541 & 29.393 & 29.828 & 29.953 & \textbf{29.985} \\
\hline
SSIM $\uparrow$ &0.9168 &0.9177 & 0.9156 & 0.9172 & 0.9201 & 0.9218 & \textbf{0.9218} \\\hline
\end{tabular}}
\caption{Ablation study of BiSCSM.
\CheckmarkBold and \XSolidBrush denote that the corresponding component is adopted and not adopted, respectively.}
\label{tab:The analysis on basic component of the network.}
\end{table}
We also test the single-directional mining modules, i.e., using Down-to-Up ($M_{4}$) or Up-to-Down ($M_{5}$) mining module alone, and the results show the bidirectional manner is better and can mine richer features for better deraining ($M_{4}$ and $M_{5}$ vs. $M_{7}$).
Finally, we observe that position awareness can improve the deraining performance ($M_{6}$ vs. $M_{7}$).
\begin{figure}[!t]
\begin{center}
\begin{tabular}{ccc}
\includegraphics[width = 0.32\linewidth]{feature-maps/input.pdf} &\hspace{-4mm}
\includegraphics[width = 0.32\linewidth]{feature-maps/before1.pdf} &\hspace{-4mm}
\includegraphics[width = 0.32\linewidth]{feature-maps/after1.pdf}
\\
(a) Input &\hspace{-4mm} (b) Before &\hspace{-4mm} (c) After
\end{tabular}
\end{center}
\caption{Visualization of the feature maps before and after BiSCSM.
}
\label{fig:Before and After denote the visualization feature map before and after BiSCSM.}
\end{figure}
\begin{table}[!t
\scalebox{0.86}{
\centering
\begin{tabular}{lccccc}
\hline
Experiments& $R_{1}$ &$R_{2}$ & $R_{3}$ & $R_{4}$ &$R_{5}$ (Ours) \\
\hline
$1/2$ Scale& \XSolidBrush & \CheckmarkBold & \XSolidBrush & \XSolidBrush & \CheckmarkBold \\
$1/4$ Scale&\XSolidBrush & \XSolidBrush & \CheckmarkBold & \XSolidBrush& \CheckmarkBold \\
Full Scale &\XSolidBrush & \XSolidBrush &\XSolidBrush & \CheckmarkBold &\XSolidBrush \\
\hline
PSNR $\uparrow$& 29.824&29.879 & 29.839 & 29.970 & \textbf{29.985} \\
\hline
SSIM $\uparrow$&0.9195 &0.9209 & 0.9204 & 0.9211 & \textbf{0.9218} \\
\hline
\end{tabular}}
\caption{Ablation study of the multi-scale compact constraints.}
\label{tab:Results on different types of multi-scale compact constraint.}
\end{table}
\subsubsection{Analysis on MSCC}
Compared with deep models that have no constraints on intermediate layers, our proposed MSCC can make the deep network more compact and learn more useful features.
Tab.~\ref{tab:Results on different types of multi-scale compact constraint.} shows the results of different types of constraints.
We observe that the model without any contraints ($R_{1}$) performs the worst, while the results get better as we add different constraints and reach the best when both $1/2$ ($R_{2}$) and $1/4$ ($R_{3}$) scale constraints are added.
We also consider replacing the $1/2$ and $1/4$ scale images with full-scale images to constrain the network.
The comparison between $R_{4}$ and $R_{5}$ demonstrates that full-scale images are less effective than the multi-scale images, which is probably due to the better structures of Laplacian pyramid images.
\subsubsection{Ablation Study on Collaborative Learning}
We conduct an ablation study of the proposed collaborative network in Tab.~\ref{tab:Results on different types of networks.}.
The results show that the model achieves the best performance when the sub-networks $\mathcal{T}$ and $\mathcal{M}$ are learned with $\mathcal{B}$ in a collaborative manner.
We also consider a case by cascading the three sub-networks to form a deep network model.
Specifically, we cascade the network modules $\mathcal{N}_{11}$, $\mathcal{N}_{12}$, $\mathcal{N}_{13}$, $\mathcal{N}_{21}$, $\mathcal{N}_{22}$, and $\mathcal{N}_{31}$ and ensure the cascaded network has roughly the same number of parameters as the collaborative network. We find that the cascaded network does not perform as well as the collaborative network, which further demonstrates the effectiveness of the proposed collaborative learning manner.
\begin{table}[!t]
\centering
\scalebox{0.68}{
\begin{tabular}{c|c|c|c|c}
\hline
& w/o $\mathcal{T}$ \& w/o $\mathcal{M}$ & w/o $\mathcal{T}$ \& w/ $\mathcal{M}$& Cascaded & w/ $\mathcal{T}$ \& w/ $\mathcal{M}$ (Ours) \\
\hline
PSNR $\uparrow$ & 29.563& 29.355& 29.642 &\textbf{29.985} \\
\hline
SSIM $\uparrow$ &0.9158& 0.9146& 0.9188 & \textbf{0.9218} \\
\hline
\end{tabular}}
\caption{Ablation study on collaborative learning.
}
\label{tab:Results on different types of networks.}
\end{table}
\begin{figure}[!t]
\begin{center}
\begin{tabular}{cc}
\includegraphics[width = 0.499\linewidth]{figs/psnr.png} &\hspace{-5mm}
\includegraphics[width = 0.499\linewidth]{figs/ssim.png}
\\
(a) PSNR &\hspace{-4mm} (b) SSIM
\end{tabular}
\end{center}
\caption{Comparison between single-stream learning and collaborative learning.
}
\label{fig: Comparative results between single learning and collaborative progressive learning.}
\end{figure}
\begin{figure}[!t]
\begin{center}
\begin{tabular}{cc}
\includegraphics[width = 0.499\linewidth]{figs/psnr-eps-converted-to.pdf} &\hspace{-5mm}
\includegraphics[width = 0.499\linewidth]{figs/ssim-eps-converted-to.pdf}
\\
(a) PSNR &\hspace{-4mm} (b) SSIM
\end{tabular}
\end{center}
\caption{Further ablation study on collaborative learning (CL) and multi-scale compact constraints (MSCC).
}
\label{fig: Results on collaborative progressive learning and multi-scale compact constraint.}
\end{figure}
\begin{figure*}[!t
\vspace{-1mm}
\begin{center}
\begin{tabular}{ccccccccc}
\includegraphics[width = 0.118\linewidth]{real/real-input-2_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-dcsfn-2_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-mspfn-2_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-drd-2_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-rcd-2_.pdf}&\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-syn2real-2_.pdf}&\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-mpr-2_.pdf}&\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-oursonline-2_.pdf}
\\
\includegraphics[width = 0.118\linewidth]{real/real-input-3_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-dcsfn-3_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-mspfn-3_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-drd-3_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-rcd-3_.pdf}&\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-syn2real-3_.pdf}&\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-mpr-3_.pdf}&\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-oursonline-3_.pdf}
\\
\includegraphics[width = 0.118\linewidth]{real/real-input-4_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-dcsfn-4_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-mspfn-4_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-drd-4_.pdf} &\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-rcd-4_.pdf}&\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-syn2real-4_.pdf}&\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-mpr-4_.pdf}&\hspace{-4mm}
\includegraphics[width = 0.118\linewidth]{real/real-oursonline-4_.pdf}
\\
(a) Input &\hspace{-4mm} (b) DCSFN&\hspace{-4mm} (c) MSPFN&\hspace{-4mm} (d) DRDNet&\hspace{-4mm} (e) RCDNet &\hspace{-4mm}(f) Syn2Real&\hspace{-4mm} (g) MPRNet&\hspace{-4mm}(h) Ours
\\
\end{tabular}
\end{center}
\caption{Comparisons with state-of-the-art methods on real-world images. Our proposed online-update learning approach is able to deal with various rainy conditions to better remove rain streaks and even haze and recover clearer images.
}
\label{fig:deraining-real-example}
\end{figure*}
\subsubsection{Comparison between Single-stream Learning and Collaborative Learning}
In Fig.~\ref{fig: Comparative results between single learning and collaborative progressive learning.}, we provide the comparison of the performance of each sub-network trained in single-stream learning and collaborative learning manners for image deraining. Single-stream learning means training the sub-networks $\mathcal{T}$, $\mathcal{M}$, and $\mathcal{B}$ independently. The results show that the sub-networks trained by collaborative learning preform much better than by single-stream learning. It can be also observed that the sub-network $\mathcal{T}$ trained by collaborative learning generates comparable results as the sub-network $\mathcal{B}$ trained by single-stream learning, while the size of $\mathcal{T}$ is two-thirds of $\mathcal{B}$.
\subsubsection{Further Ablation Study on Collaborative Learning and Multi-scale Compact Constraints}
Fig.~\ref{fig: Results on collaborative progressive learning and multi-scale compact constraint.} provides a further ablation study of collaborative learning and multi-scale compact constraints, where the learning curves of different variants are plotted.
The results show that both collaborative learning and multi-scale compact constraints are useful for improving the deraining performance. It can also be observed that without either collaborative learning or multi-scale compact constraints, the models perform worse than the cascaded network, which further demonstrates the effectiveness of the proposed external and internal learning manners for the deraining task.
\subsection{Results and Analysis on Real-world Datasets}
\begin{figure}[!t]
\begin{center}
\begin{tabular}{cccc}
\includegraphics[width = 0.24\linewidth]{real-analysis/real-input-11.pdf} &\hspace{-4.5mm}
\includegraphics[width = 0.24\linewidth]{real-analysis/real-syn-11.pdf} &\hspace{-4.5mm}
\includegraphics[width = 0.24\linewidth]{real-analysis/real-continual-11.pdf} &\hspace{-4.5mm}
\includegraphics[width = 0.24\linewidth]{real-analysis/real-ours-11.pdf}
\\
(a) &\hspace{-4mm} (b) &\hspace{-4.5mm} (c) &\hspace{-4mm} (d)
\\
\end{tabular}
\end{center}
\caption{Ablation study of the proposed online-update learning approach.
(a) Input. (b) Only trained on synthetic data. (c) Directly fine-tuned on real-world images. (d) Online-update learning on real-world images.
}
\label{fig: Results on fine-tune manner.}
\end{figure}
\subsubsection{Comparisons with SOTAs on Real-world Images}
We further demonstrate the effectiveness of our method on the real-world dataset by comparing with state-of-the-art methods.
Fig.~\ref{fig:deraining-real-example} presents the deraining results of several challenging cases. It can be observed that our method produces cleaner and clearer deraining results than others, demonstrating its effectiveness in removing rain streaks of real-world rainy images.
\subsubsection{Effectiveness of the Online-update Learning Approach}
Fig.~\ref{fig: Results on fine-tune manner.} presents the ablation study of the online-update learning manner. Compared with only using synthetic data to train the model (Fig.~\ref{fig: Results on fine-tune manner.}(b)) or directly fine-tuning the model on real-world images without updating the pseudo ground truth (Fig.~\ref{fig: Results on fine-tune manner.}(c)), our proposed online-update learning manner (Fig.~\ref{fig: Results on fine-tune manner.}(d)) is able to further improve the deraining performance on real-world images, demonstrating its effectiveness.
\subsubsection{Generality of the Online-update Learning Approach}
To further demonstrate the effectiveness of the online-update learning approach for real-world image deraining, we apply it on a state-of-the-art method, DCSFN~\cite{mm20_wang_dcsfn}.
Similar to Fig.~\ref{fig: Results on fine-tune manner.}, Fig.~\ref{fig: Results on fine-tune manner of DCSFN.} presents the results on a real-world rainy image by different ways of learning.
It can be seen that the proposed online-update learning approach can be successfully applied to DCSFN to significantly improve its deraining performance on real-world images. Since the online-update learning approach is generic, we believe it be applied to many other existing methods to improve their performance in real-world image deraining.
\begin{figure}[!t]
\begin{center}
\begin{tabular}{cccc}
\includegraphics[width = 0.24\linewidth]{real-analysis/real-input-22.pdf} &\hspace{-4.5mm}
\includegraphics[width = 0.24\linewidth]{real-analysis/real-dcsfn-syn22.pdf} &\hspace{-4.5mm}
\includegraphics[width = 0.24\linewidth]{real-analysis/real-dcsfn-continual22.pdf} &\hspace{-4.5mm}
\includegraphics[width = 0.24\linewidth]{real-analysis/real-dcsfn-online22.pdf}
\\
(a) &\hspace{-4mm} (b) &\hspace{-4.5mm} (c) &\hspace{-4.5mm} (d)
\\
\end{tabular}
\end{center}
\caption{Applying the proposed online-update learning approach on DCSFN~\cite{mm20_wang_dcsfn}.
(a) Input. (b) Only trained on synthetic data. (c) Directly fine-tuned on real-world images. (d) Online-update learning on real-world images.
}
\label{fig: Results on fine-tune manner of DCSFN.}
\end{figure}
\section{Conclusion}
In this paper, we have proposed a high-order collaborative network with multi-scale compact constraints to control the learning process in an external and internal manner for image deraining.
We have further developed a bidirectional scale-content similarity mining module to learn useful features at different scales in a down-to-up and up-to-down way to facilitate rain streaks removal.
Finally, to improve the deraining performance on real-world images, we have proposed an effective online-update learning approach to fine-tune the deraining model on real-world rainy images in a self-supervised manner.
Extensive experiments show that the proposed model outperforms state-of-the-art methods on five public synthetic datasets and one real-world dataset.
\section*{Acknowledgements}
We would like to thank the anonymous reviewers for their
helpful comments.
This work was supported by the Fundamental Research Funds for the Central Universities (No. 30920041109),
and the Grant of DaSAIL Project P0030935 funded by PolyU/UGC.
|
{'timestamp': '2022-02-15T02:39:23', 'yymm': '2202', 'arxiv_id': '2202.06568', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06568'}
|
arxiv
|
\section{Introduction}
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{figures/data_sample.pdf}
\caption{An example of electronic health record. \label{fig:data_sample}}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{figures/data_statistic.pdf}
\caption{The histogram of Jaccard between current medications and historical medications (left) and the histogram of the proportion of current medications that occur in past visits (right). \label{fig:data_statistic}}
\end{figure}
Medication recommendation aims to provide a set of medicines to treat the set of diagnosed diseases of a patient.
Take the patient in Figure~\ref{fig:data_sample} for example, this patient visits the hospital for three times. In each visit, this patient is diagnosed with a set of diseases and is prescribed a set of medicines to treat these diseases. Currently, medication recommendation is mainly conducted by doctors according to their expertise and experiences. However, many patients are diagnosed with multiple diseases at one time. To conduct a considerate medication recommendation, on one hand, the doctor needs to select proper medicines for each disease; on the other hand, the doctor needs to avoid harmful drug-drug interactions (DDI) among selected medicines. Therefore, for complicated cases, medication recommendation is time-consuming for experienced doctors and error-prone for inexperienced doctors. To address this problem, the automatic medication recommendation that can assist doctors in decision making is urged.
Due to the clinical value, medication recommendation has attracted growing research interests. A series of deep learning based medication recommendation methods \cite{safedrug, changematter} have been proposed, which can be divided into two categories: \textit{Instance-based} models \cite{LEAP, ecc, gong2021smr} only use patient's current diagnoses and procedures to conduct recommendations while ignoring the longitudinal patient history. In this manner, instance-based based models fail to consider the historical disease development process. To address this issue, \textit{Longitudinal} models \cite{safedrug, gamenet, changematter, dmnc} are designed to take use of the longitudinal patient history and capture the temporal dependencies. Existing longitudinal models usually consist of two stages, first aggregating the known information into a patient-level representation, and then conducting medication recommendation based on it.
One problem of existing works is that they do not explicitly model the relationship between medication recommendations for the same patient. However, in clinical practice, the recommendations for the same patients are closely related. For example, for patients with chronic diseases, they may keep using the same medicine all their lives. As shown in Figure~\ref{fig:data_sample}, we conduct a statistical analysis on the MIMIC-III dataset. For each visit, we calculate the proportion of medications that have appeared in history and the Jaccard between current medications and past medications. We can see that in the most visits, a large portion of prescribed medicines have been recommended before. Inspired by this, we rethink about taking use of historical information from a medication-level perspective. The challenge here is how to accurately determine whether a historical medication is still relevant at present.
In this paper, we propose an encoder-decoder based generation network to produce the appropriate medications in a sequential manner, named Conditional Generation Net (COGNet). The proposed COGNet consists of the basic model and the copy module.
The basic model conducts recommendation only based on patients' health conditions in current visit; the copy module introduces the information of historical visits in modeling. Different from the basic model, in generating each medicine, the copy module decides whether to copy a medicine from historical recommendations or to predict a new one.
The experiments on a public dataset demonstrate the effectiveness of the proposed model. We summarize our major contributions as follows:
\begin{itemize}
\item We propose a medication recommendation model, COGNet, which introduces a novel {\em copy-or-predict} mechanism. COGNet can leverage historical recommendations to produce a more accurate recommendation.
\item We develop a novel hierarchical selection mechanism, which chooses the reusable medicines to copy from both medication-level and visit-level perspectives. This increases the intepretability of the proposed COGNet.
\item We conduct comprehensive experiments on a public dataset MIMIC-III to demonstrate the effectiveness of the proposed COGNet.
\end{itemize}
\section{Problem Formulation}
\subsection{Electrical Health Records (EHR)}
The basic unit of EHR is patient and each patient consists of several visits. Let $\mathcal{R} = {\{\mathcal{V}^{(i)}\}}_{i=1}^{N}$ denote a longitudinal EHR of $N$ patients. Each patient has visited the hospital as least once and the $i$-th patient can be represented as a sequence of multivariate observations $\mathcal{V}^{(i)}=[\mathcal{V}_1^{(i)}, \mathcal{V}_2^{(i)}, \cdots, \mathcal{V}_{T^{(i)}}^{(i)}]$. Here $T^{(i)}$ is the number of visits of the $i$-th patient.
To simplify the notation, we ignore the index $i$ and describe our methods with a single patient, then a patient is represented as $\mathcal{V}=[\mathcal{V}_1,\mathcal{V}_2,\cdots,\mathcal{V}_{T}]$.
Let $\mathcal{D}=\{d_1, d_2, \cdots, d_{|\mathcal{D}|}\}$ denotes the set of diagnoses, $\mathcal{P}=\{p_1, p_2, \cdots, p_{|\mathcal{P}|}\}$ denotes the set of procedures and $\mathcal{M}=\{m_1, m_2, \cdots, m_{|\mathcal{M}|}\}$ denotes the set of medications. $|\mathcal{D}|$, $|\mathcal{P}|$ and $|\mathcal{M}|$ indicate the number of all possible diagnoses, procedures and medications, respectively.
Then, each visit of the patient can be represented by $\mathcal{V}_t = \{\mathcal{D}_t, \mathcal{P}_t, \mathcal{M}_t\}$, where $\mathcal{D}_t \subseteq \mathcal{D}$, $\mathcal{P}_t \subseteq \mathcal{P}$ and $\mathcal{M}_t \subseteq \mathcal{M}$.
\subsection{EHR\&DDI Graph}
$ G_e=\{\mathcal{M}, \mathcal{E}_e\} $ and $ G_d=\{\mathcal{M}, \mathcal{E}_d\} $ denote the EHR graph and DDI graph respectively, where $\mathcal{E}_e$ is all the possible medication combinations in $\mathcal{R}$ and $\mathcal{E}_d$ is the known DDIs. Formally, we use the adjacency matrix $A_e, A_d \in \mathbb{R}^{|\mathcal{M}|\times|\mathcal{M}|}$ to illustrate the construction of the graphs. $A_e[i,j]=1$ means the $i$-th and $j$-th medications have appeared in the same visit. For $A_d$, only the pair-wise DDIs are considered, $A_d[i,j]=1$ means the $i$-th and $j$-th medications are mutually interacted. $G_e$ and $G_d$ are the same for all patients.
\subsection{Medication Recommendation Problem}
Given a patient's current diagnoses $\mathcal{D}_t$, procedures $\mathcal{P}_t$, historical visit information $[\mathcal{V}_1, \mathcal{V}_2, \cdots, \mathcal{V}_{t-1}]$, and the EHR and DDI graphs $G_e$ and $G_d$, the goal is to train a model (i.e., COGNet) which can recommend the proper medication combination $\mathcal{M}_t$ for this patient.
\begin{table}[h]
\caption{Notations used in COGNet}
\centering
\label{notation}
\begin{tabular}{l|l}
\toprule
\textbf{Notation} & \textbf{Description} \\
\midrule
\midrule
$\mathcal{R}$ & Electronic Health Records \\
$\mathcal{V}$ & Record for a single patient \\
$\mathcal{D}, \mathcal{P}, \mathcal{M}$ & Diagnoses, Procedure and Medication set \\
\midrule
$G_*$ & EHR or DDI Graph \\
$\mathcal{E_*}, A_*$ & Edge set and adjacency matrix of graph $G_*$ \\
\midrule
$\mathbf{E}_* \in \mathbb{R}^{|*| \times s} $ & Origin embedding tables \\
$\mathbf{E}_g \in \mathbb{R}^{|\mathcal{M}| \times s} $ & Graph embedding for medications \\
\bottomrule
\end{tabular}
\end{table}
\section{Framework}
\begin{figure*}[h]
\centering
\includegraphics[width=0.85\linewidth]{figures/framework_v5.pdf}
\caption{An overview of our proposed COGNet. The basic model recommend the medication only based on the patient's health condition in current visit. The other part, named copy module, considers the information of patient's historical visits. \label{fig:framework}}
\end{figure*}
Figure~\ref{fig:framework} illustrates the architecture of COGNet.
We employ an encoder-decoder based generative network to generate the appropriate medication combination based on the patient's current and historical health conditions.
In the encoder, we encode all medical codes of the historical visits (i.e., $\mathcal{V}_1$,$\mathcal{V}_2$,$\cdots$,$\mathcal{V}_{t-1}$) to represent the patient's historical health conditions and encode the diagnosis and procedure codes of the $t-$th visit to represent the patient's current health condition.
In the decoder, we will generate the medication one by one to compose the recommendation drug combination.
During each decoding step, the decoder combines the information of the diagnoses, procedures and generated medications to recommend the next medication.
Moreover, if some diseases in current visit keep consistent with the past visits, the copy module will directly copy the corresponding medications from historical drug combinations.
We will first describe the basic encoder-decoder based generation model and then address the copy module in detail in the following subsections.
\subsection{Input Representations}
We design three embedding tables, $\mathbf{E}_d \in \mathbb{R}^{|\mathcal{D}| \times s}$, $\mathbf{E}_p \in \mathbb{R}^{|\mathcal{P}| \times s}$ and $\mathbf{E}_m \in \mathbb{R}^{|\mathcal{M}| \times s}$, where each row is an embedding vector for a distinct diagnosis code, procedure code or medication code. Here $s$ denotes the dimension of the embedding space.
For each diagnosis set $\mathcal{D}_i$ ($i\in [1, t]$), we first convert its every element $d\in \mathcal{D}_i$ to a $s$-dimensional vector $\mathbf{d}$ via the embedding matrix $\mathbf{E}_d$.
Then, we can obtain the representation of the diagnosis set $\mathbf{D}_i \in \mathbb{R}^{|\mathcal{D}_t| \times s}$.
For each procedure set $\mathcal{P}_i$ ($t\in [1, t]$) and medication set $\mathcal{M}_j$ ($j\in [1, t-1]$), we can also obtain their representations $\mathbf{P}_i \in \mathbb{R}^{|\mathcal{P}_i| \times s}$ and $\mathbf{M}_j \in \mathbb{R}^{|\mathcal{M}_j| \times s}$ via the embedding matrices $\mathbf{E}_p$ and $\mathbf{E}_m$, respectively.
\subsection{Basic Model}
In the basic model, we recommend the medication combination only based on the patient's health condition in current visit.
The basic model is an encoder-decoder generation model.
It consists of four modules: \textit{diagnosis encoder}, \textit{procedure encoder}, \textit{medication graph encoder}, and \textit{medication combination decoder}.
\subsubsection{Diagnosis Encoder}
The diagnosis encoder aims to represent the patient's health conditions based on the diagnosis codes.
It is a Transformer-based~\cite{transformer} network and has the following two major sub-layers.
\textit{Multi-Head Self-Attention}. This sub-layer aims to capture relations among all diagnoses in the same visit.
Given three input matrices \(\mathbf{Q}\in \mathbb{R}^{L_Q\times s}\), \(\mathbf{K}\in \mathbb{R}^{L_K\times s}\) and \(\mathbf{V}\in \mathbb{R}^{L_V\times s}\) where \(L_K=L_V\), the attention function is defined as:
\begin{equation}
\operatorname{Attention}(\mathbf{Q}, \mathbf{K}, \mathbf{V})
= \operatorname{Softmax}(\frac{\mathbf{Q}\mathbf{K}^\top}{\sqrt{s}}) \mathbf{V}
\end{equation}
Multi-head attention layer \(\text{MH}(\cdot,\cdot,\cdot)\) will further project the input to multiple representation subspaces and capture the interaction information from multiple views~\cite{DBLP:conf/aaai/QiuWG021}.
\begin{equation}
\begin{split}
& \operatorname{MH}(\mathbf{Q}, \mathbf{K}, \mathbf{V}) = [\operatorname{head}_1;...;\operatorname{head}_h]\mathbf{W}^O \\
& \operatorname{head}_i = \operatorname{Attention}(\mathbf{Q} \mathbf{W}^Q_i, \mathbf{K} \mathbf{W}^K_i, \mathbf{V} \mathbf{W}^V_i)
\end{split}
\end{equation}
\(\mathbf{W}^Q_i\), \(\mathbf{W}^K_i\), \(\mathbf{W}^V_i\in \mathbb{R}^{s\times s/h}\) and \(\mathbf{W}^O\in \mathbb{R}^{s\times s}\) are the parameters to learn. \(h\) is the number of heads.
\textit{Position-wise Feed-Forward}.
This sub-layer consists of two linear projections with a \(\textit{ReLU}\) activation in between.
\begin{equation}
\operatorname{FFN}(\mathbf{H}) = \operatorname{ReLU}(\mathbf{H} \mathbf{W}^F_1 + \mathbf{b}^F_1)\mathbf{W}^F_2 + \mathbf{b}^F_2
\end{equation}
where \(\mathbf{W}^F_1\in \mathbb{R}^{s\times 8s}\), \(\mathbf{W}^F_2\in \mathbb{R}^{8s\times s}\), \(\mathbf{b}^F_1\in \mathbb{R}^{8s}\) and \(\mathbf{b}^F_2\in \mathbb{R}^{s}\)
are trainable parameters.
The diagnosis encoder then employs the residual connection and layer normalization function \(\operatorname{LayerNorm}(\cdot)\) defined in ~\cite{ba2016layer} around the above two sub-layers to extract the diagnosis representation:
\begin{equation}
\begin{split}
\mathbf{D}^{\prime}_t &= \operatorname{Enc_d}(\mathbf{D}_t) = \operatorname{LayerNorm}(\mathbf{H} + \operatorname{FFN}(\mathbf{H})) \\
\text{where}\ \ \mathbf{H} &= \operatorname{LayerNorm}(\mathbf{D}_t + \operatorname{MH}(\mathbf{D}_t,\mathbf{D}_t,\mathbf{D}_t))
\end{split}
\end{equation}
where $\mathbf{D}^{\prime}_t \in \mathbb{R}^{|\mathcal{D}_t| \times s}$ is the diagnosis representation of the $t$-th visit encoded by this encoder.
\subsubsection{Procedure Encoder}
The procedure encoder has the same network structure as the diagnosis encoder but their parameters are different.
Through the same encoding process, we can also obtain the procedure representation $\mathbf{P}^{\prime}_t$ via the procedure encoder:
\begin{equation}
\mathbf{P}^{\prime}_t = \operatorname{Enc_p}(\mathbf{P}_t)
\end{equation}
\subsubsection{Medication Graph Encoder}
This encoder aims to model two kinds of drug relations:
\begin{itemize}
\item \textit{Medication EHR co-occurrence relationship}: Some medications are often prescribed together for better efficacy. For example, ranitidine and sucralfate are the popular drug combination used to treat acute gastritis. Hence, modeling these co-occurrence relations can help the decoder to recommend the drug according to the partially generated medications.
\item \textit{DDI}: As mentioned above, some medications have the DDI and can not be used together. When recommending the drug, the decoder should avoid that it is conflict with the past recommended drugs. Hence, modeling this relation can help to recommend a safe and effective medication combination.
\end{itemize}
Inspired by ~\cite{gamenet}, we use the Graph Convolutional Network~\cite{gcn} to model two kinds of relations based on the medication EHR and DDI graphs.
Given the input medication features $\mathbf{X}\in \mathbb{R}^{|\mathcal{M}|\times s}$ and the medication graph adjacency matrix $\mathbf{A}\in \mathbb{R}^{|\mathcal{M}|\times |\mathcal{M}|}$, the $\operatorname{GCN}(\cdot, \cdot)$ will obtain the new medication representations as follows:
\begin{equation}
\operatorname{GCN}(\mathbf{X}, \mathbf{A}) = \sigma(\hat{\mathbf{O}}^{-\frac{1}{2}} \hat{\mathbf{A}} \hat{\mathbf{O}}^{-\frac{1}{2}} \mathbf{X})
\end{equation}
$\hat{\mathbf{A}} = \mathbf{A}+\mathbf{I}$, $\mathbf{I}$ is the identity matrix and $\hat{\mathbf{O}}$ is the diagonal node degree matrix of $\hat{\mathbf{A}}$ (i.e., $\mathbf{O}_{i,i} = \sum_j \mathbf{A}_{i,j}$).
First, we use a two-layer GCN to model the medication EHR co-occurrence relations based on the EHR graph adjacency matrix $\mathbf{A}_e$.
\begin{equation}
\mathbf{G}_e = \operatorname{GCN}(\operatorname{ReLU}(\operatorname{GCN}(\mathbf{E}_m, \mathbf{A}_e))\mathbf{W}^g_{e}, \mathbf{A}_e)
\end{equation}
where $\mathbf{W}^g_{e}$ is the learnable parameter.
Then, we use another two-layer GCN to model the DDI relations based on the DDI graph $\mathbf{A}_d$.
\begin{equation}
\mathbf{G}_d = \operatorname{GCN}(\operatorname{ReLU}(\operatorname{GCN}(\mathbf{E}_m, \mathbf{A}_d))\mathbf{W}^g_{d}, \mathbf{A}_d)
\end{equation}
where $\mathbf{W}^g_{d}$ is the learnable parameter.
Finally, we fuse two medication relation representations $\mathbf{G}_e$ and $\mathbf{G}_d$ to obtain the relation-aware medication representations.
\begin{equation}
\mathbf{E}_g = \mathbf{G}_e - \lambda \mathbf{G}_d
\end{equation}
where $\lambda$ is a learnable parameter.
\subsubsection{Medication Combination Decoder}
The decoder will recommend the medication one by one for the $t-$th visit.
For example, at the $i$-th decoding step, the decoder will recommend the next medication $\mathcal{M}_{t,i}$ based on the partially generated medication combination $\{\mathcal{M}_{t,0},\cdots, \mathcal{M}_{t,i-1}\}$ and the patient health conditions in the $t$-th visit (i.e., $\mathbf{D}^{\prime}_t$ and $\mathbf{P}^{\prime}_t$).
The decoding process is as follows.
First, we convert all generated medications to vectors via the original embedding matrix $\mathbf{E}_m$ and relation representation matrix $\mathbf{E}_g$ and can obtain two representations of the partially generated medication combination $\hat{\mathbf{M}}_t^m$ and $\hat{\mathbf{M}}_t^g$.
We fuse two representations to obtain the relation-aware medication combination representation.
\begin{equation}
\label{eq:med emb combine}
\hat{\mathbf{M}}_t = \hat{\mathbf{M}}_t^m + \hat{\mathbf{M}}_t^g
\end{equation}
Then, we use the multi-head self-attention mechanism (defined in Eq.(2)) to capture the interactions among the recommended medications.
\begin{equation}
\hat{\mathbf{M}}_t^{'} = \operatorname{LayerNorm}( \hat{\mathbf{M}}_t + \operatorname{MH}(\hat{\mathbf{M}}_t, \hat{\mathbf{M}}_t, \hat{\mathbf{M}}_t))
\end{equation}
Intuitively, the medication recommendation task aims to generate the recommendation of drugs that can cover all diseases of the patient.
Thus, the patient's disease and procedure representations $\mathbf{D}_t^{'}$ and $\mathbf{P}_t^{'}$ play an auxiliary role during the decoding process.
To this end, we align the patient's health conditions to adaptively model the uncovered diseases to guide the next medication recommendation.
\begin{equation}
\hat{\mathbf{M}}_t^{''} = \operatorname{LayerNorm}( \hat{\mathbf{M}}_t^{'} + \operatorname{MH}(\hat{\mathbf{M}}_t^{'}, \mathbf{D}_t^{'}, \mathbf{D}_t^{'}) + \operatorname{MH}(\hat{\mathbf{M}}_t^{'}, \mathbf{P}_t^{'}, \mathbf{P}_t^{'}))
\end{equation}
Finally, we use the last row of $\hat{\mathbf{M}}_t^{''}$ (i.e., $\hat{\mathbf{M}}_{t,i-1}^{''}$) to predict the $i$-th medication via an MLP layer.
\begin{equation}
{\Pr}_g = \operatorname{Softmax}(\hat{\mathbf{M}}_{t,i-1}^{''} \textbf{W}_g + \textbf{b}_g)
\end{equation}
where $\textbf{W}_g\in \mathbb{R}^{s\times |\mathcal{M}|}$ and $\textbf{b}_g\in \mathbb{R}^{|\mathcal{M}|}$ are learnable parameters.
${\Pr}_g$ denotes the probabilities of all medications in the vocabulary in which the medication with the maximum probability is the predicted medication at step $i$.
\subsection{Copy Module}
In \textit{Basic Model} section, we introduce the encoder-decoder based model to generate the medication recommendation results based on the patient's current health conditions.
It doesn't consider the information of patient's historical visits.
In this section, we design a novel copy module to extend the basic model, which first compares the health conditions of current and historical visits and then copies the reusable medications to prescribe for current visit according to the condition changes.
Since the patient may have multiple visits, we use the hierarchical selection mechanism to conduct the copy process at each decoding step.
First, we use the visit-level selection to pick a similar visit by comparing their health conditions.
Then, at the specific decoding step, we use the medication-level selection to pick a particular medication from the prescriptions of the selected visit and add it to the recommendation results.
Finally, we repeat the above process to copy the reusable medications iteratively to form the complete recommendation medication list.
Note that the selection process is ``soft'' like the attention mechanism~\cite{DBLP:conf/icml/XuBKCCSZB15} and assigns different probabilities for all visits/medications to highlight the choice.
We will take the $i$-th medication recommendation of the $t$-th visit (i.e., $\mathcal{M}_{t,i}$) as an example to illustrate the copy process.
\subsubsection{Visit-level Selection}
We first uses two gated aggregation layers to encode the visit-level health conditions of all visits by aggregating their diagnosis and procedure representations, respectively:
\begin{equation}
\mathbf{v}^d_j = \operatorname{Softmax}({\tanh(\mathbf{D}^{\prime}_j \mathbf{W}^{1}_{d} + \mathbf{b}^1_d)\mathbf{W}^{2}_{d} + b^2_d})^\top {\mathbf{D}^{\prime}_j}
\end{equation}
\begin{equation}
\mathbf{v}^p_j = \operatorname{Softmax}({\tanh(\mathbf{P}^{\prime}_j \mathbf{W}^{1}_{p} + \mathbf{b}^1_p)\mathbf{W}^{2}_{p} + b^2_p})^\top {\mathbf{P}^{\prime}_j}
\end{equation}
where $\mathbf{W}^1_* \in \mathbb{R}^{s \times \delta}$, $\mathbf{b}^1_* \in \mathbb{R}^{\delta}$, $\mathbf{W}^2_* \in \mathbb{R}^{\delta \times 1}$ and $b^2_* \in \mathbb{R}$ are trainable parameters. Then we calculate the visit-level selection score of the past $j$-th visit ($1\le j \le t-1$) by measuring the similarity between it and the current $t$-th visit.
\begin{equation}
c_j = \operatorname{Softmax}({\frac{\mathbf{v}^d_j \cdot \mathbf{v}^d_t + \mathbf{v}^p_j \cdot \mathbf{v}^p_t}{\sqrt{s}}})
\end{equation}
$c_j \in \mathbb{R}$ denotes the selection score of the $j$-th visit.
\subsubsection{Medication-level Selection}
We use the hidden state $\mathbf{M}^{''}_{t,i-1}$ formulated in Eq.(12), which comprehensively encodes the information of diagnoses, procedures and recommended medications, to determine which historical medications $m\in \bigcup_{j=1}^{t-1} \mathcal{M}_{j}$ are reusable in current situation.
We firstly obtain the medication representations of all past visits through the similar process in Section 3.2.1:
\begin{equation}
\mathbf{M}^{'}_j = \operatorname{Enc_m}(\mathbf{M}_j)
\end{equation}
where $\mathbf{M}^{'}_j \in \mathbb{R}^{|\mathcal{M}_j| \times s}$.
Then, we use the hidden state $\hat{\mathbf{M}}_{t,i-1}^{''}$ as the query vector to calculate the selection score along the medication dimension.
The selection score of $k$-th medication in $j$-th visit $\mathcal{M}_{j,k}$ ($1\le j \le t-1$ and $1\le k \le |\mathcal{M}_j|$) is
\begin{gather}
q_{j,k} = \frac{\exp (\hat{q}_{j,k})}{\sum_{j=1}^{t-1} \sum_{k=1}^{|\mathcal{M}_j|} \exp (\hat{q}_{j,k})} \\
\hat{q}_{j,k} = \frac{ (\hat{\mathbf{M}}_{t,i-1}^{''} \textbf{W}_c) \cdot \mathbf{M}^{'}_{j,k}}{\sqrt{s}}
\end{gather}
where $\textbf{W}_c \in \mathbb{R}^{s \times s}$ is a learnable parameter.
$q_{j,k} \in \mathbb{R}$ denotes the medication-level selection score.
\subsubsection{Copy Mechanism}
We combine the visit-level and medication-level scores to determine the copy probability of each medication in past visits.
Moreover, since a medication $m_i\in \mathcal{M}$ may be used in multiple past prescriptions, we gather its final copy probability as follows:
\begin{gather}
p^{(i)}_c = \frac{\hat{p}^{(i)}_c}{\sum_{i=1}^{|\mathcal{M}|} \hat{p}^{(i)}_c} \\
\textit{where} \ \ \hat{p}^{(i)}_c = \sum_{j=1}^{t-1} \sum_{k=1}^{|\mathcal{M}_j|} q_{j,k} * c_j * \mathbf{1}_{\{\mathcal{M}_{j,k}=m_i\}}
\end{gather}
where $\mathbf{1}_{\{\mathcal{M}_{j,k}=m_i\}}$ is an indicator function which returns 1 if $\mathcal{M}_{j,k}=m_i$,
and 0 if $\mathcal{M}_{j,k}\ne m_i$.
The copy probabilities of all medications is ${\Pr}_c=[p^{(1)}_c,p^{(2)}_c, ... ,p^{(|\mathcal{M}|)}_c]\in \mathbb{R}^{|\mathcal{M}|}$.
Finally, we combine the generation probabilities and copy probabilities to conduct the prediction.
\begin{gather}
\label{eq:prediction}
\Pr = w_g * {\Pr}_g + (1-w_g)*{\Pr}_c \\
w_g = \operatorname{Sigmoid}(\hat{\mathbf{M}}^{''}_{t,i-1} \mathbf{W}_f + b_f)
\end{gather}
where $\mathbf{W}_f \in \mathbb{R}^{s\times 1}$ and $b_f\in \mathbb{R}$ are learnable parameters.
$\Pr$ denotes the probabilities of all medications in the medication set $\mathcal{M}$ in which the medication with the maximum probability is the predicted $i$-th medication of the $t-$th visit.
\subsection{Training}
We train the model by minimizing regular cross-entropy loss:
\begin{equation}
\mathcal{L}(\theta) = -\sum_{\mathcal{R}}\sum_{t}\sum_{i}\log \Pr (\mathcal{M}_{t,i}|\mathcal{V}_{<t},\mathcal{D}_t,\mathcal{P}_t,\mathcal{M}_{t,<i};\theta)
\end{equation}
where $\mathcal{R}$ is the training EHR set.
$\mathcal{M}_{t,i}$ is the $i$-th medication of the medication set of the $t-$th visit.
$\Pr (\mathcal{M}_{t,i}|\mathcal{V}_{<t},\mathcal{D}_t,\mathcal{P}_t,\mathcal{M}_{t,<i};\theta)$ is the predicted probability of the $\mathcal{M}_{t,i}$ and can be calculated by the Eq.(\ref{eq:prediction}).
$\theta$ denotes all trainable parameters in COGNet.
During the training phase, we use the teacher-forcing to train the model.
Specifically, when predicting the $i$-th medication, the model takes the real $(i-1)$-th medication rather than the predicted $(i-1)$-th medication as the input of the decoder.
At the first step, the input of the decoder is set to a special token $\langle \textit{START}\rangle$.
\begin{table*}[ht]
\caption{Performance Comparison on MIMIC-III. Best results are highlighted in bold. }
\centering
\label{performance}
\begin{tabular}{l|ccccc}
\toprule
Model & Jaccard & F1 & PRAUC & DDI & Avg. \# of Drugs \\
\midrule
\midrule
LR & 0.4865 $\pm$ 0.0021 & 0.6434 $\pm$ 0.0019 & 0.7509 $\pm$ 0.0018 & 0.0829 $\pm$ 0.0009 & 16.1773 $\pm$ 0.0942\\
ECC & 0.4996 $\pm$ 0.0049 & 0.6569 $\pm$ 0.0044 & 0.6844 $\pm$ 0.0038 & 0.0846 $\pm$ 0.0018 & 18.0722 $\pm$ 0.1914\\
\midrule
RETAIN & 0.4887 $\pm$ 0.0028 & 0.6481 $\pm$ 0.0027 & 0.7556 $\pm$ 0.0033 & 0.0835 $\pm$ 0.0020 & 20.4051 $\pm$ 0.2832\\
LEAP & 0.4521 $\pm$ 0.0024 & 0.6138 $\pm$ 0.0026 & 0.6549 $\pm$ 0.0033 & 0.0731 $\pm$ 0.0008 & 18.7138 $\pm$ 0.0666\\
DMNC & 0.4864 $\pm$ 0.0025 & 0.6529 $\pm$ 0.0030 & 0.7580 $\pm$ 0.0039 & 0.0842 $\pm$ 0.0011 & 20.0000 $\pm$ 0.0000\\
GAMENet & 0.5067 $\pm$ 0.0025 & 0.6626 $\pm$ 0.0025 & 0.7631 $\pm$ 0.0030 & 0.0864 $\pm$ 0.0006 & 27.2145 $\pm$ 0.1141\\
MICRON & 0.5100 $\pm$ 0.0033 & 0.6654 $\pm$ 0.0031 & 0.7687 $\pm$ 0.0026 & 0.0641 $\pm$ 0.0007 & 17.9267 $\pm$ 0.2172\\
SafeDrug & 0.5213 $\pm$ 0.0030 & 0.6768 $\pm$ 0.0027 & 0.7647 $\pm$ 0.0025 & \textbf{0.0589 $\pm$ 0.0005} & 19.9178 $\pm$ 0.1604\\
\midrule
\textbf{COGNet} & \textbf{0.5336 $\pm$ 0.0011} & \textbf{0.6869 $\pm$ 0.0010} & \textbf{0.7739 $\pm$ 0.0009} & 0.0852 $\pm$ 0.0005 & 28.0903 $\pm$ 0.0950 \\
\bottomrule
\end{tabular}
\end{table*}
\begin{table}[ht]
\caption{Statistics of processed MIMIC-III. \label{fig:data_stats}}
\centering
\label{statistic}
\begin{tabular}{l|l}
\toprule
\textbf{Item} & \textbf{Number} \\
\midrule
\midrule
\# of visits / \# of patients & 14,995 / 6,350 \\
diag. / prod. / med. space size & 1,958 / 1430 / 131\\
avg. / max \# of visits & 2.37 / 29\\
avg. / max \# of diagnoses per visit & 10.51 / 128\\
avg. / max \# of procedures per visit & 3.84 / 50\\
avg. / max \# of medications per visit & 11.44 / 65\\
total \# of DDI pairs & 448\\
\bottomrule
\end{tabular}
\end{table}
\subsection{Inference}
During the inference phase, inspired by the medication recommendation method~\cite{LEAP} and some NLP generation methods~\cite{DBLP:conf/nlpcc/ZhouYWTBZ17,DBLP:conf/emnlp/NemaMKSR19,DBLP:conf/coling/QiuWF20}, we use the beam search trick to improve the performance.
Different from the greedy search which only selects one best candidate as the partially generated medication combination for each decoding step, the beam search algorithm selects multiple alternatives at each decoding step based on conditional probability.
\section{Experiments}
In this section, we first introduce the experimental setups. Then we conduct some experiments to demonstrate the effectiveness of our COGNet model\footnote{https://github.com/BarryRun/COGNet}.
\subsection{Dataset}
We use the Medical Information Mart for Intensive Care (MIMIC-III)\footnote{https://mimic.physionet.org/}\cite{Johnson2016MIMICIIIAF} dataset released on PhysioNet.
It contains a total of 46520 patients and 58976 hospital admissions from 2001 to 2012.
For a fair comparison, we use the data processing script \footnote{https://github.com/ycq091044/SafeDrug} released by \cite{safedrug} and take the processed data as our benchmark. Details of the processing can be found in Appendix.
Table~\ref{fig:data_stats} shows some statistics on the processed data.
\begin{figure*}[t]
\centering
\includegraphics[width=\linewidth]{figures/visit.pdf}
\caption{The line charts show the effect of number of visits for various models. }
\label{fig:visits}
\end{figure*}
\subsection{Baselines and Metrics}
We evaluate the performance of our approach by comparing it with several baseline methods.
\begin{itemize}
\item \textbf{LR}, standard Logistic Regression;
\item \textbf{ECC}~\cite{ecc}, Ensemabled Classifier Chain, which uses a multi-hot vector to encode the diagnosis and procedure sets and leverage multiple SVM classifiers to make multi-label prediction;
\item \textbf{RETAIN}~\cite{retain}, which uses the attention and gate mechanism to improve the prediction interpretability;
\item \textbf{LEAP}~\cite{LEAP}, which uses the LSTM based generation model to conduct medication recommendation based on the diagnose information;
\item \textbf{DMNC}~\cite{dmnc}, which proposes a new memory augmented neural network model to improve the patient encoder;
\item \textbf{GAMENet}~\cite{gamenet}, which further combines the memory network and graph neural network to recommend the medication combinations;
\item \textbf{MICRON}~\cite{changematter}, which first uses an recurrent residual learning model to predict the medication changes and then conducts medication recommendation based on the medication changes and the medication combination of the last visit;
\item \textbf{SafeDrug}~\cite{safedrug}, which combines the drug molecular graph and DDI graph to predict the safe medication combination.
\end{itemize}
Following the previous medication recommendation work~\cite{gamenet,safedrug,changematter}, we use Jaccard Similarity Score (Jaccard), Average F1 (F1), Precision Recall AUC (PRAUC), and DDI Rate as our evaluation metrics. Each metric is averaged over all patients. The metric definitions can be found in Appendix.
\begin{table*}
\caption{Ablation Study for Different Components of COGNet on MIMIC-III.}
\centering
\label{ablation}
\begin{tabular}{l|ccccc}
\toprule
Model & Jaccard & F1 & PRAUC & DDI & Avg. \# of Drugs \\
\midrule
\midrule
COGNet \textit{w/o Copy} & 0.5163 $\pm$ 0.0010 & 0.6713 $\pm$ 0.0009 & 0.7637 $\pm$ 0.0018 & 0.0842 $\pm$ 0.0005 &28.3139 $\pm$ 0.0766 \\
COGNet \textit{w/o $c_i$} & 0.5119 $\pm$ 0.0016 & 0.6629 $\pm$ 0.0014 & 0.7588 $\pm$ 0.0014 & 0.0813 $\pm$ 0.0005 & 26.8944 $\pm$ 0.0953 \\
COGNet \textit{w/o $G$} & 0.5306 $\pm$ 0.0013 & 0.6836 $\pm$ 0.0012 & 0.7706 $\pm$ 0.0013 & 0.0840 $\pm$ 0.0002 & 29.1076 $\pm$ 0.0795 \\
COGNet \textit{w/o $\mathcal{D}$} & 0.4937 $\pm$ 0.0011 & 0.6496 $\pm$ 0.0011 & 0.7443 $\pm$ 0.0014 & 0.0887 $\pm$ 0.0004 & 28.0519 $\pm$ 0.0995\\
COGNet \textit{w/o $\mathcal{P}$} & 0.5117 $\pm$ 0.0010 & 0.6669 $\pm$ 0.0010 & 0.7625 $\pm$ 0.0016 & 0.0831 $\pm$ 0.0002 & 28.9554 $\pm$ 0.0885 \\
COGNet \textit{w/o BS} & 0.5266 $\pm$ 0.0021 & 0.6805 $\pm$ 0.0019 & 0.7729 $\pm$ 0.0013 & 0.0840 $\pm$ 0.0004 & 28.5592 $\pm$ 0.0701 \\
\midrule
\textbf{COGNet} & \textbf{0.5336 $\pm$ 0.0011} & \textbf{0.6869 $\pm$ 0.0010} & \textbf{0.7739 $\pm$ 0.0009} & 0.0852 $\pm$ 0.0005 & 28.0903 $\pm$ 0.0950 \\
\bottomrule
\end{tabular}
\end{table*}
\subsection{Result Analysis}
\subsubsection{Overall Comparison}
Table~\ref{performance} shows the results of all methods. Overall, our proposed model COGNet outperforms all baselines with the higher Jaccard, F1 and PRAUC.
The performances of LR, ECC and LEAP are poor as they are instance-based models that only consider the diagnoses and procedures in the current visit.
RETAIN, DMNC, GAMENet, SafeDrug and MICRON perform relatively better because they preserve longitudinal patient information in different ways.
RETAIN and DMNC only encode the patients' historical information, while GAMENet introduces additional graph information and SafeDrug incorporates the drug molecule structures in medication recommendation, resulting in a further performance improvement.
MICRON also notices that some medications in the current visit keeps consistent with the last visit and uses the recurrent residual method to inherit the unchanged part.
However, it fails to consider the correlations among the recommended medications and the recurrent like method is hard to model the long range visit information.
Hence, COGNet performs better than MICRON.
SafeDrug achieves a lower DDI rate by introducing the additional drug molecule information.
However, the MIMIC-III dataset itself has an average DDI of 0.08379 and our COGNet has a similar performance.
It suggests that COGNet mimics the behavior of physicians in prescribing medications well.
\subsubsection{Effect of number of visits}
To further explore whether our COGNet can better capture historical medication information, we investigate the impact of the number of visits on the performance of different models.
Since most patients in MIMIC visit the hospital less than five times, we take the first five visits for each patient in the test set to conduct the analysis.
As a comparison, we also take the two strongest baselines SafeDrug and MICRON, which also incorporate historical information, to conduct the analysis.
Figure~\ref{fig:visits} shows the results.
We can see that COGNet achieves relatively better performance with more visits, while the performance of SafeDrug almost stays flat and MICRON shows a decreasing trend.
The reason may be that COGNet uses the attention based hierarchical selection mechanism, which can more effectively incorporate the information of past visits than RNN like mechanism used in SafeDrug.
Moreover, MICRON iteratively updates the past medication combination to form the new medication set, which will be affected by the error accumulation problem.
\subsection{Ablation Study}
To verify the effectiveness of each module of COGNet, we design the following ablation models:
\begin{itemize}
\item COGNet \textit{w/o Copy}: We remove the copy module, which means changing the Eq.(\ref{eq:prediction}) to $\Pr = \Pr_g$.
\item COGNet \textit{w/o $c_i$}: We maintain the copy module but remove the visit-level selection by changing the $q_{j,k} c_j$ in Eq.(21) to $q_{j,k}$.
\item COGNet \textit{w/o $G$}: We remove the EHR and DDI graphs in decoder, which means changing the Eq.(\ref{eq:med emb combine}) to $\hat{\mathbf{M}}_t = \hat{\mathbf{M}}_t^m$.
\item COGNet \textit{w/o $\mathcal{D}$}: We remove the diagnoses information in each visit.
\item COGNet \textit{w/o $\mathcal{P}$}: We remove the procedures information in each visit.
\item COGNet \textit{w/o BS}. We use the greedy search strategy in the inference phase rather than beam search.
\end{itemize}
Table~\ref{ablation} shows the results for the different variants of COGNet.
As expected, the results of COGNet \textit{w/o Copy} indicate that the copy mechanism brings a significant improvement to the basic model.
COGNet can improve the medication recommendation by replicating historical drugs.
COGNet \textit{w/o $c_i$} illustrates the effectiveness of visit-level selection scores.
Both COGNet \textit{w/o $\mathcal{D}$} and COGNet \textit{w/o $\mathcal{P}$} yield poor results among all ablation models, which suggest that diagnosis and procedure information play a great role in medication recommendation. The results of COGNet \textit{w/o $G$} and COGNet \textit{w/o BS} indicate that graphs and beam search also have contributions to the final result. Overall, the complete COGNet outperforms all ablation models, which means each component of our model is integral.
\begin{figure}
\centering
\includegraphics[width=\linewidth]{figures/case_study_v3.pdf}
\caption{The example for case study. The table in the bottom shows the records of the patient and the red color indicates that the corresponding medication can be copied. The $\surd$ symbol means the corresponding recommendation is correct.}
\label{fig:case study}
\end{figure}
\subsection{Case Study}
We present an example patient in MIMIC-III to illustrate how COGNet conducts the copy mechanism to improve medication recommendation.
This patient visited the hospital twice. At the first time, the patient was mainly diagnosed with pneumonia, septicemia, sepsis, etc. Later, the patient returned for a second visit. In addition to the previously diagnosed diseases, the patient also had some new diseases, like gastroesophageal laceration and gastric ulcer. The table in Fig~\ref{fig:case study} shows the details. Due to space constraints, we use International Classification of Diseases (ICD)\footnote{\url{http://www.icd9data.com/}} codes to represent diagnosis results and Anatomical Therapeutic Chemical (ATC)\footnote{\url{https://www.whocc.no/atc/structure_and_principles/}} classification system to represent medications.
As shown in Figure~\ref{fig:case study}, we visualize the copy probability $\Pr_c$ computed by Eq.(20) at each decoding step of recommending the medications for the second visit.
We can see that some reusable medications, like A11D, N07B and H03A, are correctly copied by assigning high probabilities to them in previous visit.
In addition, some new drugs, like J01C and R03A, can also be appropriately generated.
It indicates that COGNet can not only copy historical drugs according to unhealed diseases, but also generate new drugs based on new diagnosis results.
The visualization results also hint that COGNet can provide a good way for the interpretation of the medication recommendation process.
\section{Related Work}
\subsection{Medication Recommendation}
Due the clinical value, medication recommendation has received increasing attention in recent years. According to the used information, existing approaches can be broadly categorized into rule-based, instance-based, and longitudinal methods.
\subsubsection{Rule-based Methods} Rule-based methods \cite{almirall2012designing, ChenMSGT16, gunlicks2016pilot,LakkarajuR17} rely on the human-designed recommendation protocols. For example, Gunlicks-Stoessel et al. \cite{gunlicks2016pilot} attempts to recommend porper treatments for adolescent depression based on rules.
However, these methods require a lot of effort from clinicians and lack generalization.
\subsubsection{Instance-based Methods} Instance-based methods~\cite{LEAP,gong2021smr} only take the information of current visit as input. For example, Zhang et al.~\cite{LEAP} firstly encode the patient's current diagnose and then use a recurrent decoder to generate the medication recommendations based on the encoded information.
However, they ignore the historical visit information of the patient.
\subsubsection{Longitudinal Methods} These approaches \cite{WangZHZ18, WangRCR0R19, gamenet, changematter, safedrug, premier} use the historical information of patients and explore the sequential dependency between visits.
Most of them basically model the longitudinal patient information by RNNs.
Le \textit{et al.} \cite{dmnc} and Shang \textit{et al.} \cite{gamenet} combine memory networks with RNNs to enhance the memory ability.
Yang \textit{et al.} \cite{safedrug} further incorporate the drugs' molecule information to improve the medication representation learning.
Yang \textit{et al.} \cite{changematter} explicitly model the health condition changes of the patient to enhance the correlations between continuous visits by a recurrent residual learning approach.
However, these methods do not explicitly consider the relationship between the medication recommendations of the same patient and the RNN like methods are hard to handle the long range visit dependency.
\subsection{Graph Neural Network}
Recently, graph neural networks (GNN)~\cite{gcn,zhuang2018dual,hamilton2017inductive,atwood2016diffusion,Velickovic2017,DBLP:conf/recsys/VasileSC16} have received wide attention in many fields.
The convolutional GNN can learn powerful node representations by aggregating the neighbors' features over the graph.
Some works~\cite{gamenet,safedrug} have attempted to leverage the GNN to improve the medication recommendation.
For example, Yang \textit{et al.} \cite{safedrug} take the drugs' molecule structures as graphs and use GNN to learn the better medication representations to improve medication recommendation.
Shang \textit{et al.}~\cite{gamenet} use the GNN to encode the EHR and DDI graphs to introduce the medication correlation information.
In this paper, inspired by ~\cite{gamenet}, we use the GNN to encode the medication co-occurrence and DDI relationships to improve the recommendation.
\section{Conclusion}
In this paper, we proposed a novel medication recommendation model, COGNet, to better leverage historical information from a medication-level perspective. COGNet works under an encoder-decoder based framework and introduces a \textit{copy-or-predict} mechanism to accurately determine whether a historical medication is still relevant at present. Experiment results on the publicly available MIMIC-III dataset demonstrate that COGNet outperforms existing medication recommendation methods. We also investigate the impact of number of visits on the performance, which shows that COGNet can effectively incorporate the information of multiple past visits.
Further ablation study results also suggest the effectiveness of each module of COGNet.
\begin{acks}
This work was supported by National Key R\&D Program of China, No. 2018YFC0117000.
This work was also partially supported by Natural Science Foundation of China grant, No. U21A20488.
\end{acks}
\bibliographystyle{ACM-Reference-Format}
|
{'timestamp': '2022-02-21T02:08:44', 'yymm': '2202', 'arxiv_id': '2202.06588', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06588'}
|
arxiv
|
\section{Introduction} \label{ref:intro}
\begin{figure}[ht]
\centering
\includegraphics[clip,width=0.8\linewidth]{figures/final-pos-neg-margin.pdf}
\caption{\label{fig:idea} Starting from a query paper \queryIcon in a citation graph embedding space. Hard positives \posIcon are citation graph embeddings that are sampled from a similar (close) context of\queryIcon, but are not so close that their gradients collapse easily. Hard (to classify) negatives \negIconHard (red band) are close to positives (green band) up to a \emph{sampling induced margin}. Easy negatives \negIcon are very dissimilar (distant) from the query paper \queryIcon.}
\end{figure}
Large pretrained language models (LLMs) achieve state-of-the-art results through fine-tuning on many NLP tasks \cite{BERTOLOGY}.
However, the sentence or document embeddings derived from LLMs are of lesser quality compared to simple baselines like GloVe \cite{Reimers2019}, %
as their embedding space suffers from being anisotropic, i.e.\ poorly defined in some areas \cite{Li2020}.
One approach that has recently gained attention is the combination of LLMs with contrastive fine-tuning to improve the semantic textual similarity between document representations \cite{Wu2020,Gao2021}. These contrastive methods learn to distinguish between pairs of similar and dissimilar texts. As part of metric learning, they traditionally focused on defining new loss functions, while \citet{MetricLearningReality} showed that newer metric losses lead to insignificant performance gains when compared fairly. Instead, recent works on self and supervised contrastive learning has started to focus on developing techniques that generate better positive and negative data augmentations for efficient contrastive learning \cite{MI_views,Rethmeier2021,rethmeier2021dataefficient,TextAugemntations}.
In this paper, we focus on learning scientific document representations (SDRs). The core distinguishing feature of this domain is the presence of citation information.
SDR methods like SciBERT \cite{Beltagy2019} pretrain a Transformer on domain-specific text but neglect citations.
The current state-of-the-art by \citet{Cohan2020} uses discrete citation information to generate positive and negative samples for contrastive fine-tuning of SciBERT via a triplet loss \cite{TripletLossORG}.
Cited papers are used to generate positive samples, while non-cited papers are negative samples.
This discrete cut-off to similarity is counter-intuitive to (continuous) similarity-based learning.
It encourages overfitting to human similarity annotations, i.e. citations, which may reflect politeness and policy rather than semantic similarity \cite{Pasternack1969}.
Such sample generation may also cause positive and negative samples to collide, e.g.\ \citet{ContrastiveLearningLimitations} have shown that generating more negatives harms contrastive optimization performance if collision are not avoided.
Instead, the generation of \emph{non-colliding} contrastive samples should be based on a continuous similarity function that allow us to find semantically similar papers, despite a lack of direct citation. %
\paragraph{Contributions:}
\begin{itemize}[noitemsep]
\item%
{We propose neighborhood contrastive learning for scientific document representations with citation graph embeddings (\sys).} %
\item%
{We sample similar and dissimilar papers from neighboring citation graph embeddings, such that both are hard to learn to avoid long training times and gradient collapse.}
\item{As in recent contrastive learning works, we address sample generation semantics based on contrastive learning theory insights rather than designing new loss functions.}
\item{We compare against the state-of-the-art approach SPECTER \cite{Cohan2020} and other strong methods on the \textsc{SciDocs}\xspace benchmark and find that \sys outperforms SPECTER on average and on 9 of 12 metrics.}
\item{Finally, we demonstrate that with \sys, using only 1\% of the training data, starting with a general-domain language model, or training only the bias terms of the model is sufficient to outperform the baselines.}
\item{Our code and models are publicly available.\footnote{\label{fn:github} \url{https://github.com/malteos/scincl}}}
\end{itemize}
\section{Related Work} \label{sec:related-work}
\paragraph{Contrastive Learning}\ pulls representations of similar data points (positives) closer together, while representations of dissimilar documents (negatives) are pushed apart.
A common contrastive objective is the triplet loss \cite{TripletLossORG} that \citet{Cohan2020} used for scientific document representation learning, as we describe below. However, as \citet{MetricLearningReality,Rethmeier2021} point out, contrastive objectives work best when specific requirements are respected. \textbf{(Req. 1)} Views of the same data should introduce new information, i.e.\ the mutual information between views should be minimized \cite{MI_views}. We use citation graph embeddings to generate contrast label information that supplements text-based similarity. \textbf{(Req. 2)} For training time and sample efficiency, negative samples should be hard to classify, but should also not collide with positives \cite{ContrastiveLearningLimitations}.
\textbf{(Req. 3)} Recent works like \citet{MetricLearningReality,muliplePositiveCTL1} use multiple positives. However, positives need to be consistently close to each other \cite{PositivesSimilarImportant}, since positives and negatives may otherwise collide, e.g., \citet{Cohan2020} consider only `citations by the query' as similarity signal and not `citations to the query'.
Such unidirectional similarity does not guarantee that a negative paper (not cited by the query) may cite the query paper and thus could cause collisions, the more we sample.
Our method treats both citing and being cited as positives (Req. 2), while it also generates hard negatives and hard positives (Req. 2+3). Hard negatives are close to but do not overlap positives (red band in \cref{fig:idea}). Hard positives are close, but not trivially close to the query document (green band in \cref{fig:idea}).
\paragraph{Scientific Document Representations}
based on Transformers~\cite{Vaswani2017} and pretrained on domain-specific text dominate today's scientific document processing.
There are SciBERT \cite{Beltagy2019}, BioBERT \cite{Lee2019} and SciGPT2 \cite{Luu2021}, to name a few. %
Recent works modify these domain LLMs to support cite-worthiness detection \cite{wright2021citeworth}, similarity \cite{Ostendorff2020c} or fact checking \cite{Wadden2020}.
Aside from text, citations are a valuable signal for the similarity of research papers.
Paper (node) representations can be learned using the citation graph \cite{Wu2019,Perozzi2014,Grover2016}.
Especially for recommendations of papers or citations, hybrid combinations of text and citation features are often employed \cite{Han2018,Jeong2020ACC,Molloy2020,Farber2020,holm2022longitudinal}.
Closest to \sys are Citeomatic \cite{Bhagavatula2018} and SPECTER \cite{Cohan2020}.
While Citeomatic relies on bag-of-words for its textual features, SPECTER is based on SciBERT.
Both leverage citations to learn a triplet-based document embedding model, whereby positive samples are papers cited in the query.
Easy negatives are random papers not cited by the query.
Hard negatives are citations of citations -- papers referenced in positive citations of the query, but are not cited directly by it.
Citeomatic also uses a second type of hard negatives, which are the nearest neighbors of a query that are not cited by it.
Unlike our approach, Citeomatic does not use the neighborhood of citation embeddings, but instead relies on the actual document embeddings from the previous epoch.
Despite being related to \sys, the sampling approaches employed in Citeomatic and SPECTER do not account for the pitfalls of using discrete citations as signal for paper similarity.
Our work addresses this issue.
\paragraph{Triple Mining} remains a challenge in NLP due to the discrete nature of language which makes data augmentation less trivial as compared to computer vision \cite{Gao2021}.
Examples for augmentation strategies are: translation \cite{Fang2020}, or word deletion and reordering \cite{Wu2020}.
Positives and negatives can be sampled based on the sentence position within a document \cite{Giorgi2021}.
\citet{Gao2021} utilize supervised entailment datasets for the triple generation.
Language- and text-independent approaches are also applied:
\citet{Kim2021} use intermediate BERT hidden state for positive sampling and \citet{Wu2021} add noise to representations to obtain negative samples.
\citet{Xiong2020} present an approach similar to \sys where they sample hard negatives from the k nearest neighbors in the embedding space derived from the previous model checkpoint.
While \citeauthor{Xiong2020} rely only on textual data,
\sys integrates also citation information which are especially valuable in the scientific context as \citet{Cohan2020} have shown.
\section{Methodology} \label{sec:methodology}
Our goal is to learn task-independent representations for scientific documents. To do so we sample three document representation vectors and learn their similarity. For a given query paper vector $\vd^{Q}$, we sample a positive (similar) paper vector $\vd^{+}$ and a negative (dissimilar) paper vector $\vd^{-}$. This produces a `query, positive, negative' triple $(\vd^{Q},\vd^{+},\vd^{-})$ -- represented by (\queryIcon,\posIcon,\negIcon) in \cref{fig:idea}. To learn paper similarity, we need to define three components: (\cref{ssec:cl-objective}) how to calculate document vectors ${\bm{d}}$ for the loss over triplets $\mathcal{L}$; (\cref{ssec:CGEmbeddings}) how citations provide similarity between papers; and (\cref{ssec:neg_pos_sampling}) how negative and positive papers $(\vd^{-},\vd^{+})$ are sampled as (dis-)similar documents from the neighborhood of a query paper $\vd^{Q}$.
\subsection{Contrastive Learning Objective} \label{ssec:cl-objective} %
Given the textual content of a document $d$ (paper), the goal is to derive a dense vector representation ${\bm{d}}$ that best encodes the document information and can be used in downstream tasks.
A Transformer language model $f$ (SciBERT; \citet{Beltagy2019}) encodes documents $d$ into vector representations $f(d)={\bm{d}}$.
The input to the language model is the title and abstract separated by the \texttt{[SEP]} token.\footnote{\citet{Cohan2019} evaluated other inputs (venue or author) but found the title and abstract to perform best.}
The final layer hidden state of the \texttt{[CLS]} token is then used as a document representation $f(d)={\bm{d}}$.
Training with a masked language modeling objectives alone has been shown to produce sub-optimal document representations \cite{Li2020,Gao2021}. Thus, similar to the SDR state-of-the-art method SPECTER \cite{Cohan2020}, we continue training the SciBERT model \cite{Beltagy2019} using a self-supervised triplet margin loss \cite{TripletLossORG}:
\begin{equation*}
\mathcal{L}=
\max\Big\{
\lVert \vd^{Q}{-}\vd^{+} \lVert_2{-}\lVert \vd^{Q}{-}\vd^{-} \lVert_2
+ \xi,0\Big\}
\label{eq:loss}
\end{equation*}
\noindent Here, $\xi$ is a slack term ($\xi=1$ as in SPECTER) and $\lVert\Delta{\bm{d}}\lVert_2$ is the $L^2$ norm, used as a distance function. However, the SPECTER sampling method has significant drawbacks. We will describe these issues and our contrastive learning theory guided improvements in detail below in \cref{ssec:CGEmbeddings}.
\subsection{Citation Neighborhood Sampling} \label{ssec:CGEmbeddings}
Compared to the textual content of a paper, citations provide an outside view on a paper and its relation to the scientific literature \cite{Elkiss2008}, which is why citations are traditionally used as a similarity measure in library science \cite{Kessler1963,Small1973}.
However, using citations as a discrete similarity signal, as done in \citet{Cohan2020}, has its pitfalls. Their method defines papers cited by the query as positives, while paper citing the query could be treated as negatives. This means that \emph{positive and negative learning information collides} between citation directions, which \citet{ContrastiveLearningLimitations} have shown to deteriorate performance.
Furthermore, a cited paper can have a low similarity with the citing paper given the many motivations a citation can have \cite{Teufel2006}.
Likewise, a similar paper might not be cited.
To overcome these limitations, we learn citation embeddings first and then use the citation neighborhood around a given query paper $d^Q$ to construct similar (positive) and dissimilar (negative) samples for contrast by using neighborhood information from either \textsc{kNN}\xspace (I) or a distance metric \textsc{Sim}\xspace (II-IV) as detailed in \cref{ssec:neg_pos_sampling}.
This builds on the intuition that nodes connected by edges should be close to each other in the embedding space \cite{Perozzi2014,Grover2016}. Using citation embeddings allows us to: (1) sample paper similarity on a continuous scale, which makes it possible to: (2) define hard to learn positives, as well as (3) hard or easy to learn negatives. Points (2-3) are important in making contrastive learning efficient as will describe below in \cref{ssec:neg_pos_sampling}.
\subsection{Positives and Negatives Sampling}\label{ssec:neg_pos_sampling}
\paragraph{Positive samples:} $d^{+}$ should be semantically similar to the query paper $d^{Q}$, i.e.\ sampled close to the query embedding $\vd^{Q}$. Additionally, as \citet{PositivesSimilarImportant} find, positives should be sampled from comparable locations (distances from the query) in embedding space and be dissimilar enough from the query embedding, to avoid gradient collapse (zero gradients).
Therefore, we sample $c^{+}$ positive (similar) papers from a close neighborhood around query embedding $\vd^{Q}$ $(k^{+}-c^{+},k^{+}]$,
i.e.\ the green band in \cref{fig:idea}. When sampling from \textsc{kNN}\xspace neighbors, we use a small $k^{+}$ to find positives and later analyze the impact of $k^{+}$ in \cref{fig:easy_pos}.
\paragraph{Negative samples:}
can be divided into easy \negIcon and hard \negIconHard negative samples (light and dark red in \cref{fig:idea}). Sampling more hard negatives is known to improve contrastive learning \cite{Bucher2016,Wu2017}.
However, we make sure to sample hard negatives (red band in \cref{fig:idea}) such that they are close to potential positives but do not collide with positives (green band), by using a tunable `sampling induced margin'.
We do so, since \citet{ContrastiveLearningLimitations} showed that sampling a larger number of hard negatives only improves performance \emph{if the negatives do not collide with positive samples}, since collisions make the learning signal noisy.
That is, in the margin between hard negatives and positives we expect positives and negatives to collide, thus we avoid sampling from this region. To generate a diverse self-supervised citation similarity signal for contrastive SDR learning, we also sample easy negatives that are farther from the query than hard negatives.
For negatives, the $k^{-}$ should be large when sampling via \textsc{kNN}\xspace
to ensure samples are dissimilar from the query paper.
\subsection{Sampling Strategies} \label{sssec:sampling-strategies} \label{ssec:triplet-minig}
As described in \cref{ssec:CGEmbeddings} and \cref{ssec:neg_pos_sampling}, our approach improves upon the method by \citet{Cohan2020}. Therefore, we reuse their sampling parameters (5 triples per query paper) and then further optimize our methods' hyperparameters.
For example, to train the triplet loss, we generate the same amount of $(\vd^{Q}, \vd^{+}, \vd^{-})$ triples per query paper as SPECTER \cite{Cohan2020}. To be precise, this means we generate $c^{+}{=}5$ positives (as explained in \cref{ssec:neg_pos_sampling}). We also generate 5 negatives, three easy negatives $c^{-}_{\text{easy}}{=}3$ and two hard negatives $c^{-}_{\text{hard}}{=}2$, as described in \cref{ssec:neg_pos_sampling}.
Below, we describe four strategies (I-IV) for sampling triplets. These either sample neighboring papers from citation embeddings (I-II), by random sampling (III), or using both strategies (IV). For each strategy, let $c'$ be the number of samples for either positives $c^{+}$, easy negatives $c^{-}_{\text{easy}}$, or hard negatives $c^{-}_{\text{hard}}$.
\paragraph{Citation Graph Embeddings:}
We train a graph embedding model $f_c$ on citations extracted from the Semantic Scholar Open Research Corpus \citep[S2ORC; ][]{Lo2020} to get citation embeddings $C$.
We utilize PyTorch BigGraph \cite{Lerer2019}, which allows for training on large graphs with modest hardware requirements.
The resulting graph embeddings perform well using the default training settings from \citet{Lerer2019}, but given more computational resources, careful tuning may produce even better-performing embeddings.
Nonetheless, we conducted a narrow parameter search based on link prediction -- see Appendix~\ref{ssec:graph-evaluation}.
\paragraph{(I) K-nearest neighbors (\textsc{kNN}\xspace):}
Assuming a given citation embedding model $f_c$ and a search index (e.g., FAISS \cref{ssec:Train_implement}), we run $KNN(f_c(d^{Q}), C)$ and take $c'$ samples from a range of the $(k-c',k]$ nearest neighbors around the query paper
$d^{Q}$ with its neighbors $N{=}\{n_1,n_2,n_3,\dots\}$, whereby neighbor $n_i$ is the $i$-th nearest neighbor citation.
For instance, for $c'{=}3$ and $k{=}10$ the corresponding samples would be the three neighbors descending from the tenth neighbor: $n_8$, $n_9$, and $n_{10}$.
To reduce computing effort, we sample the neighbors $N$ only once via $[0;\max(k^{+},k^{-}_{\text{hard}})]$, and then generate triples by range-selection in $N$; i.e.\ positives $=(k^{+}-c^{+};k^{+}]$, and hard negatives $=(k^{-}_{\text{hard}}-c^{-}_{\text{hard}};k^{-}_{\text{hard}}]$.
\paragraph{(II) Similarity threshold (\textsc{Sim}\xspace):}
Take $c'$ papers that are within the similarity threshold $t$ of a query paper $d^{Q}$ such that
$s(f_c(d^{Q}),f_c(d_i))<t$, where $s$ is the cosine similarity function.
For example, given the similarity scores $S{=}\{0.9,0.8,0.7,0.1\}$ (ascending order, the higher the similarity is the closer the candidate embedding to the query embedding is) with $c'{=}2$ and $t{=}0.5$, the two candidates with the largest similarity scores and larger than the threshold would be $0.8$ and $0.7$.
The corresponding papers would be selected as samples.
While the positive threshold $t^+$ should close to 1, the negative threshold $t^-$ should be small
to ensure samples are dissimilar from $d^{Q}$.
\paragraph{(III) Random sampling}
Sample any $c'$ papers without replacement from the corpus.
\paragraph{(IV) Filtered random}
Like (III) but excluding the papers that are retrieved by \textsc{kNN}\xspace or \textsc{Sim}\xspace, i.e., all neighbors within the largest $k$ or $n_i$ with $i{<=}k$ are excluded.
\vspace{0.25cm}
The \textsc{kNN}\xspace and \textsc{Sim}\xspace sampling strategies introduce hyperparameters ($k$ or $t$) that allow for the \emph{controlled sampling of positives or negatives} with different difficulty (from easy to hard depending on the hyperparameter).
Specifically, in \cref{fig:idea} these hyperparameters define the tunable \emph{sample induced margin} between positives and negatives, as well as the width and position of the positive sample band (green) and negative sample band (red) around the query sample.
Besides the strategies above, we experiment with k-means clustering and sorted random sampling, neither of which performs well (see negatives results in Appendix~\ref{ssec:negative-results}).
\section{Experiments} \label{sec:experiments}
We next introduce our experimental setting including the data used for training and evaluation, as well as implementation details.
\subsection{Evaluation Dataset}
We evaluate the document representations on the \textsc{SciDocs}\xspace benchmark \cite{Cohan2020}.
A key difference to other benchmarks is that embeddings are the input to the individual tasks without explicit fine-tuning.
The \textsc{SciDocs}\xspace benchmark consists of the following four tasks:
\textbf{Document classification} (CLS) with labels from Medical Subject Headings (MeSH) \cite{Lipscomb2000MedicalSH} and Microsoft Academic Graph (MAG) \cite{Sinha2015AnOO} evaluated with the F1 metric.
\textbf{Co-views and co-reads} (USR) prediction based on the L2 distance between embeddings.
Co-views are papers viewed in a single browsing session.
Co-read refers to a user accessing the PDF of a paper.
Both user activities are evaluated using Mean Average Precision (\textsc{map}\xspace) and Normalized Discounted Cumulative Gain (n\textsc{dcg}\xspace).
\textbf{Direct and co-citation} (CITE) prediction based on the L2 distance between the embeddings.
\textsc{map}\xspace and n\textsc{dcg}\xspace are the evaluation metrics.
\textbf{Recommendations} (REC) generation based on embeddings and paper metadata to rank a set of ``similar papers'' for a given paper. An offline evaluation with historical clickthrough data determines the performance using Precision@1 (P@1) and n\textsc{dcg}\xspace.
\subsection{Training Data} \label{ssec:training-data}
With our experiments, we mainly compare against SPECTER \cite{Cohan2020} on the \textsc{SciDocs}\xspace benchmark.
However, we found 40.5\% of \textsc{SciDocs}\xspace's papers leaking into SPECTER's training data (\cref{ssec:leakage}).
To be transparent about this leakage, we conduct experiments with two training datasets: (1) a replication of SPECTER's training data and (2) a random subset of S2ORC.
With (1), we replicate the training data from SPECTER as closely as possible including its leakage.
Unfortunately SPECTER's data does not provide a mapping to S2ORC which is the basis for our citation embedding model.
Citation embeddings based on SPECTER's data are not feasible since citation data is not provided.
We successfully map 96.2\% of SPECTER's query papers and 83.3\% of the corpus from which positives and negatives are sampled.
To account for the missing papers, we randomly sample papers from S2ORC such that the absolute number of papers is identical with SPECTER.
When we sample from S2ORC we exclude the papers from \textsc{SciDocs}\xspace to not add any additional leakage.
With (2), we select a random subset from S2ORC that does not contain any of the mapped \textsc{SciDocs}\xspace papers.
This avoids SPECTER's leakage but also makes the scores reported in \citet{Cohan2020} less comparable.
We successfully map 98.6\% of the \textsc{SciDocs}\xspace papers to S2ORC.
Thus, only the remaining 1.4\% of the \textsc{SciDocs}\xspace papers could leak into this training set.
The details of the dataset creation are described in Appendix~\ref{s2orc-mapping} and \ref{ssec:dataset-creation}.
Both training sets yield 684K triples (same count as SPECTER).
Also, the ratio of training triples per query remains the same (\cref{sssec:sampling-strategies}).
Our citation embedding model is trained on the S2ORC citation graph.
In (1), we include all SPECTER papers even if they are part of \textsc{SciDocs}\xspace, the remaining \textsc{SciDocs}\xspace papers are excluded (52.5 nodes and 463M edges).
In (2), all mapped \textsc{SciDocs}\xspace papers are excluded (52.4M nodes and 447M edges) such that we avoid leakage also for the citation embedding model.
\subsection{Training and Implementation}\label{ssec:Train_implement}
We replicate the training setup from SPECTER as closely as possible.
We implement \sys using Huggingface Transformers \cite{Wolf2019}, initialize the model with SciBERT's weights \cite{Beltagy2019}, and train via the triplet loss (Equation~\ref{eq:loss}).
The optimizer is Adam with weight decay \cite{Kingma2015,Loshchilov2019} and learning rate $\lambda{=}2^{-5}$.
To explore the effect of computing efficient fine-tuning we also train a BitFit model \cite{Zaken2021} with $\lambda{=}1^{-4}$ (\cref{ssec:data-efficiency}).
We train \sys on two NVIDIA GeForce RTX 6000 (24G) for 2 epochs (approx. 24 hours of training time) with batch size 8 and gradient accumulation for an effective batch size of 32 (same as SPECTER).
The graph embedding training is performed on a Intel Xeon Gold 6230 CPU with 60 cores and takes approx. 6 hours.
The \textsc{kNN}\xspace and \textsc{Sim}\xspace strategies are implemented with FAISS \cite{Johnson2021} using a flat index (exhaustive search) and take less than 30min.
\subsection{Baseline Methods} \label{ssec:baselines}
\begin{table*}[ht!]
\centering
\footnotesize
\setlength{\tabcolsep}{4.7pt}
\renewcommand{\arraystretch}{1.3}
\begin{tabular}{@{}lrrrrrrrrrrrrr@{}}
\toprule
Task $\rightarrow$ & \multicolumn{2}{c}{Classification} & \multicolumn{4}{c}{User activity prediction} & \multicolumn{4}{c}{Citation prediction} & \multicolumn{2}{c}{\multirow{2}{*}{\begin{tabular}{@{}c@{}}Recomm.\end{tabular}}} &
\multirow{3}{*}{\begin{tabular}{@{}c@{}}Avg.\end{tabular}}
\\ \cmidrule(lr){2-3} \cmidrule(lr){4-7} \cmidrule(lr){8-11}
Subtask $\rightarrow$ & MAG & MeSH & \multicolumn{2}{c}{Co-View} & \multicolumn{2}{c}{Co-Read} & \multicolumn{2}{c}{Cite} & \multicolumn{2}{c}{Co-Cite} & \multicolumn{2}{c}{} & \\ \cdashline{1-13}
Model $\downarrow$ / Metric $\rightarrow$ & F1 & F1 & \textsc{map}\xspace & n\textsc{dcg}\xspace & \textsc{map}\xspace & n\textsc{dcg}\xspace & \textsc{map}\xspace & n\textsc{dcg}\xspace & \textsc{map}\xspace & n\textsc{dcg}\xspace & n\textsc{dcg}\xspace & P@1 & \\
\midrule
\textit{Oracle SciDocs}\xspace $\dagger$
& \textit{87.1} & \textit{94.8} & \textit{87.2} & \textit{93.5} & \textit{88.7} & \textit{94.6} & \textit{92.3} & \textit{96.8} & \textit{91.4} & \textit{96.4} & \textit{53.8} & \textit{19.4} & \textit{83.0} \\
Doc2Vec* \citeyearpar{Le2014} & 66.2 & 69.2 & 67.8 & 82.9 & 64.9 & 81.6 & 65.3 & 82.2 & 67.1 & 83.4 & 51.7 & 16.9 & 66.6 \\
fastText-sum* \citeyearpar{Bojanowski2017} & 78.1 & 84.1 & 76.5 & 87.9 & 75.3 & 87.4 & 74.6 & 88.1 & 77.8 & 89.6 & 52.5 & 18.0 & 74.1 \\
ELMo* \citeyearpar{Peters2018} & 77.0 & 75.7 & 70.3 & 84.3 & 67.4 & 82.6 & 65.8 & 82.6 & 68.5 & 83.8 & 52.5 & 18.2 & 69.0 \\
Citeomatic* \citeyearpar{Bhagavatula2018} & 67.1 & 75.7 & 81.1 & 90.2 & 80.5 & 90.2 & 86.3 & 94.1 & 84.4 & 92.8 & 52.5 & 17.3 & 76.0 \\
SGC* \citeyearpar{Wu2019} & 76.8 & 82.7 & 77.2 & 88.0 & 75.7 & 87.5 & 91.6 & 96.2 & 84.1 & 92.5 & 52.7 & 18.2 & 76.9 \\
BERT \citeyearpar{Devlin2019} & 79.9 & 74.3 & 59.9 & 78.3 & 57.1 & 76.4 & 54.3 & 75.1 & 57.9 & 77.3 & 52.1 & 18.1 & 63.4 \\
SciBERT* \citeyearpar{Beltagy2019} & 79.7 & 80.7 & 50.7 & 73.1 & 47.7 & 71.1 & 48.3 & 71.7 & 49.7 & 72.6 & 52.1 & 17.9 & 59.6 \\
BioBERT \citeyearpar{Lee2019} & 77.2 & 73.0 & 53.3 & 74.0 & 50.6 & 72.2 & 45.5 & 69.0 & 49.4 & 71.8 & 52.0 & 17.9 & 58.8 \\
CiteBERT \citeyearpar{wright2021citeworth} & 78.8 & 74.8 & 53.2 & 73.6 & 49.9 & 71.3 & 45.0 & 67.9 & 50.3 & 72.1 & 51.6 & 17.0 & 58.8 \\
SPECTER* \citeyearpar{Cohan2020} & \bf{82.0} & 86.4 & 83.6 & 91.5 & 84.5 & 92.4 & 88.3 & 94.9 & 88.1 & 94.8 & \textbf{53.9}& \bf{20.0} & 80.0 \\
\hdashline
\multicolumn{14}{@{}p{0.8\textwidth}}{\textit{Replicated SPECTER training data (w/ leakage):}} \\
\sys (ours) & 81.4& \textbf{88.7} & \textbf{85.3} & \textbf{92.3} & \textbf{87.5} & \textbf{93.9} & \textbf{93.6} & \textbf{97.3} & \textbf{91.6} & \textbf{96.4} & \textbf{53.9} & 19.3& \textbf{81.8} \\
$\pm\ \sigma$ w/ ten seeds& \textit{.449} & \textit{.422} & \textit{.128} & \textit{.08} & \textit{.162} & \textit{.118} & \textit{.104} & \textit{.054} & \textit{.099} & \textit{.066} & \textit{.203} & \textit{.356} & \textit{.064} \\
\hdashline
\multicolumn{14}{@{}p{0.8\textwidth}}{\textit{Random S2ORC training data (w/o leakage):}} \\
SPECTER & 81.3 & 88.4 & 83.1 & 91.3 & 84.0 & 92.1 & 86.2 & 93.9 & 87.8 & 94.7 & 52.2 & 17.5 & 79.4 \\
\sys (ours) & 81.3 & 89.4 & 84.3 & 91.8 & 85.6 & 92.8 & 91.4 & 96.3 & 90.1 & 95.7 & 54.3 & 19.9 & 81.1 \\
\bottomrule
\end{tabular}
\caption{Results on the \textsc{SciDocs}\xspace benchmark.
With replicated SPECTER training data, our \sys approach surpasses the previous best avg. score by 1.8 points and also outperforms the baselines in 9 of 12 task metrics.
Our scores are reported as mean and standard deviation $\sigma$ over ten random seeds.
With training data randomly sampled from S2ORC, \sys outperforms SPECTER in terms of avg. score with 1.7 points.
The baseline scores with * are taken from \citet{Cohan2020}.
\textit{Oracle SciDocs}\xspace $\dagger$ represents the upper bound of the performance with triples generated based on \textsc{SciDocs}\xspace test and validation data.}
\label{tab:results}
\end{table*}
We compare to \baselineCount prior approaches:
Doc2Vec~\cite{Le2014},
weighted sum of in-domain fastText word embeddings \cite{Bojanowski2017},
averaged contextualized token-level representations from ELMO \cite{Peters2018},
BERT \cite{Devlin2019} a state-of-the-art LLM pretrained on general-domain text,
BioBERT-Base-Cased-v1.2 \cite{Lee2019} a BERT variation for biomedical text,
SciBERT \cite{Beltagy2019} a BERT variation for scientific text,
CiteBERT \cite{wright2021citeworth} a SciBERT variation fine-tuned on cite-worthiness detection,
the graph-convolution approach SGC \cite{Wu2019},
Citeomatic \cite{Bhagavatula2018}, and SPECTER \cite{Cohan2020}.
If not otherwise mentioned, all BERT variations are used in their \texttt{base-uncased} versions.
Also, we include the results of \textit{Oracle SciDocs}\xspace which is identical to SPECTER/\sys except that its triples are generated from the labels of validation and test set of \textsc{SciDocs}\xspace.
For example, papers with the same MAG labels are positives and papers with different labels are negatives. Similarly, the ground truth for the other tasks is used, i.e., clicked recommendations are considered as positives etc.\footnote{We under-sample triples from the classification tasks to ensure a balanced triple distribution over the tasks.}
In total, this procedure creates 106K training triples for \textit{Oracle SciDocs}\xspace.
Accordingly, \textit{Oracle SciDocs}\xspace represents an estimate for the upper bound for the results that can be achieved with the current setting (triplet margin loss and SciBERT encoder).
\section{Overall Results}
\cref{tab:results} shows our main results, comparing \sys with the best validation performance against prior approaches.
With replicated SPECTER training data (w/ leakage), \sys achieves an average performance of 81.8 across all metrics, which is a 1.8 point absolute improvement over SPECTER - the next-best baseline.
When trained on the random subset of S2ORC without any \textsc{SciDocs}\xspace papers (w/o leakage), the improvement of \sys over SPECTER is relative consistent with 1.7 points but generally lower (79.4 avg. score).
In the following, we refer to the results obtained through training on the replicated SPECTER data (w/ leakage) if not otherwise mentioned.
We find the best validation performance based on SPECTER's data when positives and hard negative are sampled with \textsc{kNN}\xspace, whereby positives are $k^{+}{=}25$, and hard negatives are $k^{-}_{\text{hard}}{=}4000$ (\cref{sec:hyperparameter-analysis}).
Easy negatives are generated through filtered random sampling.
As random sampling accounts for a large fraction of the triples (in the form of easy negatives), we report the mean scores and standard deviation based on ten random seeds ($\text{seed}\in[0,9]$).
For MAG classification, SPECTER achieves the best result with 82.0 F1 followed by \sys with 81.4 F1 (-0.6 points).
For MeSH classification, \sys yields the highest score with 88.7 F1 (+2.3 compared to SPECTER).
Both classification tasks have in common that the chosen training settings lead to over-fitting.
Changing the training by using only 1\% training data, \sys yields 82.2 F1@MAG (\cref{tab:ablation}). %
In all user activity and citation tasks, \sys yields higher scores than all baselines.
It is notable that \sys also outperforms SGC on direct citation prediction, where SGC outperforms SPECTER in terms of n\textsc{dcg}\xspace.
On the recommender task, SPECTER yields the best P@1 with 20.0, whereas \sys is slightly worst with 19.3 P@1 (in terms of n\textsc{dcg}\xspace \sys and SPECTER are on par).
When training SPECTER and \sys without leakage, \sys outperforms SPECTER even in 11 of 12 metrics and is on par in the other metric.
This suggests that \sys's hyperparameters have a low corpus dependency since they were only optimized on the corpus with leakage.
Regarding the LLM baselines, we observe that the general-domain BERT, with a score of 63.4, outperforms the domain-specific BERT variants, namely SciBERT (59.6), BioBERT (58.8), and CiteBERT (58.8).
Still, all LLMs without contrastive objectives yield substantially worse results (even compared to Doc2Vec or fastText).
This emphasizes the anisotropy problem of embeddings directly extracted from current LLMs. %
In summary, we show that \sys's triple selection leads on average to a performance improvement on \textsc{SciDocs}\xspace, with most gains being observed for user activity and citation tasks.
The gain from 80.0 to 81.8 is particularly notable given that even \textit{Oracle SciDocs}\xspace yields with 83.0 an only marginally higher avg. score despite using \textsc{SciDocs}\xspace directly for the triple selection.
Appendix~\ref{ssec:examples} shows examples of triples generated with \sys.
\section{Impact of Sample Difficulty} \label{sec:hyperparameter-analysis}
The benefit of \sys is that the hyperparameters of the sampling strategies can be tuned (\cref{ssec:neg_pos_sampling}) to learn without sample collisions.
In this section, we present the results of this tuning procedure.
We optimize the sampling strategies for positives and hard or easy negatives with partial grid search on a random sample of 10\% of the replicated SPECTER training data (sampling based on queries).
Our experiments show that optimizations on this subset correlate with the entire dataset.
The scores in \cref{fig:easy_pos} and \ref{fig:hard_neg} are reported as the mean over three random seeds including standard deviations.
\subsection{Positive Samples} \label{ssec:positves-results}
\begin{figure}[h]
\centering
\includegraphics[clip,width=1.\linewidth]{figures/easy_positives_k_max__eval-val_avg.pdf}
\caption{\label{fig:easy_pos}Results on the validation set w.r.t. positive sampling with \textsc{kNN}\xspace when using 10\% training data.}
\end{figure}
\cref{fig:easy_pos} shows the average scores on the \textsc{SciDocs}\xspace validation set depending on the selection of positives with the \textsc{kNN}\xspace strategy.
We only change $k^{+}$, while negative sampling remains fixed to its best setting (\cref{ssec:hard-negatives-results}).
The \textsc{Sim}\xspace strategy is omitted for positive sampling since it yields a poor performance throughout all tasks (Appendix~\ref{ssec:negative-results})
The performance is relatively stable for $k^{+}{<}100$ with peak at $k^{+}{=}25$, for $k^{+}{>}100$ the performance declines as $k^{+}$ increases.
\citet{PositivesSimilarImportant} state that positive samples should be semantically similar to each other, but not too similar to the query. For example, at $k^{+}{=}5$, positives may be a bit ``too easy'' to learn, such that they produce less informative gradients than the optimal setting $k^{+}{=}25$.
Similarly, making $k^{+}$ too large leads to the \emph{sampling induced margin} being too small, such that \emph{positives collide with negative samples}, which creates contrastive label noise that degrades performance \citep{ContrastiveLearningLimitations}.
Another observation is the standard deviation $\sigma$: %
One would expect $\sigma$ to be independent of $k^{+}$ since random seeds affect only the negatives.
However, positives and negatives interact with each other through the triplet margin loss.
Therefore, $\sigma$ is also affected by $k^{+}$.
\subsection{Hard Negative Samples} \label{ssec:hard-negatives-results}
\begin{figure}[h]
\centering
\includegraphics[clip,width=1.\linewidth]{figures/hard_negatives_k_max__eval-val_avg.pdf}
\caption{\label{fig:hard_neg}Results on the validation set w.r.t. hard negative sampling with \textsc{kNN}\xspace using 10\% training data.}
\end{figure}
\cref{fig:hard_neg} presents the validation results with \textsc{kNN}\xspace strategy and $k^{-}_{\text{hard}}$ and the best setting for positives ($k^{+}{=}25$).
The performance increases with increasing $k^{-}_{\text{hard}}$, until the performance plateaus for $2000{<}k^{-}_{\text{hard}}{<}4000$ with a peak at $k^{-}_{\text{hard}}{=}4000$.
This plateau can also be observed in the test performance, where $k^{-}_{\text{hard}}{=}2000$ and $k^{-}_{\text{hard}}{=}3000$ yield a marginally lower score of 81.6 and 81.7 (\cref{tab:ablation}).
For $k^{-}_{\text{hard}}{>}4000$, the performance starts to decline again.
This suggests that for large $k^{-}_{\text{hard}}$ the samples are not ``hard enough''.
The need for hard negatives confirms the findings of \citet{Cohan2020}.
Intuitively, the \textsc{kNN}\xspace strategy should suffer from a centrality or hubness problem.
How many neighbors are semantically similar strongly depends on the query paper itself.
A popular and frequently cited paper
has many more similar neighbors than a niche paper.
To test this assumption, we also evaluate the \textsc{Sim}\xspace strategy that should account for the hubness problem.
However, \textsc{Sim}\xspace underperforms with a score of 81.7 (\cref{tab:ablation}) independent from different similarity thresholds (Appendix~\ref{ssec:negative-results}).
\subsection{Easy Negative Samples}
Filtered random sampling of easy negatives yields the best validation performance compared pure random sampling (\cref{tab:ablation}).
However, the performance difference is marginal.
When rounded to one decimal, their average test scores are identical.
The marginal difference is caused by the large corpus size and the resulting small probability of randomly sampling one paper from the \textsc{kNN}\xspace results.
But without filtering, the effect of random seeds increases, since we find a higher standard deviation compared to the one with filtering. %
As a potential way to decrease randomness, we experiment with other approaches like k-means clustering but find that they decrease the performance (Appendix~\ref{ssec:negative-results}).
\section{Ablation Analysis} \label{sec:ablation-analysis}
In addition to sample difficulty, we evaluate the performance impact of data quantity, trainable parameters, and language model initialization.
\begin{table}[!t]
\footnotesize
\centering
\setlength{\tabcolsep}{3pt}
\renewcommand{\arraystretch}{1.3}
\begin{tabular}{@{}lrrrr|rr@{}}
\toprule
&CLS & USR & CITE & REC & Avg. & $\Delta$ \\ \midrule
\sys & 85.0 & 88.8 & \textbf{94.7} & 36.6 & \textbf{81.8} & -- \\
SPECTER & 84.2 & 88.4 & 91.5 & 36.9 & 80.0 & -1.8\\
\hdashline
$k^{-}_{\text{hard}}{=}2000$ & 84.9 & 88.8 & \textbf{94.7} & 36.1 & 81.6 & -0.2 \\
$k^{-}_{\text{hard}}{=}3000$ & 84.5 & 88.7 & 94.6 & 36.9 & 81.7 & -0.1 \\
hard neg. w/ \textsc{Sim}\xspace & 84.4 & \textbf{88.9} & \textbf{94.7} & 36.9 & 81.7 & -0.1 \\
easy neg. w/ random & 85.1 & 88.8 & \textbf{94.7} & 36.6 & \textbf{81.8} & 0.0 \\
\hdashline
Init. w/ BERT-Base & 83.4 & 88.4 & 93.8 & 37.5 & 81.2 & -0.6 \\
Init. w/ BERT-Large & 84.6 & 88.7 & 94.1 & 36.4 & 81.4 & -0.4 \\
Init. w/ BioBERT & 83.7 & 88.6 & 93.8 & \textbf{37.7} & 81.4 & -0.4 \\
\hdashline
1\% training data & 85.2 & 88.3 & 92.7 & 36.1 & 80.8 & -1.0 \\
10\% training data & 85.1 & 88.7 & 93.5 & 36.2 & 81.1 & -0.6 \\
BitFit training & \textbf{85.8} & 88.6 & 93.7 & 35.3 & 81.2 & -0.5 \\
\bottomrule
\end{tabular}
\caption{Ablations. Numbers are averages over tasks of the \textsc{SciDocs}\xspace test set, average score over all metrics, and rounded absolute difference to \sys.}
\label{tab:ablation}
\end{table}
\subsection{Initial Language Models} \label{ssec:init-lms}
\cref{tab:ablation} shows the effect of initializing the model weights not with SciBERT but with general-domain LLMs (BERT-Base and BERT-Large) or with BioBERT.
The initialization with other LLMs decreases the performance.
However, the decline is marginal (BERT-Base -0.6, BERT-Large -0.4, BioBERT -0.4) and all LLMs outperform the SPECTER baseline.
For the recommendation task, in which SPECTER is superior over \sys, BioBERT outperform SPECTER. %
This indicates that the improved triple mining of \sys has a greater domain adaption effect than pretraining on domain-specific literature.
Given that pretraining of LLMs requires a magnitude more resources than the fine-tuning with \sys, our approach can be a solution for resource-limited use cases.
\subsection{Data and Computing Efficiency} \label{ssec:data-efficiency} %
The last three rows of \cref{tab:ablation} show the results regarding data and computing efficiency.
When keeping the citation graph unchanged but training with only 10\% of the original triples, \sys still yields a score of 81.1 (-0.6).
Even with only 1\% (6840 triples), \sys achieves a score of 80.8 that is 1.0 points less than with 100\% but still 0.8 points more than the SPECTER baseline.
With this data efficiency, one could manually create triples or use existing supervised datasets as \citet{Gao2021}.
Lastly, we evaluate BitFit training \cite{Zaken2021}, which only trains the bias terms of the model while freezing all other parameters.
This corresponds to training only 0.1\% of the original parameters.
With BitFit, \sys yields a considerable score of 81.2 (-0.5 points).
As a result, \sys could be trained on the same hardware with even larger (general-domain) language models (\cref{ssec:init-lms}).
\section{Conclusion}
We present a novel approach for contrastive learning of scientific document embeddings that addresses the challenge of selecting informative positive and negative samples.
By leveraging citation graph embeddings for sample generation, \sys achieves a score of 81.8 on the \textsc{SciDocs}\xspace benchmark, a 1.8 point improvement over the previous best method SPECTER.
This is purely achieved by introducing tunable sample difficulty and avoiding collisions between positive and negative samples, while existing LLM and data setups can be reused.
This improvement over SPECTER can be also observed when excluding the \textsc{SciDocs}\xspace papers from the training corpus. %
Furthermore, \sys's improvement from 80.0 to 81.8 is particularly notable given that even triples, which are generated with \textsc{SciDocs}\xspace's test and validation data, yield with 83.0 only a marginally higher score. %
Our work highlights the importance of sample generation in a contrastive learning setting.
We show that 1\% of training triples are already sufficient to outperform SPECTER, whereas the remaining 99\% provide only 1.0 additional points (80.8 to 81.8).
This sample efficiency is achieved by adding reasonable effort for sample generation (graph embedding training and nearest neighbor search).
We also demonstrate that in-domain language model pretraining (like SciBERT) is beneficial, while general-domain LLMs can achieve a comparable performance and even outperform SPECTER.
This indicates that controlling sample difficulty and avoiding collisions
is more effective than in-domain pretraining, especially in scenarios where training a LLM from scratch is infeasible.
\section*{Acknowledgements}
The work presented in this article has received funding from the German Federal Ministry of Education and Research (BMBF) through the project QURATOR (no.~03WKDA1A).
|
{'timestamp': '2022-02-15T02:43:27', 'yymm': '2202', 'arxiv_id': '2202.06671', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06671'}
|
arxiv
|
\section{Introduction}
\file{elsarticle.cls} is a thoroughly re-written document class
for formatting \LaTeX{} submissions to Elsevier journals.
The class uses the environments and commands defined in \LaTeX{} kernel
without any change in the signature so that clashes with other
contributed \LaTeX{} packages such as \file{hyperref.sty},
\file{preview-latex.sty}, etc., will be minimal.
\file{elsarticle.cls} is primarily built upon the default
\file{article.cls}. This class depends on the following packages
for its proper functioning:
\begin{enumerate}
\item \file{natbib.sty} for citation processing;
\item \file{geometry.sty} for margin settings;
\item \file{fleqn.clo} for left aligned equations;
\item \file{graphicx.sty} for graphics inclusion;
\item \file{txfonts.sty} optional font package, if the document is to
be formatted with Times and compatible math fonts;
\item \file{hyperref.sty} optional packages if hyperlinking is
required in the document;
\item \file{endfloat.sty} optional packages if floats to be placed at
end of the PDF.
\end{enumerate}
All the above packages (except some optional packages) are part of any
standard \LaTeX{} installation. Therefore, the users need not be
bothered about downloading any extra packages. Furthermore, users are
free to make use of \textsc{ams} math packages such as
\file{amsmath.sty}, \file{amsthm.sty}, \file{amssymb.sty},
\file{amsfonts.sty}, etc., if they want to. All these packages work in
tandem with \file{elsarticle.cls} without any problems.
\section{Major Differences}
Following are the major differences between \file{elsarticle.cls}
and its predecessor package, \file{elsart.cls}:
\begin{enumerate}[\textbullet]
\item \file{elsarticle.cls} is built upon \file{article.cls}
while \file{elsart.cls} is not. \file{elsart.cls} redefines
many of the commands in the \LaTeX{} classes/kernel, which can
possibly cause surprising clashes with other contributed
\LaTeX{} packages;
\item provides preprint document formatting by default, and
optionally formats the document as per the final
style of models $1+$, $3+$ and $5+$ of Elsevier journals;
\item some easier ways for formatting \verb+list+ and
\verb+theorem+ environments are provided while people can still
use \file{amsthm.sty} package;
\item \file{natbib.sty} is the main citation processing package
which can comprehensively handle all kinds of citations and
works perfectly with \file{hyperref.sty} in combination with
\file{hypernat.sty};
\item long title pages are processed correctly in preprint and
final formats.
\end{enumerate}
\section{Installation}
The package is available at author resources page at Elsevier
(\url{http://www.elsevier.com/locate/latex}).
It can also be found in any of the nodes of the Comprehensive
\TeX{} Archive Network (\textsc{ctan}), one of the primary nodes
being
\url{http://tug.ctan.org/tex-archive/macros/latex/contrib/elsarticle/}.
Please download the \file{elsarticle.dtx} which is a composite
class with documentation and \file{elsarticle.ins} which is the
\LaTeX{} installer file. When we compile the
\file{elsarticle.ins} with \LaTeX{} it provides the class file,
\file{elsarticle.cls} by
stripping off all the documentation from the \verb+*.dtx+ file.
The class may be moved or copied to a place, usually,
\verb+$TEXMF/tex/latex/elsevier/+,
or a folder which will be read
by \LaTeX{} during document compilation. The \TeX{} file
database needs updation after moving/copying class file. Usually,
we use commands like \verb+mktexlsr+ or \verb+texhash+ depending
upon the distribution and operating system.
\section{Usage}\label{sec:usage}
The class should be loaded with the command:
\begin{vquote}
\documentclass[<options>]{elsarticle}
\end{vquote}
\noindent where the \verb+options+ can be the following:
\begin{description}
\item [{\tt\color{verbcolor} preprint}] default option which format the
document for submission to Elsevier journals.
\item [{\tt\color{verbcolor} review}] similar to the \verb+preprint+
option, but increases the baselineskip to facilitate easier review
process.
\item [{\tt\color{verbcolor} 1p}] formats the article to the look and
feel of the final format of model 1+ journals. This is always single
column style.
\item [{\tt\color{verbcolor} 3p}] formats the article to the look and
feel of the final format of model 3+ journals. If the journal is a two
column model, use \verb+twocolumn+ option in combination.
\item [{\tt\color{verbcolor} 5p}] formats for model 5+ journals. This
is always of two column style.
\item [{\tt\color{verbcolor} authoryear}] author-year citation style of
\file{natbib.sty}. If you want to add extra options of
\file{natbib.sty}, you may use the options as comma delimited strings
as arguments to \verb+\biboptions+ command. An example would be:
\end{description}
\begin{vquote}
\biboptions{longnamesfirst,angle,semicolon}
\end{vquote}
\begin{description}
\item [{\tt\color{verbcolor} number}] numbered citation style. Extra options
can be loaded with\linebreak \verb+\biboptions+ command.
\item [{\tt\color{verbcolor} sort\&compress}] sorts and compresses the
numbered citations. For example, citation [1,2,3] will become [1--3].
\item [{\tt\color{verbcolor} longtitle}] if front matter is unusually long, use
this option to split the title page across pages with the correct
placement of title and author footnotes in the first page.
\item [{\tt\color{verbcolor} times}] loads \file{txfonts.sty}, if
available in the system to use Times and compatible math fonts.
\item [{\tt\color{verbcolor} reversenotenum}] Use alphabets as
author--affiliation linking labels and use numbers for author
footnotes. By default, numbers will be used as author--affiliation
linking labels and alphabets for author footnotes.
\item [{\tt\color{verbcolor} lefttitle}] To move title and
author/affiliation block to flushleft. \verb+centertitle+ is the
default option which produces center alignment.
\item [{\tt\color{verbcolor} endfloat}] To place all floats at the end
of the document.
\item [{\tt\color{verbcolor} nonatbib}] To unload natbib.sty.
\item [{\tt\color{verbcolor} doubleblind}] To hide author name,
affiliation, email address etc. for double blind refereeing purpose.
\item[] All options of \file{article.cls} can be used with this
document class.
\item[] The default options loaded are \verb+a4paper+, \verb+10pt+,
\verb+oneside+, \verb+onecolumn+ and \verb+preprint+.
\end{description}
\section{Frontmatter}
There are two types of frontmatter coding:
\begin{enumerate}[(1)]
\item each author is
connected to an affiliation with a footnote marker; hence all
authors are grouped together and affiliations follow;
\pagebreak
\item authors of same affiliations are grouped together and the
relevant affiliation follows this group.
\end{enumerate}
An example of coding the first type is provided below.
\begin{vquote}
\title{This is a specimen title\tnoteref{t1,t2}}
\tnotetext[t1]{This document is the results of the research
project funded by the National Science Foundation.}
\tnotetext[t2]{The second title footnote which is a longer
text matter to fill through the whole text width and
overflow into another line in the footnotes area of the
first page.}
\end{vquote}
\begin{vquote}
\author[1]{Jos Migchielsen\corref{cor1}%
\fnref{fn1}}
\ead{[email protected]}
\author[2]{CV Radhakrishnan\fnref{fn2}}
\ead{[email protected]}
\author[3]{CV Rajagopal\fnref{fn1,fn3}}
\ead[url]{www.stmdocs.in}
\cortext[cor1]{Corresponding author}
\fntext[fn1]{This is the first author footnote.}
\fntext[fn2]{Another author footnote, this is a very long
footnote and it should be a really long footnote. But this
footnote is not yet sufficiently long enough to make two
lines of footnote text.}
\fntext[fn3]{Yet another author footnote.}
\affiliation[1]{organization={Elsevier B.V.},
addressline={Radarweg 29},
postcode={1043 NX},
city={Amsterdam},
country={The Netherlands}}
\affiliation[2]{organization={Sayahna Foundation},
addressline={JWRA 34, Jagathy},
city={Trivandrum}
postcode={695014},
country={India}}
\end{vquote}
\begin{vquote}
\affiliation[3]{organization={STM Document Engineering
Pvt Ltd.},
addressline={Mepukada, Malayinkil},
city={Trivandrum}
postcode={695571},
country={India}}
\end{vquote}
The output of the above \TeX{} source is given in Clips~\ref{clip1} and
\ref{clip2}. The header portion or title area is given in
Clip~\ref{clip1} and the footer area is given in Clip~\ref{clip2}.
\deforange{blue!70}
\src{Header of the title page.}
\includeclip{1}{130 612 477 707}{1psingleauthorgroup.pdf
\deforange{orange}
\deforange{blue!70}
\src{Footer of the title page.}
\includeclip{1}{93 135 499 255}{1pseperateaug.pdf
\deforange{orange}
Most of the commands such as \verb+\title+, \verb+\author+,
\verb+\affiliation+ are self explanatory. Various components are
linked to each other by a label--reference mechanism; for
instance, title footnote is linked to the title with a footnote
mark generated by referring to the \verb+\label+ string of
the \verb=\tnotetext=. We have used similar commands
such as \verb=\tnoteref= (to link title note to title);
\verb=\corref= (to link corresponding author text to
corresponding author); \verb=\fnref= (to link footnote text to
the relevant author names). \TeX{} needs two compilations to
resolve the footnote marks in the preamble part.
Given below are the syntax of various note marks and note texts.
\begin{vquote}
\tnoteref{<label(s)>}
\corref{<label(s)>}
\fnref{<label(s)>}
\tnotetext[<label>]{<title note text>}
\cortext[<label>]{<corresponding author note text>}
\fntext[<label>]{<author footnote text>}
\end{vquote}
\noindent where \verb=<label(s)>= can be either one or more comma
delimited label strings. The optional arguments to the
\verb=\author= command holds the ref label(s) of the address(es)
to which the author is affiliated while each \verb=\affiliation=
command can have an optional argument of a label. In the same
manner, \verb=\tnotetext=, \verb=\fntext=, \verb=\cortext= will
have optional arguments as their respective labels and note text
as their mandatory argument.
The following example code provides the markup of the second type
of author-affiliation.
\begin{vquote}
\author{Jos Migchielsen\corref{cor1}%
\fnref{fn1}}
\ead{[email protected]}
\affiliation[1]{organization={Elsevier B.V.},
addressline={Radarweg 29},
postcode={1043 NX},
city={Amsterdam},
country={The Netherlands}}
\author{CV Radhakrishnan\fnref{fn2}}
\ead{[email protected]}
\affiliation[2]{organization={Sayahna Foundation},
addressline={JWRA 34, Jagathy},
city={Trivandrum}
postcode={695014},
country={India}}
\author{CV Rajagopal\fnref{fn1,fn3}}
\ead[url]{www.stmdocs.in}
\affiliation[3]{organization={STM Document Engineering
Pvt Ltd.},
addressline={Mepukada, Malayinkil},
city={Trivandrum}
postcode={695571},
country={India}}
\end{vquote}
\vspace*{-.5pc}
\begin{vquote}
\cortext[cor1]{Corresponding author}
\fntext[fn1]{This is the first author footnote.}
\fntext[fn2]{Another author footnote, this is a very long
footnote and it should be a really long footnote. But this
footnote is not yet sufficiently long enough to make two lines
of footnote text.}
\end{vquote}
The output of the above \TeX{} source is given in Clip~\ref{clip3}.
\deforange{blue!70}
\src{Header of the title page..}
\includeclip{1}{119 563 468 709}{1pseperateaug.pdf
\deforange{orange}
Clip~\ref{clip4} shows the output after giving \verb+doubleblind+ class option.
\deforange{blue!70}
\src{Double blind article}
\includeclip{1}{124 567 477 670}{elstest-1pdoubleblind.pdf
\deforange{orange}
\vspace*{-.5pc}
The frontmatter part has further environments such as abstracts and
keywords. These can be marked up in the following manner:
\begin{vquote}
\begin{abstract}
In this work we demonstrate the formation of a new type of
polariton on the interface between a ....
\end{abstract}
\end{vquote}
\vspace*{-.5pc}
\begin{vquote}
\begin{keyword}
quadruple exiton \sep polariton \sep WGM
\end{keyword}
\end{vquote}
\noindent Each keyword shall be separated by a \verb+\sep+ command.
\textsc{msc} classifications shall be provided in
the keyword environment with the commands
\verb+\MSC+. \verb+\MSC+ accepts an optional
argument to accommodate future revisions.
eg., \verb=\MSC[2008]=. The default is 2000.\looseness=-1
\subsection{New page}
Sometimes you may need to give a page-break and start a new page after
title, author or abstract. Following commands can be used for this
purpose.
\begin{vquote}
\newpageafter{title}
\newpageafter{author}
\newpageafter{abstract}
\end{vquote}
\begin{itemize}
\leftskip-2pc
\item [] {\tt\color{verbcolor} \verb+\newpageafter{title}+} typeset the title alone on one page.
\item [] {\tt\color{verbcolor} \verb+\newpageafter{author}+} typeset the title
and author details on one page.
\item [] {\tt\color{verbcolor} \verb+\newpageafter{abstract}+}
typeset the title,
author details and abstract \& keywords one one page.
\end{itemize}
\section{Floats}
{Figures} may be included using the command, \verb+\includegraphics+ in
combination with or without its several options to further control
graphic. \verb+\includegraphics+ is provided by \file{graphic[s,x].sty}
which is part of any standard \LaTeX{} distribution.
\file{graphicx.sty} is loaded by default. \LaTeX{} accepts figures in
the postscript format while pdf\LaTeX{} accepts \file{*.pdf},
\file{*.mps} (metapost), \file{*.jpg} and \file{*.png} formats.
pdf\LaTeX{} does not accept graphic files in the postscript format.
The \verb+table+ environment is handy for marking up tabular
material. If users want to use \file{multirow.sty},
\file{array.sty}, etc., to fine control/enhance the tables, they
are welcome to load any package of their choice and
\file{elsarticle.cls} will work in combination with all loaded
packages.
\section[Theorem and ...]{Theorem and theorem like environments}
\file{elsarticle.cls} provides a few shortcuts to format theorems and
theorem-like environments with ease. In all commands the options that
are used with the \verb+\newtheorem+ command will work exactly in the same
manner. \file{elsarticle.cls} provides three commands to format theorem or
theorem-like environments:
\begin{vquote}
\newtheorem{thm}{Theorem}
\newtheorem{lem}[thm]{Lemma}
\newdefinition{rmk}{Remark}
\newproof{pf}{Proof}
\newproof{pot}{Proof of Theorem \ref{thm2}}
\end{vquote}
The \verb+\newtheorem+ command formats a
theorem in \LaTeX's default style with italicized font, bold font
for theorem heading and theorem number at the right hand side of the
theorem heading. It also optionally accepts an argument which
will be printed as an extra heading in parentheses.
\begin{vquote}
\begin{thm}
For system (8), consensus can be achieved with
$\|T_{\omega z}$
...
\begin{eqnarray}\label{10}
....
\end{eqnarray}
\end{thm}
\end{vquote}
Clip~\ref{clip5} will show you how some text enclosed between the
above code\goodbreak \noindent looks like:
\vspace*{6pt}
\deforange{blue!70}
\src{{\ttfamily\color{verbcolor}\expandafter\@gobble\string\\ newtheorem}}
\includeclip{2}{1 1 453 120}{jfigs.pdf}
\deforange{orange}
The \verb+\newdefinition+ command is the same in
all respects as its\linebreak \verb+\newtheorem+ counterpart except that
the font shape is roman instead of italic. Both
\verb+\newdefinition+ and \verb+\newtheorem+ commands
automatically define counters for the environments defined.
\vspace*{6pt}
\deforange{blue!70}
\src{{\ttfamily\color{verbcolor}\expandafter\@gobble\string\\ newdefinition}}
\includeclip{1}{1 1 453 105}{jfigs.pdf}
\deforange{orange}
The \verb+\newproof+ command defines proof environments with
upright font shape. No counters are defined.
\vspace*{6pt}
\deforange{blue!70}
\src{{\ttfamily\color{verbcolor}\expandafter\@gobble\string\\ newproof}}
\includeclip{3}{1 1 453 65}{jfigs.pdf}
\deforange{orange}
Users can also make use of \verb+amsthm.sty+ which will override
all the default definitions described above.
\section[Enumerated ...]{Enumerated and Itemized Lists}
\file{elsarticle.cls} provides an extended list processing macros
which makes the usage a bit more user friendly than the default
\LaTeX{} list macros. With an optional argument to the
\verb+\begin{enumerate}+ command, you can change the list counter
type and its attributes.
\begin{vquote}
\begin{enumerate}[1.]
\item The enumerate environment starts with an optional
argument `1.', so that the item counter will be suffixed
by a period.
\item You can use `a)' for alphabetical counter and '(i)' for
roman counter.
\begin{enumerate}[a)]
\item Another level of list with alphabetical counter.
\item One more item before we start another.
\end{vquote}
\deforange{blue!70}
\src{List -- Enumerate}
\includeclip{4}{1 1 453 185}{jfigs.pdf}
\deforange{orange}
Further, the enhanced list environment allows one to prefix a
string like `step' to all the item numbers.
\begin{vquote}
\begin{enumerate}[Step 1.]
\item This is the first step of the example list.
\item Obviously this is the second step.
\item The final step to wind up this example.
\end{enumerate}
\end{vquote}
\deforange{blue!70}
\src{List -- enhanced}
\includeclip{5}{1 1 313 83}{jfigs.pdf}
\deforange{orange}
\section{Cross-references}
In electronic publications, articles may be internally
hyperlinked. Hyperlinks are generated from proper
cross-references in the article. For example, the words
\textcolor{black!80}{Fig.~1} will never be more than simple text,
whereas the proper cross-reference \verb+\ref{tiger}+ may be
turned into a hyperlink to the figure itself:
\textcolor{blue}{Fig.~1}. In the same way,
the words \textcolor{blue}{Ref.~[1]} will fail to turn into a
hyperlink; the proper cross-reference is \verb+\cite{Knuth96}+.
Cross-referencing is possible in \LaTeX{} for sections,
subsections, formulae, figures, tables, and literature
references.
\section[Mathematical ...]{Mathematical symbols and formulae}
Many physical/mathematical sciences authors require more
mathematical symbols than the few that are provided in standard
\LaTeX. A useful package for additional symbols is the
\file{amssymb} package, developed by the American Mathematical
Society. This package includes such oft-used symbols as
$\lesssim$ (\verb+\lesssim+), $\gtrsim$ (\verb+\gtrsim+) or
$\hbar$ (\verb+\hbar+). Note that your \TeX{}
system should have the \file{msam} and \file{msbm} fonts installed. If
you need only a few symbols, such as $\Box$ (\verb+\Box+), you might try the
package \file{latexsym}.
Another point which would require authors' attention is the
breaking up of long equations. When you use
\file{elsarticle.cls} for formatting your submissions in the
\verb+preprint+ mode, the document is formatted in single column
style with a text width of 384pt or 5.3in. When this document is
formatted for final print and if the journal happens to be a double column
journal, the text width will be reduced to 224pt at for 3+
double column and 5+ journals respectively. All the nifty
fine-tuning in equation breaking done by the author goes to waste in
such cases. Therefore, authors are requested to check this
problem by typesetting their submissions in final format as well
just to see if their equations are broken at appropriate places,
by changing appropriate options in the document class loading
command, which is explained in section~\ref{sec:usage},
\nameref{sec:usage}. This allows authors to fix any equation breaking
problem before submission for publication.
\file{elsarticle.cls} supports formatting the author submission
in different types of final format. This is further discussed in
section \ref{sec:final}, \nameref{sec:final}.
\enlargethispage*{\baselineskip}
\subsection*{Displayed equations and double column journals}
Many Elsevier journals print their text in two columns. Since
the preprint layout uses a larger line width than such columns,
the formulae are too wide for the line width in print. Here is an
example of an equation (see equation 6) which is perfect in a
single column preprint format:
In normal course, articles are prepared and submitted in single column
format even if the final printed article will come in a double column
format journal. Here the problem is that when the article is typeset by
the typesetters for paginating and fit within the single column width,
they have to break the lengthy equations and align them properly. Even
if most of the tasks in preparing your proof is automated, the equation
breaking and aligning requires manual judgement, hence this task is manual.
When there comes a manual operation that area is error prone. Author
needs to check that equation pretty well.
However if authors themselves break the equation to the single column
width typesetters need not want to touch these area and the proof authors
get will be without any errors.
\setlength\Sep{6pt}
\src{See equation (6)}
\deforange{blue!70}
\includeclip{4}{105 500 500 700}{1psingleauthorgroup.pdf}
\deforange{orange}
\noindent When this document is typeset for publication in a
model 3+ journal with double columns, the equation will overlap
the second column text matter if the equation is not broken at
the appropriate location.
\vspace*{6pt}
\deforange{blue!70}
\src{See equation (6) overprints into second column}
\includeclip{3}{59 421 532 635}{elstest-3pd.pdf}
\deforange{orange}
\vspace*{6pt}
\noindent The typesetter will try to break the equation which
need not necessarily be to the liking of the author or as it
happens, typesetter's break point may be semantically incorrect.
Therefore, authors may check their submissions for the incidence
of such long equations and break the equations at the correct
places so that the final typeset copy will be as they wish.
\section{Bibliography}
Three bibliographic style files (\verb+*.bst+) are provided ---
\file{elsarticle-num.bst}, \file{elsarticle-num-names.bst} and
\file{elsarticle-harv.bst} --- the first one can be used for the
numbered scheme, second one for numbered with new options of
\file{natbib.sty}. The third one is for the author year
scheme.
In \LaTeX{} literature, references are listed in the
\verb+thebibliography+ environment. Each reference is a
\verb+\bibitem+ and each \verb+\bibitem+ is identified by a label,
by which it can be cited in the text:
\verb+\bibitem[Elson et al.(1996)]{ESG96}+ is cited as
\verb+\citet{ESG96}+.
\noindent In connection with cross-referencing and
possible future hyperlinking it is not a good idea to collect
more that one literature item in one \verb+\bibitem+. The
so-called Harvard or author-year style of referencing is enabled
by the \LaTeX{} package \file{natbib}. With this package the
literature can be cited as follows:
\begin{enumerate}[\textbullet]
\item Parenthetical: \verb+\citep{WB96}+ produces (Wettig \& Brown, 1996).
\item Textual: \verb+\citet{ESG96}+ produces Elson et al. (1996).
\item An affix and part of a reference:
\verb+\citep[e.g.][Ch. 2]{Gea97}+ produces (e.g. Governato et
al., 1997, Ch. 2).
\end{enumerate}
In the numbered scheme of citation, \verb+\cite{<label>}+ is used,
since \verb+\citep+ or \verb+\citet+ has no relevance in the numbered
scheme. \file{natbib} package is loaded by \file{elsarticle} with
\verb+numbers+ as default option. You can change this to author-year
or harvard scheme by adding option \verb+authoryear+ in the class
loading command. If you want to use more options of the \file{natbib}
package, you can do so with the \verb+\biboptions+ command, which is
described in the section \ref{sec:usage}, \nameref{sec:usage}. For
details of various options of the \file{natbib} package, please take a
look at the \file{natbib} documentation, which is part of any standard
\LaTeX{} installation.
In addition to the above standard \verb+.bst+ files, there are 10
journal-specific \verb+.bst+ files also available.
Instruction for using these \verb+.bst+ files can be found at
\href{http://support.stmdocs.in/wiki/index.php?title=Model-wise_bibliographic_style_files}
{http://support.stmdocs.in}
\section[Graphical ...]{Graphical abstract and highlights}
A template for adding graphical abstract and highlights are available
now. This will appear as the first two pages of the PDF before the
article content begins.
\pagebreak
Please refer below to see how to code them.
\begin{vquote}
....
....
\end{abstract}
\begin{graphicalabstract}
\end{graphicalabstract}
\begin{highlights}
\item Research highlight 1
\item Research highlight 2
\end{highlights}
\begin{keyword}
....
....
\end{vquote}
\section{Final print}\label{sec:final}
The authors can format their submission to the page size and margins
of their preferred journal. \file{elsarticle} provides four
class options for the same. But it does not mean that using these
options you can emulate the exact page layout of the final print copy.
\lmrgn=3em
\begin{description}
\item [\texttt{1p}:] $1+$ journals with a text area of
384pt $\times$ 562pt or 13.5cm $\times$ 19.75cm or 5.3in $\times$
7.78in, single column style only.
\item [\texttt{3p}:] $3+$ journals with a text area of 468pt
$\times$ 622pt or 16.45cm $\times$ 21.9cm or 6.5in $\times$
8.6in, single column style.
\item [\texttt{twocolumn}:] should be used along with 3p option if the
journal is $3+$ with the same text area as above, but double column
style.
\item [\texttt{5p}:] $5+$ with text area of 522pt $\times$
682pt or 18.35cm $\times$ 24cm or 7.22in $\times$ 9.45in,
double column style only.
\end{description}
Following pages have the clippings of different parts of
the title page of different journal models typeset in final
format.
Model $1+$ and $3+$ will have the same look and
feel in the typeset copy when presented in this document. That is
also the case with the double column $3+$ and $5+$ journal article
pages. The only difference will be wider text width of
higher models. Here are the specimen single and double column journal
pages.
\begin{comment}
\begin{center}
\hypertarget{bsc}{}
\hyperlink{sc}{
{\bf [Specimen single column article -- Click here]}
}
\hypertarget{bsc}{}
\hyperlink{dc}{
{\bf [Specimen double column article -- Click here]}
}
\end{center}
\end{comment}
\vspace*{-.5pc}
\enlargethispage*{\baselineskip}
\src{}\hypertarget{sc}{}
\deforange{blue!70}
\hyperlink{bsc}{\includeclip{1}{88 120 514 724}{elstest-1p.pdf}}
\deforange{orange}
\src{}\hypertarget{dc}{}
\deforange{blue!70}
\hyperlink{bsc}{\includeclip{1}{27 61 562 758}{elstest-5p.pdf}}
\deforange{orange}
~\hfill $\Box$
\end{document}
\section{}
\label{}
\section{}
\label{}
\section*{Highlights}
\begin{itemize}
\item The analysis of oscillatory behavior in a coupled nonlinear system is considered
\item The change of coupling term and external input results in a transition to different dynamical states
\item The first (discontinuous) and second (continuous) phase transitions result from relaxing the mean-field assumption
\item Delta waves can be generated by altering inputs in a network of Jansen-Rit neural mass models, which has not been previously observed in a single Jansen-Rit neural mass analysis
\end{itemize}
\begin{keyword}
Brain dynamics, Neural mass model, Synchronization, Bifurcation
\end{keyword}
\end{frontmatter}
\section{Introduction}
Complex networks are ubiquitous in nature, and studies of their nonlinear dynamics and synchronization provide insight into physical, chemical, and biological phenomena \citep{bar1998dynamics, strogatz2001exploring, boccaletti2006complex, nicholls2001neuron}. Modeling real neural systems with complex mathematical networks is beneficial \citep{dayan2001theoretical, deutsch2007mathematical}. Brain networks can be represented as graphs with nodes (neurons or brain regions) connected by edges (physical connections) \citep{beim2008lectures}. Coupled systems play a substantial role in science and engineering \citep{boccaletti2018synchronization}. Research in the nonlinear dynamic analysis is increasingly focused on complex networks with interacting elements \citep{wunderling2021modelling, hebbink2020analysis}.
The empirical measurement of individual structural connectivity in many research, such as \citep{spiegler2010bifurcation}, has been used to examine networks of coupled phase oscillators.
Regular, random, small-world, and scale-free networks are four important network topologies that have been studied extensively. As structural links between cortical neurons demonstrate a small-world topology, several studies have investigated small-world networks of interconnected units \citep{yu2017stochastic, odor2019critical, budzinski2019synchronization}.
A significant amount of research has been dedicated to synchronizing coupled systems \citep{castanedo2018synchronization, budzinski2019synchronization, liu2020synchronization}. Synchronization phenomena significantly affect how the brain functions, both normally \citep{mizuhara2007human} and abnormally \citep{uhlhaas2006neural}. Multiple brain disorders, including Parkinson's disease \citep{he2015contribution}, autism \citep{dinstein2011disrupted}, and epilepsy \citep{liu2017transition}, may result in pathological brain synchronization. Nonlinear dynamics is one of the most fundamental phenomena in phase synchronization \citep{pikovsky2002synchronization}.
The neural mass models have been around for a long time. These models describe a local population of interacting neurons. Also, they are capable of modeling diverse phenomena and generating a wide variety of dynamic behaviors. Coupling a collection of the neural mass model into a mesoscale circuit can provide a link between micro and macro scales \citep{gosak2018network}. It is essential to model a network of neural masses in order to examine brain function and determine how connected units behave differently.
A comprehensive understanding of neural populations has recently been gained at the macro-and mesoscales. Neural mass models are a valuable tool for explaining the changes in neuronal dynamics between different behaviors, as they correspond directly to the large-scale dynamics measured by EEG \citep{coombes2005waves, deco2008dynamic}.
Some models that investigated the collective behavior of neurons included Lopez da Silva \citep{da1974model, da1989interdependence}, Jansen and Rit \citep{jansen1995electroencephalogram, jansen1993neurophysiologically}, Wendling \citep{wendling2000relevance, wendling2002epileptic}, Wilson-Cowan \citep{wilson1972excitatory, wilson1973mathematical}, Freeman \citep{freeman1987simulation, chang1996parameter}, and Wong-Wang \citep{wong2006recurrent, deco2013resting}.
Since 1988, analyses and numerical studies of the Jansen-Rit model have been conducted \citep{jansen1995electroencephalogram, jansen1993neurophysiologically, grimbert2006bifurcation, kuhlmann2016neural, Ableidinger2017stochastic, kazemi2022phase}. This study investigates the dynamics of the Jansen-Rit model, which has emerged as a way to extend simultaneous electrical activities simulation, specifically the alpha rhythm, in neural masses. Additionally, Jansen and Rit demonstrated that their model simulated the evoked potentials \citep{jansen1993neurophysiologically}. The main disadvantage of this model is that it fails to produce different rhythms, especially at the onset activity of epilepsy.
The use of different inputs in a single Jansen-Rit neural mass model \citep{spiegler2010bifurcation, grimbert2006bifurcation} and two coupled Jansen-Rit neural mass models \citep{ahmadizadeh2018bifurcation} can induce various types of activity, such as alpha-like activity and seizure-like activity. The transitions between regimes in dynamics are mathematically modeled using the dynamical systems theory. Consequently, phase transitions are manifested as so-called bifurcations of system variables.
In this paper, we use mesoscale modeling to show the brain as a network of Jansen-Rit coupled oscillators, where the network connection architecture consists of a regular Watts-Strogatz topology with 50 nodes.
Each node receives an external input plus an internal input based on the output signal from the neighbors.
The aim of this paper is twofold. As a first step, we use a mean-field approximation to assume that all nodes have the same input. This implies that all nodes are fully synchronized. The bifurcation diagram presents various types of bifurcation. Second, this mean-field assumption will then be relaxed, and different types of synchronization will be observed as a function of internal and external inputs. In order to quantify synchronization, we used four measures included Pearson Cross-Correlation, Phase Locking Value, Kuramoto Order Parameter, and Phase Locking Index \citep{bastos2016tutorial}. These all yielded almost the same quality results. To simplify, only one was chosen (Pearson CrossCorrelation). In the mean-field approach, we find that there is no phase transition despite observed behavior changes. It is surprising to find that both the first (discontinuous) and second (continuous) phase transitions result from relaxing the mean-field assumption.\\
Following this, we investigate the network behavior in frequency space. Our results show a wide range of rhythms, including delta, theta, and alpha.
We investigate how inputs changes can result in pathological oscillations similar to those observed in seizure.
According to our research, delta waves can be generated by altering the inputs in a network of Jansen-Rit neural mass models, which has not been previously observed in a single Jansen-Rit neural mass analysis. This phenomenon is an emergent property in a complex system. This states that every isolated node represents an alpha rhythm that changes when these units interact with each other in a complex system.
\section{Methods}\label{method}
\subsection*{Model formulation}
In this section, the mathematical representation of the Jansen-Rit neural mass model is explained. It describes a cortical area.
This model consists of three parts: pyramidal neurons, excitatory neurons, and inhibitory neurons. Pyramidal neurons are the main population that receives inputs from three sources: excitatory and inhibitory interneuron feedback within the same column, and external input from other columns. A schematic illustration of each mass is shown in figure \ref{J1}.
\begin{figure}[!ht]
\centering
\includegraphics[width=8cm, height=10cm]{J1.png}
\caption{Schematic representation of Jansen-Rit dynamics in a Watts-Strogatz network. Each node contains the main population (pyramidal cell (PC)) that interacts with two populations: excitatory interneuron (blue hexagonal on the left side) and inhibitory interneuron (orange circle on the right side).}
\label{J1}
\end{figure}
The dynamics of a single unit is described by \citep{grimbert2006bifurcation}
\begin{eqnarray*}
\begin{array}{lr}
\dot{x}_{0} (t) = x_{3} (t)\\
\dot{x}_{3} (t) = A a S(x_{1} (t) - x_{2} (t)) -2a x_{3} (t) -a^{2}x_{0} (t)\\
\dot{x}_{1} (t) = x_{4} (t)\\
\dot{x}_{4} (t) = A a \left\lbrace f_{0}(t)+C_{2} S[C_{1} x_{0} (t)]\right\rbrace -2ax_{4}(t) -a^{2} x_{1}(t)\\
\dot{x}_{2} (t) = x_{5} (t)\\
\dot{x}_{5} (t) = B b C_{4} S(C_{3}x_{0}) -2b x_{5} (t) -b^{2}x_{2} (t)
\end{array}
\end{eqnarray*}
The activities of pyramidal, excitatory, and inhibitory ensembles are ($ x_{0} $;$ x_{3} $), ($ x_{1} $;$ x_{4} $) and ($ x_{2} $;$ x_{5} $), respectively.\\
The sigmoidal function S transforms the average membrane potential of neurons to the mean firing rate of action potentials and is defined as:
\begin{eqnarray*}
S(v) = \frac{v_{max}}{1 + e^{r(v_{0}-v)}}
\end{eqnarray*}
A biological interpretation of the parameter values used to solve equation (1) is given in Table 1 \citep{jansen1995electroencephalogram}.\\
\begin{table}
\caption{Parameters in the Jansen-Rit model are obtained experimentally.}
\label{Table}
\begin{tabular}{ccc}
\hline
Parameters & Interpretation & Value
\\
\hline
$ A $ & Excitatory PSP amplitude & 3.25 mV
\\
\hline \
$ B $ & inhibitory PSP amplitude & 22 mV
\\
\hline
$ 1/a $ & Time constant of excitatory PSP & $ a = 100 s^{-1} $
\\
\hline
$ 1/b $ & Time constant of inhibitory PSP & $ b = 50 s^{-1} $
\\
\hline
$ C1 $, $ C2 $ & Average numbers of synapses between excitatory populations & $ 1 * C $, $ 0.8 * C $
\\
\hline
$ C3 $, $ C4 $ & Average numbers of synapses between inhibitory populations & $ 0.25 * C $
\\
\hline
$ C $ & Average numbers of synapses between neural populations & 135
\\
\hline
$ v_{max} $ & Maximum firing rate & 5 Hz
\\
\hline
$ v0 $ & Potential at half of maximum firing rate & 6 mV
\\
\hline
$ r $ & Slope of sigmoid function at $ v0 $ & $ 0.56 mV^{-1} $
\\
\hline
\end{tabular}
\end{table}
The value of $ f_{0} $ describes an external input that originated from an external source. Based on the interactions between two populations of interneurons, one excitatory and one inhibitory, the model output is ($ x_{1} $ - $ x_{2} $), which corresponds to the membrane potential of pyramidal cells \citep{kandel2000principles}. Also, $ C_{i} $ = $ C \alpha_{i} $, for i =1,\ldots, 4.\\
In order to construct a network of interactive neural mass models, we assume that the pyramidal cell receives input from both its neighbors and the external input from other sources. In a network with $ N $ nodes, the Jansen-Rit dynamical equations are given as follows (i=1,\ldots, N) \citep{forrester2020role}:
\begin{eqnarray}
\begin{array}{lr}
\dot{x}_{0i} (t) = x_{3i} (t)\\
\dot{x}_{3i} (t) = A a S(x_{1i} (t) - x_{2i} (t)) -2a x_{3i} (t) -a^{2}x_{0i} (t)\\
\dot{x}_{1i} (t) = x_{4i} (t)\\
\dot{x}_{4i} (t) = A a \lbrace f_{0i}(t)+ \alpha \sum_{j=1}^{N} M_{ij} S(x_{1j} (t) - x_{2j} (t)) + C_{2} S[C_{1} x_{0i} (t)]\rbrace -2ax_{4i}(t) -a^{2} x_{1i}(t)\\
\dot{x}_{2i} (t) = x_{5i} (t)\\
\dot{x}_{5i} (t) = B b C_{4} S(C_{3}x_{0i}) -2b x_{5i} (t) -b^{2}x_{2i} (t)
\end{array} \label{MJ}
\end{eqnarray}
$ M $ is the adjacency matrix of the network describing how nodes interact and $ \alpha $ is the coupling term between nodes.\\
The parameters of all units are assumed to be the same, and changes in the network behavior result from varying external inputs and coupling coefficient between units.
\subsection{Synchronization quantifier}
Multiple criteria can be used to measure neural interactions, each with its own advantages and disadvantages \citep{bastos2016tutorial}. We quantify the synchronization between neural mass models using the concept of Pearson cross-correlation (Pcc). This quantifier identifies the linear relationship between each pair of random variables. In this measure of correlation, functional connections between individual neurons are determined \citep{lachaux1999measuring}. The Pcc coefficient between two time-series $ x $ and $ y $ is defined as follows:
\begin{eqnarray*}
r = \frac{\sum_{i=1} ^{N}(x_{i} - \langle x \rangle) (y_{i} - \langle y \rangle)}{\sqrt{\sum_{i=1} ^{N}(x_{i} - \langle x \rangle)^2} \sqrt{\sum_{i=1} ^{N}(y_{i} - \langle y \rangle)^2}}
\end{eqnarray*}
Where $ <x> $ is the mean of time series $ x $ and N represents the length of the signal. This coefficient varies between -1 and 1. An amount of 1 (-1) indicates a full linear positive (negative) correlation between two series, whereas 0 signifies no correlation between two series. This definition constructs a symmetric matrix that elements are one in the main diagonal.
\subsection{Bifurcations}
A bifurcation refers to a qualitative change in dynamics caused by changes in the parameters of a dynamical system. Bifurcations have codimensions corresponding to the minimum number of parameters that are required for a system to display the type of bifurcation \citep{kuznetsov2013elements}. \\
Two general classifications of local codimension 1 bifurcations are saddle-node bifurcations and Hopf bifurcations that distinguished by the sign of Jacobian eigenvalues.
The saddle-node (SN) bifurcation is identified by a zero eigenvalue. An SN bifurcation is often undesirable in biological systems, as it can lead the system to depart from its previous operation point, such that functionality is lost \citep{novick1957enzyme, griffith1968mathematics}.
Hopf bifurcations are determined by a Jacobian with a pair of conjugate complex eigenvalues with a zero real part. Their occurrence corresponds to the appearance and disappearance of limit cycles. Therefore, oscillatory dynamics models display this kind of bifurcation. We can further distinguish between supercritical and subcritical Hopf bifurcations by observing on which side of the bifurcation there is a limit cycle.
When a stable steady-state transition to an unstable one results in the emergence of a stable limit cycle, this is known as a supercritical Hopf bifurcation that involves sustained oscillations. Subcritical Hopf bifurcations occur when an unstable cycle coexists with a stable equilibrium on one side of the bifurcation. When an equilibrium becomes unstable, the limit cycles disappear.
A bifurcation of codimension 2 requires tuning two parameters to specific values. Codimension 2 bifurcations in a model are not only of interest theoretically but can also provide information about system dynamics such as bistability and chaos. The following is a brief overview of the most common bifurcations in codimension 2.
\subsubsection*{Generalized Hopf bifurcation:} The Generalized Hopf (GH) bifurcations \citep{bautin1984behavior, shil2001methods} occur at the transition between supercritical and subcritical Hopf bifurcations.
\subsubsection*{Bogdanov-Takens bifurcation:}The Bogdanov-Takens (BT) bifurcation \citep{takens1974singularities, carrillo2010analysis} exhibits two zero real eigenvalues of the Jacobian matrix. An BT bifurcation occurs when a saddle-node bifurcation collides with a Hopf bifurcation.
\subsubsection*{Cusp bifurcation:} A cusp bifurcation point (CP) \citep{guardia2010analytical} is a specific type of SN bifurcation that can be used to identify bistable regions.\\
It is noteworthy that on a two-parameter bifurcation diagram, codimension-1 bifurcations appear as one-dimensional lines \citep{guckenheimer2013nonlinear}.
\subsection{Equilibria}
By setting the left-hand side of (\ref{MJ}) to zero, the network equilibria (called fixed-point) is determined, thus starting the bifurcation analysis. Let $ x_{i} $ = ($ x_{0i} $,\ldots,$ x_{5i})^{T} $ for i=1, \ldots, N. The system has the following form:
\begin{equation}
\dot{x}_{i}=F(x_{i};f_{0},\alpha)
\end{equation}
Where F is the smooth map from $ R^{6} $ to $ R^{6} $ according to (\ref{MJ}) and $ f_{0} $ and $ \alpha $ are the inputs from external sources and the coupling term between nodes, respectively. Writing $ \dot{x}_{i}=0 $ for each i=1,\ldots, N. This gives us the system of equations (i=1,\ldots, N):
\begin{eqnarray}
\label{equilib}
\begin{array}{lr}
\dot{x}_{3i} (t) = 0\\
\dot{x}_{4i} (t) = 0\\
\dot{x}_{5i} (t) = 0\\
\dot{x}_{0i} (t) = \frac{A}{a} S(x_{1i} (t) - x_{2i} (t))\\
\dot{x}_{1i} (t) = \frac{A}{a} \lbrace f_{0i}(t)+ \alpha \sum_{j=1}^{N} M_{ij} S(x_{1j} (t) - x_{2j} (t)) + C_{2} S[C_{1} x_{0i} (t)]\rbrace \\
\dot{x}_{2i} (t) = \frac{B}{b} C_{4} S(C_{3}x_{0i})
\end{array}
\end{eqnarray}
According to the EEG signal, the variable ($ x_{1}-x_{2} $) reflects the firing rate of pyramidal cells. In the cortex's superficial layer, which accounts for the majority of the EEG, the apical dendrites of pyramidal neurons deliver their postsynaptic potentials. So, we define $ \mathsf{x}_{i}:=x_{1i} - x_{2i} $ which leads to the following implicit equations:
\begin{equation}\label{eqib_2}
\mathsf{x}_{i}(t) = \frac{A}{a} \left[ f_{0} + \alpha \sum_{j=1}^{N} M_{ij} S(\mathsf{x}_{i}(t)) + C_{2} S[C_{1} \frac{A}{a}S(\mathsf{x}_{i}(t))] \right] - \frac{B}{b} C_{4} S(C_{3} \frac{A}{a} S(\mathsf{x}_{i}(t)))
\end{equation}
for i=1, \ldots, N.\\
It is important to note that we assume all local parameters are identical, thus allowing network behavior only to change as inputs vary.
\subsection{Simulation}
In this simulation, a regular Watts-Strogatz network
was considered with 50 phase oscillators as nodes. Nodes are connected to eight neighbors, four on either side. We investigated the Jansen-Rit dynamics in all nodes. Runge–Kutta algorithm was chosen to integrate the system using a time step of $ 10^{4} $ s. Each simulation was 200 seconds long. On each coupling coefficient, each simulation twelve times. First, we used high-intensity noise to prevent bias in special conditions (up to 2.5s). Then, the noise was interrupted, and after some fluctuations, the equilibrium state was reached. By discarding the first 100 seconds of simulation from further analysis, we were confident that the system had reached to its equilibrium. Every node received an input from another part of the brain as an external input. Different aspects of network behavior are explored when the coupling coefficient between nodes and external inputs varies widely. Moreover, the initial conditions were changed in each repetition.
\section{Results and discussion}
In order to solve (\ref{eqib_2}), two approaches are available. First, we assume identical inputs for nodes by using the mean-field approximation ($ \mathsf{x}_{1} = \ldots, \mathsf{x}_{N} = \mathsf{x} $). In the second case, it is assumed that nodes do not create identical outputs. These two states are examined separately.
\subsection{Analysis of network behavior based on mean-field approach:}
In this case, equation (\ref{eqib_2}) converts to the following equation:
\begin{equation}
\mathsf{x}(t) = \frac{A}{a} \left[ f_{0} + \alpha \sum_{j=1}^{N} M_{ij} S(\mathsf{x}(t)) + C_{2} S[C_{1} \frac{A}{a}S(\mathsf{x}_{i}(t))] \right] - \frac{B}{b} C_{4} S(C_{3} \frac{A}{a} S(\mathsf{x}(t))).
\end{equation}
Using the MatCont package in Matlab, we investigate bifurcations numerically. Indeed, Matcont is a MATLAB software package for numerically exploring dynamical systems in particular bifurcation studies \citep{dhooge2006matcont}. Detailed bifurcation analysis of the single Jansen-Rit neural mass model, can be found in \citep{touboul2011neural}. To determine whether firing rate affects Jansen-Rit dynamics, Grimbert and Faugeras \citep{grimbert2006bifurcation} brought all the other parameters to the physiological values provided in Table 1. Moreover, 2-codimension bifurcation in a single Jansen-Rit model were investigated as a function of two critical parameters and a very rich bifurcation diagram was presented \citep{touboul2011neural}.
A codimension 2 bifurcation diagram is plotted in figure \ref{bif_1}. A positive or negative value of these parameters ($ \alpha $ and $ f_{0} $) is mathematically permissible. Although negative inputs are not fully physiologically relevant, they provide an insight into the origin of dynamical features observed at more physiologically relevant values. The light blue color region indicates the steady-state activity, and the solution will converge to this fixed point regardless of the initial conditions.
The black star in the diagram represents Generalized Hopf (GH) bifurcation ($ (\alpha, f_{0}) = (0.2275, 40.2397) $) resulting from the Bogdanov-Takens (BT) bifurcation. The green (orange) color curve shows the subcritical (supercritical) Hopf bifurcation that is related to the negative (positive) fixed-point.
The BT bifurcation point is on the lower branch of the saddle-node bifurcations curve (red color). This BT bifurcation, gives rise to subcritical Hopf bifurcation (green curve) or a curve of saddle homoclinic bifurcations (purple curve).
The red curve illustrates a saddle-node bifurcation generated by a Cusp bifurcation (CP). The region between the purple and red color border (pink zone) displays spiking behavior with a large amplitude (figure \ref{bif_1}(\textbf{c})) and low frequency ($ \sim $ 4 Hz). In the purple border, fixed-point state and oscillatory state are separated by Hopf cycles. In ($ \alpha $, $ f_{0} $) = (0, 120) large amplitude signals are appear. Results show that when ($ \alpha $, $ f_{0} $) = (0, 130), spiking behavior will disappear and the system emerges oscillatory activities. There is an oscillatory activity in the green region that is associated with alpha rhythms (figure \ref{bif_1}(\textbf{d})).
\begin{figure}[!ht]
\centering
\includegraphics[width=10cm, height=8cm]{Fig2.pdf}
\caption{\textbf{(a)} Codimension 2 bifurcations of Jansen-Rit model in a network in the ($ \alpha $, $ f_{0} $)-plane. Each color and label enjoy different dynamical properties. Codimension 1 bifurcation curves are shown in red: saddle-node, green: subcritical Hopf, orange: supercritical Hopf, purple: saddle homoclinic. Codimension 2 bifurcation points: CP: Cusp, BT: Bogdanov-Takens, GH: Generalized Hopf. \textbf{(b)} shows the specific area ($ \alpha $, $ f_{0} $) of \textbf{(a)} that is positive. The light blue color region indicates the steady-state activity. The pink color displays spiking behavior with a large amplitude (panel \textbf{(c)}). An oscillatory pattern can be seen in the green zone, which correlates with alpha rhythms (panel \textbf{(d)}).}
\label{bif_1}
\end{figure}
\subsection{Analysis of network behavior based on nonidentical input/output from each node:}
Although the simplicity of the mean-field approach is their strong point, using this assumption poses that all nodes are fully synchronized, and consequently the system is being at a full synchronization state, which is not the case in reality. So, we relax this assumption. The dimensionality and complexity of the system make it impossible to plot bifurcation diagrams with the Matcont package in this case. We construct a grid
$ (\alpha, f_{0}) = \left\lbrace 0, 0.5, 1, 1.5, ..., 19.5\right\rbrace \times \left\lbrace 0, 10, 20, 30, ...330\right\rbrace . $
Making use of the measure described in Section \ref{method}, we study the network synchronization. The scheme of the mean synchronization matrix as a function of coupling coefficients and external inputs is found in figure \ref{corr}. This figure is divided into different segments based on the activity type. All of these areas are thoroughly investigated as follows.
\begin{figure}[!ht]
\centering
\includegraphics[width=10cm, height=4.5cm]{Fig3.png}
\caption{The mean Pearson cross coefficient as a function of coupling strengths ($ \alpha $) and external inputs ($ f_{0} $). Each color and label exhibits different dynamical properties. This figure is divided into different segments based on the activity type and synchronization value.}
\label{corr}
\end{figure}
\subsubsection*{G area:}
As a result of either the extremely high coupling strength or the external input, the system is at rest. Due to excessive input, it is reasonable for the system to reach a stable equilibrium. The numerical amount of fixed points is the positive number.
\subsubsection*{A area:}
Contrary to the 'G' zone, the weak intensity of input cannot create fluctuations in the 'A' zone, which means that the system has entered a state of rest. Although the steady-state for small values of external input ($ < $50) is negative, which has no biological significance, the neighbors each of these has a wide variation of behaviors. Some interesting behaviors along the border between this area and the 'B' and 'C' areas are seen. It is observed that the system starts to fluctuate, and after a short time goes to rest.
It has indeed been unable to remain oscillating forever and has finally entered a fixed-point. Throughout this zone, multi-stability can exist between nodes. It means that due to different initial conditions and different inputs during the simulation, some nodes are being at rest, whereas others emit oscillatory activity or take different fixed points. Notably, the mean system activity finally reaches a stable equilibrium. As shown in figure \ref{E_border}, two cases have been observed in this area.
\begin{figure}[!ht]
\centering
\includegraphics[width=10cm, height=4.2cm]{Fig4.pdf}
\caption{Two behaviors in the border between 'A' area and 'B' and 'C' zones. Due to different initial conditions and different inputs during the simulation, some nodes are being at rest, whereas others emit oscillatory activity or take different fixed points (panel \textbf{(a)}). In some cases, all nodes are in a fixed-point state (panel \textbf{(b)}).}
\label{E_border}
\end{figure}
\subsubsection*{B area:}
Individual oscillators leave their fixed points and start to fluctuate. Observe that when the single cell of Jansen-Rit dynamics receives input of over 315, it goes to rest \citep{grimbert2006bifurcation}. As the inserted inputs to each unit in this area are more than this value, we expected the system to be at rest, but spiking mode is observed.\\
Different types of activity, including periodic and nonperiodic spikes and chaotic activity with the low-frequency band, are visible in the 'H' area. A generalized spike wave discharge (GSWD) occurs in this region. In the corticothalamic networks, GSWDs typically occur after paroxysmal \citep{martinet2017human}, but their exact mechanism is not clear yet. The emergence of high amplitude signals confirms a disorder such as epileptic seizure in a brain network \citep{maturana2020critical}. In figure \ref{H_area}, the left column is related to the chaotic, periodic, and mixed of these two oscillation states, respectively, and their phase portraits are viewed in the right column. Results show that the mean and variance of the cross-correlation matrix are varied widely. Figure \ref{corr_H} depicts the synchrony matrices of states from figure \ref{H_area}. A zero correlation (in chaotic activity), a complete correlation (in ordered periodic signals), and a correlation approximately equal to 0.5 (in mixed of ordered and disordered activity) exist. Actually, a range of different patterns of the correlation matrix is found. Noteworthy, a saddle-node bifurcation has occurred between the 'A' and the 'B' areas at the border between fixed-point state and spiking activity.
\begin{figure}[!ht]
\centering
\includegraphics[width=10cm, height=10cm]{Fig5.pdf}
\caption{Three behaviors in the 'B' area. Chaotic (\textbf{(a)}), periodic (\textbf{(c)}), and mixtures of these two oscillation states (\textbf{(e)}) are shown. The phase portraits of (\textbf{a}), (\textbf{c}), and (\textbf{e}) are viewed in (\textbf{b}), (\textbf{d}), and (\textbf{f}) respectively.}
\label{H_area}
\end{figure}
\begin{figure}[!ht]
\centering
\includegraphics[width=10cm, height=3.5cm]{Fig6.pdf}
\caption{The synchrony matrices of states from figure \ref{H_area}. (\textbf{a}) a zero correlation (in chaotic activity), (\textbf{b}) a complete correlation (in ordered periodic signals), and (\textbf{c}) a correlation approximately equal to 0.5 (in mixed of ordered and disordered activity) are exist.}
\label{corr_H}
\end{figure}
\subsubsection*{C area:}
All nodes exhibit oscillatory activity in region 'C'. The fluctuations have no fixed amplitude and have changed based upon the coupling coefficient or external input. Increasing or decreasing these factors have affected the fluctuation amplitude. Three arbitrary states in this regime and their phase portrait are shown in the left and right columns of figure \ref{G_area}, respectively. Figure \ref{G_corr} shows the synchrony matrix for each of the three cases in figure \ref{G_area}. Increased coupling coefficients or external input results in larger signal amplitudes and expanded phase-space volumes. The correlation value in this area is close to zero, which means there is no linear relationship between the nodes. Chaos is the name we give to this area. The boundary between 'A' and 'C' refers to the appearance of a periodic orbit through a change in the stability properties of a fixed point known as the Hopf bifurcation. Moreover, taking synchronization as an order parameter, this boundary can separate the ordered phase (A) from the disordered phase (C), and so, a phase transition is expected.
\begin{figure}[!ht]
\centering
\includegraphics[width=10cm, height=10cm]{Fig7.pdf}
\caption{Three arbitrary behaviors (left columns) and their phase portrait (right columns) in the 'C' area. Increased coupling coefficients or external input results in larger signal amplitudes and expanded phase-space volumes.}
\label{G_area}
\end{figure}
\begin{figure}[!ht]
\centering
\includegraphics[width=10cm, height=3.5cm]{Fig8.pdf}
\caption{The synchrony matrices of states from figure \ref{G_area}. The correlation value in this area is close to zero, which means there is no linear relationship between the nodes.}
\label{G_corr}
\end{figure}
\subsubsection*{D area:}
There is no spiking activity in this region, and the modulated signals are visible. Different exciting patterns in correlation matrices have emerged. Indeed, the 'D' zone is located between full synchronous ('E') and asynchronous ('C') areas. A summary of the most repeatable is shown in figure \ref{2_corr}. On the border of the 'E' ('C') area, the correlation matrix has a high (low) mean. Figure \ref{2_area} shows the mean signals and their phase spaces for each matrix in figure \ref{2_corr}. $ (\alpha, f_{0}) = $ (13.5, 120), $ (\alpha, f_{0}) = $ (11, 180) are in the border of 'E' area and are showing a phase space close to that of a regular limit cycle. Also, $ (\alpha, f_{0}) = $ (13.5, 120) displays periodic and regularity patterns. On the edge of 'C' area, irregularity trends are observed in $ (\alpha, f_{0}) = $ (14, 80). In $ (\alpha, f_{0}) = $ (10, 170) that possesses no common border with any area, the phase space is composed of both regular and irregular activity.
\begin{figure}[!ht]
\centering
\includegraphics[width=8cm, height=8cm]{Fig9.pdf}
\caption{Four different patterns in correlation matrices in the 'D' zone. In the border of the 'E' area (panel \textbf{(b)}, \textbf{(c)}), the correlation matrix has a high mean. There is a low mean in the correlation matrix in the 'C' area (panel \textbf{(d)}).}
\label{2_corr}
\end{figure}
\begin{figure}[!ht]
\centering
\includegraphics[width=8cm, height=11cm]{Fig10.pdf}
\caption{The time series (left columns) and their phase spaces (right columns) of states from figure \ref{2_corr}. The modulated signals are visible and there is no spiking activity in this region (left columns). Panel \textbf{(d)} and \textbf{(f)} are on the border of the 'E' area, and they show a phase space close to that of a regular limit cycle. On the edge of the 'C' area, irregularity trends are observed in panel \textbf{(h)}. Panel \textbf{(b)} is composed of regular and irregular activities because possessing no common border with any area.}
\label{2_area}
\end{figure}
\subsubsection*{E area:}
Here is where the complete system synchronization begins and the nodes are approximately synchronized. Indeed, the system tends to synchronize strongly with each coupling coefficient. A single Jansen-Rit mass possesses a stable equilibrium where the received input exceeds 315 \citep{grimbert2006bifurcation}.
Surprisingly, almost all of the input has received by the system in this zone is more than 315, but the system still shows oscillatory behavior. Actually, interactions between nodes make this possible. The one arbitrarily chosen sample of the mean signal, its phase space, and its correlation matrix in this area are displayed in figure \ref{F_all}.
\begin{figure}[!ht]
\centering
\includegraphics[width=12cm, height=3.7cm]{Fig11.pdf}
\caption{One arbitrarily chosen sample of the mean signal (panel \textbf{(a)}), its phase space (panel \textbf{(b)}), and its correlation matrix (panel \textbf{(c)}) in the 'E' region. The nodes are approximately synchronized, and complete system synchronization is observed.}
\label{F_all}
\end{figure}
\subsubsection*{F (Zero coupling coefficient) area:}
In uncoupled oscillators ($ \alpha = $ 0 in the system) with external input less than 90, each node is at a fixed point. So, the mean network behavior is non-active. Note that the value of system fixed-point is negative (positive) for external input less (more) than 50.\\
In $ f_{0} = $100, 110, some nodes start to fluctuate. Each node has two states in these values: a fixed-point and a stable limit cycle producing the alpha rhythm.
The value of $ f_{0} = $ 120 is the minimum of external input at which all nodes leave the fixed-point and show fluctuations. Moreover, two types of activity are visible in each node: Spiking and Oscillating (figure \ref{res_120}\textbf{(a)}). Therefore, the appearance of the mean activity has a strange trend (figure \ref{res_120}\textbf{(b)}).
This behavior is continued up to $ f_{0} = $ 140. The spiking type disappears at the higher value of $ f_{0} = $ 140. When $ f_{0} $ varies between 140 and 310, only oscillatory activity occurs at individual nodes. At $ f_{0} = $ 320, all nodes leave the limit cycle and rest in a fixed point. \\
As a summary, two Hopf bifurcations occur at $ f_{0} \simeq $ 90, 320. At $ f_{0} \simeq $ 120, a saddle-node on an invariant curve (SNIC) bifurcation happens. Moreover, at $ f_{0} \simeq $ 140, a Limit Point of Cycle (LPC) bifurcation is observed.
It is imperative to note that the zero coupling coefficient region is the same as a single Jansen-Rit mass that has been investigated in detail in \citep{grimbert2006bifurcation}.
\begin{figure}[!ht]
\centering
\includegraphics[width=10cm, height=3.8cm]{Fig12.pdf}
\caption{(\textbf{a}) The activity of each node for $ (\alpha, f_{0}) $ = (0, 120). Two Spiking and Oscillating activities are visible in each node. Panel (\textbf{b}) shows the mean of these activities.}
\label{res_120}
\end{figure}
\subsubsection*{Some special cases:}
Each segment of the synchronization matrix map has been investigated based on its properties so far. We have examined in-dept several specific characteristics such as the time series of each unit and the correlation matrix between them, the mean signals, and finally, their phase portraits of the network.
It is important to note that some interesting patterns are formed at a boundary between areas. Several of these cases are examined in detail as follows:\\
\begin{itemize}
\item $ (\alpha, f_{0}) $ = (17.5, 0): At this point, the nodes are synchronized, and the network shows either a resting state at the negative fixed-point or oscillatory activity depending on initial conditions. This coexistence of two distinct attractors at the same parameter value is called bistability. According to theoretical and empirical studies, bistability is associated with first-order phase transitions \citep{cowan2016wilson, cocchi2017criticality}. Mathematically, this transition is equivalent to subcritical bifurcation \citep{pomeau1986front}. Indeed, the mean signal of the model erratically switches between a fixed point and a limit cycle attractor. The nodes are either in a quiescent phase or an oscillating state simultaneously (Figure \ref{Fig16}). The phenomenon of bistability can be explained very well by a type of bifurcation known as the cusp \citep{harlim2007cusp}.
\begin{figure}[!ht]
\centering
\includegraphics[width=10cm, height=3.8cm]{Fig16.pdf}
\caption{Two possible behaviors for $ (\alpha, f_{0}) $ = (17.5, 0). At this point, the nodes are synchronized, and the network shows either a resting state at the negative fixed-point (panel \textbf{(b)}) or oscillatory activity (panel \textbf{(a)}) that depends on initial conditions. Indeed, the nodes are either in a quiescent phase or an oscillating state simultaneously.}
\label{Fig16}
\end{figure}
\item $ (\alpha, f_{0}) $ = (2, 90), (1, 100): The three types of behavior presented here by each node are fixed-point state, spiking activity, or oscillatory activity. The mean of the network either exhibits a fixed point attractor or spiking activity. Figure \ref{special_case} shows two arbitrary runs of each state. Moreover, there are numerous patterns in the Pearson correlation matrix (Figure \ref{special_case_corr}). The red (blue) color indicates full synchronization (anti-synchronization). Local and global synchronization is also shown in these figures. These types of synchronizes are denoted by the red and blue masses, respectively. In local synchronization, some ensembles of neurons behave the same, i.e., synchronized clusters, but others act in completely different ways. In fact, Pearson cross-correlation matrices containing only red color signify a global synchrony state. The blue and red masses indicate in-phase and antiphase local synchrony states, respectively. Additionally, The presence of green masses is related to local asynchrony, which means there is no synchronization. This different pattern could reflect different brain network synchronization patterns during different types of tasks \citep{nazemi2019influence}.\\
Due to the high variance of the synchronization value, these points are suitable candidates to identify the second phase transitions. In order to claim that the second phase transition occurs at any of these points, we should compute the coefficient of variation (CV) against the control parameter \citep{di2018landau}. Indeed, CV is a statistical measure of the dispersion of data points in a data series around the mean. A peak in the coefficient of variation during the continuous phase transition (if it exists) would be the first marker of the second phase transition \citep{kazemi2022phase}.
According to figure \ref{CV}, $ (\alpha, f_{0}) $ = (2, 90), (1, 100) can be shown the second phase transition. Notably, the CV value for alpha greater than 3 at f=90, 100 is approximately zero and therefore is discarded in figure \ref{CV}.
\begin{figure}[!ht]
\centering
\includegraphics[width=9cm, height=7.5cm]{Fig15.pdf}
\caption{Two arbitrary runs for $ (\alpha, f_{0}) $ = (2, 90), (1, 100). The three types of behavior by each node are fixed-point state, spiking activity, or oscillatory activity (panel \textbf{(a)} and \textbf{(c)}). Panel \textbf{(b)} and \textbf{(d)} show the mean activity of \textbf{(a)} and \textbf{(c)}, respectively.}
\label{special_case}
\end{figure}
\begin{figure}[!ht]
\centering
\includegraphics[width=7cm, height=5.7cm]{Fig13.pdf}
\caption{Four patterns in the Pearson correlation matrix from figure \ref{special_case}. The red (blue) color indicates full synchronization (anti-synchronization). The green masses are related to local asynchrony, which means there is no synchronization (panel \textbf{(a)} and \textbf{(b)}). Some ensembles of neurons behave the same, i.e., synchronized clusters that are visible in panel \textbf{(a)}. Panel \textbf{(c)} shows the asynchrony state. Panel \textbf{(d)} contains only red color signifies a global synchrony state.}
\label{special_case_corr}
\end{figure}
\begin{figure}[!ht]
\centering
\includegraphics[width=8cm, height=6cm]{cv_f0.pdf}
\caption{The coefficient of variation (CV) against the coupling coefficient for $ f_{0} $ = 90, 100. These points of a maximum of these curves correspond to the value of the transition points. Notably, the CV value for alpha greater than 3 at f=90, 100 is approximately zero and therefore is discarded here.}
\label{CV}
\end{figure}
\item $ (\alpha, f_{0}) $ = (0.5, 110), (1.5, 100): Nodes here exhibit either spiking activity or oscillatory activity (Figure \ref{special_case_second}). The mean of the network shows the chaos caused by spiking and oscillation. The correlation matrix is similar to the 'G' area and has a zero value.
\begin{figure}[!ht]
\centering
\includegraphics[width=10cm, height=8.5cm]{Fig17.pdf}
\caption{Two arbitrary runs for $ (\alpha, f_{0}) $ = (0.5, 110), (1.5, 100). Nodes exhibit either spiking activity or oscillatory activity (panel \textbf{(a)} and \textbf{(c)}). Panel \textbf{(b)} and \textbf{(d)} show the mean activity of (a) and (c), respectively.}
\label{special_case_second}
\end{figure}
\end{itemize}
Interestingly, the first special case lies on the border of several different areas ('B', 'E' and 'G') and the first phase transition. So, these overlaps have been lead to different surprising results. Other special cases explained before are situated on the border of fixed-point and oscillatory activity that some of them are related to the second phase transition.
The correlation matrix between nodes, mean time series, and their phase spaces for all considering coupling coefficients and external inputs are available in Supplementary 1, Supplementary 2, and Supplementary 3, respectively.
\subsection{Frequency domain analysis}
Using dominant frequency as a tool for signal analysis can provide valuable insight into brain disorders \citep{goel1996dominant, goossens2017eeg, newson2019eeg}. In order to determine the dominant frequency, the power spectrum of a signal is plotted. The dominant frequency is usually the one that carries the most energy, which can be observed on a magnitude spectrum as the peak frequency \citep{think2014digital, unpingco2016python}. Additionally, the fundamental frequency is the lowest frequency on a power spectrum with a peak \citep{telgarsky2013dominant}.
The dominant frequency value is plotted as a function of the coupling term and external input in figure \ref{dominant rhythm}. These subplots (a) and (b) are related to nonidentical and identical inputs from each node, respectively. (a) has a smaller steady-state region than (b). In other words, each node's nonidentical inputs contribute to the emergence of oscillatory behavior. Notably, an increase in one direction (coupling term or external input) increases the dominant frequency in (a) and (b) states.
Different rhythms, including delta, theta, and alpha, can be observed in every two states, (a) and (b).
\begin{figure}[!ht]
\centering
\includegraphics[width=13.2cm, height=5.2cm]{Fig18.pdf}
\caption{The dominant frequency value as a function of the coupling term and external input. Panel \textbf{(a)} and \textbf{(b)} are related to nonidentical and identical inputs from each node, respectively. Different rhythms, including delta, theta, and alpha, can be observed in these two states. Moreover, an increase in one direction (coupling term or external input) increases the dominant frequency in \textbf{(a)} and \textbf{(b)}. Using Seaborn, a Python data visualization library based on Matplotlib, we visualized the data.}
\label{dominant rhythm}
\end{figure}
Delta oscillations correspond to the low-frequency range ($ < $ 4 Hz). Delta waves represent the slowest recorded brain waves with high amplitudes in humans and are associated with deep sleep stages. The presence of delta waves is prominent in brain injuries and learning disabilities \citep{alfimova2007changes}. They also affect concentration \citep{abhang2016introduction}. Moreover, the absence seizure is characterized by spike-wave discharges that occur during the delta-band frequency \citep{hindriks2013phase}. Due to figure \ref{dominant rhythm}, by altering the inputs in a network of Jansen-Rit neural mass models, delta waves can be generated that have not previously been observed in a single Jansen-Rit neural mass analysis \citep{grimbert2006bifurcation}. It is an emergent property of a complex system. The following statement states that no isolated node represents a delta rhythm, but this rhythm can emerge when these units interact with each other in a complex system.\\
Learning and memory may be affected by theta oscillations, a rhythm that appears at 4$ - $8 Hz \citep{seager2002oscillatory, eggermont2021brain}. An electrode recording in the hippocampal region can clearly reveal theta oscillations, which are high-amplitude neuronal oscillations \citep{buzsaki2002theta, munro2019theta}. Past studies have attributed theta rhythms to various clinical conditions, including epilepsy \citep{douw2010epilepsy}, however, their common occurrence has been recognized as a normal phenomenon \citep{mari2019normal}. Based on figure \ref{dominant rhythm}, nonidentical inputs (a) result in a smaller theta frequency region than identical inputs (b). Indeed, the alpha rhythm in (a) is propagated sooner than (b), which is more intriguing.\\
There are macroscopic oscillations of the brain in the range of 8$ - $12 Hz known as alpha waves. Analyses of electrophysiological methods, such as electroencephalography (EEG) and magnetoencephalography (MEG), detect the alpha waves as part of the brain wave activity \citep{fumagalli2012functional, ince2021inventor}. In the human brain, alpha-band oscillations are dominant and also play a significant role in information processing \citep{klimesch1997eeg, sigala2014role}. The first pixel in (b) that alpha rhythm can emerge, is in $ f_{0} $ = 50. Surprisingly, interacting nodes make it possible to observe the alpha rhythm even if there is no external input (a).
\section{Conclusion}
We studied the dynamical properties of a network composed of 50 coupled oscillators with Jansen-Rit masses under a regular Watts-Strogatz model. Each node receives both deterministic external and internal inputs based on what it receives from its neighbors.
We can use both the external input and coupling gain (internal input) as bifurcation parameters to obtain a more comprehensive understanding of network behavior.
Two fundamental forms of system output have been discussed: (i) using a mean-field approximation to generate identical input for all nodes and (ii) nonidentical input for all nodes.
In case (i), we have shown that this system exhibits very rich dynamics, displaying various bifurcations. Fixed-point, oscillatory activity, and seizure-like activity are three activities in this state.
In case (ii), different types of synchronization are observed depending on the internal and external inputs. We have examined in-dept several specific characteristics, such as the time series of each unit and the correlation matrix between them, the mean signals, and finally, their phase portraits of the network. Similar to case (i), steady-state, oscillatory, and seizure-like activities were observed in this state. Moreover, we showed some interesting patterns that were formed at the boundaries between the areas. Afterward, the network behavior in the frequency domain was examined. Delta, theta, and alpha rhythms appeared in our data.\\
Moreover, in case (i), we find that there is no phase transition despite observed behavior changes. It is surprising to find that both the first (discontinuous) and second (continuous) phase transitions result from relaxing the mean-field assumption (case (ii)). While mean-field approximation is a valid and valuable method in a complex systems investigation, it may result in omitting some noteworthy phenomena. Moreover, this theory is not efficient and accurate in asynchrony cases.\\
We investigated how inputs changes can result in pathological oscillations similar to those observed in epilepsy. Moreover, our findings indicated that delta waves can be generated by altering inputs in a network of Jansen-Rit neural mass models, which has not been previously observed in a single Jansen-Rit neural mass analysis.\\
To put it briefly, a network can have different complex behaviors depending on the randomness of the input, the initial conditions, the noise, and the coupling strength. Although delays between neural populations may lead to intriguing dynamics in networks, we assumed that they were zero in this study. If this were to be taken into account, it could have significant implications.
\section*{Declaration of interests}
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
\section*{Credit Author Statement}
\textbf{Yousef Jamali}: Supervision, Conceptualization, Formal analysis, Investigation, Methodology, Project administration, Resources, Software, Validation, Writing – review and editing\\
\textbf{Sheida Kazemi}: Conceptualization, Data curation, Formal analysis, Investigation, Methodology, Software, Validation, Visualization, Writing – original draft, Writing – review and editing
\section*{Funding}
This work has been supported in part by a grant from the Cognitive Sciences and Technologies Council with grant No. 8226. In addition, the second author is indebted to the Research Core: ”Bio-Mathematics with computational approach” of Tarbiat Modares University, with Grant No. IG-39706.
\bibliographystyle{elsarticle-num}
|
{'timestamp': '2022-02-17T02:28:53', 'yymm': '2202', 'arxiv_id': '2202.06634', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06634'}
|
arxiv
|
\section{Introduction}
Human mobility research studies individual and collective human movement in space and time.
Examples of human mobility include livelihood mobility, urban migrations, and traffic flows.
Understanding human mobility is essential to multiple social-economic aspects such as mitigating urban traffic congestion and improving public health~\cite{barbosa2018human}. For instance, human mobility plays a significant role in understanding the dispersal of infectious diseases such as COVID-19. Comprehension of human mobility could help predict the variation of diseases to enable optimal decision making and public health interventions at early stages~\cite{zheng2021exploring}.
\medskip
\noindent An important aspect of human mobility study is modeling and prediction of human mobility patterns. Accurate modeling and prediction can provide opportunities to monitor, manage and optimize human movement. For example, effective modeling of urban traffic flow could suggest strategies to mitigate traffic jam, promoting road safety and reducing environmental impacts. Human mobility at different scales exhibit different natures. Mobility on the individual scale typically depends on a large number of uncertainty factors such as individual mood or emotions; it thus often shows a stochastic nature. On the other hand, human mobility on the scale of groups demonstrates a deterministic nature, and the nature can be understood as an average/expectation of a large number of individual mobility.
\medskip
\noindent Based on the scale of mobility, current models can be classified into two categories: individual mobility model and general population model.
Individual models aims at reproducing individual mobility patterns. Typical examples include Brownian motion model, Levy flight model, continuous time random walk model, and preferential return model. In contrast, general population models seeks to describe the aggregate mobility of many individuals.
Representatives include the gravity model proposed by Zipf, which was inspired by Newton's Law of Gravitation~\cite{zipf1946p}; intervening opportunities models introduced by Stouffer~\cite{stouffer1940intervening}, and the radiation model proposed by Simini et al.~\cite{simini2012universal}, which is parameter-free and can be used without mobility measurement. We refer readers to the reference~\cite{barbosa2018human} for a comprehensive review of different models as well as their weakness and strength.
\medskip
\noindent As the average of numerous individual behaviors, mobility of populations usually features significantly higher stability and predictability. We therefore focus on modeling population mobility in this paper.
All the aforementioned population mobility models are based on the intrinsic physics, thus depending on accurate prior knowledge to achieve accurate modeling.
On the other hand, the development of information and communication technologies
has made large-scale mobility-related datasets more accessible than ever before.
With the advance of machine learning methodology, powerful data-driven machinery becomes available to extract statistically meaningful patterns from these large datasets. The goal of this paper is to evaluate a data-driven, equation-free modeling approach known as the dynamic mode decomposition.
\medskip
\noindent The dynamic mode decomposition(DMD) is a data-driven method that can provide effective modeling of dynamical systems~\cite{kutz2016dynamic}. The method was initially proposed by Schmid and Sesterhenn~\cite{schmidandsesterhenn} and Schmid~\cite{schmid2010dynamic}
in fluid dynamics, yet later found wide applications in a variety of areas including video processing~\cite{grosek2014dynamic}, epidemiology~\cite{proctor2015discovering}, neuro-science~\cite{brunton2016extracting}, and financial trading~\cite{mann2016dynamic}.
The idea of DMD is to learn a temporal low rank structure of the dynamic systems. It is therefore also a dimension reduction technique, which makes it ideal for processing large-scale data.
In this paper, we will apply DMD to model the population human mobility between different states in the US from 2019 to 2021 using the publicly available dataset~\cite{kang2020multiscale}. We will build multiple DMD models with different low rank structures, and evaluate their accuracy in predicting future human mobility patterns.
\medskip
\noindent The paper is organized as follows. We describe the structure of the human mobility data set in use in Section 2. Section 3 presents the idea of DMD in detail and formulates the precise algorithm. Section 4 includes multiple numerical experiments to validate the efficacy of DMD in modeling population human mobility with different training and testing datasets.
\section{Data Structure}
The dataset we will utilize to model human mobility is the multis-cale dynamic human mobility flow dataset collected in~\cite{kang2020multiscale} and made publicly available on Github~\cite{github}.
It consists of daily and weekly human mobility flow data collected across the United States from 2019 to 2021.
The dataset is collected with the help of the mobile phone application ``SafeGraph'' and pre-processed in several steps. First, selected mobile phone users from an origin to various destinations are tracked to generate visit information. Next, users in selected regions are grouped to form multiple clusters, and daily/weekly visit information between two clusters are calculated by summing up the number of individual users.
Next, data are aggregated into three spatial scales: census tract, county and state by grouping all records based on the origin-destination(O-D) pairs. Finally, the dynamic population flow from the geographic origin ``$o$'' to the geographic destination ``$d$'' is inferred from the visitor flow using the following relation:
\begin{equation} \label{eq:popflow}
pop\_flows(o,d)= visitor\_flows(o,d)\times \frac{pop(o)}{num\_devices(o)}
\end{equation}
where $pop\_flows(o,d)$ is the estimated dynamic population flows from the origin $o$ to the destination $d$, $visitor\_flows(o,d) $ is the computed mobile phone-based visitor flow from $o$ to $d$, $pop(o)$ is the population
at the origin $o$ extracted from the American Community Survey~\cite{webster2006us}, and $ num\_devices(o)$ is the number of unique mobile devices residing in $o$. Details description of these steps are described in~\cite{kang2020multiscale}.
\medskip
\noindent In this paper, we will make use of weekly visit flow data between different states. The data includes 52 distinct places as origins and destinations: 50 states, Washington D.C., and Puerto Rico.
The weekly visitor flow data is recorded in a data matrix~\cite{github} with nine columns of information consisting of unique identifiers for origins and destinations, geographic locations of origins and destinations, data range of the records, estimated visitor flow, and inferred population flow based on the relation~\eqref{eq:popflow}.
The information that is directly used in this paper is identifiers for origins and destinations, data range, and estimated visitor flow. We attempt to utilize the information to model and predict collective human mobility patterns.
\section{DMD Algorithm}
The dynamic mode decomposition(DMD) is an equation-free and data-driven method in modeling dynamic systems using high dimensional data~\cite{kutz2016dynamic,Tu2014OnDM,bistrian2015improved,brunton2016extracting,mohan2018data}. It is designed to learn coherent patterns of dynamic systems.
Specifically, for a dynamical system
\begin{equation} \label{eq:ds}
\frac{dx}{dt} = f(x,t;\mu)
\end{equation}
where $x(t)\in \mathbb{R}^n$ is the state of the system at time $t$, $\mu$ represents parameters of the system, and $f(x,t;\mu)$ represents the dynamics, its corresponding discrete-time form can be obtained by evolving~\eqref{eq:ds} by a fixed time step $\Delta t$. Denote $x_k := x(k\Delta t)$ where $x$ is the solution of~\eqref{eq:ds}, then the Fundamental Theorem of Calculus implies
\begin{equation}
x_{k+1} = x_k+ \int_{k\Delta t}^{(k+1)\Delta t}f(x,\tau;\mu)d\tau
\end{equation}
It is natural to introduce the following discrete-time flow map $F$:
\begin{equation}
x_{k+1} := F(x_k) := x_k+ \int_{k\Delta t}^{(k+1)\Delta t}f(x,\tau;\mu)d\tau.
\end{equation}
\noindent Given snapshots of the solution $x_1, x_2, \dots, x_{m}$, one can use these snapshots to construct two $n\times (m-1)$ data matrices:
\begin{equation}
X=\left(
\begin{array}{cccc}
| & | & & |\\
x_1 & x_2 & ... &x_{m-1}\\
| & | & &|\\
\end{array}
\right), \quad\quad\quad
X'=\left(
\begin{array}{cccc}
| & | & & |\\
x_2 & x_3 & ... &x_m \\
| & | & &|\\
\end{array}
\right).
\end{equation}
The idea of DMD is to compute the leading eigendecomposition of the best-fit linear operator $A$ relating the data $X^{'} \approx AX$:
\begin{equation}
A=X'X^{\dagger}
\end{equation}
where $X^{\dagger} $ is the pseudoinverse of $X$. The eigenvectors of $A$ are said to be the DMD modes. More specifically, the DMD algorithm~\cite{kutz2016dynamic} is summarized in Algorithm~\ref{alg:DMD}:
\begin{algorithm}
\caption{DMD Algorithm~\cite{kutz2016dynamic}}\label{alg:DMD}
1. Arrange the data $\{x_1,...,x_{m}\}$ into matrices
\begin{equation}
X = \left(
\begin{array}{cccc}
| & | & & |\\
x_1 & x_2 & ... &x_{m-1}\\
| & | & &|\\
\end{array}
\right) ,
X' =\left(
\begin{array}{cccc}
| & | & & |\\
x_2 & x_3 & ... &x_m \\
| & | & &|\\
\end{array}
\right)
\end{equation}
where $X$ and $X'$ are defined in equation (5) and equation (6) respectively.\\
\\
2. Compute the (reduced) SVD of $X$, writing
\begin{equation}
X = U\Sigma V^*
\end{equation}
\indent where $U$ is an $n\times r$ matrix, $\Sigma$ is an $r\times r$ diagonal matrix, $V$ is an $m\times r$ matrix, and $r$ is the rank of $X$ (known as the \textit{target rank}.).\\
\\
3. Define the matrix
\begin{equation}
\widetilde{A} \vcentcolon= U^*X'V\Sigma^{-1}
\end{equation}
\\
4. Compute the eigendecomposition of $ \widetilde{A}$, writing
\begin{equation}
\widetilde{A}W = W\Lambda
\end{equation}
\indent where columns of $W$ are eigenvectors and $\lambda$ is a diagonal matrix containing
\indent the corresponding eigenvalues $\lambda_k$.\\
\\
5. Reconstruct the eigendecomposition of $A$ from $W$ and $\Lambda$. The eigenvalues
\indent of A are given by $\Lambda$ and the eigenvectors of $A$ (DMD modes) are given by
\indent columns of $\Phi$:
\begin{equation}
\Phi = X'V\Sigma^{-1}W
\end{equation}
\\
6. Finally, the approximate solution at all future
times is given by
\begin{equation} \label{eq:xt}
x(t)\approx \sum_{k=1}^{r} \phi_k \exp(\omega_k(t)) b_k =\Phi \exp(\Omega t) \textbf{b},
\end{equation}
\indent where $\omega_k = ln(\lambda_k)/\Delta t $ , $b_k$ is the initial amplitude of each mode, $\Phi$ is the
\indent matrix whose columns are the DMD eigenvectors $\phi_k$, and $\Omega = diag(\omega)$ is a
\indent diagonal matrix whose entries are the
eigenvalues $\omega_k$. The eigenvectors $\Phi$
\indent are the same size as the state $x$, and $\textbf{b}$ is a vector of the coefficients $b_k$.
\end{algorithm}
\section{Numerical Experiments}
We will apply the DMD algorithm to the weekly visit flow data~\cite{github} to model human mobility patterns. The 52 distinct places (50 states plus Washington D.C. and Puerto Rico) are assigned unique identifiers from 1 to 52.
The weeks are arranged in the chronological order, starting from the first week of 2019.
For the $t$-th week, we form a $52\times 52$ matrix $A^t$ whose $(i,j)$-entry is the visitor flow data from the origin $i$ to the destination $j$.
Next, we symmetrize each matrix $A^t$ to obtain a matrix $S^t$ whose $(i,j)$-entry is the total visitor flow from $i$ to $j$ or vice versa. If we view the matrix $A^t$ as the adjacent matrix of a directed graph defined by the visitor flow, then $S^t$ is the adjacent matrix of the underlying undirected graph. We then re-shape each matrix $S^t$ to a column vector and use it as a temporal snapshot of the underlying dynamic system that dictates human mobility to apply the DMD algorithm.
By the end of these procedures, we obtain a data matrix
\begin{equation} \label{eq:Mmatrix}
M = \left(
\begin{array}{cccc}
| & | & & |\\
S^1 & S^2 & ... &S^{m}\\
| & | & &|\\
\end{array}
\right)
\end{equation}
where the columns are reshaped symmetric matrices $S^t$, $t=1,2,\dots,m$.
The procedures are summarized in Algorithm~\ref{alg:Data Matrix M}.
\begin{algorithm}
\caption{Generate Data Matrix M}\label{alg:Data Matrix M}
\begin{algorithmic}
\FOR{$t=1, \dots, m$}
\STATE
\begin{enumerate}
\item\textbf{Create Origin-Destination Matrix $A_{k\times k}^t$ for the t-th week} \\
\begin{equation}
A^t_{ij} = visitor\_flows_t(i,j)
\end{equation}
where $visitor\_flows_t(i,j)$ is the t-th week visitor flow
from state i to state j and there are k states in total.
\item \textbf{Get Symmetric Matrix $S_{k\times k}^t$ }\\
\begin{equation}
S^t = (A^t+{A^t}^T)/2
\end{equation}
\item \textbf{Reshape Matrix $S_{k\times k}^t$ and Fill Data Matrix $M_{k^2\times m}$ }\\
Finally, we convert square matrix $S_{k\times k}^t$ to a $k^2$-dimentional column vector $M_t$ by column and
assign the vector $M_t$ to t-th column of matrix M.
\end{enumerate}
\ENDFOR
\end{algorithmic}
\end{algorithm}
\subsection{Experiment 1.}
In the next few subsections, we conduct numerical experiments by applying Algorithm~\ref{alg:Data Matrix M} to model the human mobility patterns.
\medskip
\noindent Firstly, we use the visitor flow data of the year 2019 (52 weeks in total). We implement Algorithm~\ref{alg:DMD} to obtain the DMD model $x(t)$ as defined in~\eqref{eq:xt}.
The singular values of the matrix $M$ are plot in Fig.~\ref{Fig.Singular Value of 2019} in log scale. The distribution decreases slower after the 10th singular value.
The DMD models~\eqref{eq:xt} with target rank $r=5,10,15$ are calculated following Algorithm~\ref{alg:DMD}.
\medskip
\noindent To evaluate the model accuracy, we randomly picked the origin with ID=2 and the destination with ID=32. The visitor flow data as well as DMD models between these two places from Week 1 to Week 105 (that is, from 2019 to 2020) are illustrated in Fig.~\ref{Fig.Visitor Flow Comparison From 2019 to 2020}. We observe that the DMD models with $r=5,10$ remains to fit well on the testing data from Week 57 to Week 62 (that is, the first 5 to 10 weeks in 2020), yet the DMD model with $r=15$ flows up more rapidly than others. On the other hand, all the models seem to deviate from the real data after Week 62 (that is the 10th week in 2020).
\medskip
\noindent Various errors between the real data and DMD model predictions with target rank $r=10$ are shown in Table~\ref{Table.Error results in 2020}. Here $M$ refers to the data matrix~\eqref{eq:Mmatrix}, $M_{dmd}$ consists of predictions computed by~\eqref{eq:xt}, $||M_i||_2$ is the $L^2$ norm of the visitor flow of Week $i$, $||M_{dmdi}||_2$ is the the $L^2$ norm of the DMD prediction of Week $i$.
$\frac{||M_i-M_{dmdi}||_2}{||M_i||_2}$ and $\frac{||M_i-M_{dmdi}||_{\infty}}{||M_i||_\infty}$ are the relative $L^2$ and $L^{\infty}$ prediction error, respectively. It is clear that, DMD predictions can be far away from real data in the long run, as the model~\eqref{eq:xt} grows exponentially in time $t$.
\subsection{Experiment 2.}
\noindent In this experiment, we use 2019 and 2020 data (104 weeks in total) to compute the DMD mode to predict 2021 data.
The singular values of the data matrix $M$ is shown in Fig.~\ref{Fig.Singular Value of 2019 and 2020}. We will choose target rank $r=20,33,45$ to compute different DMD models. We choose the places with ID=2 and ID=32 again. The real visitor flow data and DMD predictions from the first week of 2019 to the last week of 2021 (156 weeks in total) are shown in Fig.~\ref{Fig.Real and Numerical Data Comparison from 2019 to 2021}. Various errors with rank $r=33$ are summarized in Table~\ref{Table.The Error Results in 2021}. This time, none of the DMD models seems to give reasonable predictions on testing data.
\subsection{Experiment 3.}
We repeat the experiment using visitor flow data from March 9,2020 to May 31,2021 (65 weeks in total) as the training data to compute DMD models. The singular values of the data matrix are shown in Fig.~\ref{Fig.Singular Value of Part 2019 and 2020}. The real data and DMD predictions with target rank $r=12,22,33$ are displayed in Fig.~\ref{Fig.VisitorFlowComparison}, and the errors are summarized in Table~\ref{table:errorin2021}.
\medskip
\noindent We observe that the predictions are better than those in Experiment 2. The difference between the training data for Experiment 1 \& 3 and that for Experiment 2 is that the latter contains a sharp change in March 2020. This was because of the presidential declaration of the state of national emergency on March 13, 2020, which leads to a drastic decay of the number of domestic visitors. The DMD models, as is shown in~\eqref{eq:xt}, consist of mostly low-frequency content, thus finds it difficult to learn this high-frequency content.
\newpage
\graphicspath{{Figure/}}
\begin{figure}[H]
\centering
\includegraphics[width=0.6\textwidth]{singular}
\caption{Singular Value of 2019 Data Matrix X}
\label{Fig.Singular Value of 2019}
\end{figure}
\graphicspath{{Figure/}}
\begin{figure}[H]
\centering
\includegraphics[width=0.6\textwidth]{visitorflow}
\caption{Real Visitor Flow and DMD Predictions in 2019 and 2020}
\label{Fig.Visitor Flow Comparison From 2019 to 2020}
\end{figure}
\begin{table}[H]
\begin{center}
\caption{The Weekly Visitor Flows Data and Errors in 2020 }
\label{Table.Error results in 2020}
\begin{tabular}{cccccc}
\toprule
Week of 2020 & $||M_i||_2$ & $||M_{dmdi}||_2$ & $ \frac{||M_i-M_{dmdi}||_2}{||M_i||_2}$ & $ \frac{||M_i-M_{dmdi}||_{\infty}}{||M_i||_\infty}$ \\
\midrule
1st &2.2066e+07 &2.0900e+07 &0.0776 &0.0508 \\
2nd & 2.1741e+07& 2.2276e+07 &0.0679&0.0694 \\
3rd & 2.1410e+07 & 2.2861e+07 &0.0669&0.0732 \\
4th & 2.1071e+07 & 2.2923e+07 &0.0713&0.0742 \\
5th & 2.2923e+07& 2.2719e+07&0.0776&0.0558 \\
\bottomrule
\end{tabular}
\end{center}
\end{table}
\newpage
\graphicspath{{Figure/}}
\begin{figure}[H]
\centering
\includegraphics[width=0.6\textwidth]{singular1}
\caption{Singular Value of 2019 and 2020 Data Matrix X}
\label{Fig.Singular Value of 2019 and 2020}
\end{figure}
\graphicspath{{Figure/}}
\begin{figure}[H]
\centering
\includegraphics[width=0.6\textwidth]{visitorflow1}
\caption{Real Visitor Flow and DMD Computation Visitor Flow Data from 2019 to 2021}
\label{Fig.Real and Numerical Data Comparison from 2019 to 2021}
\end{figure}
\begin{table}[H]
\begin{center}
\caption{The Weekly Visitor Flows Data and Errors in 2021 }
\label{Table.The Error Results in 2021}
\begin{tabular}{cccccc}
\toprule
Week of 2021 & $||X_i||_2$ & $||M_{dmdi}||_2$ & $ \frac{||M_i-M_{dmdi}||_2}{||M_i||_2}$ & $ \frac{||M_i-M_{dmdi}||_{\infty}}{||M_i||_\infty}$ \\
\midrule
1st &2.1651e+07 &1.9726e+07 &0.1040 &0.1088 \\
2nd & 2.1370e+07& 1.9628e+07 &0.0958&0.1073 \\
3rd & 2.0825e+07 & 1.9530e+07 &0.0788&0.0782 \\
4th & 2.0556e+07& 1.9432e+07 &0.0779&0.0901 \\
5th & 2.1252e+07& 1.9335e+07&0.1074&0.1192 \\
\bottomrule
\end{tabular}
\end{center}
\end{table}
\newpage
\graphicspath{{Figure/}}
\begin{figure}[H]
\centering
\includegraphics[width=0.6\textwidth]{singular2}
\caption{Singular Value of Partly 2019 and 2020 Data Matrix X}
\label{Fig.Singular Value of Part 2019 and 2020}
\end{figure}
\graphicspath{{Figure/}}
\begin{figure}[H]
\centering
\includegraphics[width=0.6\textwidth]{visitorflow2}
\caption{Real Visitor Flow and DMD Computation Visitor Flow Data From March 9, 2020 to December 31, 2021}
\label{Fig.VisitorFlowComparison}
\end{figure}
\begin{table}[H]
\begin{center}
\caption{The Weekly Visitor Flows Data and Errors in 2021 }
\label{table:errorin2021}
\begin{tabular}{cccccc}
\toprule
Week of 2021 & $||X_i||_2$ & $||M_{dmdi}||_2$ & $ \frac{||M_i-M_{dmdi}||_2}{||M_i||_2}$ & $ \frac{||M_i-M_{dmdi}||_{\infty}}{||M_i||_\infty}$ \\
\midrule
23rd &2.6570e+07 &2.8383e+07 &0.0733 &0.0576 \\
24th & 2.6968e+07& 2.8500e+07 &0.0640&0.0633 \\
25th & 2.6561e+07 & 2.8617e+07 &0.0841&0.0754 \\
26th & 2.6720e+07& 2.8735e+07 &0.0824&0.0703 \\
\bottomrule
\end{tabular}
\end{center}
\end{table}
\section*{Acknowledgement}
The research of L. Li and Y. Yang is partially supported by the NSF grant DMS-1715178, DMS-2006881, and the start-up fund from Michigan State University.
\normalem
|
{'timestamp': '2022-02-15T02:41:20', 'yymm': '2202', 'arxiv_id': '2202.06619', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06619'}
|
arxiv
|
\section{Dialogue Analysis}
\label{sec:dialogues_analysis}
First, we compare ArgSciChat with related datasets.
We then analyze the ArgSciChat datasets from the following perspectives: topical diversity of dialogues collected for a paper, the impacts of our defined intent set on dialogues, and the properties of supportive facts selected by \texttt{DE} from papers.
\subsection{Comparison With Other Datasets}
Table \ref{tab:dialogue_analysis} reports detailed statistics about dialogues.
Dialogues in ArgSciChat are comparable in terms of dialogue turns with dialogues in other examined datasets.
Compared with CoQA, dialogues in ArgSciChat are shorter in terms of the number of turns.
However, ArgSciChat contains a higher percentage (50\%) of multi-sentence messages than other datasets.
This observation is confirmed by the average number of tokens per message.
\begin{table}[!t]
\small
\centering
\begin{tabular}{lccc}
\toprule
\textbf{Dataset} & \textbf{Avg. Turns} & \textbf{\% MSM} & \textbf{Avg. Mes. Len.}\\
\midrule
CoQA & 15.5 & 0.2\% & 4.7 \\
QuAC & 7.3 & 4.0\% & 11.4 \\
Doc2Dial & 6.4 & 17.8\% & 16.3 \\
ArgSciChat & 6.3 & 50.8\% & 38.2 \\
\bottomrule
\end{tabular}
\caption{
Comparing ArgSciChat with related datasets.
\textbf{Avg. Turns} shows the average number of turns per dialogue.
\textbf{\% MSM} depicts the percentage of Multi Sentence Messages in a dataset.
\textbf{Avg. Mes. Len.} indicates the average number of tokens per message in a dataset.
}
\label{tab:dialogue_analysis}
\end{table}
\subsection{Topical Diversity}
We investigate the topical diversity of messages in dialogues on the same paper.
In particular, we categorize messages in dialogues grounded on one paper into three groups:
(i) \textbf{G1:} \texttt{P} messages;
(ii) \textbf{G2:} \texttt{DE} messages that respond to a \texttt{P} message topic; which is represented with a cluster of topically similar \texttt{P} messages,
and
(iii) \textbf{G3:}
\texttt{DE} messages and their corresponding supportive facts.
We compute the topical diversity between messages in each group.
To do so, we pair messages in a group with one another, and then use the cosine similarity between vector representations of messages in a pair as a proxy to the topical diversity of messages.
We obtain the vector representations of messages using S-BERT~\cite{DBLP:journals/corr/abs-1908-10084}.
If the similarity score between messages in a pair is above a similarity threshold, we consider the messages topically similar, otherwise we consider them topically diverse.
We compute the percentage of message pairs whose messages are topically diverse as a diversity score for messages in dialogues on one paper.
We then report the average topical diversity score over all papers with multiple dialogues in our dataset for different diversity thresholds.
\begin{table}[!t]
\small
\centering
\begin{tabular}{ccccccc}
\toprule
\textbf{Group} & & \textbf{0.3} & \textbf{0.4} & \textbf{0.5} & \textbf{0.6} & \textbf{0.7} \\ \midrule
G1 & & 0.77 & 0.87 & 0.92 & 0.96 & 0.98 \\
G2 & & 0.43 & 0.48 & 0.63 & 0.73 & 0.68 \\
G3 & & 0.18 & 0.28 & 0.43 & 0.60 & 0.81 \\ \bottomrule
\end{tabular}
\caption{Topical diversity on dialogues on identical papers.
The numbers in the header of columns represent the diversity thresholds.
}
\label{tab:sentencebert}
\end{table}
Table~\ref{tab:sentencebert} shows the diversity scores for each group of messages across different diversity thresholds.
For example, for diversity threshold 0.5 about 90\% of messages in group G1, 63\% of messages in group G2, and 43\% of messages in group G3 are topically diverse.
This is mainly attributed to the high rate of multi-sentence messages in our dataset.
Moreover, messages in G1 have the highest diversity followed by those in G2 and G3, respectively.
These results suggest that our dialogue formulation yields diverse dialogues even on identical papers.
This is important when these dialogues are used to train and evaluate dialogue agents.
\subsection{Intent Set Analysis}
\label{paragraph:role-specific_behaviours}
We analyse to what extent our proposed intent set is used by \texttt{P} and \texttt{DE}.
To do so, we ask four NLP practitioners to annotate messages from all dialogues in ArgSciChat at the sentence level with the intent labels from our action set (Table~\ref{tab:action_set}).
We compute the inter-annotator agreement on messages of 10 randomly selected dialogues.
The average Fleiss's Kappa is 0.89 and the Krippendorf's alpha is 0.83.
This high agreement indicates that the quality of annotations is high enough to be used in our analysis.
\begin{table}[!t]
\small
\centering
\begin{tabular}{lccccc|cc}
\toprule
\textbf{Role} & \textbf{AI} & \textbf{S} & \textbf{RI} & \textbf{GO} & \textbf{AR} & \textbf{IS} & \textbf{ARG} \\
\midrule
\texttt{P} & 63.3 & 1.2 & 7.6 & 21.9 & 6.1 & 72.0 & 28.0 \\
\texttt{DE} & 1.0 & 7.6 & 72.7 & 11.8 & 6.9 & 81.3 & 18.7 \\ \midrule
Total & 29.5 & 4.7 & 42.9 & 16.4 & 6.5 & 77.1 & 22.9 \\
\bottomrule
\end{tabular}
\caption{The frequency (\%) of labels from our action set for each dialogue role. ``Total'' is the total frequency of each label.
}
\label{table:action_distribution}
\end{table}
Table \ref{table:action_distribution} reports the frequency of each label on messages expressed by \texttt{P} and \texttt{DE} roles computed over the whole dataset.
\texttt{P} is more inclined to ask questions (AI), whereas \texttt{DE} reports about facts from paper content (RI).
This is compatible with our definitions for these roles.
\texttt{P} expresses its opinion (GO) more often than \texttt{DE} by 21\%.
This is compatible with the fact that \texttt{G}'s messages are grounded on facts that are counted as RI.
Both \texttt{P} and \texttt{DE} ask for rebuttal (AR) with a similar frequency ($\approx$6\%).
\texttt{DE} suggests a topic more frequently than \texttt{P} by about 6\%.
This is because DE has access to the content of the paper and is requested to drive the conversation.
Additionally, by grouping up actions according to their corresponding dialogue intent labels (the IS and ARG columns in Table~\ref{table:action_distribution}), we observe that the argumentative intent represents nearly 23\% of all messages, and the information seeking intent represents about 77\% of messages, confirming that dialogue partners not only exchange information but also argue about that information.
\subsection{Supportive Fact Analysis}
We first study how \texttt{DE} messages are grounded on scientific facts and how these facts are distributed over paper sections.
\begin{table}[!t]
\small
\centering
\begin{tabular}{lc}
\toprule
\textbf{Property} & \textbf{Value} \\
\midrule
\% 1-Fact messages & 61.1 \\
\% 2-Fact messages & 38.9 \\
Avg. sent. dist. between facts & 5.8 \\
\midrule
\% Facts from Title & 1.0 \\
\% Facts from Abstract & 38.2 \\
\% Facts from Introduction & 60.8 \\
\bottomrule
\end{tabular}
\caption{ArgSciChat statistics regarding fact selection.}
\label{tab:fact_analysis}
\end{table}
Table \ref{tab:fact_analysis} reports statistics about \texttt{DE} messages that are grounded on facts.
61.1\% of messages (129 out of 211 messages) are grounded on only facts and 38.9\% (82 out of 211) of messages are grounded on two facts.
The average sentence-based distance between selected facts in a paper is 5.8, indicating that facts in the 2-fact messages are selected from different text spans.
In total, 1\% of facts are selected from Title, 38\% from Abstract and about 60.0\% from Introduction of the paper, confirming that all content given to participants are used to conduct dialogues.
We also investigate how supportive facts are distributed in each paper. We focus on the Introduction section since it is the largest available content portion of a paper. Additionally, the majority of supportive facts belong to the Introduction section. We divide the Introduction section into sentence chunks.
Each chunk contains up to four sentences.
Figure~\ref{fig:facts_clusters} reports the supportive fact distribution. We observe that supportive facts are primarily selected within the first 3-4 chunks (i.e. first 12-16 sentences) of the Introduction section. This result is mainly motivated by how dialogues are defined. In particular, collected dialogues are relatively short and are centred on a few topics.
Nonetheless, around 20\% of supportive facts belong to chunks 7-11. This means that dialogues span throughout the whole content of the paper and are not limited to restricted text spans.
\begin{figure}[!t]
\centering
\includegraphics[width=0.50\textwidth]{img/cluster_barplot.jpg}
\caption{Supportive fact distribution over sentence chunks regarding the Introduction section. Chunk size is set to four sentences.}
\label{fig:facts_clusters}
\end{figure}
\section{Data Collection Supplementary Details} \label{appendix:collection_details}
We provide details about our implementation of the described data collection framework below. We define a time deadline for each pipeline step to ease synchronizing participants along the data collection process.
\paragraph{Participants Sign-up}
We require participants to provide the following information: full name and email address. We also need participants to provide their Google Scholar profiles regarding paper selection. If no Google Scholar profile is available, participants can still sign-up by manually submitting hyperlinks to the PDF files of papers about which they have enough expertise. The automatic paper retrieval step reports the top five participants' most recent papers listed in their Google Scholar profile. Participants are then asked to select two to participate in the study.
\paragraph{Booking as DE}
We consider \texttt{DE} dialogue sessions of one hour in length. Upon sign-up, summary information about selected papers and dialogue sessions is provided to participants. In particular, participants can add selected dialogue sessions to their calendar to ensure participation.
Upon submission, summary information is provided to participants with the possibility to add chosen dialogue sessions to their calendar to ensure participation.
\paragraph{Booking as P}
Once the sign-up deadline has been met, our framework automatically notifies participants about the next phase. Additionally, a unique private authentication code is assigned and provided to each participant. The authentication code is used to identify participants during the study while ensuring anonymity. Regarding dialogue session booking as \texttt{P}, we split \texttt{DE} dialogue sessions into session slots of 20 minutes duration. Participants are required to book four distinct dialogue session slots, each one regarding a different paper. Upon submission, summary information is provided to participants regarding their final schedule concerning both roles.
\paragraph{Joining a Dialogue}
Once the time deadline of the previous pipeline step has been met, our framework automatically notifies participants about their final schedule. By doing so, participants have exact information about which session slots they have to join. Our framework also supports an automatic notification system that ensures participants join each session slot on time.
\paragraph{Why Synchronous Dialogues?}
Given participants' required level of expertise and to ensure naturalness during dialogue collection, we opted for synchronous dialogue sessions. Indeed, such a choice introduces tight requirements about participants' availability and corresponding attributable effort. However, asynchronous dialogues can potentially lead to harsher drawbacks, such as an extended data collection period. Additionally, in an asynchronous dialogue, dialogue properties like the partial observability of \texttt{P} can be quickly overcome due to the absence of a time limit. Conversely, short synchronous dialogue sessions encourage both dialogue partners to maximize the exchanged information flow alike a natural goal-oriented conversation.
\paragraph{Data Collection Interfaces}
We develop role-specific collection interfaces based on the Mephisto library\footnote{\url{https://github.com/facebookresearch/Mephisto}}.
We opt for a standalone data collection application that does not impose additional participation steps apart from initial data submission.
Upon connection between dialogue partners, associated paper content is loaded, and dialogue roles are attributed to each participant.
Coherently with the given formulation, no worker payment was considered, but an award system is devised to encourage attendance further.
To avoid \texttt{DE} message without supportive facts, the system notifies when no facts have been highlighted upon a message sent. Additionally, a hint system encourages both dialogue partners to suggest discussing previous dialogue turns encouraging opinions exchange. Figure \ref{fig:collection_interfaces} reports the data collection interfaces for both dialogue roles. Both interfaces reflect the asymmetrical nature of the dialogue by restricting information to individual roles.
\paragraph{Implementation Limitations}
The major limitation of our implementation concerns the chosen interface library. More precisely, the Mephisto library has been developed for crowdsourcing. In crowdsourcing, there are no restrictions about joining a specific task instance, i.e. a dialogue in our setting. However, we require advanced access control operations to guarantee participants can only join their scheduled dialogue sessions. For this reason, we couldn't allow parallel dialogue sessions. This limitation significantly reduced the number of possible dialogue sessions and, thus, dialogues. We opted for an existing data collection platform to avoid the burden of building one from scratch. Nonetheless, there might be a need to define a custom crowdsourcing platform to overcome this major limitation. We leave platform improvements as future work.
\paragraph{Collection Issues}
Considering the two data collection rounds, we identified 68 dialogue sessions in total.
However, events like participant disconnection, reply timeout and session skipping lowered the number of dialogues with a sufficient number of messages to 41. Part of encountered issues could be overcome with a more advanced data collection implementation. We leave this as future work.
\begin{figure*}[!t]
\centering
\begin{subfigure}[b]{\textwidth}
\centering
\includegraphics[width=\textwidth]{img/proponent_interface.jpg}
\caption{}
\label{fig:collection_interfaces:proponent}
\end{subfigure}
\hfill
\vspace{0.3cm}
\begin{subfigure}[b]{\textwidth}
\centering
\includegraphics[width=\textwidth]{img/domain_expert_interface.jpg}
\caption{}
\label{fig:collection_interfaces:domain_expert}
\end{subfigure}
\hfill
\caption{Data collection interfaces for (a) \texttt{P} and (b) \texttt{DE}. On the right side, the title, abstract and introduction sections of the paper are reported for \texttt{DE}. Conversely, \texttt{P}'s view is solely restricted to the paper title.}
\label{fig:collection_interfaces}
\end{figure*}
\section{Experiments Supplementary Details} \label{appendix:experiments}
In this section, we reported additional details regarding our experimental setup and the described tasks.
\paragraph{Setup}
As in \cite{Dasigi2021ADO}, multiple inputs are concatenated together with a special separation token. In our experimental setup, inputs are concatenated based on the following criteria: (i) query; (ii) dialogue history; (iii) scientific paper. In particular, we set the LED global attention mask to take into account each individual input as done in \cite{Dasigi2021ADO}.
In contrast to \cite{Dasigi2021ADO}, the lack of LaTeX source files forbids the automatic retrieval of paper section paragraphs. Instead, we work at the sentence level.
The average training time is ${\sim}40-60$ seconds per epoch depending on the given input combination. Experiments are conducted on an NVidia GeForce 2080ti 11 GB.
\paragraph{Model Configuration}
Table \ref{table:appendix:experiments:model_configuration} reports the main hyper-parameters of the LED model. As in \cite{Dasigi2021ADO}, we employ the HuggingFace model \texttt{allenai/led-base-16384}. Given the limited scientific paper content, we re-scale the \textit{attention window size} hyper-parameter according to our maximum document length. Note that the selected hyper-parameter value corresponds to the same percentage with respect to the maximum document length as in \cite{Dasigi2021ADO}.
\begin{table}[!t]
\centering
\small
\begin{tabular}{lc}
\toprule
\textbf{Hyperparameter} & \textbf{Value} \\ \midrule
Attention dropout & 0.1 \\
Attention window size & 700 \\
Optimizer & Adam \\
Learning rate & $5 \cdot 10^{-5}$ \\ \bottomrule
\end{tabular}
\caption{The LED model hyper-parameters.}
\label{table:appendix:experiments:model_configuration}
\end{table}
\section{ArgSciChat: Dialogue Collection} \label{sec:dialogue_collection}
We first formulate the dialogues we aim to collect.
Then, we introduce our data collection framework to acquire dialogues and its specification for collecting argumentative dialogues on NLP papers.
\subsection{Dialogue Formulation} \label{sec:dialogue_formulation}
We aim at collecting argumentative and information-seeking dialogues between scientists. We define two roles for participants: \texttt{DE} and \texttt{P}.
\texttt{P} starts a dialogue with \texttt{DE} on a scientific paper of which \texttt{P} only knows the paper's title. \texttt{DE} is given the abstract and introduction sections of the same paper.
Thus, \texttt{P} is encouraged to formulate initial questions to learn more about the paper. \texttt{P} and \texttt{DE} then argue about the claims in the paper.
We limit the paper content to abstract and introduction sections to limit participants' effort to act as \texttt{DE} while providing enough information to sustain a dialogue.
We also define a set of intents for dialogue partners to ensure their interactions follow IS and Arg intents.
As shown in Table~\ref{tab:action_set}, these intents are grouped by their intent type.
We instruct \texttt{DE} to select up to two supportive facts to ground their messages.
Lastly, we instruct \texttt{DE} to provide suggestions about available paper content to limit the occurrences of unanswerable questions.
\begin{table}[!t]
\small
\centering
\begin{tabular}{p{3cm}@{}p{4cm}}
\toprule
\multicolumn{2}{c}{\textbf{IS}} \\
\midrule
Ask Info (AI) & A question to seek facts from a paper's content. \\
\midrule
Reply Info (RI) & A reply supported by a fact from the paper to respond to a question with the AI intent.
\\\midrule
Ask Suggestion (S) & A request or proposal regarding which topic to discuss next. \\ \midrule
\midrule
\multicolumn{2}{c}{\textbf{Arg}} \\
\midrule
Ask Rebuttal (AR) & A question about the opinion of the dialogue partner on a fact from the paper.\\
\midrule
Give Opinion (GO) & An opinion about a topic using a fact selected from the paper. \\
\bottomrule
\end{tabular}
\caption{We define two sets of intents for dialogue messages.
The IS set contains the intents defined for information-seeking messages.
The intents in the Arg set are defined for argumentative messages.}
\label{tab:action_set}
\end{table}
\paragraph{Terminology}
A \textit{message} is a piece of text generated by a dialogue partner.
$\texttt{P}_2$ in Figure \ref{fig:conversation_example} is an example of a message.
A message can contain one or more \textit{sentences}.
Each sentence is associated with a dialogue intent.
If a message consists of more than one sentence, then we refer to it as a \textit{multi-sentence message}.
A \textit{dialogue turn} is a pair of adjacent \texttt{P} and \texttt{DE} messages.
For instance, the pair ($\texttt{P}_1$, ${\texttt{DE}}_1$) in Figure \ref{fig:conversation_example} is a dialogue turn.
\subsection{Data Collection Framework} \label{sec:data_collection_pipeline}
We define a novel framework to collect dialogues between scientists as domain experts.
To encourage scientists to participate in our dialogue collection study, we allow scientists to propose their own papers to be discussed in a dialogue and also their free time slot in which they can join in a dialogue.
As shown in Figure \ref{fig:data_collection_pipeline}, our framework consists of four major steps.
\paragraph{Participants Sign-up}
The step \emph{``Participant Sign-up''} allows domain experts to sign up in the system and propose the topics at which they are experts.
For doing so, participants fill in a sign-up form consisting of two sections.
The first section asks for participants' contact information.
The second section allows participants to suggest their papers to be used in a dialogue.
Participants' most recent papers are automatically retrieved from their Google scholar page and ask them to select a few of their papers as the topics they are experts on.
Participants can also submit their papers manually to include topics other than what we retrieved.
\paragraph{Booking as DE}
The step \emph{``Booking as DE''} lets experts propose the dialogue sessions at which they are available to participate in a dialogue with a \texttt{DE} role.
In particular, we ask participants to select a \emph{dialogue session} for each selected paper.
We refer to these sessions as ``\texttt{DE} dialogue session'' as participants take the \texttt{DE} role in these sessions.
\paragraph{Booking as P}
The step \emph{``Booking as P''} lets experts choose the topics about which they are willing to learn and also the dialogue sessions at which they can participate with a \texttt{P} role.
To do so, we provide participants with the topics of all \texttt{DE} dialogue sessions, and ask them to select a topic on which they are interested to learn about.
To collect several dialogues on each paper, we split each \texttt{DE} dialogue session into multiple short slots.
We refer to these slots as \emph{session slots}. Participants then select several session slots according to their availability time and the topic of the dialogue sessions.
\paragraph{Joining a Dialogue}
Finally, the step \emph{``Joining a Dialogue''} provides a synchronous online session in which two experts chat about the paper they agreed on.
Our framework notifies participants by emails before each session slot begins to maximize the number of session slots in which two participants, acting as \texttt{P} and \texttt{DE} respectively, are present to talk about a paper.
When both \texttt{P} and \texttt{DE} are present in a session slot, the session starts and scientists start chatting about the paper.
We demonstrate a screenshot of a dialogue session in our framework in Appendix \ref{appendix:collection_details}.
\subsection{Collecting Dialogues About NLP Papers} \label{sec:data_collection_period}
\begin{figure}[!t]
\advance\leftskip-0.25cm
\includegraphics[width=0.5\textwidth]{img/worker_schema.jpg}
\caption{A general view of our proposed data collection framework.}
\label{fig:data_collection_pipeline}
\end{figure}
In this study, we use our framework to collect dialogues about NLP papers.
While this choice opens a common background between participants, it also brings enough topic diversity for dialogues.
We invite senior and junior researchers from two large NLP groups in Europe as a candidate pool for participation.
We organize the data collection phase into multiple short data collection rounds.
Such short-term rounds give scientists more flexibility to participate in our study due to their limited time budget.
We report the implementation details in Appendix~\ref{appendix:collection_details}.
The dialogues collected in these two rounds construct our ArgSciChat dataset.
Table \ref{tab:pipeline_analysis} reports characteristics of our ArgSciChat dataset.
We collect 68 dialogues in total.
We filtered out dialogues that were too short, i.e., had less than eight messages, or ended abruptly.
At the end of this process, we obtain 41 dialogues.
\begin{table}[!t]
\centering
\begin{tabular}{lc}
\toprule
\textbf{Characteristic} & \textbf{Value} \\
\midrule
\# participants & 23 \\
\# scientific papers & 20 \\
\# dialogues & 41 \\
\# messages & 498 \\
\# sentences & 1034 \\
Avg. \# dial. per paper & 2 \\
\bottomrule
\end{tabular}
\caption{The characteristics of the ArgSciChat dataset.}
\label{tab:pipeline_analysis}
\end{table}
\section{Conclusion}
We have presented ArgSciChat, the first argumentative conversational dataset on scientific papers with multiple dialogue intents.
We have proposed a novel framework to collect dialogues from scientists.
Experimental results on dialogue generation show that scientific dialogues are a challenging domain. Additional inputs like dialogue history can be beneficial for conversational agents. Nonetheless, their integration is non-trivial and ad-hoc solutions might have to be considered given the complexity of the scenario.
In future work, we will mainly investigate techniques for low resource scenarios, such as few-shot learning and data augmentation. These solutions are crucial given the challenging data collection setting.
\section{A Scientific Agent for NLP Papers} \label{sec:experiments}
In this section, we study the difficulty of our ArgSciChat dataset for recent document-grounded conversational agents.
To do this, we use ArgSciChat to define two tasks:
\textbf{(i) Fact selection} where an agent should select at most two sentences from the paper as argumentative facts; and
\textbf{(ii) Response generation} where an agent should play the \texttt{DE} role and generate a text to respond to a \texttt{P} message.
\subsection{Setup}
We use LED~\cite{Beltagy2020LongformerTL}, a neural transformer-based encoder-decoder text generation model.
The input to LED is a sequence of tokens known as \emph{query} and a document.
The output is a sequence of tokens to respond to the input query.
\newcite{Dasigi2021ADO} use an MLP layer to transform the vector representations of document sentences, which are encoded by the LED's encoder, into two scores to identify if sentences should be selected as a fact.
In this way, \newcite{Dasigi2021ADO} show that training LED for both tasks (fact selection and response generation) jointly yields high performance on the QASPER dataset.
Likewise, we train the LED agent for the two tasks jointly using the following loss function:
\begin{equation}
\mathcal{L} = \mathcal{L}_{gen} + \mathcal{L}_{fact} \,\textit{,}
\end{equation}
where $\mathcal{L}_{gen}$ is the average negative log-likelihood (NLL) loss between a generated response and the \texttt{DE} message as a reference response.
The $\mathcal{L}_{fact}$ loss is the binary cross-entropy loss between the output of the MLP layer and fact labels associated with sentences of the paper.
If any token of a sentence in a paper is part of a supportive fact in a dialogue in our dataset, we give the sentence a fact label 1, otherwise 0.
We evaluate LED for the tasks mentioned above on our dataset.
Inspired by the cross-validation technique, we randomly split dialogues in our dataset into five folds. Splits are applied at scientific paper level.
Each fold consists of four dialogues.
We take one unique fold for the evaluation at different cross-validation iterations and four folds for training purposes.
We further split any selected fold for the evaluation into two parts to construct the validation and test sets.
To construct data samples for our experiments, we split a dialogue based on its dialogue turns.
A data sample consists of a \texttt{P} message and a \texttt{DE} message in a dialogue, where the former is the input to the agent and the latter is what the agent should generate.
Table~\ref{tab:folds} shows the number of data samples used in each fold's training, validation, and test sets.
\begin{table}[!t]
\small
\centering
\begin{tabular}{@{}lccccc@{}}
\toprule
& \textbf{Fold 1} & \textbf{Fold 2} & \textbf{Fold 3} & \textbf{Fold 4} & \textbf{Fold 5} \\
\midrule
Train & 199 & 200 & 183 & 212 & 207 \\
Validation & 27 & 14 & 39 & 27 & 22 \\
Test & 23 & 35 & 27 & 10 & 20 \\
\bottomrule
\end{tabular}
\caption{The number of data samples, i.e., the dialogue turns, used in different folds of the ArgSciChat dataset.
}
\label{tab:folds}
\end{table}
\begin{table}[!t]
\small
\centering
\begin{tabular}{@{}lcccc@{}}
\toprule
\textbf{Model} & \textbf{Fact-F1} & \textbf{Message-F1} & \textbf{BScore} & \textbf{Mover} \\
\midrule
TF-IDF & 16.22 & - & - & - \\
S-BERT & 13.65 & - & - & - \\
\midrule
LED(Q,P) & 10.58 & 14.25 & 85.85 & 2.25\\
LED(Q,P,H) & 8.50 & 16.14 & 86.00 & 4.54 \\
LED(Q,F) & - & 19.54 & 86.64 & 8.53\\
\midrule
Human & 51.26 & - & - & -\\
\bottomrule
\end{tabular}
\caption{The LED's performance for fact selection (Fact-F1) and response generation (Message-F1, BScore, and Mover). }
\label{tab:led_results}
\end{table}
We report the values of all hyperparameters in Appendix~\ref{appendix:experiments}.
\begin{table*}[!t]
\centering
\begin{tabular}{ll}
\toprule
Query: & \emph{Sounds promising! So how well do the models perform?} \\
\midrule
LED(Q,P): & \emph{We use a neural network to train the neural network to generate neural networks.} \\
LED(Q,P,H): & \emph{We use a generic, KB-agnostic annotation approach.} \\
LED(Q,F): & \emph{They use their models to improve annotation speed. What do you think about this?} \\
\midrule
Reference \texttt{DE}: & \begin{tabular}[c]{@{}l@{}} \emph{Using these in a user study, we measured an annotation time improvement of up 35\%.}\\
\emph{Do you think this is useful?}
\end{tabular} \\
\midrule
Facts: & \begin{tabular}[c]{@{}l@{}} \emph{We show that statistical machine learning models can be used in an}\\\emph{interactive entity linking setting to improve annotation speed by over 35\%.}\end{tabular} \\
\bottomrule
\end{tabular}
\caption{A case study of the response generated by the LED agent when trained on the ArgSciChat dataset. }
\label{tab:case-study}
\end{table*}
\subsection{Results}
\label{sec:automatic_reply_generation}
Similar to \newcite{Dasigi2021ADO}, for fact selection, we report \textit{Fact-F1}, i.e., sentence-level F1-score, and for dialogue generation we report \textit{Message-F1}, i.e. token-level F1-score between a generated response and its corresponding \texttt{DE} message, BertScore (\textit{BScore})~\cite{ZhangKWWA20} and MoverScore (\textit{Mover})~\cite{ZhaoPLGME19}.
We consider three different inputs to the LED agent:
(i) LED(Q,P) shows that the input to LED consists of a \texttt{P} message to which we refer as a query (Q) and a paper (P);
(ii) LED(Q,P,H) shows that the input to LED consists of a query (Q), a paper (P), and all messages exchanged prior to Q, also known as dialogue history (H);
(iii) LED(Q,F) shows that the input to LED consists of the query and the reference facts in the ArgSciChat dataset.
Table~\ref{tab:led_results} shows the results for both tasks.
\paragraph{Fact Selection}
We use a retrieval-based method as the baseline for the fact selection task.
This method computes the cosine-similarity scores between the vector representation of an input \texttt{P} message and the vector representation of any sentence in the input paper.
We use TF-IDF and S-BERT to obtain vector representation of the \texttt{P} message and paper sentences.
We then rank the sentences for their similarity scores with the \texttt{P} message and select 2-top sentences as the supportive facts.
We also compute a human score for the fact selection task by asking three NLP practitioners to select two sentences from the input paper as supportive facts for an input \texttt{P} message.
We observe that the performance of the LED model in terms of Fact-F1 is comparable with the baseline models and far from the human performance, confirming the difficulty of the fact selection task on the ArgSciChat dataset.
It is worth noting that one reason for such a low performance might be the small number of data samples in each fold (see Table~\ref{tab:folds}), motivating the development of few-shot learning methods for training conversational agents in expert domains.
\paragraph{Response Generation}
In terms of the \mbox{Message-F1} metric
LED(Q,P) achieves a 14.25 token-level F1 score, followed by the LED(Q,P,H) with a 16.14 score.
Both LED(Q,P) and LED(Q,P,H) are outperformed by LED(Q,F) by at least three F1 score.
The high score of LED(Q,F) is because the input facts are reference facts from the ArgSciChat dataset.
These facts were selected by \texttt{DE} participants in our data collection study.
Therefore, these facts are a great source of knowledge for the LED agent to ground its responses. The gap between the performance of LED(Q,F) other examined settings confirm the importance of the fact selection task for generating argumentative responses.
It is worth noting that the task becomes more challenging for LED when we don't provide human-selected facts.
LED(Q,P), which has access to the paper instead of facts, fails in retrieving facts from paper content and therefore generating a proper response.
LED(Q,P,H) outperforms LED(Q,P) confirming the benefits of dialogue history in generating informative responses.
This also shows that dialogues in our dataset are beyond a sequence of unrelated questions and answers.
Table~\ref{tab:case-study} shows responses generated by LED models given different inputs for an identical query or a \texttt{P} message.
We observe that LED(Q,F) captures that the intent of the query is asking information about ``the speed improvement of the annotation study'', and provides a multi-sentence response with mixed intents, where the first sentence in the LED(Q,F)'s response has the intent RI (see Table~\ref{tab:action_set}) as it provides information to answer the question, and the second sentence has intent GO as it asks for the proponent's opinion, heading towards an argumentative dialogue.
In summary, the results on both tasks confirm the difficulty of our dataset for LED as an advanced document-grounded conversational agent.
This difficulty motivates further research on building argumentative conversational agents on scientific papers.
The ArgSciChat dataset is a stepping stone in this research direction.
\section{Introduction}
\label{sec:introduction}
Conversational agents assist human users in accomplishing tasks in generic domains.
However, these agents have rarely been used in expert domains due to the lack of dialogue data to train the agents.
In contrast to generic domains, crowdsourcing is not a solution for expert domains since collecting dialogues in expert domains requires experts.
Due to the limited time budget of experts, encouraging experts to participate in a data collection study and then aligning the experts to chat about a topic is a cumbersome process.
The conventional crowdsourcing frameworks like Amazon Mechanical Turk (AMT) and Upwork are not suitable for dialogue collection in expert domains due to their shortcomings in
(1) letting experts suggest and choose the topics of dialogues, which helps in encouraging experts to participate in a conversation,
(2) being flexible with the time slots in which experts are willing to participate in a conversation, which is required as experts have limited time budget, and
(3) supporting synchronous participation, which is required to generate natural dialogues.
The first novelty of this work is to introduce a framework to collect argumentative dialogues in expert domains with an application to the NLP scientific domain (Section \ref{sec:dialogue_collection}).
In this domain, experts are NLP practitioners and scientists who chat about a scientific paper.
Our framework allows scientists to contribute to the data collection study using papers published by the scientists as groundings for dialogues.
It also lets scientists choose what scientific paper is of their interest to learn about through dialogue.
Moreover, our framework facilitates time alignment between scientists by letting them propose some time slots to join into a dialogue.
Therefore, our framework changes the view of the data collection process from a cumbersome and time-consuming process for scientists to an including process to conduct scientific dialogues.
\begin{figure*}[!t]
\centering
\includegraphics[width=\textwidth]{img/conversation_example.jpg}
\caption{An example dialogue from our ArgSciChat dataset.
Supportive facts $\{F_1, \dots, F_6\}$ are highlighted in the scientific paper.
Dialogue partners alternate between information-seeking (IS) and argumentative (Arg) intents.
}
\label{fig:conversation_example}
\end{figure*}
The second novelty of this work is \emph{ArgSciChat}, an argumentative dialogue dataset on scientific papers.
Figure~\ref{fig:conversation_example} demonstrates an example dialogue from our ArgSciChat dataset.
We use our framework to align scientists to conduct a dialogue in which one scientist is the Domain Expert (\texttt{DE}) and another scientist is the Proponent (\texttt{P}).
Given a scientific paper, \texttt{DE} is an expert on the research presented on that paper.
\texttt{P} attempts to learn about the paper by expressing information seeking questions.
Importantly, \texttt{DE} and \texttt{P} argue about the content of the paper and each other's opinion in a dialogue.
This shapes argumentative dialogues as a discourse structure including dialogue messages with two major sets of intents: \textbf{Information-Seeking (IS)} and \textbf{Argumentative (Arg)}~\cite{macagno2000types,walton_2008}.
Indeed, scientific papers follow a persuasive structure, which is necessary to conduct argumentative dialogues \cite{kirschner2015linking, green2015identifying}.
However, recent datasets on scientific papers are limited to the question-answering and reading comprehension tasks with information-seeking questions \cite{Dasigi2021ADO, welbl-etal-2018-constructing, reddy2019coqa, DBLP:journals/corr/abs-1909-06146,DBLP:journals/corr/abs-2011-06623}.
In ArgSciChat, the intents of messages are grouped into IS, Arg, or Mixed (which is a combination of IS and Arg) intents.
Moreover, dialogue messages are grounded on facts selected from papers.
We refer to these facts as \emph{supportive facts} as \texttt{DE} and \texttt{P} use them to support their arguments in a dialogue.
To the best of our knowledge, we are the first to introduce a dialogue dataset on scientific papers where dialogues are annotated with argumentative intent labels and accompanied with supportive facts.
We analyze dialogues in our ArgSciChat dataset (Section~\ref{sec:dialogues_analysis}).
Our dataset consists of 498 messages collected from 41 dialogues over 20 scientific papers.
Compared with dialogues in similar datasets (i.e., CoQA, QuAC, and Doc2Dial) messages in ArgSciChat are longer and consist of multiple sentences.
We find that sentences of dialogues in our dataset are topically diverse, making our dataset useful for evaluating dialogue agents.
We evaluate a recent dialogue agent to play the role of a domain expert on scientific papers in our dataset.
The examined dialogue agent poorly performs on ArgSicChat, motivating further research on argumentative dialogue generation on scientific papers.
This work is beneficial for the NLP community. The designed framework can be used for collecting dialogues in various expert domains.
The ArgSciChat dataset initiates a challenge for document-grounded dialogue agents to conduct argumentative dialogues.
Overall, this work leads towards building practical dialogue agents for expert domains.
\section*{Acknowledgments}
We would like to thank the NLP scientists who participated in our dialogue collection study.
These scientists are mostly from the UKP Lab at the Technical University of Darmstadt and the Center for Information and Language Processing (CIS) group at the University of Munich (LMU).
We also thank Thy Thy Tran for commenting on early drafts of this paper.
\section*{Ethical Consent}
Participants are asked to read the detailed document concerning data privacy and informed consent during participation sign-up. In this document, the aim of the study and the later use of collected data is explicitly stated to inform participants. Extensive details about required personal data information and temporary usage are shown. Lastly, participants can request data deletion at any given step of the study. All participants who agree to sign-up also consent to participate in the study.
\section{Related Work}
\label{sec:related_work}
Table \ref{tab:dataset_comparison} schematically compares ArgSciChat with well known conversational and QA datasets.
\subsection{Dialogue Datasets on Scientific Papers}
Recent datasets on scientific papers address the QA tasks primarily.
The majority of such QA datasets on scientific papers are centred on entity linking to knowledge bases, such as emrQA \cite{DBLP:journals/corr/abs-1809-00732}, BioRead \cite{pappas-etal-2018-bioread}, BioMRC \cite{DBLP:journals/corr/abs-2005-06376} and QAngaroo \cite{welbl-etal-2018-constructing}.
Some datasets focus on content retrieval like PubMedQA \cite{DBLP:journals/corr/abs-1909-06146} and BioAsq \cite{balikas2013evaluation, 10.1007/978-3-030-45442-5_71}.
In these datasets, sentences are limited to single words or text spans extracted from paper content.
In contrast, dialogue sentences in ArgSciChat are exclusively in a free-text format, i.e. dialogue partners are free to formulate their sentences as natural as possible.
The free-text format ensures lexical diversity reflecting a natural human dialogue~\cite{reddy2019coqa}.
QASPER~\cite{Dasigi2021ADO} is a recent question-answering dataset on scientific papers.
Unlike QASPER, ArgSciChat consists of argumentative dialogues between scientists.
\subsection{Argumentative Dialogue Datasets}
A few papers study dialogue datasets with argumentative annotations. These papers mostly explore online debates, such as the Persuasion dataset \cite{Biran2011IdentifyingJI}, RedditCMV \cite{hidey-etal-2017-analyzing}, CreateDebate \cite{swanson-etal-2015-argument},
and political debates~\cite{DBLP:conf/acl/HaddadanCV19}. Online debates are rich sources for argument mining~\cite{lippi2016argumentation, lawrence2020}.
However, the extracted arguments do not manifest the characteristics of the dialogue discourse as arguments in online debates are not synchronous.
Dialogue datasets with argumentative annotations in the scientific literature have yet not been explored.
Prior studies address the argument identification task for scientific manuscripts \cite{lauscher2018argument, sakai2018creating, trautmann2020fine, liakata2010corpora, accuosto2019transferring}.
The benefits of these augmentations have also been studied for open dialogue agents \cite{toniuc2017climebot, le2018dave, swanson2015argument} and educational agents \cite{kulatska2019arguebot}.
ArgSciChat is the first argumentative dialogue dataset on scientific papers where dialogues are annotated with argumentative intent labels.
|
{'timestamp': '2022-02-21T02:20:11', 'yymm': '2202', 'arxiv_id': '2202.06690', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06690'}
|
arxiv
|
\subsection*{Proofs of Section~\ref{sec:causal_perspective}}
\observationalDataSufficiency*
\begin{proof}
First, recall that with observational data alone, a causal graph can be identified up to its Markov equivalence class~\cite{2014buhlmann}. This means that its skeleton and v-structure are properly identified, meanwhile determining the edge orientations requires interventional data in the general case. Since in the considered causal graph $\mathcal{G}$ the edges orientations are determined a priori (as they follow the direction of time), the causal graph can be entirely determined by using only observational data.
\end{proof}
\subsection*{Proofs of Section~\ref{sec:complexity_generalization}: Causal Transition Model Estimation}
Before reporting the proof of the main result in Theorem~\ref{thr:sample_complexity}, it is worth considering a set of lemmas that will be instrumental to the main proof.
First, we provide an upper bound to the L1-norm between the Bayesian network $P_\mathcal{G}$ over a given structure $\mathcal{G}$ and the Bayesian network $P_{\mathcal{G}_\epsilon}$ over the structure $\mathcal{G}_\epsilon$, which is the $\epsilon$-dependency subgraph of $\mathcal{G}$ as defined in Definition~\ref{def:dependency_subgraph}.
\begin{lemma}
\label{thr:l1_norm_bayesian_networks}
Let $\mathcal{G}$ a $Z$-sparse dependency graph, and let $\mathcal{G}_\epsilon$ its corresponding $\epsilon$-dependence subgraph for a threshold $\epsilon > 0$. The L1-norm between the Bayesian network $P_{\mathcal{G}}$ over $\mathcal{G}$ and the Bayesian network $P_{\mathcal{G}_\epsilon}$ over $\mathcal{G}_\epsilon$ can be upper bounded as
\begin{equation*}
\| P_{\mathcal{G}} - P_{\mathcal{G}_\epsilon} \|_1 \leq d_S Z \epsilon.
\end{equation*}
\end{lemma}
\begin{proof}
The proof is based on the fact that every edge $(X_i, Y_j)$ such that $(X_i, Y_j) \in \mathcal{G}$ and $(X_i, Y_j) \notin \mathcal{G}_{\epsilon}$ corresponds to a weak conditional dependence (see Definition~\ref{def:dependency_subgraph}), which means that $ \| P_{Y_j | X_i} - P_{Y_j} \|_1 \leq \epsilon$.
We denote with $Z_j$ the scopes of the parents of the node $Y[j]$ in $\mathcal{G}$, \ie $\Pa_\mathcal{G} (Y[j]) = X[Z_j]$, and with $Z_{j, \epsilon}$ the scopes of the parents of the node $Y[j]$ in $\mathcal{G}_{\epsilon}$, \ie $\Pa_{\mathcal{G}_\epsilon} (Y[j]) = X[Z_{j,\epsilon}]$. As a direct consequence of Definition~\ref{def:dependency_subgraph}, we have $Z_{j, \epsilon} \subseteq Z_j$ for any $j \in d_S$, and we can write
\begin{equation*}
P_\mathcal{G} (Y | X)
= \prod_{j = 1}^{d_S} P_j (Y[j] \ | \ X[Z_j])
= \prod_{j = 1}^{d_S} P_j (Y[j] \ | \ X[Z_{j,\epsilon}], X[Z_j \setminus Z_{j,\epsilon}]),
\qquad
P_{\mathcal{G}_{\epsilon}} (Y | X)
= \prod_{j = 1}^{d_S} P_j (Y[j] \ | \ X[Z_{j,\epsilon}]).
\end{equation*}
Then, we let $Z_j \setminus Z_{j, \epsilon} = [I]$ overwriting the actual indices for the sake of clarity, and we derive
\begin{align}
\| P_\mathcal{G} - P_{\mathcal{G}_\epsilon} \|_1
&\leq \sum_{j = 1}^{d_S} \Big\| P_j (Y[j] \ | \ X[Z_{j, \epsilon}], \cup_{i = 1}^I X[i]) - P_j (Y[j] \ | \ X[Z_{j, \epsilon}] ) \Big\|_1 \label{eq:13} \\
&\leq \sum_{j = 1}^{d_S} \sum_{i' = 1}^{I} \Big\| P_j (Y[j] \ | \ X[Z_{j,\epsilon}], \cup_{i = i'}^I X[i]) - P_j (Y[j] \ | \ X[Z_{j, \epsilon}], \cup_{i = i' + 1}^I X[i] ) \Big\|_1 \label{eq:14} \\
&\leq \sum_{j = 1}^{d_S} \sum_{i' = 1}^{I} \epsilon \leq d_S Z \epsilon, \label{eq:15}
\end{align}
in which we employed the property $\| \mu - \nu \|_1 \leq \| \prod_i \mu_i - \prod_i \nu_i \|_1 \leq \sum_{i} \| \mu_i - \nu_i \|_1$ for the L1-norm between product distributions $\mu = \prod_i \mu_i, \nu = \prod_i \nu_i$ to write~\eqref{eq:13}, we repeatedly applied the triangle inequality $\| \mu - \nu \|_1 \leq \| \mu - \rho \|_1 + \| \rho - \nu \|_1$ to get~\eqref{eq:14} from~\eqref{eq:13}, we upper bounded each term of the sum in~\eqref{eq:14} with $\epsilon$ thanks to Definition~\ref{def:dependency_subgraph}, and we finally employed the Z-sparseness Assumption~\ref{ass:sparseness} to upper bound $I$ with $Z$ in~\eqref{eq:15}.
\end{proof}
Next, we provide a crucial sample complexity result for a provably efficient estimation of a Bayesian network $\widehat{P}_{\widehat{\mathcal{G}}}$ over an estimated $\epsilon$-dependency subgraph $\widehat{\mathcal{G}}$, which relies on both the causal structure estimation result of Theorem~\ref{thr:sample_complexity_G} and the Bayesian network estimation result of Theorem~\ref{thr:sample_complexity_P}.
\begin{lemma}
\label{thr:sample_complexity_PG}
Let $\mathcal{M}$ be a discrete MDP, let $\mathbb{M} = \{ \mathcal{M} \}$ be a singleton class, let $\delta \in (0, 1)$, and let $\epsilon > 0$. The Algorithm~\ref{alg:learning_ctm} returns a Bayesian network $\widehat{P}_{\widehat{\mathcal{G}}}$ such that $ Pr ( \| \widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G} \|_1 \geq \epsilon ) \leq \delta $ with a sample complexity
\begin{equation*}
K = O \Bigg( \frac{d_S^3 \ Z^2 \ n^{3Z + 1} \ \log \big( \frac{ 4 d_S^2 d_A n^Z }{ \delta} \big) }{ \epsilon^2} \Bigg).
\end{equation*}
\end{lemma}
\begin{proof}
We aim to obtain the number of samples $K = K' + K''$ for which Algorithm~\ref{alg:learning_ctm} is guaranteed to return a Bayesian network estimate $\widehat{P}_{\widehat{\mathcal{G}}}$ over a causal structure estimate $\widehat{\mathcal{G}}$ such that $Pr ( \| \widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G} \|_1 \geq \epsilon ) \leq \delta$ in a setting with a singleton class of discrete MDPs. First, we derive the following decomposition of the error
\begin{equation}
\| \widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G} \|_1
\leq \| \widehat{P}_{\widehat{\mathcal{G}}} \pm P_{\widehat{\mathcal{G}}} \pm P_{{\mathcal{G}}_{\epsilon'}} - P_\mathcal{G} \|_1
\leq \| \widehat{P}_{\widehat{\mathcal{G}}} - P_{\widehat{\mathcal{G}}} \|_1
+ \| P_{\widehat{\mathcal{G}}} - P_{\mathcal{G}_{\epsilon'}} \|_1
+ \| P_{\mathcal{G}_{\epsilon'}} - P_\mathcal{G} \|_1
\label{eq:error_decomposition}
\end{equation}
in which we employed the triangle inequality $\| \mu - \nu \|_1 \leq \| \mu - \rho \|_1 + \| \rho - \nu \|_1$. Then, we can write
\begin{equation*}
Pr \big( \| \widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G} \|_1 \geq \epsilon \big)
\leq \underbrace{Pr \Big( \| \widehat{P}_{\widehat{\mathcal{G}}} - P_{\widehat{\mathcal{G}}} \|_1 \geq \frac{\epsilon}{3} \Big)}_{\text{Bayesian network estimation } (\star)}
+ \underbrace{Pr \Big( \| P_{\widehat{\mathcal{G}}} - P_{\mathcal{G}_{\epsilon'}} \|_1 \geq \frac{\epsilon}{3}\Big)}_{\text{causal structure estimation } (\bullet)}
+ \underbrace{Pr \Big( \| P_{\mathcal{G}_{\epsilon'}} - P_\mathcal{G} \|_1 \geq \frac{\epsilon}{3} \Big)}_{\text{Bayesian network subgraph } (\diamond)}
\end{equation*}
through the decomposition~\eqref{eq:error_decomposition} and a union bound to isolate the three independent sources of error $(\star), (\bullet), (\diamond)$. To upper bound the latter term $(\diamond)$ with 0, we invoke Lemma~\ref{thr:l1_norm_bayesian_networks} to have $d_s Z \epsilon' \leq \frac{\epsilon}{3}$, which gives $\epsilon' \leq \frac{\epsilon}{3 d_S Z}$. Then, we consider the middle term $(\bullet)$, for which we can write
\begin{equation}
Pr \bigg( \| P_{\widehat{\mathcal{G}}_{\epsilon'}} - P_{\mathcal{G}_{\epsilon'}} \|_1 \geq \frac{\epsilon}{3} \bigg) \leq Pr \big( \widehat{\mathcal{G}} \neq \mathcal{G}_\epsilon \big).
\label{eq:causal_estimation}
\end{equation}
We can now upper bound $(\bullet) \leq \delta / 2$ through~\eqref{eq:causal_estimation} by invoking Theorem~\ref{thr:sample_complexity_G} with threshold $\epsilon' = \frac{\epsilon}{3 d_S Z}$ and confidence $\delta' = \frac{\delta}{2}$, which gives
\begin{equation}
K' = C' \bigg( \frac{ d_S^{4 / 3} \ Z^{4 / 3} \ n \ \log^{1 / 3} (2 d_S^2 d_A / \delta) }{ \epsilon^{4 / 3}} + \frac{d_S^2 \ Z^2 \ n \ \log^{1 / 2} (2 d_S^2 d_A / \delta) + \log(2 d_S^2 d_A / \delta)}{\epsilon^2} \bigg).
\label{eq:k1}
\end{equation}
Next, we can upper bound $(\star) \leq \delta / 2$ by invoking Theorem~\ref{thr:sample_complexity_P} with threshold $\epsilon' = \frac{\epsilon}{3}$ and confidence $\delta' = \frac{\delta}{2}$, which gives
\begin{equation}
K'' = C'' \bigg( \frac{ \ d_S^3 \ n^{3Z + 1} \ \log (4 d_S n^Z / \delta)}{\epsilon^2 } \bigg).
\label{eq:k2}
\end{equation}
Finally, through the combination of~\eqref{eq:k1} and~\eqref{eq:k2}, we can derive the sample complexity that guarantees $ Pr ( \| \widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G} \|_1 \geq \epsilon ) \leq \delta $ under the assumption $\epsilon^{4 / 3} \ll \epsilon^2$, \ie
\begin{equation*}
K = K' + K'' \leq \frac{d_S^3 \ Z^2 \ n^{3Z + 1} \ \log \Big( \frac{4 d_S^2 d_A n^Z}{\delta} \Big)}{\epsilon^2},
\end{equation*}
which concludes the proof.
\end{proof}
Whereas Lemma~\ref{thr:sample_complexity_PG} is concerned with the sample complexity of learning the Bayesian network of a singleton class, we can now extend the result to account for a class $\mathbb{M}$ composed of $M$ discrete MDPs.
\sampleComplexityCTM*
\begin{proof}
We aim to obtain the number of samples $K = M K' + K''$ for which Algorithm~\ref{alg:learning_ctm} is guaranteed to return a Bayesian network estimate $\widehat{P}_{\widehat{\mathcal{G}}}$ over a causal structure estimate $\widehat{\mathcal{G}}$ such that $Pr ( \| \widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G} \|_1 \geq \epsilon ) \leq \delta$ in a setting with a class of $M$ discrete MDPs. First, we can derive an analogous decomposition as in~\eqref{eq:error_decomposition}, such that we have
\begin{equation*}
Pr \big( \| \widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G} \|_1 \geq \epsilon \big)
\leq \underbrace{Pr \Big( \| \widehat{P}_{\widehat{\mathcal{G}}} - P_{\widehat{\mathcal{G}}} \|_1 \geq \frac{\epsilon}{3} \Big)}_{\text{Bayesian network estimation } (\star)}
+ \underbrace{Pr \Big( \| P_{\widehat{\mathcal{G}}} - P_{\mathcal{G}_{\epsilon'}} \|_1 \geq \frac{\epsilon}{3}\Big)}_{\text{causal structure estimation } (\bullet)}
+ \underbrace{Pr \Big( \| P_{\mathcal{G}_{\epsilon'}} - P_\mathcal{G} \|_1 \geq \frac{\epsilon}{3} \Big)}_{\text{Bayesian network subgraph } (\diamond)}
\end{equation*}
through a union bound. Crucially, the terms $(\star), (\diamond)$ are unaffected by the class size, which leads to $K'' = \eqref{eq:k2}$ by upper bounding $(\star)$, and $\epsilon' \leq \frac{\epsilon}{3 d_S Z}$ by upper bounding $(\diamond)$, exactly as in the proof of Lemma~\ref{thr:sample_complexity_PG}. Instead, the number of samples $K'$ has to guarantee that $(\bullet) = Pr ( \| P_{\widehat{\mathcal{G}}} - P_{\mathcal{G}_{\epsilon'}} \|_1 \geq \epsilon / 3 ) \leq \delta / 2$, where the causal structure $\mathcal{G}_{\epsilon'}$ is now the intersection of the causal structures of the single class components $\mathcal{M}_i$, \ie $\mathcal{G}_{\epsilon'} = \cap_{i = 1}^M \mathcal{G}_{\epsilon', i}$. Especially, we can write
\begin{equation}
(\bullet) = Pr \Big( \| P_{\widehat{\mathcal{G}}} - P_{\mathcal{G}_{\epsilon'}} \|_1 \geq \frac{\epsilon}{3} \Big)
\leq Pr \Big( \widehat{\mathcal{G}} \neq \mathcal{G}_{\epsilon'} \Big)
\leq Pr \bigg( \bigcup_{i = 1}^M \widehat{\mathcal{G}}_i \neq \mathcal{G}_{\epsilon', i} \bigg)
\leq \sum_{i = 0}^M Pr \Big( \widehat{\mathcal{G}}_i \neq \mathcal{G}_{\epsilon', i} \Big),
\label{eq:causal_structures}
\end{equation}
through a union bound on the estimation of the single causal structures $\widehat{\mathcal{G}}_i$. Then, we can upper bound $(\bullet) \leq \delta / 2$ through~\eqref{eq:causal_structures} by invoking Theorem~\ref{thr:sample_complexity_G} with threshold $\epsilon' = \frac{\epsilon}{3 d_S Z}$ and confidence $\delta' = \frac{\delta}{2M}$, which gives
\begin{equation}
K' = C' \bigg( \frac{ d_S^{4 / 3} \ Z^{4 / 3} \ n \ \log^{1 / 3} (2 M d_S^2 d_A / \delta) }{ \epsilon^{4 / 3}} + \frac{d_S^2 \ Z^2 \ n \ \log^{1 / 2} (2 M d_S^2 d_A / \delta) + \log(2 M d_S^2 d_A / \delta)}{\epsilon^2} \bigg).
\label{eq:k1m}
\end{equation}
Finally, through the combination of~\eqref{eq:k1m} and~\eqref{eq:k2}, we can derive the sample complexity that guarantees $ Pr ( \| \widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G} \|_1 \geq \epsilon ) \leq \delta $ under the assumption $\epsilon^{4 / 3} \ll \epsilon^2$, \ie
\begin{equation*}
K = M K' + K'' \leq \frac{M d_S^3 \ Z^2 \ n^{3Z + 1} \ \log \Big( \frac{4 M d_S^2 d_A n^Z}{\delta} \Big)}{\epsilon^2},
\end{equation*}
which concludes the proof.
\end{proof}
It is now straightforward to extend Lemma~\ref{thr:sample_complexity_ctm} for a class $\mathbb{M}$ composed of $M$ tabular MDPs.
\sampleComplexityCTMtabular*
\begin{proof}
To obtain $K = M K' + K''$, we follows similar steps as in the proof of Lemma~\ref{thr:sample_complexity_ctm}, to have the usual decomposition of the event $Pr ( \| \widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G} \|_1 \geq \epsilon ) $ in the $(\star), (\bullet), (\diamond)$ terms. We can deal with $(\diamond)$ as in Lemma~\ref{thr:sample_complexity_ctm} to get $\epsilon' \leq \frac{\epsilon}{3 S Z}$. Then, we upper bound $(\bullet) \leq \delta / 2$ by invoking Corollary~\ref{thr:sample_complexity_G_tabular} (instead of Theorem~\ref{thr:sample_complexity_G}) with threshold $\epsilon' = \frac{\epsilon}{3 S Z}$ and confidence $\delta' = \frac{\delta}{2M}$, which gives
\begin{equation}
K' = C' \bigg( \frac{ S^{4 / 3} \ Z^{4 / 3} \ \log^{1 / 3} (2 M S^2 A / \delta) }{ \epsilon^{4 / 3}} + \frac{S^2 \ Z^2 \ \log^{1 / 2} (2 M S^2 A / \delta) + \log(2 M S^2 A / \delta)}{\epsilon^2} \bigg).
\label{eq:k1m_tabular}
\end{equation}
Similarly, we upper bound $(\star) \leq \delta / 2$ by invoking Corollary~\ref{thr:sample_complexity_P_tabular} (instead of Theorem~\ref{thr:independence_testing}) with threshold $\epsilon' = \frac{\epsilon}{3}$ and confidence $\delta' = \frac{\delta}{2}$, which gives
\begin{equation}
K'' = \frac{ 18 \ S^2 \ 2^{2Z} \ \log( 4 S 2^Z / \delta)}{ \epsilon^2 }.
\label{eq:k2_tabular}
\end{equation}
Finally, we combine~\ref{eq:k1m_tabular} with~\ref{eq:k2_tabular} to obtain
\begin{equation*}
K = M K' + K'' \leq \frac{M \ S^2 \ Z^2 \ 2^{2Z} \ \log \big( \frac{ 4 M S^2 A 2^Z }{ \delta} \big) }{ \epsilon^2}
\end{equation*}
\end{proof}
\subsection*{Proofs of Section~\ref{sec:complexity_generalization}: Planning}
For the sake of notational clarity within the following proofs we express
\sampleComplexity*
\begin{proof}
Consider the MDPs with transition model $P$ and $\widehat{P}_{\widehat{\mathcal{G}}}$. We refer to the respective optimal policies as $\pi^*$ and $\widehat{\pi}^*$. Moreover, since the reward $r$ is fixed, we remove it from the expressions for the sake of clarity, and refer with $\widehat{V}$ to the value function of the MDP with transition model $\widehat{P}_{\widehat{\mathcal{G}}}$. As done in~\citep[][Theorem 3.5]{jin2020reward}, we can write the following decomposition, where $V^* := V^{\pi^*}$.
\begin{align*}
\EV_{s_1 \sim P}\Big[V^*_1 (s_1) - V^{\widehat{\pi}}_1 (s_1)\Big] &\leq \underbrace{\Big|\EV_{s_1 \sim P}\Big[V^*_1 (s_1) - \widehat{V}^{\widehat{\pi}^*}_1 (s_1)\Big]\Big|}_{\text{evaluation error}} + \underbrace{\EV_{s_1 \sim P}\Big[\widehat{V}^*_1 (s_1) - \widehat{V}^{\widehat{\pi}^*}_1 (s_1)\Big]}_{\text{$\leq 0$ by def.}}\\
&+ \underbrace{\EV_{s_1 \sim P}\Big[\widehat{V}^{\widehat{\pi}^*}_1 (s_1) - \widehat{V}^{\widehat{\pi}}_1 (s_1)\Big]}_{\text{optimization error}} + \underbrace{\Big| \EV_{s_1 \sim P}\Big[\widehat{V}^{\widehat{\pi}}_1 (s_1) - V^{\widehat{\pi}}_1(s_1)\Big]\Big|}_{\text{evaluation error}}\\
&\leq \underbrace{2 n^{Z + 1} H^3\epsilon'}_{\epsilon} + \underbrace{2n^{2Z + 1}d_S H^3\lambda}_{\epsilon_\lambda}
\end{align*}
where in the last step we have set to 0 the approximation due to the planning oracle assumption, and we have bounded the evaluation errors according to Lemma \ref{thr:evaluation_error_discrete}. In order to get $2 n^{Z + 1}H^3\epsilon' = \epsilon$ we have to set $\epsilon' = \frac{\epsilon}{2n^{Z + 1}H^3}$. Considering the sample complexity result in Lemma \ref{thr:sample_complexity_ctm} the final sample complexity will be:
\begin{equation*}
K = O \Bigg( \frac{M \ d_S^3 \ Z^2 \ n^{3Z + 1} \ \log \big( \frac{ 4 M d_S^2 d_A n^Z }{ \delta} \big) }{ (\epsilon')^2} \Bigg) = O \Bigg( \frac{4 \ M \ d_S^3 \ Z^2 \ n^{5Z + 3} \ H^6 \ \log \big( \frac{ 4 M d_S^2 d_A n^Z }{ \delta} \big) }{ \epsilon^2} \Bigg)
\end{equation*}
\end{proof}
\begin{lemma}
\label{thr:evaluation_error_discrete}
Under the preconditions of Theorem~\ref{thr:sample_complexity}, with probability $1-\delta$, for any reward function $r$ and policy $\pi$, we can bound the value function estimation error as follows.
\begin{equation}
\Big| \EV_{s \sim P}\Big[\widehat{V}^\pi_{1,r}(s) - V_{1,r}^\pi(s) \Big] \Big| \leq \underbrace{n^{Z + 1} H^3\epsilon'}_{\epsilon} + \underbrace{n^{2Z + 1} d_S H^3\lambda}_{\epsilon_\lambda}
\end{equation}
where $\widehat{V}$ is the value function of the MDP with transition model $\widehat{P}_{\widehat{\mathcal{G}}}$, $\epsilon'$ is the approximation error between $\widehat{P}_{\widehat{\mathcal{G}}}$ and $P_G$ studied in Lemma \ref{thr:sample_complexity_ctm}, and $\lambda$ stands for the $\lambda$-sufficiency parameter of $P_\mathcal{G}$.
\end{lemma}
\begin{proof}
The proof will be along the lines of that of Lemma 3.6 in~\citep[]{jin2020reward}. We first recall ~\citep[][Lemma E.15]{dann2018unifying}, which we restate in Lemma \ref{thr:V_difference}. In this prof we consider an environment specific true MDP $\mathcal{M}$ with transition model $P$, and an mdp $\widehat{\mathcal{M}}$ that has as transition model the estimated causal transition model $\widehat{P}_{\widehat{\mathcal{G}}}$. In the following, the expectations will be \wrt $P$. Moreover, since the reward $r$ is fixed, we remove it from the expressions for the sake of clarity. We can start deriving
\begin{align}
\Big| \EV_{s \sim P}\Big[\widehat{V}^\pi_1(s) - V_1^\pi(s) \Big] \Big| &\leq \Big| \EV_{X}\Big[\sum_{h=1}^H (\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}_{h+1}^\pi(X) \Big] \Big| \nonumber\\
&\leq \EV_{X}\Big[\sum_{h=1}^H \Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}_{h+1}^\pi(X)\Big| \Big] \nonumber\\
&= \sum_{h=1}^H \EV_{X}\Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}_{h+1}^\pi(X)\Big| \label{initial_expression}
\end{align}
We now bound a single term within the sum above as follows:
\begin{align}
\EV_{X}\Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}_{h+1}^\pi(X)\Big| &= \EV_{X}\Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G} + P_\mathcal{G} - P)\widehat{V}_{h+1}^\pi(X)\Big| \nonumber\\
&= \EV_{X}\Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G})\widehat{V}_{h+1}^\pi(X) + (P_\mathcal{G} - P)\widehat{V}_{h+1}^\pi(X)\Big| \nonumber\\
&\leq \EV_{X} \Bigg[\Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G})\widehat{V}_{h+1}^\pi(X)\Big| + \Big|(P_\mathcal{G} - P)\widehat{V}_{h+1}^\pi(X)\Big| \Bigg] \nonumber\\
&=\EV_{X} \Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G})\widehat{V}_{h+1}^\pi(X)\Big| + \EV_{X}\Big|(P_\mathcal{G} - P)\widehat{V}_{h+1}^\pi(X)\Big| \label{eq_decomposition}
\end{align}
We can now bound each term. Let us start considering the first term:
\begin{align}
\EV_{X}\Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G})\widehat{V}_{h+1}^\pi(X)\Big| &= \EV_{X}\Big|\widehat{P}_{\widehat{\mathcal{G}}}\widehat{V}_{h+1}^\pi(X) - P_\mathcal{G}\widehat{V}_{h+1}^\pi(X)\Big| \nonumber\\
&= \EV_{X}\Big|\sum_{Y}\widehat{P}_{\widehat{\mathcal{G}}}(Y|X)\widehat{V}_{h+1}^\pi(Y) - \sum_{Y}P_\mathcal{G}(Y|X) \widehat{V}_{h+1}^\pi(Y)\Big| \nonumber\\
&= \EV_{X}\Big|\sum_{Y}\widehat{P}_{\widehat{\mathcal{G}}}(Y|X)\EV_{X' \sim \pi}\Big[ r(X') + \widehat{P}_{\widehat{\mathcal{G}}}\widehat{V}_{h+2}^\pi(X') \Big] - \sum_{Y}P_\mathcal{G}(Y|X)\EV_{X' \sim \pi}\Big[ r(X') + P_\mathcal{G} \widehat{V}_{h+2}^\pi(X') \Big] \Big| \nonumber\\
&= \EV_{X}\Big|\sum_{Y}\big(\widehat{P}_{\widehat{\mathcal{G}}}(Y|X) - P_\mathcal{G}(Y|X)\big)\EV_{X' \sim \pi}\Big[ r(X')\Big] \nonumber\\
&+ \sum_{Y}\widehat{P}_{\widehat{\mathcal{G}}}(Y|X)\EV_{X' \sim \pi}\Big[ \widehat{P}_{\widehat{\mathcal{G}}} \widehat{V}_{h+2}^\pi(X')\Big] - \sum_{Y}P_\mathcal{G}(Y|X)\EV_{X' \sim \pi}\Big[ P_\mathcal{G} \widehat{V}_{h+2}^\pi(X')\Big] \Big| \nonumber\\
&\leq \EV_{X}\Big|\sum_{Y}\big(\widehat{P}_{\widehat{\mathcal{G}}}(Y|X) - P_\mathcal{G}(Y|X)\big) \Big| \label{eq_3_terms}\\
&+ \EV_{X} \Big|\sum_{Y}\widehat{P}_{\widehat{\mathcal{G}}}(Y|X)\EV_{X' \sim \pi}\Big[ \widehat{P}_{\widehat{\mathcal{G}}} \widehat{V}_{h+2}^\pi(X')\Big] - \sum_{Y}P_\mathcal{G}(Y|X)\EV_{X' \sim \pi}\Big[ P_\mathcal{G} \widehat{V}_{h+2}^\pi(X')\Big] \Big| \nonumber
\end{align}
We can now bound the first term of \eqref{eq_3_terms}:
\begin{align}
\EV_{X}\Big|\sum_{Y}\big(\widehat{P}_{\widehat{\mathcal{G}}}(Y|X) - P_\mathcal{G}(Y|X)\big) \Big| &= \EV_{X}\Bigg|\sum_{Y}\Big(\prod_{j=1}^{d_S}\widehat{P}_j(Y[j]|X[Z_j]) - \prod_{j=1}^{d_S}P_j(Y[j]|X[Z_j])\Big) \Bigg| \nonumber\\
&\leq \EV_{X}\Bigg[\sum_{Y}\sum_{j=1}^{d_S}\Big| \widehat{P}_j(Y[j]|X[Z_j]) - P_j(Y[j]|X[Z_j]) \Big| \Bigg] \nonumber\\
&= \sum_{X}P_\mathcal{G}^\pi(X)\Bigg[\sum_{Y}\sum_{j=1}^{d_S}\Big| \widehat{P}_j(Y[j]|X[Z_j]) - P_j(Y[j]|X[Z_j]) \Big| \Bigg] \nonumber\\
&= \sum_{Y}\sum_{j=1}^{d_S}\sum_{X[Z_j]}P_\mathcal{G}^\pi(X[Z_j])\Big| \widehat{P}_j(Y[j]|X[Z_j]) - P_j(Y[j]|X[Z_j]) \Big| \label{single_term}
\end{align}
Due to the uniform sampling and Z-sparseness assumptions, we have $P_\mathcal{G}(X[Z_j]) = \frac{1}{n^Z}$, hence:
\begin{equation*}
\max_{\pi^\dagger}\frac{P_\mathcal{G}^{\pi^\dagger}(X[Z_j])}{P_\mathcal{G}(X[Z_j])} \leq \frac{1}{P_\mathcal{G}(X[Z_j])} = n^Z
\end{equation*}
Therefore:
\begin{equation*}
P_\mathcal{G}^{\pi^\dagger}(X[Z_j]) \leq n^Z\cdot P_\mathcal{G}(X[Z_j])
\end{equation*}
Replacing this in \eqref{single_term} and marginalizing over $Y$ \textbackslash $Y[j]$ we obtain:
\begin{align*}
\EV_{X}\Big|\sum_{Y}\big(\widehat{P}_{\widehat{\mathcal{G}}}(Y|X) - P_\mathcal{G}(Y|X)\big) \Big| &= n^Z \sum_{j=1}^{d_s}\sum_{Y[j]}\sum_{X[Z_j]}\Big| \widehat{P}_j(Y[j]|X[Z_j]) - P_j(Y[j]|X[Z_j]) \Big| P_\mathcal{G}(X[Z_j])\\
&\leq n^Z \sum_{j=1}^{d_S}\sum_{Y[j]} \frac{\epsilon'}{d_S}\sum_{X[Z_j]}P_\mathcal{G}(X[Z_j])\\
&= n^{Z+1} \epsilon'
\end{align*}
Where $\frac{\epsilon'}{d_S}$ is the approximation term of each component. By plugging this bound into \eqref{eq_3_terms} we get:
\begin{align*}
\EV_{X}\Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G})\widehat{V}_{h+1}^\pi(X)\Big| &\leq n^{Z+1} \epsilon' + \EV_{X} \Big|\sum_{Y}\widehat{P}_{\widehat{\mathcal{G}}}(Y|X)\EV_{X' \sim \pi}\Big[ \widehat{P}_{\widehat{\mathcal{G}}} \widehat{V}_{h+2}^\pi(X')\Big] - \sum_{Y}P_\mathcal{G}(Y|X)\EV_{X' \sim \pi}\Big[ P_\mathcal{G} \widehat{V}_{h+2}^\pi(X')\Big] \Big|\\
&\leq \sum_{i=h+1}^H i\cdot n^{Z+1} \epsilon'\\
&\leq H^2 n^{Z+1} \epsilon'
\end{align*}
where in the last step we have recursively bounded the right terms as in \eqref{recursive_bound}.
By considering $2Z$-sparseness, $\lambda$-sufficiency, and that the transition model $P$ factorizes, we can apply the same procedure to bound the second term of equation \eqref{eq_decomposition} as:
\begin{equation*}
\EV_{X}\Big|(P_\mathcal{G} - P)\widehat{V}_{h+1}^\pi(X)\Big| \leq H^2 n^{Z + 1} d_S \lambda
\end{equation*}
Therefore the initial expression in \eqref{initial_expression} becomes:
\begin{align}
\Big| \EV_{s \sim P}\Big[\widehat{V}^\pi_1(s) - V_1^\pi(s) \Big] \Big| &\leq \sum_{h=1}^H \EV_{X}\Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}_{h+1}^\pi(X)\Big|\\
&\leq \sum_{h=1}^H [n^{Z + 1} H^2 \epsilon' + n^{2Z + 1} d_S H^2 \lambda]\\
&\leq \underbrace{n^{Z + 1} H^3 \epsilon'}_{\epsilon} + \underbrace{n^{2Z + 1}d_S H^3\lambda}_{\epsilon_\lambda}
\end{align}
\end{proof}
\sampleComplexitytabular*
\begin{proof}
Consider the MDPs with transition model $P$ and $\widehat{P}_{\widehat{\mathcal{G}}}$. We refer to the respective optimal policies as $\pi^*$ and $\widehat{\pi}^*$. Moreover, since the reward $r$ is fixed, we remove it from the expressions for the sake of clarity, and refer with $\widehat{V}$ to the value function of the MDP with transition model $\widehat{P}_{\widehat{\mathcal{G}}}$. As done in~\citep[][Theorem 3.5]{jin2020reward}, we can write the following decomposition, where $V^* := V^{\pi^*}$.
\begin{align*}
\EV_{s_1 \sim P}\Big[V^*_1 (s_1) - V^{\widehat{\pi}}_1 (s_1)\Big] &\leq \underbrace{\Big|\EV_{s_1 \sim P}\Big[V^*_1 (s_1) - \widehat{V}^{\widehat{\pi}^*}_1 (s_1)\Big]\Big|}_{\text{evaluation error}} + \underbrace{\EV_{s_1 \sim P}\Big[\widehat{V}^*_1 (s_1) - \widehat{V}^{\widehat{\pi}^*}_1 (s_1)\Big]}_{\text{$\leq 0$ by def.}}\\
&+ \underbrace{\EV_{s_1 \sim P}\Big[\widehat{V}^{\widehat{\pi}^*}_1 (s_1) - \widehat{V}^{\widehat{\pi}}_1 (s_1)\Big]}_{\text{optimization error}} + \underbrace{\Big| \EV_{s_1 \sim P}\Big[\widehat{V}^{\widehat{\pi}}_1 (s_1) - V^{\widehat{\pi}}_1}_{\text{evaluation error}} (s_1)\Big]\Big|\\
&\leq \underbrace{2SAH^3\epsilon'}_{\epsilon} + \underbrace{2SAH^3\lambda}_{\epsilon_\lambda}
\end{align*}
where in the last step we have set to 0 the approximation due to the planning oracle assumption, and we have bounded the evaluation errors according to Lemma \ref{thr:evaluation_error_tabular}. In order to get $2SAH^3 \epsilon' = \epsilon$ we have to set $\epsilon' = \frac{\epsilon}{2SAH^3}$. Considering the sample complexity result in Lemma \ref{thr:sample_complexity_ctm_tabular} the final sample complexity will be:
\begin{equation*}
K = O \Bigg( \frac{M \ S^2 \ Z^2 \ 2^{2Z} \ \log \big( \frac{ 4 M S^2 A 2^Z }{ \delta} \big) }{ (\epsilon')^2} \Bigg) = O \Bigg( \frac{4M \ S^4 \ A^2 \ H^6 \ Z^2 \ 2^{2Z} \ \log \big( \frac{ 4 M S^2 A 2^Z }{ \delta} \big) }{ \epsilon^2} \Bigg)
\end{equation*}
\end{proof}
\begin{lemma}
\label{thr:evaluation_error_tabular}
Under the preconditions of Corollary~\ref{thr:sample_complexity_tabular}, with probability $1-\delta$, for any reward function $r$ and policy $\pi$, we can bound the value function estimation error as follows.
\begin{equation}
\Big| \EV_{s \sim P}\Big[\hat{V}^\pi_{1,r}(s) - V_{1,r}^\pi(s) \Big] \Big| \leq \underbrace{SAH^3\epsilon'}_{\epsilon} + \underbrace{SAH^3\lambda}_{\epsilon_\lambda}
\end{equation}
where $\widehat{V}$ is the value function of the MDP with transition model $\widehat{P}_{\widehat{\mathcal{G}}}$, $\epsilon'$ is the approximation error between $\widehat{P}_{\widehat{\mathcal{G}}}$ and $P_G$ studied in Lemma \ref{thr:sample_complexity_ctm}, and $\lambda$ stands for the $\lambda$-sufficiency parameter of $P_\mathcal{G}$.
\end{lemma}
\begin{proof}
The proof will be along the lines of that of Lemma 3.6 in~\citep[]{jin2020reward}. We first recall ~\citep[][Lemma E.15]{dann2018unifying}, which we restate in Lemma \ref{thr:V_difference}. In this prof we consider an environment specific true MDP $\mathcal{M}$ with transition model $P$, and an mdp $\widehat{\mathcal{M}}$ that has as transition model the estimated causal transition model $\widehat{P}_{\widehat{\mathcal{G}}}$. In the following, the expectations will be \wrt $P$. Moreover, since the reward $r$ is fixed, we remove it from the expressions for the sake of clarity. We can start deriving
\begin{align*}
\Big| \EV_{s \sim P}\Big[\hat{V}^\pi_1(s) - V_1^\pi(s) \Big] \Big| &\leq \Big| \EV_{\pi}\Big[\sum_{h=1}^H (\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}_{h+1}^\pi(s_h,a_h) \Big] \Big|\\
&\leq \EV_{\pi}\Big[\sum_{h=1}^H \Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}_{h+1}^\pi(s_h,a_h)\Big| \Big]\\
&= \sum_{h=1}^H \EV_{\pi}\Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}_{h+1}^\pi(s_h,a_h)\Big|
\end{align*}
We now bound a single term within the sum above as follows:
\begin{align*}
\EV_{\pi}\Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}_{h+1}^\pi(s_h,a_h)\Big| &\leq \sum_{s,a} \Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}^\pi(s,a)\Big| P^\pi(s,a)\\
&= \sum_{s,a} \Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}^\pi(s,a)\Big| P^\pi(s)\pi(a|s)\\
&\leq \max_{\pi'}\sum_{s,a} \Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}^\pi(s,a)\Big| P^\pi(s)\pi'(a|s)\\
&= \max_{\nu: \mathcal{S} \to \mathcal{A}} \sum_{s,a} \Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}^\pi(s,a)\Big| P^\pi(s) \mathds{1} \{a=\nu(s)\}\\
\end{align*}
where in the last step we have used the fact that there must exist an optimal deterministic policy.\newline
Due to the uniform sampling assumption, we have $P(s,a) = \frac{1}{SA}$, hence:
\begin{equation*}
\max_{\pi^\dagger}\frac{P^{\pi^\dagger}(s,a)}{P(s,a)} \leq \frac{1}{P(s,a)} = SA
\end{equation*}
Therefore:
\begin{equation*}
P^{\pi_\dagger}(s,a) \leq SA\cdot P(s,a)
\end{equation*}
Moreover, notice that, since $\pi'$ is deterministic we have $P^\pi(s) = P^{\pi'}(s) = P^{\pi'}(s,a) \leq SA\cdot P(s,a)$. Replacing it in the expression above we get
\begin{align}
\EV_{\pi}\Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}_{h+1}^\pi(s_h,a_h)\Big| &\leq SA \cdot \sum_{s,a} \Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}_{h+1}^\pi(s,a)\Big| P(s) \mathds{1} \{a=\nu(s)\} \nonumber\\
&\leq SA \cdot \Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}_{h+1}^\pi(s,a)\Big| \nonumber\\
&\leq SA \cdot \Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G})\widehat{V}_{h+1}^\pi(s,a) \Big| + SA \cdot \Big|(P_\mathcal{G} - P)\widehat{V}_{h+1}^\pi(s,a)\Big| \label{eq_terms_pre}\\
&\leq SA\cdot \sum_{i=h+1}^H i\cdot \epsilon' + SA\cdot \sum_{i=h+1}^H i\cdot \lambda \nonumber\\
&\leq SAH^2\epsilon' + SAH^2\lambda \label{eq_terms}
\end{align}
where $\epsilon'$ is the approximation error between $\widehat{P}_{\widehat{\mathcal{G}}}$ and $P_G$ studied in Lemma \ref{thr:sample_complexity_ctm}, and in the penultimate step we have used the following derivation:
\begin{align}
\Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G})\widehat{V}_{h+1}^\pi(s,a) \Big| &= \Big|\widehat{P}_{\widehat{\mathcal{G}}}\widehat{V}_{h+1}^\pi(s,a) - P_\mathcal{G}\widehat{V}_{h+1}^\pi(s,a) \Big| \label{recursive_bound}\\
&= \Big|\sum_{s'}\widehat{P}_{\widehat{\mathcal{G}}}(s'|s,a)\widehat{V}_{h+1}^\pi(s') - \sum_{s'}P_\mathcal{G}(s'|s,a)\widehat{V}_{h+1}^\pi(s') \Big| \nonumber\\
&= \Big|\sum_{s'}\widehat{P}_{\widehat{\mathcal{G}}}(s'|s,a)\EV_{a' \sim \pi}\Big[ r(s',a') + \widehat{P}_{\widehat{\mathcal{G}}}\widehat{V}_{h+2}^\pi(s',a') \Big] - \sum_{s'}P_\mathcal{G}(s'|s,a)\EV_{a' \sim \pi}\Big[ r(s',a') + P_\mathcal{G} \widehat{V}_{h+2}^\pi(s',a') \Big] \Big| \nonumber\\
&= \Big|\sum_{s'}\big(\widehat{P}_{\widehat{\mathcal{G}}}(s'|s,a) - P_\mathcal{G}(s'|s,a)\big)\EV_{a' \sim \pi}\Big[ r(s',a')\Big] \nonumber\\
&+ \sum_{s'}\widehat{P}_{\widehat{\mathcal{G}}}(s'|s,a)\EV_{a' \sim \pi}\Big[\widehat{P}_{\widehat{\mathcal{G}}}\widehat{V}_{h+2}^\pi(s',a') \Big]
- \sum_{s'}P_\mathcal{G}(s'|s,a)\EV_{a' \sim \pi}\Big[P_\mathcal{G} \widehat{V}_{h+2}^\pi(s',a') \Big] \Big| \nonumber\\
&\leq \epsilon' + \Big| \sum_{s'}\widehat{P}_{\widehat{\mathcal{G}}}(s'|s,a)\EV_{a' \sim \pi}\Big[\widehat{P}_{\widehat{\mathcal{G}}}\widehat{V}_{h+2}^\pi(s',a') \Big]
- \sum_{s'}P_\mathcal{G}(s'|s,a)\EV_{a' \sim \pi}\Big[P_\mathcal{G} \widehat{V}_{h+2}^\pi(s',a') \Big] \Big| \nonumber\\
&= \epsilon' + \Big| \sum_{s'}\widehat{P}_{\widehat{\mathcal{G}}}(s'|s,a)\EV_{a' \sim \pi}\Big[\sum_{s''}\widehat{P}_{\widehat{\mathcal{G}}}(s''|s',a')\EV_{a'' \sim \pi}\Big[r(s'',a'') + \widehat{P}_{\widehat{\mathcal{G}}}\widehat{V}_{h+3}^\pi(s'',a'') \Big] \Big] \nonumber\\
&- \sum_{s'}P_\mathcal{G}(s'|s,a)\EV_{a' \sim \pi}\Big[\sum_{s''}P_\mathcal{G}(s''|s',a')\EV_{a'' \sim \pi}\Big[r(s'',a'') + P_\mathcal{G} \widehat{V}_{h+3}^\pi(s'',a'') \Big] \Big] \Big| \nonumber\\
&\leq \epsilon' + \sum_{s',s'',a'} \Big| \widehat{P}_{\widehat{\mathcal{G}}}(s'|s,a)\widehat{P}_{\widehat{\mathcal{G}}}(s''|s',a') - P_\mathcal{G}(s'|s,a)P_\mathcal{G}(s''|s',a') \Big|_1 + \ldots \nonumber\\
&\leq \epsilon' + \sum_{s',s'',a'}\Big[ \Big|\widehat{P}_{\widehat{\mathcal{G}}}(s'|s,a) - P_\mathcal{G}(s'|s,a)\Big|_1 + \Big|\widehat{P}_{\widehat{\mathcal{G}}}(s''|s',a') - P_\mathcal{G}(s''|s',a')\Big|_1\Big] + \ldots \nonumber\\
&\leq \epsilon' + 2\epsilon' + \ldots \nonumber
\end{align}
Hence, due to this recursive unrolling, we have:
\begin{equation*}
\Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G})\widehat{V}_{h+1}^\pi(s,a) \Big| \leq \sum_{i=h+1}^H i\epsilon' \leq H^2\epsilon
\end{equation*}
Notice that the same argument holds also for the second term of \eqref{eq_terms_pre}, replacing $\epsilon'$ with $\lambda$.
By plugging the result in equation \eqref{eq_terms} into the initial expression we get:
\begin{align*}
\Big| \EV_{s \sim P}\Big[\widehat{V}^\pi_1(s) - V_1^\pi(s) \Big] \Big| &\leq \sum_{h=1}^H \EV_{\pi}\Big|(\widehat{P}_{\widehat{\mathcal{G}}} - P)\widehat{V}_{h+1}^\pi(s_h,a_h)\Big|\\
&\leq \sum_{h=1}^H SAH^2\epsilon' + SAH^2\lambda\\
&= SAH^3\epsilon' + SAH^3\lambda
\end{align*}
\end{proof}
In the following we restate~\citep[][Lemma E.15]{dann2018unifying} for the case of stationary transition model.
\begin{lemma}
\label{thr:V_difference}
For any two MDPs $\mathcal{M}'$ and $\mathcal{M}''$ with rewards $r'$ and $r''$ and transition models $P'$ and $P''$, the difference in value functions $V', V''$ \wrt the same policy $\pi$ can be written as:
\begin{equation}
V'_h(s) - V''_h(s) = \EV_{\mathcal{M}'', \pi}\Big[\sum_{i=h}^H [r'(s_i, a_i) - r''(s_i, a_i) + (P'-P'')V'_{i+1}(s_i,a_i)]\mid s_h=s \Big]
\end{equation}
\end{lemma}
\subsection*{Proofs of Section~\ref{sec:complexity_cuasal_discovery}}
We provide the proof of the sample complexity result for learning the causal structure of a discrete MDP with a generative model.
\sampleComplexityG*
\begin{proof}
We aim to obtain the number of samples $K$ for which Algorithm~\ref{alg:learning_g} is guaranteed to return a causal structure estimate $\widehat{\mathcal{G}}$ such that $Pr (\widehat{\mathcal{G}} \neq \mathcal{G}_{\epsilon}) \leq \delta$ in a discrete MDP setting.
First, we can upper bound the probability of the bad event $Pr (\widehat{\mathcal{G}} \neq \mathcal{G}_{\epsilon})$ in terms of the probability of a failure in the independence testing procedure $\mathbb{I} (X_z, Y_j)$ for a single pair of nodes $X_z \in \mathcal{G}_\epsilon, Y_z \in \mathcal{G}_\epsilon$, \ie
\begin{equation}
Pr (\widehat{\mathcal{G}} \neq \mathcal{G}_{\epsilon})
\leq Pr \bigg( \bigcup_{z = 1}^{d_S + d_A} \bigcup_{j = 1}^{d_S} \text{ test } \mathbb{I} (X_z, Y_j) \text{ fails} \bigg)
\leq \sum_{z = 1}^{d_S + d_A} \sum_{j = 1}^{d_S} Pr \bigg(\text{test } \mathbb{I} (X_z, Y_j) \text{ fails} \bigg), \label{eq:ub}
\end{equation}
where we applied an union bound to obtain the last inequality. Now we can look at the probability of a single independence test failure. Especially, for a provably efficient independence test (the existence of such a test is stated by Lemma~\ref{thr:independence_testing}, whereas the Algorithm 2 in~\citet{diakonikolas2021optimal} reports an actual testing procedure), we have $Pr (\text{test } \mathbb{I} (X_z, Y_j) \text{ fails} ) \leq \delta' $, for any choice of $\delta' \in (0, 1)$, $\epsilon' > 0$, with a number of samples
\begin{equation}
K' = C \bigg( \frac{ n \ \log^{1 / 3} (1 / \delta') }{ (\epsilon')^{4 / 3}} + \frac{n \ \log^{1 / 2} (1 / \delta') + \log(1 / \delta')}{(\epsilon')^2} \bigg), \label{eq:K}
\end{equation}
where $C$ is a sufficiently large universal constant~\citep[][Theorem 1.3]{diakonikolas2021optimal}. Finally, by letting $\epsilon' = \epsilon$, $\delta' = \frac{\delta}{d_S^2 d_A}$ and combining~\eqref{eq:ub} with~\eqref{eq:K}, we obtain $Pr (\widehat{\mathcal{G}} \neq \mathcal{G}_{\epsilon})$ with a sample complexity
\begin{equation*}
K = O \bigg( \frac{n \log(d_S^2 d_A / \delta)}{\epsilon^2} \bigg),
\end{equation*}
under the assumption $\epsilon^2 \ll \epsilon^{4 / 3}$, which concludes the proof.
\end{proof}
The proof of the analogous sample complexity result for a tabular MDP setting (Corollary~\ref{thr:sample_complexity_G_tabular}) is a direct consequence of Theorem~\ref{thr:sample_complexity_G} by letting $n = 2, d_S = S, d_A = A$.
\subsection*{Proofs of Section~\ref{sec:complexity_bayesian_network}}
We first report a useful concentration inequality for the L1-norm between the empirical distribution computed over $K$ samples and the true distribution~\citep[][Theorem 2.1]{weissman2003inequalities}.
\begin{lemma}[\citet{weissman2003inequalities}]
\label{thr:l1_concentration}
Let $X_1, \ldots, X_K$ be i.i.d. random variables over $[n]$ having probabilities $Pr (X_k = i) = P_i$, and let $\widehat{P}_{K} (i) = \frac{1}{K} \sum_{k = 1}^{K} \mathds{1} (X_k = i)$. Then, for every threshold $\epsilon > 0$, it holds
\begin{equation*}
Pr \bigg( \| \widehat{P}_K - P \|_1 \geq \epsilon \bigg) \leq 2 \exp(- K \epsilon^2 / 2n).
\end{equation*}
\end{lemma}
We can now provide the proof of the sample complexity result for learning the Bayesian network of a discrete MDP with a given causal structure.
\sampleComplexityP*
\begin{proof}
We aim to obtain the number of samples $K$ for which Algorithm~\ref{alg:learning_p} is guaranteed to return a Bayesian network estimate $\widehat{P}_\mathcal{G}$ such that $ Pr ( \| \widehat{P}_\mathcal{G} - P_\mathcal{G} \|_1 \geq \epsilon ) \leq \delta $ in a discrete MDP setting. First, we note that
\begin{align}
Pr \Big( \| \widehat{P}_\mathcal{G} - P_\mathcal{G} \|_1 \geq \epsilon \Big)
&\leq Pr \bigg( \sum_{j = 1}^{d_S} \| \widehat{P}_j - P_j \|_1 \geq \epsilon \bigg) \label{eq:1} \\
&\leq Pr \bigg( \frac{1}{d_S} \sum_{j = 1}^{d_S} \| \widehat{P}_j - P_j \|_1 \geq \frac{\epsilon}{d_S} \bigg) \\
&\leq Pr \bigg( \bigcup_{j = 1}^{d_S} \| \widehat{P}_j - P_j \|_1 \geq \frac{\epsilon}{d_S} \bigg) \label{eq:2} \\
&\leq \sum_{j = 1}^{d_S} Pr \bigg( \| \widehat{P}_j - P_j \|_1 \geq \frac{\epsilon}{d_S} \bigg), \label{eq:3}
\end{align}
in which we employed the property $\| \mu - \nu \|_1 \leq \| \prod_i \mu_i - \prod_i \nu_i \|_1 \leq \sum_{i} \| \mu_i - \nu_i \|_1$ for the L1-norm between product distributions $\mu = \prod_i \mu_i, \nu = \prod_i \nu_i$ to write~\eqref{eq:1}, and we applied a union bound to derive~\eqref{eq:3} from~\eqref{eq:2}. Similarly, we can write
\begin{align}
Pr \Big( \| \widehat{P}_j - P_j \|_1 \geq \frac{\epsilon}{d_S} \Big)
&\leq Pr \bigg( \bigcup_{x \in [n]^{|Z_j|}} \| \widehat{P}_j (\cdot | x) - P_j (\cdot | x) \|_1 \geq \frac{\epsilon}{d_S n^{|Z_j|}} \bigg) \label{eq:4} \\
&\leq \sum_{x \in [n]^{|Z_j|}} Pr \bigg( \| \widehat{P}_j (\cdot | x) - P_j (\cdot | x) \|_1 \geq \frac{\epsilon}{d_S n^{|Z_j|}} \bigg) \label{eq:5} \\
&\leq \sum_{x \in [n]^{|Z_j|}} Pr \bigg( \| \widehat{P}_j (\cdot | x) - P_j (\cdot | x) \|_1 \geq \frac{\epsilon}{d_S n^{Z}} \bigg) \label{eq:6}
\end{align}
by applying a union bound to derive~\eqref{eq:5} from~\eqref{eq:4}, and by employing Assumption~\ref{ass:sparseness} to bound $|Z_j|$ with $Z$ in~\eqref{eq:6}. We can now invoke Lemma~\ref{thr:l1_concentration} to obtain the sample complexity $K'$ that guarantees $ Pr ( \| \widehat{P}_j (\cdot | x) - P_j (\cdot | x) \|_1 \geq \epsilon' ) \leq \delta' $, \ie
\begin{equation*}
K' = \frac{2 n \log (2 / \delta')}{ (\epsilon')^2} = \frac{2 \ d_S^2 \ n^{2Z + 1} \ \log (2 d_S n^Z / \delta)}{\epsilon^2 },
\end{equation*}
where we let $\epsilon' = \frac{\epsilon}{d_S n^Z} $, $\delta' = \frac{\delta}{d_S n^Z}$. Finally, by summing $K'$ for any $x \in [nm]^{|Z_j|}$ and any $j \in [d_S]$, we obtain
\begin{equation*}
K = \sum_{j \in [d_S]} \sum_{x \in [n]^{|Z_j|}} K' \leq \frac{2 \ d_S^3 \ n^{3Z + 1} \ \log (2 d_S n^Z / \delta)}{\epsilon^2 },
\end{equation*}
which proves the theorem.
\end{proof}
To prove the analogous sample complexity result for a tabular MDP we can exploit a slightly tighter concentration on the KL divergence between the empirical distribution and the true distribution in the case of binary variables~~\citep[][Theorem 2.2.3]{dembo2009ldp}\footnote{Also reported in \citep[][Example 1]{mardia2020concentration}.}, which we report for convenience in the following lemma.
\begin{lemma}[\citet{dembo2009ldp}]
\label{thr:KL_binary_concentration}
Let $X_1, \ldots, X_K$ be i.i.d. random variables over $[2]$ having probabilities $Pr (X_k = i) = P_i$, and let $\widehat{P}_{K} (i) = \frac{1}{K} \sum_{k = 1}^{K} \mathds{1} (X_k = i)$. Then, for every threshold $\epsilon > 0$, it holds
\begin{equation*}
Pr \bigg( d_{KL} \big( \widehat{P}_K || P \big) \geq \epsilon \bigg) \leq 2 \exp(- K \epsilon).
\end{equation*}
\end{lemma}
We can now provide the proof of Corollary~\ref{thr:sample_complexity_P_tabular}.
\sampleComplexityPtabular*
\begin{proof}
We aim to obtain the number of samples $K$ for which Algorithm~\ref{alg:learning_p} is guaranteed to return a Bayesian network estimate $\widehat{P}_\mathcal{G}$ such that $ Pr ( \| \widehat{P}_\mathcal{G} - P_\mathcal{G} \|_1 \geq \epsilon ) \leq \delta $ in a tabular MDP setting. We start by considering the KL divergence $d_{KL} ( \widehat{P}_\mathcal{G} || P_\mathcal{G} )$. Especially, we note
\begin{align*}
d_{KL} \big( \widehat{P}_\mathcal{G} || P_\mathcal{G} \big)
&= \sum_{X, Y} \widehat{P}_\mathcal{G} (X, Y) \log \frac{\widehat{P}_\mathcal{G} (X, Y)}{P_\mathcal{G} (X, Y)} \\
&= \sum_{X, Y} \widehat{P}_\mathcal{G} (X, Y) \log \frac{ \prod_{j = 1}^{S} \widehat{P}_j (Y[j] | X[Z_j])}{\prod_{j = 1}^{S} P_j (Y[j] | X[Z_j])} \\
&= \sum_{X, Y} \widehat{P}_\mathcal{G} (X, Y) \sum_{j = 1}^{S} \log \frac{ \widehat{P}_j (Y[j] | X[Z_j])}{ P_j (Y[j] | X[Z_j])} = \sum_{j = 1}^{S} d_{KL} \big( \widehat{P}_j || P_j \big).
\end{align*}
Then, for any $\epsilon' > 0$ we can write
\begin{align}
Pr \Big( d_{KL} \big( \widehat{P}_\mathcal{G} || P_\mathcal{G} \big) \geq \epsilon' \Big)
&\leq Pr \bigg( \bigcup_{j = 1}^{S} d_{KL} \big( \widehat{P}_j || P_j \big) \geq \frac{\epsilon'}{S} \bigg) \label{eq:7} \\
&\leq \sum_{j = 1}^{S} Pr \bigg( d_{KL} \big( \widehat{P}_j || P_j \big) \geq \frac{\epsilon'}{S} \bigg) \label{eq:8} \\
&\leq \sum_{j = 1}^{S} Pr \bigg( \bigcup_{x \in [2]^{|Z_j|}} d_{KL} \big( \widehat{P}_j (\cdot | x) || P_j (\cdot | x) \big) \geq \frac{\epsilon'}{S 2^{|Z_j|}} \bigg) \label{eq:9} \\
&\leq \sum_{j = 1}^{S} \sum_{x \in [2]^{|Z_j|}} Pr \bigg( d_{KL} \big( \widehat{P}_j (\cdot | x) || P_j (\cdot | x) \big) \geq \frac{\epsilon'}{S 2^{|Z_j|}} \bigg) \label{eq:10} \\
&\leq \sum_{j = 1}^{S} \sum_{x \in [2]^{|Z_j|}} Pr \bigg( d_{KL} \big( \widehat{P}_j (\cdot | x) || P_j (\cdot | x) \big) \geq \frac{\epsilon'}{S 2^{Z}} \bigg), \label{eq:11}
\end{align}
in which we applied a first union bound to get~\eqref{eq:8} from~\eqref{eq:7}, a second union bound to get~\eqref{eq:10} from~\eqref{eq:9}, and Assumption~\ref{ass:sparseness} to bound $|Z_j|$ with $Z$ in~\eqref{eq:11}. We can now invoke Lemma~\ref{thr:KL_binary_concentration} to obtain the sample complexity $K''$ that guarantees $ Pr ( d_{KL} ( \widehat{P}_j (\cdot | x) || P_j (\cdot | x) ) \geq \epsilon'' ) \leq \delta'' $, \ie
\begin{equation*}
K'' = \frac{ \log(2 / \delta'')}{\epsilon''} = \frac{ S 2^Z \log(2 S 2^Z / \delta')}{ \epsilon'},
\end{equation*}
where we let $\epsilon'' = \frac{\epsilon'}{S 2^Z}$, and $\delta'' = \frac{\delta'}{S 2^Z}$ for any choice of $\delta' \in (0, 1)$. By summing $K''$ for any $x \in [2]^{|Z_j|}$ and and $j \in [S]$, we obtain the sample complexity $K'$ that guarantees $ Pr ( d_{KL} ( \widehat{P}_\mathcal{G} || P_\mathcal{G} ) \geq \epsilon' ) \leq \delta' $, \ie
\begin{equation}
K' = \sum_{j = 1}^{S} \sum_{x \in [2]^{|Z_j|}} K'' \leq \frac{ S^2 2^{2Z} \log(2 S 2^Z / \delta')}{ \epsilon'}. \label{eq:12}
\end{equation}
Finally, we employ the Pinsker's inequality $\| \widehat{P}_\mathcal{G} - P_\mathcal{G} \|_1 \leq \sqrt{ 2 d_{KL} ( \widehat{P}_\mathcal{G} || P_\mathcal{G}) }$~\cite{csiszar1967information} to write
\begin{equation*}
Pr \Big( d_{KL} ( \widehat{P}_\mathcal{G} || P_\mathcal{G}) \geq \epsilon' \Big)
= Pr \Big( \sqrt{ 2 d_{KL} ( \widehat{P}_\mathcal{G} || P_\mathcal{G})} \geq \sqrt{ 2 \epsilon'} \Big)
\geq Pr \Big( \| \widehat{P}_\mathcal{G} - P_\mathcal{G} \|_1 \geq \sqrt{ 2 \epsilon'} \Big),
\end{equation*}
which gives the sample complexity $K$ that guarantees $ Pr ( \| \widehat{P}_\mathcal{G} - P_\mathcal{G} \|_1 \geq \epsilon ) \leq \delta $ by letting $\epsilon' = \frac{\epsilon^2}{2}$ and $\delta' = \delta$ in~\eqref{eq:12}, \ie
\begin{equation*}
K = \frac{ 2 S^2 2^{2Z} \log( 2 S 2^Z / \delta)}{ \epsilon^2 }.
\end{equation*}
\end{proof}
\subsection{Sample Complexity of Systematic Generalization with a Generative Model}
\label{sec:complexity_generalization}
We have access to a class $\mathbb{M}$ of discrete MDPs within a universe $\mathbb{U}$, from which we can draw interactions with a generative model $P(X)$. We would like to solve the systematic generalization problem as described in Definition~\ref{def:systematic_generalization}. This problem requires to provide, for any combination of a (latent) MDP $\mathcal{M} \in \mathbb{U}$, and a given reward function $r$, a planning policy $\widehat{\pi}$ such that
$ V^*_{\mathcal{M}, r} - V^{\widehat{\pi}}_{\mathcal{M}, r} \leq \epsilon.$
Especially, can we design an algorithm that guarantees this requirement with high probability by taking a number of samples $K$ that is polynomial in $\epsilon$ and the relevant parameters of $\mathbb{M}$? Here we give a partially positive answer to this question, by providing a simple but provably efficient algorithm that guarantees systematic generalization over $\mathbb{U}$ up to an unavoidable sub-optimality term $\epsilon_\lambda$ that we will later specify.
The algorithm implements a model-based approach into two separated components. The first, for which we provide the pseudocode in Algorithm~\ref{alg:learning_ctm}, is the procedure that actually interacts with the class $\mathbb{M}$ to obtain a principled estimation $\widehat{P}_{\widehat{\mathcal{G}}}$ of the causal transition model $P_\mathcal{G}$ of $\mathbb{U}$. The second, is a planning oracle that takes as input a reward function $r$ and the estimated causal transition model, and returns an optimal policy $\widehat{\pi}$ operating on $\widehat{P}_{\widehat{\mathcal{G}}}$ as an approximation of the transition model $P_i$ of the true MDP $\mathcal{M}_i$.\footnote{Note that we do not lose generality here, as the planning oracle can be substituted with a principled approximate planning solver~\citep[see][Section 3.3]{jin2020reward}.}
First, we provide the sample complexity of the causal transition model estimation (Algorithm~\ref{alg:learning_ctm}), which in turn is based on repeated causal structure estimations (Algorithm~\ref{alg:learning_g}) to obtain $\widehat{\mathcal{G}}$, and an estimation procedure of the Bayesian network over $\widehat{\mathcal{G}}$ (Algorithm~\ref{alg:learning_p}) to obtain $\widehat{P}_{\widehat{\mathcal{G}}}$.
\begin{restatable}[]{lemma}{sampleComplexityCTM}
\label{thr:sample_complexity_ctm}
Let $\mathbb{M} = \{ \mathcal{M}_i \}_{i = 1}^M$ be a class of $M$ discrete MDPs, let $\delta \in (0, 1)$, and let $\epsilon > 0$. The Algorithm~\ref{alg:learning_ctm} returns a causal transition model $\widehat{P}_{\widehat{\mathcal{G}}}$ such that $ Pr ( \| \widehat{P}_{\widehat{\mathcal{G}}} - P_\mathcal{G} \|_1 \geq \epsilon ) \leq \delta $ with a sample complexity
\begin{equation*}
K = O \Bigg( \frac{M d_S^3 Z^2 n^{3Z + 1} \log \big( \frac{ 4 M d_S^2 d_A n^Z }{ \delta} \big) }{ \epsilon^2} \Bigg).
\end{equation*}
\end{restatable}
An analogous result can be derived for the tabular MDP setting, as stated by the following lemma.
\begin{restatable}[]{lemma}{sampleComplexityCTMtabular}
\label{thr:sample_complexity_ctm_tabular}
Let $\mathbb{M} = \{ \mathcal{M}_i \}_{i = 1}^M$ be a class of $M$ tabular MDPs. The sample complexity of Lemma~\ref{thr:sample_complexity_ctm} reduces to
\begin{equation*}
K = O \Bigg( \frac{M S^2 Z^2 2^{2Z} \log \big( \frac{ 4 M S^2 A 2^Z }{ \delta} \big) }{ \epsilon^2} \Bigg).
\end{equation*}
\end{restatable}
Having established the sample complexity of the causal transition model estimation, we can now show how the learned model $\widehat{P}_{\widehat{\mathcal{G}}}$ allows us to approximately solve, via a planning oracle, any task defined by a combination of a latent MDP $\mathcal{M}_i \in \mathbb{U}$ and a given reward function $r$. To provide this result in the discrete MDP setting, we have to further assume that the transition dynamics $P_i$ of the target MDP $\mathcal{M}_i$ admits factorization analogous to~\eqref{eq:factorization}, such that we can write $P_i (Y | X) = \prod_{j = 1}^{d_S} P_{i, j} (Y[j] | X[Z_j^{'}])$, where the scopes $Z_j^{'}$ are given by the environment-specific causal structure $\mathcal{G}_i$, which we assume to be $2Z$-sparse (Assumption~\ref{ass:sparseness}).
\begin{restatable}[]{theorem}{sampleComplexity}
\label{thr:sample_complexity}
Let $\delta \in (0, 1)$ and $\epsilon > 0$. For a latent discrete MDP $\mathcal{M} \in \mathbb{U}$, and a given reward function $r$, a planning oracle operating on the causal transition model $\widehat{P}_{\widehat{\mathcal{G}}}$ as an approximation of $\mathcal{M}$ returns a policy $\widehat{\pi}$ such that
\begin{equation*}
Pr \big( V^*_{\mathcal{M}_i, r} - V_{\mathcal{M}_i, r} \geq \epsilon_\lambda + \epsilon \big) \leq \delta,
\end{equation*}
where $\epsilon_\lambda = 2 \lambda H^3 d_S n^{2Z + 1}$, and $\widehat{P}_{\widehat{\mathcal{G}}}$ is obtained from Algorithm~\ref{alg:learning_ctm} with $\delta' = \delta$ and $\epsilon' = \epsilon / 2 H^3 n^{Z + 1}$.
\end{restatable}
Without the additional factorization of the environment-specific transition model, the result of Theorem~\ref{thr:sample_complexity} reduces to the analogous for the tabular MDP setting.
\begin{restatable}[]{corollary}{sampleComplexitytabular}
\label{thr:sample_complexity_tabular}
For a tabular MDP $\mathcal{M} \in \mathbb{M}$, the result of Theorem~\ref{thr:sample_complexity} holds with $\epsilon_\lambda = 2 \lambda S A H^3 $, $\epsilon' = \epsilon / 2 S A H^3$.
\end{restatable}
Theorem~\ref{thr:sample_complexity} and Corollary~\ref{thr:sample_complexity_tabular} establish the sample complexity of systematic generalization through Lemma~\ref{thr:sample_complexity_ctm} and Lemma~\ref{thr:sample_complexity_ctm_tabular} respectively. For the discrete MDP setting, we have that $\widetilde{O} (M H^6 d_S^3 Z^2 n^{5Z + 3} )$, which reduces to $\widetilde{O} (M H^6 S^4 A^2 Z^2 )$ in the tabular setting. Unfortunately, we are only able to obtain systematic generalization up to an unavoidable sub-optimality term $\epsilon_\lambda$. This error term is related to the $\lambda$-sufficiency of the causal transition model (Assumption~\ref{ass:sufficiency}), and it accounts for the fact that $P_\mathcal{G}$ cannot fully explain the transition dynamics of each $\mathcal{M} \in \mathbb{U}$, even when it is estimated exactly. This is inherent to the ambitious problem setting, and can be only overcome with additional interactions with the test MDP $\mathcal{M}$.
\begin{algorithm}[t!]
\caption{Causal Transition Model Estimation}
\label{alg:learning_ctm}
\begin{algorithmic}[t]
\STATE \textbf{Input}: class of MDPs $\mathbb{M}$, error $\epsilon$, confidence $\delta$
\STATE let $K' = C' \big( d_S^2 Z^2 n \log (2 M d_S^2 d_A / \delta ) \big/ \epsilon^2 \big)$
\STATE set the generative model $P(X) = \mathcal{U}_{X}$
\FOR{$i = 1, \ldots, M$}
\STATE let $P_i (Y|X)$ be the transition model of $\mathcal{M}_i \in \mathbb{M}$
\STATE $\widehat{\mathcal{G}}_i \leftarrow$ \emph{Causal Structure Estimation} $(P_i, P(X), K')$
\ENDFOR
\STATE let $\widehat{\mathcal{G}} = \cap_{i = 1}^M \widehat{\mathcal{G}}_i$
\STATE let $K'' = C'' \big( d_S^3 n^{3Z + 1} \log (4 d_S n^Z / \delta ) \big/ \epsilon^2 \big)$
\STATE let $P_\mathbb{M} (Y | X)$ be the mixture $\frac{1}{M} \sum_{i = 1}^M P_i (Y | X)$
\STATE $\widehat{P}_{\widehat{\mathcal{G}}} \leftarrow$ \emph{Bayesian Network Estimation} $(P_\mathbb{M}, \widehat{\mathcal{G}}, K'')$
\STATE \textbf{Output}: causal transition model $\widehat{P}_{\widehat{\mathcal{G}}}$
\end{algorithmic}
\end{algorithm}
\subsection{Sample Complexity of Learning the Causal Structure of a Discrete MDP}
\label{sec:complexity_cuasal_discovery}
As a byproduct of the main result in Theorem~\ref{thr:sample_complexity}, we can provide a specific sample complexity result for the problem of learning the causal structure $\mathcal{G}$ underlying a discrete MDP $\mathcal{M}$ with a generative model.
We believe that this problem can be of independent interest, mainly in consideration of previous work on causal discovery of general stochastic processes~\citep[\eg][]{wadhwa2021sample}, for which we refine known results to account for the structure of an MDP, which allows for a tighter analysis of the sample complexity.
Instead of targeting the exact dependency graph $\mathcal{G}$, which can include dependencies that are so weak to be nearly impossible to detect with a finite number of samples, we only address the dependencies above a given $\epsilon$ threshold.
\begin{definition}[]
\label{def:dependency_subgraph}
We call $\mathcal{G}_\epsilon \subseteq \mathcal{G}$ the {\em $\epsilon$-dependency subgraph} of $\mathcal{G}$ if it holds, for each pair $(A, B) \in \mathcal{G}$ distributed as $P_{A, B}$
\begin{equation*}
(A, B) \in \mathcal{G}_\epsilon \quad \text{iff} \quad \inf_{Q \in \{ \Delta_A \times \Delta_B\} } \| P_{A, B} - Q \|_1 \geq \epsilon.
\end{equation*}
\end{definition}
Before presenting the sample complexity result, we state the existence of a principled independence testing procedure.
\begin{lemma}[\citet{diakonikolas2021optimal}]
\label{thr:independence_testing}
There exists an $(\epsilon,\delta)$-independence tester $\mathbb{I} (A, B)$ for distributions $P_{A, B}$ on $[n] \times [n]$, which returns with probability at least $1 - \delta$
\begin{itemize}[noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt]
\item yes, if $A, B$ are independent,
\item no, if $\inf_{Q \in \{ \Delta_A \times \Delta_B\} } \| P_{A, B} - Q \|_1 \geq \epsilon$,
\end{itemize}
with a sample complexity $O ( n \log (1 / \delta) / \epsilon^2 )$.
\end{lemma}
We can now provide an upper bound to the number of samples required by a simple estimation procedure to return an $(\epsilon, \delta)$-estimate $\widehat{\mathcal{G}}$ of the causal dependency graph $\mathcal{G}$.
\begin{restatable}[]{theorem}{sampleComplexityG}
\label{thr:sample_complexity_G}
Let $\mathcal{M}$ be a discrete MDP with an underlying causal structure $\mathcal{G}$, let $\delta \in (0, 1)$, and let $\epsilon > 0$. The Algorithm~\ref{alg:learning_g} returns a dependency graph $\widehat{\mathcal{G}}$ such that $ Pr ( \widehat{\mathcal{G}} \neq \mathcal{G}_\epsilon ) \leq \delta $ with a sample complexity
\begin{equation*}
K = O \big( n \log ( d_S^2 d_A / \delta) / \epsilon^2 \big).
\end{equation*}
\end{restatable}
Finally, we can state an analogous result for a tabular MDP setting, by taking $n = 2, d_S = S, d_A = A$.
\begin{restatable}[]{corollary}{}
\label{thr:sample_complexity_G_tabular}
Let $\mathcal{M}$ be a tabular MDP. The result of Theorem~\ref{thr:sample_complexity_G} reduces to
$
K = O \big( \log ( S^2 A / \delta) / \epsilon^2 \big).
$
\end{restatable}
\begin{algorithm}[t!]
\caption{Causal Structure Estimation for an MDP}
\label{alg:learning_g}
\begin{algorithmic}[t]
\STATE \textbf{Input}: sampling model $P(Y|X)$, generative model $P(X)$, batch parameter $K$
\STATE draw $(x_k, y_k)_{k = 1}^{K} \overset{\text{iid}}{\sim} P(Y | X) P(X)$
\STATE initialize $\widehat{\mathcal{G}} = \emptyset$
\FOR{each pair of nodes $X_z, Y_j$}
\STATE compute the independence test $\mathbb{I} (X_z, Y_j)$
\STATE if a dependency is found add $(X_z, Y_j)$ to $\widehat{\mathcal{G}}$
\ENDFOR
\STATE \textbf{Output}: causal dependency graph $\widehat{\mathcal{G}}$
\end{algorithmic}
\end{algorithm}
\subsection{Sample Complexity of Learning the Bayesian Network of a Discrete MDP}
\label{sec:complexity_bayesian_network}
We present as a standalone result an upper bound to the sample complexity of learning the parameters of a Bayesian network $P_\mathcal{G}$ with a fixed structure $\mathcal{G}$. Especially, we refine known results~\citep[\eg][]{friedman1996sample, dasgupta1997sample, cheng2002learning, abbeel2006learning, canonne2017bn} by considering the specific structure $\mathcal{G}$ of an MDP.
If the structure $\mathcal{G}$ is dense, the number of parameters of $P_\mathcal{G}$ grows exponentially, making the estimation problem mostly intractable. Thus, we consider a $Z$-sparse $\mathcal{G}$ (Assumption~\ref{ass:sparseness}), as in previous works~\cite{dasgupta1997sample}.
Then, we can provide a polynomial sample complexity for the problem of learning the Bayesian network $P_\mathcal{G}$ of a discrete MDP $\mathcal{M}$.
\begin{restatable}[]{theorem}{sampleComplexityP}
\label{thr:sample_complexity_P}
Let $\mathcal{M}$ be a discrete MDP, let $\mathcal{G}$ be its underlying causal structure, let $\delta \in (0, 1)$, and let $\epsilon > 0$. The Algorithm~\ref{alg:learning_p} returns a Bayesian network $\widehat{P}_\mathcal{G}$ such that $ Pr ( \| \widehat{P}_\mathcal{G} - P_\mathcal{G} \|_1 \geq \epsilon ) \leq \delta $ with a sample complexity
\begin{equation*}
K = O \big( d_S^3 n^{3Z + 1} \log ( d_S n^Z / \delta ) / \epsilon^2 \big).
\end{equation*}
\end{restatable}
Analogously, we can state the sample complexity of learning the fixed structure Bayesian network of a tabular MDP.
\begin{restatable}[]{corollary}{sampleComplexityPtabular}
\label{thr:sample_complexity_P_tabular}
Let $\mathcal{M}$ be a tabular MDP. The result of Theorem~\ref{thr:sample_complexity_P} reduces to
$
K = O \big( S^2 2^{2Z} \log ( S 2^Z / \delta ) / \epsilon^2 \big).
$
\end{restatable}
\begin{algorithm}[t!]
\caption{Bayesian Network Estimation for an MDP}
\label{alg:learning_p}
\begin{algorithmic}[t]
\STATE \textbf{Input}: sampling model $P(Y|X)$, dependency graph $\mathcal{G}$, batch parameter $K$
\STATE let $K' = \lceil K / d_S n^Z \rceil$
\FOR{$j = 1, \ldots, d_S$}
\STATE let $Z_j$ the scopes $(X[Z_j],Y[j]) \subseteq \mathcal{G} $
\STATE initialize the counts $N (X[Z_j], Y[j]) = 0$
\FOR{each value $x \in [n]^{|Z_j|}$}
\FOR{$k = 1, \ldots, K'$}
\STATE draw $y \sim P(Y[j] | X[Z_j] = x)$
\STATE increment $N (X[Z_j] = x, Y[j] = y)$
\ENDFOR
\ENDFOR
\STATE compute $\widehat{P}_j (Y[j]| X[Z_j]) = N (X[Z_j], Y[j]) / K'$
\ENDFOR
\STATE let $\widehat{P}_\mathcal{G} (Y | X) = \prod_{j = 1}^{d_S} \widehat{P}_j (Y[j] | X[Z_j])$
\STATE \textbf{Output}: Bayesian network $\widehat{P}_\mathcal{G}$
\end{algorithmic}
\end{algorithm}
\subsection{The Causal Structure of the Transition Dynamics}
The transition dynamics of a discrete MDP gives the conditional probability of next state features $s'$ given the current state-action features $(s, a)$. To ease the notation, from now on we will denote the current state-action features with a random vector $X = (X_i)_{i \in [d_S + d_A]}$, in which each $X_i$ is supported in $[n]$, and the next state features with a random vector $Y = (Y_i)_{i \in [d_S]}$, in which each $Y_i$ is supported in $[n]$.
For each environment $\mathcal{M}_i \in \mathbb{U}$, the conditional dependencies between the next state features $Y$ and the current state-action features $X$ are represented through a bipartite dependency graph $\mathcal{G}_i$, such that $(X[z], Y[j]) \in \mathcal{G}_i$ if and only if $Y[j]$ is conditionally dependent on $X[z]$.
Clearly, each environment can display its own dependencies, but we assume there is a set of dependencies that represent general causal relationships between the features, and that appear in any $\mathcal{M}_i \in \mathbb{U}$. In particular, we call the intersection $\mathcal{G} := \cap_{i = 0}^\infty \mathcal{G}_i$ the \emph{causal structure} of $\mathbb{U}$, which is the set of conditional dependencies that are common across the universe. In Figure~\ref{fig:causal_transition_model}, we show an illustration of such a causal structure.
Since it represents universal causal relationships, the causal structure $\mathcal{G}$ is time-consistent, \ie $\mathcal{G}^{(h)} = \mathcal{G}^{(1)}$ for any step $h \in [H]$, and we further assume that $\mathcal{G}$ is sparse, which means that the number of features $X[z]$ on which a feature $Y[j]$ is dependent on is bounded from above.
\begin{assumption}[$Z$-sparseness]
\label{ass:sparseness}
Let $Z \in \mathbb{N}$. The causal structure $\mathcal{G}$ is {\em $Z$-sparse} if $\max\limits_{j \in [d_S]} \mathrm{degree_{in}}(Y[j]) \leq Z$.
\end{assumption}
Given a causal structure $\mathcal{G}$, and without losing generality,\footnote{Note that one can always take $P_\mathcal{G} (Y | Z) = 1, \forall (X, Y)$ to avoid shared structure on the transition dynamics.} we can express each transition model $P_i$ as
\begin{equation*}
P_i (Y | X) = P_\G (Y | X) F_i (Y | X),
\end{equation*}
in which $P_\G$ is the Bayesian network over the causal structure $\mathcal{G}$, whereas $F_i$ includes environment-specific factors affecting the conditional probabilities.\footnote{The parameters in $F_i$ are numerical values such that $P_i$ remains a well-defined probability measure.} Since it represents the conditional probabilities due to universal causal relations in $\mathbb{U}$, we call $P_\mathcal{G}$ the \emph{causal transition model} of $\mathbb{U}$. Thanks to the structure $\mathcal{G}$, this model can be further factored as
\begin{equation}
\label{eq:factorization}
P_\G (Y | X) = \prod_{j = 1}^{d_S} P_j (Y[j] | X[Z_j] ),
\end{equation}
where the scopes $Z_j$ are the set of indices $z$ such that $(X[z], Y[j]) \in \mathcal{G}$, i.e. the causal parents of $X[z]$. In Figure~\ref{fig:bayesian_network}, we show an illustration of the causal transition model and its factorization.
Similarly to the underlying structure $\mathcal{G}$, the causal transition model $P_\mathcal{G}$ is also time-consistent, \ie $P_\mathcal{G}^{(h)} = P_{\mathcal{G}}^{(1)}$ for any step $h \in [H]$. For the purpose of this work, we make the crucial assumption that the causal transition model is non-vacuous and that it explains a significant part of the transition dynamics of $\mathcal{M}_i \in \mathbb{U}$.
\begin{assumption}[$\lambda$-sufficiency]
\label{ass:sufficiency}
Let $\lambda \in [0, 1]$ be a constant. The causal transition model $P_{\mathcal{G}}$ is {\em causally $\lambda$-sufficient} if
\begin{equation*}
\sup_{X} \| P_{\mathcal{G}} (\cdot | X) - P_i (\cdot | X) \|_1 \leq \lambda, \qquad \forall P_i \in \mathcal{M}_i \in \mathbb{U}.
\end{equation*}
\end{assumption}
Notably, the parameter $\lambda$ controls the amount of the transition dynamics that is due to the universal causal relations $\mathcal{G}$ ($\lambda = 0$ means that $P_\mathcal{G}$ is sufficient to explain the transition dynamics of any $\mathcal{M}_i \in \mathbb{U}$, whereas $\lambda = 1$ implies no shared structure between the transition dynamics of the $\mathcal{M}_i \in \mathbb{U}$). In this paper, we argue that learning the causal transition model $P_\mathcal{G}$ is a good target for systematic generalization and we provide theoretical support for this claim in Section~\ref{sec:complexity}.
\begin{figure}
\vskip -0.03in
\centering
\includegraphics[width=0.8\linewidth]{contents/figures/bayesian_network.pdf}
\vskip -0.075in
\caption{Illustration of the causal transition model $P_\mathcal{G}$.}
\label{fig:bayesian_network}
\end{figure}
\subsection{A Class of Training Environments}
Even if the universe $\mathbb{U}$ admits the structure that we presented in the last section, it is still an infinite set. Instead, the agent can only interact with a finite subset of discrete MDPs
\begin{equation*}
\mathbb{M} := \{ \mathcal{M}_i = ((\mathcal{S}, d_S, n), (\mathcal{A}, d_A, n), P_i, \mu)\}_{i = 1}^M \subset \mathbb{U},
\end{equation*}
which we call a \emph{class} of size $M$. Crucially, the causal structure $\mathcal{G}$ is a property of the full set $\mathbb{U}$, and if we aim to infer it from interactions with a finite class $\mathbb{M}$, we have to assume that $\mathbb{M}$ is informative enough on the universal causal relations of $\mathbb{U}$.
\begin{assumption}[Diversity]
\label{ass:diversity}
Let $\mathbb{M} \subset \mathbb{U}$ be class of size $M$. We say that $\mathbb{M}$ is {\em causally diverse} if
$\mathcal{G} = \cap_{i = 1}^{M} \mathcal{G}_i = \cap_{i = 1}^{\infty} \mathcal{G}_i.$\footnote{Without losing generality, we assume that the indices $i \in [M]$ refers to the $\mathcal{M}_i \in \mathbb{M}$, and $i \in (M, \infty)$ to the $\mathcal{M}_i \in \mathbb{U} \setminus \mathbb{M}$.}
\end{assumption}
Analogously, if we aim to infer the causal transition model $P_\mathcal{G}$ from interactions with the transition models $P_i$ of the single MDPs $\mathcal{M}_i \in \mathbb{M}$, we have to assume that $\mathbb{M}$ is balanced in terms of the conditional probabilities displayed by its components, so that the factors that do not represent universal causal relations even out while learning.
\begin{assumption}[Evenness]
\label{ass:evenness}
Let $\mathbb{M} \subset \mathbb{U}$ be class of size $M$. We say that $\mathbb{M}$ is {\em causally even} if
\begin{equation*}
\EV_{i \sim \mathcal{U}_{[M]}} \big[ F_i (Y[j] | X) \big] = 1, \quad \forall j \in [d_S].
\end{equation*}
\end{assumption}
Whereas in this paper we assume that $\mathbb{M}$ is \emph{diverse} and \emph{even} by design, we leave as future work the interesting problem of selecting such a class from active interactions with $\mathbb{U}$, which would add to our problem formulation flavors of active learning and experimental design~\cite{2014buhlmann, KocaogluExp2017, ghassami2018budgeted}.
\subsection{Learning Systematic Generalization}
\label{sec:causal_perspective}
Before addressing the sample complexity of systematic generalization, it is worth considering the kind of interactions that we need in order to learn the causal transition model $P_\mathcal{G}$ and its underlying causal structure $\mathcal{G}$. Especially, thanks to the peculiar configuration of the causal structure $\mathcal{G}$, \ie a bipartite graph in which the edges are necessarily directed from the state-action features $X$ to the next state features $Y$, as a causation can only happen from the past to the future, learning the skeleton of $\mathcal{G}$ is equivalent to learning its full structure. Crucially, learning the skeleton of a causal graph does not need specific interventions, as it can be done from observational data alone~\cite{2014buhlmann}.
\begin{restatable}[]{proposition}{observationalDataSufficiency}
\label{thr:observational_data_sufficiency}
The causal structure $\mathcal{G}$ of $\;\mathbb{U}$ can be identified from purely observational data.
\end{restatable}
In this paper, we will consider the online learning setting with a \emph{generative model} for estimating $\mathcal{G}$ and $P_\mathcal{G}$ from sampled interactions with a class $\mathbb{M}$ of size $M$. A generative model allows the agent to set the state of an MDP before sampling a transition, instead of drawing sequential interactions from the process.
Finally, analogous results to what we obtain here can apply to the offline setting as well, in addition to convenient coverage assumptions on the dataset.
\subsection{Graphs}
We define a graph $\mathcal{G}$ as a pair $\mathcal{G} := (\mathcal{V}, E)$, where $\mathcal{V}$ is a set of nodes and $E \subseteq N\times N$
is a set of edges between them. We call $\mathcal{G}$ a \emph{directed graph} if all of its edges $E$ are directed (i.e., ordered pairs of nodes). We also define the in-degree of a node to be its number of incoming edges: $\mathrm{degree_{in}}(A)=|\{(B, A) : (B, A) \in E, \forall B\}|$. $\mathcal{G}$ is said to be a \emph{Directed Acyclic Graph} (DAG) if it is a directed graph without cycles. We call $\mathcal{G}$ a \emph{bipartite graph} if there exists a partition $X \cup Y = \mathcal{V}$ such that none of the nodes in $X$ and $Y$ are connected by an edge, \ie $E \cap (X \times X) = E \cap (Y \times Y) = \emptyset$. For any subset of nodes $S \subset \mathcal{V}$, we define the \emph{subgraph} induced by $S$ as $\mathcal{G} [S] := (S, E[S])$, in which $E[S] = E \cap (S \times S)$.
The \emph{skeleton} of a graph $\mathcal{G}$ is the undirected graph that is obtained from $\mathcal{G}$ by replacing all the directed edges in $E$ with undirected ones.
Finally, the \emph{graph edit distance} between two graphs is the minimum number of graph edits (addition or deletion of either a node or an edge) necessary to transform one graph into the other.
\subsection{Causal Graphs and Bayesian Networks}
For a set $\mathcal{X}$ of random variables, we represent the causal structure over $\mathcal{X}$ with a DAG $\mathcal{G}_{\mathcal{X}} = (\mathcal{X}, E)$,\footnote{We will omit the subscript $\mathcal{X}$ whenever clear from the context.} which we call the \emph{causal graph} of $\mathcal{X}$.
For each pair of variables $A, B \in \mathcal{X}$, a directed edge $(A, B) \in \mathcal{G}_{\mathcal{X}}$ denotes that $B$ is conditionally dependent on $A$.
For every variable $A \in \mathcal{X}$, we denote as $\Pa(A)$ the \emph{causal parents} of $A$, \ie the set of all the variables $B \in \mathcal{X}$ on which $A$ is conditionally dependent, $(B, A) \in \mathcal{G}_\mathcal{X}$.
A Bayesian network~\cite{dean1989model} over the set $\mathcal{X}$ is defined as $\mathcal{N} := (\mathcal{G}_{\mathcal{X}}, P)$, where $\mathcal{G}_\mathcal{X}$ specifies the \emph{structure} of the network, \ie the dependencies between the variables in $\mathcal{X}$, and the distribution $P : \mathcal{X} \to \Delta_{\mathcal{X}}$ specifies the conditional probabilities of the variables in $\mathcal{X}$, such that
\begin{equation*}
P(\mathcal{X}) = \prod_{X_i \in \mathcal{X}} P_i (X_i | \Pa (X_i) ).
\end{equation*}
\subsection{Markov Decision Processes}
A \emph{tabular} episodic Markov Decision Process (MDP)~\cite{puterman2014markov} is defined as $\mathcal{M} := (\mathcal{S}, \mathcal{A}, P, H, r)$, where $\mathcal{S}$ is a set of $|\mathcal{S}| = S$ states, $\mathcal{A}$ is a set of $|\mathcal{A}| = A$ actions, $P$ is a transition model such that $P(s'|s, a)$ gives the conditional probability distribution of the next state $s'$ having taken action $a$ in state $s$, $H$ is the horizon of an episode, and $r : \mathcal{S} \times \mathcal{A} \to [0, 1]$ is a deterministic reward function.
The strategy of an agent interacting with $\mathcal{M}$ is represented by a non-stationary, stochastic \emph{policy}, a collection of functions $(\pi_h : \mathcal{S} \to \Delta_{\mathcal{A}})_{h \in [H]}$ where $\pi_h (a|s)$ denotes the conditional probability of taking action $a$ in state $s$ at step $h$. The \emph{value function} $V^\pi_h : \mathcal{S} \to \mathbb{R}$ associated to $\pi$ is defined as the expected sum of the rewards that will be collected, under the policy $\pi$, starting from $s$ at step $h$, \ie
\begin{equation*}
V^\pi_h (s) := \EV_{\pi} \bigg[ \sum_{h' = h}^H r (s_{h'}, a_{h'}) \ \Big| \ s_{h} = s \bigg].
\end{equation*}
For later convenience, we further define $P V^\pi_{h + 1} (s, a) := \EV_{s' \sim P(\cdot | s, a)} [ V_{h + 1}^{\pi} (s')]$ and $V_1^\pi := \EV_{s \sim P} [ V^\pi_1 (s)]$. We will write $V^\pi_{\mathcal{M}, r}$ to denote $V^\pi_1$ in the MDP $\mathcal{M}$ with reward function $r$ (if not obvious from the context).
For an MDP $\mathcal{M}$ with finite states, actions, and horizon, there always exists an \emph{optimal policy} $\pi^*$ that gives the value $V^*_h (s) = \sup_{\pi} V^\pi_h (s)$ for every $s, a, h$. The goal of the agent is to find a policy $\pi$ that is $\epsilon$-close to the optimal one, \ie $ V^*_1 - V^\pi_1 \leq \epsilon.$
Finally, we define a \emph{discrete} Markov decision process as $\mathcal{M} := ((\mathcal{S}, d_S, n), (\mathcal{A}, d_A, n), P, H, r)$, where $\mathcal{S}, \mathcal{A}, P, H, r$ are specified as before, and where the states and actions spaces admit additional structure, such that every $s \in \mathcal{S}$ can be represented through a $d_S$-dimensional vector of discrete features taking value in $[n]$, and every $a \in \mathcal{A}$ can be represented through a $d_A$-dimensional vector of discrete features taking value in $[n]$. Note that any tabular MDP can be formulated under this alternative formalism by taking $n = 2$, $d_S = S$, and $d_A = A$, so that the states and actions are specified through one-hot encoding.
\section{Introduction}
\input{contents/sections/introduction}
\section{Preliminaries}
\label{sec:preliminaries}
\input{contents/sections/preliminaries}
\section{Problem Formulation}
\label{sec:problem}
\input{contents/sections/problem}
\section{Sample Complexity Analysis}
\label{sec:complexity}
\input{contents/sections/complexity}
\section{Numerical Validation}
\label{sec:experiments}
\input{contents/sections/experiments}
\section{Related Work}
\label{sec:related_work}
\input{contents/sections/related_work}
\section{Conclusion}
\label{sec:conclusion}
\input{contents/sections/conclusion}
|
{'timestamp': '2022-02-15T02:38:34', 'yymm': '2202', 'arxiv_id': '2202.06545', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06545'}
|
arxiv
|
\section{Introduction}
Online services have surged into popularity in recent years and serve millions of customers on a 24/7 basis, such as Google Search, Bing, Facebook and Twitter.
Although enormous amounts of effort have been resorted to maintain the reliability and availability of these services, in practice, various hardware or software failures are still inevitable, leading to unplanned interruptions of the services.
Once a failure bursts, operators and developers tend to inspect console logs that record system events and runtime status, to investigate, mitigate and resolve the failure timely.
However, facing the rapid growth volume of raw log messages, it is becoming more and more challenging to identify the valuable information from the enormous log data, even for those experienced engineers~\cite{onion}.
To tackle this problem, \textit{automated log analysis} has emerged in recent years, aiming to automatically analyze the log data with machine learning (ML) or deep learning (DL) techniques. Typical log analysis scenarios consist of log-based anomaly detection~\cite{xu2009detecting, du2017deeplog, zhang2019robust}, diagnosis~\cite{log3c, onion}, failure prediction~\cite{zhang2018prefix, luo2021ntam}, and performance modeling~\cite{chow2014mystery}. Among them, an important and widely-adopted first step is \textit{log parsing}, which parses the \textit{semi-structured} console logs into a \textit{structured} format. After log parsing, the structurized log data are fed into various ML or DL models (e.g., PCA~\cite{xu2009detecting}, LSTM~\cite{deeplog}) for further analysis.
\begin{figure}[t!]
\centering
\includegraphics[width=1.0\linewidth]{figures/log_example.pdf}
\caption{An example of log parsing after log generation.}
\label{fig:example}
\end{figure}
As shown in Fig.\ref{fig:example}, logs are generated from various logging statements in the source code during the software execution and collected in an interleaving manner. A typical log contains the log header (e.g., time, level) and the log message, which further consists of two elements: 1) \textit{static} descriptive words fixed in source code to represent the system events, namely \textit{log template}. For example, ``\textit{SessionID=<*>, initialized by <*>, version (<*>).}''; 2) \textit{dynamic} variables, which reflect system runtime status that varies with different executions, called \textit{log parameters}.
For instance, ``30546173'', ``OSAgent'', and ``1.0.0'' are parameters generated from three different variables.
The goal of log parsing is to extract the static log template and the dynamic log parameters from a raw log message.
To enable the log parsing, a straightforward way is to match logs with the source code. However, it is not applicable in practice since the method is ad-hoc and label-intensive when dealing with different logging formats. Besides, the source code is often unavailable, especially for those third-party libraries~\cite{tools}. An alternative approach is manually designing regular expressions based on the generated log data, but it suffers from the low scalability and low accuracy problems~\cite{tools}. To overcome these problems, some data-driven log parsers~\cite{drain, logram, logsig, logcluster} have been proposed in recent years. These approaches follow the same basic paradigm: tokens (e.g., ``SessionID='', ``Starting'') that do not vary with the log messages are templates while the opposite ones (e.g., ``592'', ``1612'', ``660'') are log parameters. Specifically, a variety of statistical analysis (e.g., prefix tree~\cite{drain}) and data mining techniques (e.g., frequent pattern mining~\cite{logram} and clustering~\cite{logsig}) are leveraged to extract the common parts from raw log messages.
Although making progresses, existing log parsers are still criticized for the unsatisfactory parsing accuracy, which may cause significant adverse effect on follow-up tasks such as log-based anomaly detection~\cite{he2016evaluation}. We summarize two major problems that lead to erroneous parsing results: 1) Existing log parsers only rely on extracting common parts as templates but ignore the semantic meaning of logs. A typical case is illustrated in Fig.\ref{fig:example}.
Considering the semantic meaning of the log message, the directory address "/etc/data" and the return status "success" should apparently be identified as parameters. Here, "/etc/data" is the default configured data reading directory and "success" represents the normal system behaviour, both of which would not be changed often in log messages. Thus, without considering the semantics, existing log parsers tend to mistakenly treat both parameters as the template. 2) Log contents from different services and systems possess high diversity.
It can often be found that the system events as well as the words used in logs produced by different data sources are very different.
As an example, we found that only about 0.5\% of log tokens are shared among log sources generated by three different OS platforms (Linux, Windows and Mac). Thus, it hinders the generality of log parsing across heterogeneous log data sources.
Facing new log sources, we have to re-accumulate sufficient raw log data as the training materials, adjust hyper-parameters to fit the new log sources, reconfigure the regular expressions for preprocessing, or even build a brand new log parser.
To deal with the above-mentioned problems, in this paper, we point out an important but particular characteristic of log data, i.e, there exist common semantic patterns to indicate templates or parameters regardless of diverse log contents. It is because developers tend to follow the common logging practice for readability.
For instance, developers habitually nest the parameters in a bracket (e.g., "(1.0.0)") or conventionally set the return status (e.g., "success") as a parameter.
In order to capture this kind of patterns prevailing throughout most log data sources, we propose a unified log parser trained across multiple log sources, named UniParser.
It consists of three modules. Token Encoder module and Context Encoder module are responsible for learning the semantic patterns from the log token itself and its neighbouring context.
Context Similarity module forces our model to focus more on the commonalities of the learned patterns.
After training, UniParser can be directly applied to new log data sources.
We have evaluated UniParser on 16 public log datasets~\cite{log_parsing_dataset}.
UniParser outperforms the state-of-the-art parsers by 12\% on Group Accuracy~\cite{tools} and about 40\% on Message-Level Accuracy.
More than that, UniParser also can parse millions of logs in only 2 $\sim$ 3 minutes, which is only about half the running time of the most efficient existing parser.
To summarize, our main contributions are as follows:
\vspace{-6pt}
\begin{itemize}
\item We propose UniParser, a unified log parser that can capture the common patterns of templates or parameters across heterogeneous log sources.
\item We evaluated our proposed UniParser on 16 benchmark log datasets and the results show that UniParser performs much better than all existing approaches. Its efficiency and module effectiveness are also verified through the experiments.
\end{itemize}
\section{Background and Motivation}
\label{sec:background}
\subsection{Log Parsing}
Log parsing has been extensively studied in literature~\cite{tools, drain, IPLoM, logsig}.
In general, the ultimate goal of log parsing is to extract the static log template part and the dynamic log parameter part from a raw log message. Developers write their free-text logs, which are composed of some static descriptive words (log template), and some dynamic variables that will be filled up in the log template during the software running period (log parameters). "2021-09-28 04:31:30 DEBUG" is the log header, which is generally easy to extract because its format is fixed in a specific log source.
The "SessionID=<*>, initialized by <*>, version(<*>)" is the log template and "30546173", "OSAgent" and "1.0.0" are the log parameters filled up into the template placeholder for forming the complete log message.
\subsection{Existing Log Parsers}
\subsubsection{General Idea}
Almost all existing log parsers follow the core idea as below: \textit{extracting common part of raw log messages as log templates and remaining parts are treated as log parameters.}
For example as shown in Fig.\ref{fig:example}, we can first group a series of simliar logs together (shown in brown color) and find that there are some log tokens appear frequently and widely throughout these logs, such as "SessionID", "initialized", "by" in line 1, 2, 4.
These log tokens thus should be identified as the log template part.
On the contrary, other tokens varying in different log messages are regarded as log parameters, such as "OSAgent", "NetAgent" and "PerfCounter".
\subsubsection{Related Work}
\label{ssec:related_work}
In this section, we introduce how existing log parsers implement the above core idea. These parsers can be categorized by the techniques they adopt:
\paragraph{Frequent Pattern Mining}
Intuitively, the common part of logs should emerge frequently in the whole log dataset.
Therefore, frequent pattern mining technologies were applied widely in the log parsing task.
Typical approaches include SLCT~\cite{SLCT}, LFA~\cite{LFA}, LogCluster~\cite{logcluster} and Logram~\cite{logram}.
These methods firstly traverse over the log data and build frequent itemsets based on tokens, token-position pairs or token n-grams. Then, given the frequent itemset, log messages can be grouped into several clusters and log templates can be extracted from the clusters. SLCT is the first work that applies frequent pattern mining to log parsing~\cite{tools}.
LFA further took the token frequency distribution into account.
LogCluster considered the token position during the process of frequent items mining.
Logram aims to extract those frequent 2-gram and 3-gram of log tokens, instead of based on single token.
\paragraph{Clustering}
For capturing the common part of logs, another idea is to cluster the similar logs together and identify the common tokens shared within each cluster as its template.
Compared with frequent pattern mining methods, this kind of approaches enables the common part extraction process on the local cluster of similar logs instead of the global log dataset.
LKE~\cite{LKE}, LogSig~\cite{logsig}, LogMine~\cite{Logmine}, SHISO ~\cite{SHISO}, and LenMa~\cite{LenMa} adopt this technology pathway.
Specifically, LKE and LogMine utilize the hierarchical clustering
algorithm to group similar logs based on weighted edit distances.
Instead of conducting clustering on raw log messages directly, LogSig extracts the signature of logs first, on which the clustering is performed then.
SHISO and LenMa are both online log parsing methods, which means they are capable of processing log messages one by one in a streaming manner, which is more practical in real-world scenarios~\cite{tools}.
Both log parsers use the idea of incremental clustering technology.
\paragraph{Heuristics}
Different from general text data, log messages
have some unique characteristics. As such, some log parsers leveraged them to extract common parts as templates.
AEL~\cite{jiang2008abstracting} separates log messages into multiple groups by comparing the occurrences between constant tokens and variable tokens.
IPLoM~\cite{IPLoM} employs an iterative partitioning strategy, which partitions log messages into groups by message length, token position and mapping relation.
Drain~\cite{drain} borrows the idea from prefix tree.
It builds a fixed-depth tree structure to represent log messages and extracts common templates efficiently.
Spell~\cite{spell} utilizes the longest common subsequence algorithm to parse logs in a stream manner.
\subsection{Limitations of Existing Work}
Although the existing log parsers have achieved good performance in some public datasets, these approaches are still hardly applied in real-world scenarios.
The reason behind lies in their unsatisfying parsing accuracy on complicated real-world log data.
We point out three major problems causing inaccurate parsing results, which could fundamentally challenge the current log parsing paradigm.
\subsubsection{Ignoring semantic meaning of log tokens}
Existing log parsers only consider the static and dynamic properties but neglect the semantic meaning of logs.
As a consequence, it often gives rise to unreasonable misidentification of log parameters and templates.
At first glance in the example shown in Fig.\ref{fig:example}, some log tokens (such as "success" and "/etc/data/") seem to belong to a part of log template because they do not vary in different log messages.
However, if we take their semantic meaning into consideration, these tokens should be classified as parameters.
For example, "from" is always followed by parameters, such as directory address "/etc/data/" in this illustrated case. Therefore, they are likely to be misidentified as a part of log template. To deal with this problem, most offline log parsers (only support batch processing and all log data are required to be available before parsing)~\cite{tools} have to accumulate sufficient large volume of log messages to guarantee the parameters parts exhibit significant dynamic characteristics.
\subsubsection{Barrier among different log sources}
\label{subsec:log_diversity}
Log contents from different systems or services are characterized by their high diversity.
As a real example, we performed statistical analysis on collected syslogs from three commonly-used OS platforms\footnote{\url{https://github.com/logpai/loghub}}, i.e., Windows\footnote{collected from Component Based Servicing (CBS) logs}, Mac and Linux.\footnote{both are collected from /var/log/system.log}
We found that they shared only about 0.5\% of common log tokens.
For example, "session opened for user news by (uid=0)" (from Linux log) and "Session: 30546173\_4261722401 initialized by client WindowsUpdateAgent." (from Windows log) are totally different log events and only one word "session" are shared between the two.
High diversity among various log sources poses an obstacle in log parsers generalization across different systems or services.
Every time when we apply the existing approaches to a new log data source, we have to re-accumulate sufficient raw log data as the training materials, adjust hyper-parameters to adapt to the new log sources, and reconfigure the regular expressions for preprocessing. Especially, for online log parsers (building up a model in advance and process log messages one
by one in a streaming manner~\cite{tools}), we even need to develop a new log parser from scratch.
\subsubsection{Improper evaluation metrics}
Log templates and parameters identification should be treated equally without discrimination.
For example, on the one hand, most log anomaly detection models, such as LogRobust~\cite{zhang2019robust}, group logs by the same predicted log templates and denote them as log events. Then they identify abnormal behaviors based on these log events. On the other hand, some log-based anomaly detection models, such as DeepLog~\cite{deeplog}, pay more attention to the variation of parameters, such as running time or return status code. Unfortunately, most existing work deviates from the original intention of log parsing. Especially, during the evaluation process, the evaluation metrics measure the accuracy of grouping logs but do not explicitly check the extracted templates and parameters. It thus cannot reflect the actual effectiveness of their proposed log parsers.
The details will be discussed in Section~\ref{subsec:metric}.
\subsection{Insights and Opportunities}
The above three problems motivate us to change our mindset for log parsing.
Through the investigation of multiple sources of logs from public log datasets as well as industrial logs, we uncovered an important characteristic of log data, i.e., even though log contents are very diverse in different systems or services, they generally follow certain common logging practice. Developers may print different log contents, but they have some common logging preferences, which can help others read the log messages easily. For the example in Fig.\ref{fig:example}, developers like to nest a parameter in a bracket ("version (1.0.0)") or place it after a equal sign ("SessionID=30546173").
More than that, developers would also conventionally set the status code ("success") or directory path ("/etc/data/") as parameters, rather than fixing them as a part of the template. Actually, there are also many unified and common logging specifications and practices ~\cite{yuan2012characterizing,fu2014developers}, which make logs more informative.
The common logging practice sheds light on the opportunity to capture the common logging behaviours across heterogeneous log sources.
It inspires us that we are able to distinguish the parameters or templates through acquiring conventional logging "syntax".
In order to capture the sharing common logging behaviors across heterogeneous log sources, we need to develop a new log parser, which can learn the common logging practices through understanding the semantic meaning of logs.
After that, the learned model can be applied to parse new sources of log messages.
\section{Approach}
\label{sec:approach}
In this section, we first present the problem formulation in Sec.~\ref{ssec:problem}. We propose a unified log parser based on deep learning technology, named UniParser, to capture the common patterns across heterogeneous log sources indicating parameters or templates.
It contains two major phases, including the offline cross-sources training process and online parsing process, which will be presented in Sec.~\ref{ssec:overview}.
After the overview of UniParser, we will detail the core model architecture design in Sec.~\ref{sec:model_architecture}.
UniParser is composed of three modules, where Token Encoder module and Context Encoder module are utilized for acquiring the semantic patterns from the log token itself and its neighbouring context. Context Similarity module focus more on the commonalities of the learned patterns through contrastive learning. Finally, we will describe the loss function adopted by UniParser in Sec.~\ref{ssec:loss}.
\subsection{Problem Definition}
\label{ssec:problem}
In our proposed model, we transform the log parsing task into the log token classification problem.
Specifically, suppose a raw log message $L$ consists of $n$ tokens after word splitting, denoted as $[t_1, t_2, ... t_n]$. Our proposed log parser is required to predict whether each log token $t_i$ belongs to template part ($y_i=0$) or parameter part ($y_i=1$) based on the learned common logging patterns. All tokens with $y_i=0$ are included in log template and other tokens with $y_i=1$ are put into the parameters list.
\subsection{Overview}
\label{ssec:overview}
In this section, we briefly introduce the overall workflow of UniParser.
As illustrated in Fig.\ref{fig:overview}, there are two phases for the proposed UniParser model, i.e., offline cross-sources training phase and online parsing phase on the target log source.
During the training phase, we take labeled log data from multiple sources as a training dataset, which is fed into the UniParser model for training. We expect our model to learn the underlying common patterns indicating templates or parameters instead of the individual and specific log contents.
To achieve this target, we take multiple log sources as the training set and propose a tailored deep learning model, whose architecture and training details will be depicted in Sec.~\ref{sec:model_architecture} and Sec.~\ref{ssec:loss}.
After training across heterogeneous log sources, we can apply our trained model \textit{directly} to the target log source for parsing.
It will parallelly predict the class (template or parameter) of each log token and then integrate them as log template or parameter list, respectively.
It is worth noting that the training log sources and the testing log sources can be completely mutually exclusive.
Owing to the specially designed deep learning model architecture for capturing the common semantic patterns, UniParser makes generalizing the knowledge learned from other log sources to unknown new log sources possible.
It implies our proposed UniParser does not require any labels in the target log sources to be parsed.
\begin{figure}[ht!]
\centering
\includegraphics[width=1.0\linewidth]{figures/overview.pdf}
\caption{An overview of UniParser (red text denotes the parameter part while black text denotes the template part)}
\label{fig:overview}
\end{figure}
\begin{figure*}[htbp]
\centering
\includegraphics[width=0.9\textwidth]{figures/model.pdf}
\caption{The model architecture of UniParser, where the Context Similarity module (left gray part) is used in the offline training phase only. P denotes log parameter token and T denotes log template token.}
\label{fig:architecture}
\end{figure*}
\subsection{Model Architecture}
\label{sec:model_architecture}
\label{ssec:architecture}
In this section, we will elaborate on the model architecture of UniParser.
As shown in Fig.~\ref{fig:architecture}, UniParser consists of three components: Token Encoder module, Context Encoder module and Context Similarity module.
We will delve into the technical details of all modules in the following subsections.
\subsubsection{Token Encoder module}
\label{ssec:token_encoder}
Given a raw log message, we first conduct word splitting with spaces, tabs, special characters (like equal sign or comma), and so on.
After that, Token Encoder module encodes each split log token into a high-dimensional embedding vector as the model input.
However, diverse and dynamic log words pose a barrier in embedding matrix construction at the token-level.
The endless unseen log tokens would incur the out-of-vocabulary (OOV) problem.
Developers are permitted to create an infinite variety of variable names, abbreviations or special technical terms, which are far beyond the scale of common English words and will explode the vocabulary.
In addition, some parameters composed of digits (e.g.,"30546173") or some special symbols (e.g.," /etc/data/") are hard to embed as well because they are constantly changing.
To deal with this problem, we alternatively utilize the char-level embedding~\cite{charembedding} to encode log tokens.
The granularity of the character-level is finer than that of the token-level.
The most commonly-used characters, such as lowercase letters, uppercase letters, digits, punctuation and so on (96 characters we used in total), are sufficient to cover the most of tokens formed by their combinations.
Instead of maintaining a vocabulary of enormous size at the token-level, we build up an embedding layer to encode each character.
Then we sum up all char-level embedding vectors together within in a log token as its encoding vector.
In this way, we can avoid OOV problem and also control the size of the embedding matrix at the appropriate scale.
\subsubsection{Context Encoder module}
\label{ssec:context encoder}
The category (\textit{template or parameter}) of a target log token is not only related to itself but also its neighboring tokens, i.e, \textit{context}.
On the one hand, parameters tend to emerge conjointly with some special characters or symbols.
For the example shown in Fig.\ref{fig:example}, "30546173" is on the heels of an equal sign "=" or "1.0.0" is embraced by a bracket ("(1.0.0)").
On the other hand, the semantics of context is also conducive to indicating the parameters or templates.
A more complicated case is illustrated in line 3 of Fig.\ref{fig:example}.
If we are not so confident in determining the class of log token "/etc/data/" only depending on itself, its context "from" is conducive to classifying it as a parameter because "from" is likely to be followed by a parameter (such as directory address) considering its semantic meaning.
Motivated by the above idea, we utilize Context Encoder module to encode context information.
Intuitively, not every log token within a log message should be treated as the context of the target log token.
It is because that those log tokens far from the target one tend to be useless for classification.
For example, in line 1 of Fig.\ref{fig:example}, the top token "SessionID" has little relevance to the tail token "(1.0.0)".
Taking that into account, we regard the range from left $k$ to right $k$ tokens around the target token as its context.
In general, $k=3$.
We reuse Token Encoder module to transform each context token into an embedding vector and obtain a sequence of context vectors.
It is noted that the target token is \textit{masked} during this process.
The purpose of this operation is that Context Encoder module is expected to independently capture the patterns reflected by context tokens without the aid of the target log token itself.
Otherwise, our model might be biased to the target log token heavily and could not learn the patterns from the context.
The sequence of context vectors is fed into a bidirectional LSTM network to capture the order information.
The hidden states $h_i$ at all time steps of LSTM are aggregated as the final encoding vector of the context.
\subsubsection{Context Similarity module}
Ideally, the embedding vectors produced by Context Encoder module should be close if their corresponding log contexts contain similar patterns.
Nevertheless, the common patterns tend to be manifested with diverse log contents.
Char-level embedding is content-aware and would lead to dispersive encoding vectors since the characters in context might be various.
For the instance in Fig.\ref{fig:example}, when we target to predict the class of token "initialized", its context "by OSAgent" in line 1 and "by perfCounter" in line 2 are very different.
Their encoding vectors may also vary a lot, which is not conducive to making our model capture common patterns in logs.
To overcome this problem, we are required to map the log context under the similar patterns to a tighter vector space, mitigating the effect of the content diversity. We assume that similar log messages are supposed to possess the similar patterns. Thus, we can guide Context Encoder module through the contrast learning between the similar or dissimilar log messages.
To obtain similar log messages, we first cluster the training log data from heterogeneous log sources into several groups.
The log messages in each group are identical in token length, as well as on the first token.
Log messages in the same group are considered to be similar to each other, while those in different groups are not. After clustering we utilize contrastive learning~\cite{contrastive2021survey} to assist the training of Context Encoder module. For each log message, we randomly select one similar log messages and $|V_d|$ dissimilar ones. The distance between two encoding vectors from similar contexts should be closer. While for the dissimilar ones, their distances should be far apart. This module is optimized towards the above target by constrastive loss~\cite{contrastive2021survey}, which will be introduced in Sec. \ref{ssec:loss}. One interesting point to notice is that the Context Similarity module only serves as an auxiliary module during the training phase and will be disabled when parsing logs online.
Therefore, Context Similarity module only brings extra time cost during training, while does not slow down the speed of inference.
\subsection{Loss Function}
\label{ssec:loss}
The loss function of our model consists of two parts: token-level classification loss and context-level contrastive loss.
\paragraph{Token-level classification loss} Collecting the encoding vectors generated from Token Encoder module and Context Encoder module, we concatenate both of them and add the classification layer on top of it to make predictions.
The token-level classification loss can be formulated as:
\begin{equation}
Loss_{cls} = - \frac{1}{N}(\sum_{i=1}^N[y_i \cdot \log(\hat{y_i}) + (1 - y_i) \cdot (1 - log(\hat{y_i}))])
\end{equation}
As mentioned in Sec.~\ref{ssec:problem}, $y_i$ refers to the label of the target token, and $\hat{y_i}$ is the predicted probability of the token being a parameter. $N$ denotes the total number of tokens.
\paragraph{Context-level contrastive loss}
The contrastive loss can be formulated as:
\begin{equation}
Loss_{contrast} = -log\frac{exp(v \cdot v_s)}{ \sum_{v_d \in V_d} exp(v \cdot v_d)}
\end{equation}
where $v$ represents encoding vector for target log context produced by the Context Encoder module, $v_s$ denotes the similar log vector and $v_d$ denotes log vector from the dissimilar set $V_d$, respectively. For each $v$, we randomly select one similar log messages and $|V_d|$ dissimilar log messages ($|V_d|=3$ by default).
Thanks to the context-level contrastive loss function, UniParser is forced to compress the context encoding vectors from simliar logs much closer than those of dissimilar log messages.
The total loss is the weighted sum of the two losses, which can be formulated as:
\begin{equation}
Loss = Loss_{cls} + \lambda \cdot Loss_{contrast}
\label{loss}
\end{equation}
where $\lambda$ is set to 0.01 as default for balancing the magnitude of both loss functions.
\section{Experiment}
\label{sec:experiment}
In order to evaluate the effectiveness and efficiency of UniParser, we conduct extensive experiments.
In this section, we first describe the experiment settings.
Then, we introduce two evaluation metrics, including group accuracy proposed in \cite{tools}, and another metric proposed in this paper that is better aligned with the real goal of log parsing.
The experiment results of parsing accuracy are presented in Sec.\ref{subsec:sota_comparison}, followed by performance comparison and the component evaluation results.
\subsection{Experimental Settings}
\subsubsection{Datasets}
We conduct experiments based on datasets collected from \textit{LogPai} benchmark \cite{log_parsing_dataset}, which consists of various logs from 16 different systems spanning distributed
systems, supercomputers, operating systems, mobile systems,
server applications, and standalone software.
Each log message is labeled with a log template as ground truth.
In our method, we need to split log messages into tokens and separately predict classes of them.
Therefore, we transformed the message-level labels into token-level labels.
Due to some labeling errors in the original version, we also calibrated some labels during the transformation process.
\subsubsection{Implementation Details}
We conduct experiments on a GPU Server equipped with NVIDIA Tesla P100 GPU and CUDA 10.2.
The code is implemented based on PyTorch 1.4.
During the training process, we utilize Adam optimizer and set the initial learning rate as 0.002. We set the batch size as 256 and train the model for 4 epochs.
During the online parsing phase, we set batch size to 512.
In Context Encoder module, we set $k=3$. In Context Similarity module, we set $|V_d|=3$.
\subsection{Evaluation Metrics}
\label{subsec:metric}
\textbf{Group Accuracy:} Group Accuracy is proposed in \cite{tools} and has been widely used for evaluating log parsers.
Group Accuracy measures the alignment degree between a set of log messages grouped by identified templates (generated by log parsers) and the corresponding set of log messages belonging to the same true log template.
However, Group Accuracy prefers properly grouping logs under the same templates together, while the log templates and parameters may not be correctly identified.
For example, the log messages in Fig.\ref{fig:example} are grouped completely correctly by existing log parsers, which indicates the group accuracy is 100$\%$.
However, "/etc/data/" and "success" are misidentified as a part of the template due to their invariance in logs. Therefore, Group Accuracy can not directly reflect whether messages are correctly parsed by log parsers .
\begin{figure}[ht!]
\centering
\includegraphics[width=1.0\linewidth]{figures/metrics.pdf}
\caption{Existing log parsers misidentify parameters ("etc/data/" and "success") but group logs under the same template correctly}
\label{fig:weak}
\end{figure}
\textbf{Message-Level Accuracy (MLA):} we propose Message-Level Accuracy to overcome the shortcomings of Group Accuracy, where a log message is considered correctly parsed if and only if every token of the message is correctly identified as template or parameter.
Obviously, this metric is much stricter than Group Accuracy since any incorrect log token identification will lead to the wrong parsing result for the whole log message.
For example, MLA in Fig.\ref{fig:weak} is $\frac{3}{6}$ since only logs in left group (3 log messages) are parsed completely correctly.
\subsection{Parsing Accuracy Evaluation}
\label{subsec:sota_comparison}
We compare our proposed model with four state-of-the-art methods (including Drain~\cite{drain}, AEL~\cite{jiang2008abstracting}, LenMa~\cite{LenMa}, and LFA~\cite{LFA}) on all 16 log datasets. These log parsers cover most types of parsing techniques (see Sec.\ref{ssec:related_work}) and achieve good results on public datasets.
For each dataset to be tested, we conduct cross-source training based on the other 15 datasets and applied the trained model to the target dataset.
Since Group Accuracy measures the overlap between logs sets under the ground truth templates and the predicted templates given by parsers, we thus needed to group logs under the similar predicted log templates together for evaluation.
The results in terms of two metrics (Group Accuracy, Message-Level Accuracy) are shown in Table \ref{table:group} and Table \ref{table:template}, respectively.
From the results, we can see that our model outperforms these existing methods on almost all datasets with respect to the two metrics.
Specifically, compared with the powerful existing log parser Drain~\cite{drain}, UniParser exceeds it by 11.9\% on group accuracy and 40.8\% on MLA on average.
In addition, we also note that traditional log parsers such as Drain achieves high group accuracy (0.867) but a very low MLA (0.377).
It confirms that existing methods focus more on grouping logs under the same template, but ignore the identification of templates and parameters. Different from the related work, UniParser is capable of learning semantic patterns and predicting the categories token by token.
Therefore, it achieves a higher score on MLA (0.785), demonstrating the effectiveness of our method.
One notable issue is that UniParser does not outperform existing methods on Proxifier dataset.
After investigation, we found that there exists a large gap between Proxifier and other datasets, which decreases the performance of UniParser.
We will discuss this problem in Sec.\ref{sec:discussion} and show how to improve the accuracy of UniParser via a small amount labeled data for fine-tuning.
\begin{table}[ht!]
\centering
\caption{Comparison with the state-of-the-art log parsers on Group Accuracy}
\label{table:group}
\begin{tabular}{c|ccccc}
\toprule
Method & Drain & AEL & LenMa & LFA & UniParser \\
\midrule
HDFS &0.998 & 0.998 & 0.998 & 0.885 & \textbf{1.000} \\
Hadoop &0.948 & 0.538 & 0.885 & 0.900 & \textbf{1.000}\\
Spark &0.920 & 0.905 & 0.884 & 0.994 & \textbf{1.000}\\
ZooKeeper &0.967 & 0.921 & 0.841 & 0.839 & \textbf{0.995}\\
OpenStack &0.733 & 0.758 & 0.743 & 0.200 & \textbf{1.000}\\
BGL &0.963 & 0.758 & 0.690 & 0.854 &\textbf{ 0.997}\\
HPC &0.887 & 0.903 & 0.830 & 0.817& \textbf{0.966}\\
Thunderbird &0.955 & 0.941 & 0.943 & 0.649 & \textbf{0.990}\\
Windows &0.997 & 0.690 & 0.566 & 0.588 & \textbf{1.000}\\
Linux &0.690 & 0.673 & 0.701 & 0.279 & \textbf{0.878}\\
Mac &0.787 & 0.764 & 0.698 & 0.599 & \textbf{0.997}\\
Android &0.911 & 0.712 & 0.880 & 0.616 & \textbf{0.973}\\
HealthApp &0.780 & 0.822 & 0.174 & 0.549 &\textbf{1.000}\\
Apache &1.000 & 1.000 & 1.000& 1.000 & \textbf{1.000}\\
OpenSSH &0.788 & 0.538 & 0.925 & 0.501 & \textbf{1.000}\\
Proxifier &0.527 & 0.518 & 0.508 & 0.0026 & \textbf{0.976}\\ \midrule
Average & 0.867 & 0.777 & 0.767 & 0.642 & \textbf{0.986} \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}[ht!]
\centering
\caption{Comparison with the state-of-the-art log parsers on MLA}
\label{table:template}
\begin{tabular}{c|ccccc}
\toprule
Method & Drain & AEL & LenMa & LFA & UniParser \\
\midrule
HDFS &0.567 & 0.568 & 0.123 & 0.156 & \textbf{1.000} \\
Hadoop &0.530 & 0.526 & 0.079 & 0.499 & \textbf{0.866}\\
Spark &0.384 & 0.373 & 0.006 & 0.382 & \textbf{0.972}\\
ZooKeeper &0.792 & 0.748 & 0.677 & 0.340 & \textbf{0.99}\textbf{2}\\
OpenStack &0.019 & 0.021 & 0.018 & 0.008 & \textbf{0.459}\\
BGL &0.341 & 0.341 & 0.082 & 0.230 & \textbf{0.811}\\
HPC &0.701 & 0.725 & 0.632 & 0.674& \textbf{0.974}\\
Thunderbird &0.059 & 0.048 & 0.038 & 0.026 & \textbf{0.542}\\
Windows &0.158 & 0.153 & 0.152 & 0.142 & \textbf{0.691}\\
Linux &0.169 & 0.164 & 0.107 & 0.023 & \textbf{0.854}\\
Mac &0.176 & 0.148 & 0.094 & 0.082 & \textbf{0.584}\\
Android &0.431 & 0.350 & 0.430 & 0.299 & \textbf{0.838}\\
HealthApp &0.295 & 0.295 & 0.174 & 0.285 &\textbf{ 0.985}\\
Apache &0.694 & 0.690 & 0.634 & 0.688 & \textbf{0.994}\\
OpenSSH &0.507 & 0.247 & 0.133 & 0.164 & \textbf{0.626}\\
Proxifier &0.203 & 0.195 & 0.017 & \textbf{0.478} & 0.369\\ \midrule
Average & 0.377 & 0.350 & 0.212 & 0.280 & \textbf{0.785} \\
\bottomrule
\end{tabular}
\end{table}
\begin{figure*}[t]
\centering
\begin{minipage}[t]{.30\textwidth}
\includegraphics[width=\linewidth]{figures/running_time.pdf}
\caption{Running time of different log parsers under different volume.}
\label{fig:performance}
\end{minipage}\qquad
\begin{minipage}[t]{.30\textwidth}
\includegraphics[width=\linewidth]{figures/ablation_study.pdf}
\caption{Ablation study results.}
\label{fig:ablation_study}
\end{minipage}\qquad
\begin{minipage}[t]{.30\textwidth}
\includegraphics[width=\linewidth]{figures/sample_size_test.pdf}
\caption{Parameter exploration of Context Encoder module}
\label{fig:params_test}
\end{minipage}
\vspace{-6pt}
\end{figure*}
\subsection{Runtime Performance Evaluation}
Besides parsing accuracy, performance is another critical metric for log parsers.
Therefore, we also need to compare the running time of UniParser with other log parsers under different volumes of log data.
It is worth noting that we also include the time cost of loading data for our proposed UniParser.
The results are shown in Fig.\ref{fig:performance} (X and Y axis both are in log-scale).
From the results, we can see the running time of UniParser increases slowly with the log scale expansion.
Moreover, with the parallel prediction of log tokens based on GPU acceleration, our model performs faster than other traditional parsers.
Even at the scale of one million log messages, UniParser took about 140 seconds, which is only about half of the time spent by AEL (214s) and around a quarter of the time spent by Drain (482s).
\subsection{Component Evaluation}
In this section, we evaluate the effectiveness of the major components and parameters.
The experiments are performed based on Android log dataset as it is enriched with hundreds of log templates and complicated patterns, which is representative among 16 log datasets. As mentioned in Sec.\ref{subsec:metric}, Group Accuracy can not properly measure the performance of log parsers, we only focus on MLA metric in this section.
\subsubsection{Ablation Study}
\label{ssec:ablation}
Firstly, we explore the effectiveness of each component on our model, and the results are shown in Fig.\ref{fig:ablation_study}.
UniParser exhibits worse accuracy with only Token Encoder module (0.352 MLA), while achieves a rapid boosting with Context Encoder module (0.587 MLA) added.
This comparison indicates that Context Encoder module learns common patterns from context, which facilities the target token classification.
In addition, Context Similarity module significantly improves the accuracy of UniParser (0.838 MLA), which demonstrates its usefulness for making Context Encoder module encodes feature vector more precisely.
\subsubsection{Parameter Analysis}
As shown in Fig.\ref{fig:params_test}, we explored the effect of $k$ in Context Encoder module, which denotes the number of tokens around the target token (as mentioned in Sec.\ref{ssec:context encoder}).
We adjusted the value of $k$ from 1 to 5 and observe the changes in MLA.
From the results, we found that MLA is relatively stable in the whole range (from 0.78 $\sim$ 0.84). It increases gradually when $k$ in [1, 3] but drops if $k$ continues increasing. This implies that context tokens indeed help to capture semantic patterns. On the contrary, tokens far away from target token may not provide effective context information, and could bring noise to the model and decrease the accuracy of UniParser.
\subsubsection{Comparison with sequence labeling model}
In addition, we compared our model with Bidirectional LSTM-CNNs-CRF \cite{ma2016end}, a commonly-used sequence labeling model which can be utilized to classify log tokens as well.
Bi-LSTM-CNNs-CRF first utilizes CNN to encode each word into a vector representation, then word-level representations are fed into Bi-LSTM to obtain context information. Lastly, on top of Bi-LSTM, a sequential CRF jointly decode labels for the whole sentence. On the one hand, the results in Table~\ref{table:crf} indicate that deep learning based log parsers benefit from the supervised labels on token-level and indeed perform better than previous unsupervised methods (both models outperform other existing log parsers such as Drain on Android dataset);
On the other hand, our UniParser outperforms Bidirectional LSTM-CNNs-CRF,
which demonstrates the effectiveness of our proposed model.
\begin{table}[H]
\centering
\caption{Comparison with Bi-LSTM-CRF}
\label{table:crf}
\begin{tabular}{c|ccc}
\toprule
Method & Drain & Bi-LSTM-CNNs-CRF & UniParser\\
\midrule
MLA & 0.431 & 0.555 &\textbf{0.838} \\
\bottomrule
\end{tabular}
\end{table}
\section{Discussion}
\label{sec:discussion}
\paragraph{Model Fine-tuning:}
Patterns may differ between the training and the target log sources. To tackle this problem, we devise an online feedback mechanism to fine-tune the UniParser model under the target log data.
Engineers only need to inspect a few lines of parsed structured logs and calibrate the results (templates or parameters) according to their domain knowledge.
Then these labeled logs are fed into UniParser to make the model fast adapt to the new log sources.
We applied fine-tuning to our model on Proxifier dataset, where UniParser performs worst. The result is listed in Table~\ref{tab:fine_tune}.
It can be seen that after fine-tuning with tens of labeled logs, the UniParser model can achieve a rapid boosting of parsing accuracy.
\begin{table}[ht!]
\centering
\caption{Model fine tuning with different numbers of labeled logs}
\label{tab:fine_tune}
\begin{tabular}{c|ccc}
\toprule
\#Samples & 0 & 20 & 40 \\
\midrule
MLA & 0.369 & 0.507& 0.893 \\
\bottomrule
\end{tabular}
\end{table}
\paragraph{Labeling Effort}
Our proposed method relies on the labeled log data, which means some labeling effort is required for training.
The labeled log datasets are used in the offline supervised learning and can be labeled once for all.
From the experiment results shown in Sec.\ref{subsec:sota_comparison}, our model is capable of learning the common logging patterns from heterogeneous log sources, and can be applied to most of the new log sources directly without extra labeling effort.
Even for the logs with distinctive patterns such as those in the Proxifier dataset, a small amount of fine-tuning is sufficient.
\paragraph{Token Splitting}
As introduced in Sec.\ref{ssec:problem}, UniParser transforms the log parsing task into the log token classification problem.
We split tokens in raw log messages according to some special symbols such as spaces, tabs and comma (see Sec.\ref{ssec:token_encoder}).
Nevertheless, some log tokens are difficult to be split up due to the complexity of the log messages.
For example, in log message "Process A done this 1 time(s)", "(s)" in the bracket should not be separated from the preceding token "time" and is not a parameter.
In our future work, we will design effective mechanisms to handle rare cases like this.
\section{Application in Practice}
So far, our proposed UniParser has already successfully applied to multiple log analysis scenarios in Microsoft 365 and Azure Cloud, including safe deployment guarding, performance issue diagnosis, log-based anomaly detection and so on.
Compared with the existing log parsers, UniParser achieves much higher parsing accuracy and exhibits more robustness on complicated industrial log data, which greatly improves the performance of various log-based downstream tasks.
\section{Conclusion}
\label{sec:conclusion}
Log parsing is the foundation of automated log analysis, which is responsible for transforming the semi-structured raw logs into a structured format. In this paper, we propose a novel deep learning based model named UniParser to capture the common logging behaviours from heterogeneous log data.
UniParser utilizes a Token Encoder module and a Context Encoder module to capture the patterns of templates and parameters.
A Context Similarity module is specially designed to focus on the commonalities of learned patterns.
We have evaluated UniParser on public log datasets and the results show that UniParser outperforms the state-of-the-art parsers by 12\% on Group Accuracy and about 40\% on Message-Level Accuracy.
\section{ACKNOWLEDGMENTS}
We would like to thank Murali Chintalapati, Jim Kleewein, Andrew Zhou, Zhangwei Xu, Thomas Moscibroda, Victor Rühle, Chetan Bansal, Lingling Zheng, Marcus Fontoura and Silvia Yu for
their great support and sponsorship.
\balance
\bibliographystyle{ACM-Reference-Format}
|
{'timestamp': '2022-02-15T02:39:23', 'yymm': '2202', 'arxiv_id': '2202.06569', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06569'}
|
arxiv
|
\section*{Acknowledgments}
\section*{ACKNOWLEDGMENT}
We thank the UK Research and Innovation (UKRI), Department of Transport (DfT), Transport for London (TfL) and Go North East.
\bibliographystyle{IEEEtran}
\section{Related Work}
\label{sec:related-work}
Recently, taking advantage of the performance of CNN in detecting objects and people, there has been great interest in developing methods for the detection of social distancing which we review in this section.
For example, YOLO v3 has been used as the object detection architecture for detecting pedestrians in~\cite{kumari2021deep, magoo2021deep, shalini2021social, punn2020monitoring, mercaldo2021proposal, hou2020social}, primarily because it works better in a real-time setting~\cite{punn2020monitoring}. Other versions of YOLO architecture have also been used for object detection, such as YOLO v2~\cite{saponara2021implementing} and YOLO v4~\cite{rahim2021monitoring}. Other work in the literature has focused on comparing different object detection algorithms at detecting pedestrians, for example, the authors in~\cite{yang2021vision} compare Faster R-CNN and YOLO v4, the authors in~\cite{punn2020monitoring} compare Faster R-CNN, Single Shot Detector (SSD) and YOLO v3 and the authors in~\cite{zuo2021reference} used YOLO v3 after comparing to RetinaNet and Mask R-CNN.
In order to measure the distance between people, the authors in~\cite{kumari2021deep, magoo2021deep, yang2021vision} transformed the camera view into a bird's eye view to get the location of the detected person from the top-down perspective. The centroid of the detected person is used to measure the Euclidean distance to any other person in the image. The Euclidean distance is also used in \cite{pooranam2021safety,shalini2021social, mercaldo2021proposal, rahim2021monitoring, su2021novel} as well without any camera transformation for social distance measurement. In \cite{hou2020social}, the position of the detected pedestrian is estimated based on the bottom-centre point of the bounding box, rather than the centroid, before computing the distance between every pedestrian pair. Instead of tracking individual location, the work in \cite{zuo2021reference} measures the pedestrian density in a given image, via the use of a heatmap and temporal density distribution.
The author in~\cite{rezaei2020deepsocial} proposed a model, entitled DeepSOCIAL, based on a modified YOLO v3 to detect, track and estimate the distance between people. They applied the Simple Online and Real-time (SORT) tracking technique that uses Kalman filter and Hungarian optimisation to track and assign a unique ID to each detected people. To then detect the distance between people, they used inverse perspective geometric mapping.
The authors in \cite{varghese2021multimodal} proposed a multimodal Convolutional Variational Autoencoder (CVAE) fusion framework where the input data is from a combination of visual, infrared, audio and accelerometer sensors. The authors argue this multi-modality allows for a greater performance level than offered by considering only visuals.
Most of the work in social distancing measurement has been trained and evaluated on CCTV footage of pedestrians walking for example, from Oxford Town Centre~\cite{yang2021vision, punn2020monitoring, rezaei2020deepsocial} and New York~\cite{zuo2021reference}. Other studies have used data from low light environments\cite{rahim2021monitoring} and three different videos from town centers and beaches~\cite{mercaldo2021proposal}.
While earlier work focuses on CCTV footage that captures people mostly walking in a wide spacious area, in this paper we address the complexity of social distancing measurement on public transportation, especially those due to low-resolution images, non-optimal camera placement and physical limitations.
\begin{figure}[!h]
\centering
\subfloat[V01]{\includegraphics[width=0.25\textwidth]{Figures/RC/RC_V01}%
\label{RC_V01}}
\subfloat[V02]{\includegraphics[width=0.25\textwidth]{Figures/RC/RC_V02}%
\label{RC_V02}}
\hfil
\vskip -5pt
\subfloat[V03]{\includegraphics[width=0.25\textwidth]{Figures/RC/RC_V03}%
\label{RC_V03}}
\subfloat[V04]{\includegraphics[width=0.25\textwidth]{Figures/RC/RC_V04}%
\label{RC_V04}}
\hfil
\subfloat[V05]{\includegraphics[width=0.25\textwidth]{Figures/RC/RC_V05}%
\label{RC_V05}}
\subfloat[V06]{\includegraphics[width=0.25\textwidth]{Figures/RC/RC_V06}%
\label{RC_V06}}
\hfil
\subfloat[V07]{\includegraphics[width=0.25\textwidth]{Figures/RC/RC_V07}%
\label{RC_V07}}
\subfloat[V08]{\includegraphics[width=0.25\textwidth]{Figures/RC/RC_V08}%
\label{RC_V08}}
\hfil
\subfloat[V09]{\includegraphics[width=0.25\textwidth]{Figures/RC/RC_V09}%
\label{RC_V09}}
\subfloat[V10]{\includegraphics[width=0.25\textwidth]{Figures/RC/RC_V10}%
\label{RC_V10}}
\caption{Relative change between the headcount of ground truth and prediction.}
\label{fig:RC}
\end{figure}
\begin{figure*}[!t]
\centering
\subfloat[V01]{\includegraphics[width=0.2\textwidth]{Figures/Headcounts/V01}%
\label{V01}}
\subfloat[V02]{\includegraphics[width=0.2\textwidth]{Figures/Headcounts/V02}%
\label{V02}}
\subfloat[V03]{\includegraphics[width=0.2\textwidth]{Figures/Headcounts/V03}%
\label{V03}}
\hfil
\subfloat[V04]{\includegraphics[width=0.2\textwidth]{Figures/Headcounts/V04}%
\label{V04}}
\subfloat[V05]{\includegraphics[width=0.2\textwidth]{Figures/Headcounts/V05}%
\label{V05}}
\hfil
\subfloat[V06]{\includegraphics[width=0.2\textwidth]{Figures/Headcounts/V06}%
\label{V06}}
\subfloat[V07]{\includegraphics[width=0.2\textwidth]{Figures/Headcounts/V07}%
\label{V07}}
\subfloat[V08]{\includegraphics[width=0.2\textwidth]{Figures/Headcounts/V08}%
\label{V08}}
\subfloat[V09]{\includegraphics[width=0.2\textwidth]{Figures/Headcounts/V09}%
\label{V09}}
\subfloat[V10]{\includegraphics[width=0.2\textwidth]{Figures/Headcounts/V10}%
\label{V10}}
\caption{Passenger detection via Mask R-CNN}
\label{fig:Headcount_example}
\end{figure*}
\section{Dataset}
\label{sec:Dataset}
This paper analyses the complexity of applying the social distancing measurement via onboard low-resolution CCTV, especially public transportation. Our analysis is based on footage from a London underground line and from Go North East busses.
The majority of the London Underground lines have high-resolution CCTV cameras. However, this study investigates the complexity of detecting passengers not only in low-resolution images that can be found on a specific line on London underground and busses but also because of the occlusion caused by the camera's physical location.
We randomly choose five clips from the Go North East bus journey and five from a London underground train to visualise the outcome of this analysis. For privacy reasons, all the images in this paper have been post-processed with a Gaussian blur after the experiments to hide any passengers and their belongings.
\section{Results and Discussion}
\label{sec:results}
\subsection{Passenger Detection}
\label{sec:results_detection}
Based on the preliminary experiments on comparing three different object detection models, we use Mask R-CNN running on the Detectron2 framework for passenger detection in this paper. We compare the headcount from the Mask R-CNN to the ground truth to see how accurately the model detects passengers on public transportation. We randomly choose five different camera footages from the bus journey and five from the underground train, and manually count the number of passengers of each journey as the ground truth headcount. We also randomly select a frame range where the headcount is constant to monitor the performance of the Mask R-CNN.
To study whether the model under or over predicts, we plot the relative change in percentage as in Figure~\ref{fig:RC}. We measure the relative changes of the headcount for every frame based on $:$
\begin{equation}
RC=\frac{y_{i}-x_{i}}{y_{i}},
\label{eq:rc}
\end{equation}
where $y_i$ is the ground truth number and $x_i$ is the prediction number. The percentage above zero indicates under prediction, while the percentage less than zero indicates over prediction (False Positive).
Table~\ref{table:headcount} shows the headcount of the prediction using Mask R-CNN to the ground truth on the frames where the ground truth headcounts are constant (i.e. between stops) to show the performance of Mask R-CNN on detecting passengers. We also calculate the mean absolute relative changes to see average relative changes across all frames on the footage.
Figure~\ref{fig:RC} and Table~\ref{table:headcount} show that the predictions often differ greatly from the ground truth headcount. The bus footage plots indicate that false positives happen in all the footage. Some of the examples of object detection via Mask R-CNN can be seen in Figure~\ref{fig:Headcount_example}.
The current literature in Section~\ref{sec:related-work} focuses on pedestrian detection, where the pedestrian in the footage is mostly standing up, which shows more visible features than people sitting down. Figure~\ref{fig:tand} shows an example of a passenger being easily detected when standing up compared to sitting down.
Object detection works very well when the model can learn features that discriminate between different classes:- in our case, between a person and a non-person. However, we have to work with low-resolution CCTV images, making it hard for the object detection network (Mask R-CNN) to identify the features within the images. Apart from that, there are many passengers that are occluded because of the CCTV's physical location, for example, in Figure~\ref{fig:Bad}.
\begin{figure}[!h]
\centering
\subfloat[A passenger is blocking another passenger.]{\includegraphics[width=0.32\textwidth]{Figures/Bad/TFL_Bad_00}%
\label{Bad00}}
\hfill
\subfloat[Two passengers have been detected as an object.]{\includegraphics[width=0.32\textwidth]{Figures/Bad/TFL_Bad_01}%
\label{Bad01}}
\hfill
\subfloat[Pedestrian on the street.]{\includegraphics[width=0.32\textwidth]{Figures/Bad/GNE_Bad_00}%
\label{Bad02}}
\hfill
\subfloat[Cyclist on the street.]{\includegraphics[width=0.32\textwidth]{Figures/Bad/GNE_Bad_01}%
\label{Bad03}}
\caption{Example of the incorrect detection on the public transportation footages.}
\label{fig:Bad}
\end{figure}
\begin{figure*}[!h]
\centering
\subfloat[V06]{\includegraphics[width=0.2\textwidth]{Figures/BB_RC/RC_BB_V06}%
\label{RCBB_V06}}
\subfloat[V07]{\includegraphics[width=0.2\textwidth]{Figures/BB_RC/RC_BB_V07}%
\label{RCBB_V07}}
\subfloat[V08]{\includegraphics[width=0.2\textwidth]{Figures/BB_RC/RC_BB_V08}%
\label{RCBB_V08}}
\subfloat[V09]{\includegraphics[width=0.2\textwidth]{Figures/BB_RC/RC_BB_V09}%
\label{RCBB_V09}}
\subfloat[V10]{\includegraphics[width=0.2\textwidth]{Figures/BB_RC/RC_BB_V10}%
\label{RCBB_V10}}
\caption{Relative change between the headcount of ground truth and prediction before and after the bounding box analysis.}
\vskip -10pt
\label{fig:BB_RC}
\end{figure*}
\begin{figure*}[!h]
\centering
\subfloat[V01]{\includegraphics[width=0.2\textwidth]{Figures/SD/V01_SD}%
\label{V01}}
\subfloat[V02]{\includegraphics[width=0.2\textwidth]{Figures/SD/V02_SD}%
\label{V02}}
\subfloat[V03]{\includegraphics[width=0.2\textwidth]{Figures/SD/V03_SD}%
\label{V03}}
\subfloat[V04]{\includegraphics[width=0.2\textwidth]{Figures/SD/V04_SD}%
\label{V04}}
\subfloat[V05]{\includegraphics[width=0.2\textwidth]{Figures/SD/V05_SD}%
\label{V05}}
\hfil
\subfloat[V06]{\includegraphics[width=0.2\textwidth]{Figures/SD/V06_SD}%
\label{V06}}
\subfloat[V07]{\includegraphics[width=0.2\textwidth]{Figures/SD/V07_SD}%
\label{V07}}
\subfloat[V08]{\includegraphics[width=0.2\textwidth]{Figures/SD/V08_SD}%
\label{V08}}
\subfloat[V09]{\includegraphics[width=0.2\textwidth]{Figures/SD/V09_SD}%
\label{V09}}
\subfloat[V10]{\includegraphics[width=0.2\textwidth]{Figures/SD/V10_SD}%
\label{V10}}
\caption{Social distancing measurement}
\vskip -10pt
\label{fig:SD_train}
\end{figure*}
In Figure \ref{Bad00}, we can see that a passenger is blocking another passenger, and the Mask R-CNN is blending this passenger's head to another passenger's lower body as a detection. Similarly, two passengers in Figure \ref{Bad01} have been detected as a passenger. There are pedestrians outside of the bus in Figure \ref{Bad02} and Figure \ref{Bad03} that have been detected, contributing to the detection's false positive. Additionally, a passenger in Figure \ref{Bad02} has not been detected, perhaps because of the unusual angle of the passenger and the hardcoded metadata causing some occlusion of the passenger.
\begin{table}[h!]
\centering
\caption{The number of passengers based on ground truth headcount and prediction headcount, and the mean absolute relative change (Mean Abs RC) between the headcounts.}
\label{table:headcount}
\begin{tabu}{c c c c}
\hline\hline
\textbf{Footage} & \textbf{Ground truth} & \textbf{Prediction} & \textbf{Mean Abs RC}\\
\hline\hline
\textbf{V01} & 13 & 7 & 60.5$\%$\T\\
\textbf{V02} & 7 & 3 & 81.5$\%$ \\
\textbf{V03} & 4 & 3 & 58.6$\%$\\
\textbf{V04} & 8 & 5 & 55.1$\%$\\
\textbf{V05} & 8 & 4 & 77.7$\%$\\
\textbf{V06} & 3 & 2 & 73.3$\%$\\
\textbf{V07} & 3 & 3 & 80.7$\%$\\
\textbf{V08} & 3 & 2 & 36.0$\%$\\
\textbf{V09} & 4 & 3 & 51.2$\%$\\
\textbf{V10} & 5 & 4 & 53.8$\%$ \\
\hline\hline
\end{tabu}
\end{table}
In addition to the low-resolution camera, the physical location of the surveillance camera on the vehicle can also be an issue. For example;
\begin{itemize}
\item Having a camera far away from the passenger seats' location results in some people only appearing as a few pixels in the frame.
\item Other obstacles may occlude a clear line of sight to the passengers, such as seats, handrails, or other passengers in front of the others.
\item As the CCTV also captures partial images from outside of the vehicle, false positives may occur, especially if any pedestrians or cyclists are captured within the frame.
\item The inconsistent brightness on the vehicle will either create shadows that can be mistaken as a person or may result in low illumination in the images, again degrading the network's performance.
\end{itemize}
\subsection{Bounding Box Analysis}
\label{sec:results_bb}
Based on Figure \ref{fig:RC} in Section \ref{sec:results_detection}, all the bus footages (V06, V07, V08, V09, V10) have a significant number of false-positive detections. From the observation, the location of the CCTV cameras and the positions and the large windows contribute to the false positive detections on the bus. As the CCTV captures partial images from outside of the bus, false positives may occur, as when pedestrians or cyclists are captured within the frame. In addition, the inconsistent brightness on the bus will either create shadows that can be mistaken as a passenger, again degrading the performance of the object detection network. Therefore, we ran the bounding box analysis to investigate if our assumptions are correct and improve the relative change of passenger detection.
As shown in Figure \ref{fig:BB_RC}, this bounding box analysis method manages to remove some of the false positives. However, some of the true positives have been removed as well. The mean absolute relative change for these five videos now are; 76.1$\%$, 77.4$\%$, 23.2$\%$, 51.5$\%$, and 40.4$\%$. One of the observations that contribute to this is some of the passengers are sitting where they are obscured from a clear line of sight of the CCTV camera. Thus, the only time they were detected was when they walked to their seat or walked out from the bus. By eliminating the bounding box that appears less frequent around the same region, the detection of these passengers will have eliminated as well, resulting in them not being counted.
\begin{figure}[!h]
\centering
\subfloat[A part of the passenger has been detected.]{\includegraphics[width=0.35\textwidth]{Figures/Bad_SD/TFL_BadSD_00}%
\label{Badsd00}}
\hfill
\subfloat[A passenger is stretching out the leg.]{\includegraphics[width=0.35\textwidth]{Figures/Bad_SD/TFL_BadSD_01}%
\label{Badsd01}}
\hfill
\subfloat[A false positive of a seat next to a detected passenger.]{\includegraphics[width=0.35\textwidth]{Figures/Bad_SD/GNE_BadSD_00}%
\label{Badsd02}}
\hfill
\subfloat[The lower body of the passenger is not detected.]{\includegraphics[width=0.35\textwidth]{Figures/Bad_SD/GNE_BadSD_01}%
\label{Badsd03}}
\caption{Example of the incorrect social distancing measurement on the public transportation footages.}
\vskip -10pt
\label{fig:Badsd}
\end{figure}
\subsection{Social Distancing}
\label{sec:results_distance}
Using bounding boxes from the detected passengers, we can obtain the centroid of the boxes and measure the Euclidean distances of any adjacent passengers. We use this information and the safe distance threshold to measure the social distancing between passengers. We used Density-Based Spatial Clustering of Applications with Noise (DBSCAN) as density-based clustering where it clusters based on the distance between the nearest point \cite{ester1996density}.
Figure \ref{fig:SD_train} shows the example of a social distancing measurement on public transportation. The green bounding box indicates safe social distancing, amber indicates not safe, and the red bounding box indicates dangerous social distancing. As the social distancing relies on passenger detection, the passenger that has not been detected did not contribute to the overall clustering algorithm, causing inaccurate measurement of the social distancing. It is also similar to any false positives that add inaccurate bounding boxes that will affect the accuracy of the social distancing measurement.
It is also important to note that this social distancing measure is purely based on the passenger detection based on the footage. There is not enough information to conclude whether the passengers are perhaps from the same household.
The occlusion or the wrong pixel detection during passenger detection causes the wrong size of the bounding box, leading to inaccurate social distancing measurement as the clustering is based on the centre of the bounding box.
Some of the inaccurate social distancing measurement examples can be seen in Figure \ref{fig:Badsd} that shows a part of a passenger has been detected. However, the size of the bounding box is smaller than the actual ground truth, making the passenger's centroid a bit far from the next passenger. Contrary, as the passenger in Figure \ref{Badsd01} stretched out the legs, the bounding box became bigger and pushed the centroid closer to the other passenger.
A false positive is detected next to a detected passenger in Figure \ref{Badsd02}, resulting in a false danger social distancing measurement. The seats on the vehicle can sometimes block some part of passengers resulting in a smaller bounding box than the actual ground truth. The two passengers sitting next to each other in Figure \ref{Bad03} are measured as at a safe distance because of the big difference in the bounding box size.
\section{Introduction}
\label{sec:intro}
\begin{figure*}[!b]
\centering
\subfloat[Faster R-CNN]{\includegraphics[width=0.32\textwidth]{Figures/compare/faster_rcnn00}%
\label{fig:compare_frcnn00}}
\hfil
\subfloat[Faster R-CNN]{\includegraphics[width=0.32\textwidth]{Figures/compare/faster_rcnn01}%
\label{fig:compare_frcnn01}}
\hfil
\subfloat[Faster R-CNN]{\includegraphics[width=0.32\textwidth]{Figures/compare/faster_rcnn02}%
\label{fig:compare_frcnn02}}
\subfloat[Mask R-CNN]{\includegraphics[width=0.32\textwidth]{Figures/compare/mask_rcnn00}%
\label{fig:compare_mrcnn00}}
\hfil
\subfloat[Mask R-CNN]{\includegraphics[width=0.32\textwidth]{Figures/compare/mask_rcnn01}%
\label{fig:compare_mrcnn01}}
\hfil
\subfloat[Mask R-CNN]{\includegraphics[width=0.32\textwidth]{Figures/compare/mask_rcnn02}%
\label{fig:compare_mrcnn02}}
\subfloat[YOLOv3]{\includegraphics[width=0.32\textwidth]{Figures/compare/yolo00}%
\label{fig:compare_yolo00}}
\hfil
\subfloat[YOLOv3]{\includegraphics[width=0.32\textwidth]{Figures/compare/yolo01}%
\label{fig:compare_yolo01}}
\hfil
\subfloat[YOLOv3]{\includegraphics[width=0.32\textwidth]{Figures/compare/yolo02}%
\label{fig:compare_yolo02}}
\caption{Preliminary passenger detection comparing three state-of-the-art object detection}
\label{fig:Modelcompare}
\end{figure*}
There have been many studies on monitoring social distancing to provide safety measures in public spaces in recent years, primarily because of the COVID-19 pandemic. Social distancing refers to a distance maintained between one person to another to minimise physical contact~\cite{saponara2021implementing}. One of the ways the virus spreads is through close contact between people; therefore, social distancing can reduce or slow down the spread~\cite{khataee2021effects}. By taking advantage of surveillance camera footage, social distancing monitoring systems have been developed that can be used to to either enforce social distancing in public spaces~\cite{varghese2021multimodal} or provide advice and guidelines on how effectively social distancing works~\cite{kumari2021deep, magoo2021deep, shalini2021social, punn2020monitoring, mercaldo2021proposal, hou2020social}. However, no study shows the efficacy of social distancing measurement on public transportation.
Public transportation is an essential facility for daily transportation. According to the United Kingdom Department of Transport, in the year 2019/2020, there were 4524 million passenger journeys on local bus services in Great Britain, 1745 million passenger journeys on the national rail network, and 1337 million passenger journeys on London underground~\cite{DfTRail}. These numbers showed that there were many journeys with a high-density of passengers and so automatic social distancing measurement would have been helpful. Whilst, social distancing on public transportation is critical as the virus spreads more easily in the enclosed spaces, other factors such as good ventilation on public transportation will also help with transmission mitigation and are highly recommended~\cite{morawska2020can}. However, social distancing is crucial when it is hard to achieve a good ventilation.
Convolutional Neural Networks (CNN) are a state-of-the-art machine learning approach that has been shown as a practical solution in object detection tasks within computer vision~\cite{zou2019object}. Object detection architectures such as region-based CNN (R-CNN) like Faster R-CNN , Mask R-CNN, and YOLO v3 (You Only Look Once version 3) provide solutions for detecting objects and their locations in an image~\cite{liu2020deep}. These large architectures are trained on massive benchmark datasets for multiple days to achieve their predictive performance. Despite advancements in computer vision, object detection tasks still face challenges when dealing with real-world images, especially where the images suffer from degradation and occlusion~\cite{liu2020deep}.
In order to accurately monitor social distancing on public transportation, ideally object detection should be able to detect the presence and position of every passenger on board by using the surveillance CCTV system on the vehicle. However, based on our observation of these images, the quality of the images is poor, with very low-resolution and low frame-per-second when compared to the benchmark dataset used to train object detection algorithms such as MS COCO that has high quality and clean images~\cite{lin2014microsoft}. Additionally, the camera's physical position in the vehicle often means it is far from the location of the passenger seats and there are fittings such as hand rails and seats that prevent clear line of sight. This results in social distancing monitoring on public transportation being complex when compared to monitoring using CCTV in streets or malls. There are also possible false positives on the footage caused by either image degradation or the capture of partial images of people through the window and therefore outside the vehicle.
In this study, we present three different object detection algorithms, Faster R-CNN, Mask R-CNN and YOLO v3, to investigate the performance of these algorithms in detecting passengers from the low-resolution onboard CCTV cameras from both busses and underground trains. We then explore using our domain knowledge on the expected behaviour of passengers to improve the accuracy. We also use density-based clustering of the detected passengers to examine the possibility of automatic social distancing measurement on public transportation.
This paper highlights the complexity of achieving social distancing measurement from onboard low-resolution CCTV. To our knowledge, this study is the first to address such an issue on public transportation datasets. Using state-of-the-art computer vision algorithms such as Mask R-CNN, we believe performing social distance measurement in real-life will require some adjustment in terms of the hardware specification and the physical location of the surveillance camera. In summary, the main contributions of this study are:
\begin{itemize}
\item A study of social distancing measurement on public transportation based on the existing, low-resolution onboard surveillance cameras in the vehicles.
\item We show that domain knowledge based on expected passenger behaviour on public transportation can improve the results by certain condition.
\item We highlight the complexity of detecting passengers and social distancing automatically via object detection algorithms on real world CCTV footage and suggest how this could be improved.
\end{itemize}
\section{Methodology}
\label{sec:methods}
This section discusses three different state-of-the-art object detection approaches on images from low-resolution onboard surveillance cameras on public transportation to assess how well the pre-trained networks detect the passengers. We also present a post-processing technique we used to investigate if we can improve the quality of the detections.
\subsection{Object Detection}
\label{sec:objdetection}
Object Detection is one of the most used applications within Computer Vision and has been widely used in object tracking, autonomous vehicle, medical imaging and many more application. The goal of object detection is to locate each object in an image \cite{Vahab2019applications}. In this paper, we show three different object detection algorithms to see if the algorithms can detect the passengers using the onboard CCTV camera footage from the bus and underground train.
\subsubsection{Faster R-CNN}
\label{sec:frcnn}
The Faster R-CNN is a region-based CNN that introduces another convolutional network (on top of the CNN for the classification task) as Region Proposal Network (RPN) to generate the pixel coordinates of the potential objects in an image \cite{ren2015faster}. A region-based network is a network that has a region proposal module that generates a variety of bounding boxes with different sizes and aspect ratios as the proposed object regions. This network will return object classes with the score and the bounding boxes for each object as the pixel coordinates \cite{girshick2014rich}.
\subsubsection{Mask R-CNN}
\label{sec:mrcnn}
Mask R-CNN used the RPN from Faster R-CNN, but instead of just the bounding box, it indicates the binary mask of each object and the bounding box. The binary mask gives 1 to the pixel that belongs to the objects and 0 otherwise. Mask R-CNN is considered an instance segmentation because of the mask segmentation, given the pixel by pixel location and the bounding box of every object. The granularity can be beneficial in applications such as autonomous vehicles and pose estimation, where precision is essential \cite{he2017mask}.
\begin{figure}[!h]
\centering
\subfloat[Passenger sitting down.]{\includegraphics[width=0.32\textwidth]{Figures/Stand/Stand00}%
\label{S00}}
\hfil
\subfloat[Passenger standing up.]{\includegraphics[width=0.32\textwidth]{Figures/Stand/Stand01}%
\label{S01}}
\caption{Comparison of the Mask R-CNN in detecting passenger standing up as compared to the same passenger sitting down.}
\vskip -5pt
\label{fig:tand}
\end{figure}
\subsubsection{YOLOv3}
\label{sec:yolov3}
Unlike region-based object detection CNN use two networks, one for object localisation and another for feature extraction, You Only Look Once (YOLO) introduces single-stage architecture using the regression-based method \cite{redmon2016you}. YOLO v3 has a deep end-to-end CNN that deals with feature extraction and object localisation, making this unified architecture very quick to train \cite{redmon2018yolov3}.
We show examples of these three object detection approaches as in Figure \ref{fig:Modelcompare}. As the performance of Mask R-CNN is better than Faster R-CNN or YOLOv3, in this paper, we use Mask R-CNN running on Detectron2 framework \cite{wu2019detectron2} as our passenger detection.
\subsection{Post Processing}
\label{sec:postprocess}
There are some possible false positives in the footage that caused by the degradation of images or the camera angle, especially on the bus that captures partial images from outside the vehicle. In this paper, we explore the way to eliminate any false positive detection by using bounding box analysis. We are interested in reducing the false positives via the usage of domain knowledge on the expected behaviour of the passengers on public transportation by eliminating any bounding boxes from the prediction that only appear for a few frames.
The assumption is that, once people are on the bus, their bounding boxes will frequently appear within the same region for at least a few minutes. If a ``person" is detected for less than a certain number of frames, we can assume it is a misidentification, for example, a pedestrian or cyclist outside of the bus.
Our bounding box analysis is based on a few assumptions:
\begin{itemize}
\item Most of the time, all passengers are roughly in the same place (they are sitting in the same seat) throughout the journey.
\item There is no more than one false positive in a frame.
\item We vary the frame window between 4 frames to 300 frames (1 second to 60 seconds given 4fps of the video).
\item We vary the centre of the bounding box within $\pm$10 and $\pm$15 pixels.
\end{itemize}
\section{Conclusion}
With the recent progress in machine learning for computer vision, there is much literature investigating the best way to tackle the issue of social distancing through the use of surveillance cameras in public spaces, primarily because of the COVID-19 pandemic. However, there is no related study on social distancing on public transportation up to date. CNNs have been shown capable in various object detection tasks within computer vision, especially when the image quality is good. In this work, we highlight the complexity of applying social distancing measurement using these methods on onboard low-resolution CCTV from public transportation. Using domain knowledge, we analyse the detection output to see if it is possible to improve the detection, especially in the headcount. Finally, we measure the social distancing between passengers using density-based clustering.
In order to accurately monitor social distancing on public transportation, object detection should be able to detect every passenger on board by using the surveillance CCTV system on the vehicle. The physical location of the camera on public transportation, typically distant from the passenger seat location causes some passengers to appear as only a few pixels in the image. Additionally, the nature of the public transportation with obstacles such as seats, handrails and other passengers may occlude clear line of sight to the passengers. In addition, inconsistent image illumination and partial scenes captured from outside of the vehicles can be a potential issue degrading model predictive performance.
The current onboard surveillance cameras on public transportation hinders satisfactory object detection and, consequently, affects the social distancing measurement. Other training approaches may be required to help models account for the challenges of these real-world images. Additionally, better quality hardware and improved physical placement of the camera should be put in place to improve automatic social distance measurement.
|
{'timestamp': '2022-02-15T02:42:18', 'yymm': '2202', 'arxiv_id': '2202.06639', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06639'}
|
arxiv
|
\section{Electronic Submission}
\label{submission}
Submission to ICML 2022 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 \textbf{New to this year}: If your paper has appendices, submit the appendix together with the main body and the references \textbf{as a single file}. Reviewers will not look for appendices as a separate PDF file. So if you submit such an extra file, reviewers will very likely miss it.
\item Page limit: The main body of the paper has to be fitted to 8 pages, excluding references and appendices; the space for the latter two is not limited. For the final version of the paper, authors can add one extra page to the main body.
\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. \cref{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{icml2022}
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
\cref{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{39}^{th}$ International Conference on Machine Learning},
Baltimore, Maryland, USA, PMLR 162, 2022.
Copyright 2022 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\{icml2022\}}$ to
$$\mathtt{\backslash usepackage[accepted]\{icml2022\}}$$
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
2022 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.
Do not write anything on the margins.
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{icml2022.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 (they are not required to look at more than the first $8$ pages of the submitted document).
\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 protected]\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 ICML2022 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
\cref{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.
\cref{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
\cref{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{Theorems and such}
The preferred way is to number definitions, propositions, lemmas, etc. consecutively, within sections, as shown below.
\begin{definition}
\label{def:inj}
A function $f:X \to Y$ is injective if for any $x,y\in X$ different, $f(x)\ne f(y)$.
\end{definition}
Using \cref{def:inj} we immediate get the following result:
\begin{proposition}
If $f$ is injective mapping a set $X$ to another set $Y$,
the cardinality of $Y$ is at least as large as that of $X$
\end{proposition}
\begin{proof}
Left as an exercise to the reader.
\end{proof}
\cref{lem:usefullemma} stated next will prove to be useful.
\begin{lemma}
\label{lem:usefullemma}
For any $f:X \to Y$ and $g:Y\to Z$ injective functions, $f \circ g$ is injective.
\end{lemma}
\begin{theorem}
\label{thm:bigtheorem}
If $f:X\to Y$ is bijective, the cardinality of $X$ and $Y$ are the same.
\end{theorem}
An easy corollary of \cref{thm:bigtheorem} is the following:
\begin{corollary}
If $f:X\to Y$ is bijective,
the cardinality of $X$ is at least as large as that of $Y$.
\end{corollary}
\begin{assumption}
The set $X$ is finite.
\label{ass:xfinite}
\end{assumption}
\begin{remark}
According to some, it is only the finite case (cf. \cref{ass:xfinite}) that is interesting.
\end{remark}
\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{icml2022.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 \cref{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, e.g. use the actual current name of authors.
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*{Accessibility}
Authors are kindly asked to make their submissions as accessible as possible for everyone including people with disabilities and sensory or neurological differences.
Tips of how to achieve this and what to pay attention to will be provided on the conference website \url{http://icml.cc/}.
\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}
\section{Introduction}
Learning tasks requires information~\citep{principe2006information} in the form of training data. Thus, information measures~\citep{Shannon1948Mathematical} (\textit{e.g.}\ entropy, conditional entropy and mutual information) have been a source of inspiration for the design of learning objectives in modern machine learning (ML) models~\citep{Linsker1989How,Torkkola2006}. Over the years, a plethora of estimators have been introduced to estimate the value of the aforementioned measures of information and they have been applied to many different problems, including information and coding theory, limiting distributions, model selection, design of experiment and optimal prior distribution, data disclosure, and relative importance of predictors~\citep{https://doi.org/10.1111/j.1751-5823.2010.00105.x}. In these applications, traditional research focused on both developing new estimators and obtaining provable guarantees on the asymptotic behavior of these estimators~\citep{NIPS2012_c8ba76c2,Verdu2019Empirical}.
However, when used for training deep neural networks, additional \emph{requirements} need to be satisfied. In particular, the estimator needs to be differentiable w.r.t.\ the data distribution \textbf{(R1)}, computationally tractable \textbf{(R2)}, and able to rapidly adapt to changes in the underlying distribution \textbf{(R3)}.
For instance, Mutual Information (MI), a fundamental measure of dependence between variables, only became a popular (standalone or regularizing) learning objective for DNNs once estimators satisfying the above requirements were proposed~\citep{pmlr-v97-poole19a, 10.5555/2981345.2981371}. Although MI is notoriously difficult to estimate in high dimensions~\citep{PhysRevE.69.066138, DBLP:journals/corr/abs-2002-02851, pmlr-v108-mcallester20a}, these estimators have demonstrated promising empirical results in unsupervised representation learning \citep{NIPS2010_42998cf3, NIPS1991_a8abb4bb,hjelm2018learning, Tschannen2020On}, discrete/invariant representations~\citep{pmlr-v70-hu17b,Ji_2019_ICCV}, generative modelling \citep{infogan,info_vae}, textual disentangling~\citep{dt_info,colombo2021novel}, and applications of the Information Bottleneck (IB) method~\citep{mahabadi2021variational,devlin2018bert, DBLP:journals/corr/AlemiFD016} among others. Compared to MI, Differential Entropy (DE) has received less attention from the ML community while offering a potentially wider range of applications than MI.
In this paper, we focus on the problem of differentiable, flexible and efficient DE estimation satisfying simultaneously \textbf{(R1)},\textbf{(R2)},\textbf{(R3)} as this quantity naturally appears in many applications (\textit{e.g.}\ reinforcement learning \citep{pmlr-v97-shyam19a, provably_efficient_entropy_maximization, impact_entropy_policy_optimization,emi}, IB \citep{DBLP:journals/corr/AlemiFD016}, mode collapse \citep{mine}) and can be used to estimate MI. Traditional estimators of DE often violate at least one of the requirements \textbf{(R1)} -- \textbf{(R3)} listed above (\textit{e.g.}\ $k$-nearest neighbor based estimators violate \textbf{(R1)}). Consequently, the lack of appropriate DE estimators for arbitrary data distributions forces deep learning researchers to either restrict themselves to special cases where closed-form expressions for DE are available \citep{pmlr-v97-shyam19a} or use MI as a proxy \citep{mine}. In this work, we introduce a \underline{K}ernelized \underline{N}eural d\underline{IF}ferential \underline{E}ntropy (\textsc{Knife}) estimator, that satisfies the aforementioned requirements and addresses limitations of existing DE estimators \citep{Schraudolph2004Gradient,pmlr-v108-mcallester20a}. Stemming from recent theoretical insights \citep{pmlr-v108-mcallester20a} that justify the use of DE estimators as building blocks to better estimate MI, we further apply {\textsc{Knife}} to MI estimation. In the context of deep neural networks with high dimensional data (\textit{e.g.}\ image, text), {\textsc{Knife}} achieves competitive empirical results in applications where DE or MI is required.
\iffalse
Entropy and conditional entropy have been extraordinarily valuable in the design of modern communication systems~\citep{Shannon1948Mathematical} and their use has been recently gaining momentum within the machine learning (ML) community.
Here, they help to specify the design of objectives for training modern ML models~\citep{Linsker1989How,Torkkola2006}.
For instance, entropy has become very popular in reinforcement learning \citep{pmlr-v97-shyam19a, provably_efficient_entropy_maximization, impact_entropy_policy_optimization,emi}, where entropy maximization is used to encourage exploration and thus, to avoid convergence to poor low entropy policies.
Quantifying the dependence between two continuous or discrete/continuous random variables (e.g., concepts and features) is a fundamental ingredient in representation learning, and thus many measures have been proposed. As a fundamental measure of dependence, Mutual Information (MI) has been commonly applied in statistics and machine learning to quantify the dependence between variables. MI has the advantage of providing a very powerful measure of nonlinear associations, e.g., compared to Pearson’s correlation coefficient which can only measure linear dependence. As MI typically cannot be estimated directly~\citep{PhysRevE.69.066138, DBLP:journals/corr/abs-2002-02851, pmlr-v108-mcallester20a}, estimates of surrogate functions, either upper/lower bounds~\citep{pmlr-v97-poole19a, 10.5555/2981345.2981371}, are commonly used in place. Recently, there has been a revival of methods inspired by the celebrated \emph{InfoMax principle}~\citep{Linsker1988Self}, which explore various estimators of upper/lower bounds of MI that have demonstrated promising empirical results in unsupervised representation learning \citep{NIPS2010_42998cf3, NIPS1991_a8abb4bb,mi_nce,hjelm2018learning,beta_tcvae, NEURIPS2019_6fb52e71, Tschannen2020On}, discrete/invariant representations~\citep{pmlr-v70-hu17b,Ji_2019_ICCV}, generative modelling \citep{infogan,info_vae}, textual disentangling~\citep{dt_info,colombo2021novel}, applications of the information bottleneck~\citep{mahabadi2021variational,devlin2018bert, DBLP:journals/corr/AlemiFD016}, among others.
In this paper, we investigate the problem of estimating differential
entropy and conditional differential entropy---fundamental concepts that began as an attempt by Shannon to extend the notion of entropy to continuous probability distributions---using a finite number of samples.
More specifically, given $N$ i.i.d.\ samples
of a random variable with unknown Probability Density Function (PDF) $p$,
we propose a fully differentiable kernel-based estimator of the differential entropy:\footnote{All logarithms in this work are to base $e$ and thus, information-theoretic quantities are measured in $\nat$.}
\begin{equation}
\label{eq:entropy}
\Ent(X) \coloneqq -\int p(x) \log p(x) \,\mathrm{d}x .
\end{equation}
MI is intimately linked to differential and conditional differential entropy by noticing that
\begin{equation}\label{eq:mi_conditionnal}
\MI(X;Y) = \Ent(X) - \Ent(X|Y).
\end{equation}
Although the study of efficient neural-based estimators of MI has undoubtedly played an important role in the recent development of the field of machine learning (e.g., adversarial and representation learning), conditional and differential entropy hardly received any attention in recent years.
\fi
\subsection{Contributions}
Our work advances the field of differentiable, flexible and efficient DE estimation satisfying simultaneously \textbf{(R1)},\textbf{(R2)},\textbf{(R3)}.
\begin{enumerate}[wide, labelindent=0pt]
\item We showcase limitation of the existing DE estimators proposed in \citep{Schraudolph2004Gradient,pmlr-v108-mcallester20a} with respect to desirable properties required for training deep neural networks. To address these shortcomings, we introduce {\textsc{Knife}}, a fully learnable kernel-based estimator of DE. The flexibility of {\textsc{Knife}} allows us to construct {\textsc{Knife}}-based estimators for conditional DE, conditioning on either a discrete or continuous random variable.\vspace{-0.1cm}
\item We prove learnability under natural conditions on the underlying probability distribution. By requiring a fixed Lipschitz condition and bounded support we are not only able to provide an asymptotic result, but also a confidence bound in the case of a finite training set. This extends the consistency result by \citep{Ahmad1976Nonparametric}.\vspace{-0.1cm}
\item We validate on synthetic datasets (including multi-modal, non-Gaussian distributions), that {\textsc{Knife}} addresses the identified limitations and outperforms existing methods on both DE and MI estimation. In particular, {\textsc{Knife}} more rapidly adapts to changes in the underlying data distribution.\vspace{-0.1cm}
\item We conduct extensive experiments on natural datasets (including text and images) to compare {\textsc{Knife}}-based MI estimators to most recent MI estimators. First, we apply {\textsc{Knife}} in the IB principle to fine-tune a pretrained language model. Using {\textsc{Knife}}, we leverage a closed-form expression of a part of the training objective and achieve the best scores among competing MI estimators.
Second, on fair textual classification, the {\textsc{Knife}}-based MI estimator achieves near perfect disentanglement (with respect to the private, discrete label) at virtually no degradation of accuracy in the main task. Lastly, in the challenging scenario of visual domain adaptation, where both variables are continuous, {\textsc{Knife}}-based MI estimation also achieves superior results. \textcolor{red}{Code for {\textsc{Knife}} and to reproduce results can be found at \url{}. }\vspace{-0.1cm}
\end{enumerate}
\subsection{Existent Methods and Related Works}
\textbf{DE estimation.} Existing methods for estimating DE fit into one of three categories~\citep{Beirlant1997Nonparametric,hlavavckova2007causality,Verdu2019Empirical}: plug-in estimates~\citep{Ahmad1976Nonparametric,Gyoerfi1987Density}, estimates based on sample-spacings~\citep{Tarasenko1968evaluation}, and estimates based on nearest neighbor distances~\citep{Kozachenko1987Sample,Tsybakov1996Root,berrett2019efficient}. Our proposed estimator falls into the first category and we will thus focus here on previous work using that methodology.
Excellent summaries of all the available methods can be found in the works~\citep{Beirlant1997Nonparametric,hlavavckova2007causality,Wang2009Universal,Verdu2019Empirical}. In \citep{Ahmad1976Nonparametric}, a first nonparametric estimator of DE was suggested and theoretically analyzed.
It builds on the idea of kernel density estimation using Parzen-Rosenblatt windowing \citep{Rosenblatt1956Remarks,Parzen1962estimation}.
More detailed analysis followed \citep{Joe1989Estimation,Hall1993Estimation} but the estimator remained essentially unchanged.
Unfortunately, this classical literature is mostly concerned with appropriate regularity conditions that guarantee asymptotic properties of estimators, such as (asymptotic) unbiasedness and consistency.
Machine learning applications, however, usually deal with a fixed---often very limited---number of samples.
\textbf{Differentiable DE estimation.}
A first estimator that employed a differential learning rule was introduced in \citep{viola1996empirical}.
Indeed, the estimator proposed therein is optimized using stochastic optimization, it only used a single kernel with a low number of parameters.
An extension that uses a \emph{heteroscedastic} kernel density estimate, i.e., using different kernels at different positions, has been proposed in \citep{Schraudolph2004Gradient}.
Still the number of parameters was quite low and varying means in the kernels or variable weights were not considered.
Although the estimation of DE remained a topic of major interest as illustrated by recent works focusing on special classes of distributions \citep{kolchinsky2017estimating,chaubey2021estimation} and nonparametric estimators \citep{ 6473887, NIPS2015_06138bc5,9496673},
the estimator introduced in \citep{Schraudolph2004Gradient}
was not further refined and hardly explored in recent works.
\textbf{Differentiable MI estimation.} In contrast, there has been a recent surge on new methods for the estimation of the closely related MI between two random variables.
The most prominent examples include unnormalized energy-based variational lower bounds \citep{pmlr-v97-poole19a}, the lower bounds developed in \citep{convex_risk_minimization} using variational characterization of f-divergence, the MINE-estimator developed in \citep{mine} from the Donsker-Varadhan representation of MI which can be also interpreted as an improvement of the plug-in estimator of~\citep{suzuki2008approximating}, the noise-contrastive based bound developed in \citep{mi_nce} and finally a contrastive upper bound~\citep{Cheng2020CLUB}. \citep{pmlr-v108-mcallester20a} point out shortcomings in other estimation strategies and introduce their own Differences of Entropies (\textsc{DoE}) method.
\section{\textsc{Knife}}
In this section we identify limitations of existing entropy estimators introduced in \citep{Schraudolph2004Gradient,pmlr-v108-mcallester20a}. Subsequently, we present {\textsc{Knife}}, which addresses these shortcomings.
\subsection{Limitations of Existing Differential Entropy Estimators}
\label{sec:limit-exist-de}
Consider a continuous random vector $X \sim p$ in $\mathbb R^d$. Our goal is to estimate the DE $\Ent(X) \coloneqq -\int p(x) \log p(x) \,\mathrm{d} x$.
Given the intractability of this integral, we will rely on a Monte-Carlo estimate of $\Ent(X)$, using $N$ i.i.d.\ samples $\mathcal D_{\mathrm{x}} = \{x_n\}_{n=1}^N$ to obtain
\begin{equation} \label{eq:oracle}
\widehat{\Ent}_{\textsc{Oracle}}(\mathcal D_{\mathrm{x}}) \coloneqq - \frac{1}{N} \sum_{n=1}^N \log p(x_n).
\end{equation}
Unfortunately, assuming access to the true density $p$ is often unrealistic, and we will thus construct an estimate $\hat{p}$ that can then be plugged into \cref{eq:oracle} instead of $p$. If $\hat p$ is smooth, the resulting plug-in estimator of DE is differentiable \textbf{(R1)}.
Assuming access to an additional---ideally independent---set of $M$ i.i.d.\ samples $\mathcal E = \{x_m'\}_{m=1}^M$, we build upon the Parzen-Rosenblatt estimator~\citep{Rosenblatt1956Remarks,Parzen1962estimation}
\begin{equation}
\label{eq:kernel0}
\hat p(x; w, \mathcal E) = \frac{1}{w^d M} \sum_{m=1}^M \kappa\left(\frac{x - x_m'}{w} \right),
\end{equation}
where $w > 0$ denotes the bandwidth and $\kappa$ is a kernel density.
The resulting entropy estimator when replacing $p$ in \cref{eq:oracle} by \cref{eq:kernel0} was analyzed in~\citep{Ahmad1976Nonparametric}.
In \citep{Schraudolph2004Gradient}, this approach was extended using the kernel estimator
\begin{equation}
\label{eq:schraudolph}
\hat p_{\text{Schrau.}}(x; \mathbf A, \mathcal E) \coloneqq \frac{1}{M} \sum_{m=1}^M \kappa_{A_m}(x - x_m') ,
\end{equation}
where $\mathbf A \coloneqq (A_1,\dots,A_M)$ are (distinct, diagonal) covariance matrices and $\kappa_A (x)= \mathcal N(x;0, A)$ is a centered Gaussian density with covariance matrix $A$.
The {\textsc{DoE}} method of~\citep{pmlr-v108-mcallester20a} is a MI estimator that separately estimates a DE and a conditional DE. For DE, a simple Gaussian density estimate $\hat p_{\textsc{DoE}}(x; \boldsymbol\theta) = \kappa_A(x-\mu)$
is used, where $\boldsymbol\theta = (A, \mu)$ are the training parameters, the diagonal covariance matrix $A$ and the mean $\mu$.
While both {\text{Schrau.}} and {\textsc{DoE}} yield differentiable plug-in estimators for DE, they each have a major disadvantage. The strategy of \citep{Schraudolph2004Gradient} fixes the kernel mean values at $\mathcal E$, which implies that the method cannot adapt to a shifting input distribution \textbf{(R3)}. On the other hand, {\textsc{DoE}} allows for rapid adaptation, but its simple structure makes it inadequate for the DE estimation of multi-modal densities. We illustrate these limitations in \cref{sec:ent-estimation}.
\subsection{{\textsc{Knife}} Estimator}
\label{sec:KNIFE}
In {\textsc{Knife}}, the kernel density estimate is given by
\begin{equation}
\label{eq:knife}
\hat p_{\textsc{Knife}}(x; \boldsymbol \theta) \coloneqq \sum_{m=1}^M u_m \kappa_{A_m}(x - a_m) ,
\end{equation}
where $\boldsymbol \theta \coloneqq (\mathbf A, \mathbf a, \mathbf u)$ and the additional parameters $0 \le \mathbf u = (u_1, u_2, \dots, u_M)$ with $\mathbf 1 \cdot \mathbf u = 1$ and $\mathbf a = (a_1,\dots,a_M)$ are introduced.
Note that $\hat p_{\textsc{Knife}}(x; \boldsymbol \theta)$ is a smooth function of $\boldsymbol \theta$, and so is our proposed plug-in estimator
\begin{equation}
\label{eq:hat-h}
\widehat \Ent_{\textsc{Knife}}(\mathcal D_{\mathrm{x}}; \boldsymbol\theta) \coloneqq -\frac{1}{N} \sum_{n=1}^N \log \hat p_{\textsc{Knife}}(x_n; \boldsymbol \theta).
\end{equation}
{\textsc{Knife}} combines the ideas of \citep{Schraudolph2004Gradient,pmlr-v108-mcallester20a}. It is differentiable and able to adapt to shifting input distributions, while capable of matching multi-modal distributions.
Thus, as we will see in synthetic experiments, incorporating $u_m$ and shifts $a_m$ in the optimization enables the use of ${\textsc{Knife}}$ in non-stationary settings, where the distribution of $X$ evolves over time.
\paragraph{Learning step: } Stemming from the observation that, by the Law of Large Numbers (LLN),
\begin{equation}
\begin{split} \label{eq:ce_bound}
\widehat \Ent_{\textsc{Knife}}(\mathcal D_{\mathrm{x}}, \boldsymbol\theta) & \stackrel{\text{LLN}}{\approx}
-\mathbb{E}~\big[\log\hat p_{\textsc{Knife}}(X; \boldsymbol \theta)\big] \\
& = \Ent(X) + \mathrm{D}_{\mathrm{KL}}(p \| \hat p_{\textsc{Knife}}(\,\cdot\,;\boldsymbol \theta)) \\ & \ge \Ent(X),
\end{split}
\end{equation}
we propose to learn the parameters $\boldsymbol\theta$ by minimizing $\widehat \Ent_{\textsc{Knife}}$, where $\mathcal E$ may be used to initialize $\mathbf a$. Although not strictly equivalent due to the Monte-Carlo approximation, minimizing $\widehat \Ent_{\textsc{Knife}}$ can be understood as minimizing the Kullback-Leibler (KL) divergence in~\cref{eq:ce_bound}, effectively minimizing the gap between $\widehat \Ent_{\textsc{Knife}}$ and $\Ent(X)$. In fact, $\widehat \Ent_{\textsc{Knife}}$ can also be interpreted as the standard maximum likelihood objective, widely used in modern machine learning. It is worth to mention that the {\textsc{Knife}} estimator is fully differentiable with respect to $\boldsymbol \theta$ and the optimization can be tackled by any gradient-based method (e.g., Adam~\citep{Kingma2014Adam} or AdamW~\citep{loshchilov2017decoupled}).
\subsection{Convergence Analysis}
\label{sec:convergence-analysis}
Note that the classical Parzen-Rosenblatt estimator $\widehat\Ent(\mathcal D_{\mathrm{x}}; w)$, where~\cref{eq:kernel0} is plugged into~\cref{eq:oracle}, is a special case of \textsc{Knife}. Thus, the convergence analysis provided in \citep{Ahmad1976Nonparametric}[Theorem~1] also applies and yields sufficient conditions for $\widehat \Ent_{\textsc{Knife}}(\mathcal D_{\mathrm{x}}, \boldsymbol\theta) \to \Ent(X)$.
In \cref{sec:error-bound}, we extend this result and, assuming that the underlying distribution $p$ is compactly supported on $\mathcal X = [0,1]^d$ and $L$-Lipschitz continuous, the following \lcnamecref{thm:convergence} is proved.
\begin{theorem}
\label{thm:convergence}
For any $\delta > 0$, there exists a function ${\epsilon}(N, M, w)$ such that, with probability at least $1-\delta$,
$\big\lvert \widehat \Ent(\mathcal D_{\mathrm{x}}; w) - \Ent(X)\big\rvert \le {\epsilon}(N, M, w)$.
Additionally, ${\epsilon}(N, M, w) \to 0$ as ${M,}N \to \infty$ and $w\to 0$ if
\begin{align}
Nw &\to 0 &\text{and}&&
\frac{N^2 \log N}{w^{2d} M} &\to 0 ,
\end{align}
where $M$ and $N$ denote the number of samples in $\mathcal E$ and $\mathcal D_{\mathrm{x}}$, respectively.
\end{theorem}
The precise assumptions for \cref{thm:convergence} and an explicit formula for ${\epsilon}(N, M, w)$ are given in \cref{thm:confidence_bound} in \cref{sec:error-bound}. For instance, \cref{thm:convergence} provides a bound on the speed of convergence for the consistency analysis in \citep[Thm.~1]{Ahmad1976Nonparametric}.
\subsection{Estimating Conditional Differential Entropy and Mutual Information}
\label{sec:cond_mi}
Similar to \citep{pmlr-v108-mcallester20a}, the proposed DE estimator can be used to estimate other information measures. In particular, we can use {\textsc{Knife}} to construct estimators of conditional DE and MI.
When estimating the conditional DE and MI for a pair of random variables $(X,Y) \sim p$, we not only use $\mathcal D_{\mathrm{x}} = \{x_n\}_{n=1}^N$, but also the according i.i.d.\ samples $\mathcal D_{\mathrm{y}} = \{y_n\}_{n=1}^N$, where $(x_n, y_n)$ are drawn according to $p$.
\paragraph{Conditional Differential Entropy.}
We estimate conditional DE $\Ent(X|Y)$ by considering $\boldsymbol\theta$ to be a parameterized function $\boldsymbol\Theta(y)$ of $y$. Then all relations previously established naturally generalize and
\begin{align}
\hat p_{\textsc{Knife}}(x|y; \boldsymbol\Theta) & \coloneqq \hat p_{\textsc{Knife}}(x; \boldsymbol\Theta(y)), \\
\widehat \Ent_{\textsc{Knife}}(\mathcal D_{\mathrm{x}}|\mathcal D_{\mathrm{y}}; \boldsymbol\Theta)& \coloneqq \frac{1}{N} \sum_{n=1}^N \log \frac{1}{\hat p_{\textsc{Knife}}(x_n|y_n; \boldsymbol\Theta)}.
\label{eq:hat_h_xgivy}
\end{align}
Naturally, minimization of~\cref{eq:ce_bound} is now performed over the parameters of $\boldsymbol\Theta$.
If $Y$ is a continuous random variable, we use an artificial neural network $\boldsymbol\Theta(y)$, taking $y$ as its input.
On the other hand,
if $Y \in \mathcal{Y}$ is a discrete random variable, we have one parameter $\boldsymbol\theta$ for each $y \in \mathcal Y$, i.e., $\boldsymbol\Theta = \{\boldsymbol \theta_y\}_{y \in \mathcal Y}$ and
$\hat p_{\textsc{Knife}}(x|y; \boldsymbol\Theta) = \hat p_{\textsc{Knife}}(x; \boldsymbol\Theta(y)) = \hat p_{\textsc{Knife}}(x; \boldsymbol\theta_y)$.
\paragraph{Mutual Information.}
To estimate the MI between random variables $X$ and $Y$ (either discrete or continuous), recall that MI can be written as $\MI(X;Y) = \Ent(X) - \Ent(X|Y)$. Therefore, we use the marginal and conditional DE estimators \cref{eq:hat-h,eq:hat_h_xgivy} to build a {\textsc{Knife}}-based MI estimator
\begin{align}
\widehat \MI_{\textsc{Knife}}(\mathcal D_{\mathrm{x}}, \mathcal D_{\mathrm{y}}; \boldsymbol\theta, \boldsymbol\Theta) &\coloneqq \widehat{\Ent}_{\textsc{Knife}}(\mathcal D_{\mathrm{x}}; \boldsymbol{\theta}) \nonumber\\*
&\quad - \widehat \Ent_{\textsc{Knife}}(\mathcal D_{\mathrm{x}}|\mathcal D_{\mathrm{y}}; \boldsymbol{\Theta}). \label{eq:MI}
\end{align}
\section{Experiments using Synthetic Data}
\subsection{Differential Entropy Estimation}
\label{sec:ent-estimation}
In this \lcnamecref{sec:ent-estimation} we apply {\textsc{Knife}} for DE estimation, comparing it to~\cref{eq:schraudolph}, the method introduced in~\citep{Schraudolph2004Gradient}, subsequently labeled ``\text{Schrau.}''. It is worth to mention that we did not perform the Expectation Maximization algorithm, as suggested in~\citep{Schraudolph2004Gradient}, but instead opted to use the same optimization technique as for {\textsc{Knife}} to facilitate a fair comparison.
\subsubsection{Gaussian Distribution}
\label{sec:gauss}
As a sanity check, we test {\textsc{Knife}} on multivariate normal data in moderately high dimensions, comparing it to {\text{Schrau.}} and {\textsc{DoE}}, which we trained with the exact same parameters.
We estimate the entropy $\Ent(X) = \frac{d}{2} \log 2\pi e$ of $X \sim \mathcal N(\mathbf 0, I_d)$ for $d=10$ and $d=64$. The mean error and its empirical standard deviation are reported in \cref{tab:gaussian_results} over $20$ runs.
{\textsc{Knife}} yielded the lowest bias and variance in both cases, despite {\textsc{DoE}} being perfectly adapted to matching a multivariate Gaussian distribution. Additional experimental details can be found in \cref{sec:appendix:gaussian-data}.
\begin{table}
\begin{tabular}{rcc}
\toprule
$|h - \widehat h|$ & $d=10$ & $d=64$ \\
\midrule
{\textsc{DoE}} & $\input{numbers/estimate_entropy_gauss_d-10_rho1_DoE.summary}$ & $\input{numbers/estimate_entropy_gauss_d-64_rho1_DoE.summary}$\\
{\text{Schrau.}} & $\input{numbers/estimate_entropy_gauss_d-10_rho1_Schraudolph.summary}$ & $\input{numbers/estimate_entropy_gauss_d-64_rho1_Schraudolph.summary}$ \\
{\textsc{Knife}} & $\mathbf{\input{numbers/estimate_entropy_gauss_d-10_rho1_KNIFE.summary}}$ & $\mathbf{\input{numbers/estimate_entropy_gauss_d-64_rho1_KNIFE.summary}}$ \\
\bottomrule
\end{tabular}
\caption{Results on normal data with dimension $d$.}
\label{tab:gaussian_results}
\end{table}
In order to use a DE estimation primitive in a machine learning system, it must be able to adapt to a changing input distribution during training \textbf{(R3)}.
As already pointed out in \cref{sec:limit-exist-de}, this is a severe limitation of {\text{Schrau.}}, as re-drawing the kernel support $\mathcal E$ can be either impractical or at the very least requires a complete re-training of the entropy estimator.
Whereas in \cref{eq:knife}, the kernel support $\mathbf a$ is trainable and it can thus
adapt to a change of the input distribution. In order to showcase this ability, we utilize the approach of \citep{Cheng2020CLUB} and successively decrease the entropy, observing how the estimator adapts. We perform this experiment with data of dimension $d=64$ and repeatedly multiply the covariance matrix of the training vectors with a factor of $a = \frac 12$.
The resulting entropy estimation is depicted in \cref{fig:gauss}. It is apparent that {\text{Schrau.}} suffers from a varying bias. The bias increases with decreasing variance, as the kernel support is fixed and cannot adapt as the variance of $\mathcal D_{\mathrm{x}}$ shrinks.
{\textsc{DoE}} is perfectly adapted to a single Gaussian distribution and performs similar to \textsc{Knife}.
\begin{figure*}
\begin{minipage}[t]{0.32\linewidth}
\includegraphics[width=\textwidth]{plots/estimate_entropy_gauss_d-64_rho0.5.pdf}\vspace{-0.01cm}
\caption{Estimating DE of Gaussian data with decreasing variance.}\label{fig:gauss}
\end{minipage}\hfill\begin{minipage}[t]{0.65\linewidth}
\centering
\subcaptionbox*{}
{\includegraphics[width=.4923\linewidth]{plots/estimate_entropy_triangle_d-1_pdfs.pdf}}
\subcaptionbox*{}
{\includegraphics[width=.4923\linewidth]{plots/estimate_entropy_triangle_d-8_run1.pdf}}\vspace{-0.8cm}
\caption{\textbf{Left}: PDF when estimating DE of a triangle mixture in 1 dimension. \textbf{Right}: Training run when estimating DE of a $2$-component triangle mixture in 8 dimensions.}\label{fig:tirangle_mixture_expe}
\end{minipage}\vspace{-0.5cm}
\end{figure*}[t]
\subsubsection{Triangle Mixture}\label{sec:ent_triangle}
{\textsc{Knife}} is able to cope with distributions that have multiple modes. While \cref{eq:schraudolph} is also capable of matching multi-modal distributions, {\textsc{DoE}} is unable to do so, as it approximates any distribution with a multivariate Gaussian.
We illustrate this by matching a mixture of randomly drawn triangle distributions.
The resulting estimated PDFs as well as the ground truth when estimating the entropy of a $1$-dimensional mixture of triangles with $10$ components can be observed in \cref{fig:tirangle_mixture_expe} (left).
With increasing dimension the difficulty of this estimation rises quickly as in $d$ dimensions, the resulting PDF of independent $c$-component triangle mixtures has $c^d$ modes.
To showcase the performance of {\textsc{Knife}} in this challenging task, we
ran $10$ training runs for DE estimation of $2$-component triangle mixtures in $8$ dimensions. An example training run is depicted in \cref{fig:tirangle_mixture_expe} (right).
\subsection{Mutual Information Estimation}
\label{sec:synthetic_mi_estimation}
\paragraph{Multivariate Gauss} We repeat the experiments in~\citep{Cheng2020CLUB}, stepping up the MI $\MI(X^d; Y^d)$ between $d$ i.i.d.\ copies of joint normal random variables $(X,Y)$ by increasing their correlation coefficient, i.e., $(X,Y)$ are multivariate Gaussian with correlation coefficient $\rho_i$ in the $i$-th epoch.
A training run is depicted in the top of \cref{fig:mi_gauss}.
As in~\citep{Cheng2020CLUB}, we also repeat the experiment, applying a cubic transformation to $Y$. The estimation of MI between $d$ i.i.d.\ copies of $X$ and $Y^3$ can be observed in the middle row of \cref{fig:mi_gauss}. The MI is unaffected by this bijective transformation.
\begin{figure*}
\subcaptionbox*{}
{
\includegraphics[width=\textwidth]{plots/plot_gaussian/mi_est_Gaussian_False.pdf}}\vspace{-.5cm}
\subcaptionbox*{}
{\includegraphics[width=\textwidth]{plots/plot_gaussian/mi_est_Gaussian_True.pdf}}\vspace{-.5cm}
\subcaptionbox*{}
{\includegraphics[width=\textwidth]{plots/estimate_mi_uniform_d-20.pdf}}\vspace{-.5cm}
\caption{\textbf{Top}: Estimation of $\MI(X^d; Y^d)$, where $(X, Y)$ are multivariate Gaussian with correlation coefficient $\rho_i$ in the $i$-th epoch and $d=20$. \textbf{Middle}: Estimation of $\MI(X^d; (Y^3)^d)$. \textbf{Bottom}: Estimation of $\MI(X^d; Y^d)$ for uniform $(X, E)$ and $Y = \rho_i X + \sqrt{1-\rho_i^2}E$ in the $i$-th epoch.}
\label{fig:mi_gauss}
\end{figure*}
In \cref{sec:app:MI_estimation}, the bias and variance are depicted separately.
\paragraph{Sum of Uniformly Distributed Variables}
\label{sec:uniform}
In order to test the ability of {\textsc{Knife}} to adapt to distributions substantially different from the Gaussian kernel shape, we apply it in MI estimation of $\MI(X^d; Y^d)$ with uniformly distributed data. To this end, let $X$ and $E$ be centered, uniformly distributed random variables with $\mathbb E[X^2] = \mathbb E[E^2] = 1$ and define
$Y = \rho_i X + \sqrt{1-\rho_i^2}E$ in the $i$-th epoch. One training run with $d=20$ is shown in \cref{fig:mi_gauss} (bottom). Details about the source distribution as well as details of the experiments can be found in \cref{sec:app:MI_estimation}.
\section{Experiments on Natural Data}\label{sec:natural_data}
In this section, we benchmark our proposed {\textsc{Knife}}-based MI estimator on three practical applications, spanning textual and visual data. We reproduce and compare our method to the most recent MI estimators including MINE~\citep{mine}, NWJ~\citep{convex_risk_minimization}, InfoNCE~\citep{mi_nce}, CLUB~\citep{Cheng2020CLUB}, and {\textsc{DoE}}~\citep{pmlr-v108-mcallester20a}. We do not explicitly include the SMILE estimator~\citep{song2019understanding} in our comparison as it has the same gradient as NWJ.
\textbf{Common notation}: In all following applications, we will use $\Phi_{\boldsymbol{\psi}} \colon \mathcal{X} \rightarrow \mathcal{Z}$ to denote an encoder, where $\mathcal{X}$ is the raw input space (i.e., texts or images), and $\mathcal{Z}$ denotes a lower dimensional continuous feature space.
Additionally, we will use $C_{\boldsymbol{\psi}} \colon \mathcal{Z} \rightarrow \mathcal{Y}$ to denote a shallow classifier from the latent space $\mathcal{Z}$ to a discrete or continuous target space $\mathcal{Y}$ for classification or regression, respectively. We will use $\boldsymbol\psi$ to denote the parameters of both models, $\Phi_{\boldsymbol{\psi}}$ and $C_{\boldsymbol\psi}$. CE denotes the cross entropy loss.
\subsection{Information Bottleneck for Language Model Finetuning}
IB has recently been applied to fine-tune large-scale pretrained models \citep{mahabadi2021variational} such as BERT \citep{devlin2018bert} and aims at suppressing irrelevant features in order to reduce overfitting.
\paragraph{Problem statement.} Given a textual input $X \in \mathcal{X}$ and a target label $Y \in \mathcal{Y}$, the goal is to learn the encoder $\Phi_{\boldsymbol{\psi}}$ and classifier $C_{\boldsymbol{\psi}}$, such that $\Phi_{\boldsymbol{\psi}}(X)$ retains little information about $X$, while still producing discriminative features, allowing the prediction of $Y$. Thus, the loss of interest is:
\begin{equation}\label{eq:bottleneck}
\mathcal{L} = \lambda \cdot \underbrace{\MI(\Phi_{\boldsymbol{\psi}} (X);X)}_{\mathclap{\textrm{compression term}}} \;\;-\;\; \underbrace{\MI(\Phi_{\boldsymbol{\psi}}(X);Y)}_{\mathclap{\textrm{downstream term}}} ,
\end{equation} where $\lambda$ controls the trade-off between the downstream and the compression terms.
\paragraph{Setup.} Following \citep{mahabadi2021variational} (relying on VUB), we work with the VIBERT model, which uses a Gaussian distribution as prior.
$\Phi_{\boldsymbol{\psi}}$ is implemented as a stochastic encoder $\Phi_{\boldsymbol{\psi}} (X) = Z\sim \mathcal{N}(\mu_{\boldsymbol{\psi}}(X),\Sigma_{\boldsymbol{\psi}}(X))$. Details on the architecture of $\mu_{\boldsymbol{\psi}}$ and $\Sigma_{\boldsymbol{\psi}}$ can be found in \cref{sec:expdetailssupp}.
The classifier $C_{\boldsymbol{\psi}}$ is composed of dense layers. To minimize $\mathcal L$, the second part of the objective \cref{eq:bottleneck} is bounded using the variational bound from \citep{10.5555/2981345.2981371}. Since we use a Gaussian prior, $\Ent(Z|X)$ can be expressed in closed form.\footnote{$\Ent(Z|X) = \frac12\ln|\Sigma_{\boldsymbol{\psi}}(X)| + \frac{d}{2}\ln(2\pi e),$ where $d$ is the dimension of $X$ and $|\cdot|$ denotes the determinant.}
Thus, when using {\textsc{Knife}}, $\MI(X;Z)=\Ent(Z) - \Ent(Z|X)$ can be estimated by using $\widehat{\Ent}_{\textsc{Knife}}$ to estimate $\Ent(Z)$.
We compare this {\textsc{Knife}}-based MI estimator with aforementioned MI estimators and the variational upper bound (VUB).
For completeness, we also compare against a BERT model trained by direct minimization of a CE loss.
We closely follow the protocol of \citep{mahabadi2021variational} and work on the GLUE benchmark \citep{wang2018glue} originally composed of 5 datasets.
However, following \citep{mahabadi2021variational}, we choose to finetune neither on WNLI \citep{morgenstern2015winograd} nor on CoLA \citep{warstadt2019neural} due to reported flaws in these datasets.
The evaluation is carried out on the standard validation splits as the test splits are not available.
Following standard practice \citep{liu2019roberta,yang2019xlnet}, we report
the accuracy and the F1 for MRPC, the accuracy for RTE and the Pearson and Spearman correlation coefficient for STS-B.
\paragraph{Results.}
\cref{tab:result_glue} reports our results on the GLUE benchmark. We observe that {\textsc{Knife}} obtains the best results on all three datasets and the lowest variance on MRPC and STS-B. The use of a Gaussian prior in the stochastic encoder $\Phi_{\boldsymbol\psi}$ could explain the observed improvement of {\textsc{Knife}}-based estimation over MI-estimators such as CLUB, InfoNCE, MINE, \textsc{DoE}, or NWJ.
\begin{table}
\centering
\resizebox{0.45\textwidth}{!}{
\begin{tabular}{cccccc}
\toprule
& \multicolumn{2}{c}{MRPC} & \multicolumn{2}{c}{STS-B} & RTE\\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-6}
&
F1 &
Accuracy& Pearson&Spearman & Accuracy \\
\midrule
BERT
& \result{83.4}{0.9} &\result{88.2}{0.7} & \result{89.2}{0.4} & \result{88.8}{0.4} & \result{69.4}{0.4} \\
CLUB
& \result{85.0}{0.4} & \result{89.0}{0.7} & \result{89.7}{0.2} & \result{89.4}{0.1} & \result{70.7}{0.1} \\
InfoNCE
&\result{84.9}{0.8} & \result{88.9}{0.6} & \result{89.4}{0.4} & \result{89.7}{0.6} & \result{70.6}{0.1} \\
MINE
& \result{80.0}{2.5} & \result{85.0}{0.9} & \result{88.0}{0.7} & \result{88.0}{0.6} & \result{69.0}{0.9} \\
NWJ
& \result{84.6}{0.8} & \result{88.1}{0.7} & \result{89.8}{0.1} & \result{89.6}{0.2} & \result{69.6}{0.7} \\
VIBERT
& \result{85.1}{0.5} & \result{89.1}{0.3} &\result{90.0}{0.2} &\result{89.5}{0.3} & \result{70.9}{0.1} \\
{\textsc{DoE}}
& \result{84.1}{0.2} & \result{88.3}{0.2} &\result{89.6}{0.2} &\result{89.5}{0.2} & \result{69.6}{0.2} \\
{\textsc{Knife}} & \result{\textbf{85.3}}{0.1} & \result{\textbf{90.1}}{0.1} & \result{\textbf{90.3}}{0.0} & \result{\textbf{90.1}}{0.0} & \result{\textbf{72.3}}{0.2} \\
\bottomrule
\end{tabular}
} \caption{Fine-tuning on GLUE. Following \citep{lee2019mixout,dodge2020fine}, mean and variance are computed for 10 seeds. VIBERT is similar to VUB \citep{DBLP:journals/corr/AlemiFD016}.}\label{tab:result_glue}
\end{table}
\subsection{Fair Textual Classification}
In fair classification, we would like the model to take its decision without utilizing
private information such as gender, age,
or race.
For this task, MI can be minimized to disentangle the output of the encoder $Z$ and a private label $S \in \mathcal{S}$ (e.g., gender, age, or race).
\paragraph{Problem Statement.}
Given an input text $X$, a discrete target label $Y$ and a private label $S$, the loss is given by
\begin{equation}\label{eq:all_loss}
\mathcal{L} = \underbrace{\CE(Y; \Phi_{\boldsymbol{\psi}}(X)) }_{\textrm{downstream task}} + \lambda \cdot \underbrace{\MI(\Phi_{\boldsymbol{\psi}}(X);S)}_{\textrm{disentangled}},
\end{equation}
where $\lambda$ controls the trade-off between minimizing MI and CE loss. In this framework, a classifier is said to be fair or to achieve perfect privacy if no statistical information about $S$ can be extracted from $\Phi_{\boldsymbol{\psi}}(X)$ by an adversarial classifier.
Overall, a good model should achieve high accuracy on the main task (i.e., prediction of $Y$) while removing information about the protected attribute $S$. This information is measured by training an offline classifier to recover the protected attribute $S$ from $\Phi_{\boldsymbol{\psi}}(X)$.
\paragraph{Setup.}
We compute the second term of \cref{eq:all_loss} with competing MI estimators, as well as the model from \citep{elazar2018adversarial}, which will be referred to as ``{\text{Adv}}'',
as it utilizes an adversary to recover the private label from the latent representation $Z$.
For \textsc{Knife}-based MI estimation, we use two DE estimators (as $S$ is a binary label), following the approach outlined in \cref{sec:cond_mi}. All derivations are detailed in \cref{sec:expdetailssupp}.
\newline We follow the experimental setting from \citep{elazar2018adversarial,barrett2019adversarial} and use two datasets from the DIAL corpus \citep{blodgett2016demographic} (over 50 million tweets) where the protected attribute $S$ is the race and the main labels are sentiment or mention labels. The mention label indicates whether a tweet is conversational or not.
We follow the official split using $160\,000$ tweets for training and two additional sets composed of $10\,000$ tweets each for development and testing. In all cases, the labels $S$ and $Y$ are binary and balanced, thus a random guess corresponds to 50\% accuracy.
\paragraph{Results.} \cref{fig:fair_classification_main} gathers results on the fair classification task. The upper dashed lines represent the (private and main) task accuracies when training a model with only the $\CE$ loss (case $\lambda = 0$ in \cref{eq:all_loss}). This shows that the learned encoding $\Phi_{\boldsymbol{\psi}}(X)$
contains information about the protected attribute, when training is only performed for the main task.
On both the sentiment and mention task, we observe that a \textsc{Knife}-based estimator can achieve perfect privacy (see \cref{fig:fair_classification_private_sentiment,fig:fair_classification_private_mention}) with nearly no accuracy loss in the main task (see \cref{fig:fair_classification_main_sentiment,fig:fair_classification_main_mention}).
The other MI estimators exhibit different behavior. For sentiment labels, most MI estimators fail to reach perfect privacy (CLUB, NWJ, \textsc{DoE}, and {\text{Adv}}) while others (InfoNCE) achieve perfect privacy while degrading the main task accuracy (10\% loss on main accuracy).
For mention labels, CLUB can also reach perfect privacy with almost no degradation of the accuracy of the main task.
Overall, it is worth noting that {\textsc{Knife}}-based MI estimation enables better control of the degree of disentanglement than the reported baselines.
\begin{figure*}
\centering
\subcaptionbox{$Y$ (sentiment) \label{fig:fair_classification_main_sentiment}}
{\includegraphics[width=0.24\textwidth]{plots/plot_fair_classification/task_accuracy_sentiment.pdf}}\subcaptionbox{$S$ (sentiment) \label{fig:fair_classification_private_sentiment}}
{\includegraphics[width=0.24\textwidth]{plots/plot_fair_classification/attacker_accuracy_sentiment.pdf}
}\subcaptionbox{$Y$ (mention) \label{fig:fair_classification_main_mention}}
{\includegraphics[width=0.24\textwidth]{plots/plot_fair_classification/task_accuracy_mention.pdf}}
\subcaptionbox{$S$ (mention)\label{fig:fair_classification_private_mention}}{ \includegraphics[width=0.24\textwidth]{plots/plot_fair_classification/attacker_accuracy_mention.pdf}
}
\caption{Results on the fair classification task for both main (\cref{fig:fair_classification_main_sentiment,fig:fair_classification_main_mention}) and private task (\cref{fig:fair_classification_private_sentiment,fig:fair_classification_private_mention}) for both mention and sentiment labels. Results of MINE are not reported because of instabilities that prevent the network from converging.
\Cref{fig:fair_classification_private_sentiment,fig:fair_classification_private_mention} are obtained by training an offline classifier to recover the protected attribute $S$ from $\Phi_{\boldsymbol\psi}(X)$.}\label{fig:fair_classification_main}
\end{figure*}
\subsection{Unsupervised Domain Adaptation}
\begin{table*}\centering
\resizebox{0.7\textwidth}{!}{
\begin{tabular}{cccccccc}
\toprule
& M $\rightarrow$ MM & S $\rightarrow$ C & U $\rightarrow$ M & M $\rightarrow$ U & C $\rightarrow$ S & SV $\rightarrow$ M & Mean \\
\cmidrule{2-8}
Source only & \result{51.9}{0.8} & \result{58.3}{0.2} & \result{91.1}{0.7} & \result{93.5}{0.6} & \result{\textbf{72.3}}{0.5} & \result{54.7}{2.8} & \result{70.3}{0.9} \\
\midrule
\textsc{CLUB} & \result{79.1}{2.2} & \result{59.9}{1.9} & \result{96.0}{0.2} & \result{96.8}{0.5} & \result{71.6}{1.3} & \result{83.8}{3.4} & \result{81.2}{1.7} \\
{\textsc{DoE}} & \result{\textbf{82.2}}{2.6} & \result{58.9}{0.8} & \result{97.2}{0.3} & \result{94.2}{0.9} & \result{68.8}{1.4} & \result{86.4}{5.4} & \result{81.3}{1.9} \\
\textsc{InfoNCE} & \result{77.3}{0.5} & \result{61.0}{0.1} & \result{97.4}{0.2} & \result{97.0}{0.3} & \result{70.6}{0.8} & \result{89.2}{4.1} & \result{82.1}{1.0} \\
\textsc{MINE} & \result{76.7}{0.4} & \result{61.2}{0.3} & \result{\textbf{97.7}}{0.1} & \result{97.3}{0.1} & \result{70.8}{1.0} & \result{91.8}{0.8} & \result{82.6}{0.4} \\
\textsc{NWJ} & \result{77.1}{0.6} & \result{61.2}{0.3} & \result{97.6}{0.1} & \result{97.3}{0.5} & \result{72.1}{0.7} & \result{91.4}{0.8} & \result{82.8}{0.5} \\
{\textsc{Knife}} & \result{78.7}{0.7} & \result{\textbf{61.8}}{0.5} & \result{\textbf{97.7}}{0.3} & \result{\textbf{97.4}}{0.4} & \result{71.2}{1.8} & \result{\textbf{93.2}}{0.2} & \result{\textbf{83.4}}{0.6} \\
\bottomrule
\end{tabular}
}
\caption{Domain adaptation results: M (MNIST), MM (MNIST M), U (USPS), SV (SVHN), C (CIFAR10) and S (STL10). Results are averaged over 3 seeds.}
\label{tab:da_results}
\end{table*}
In unsupervised domain adaptation, the goal is to transfer knowledge from the source domain ($S$) with a potentially large number of labeled examples to a target domain ($T$), where only unlabeled examples are available.
\paragraph{Problem Statement.}
The learner is given access to labeled images from a source domain $(x_s, y) \sim (X_S,Y) \in \mathcal{X}_{S} \times \mathcal{Y}$ and unlabeled images from a target domain $x_t \sim X_T \in \mathcal{X}_{T}$. The goal is to learn a classification model $\{\Phi_{\boldsymbol{\psi}}, C_{\boldsymbol{\psi}}\}$ that generalizes well to the target domain.
Training models on the supervised source data only results in domain-specific latent representations $\Phi_{\boldsymbol{\psi}}(X)$ leading to poor generalization (when $X$ is chosen randomly from $\{X_S, X_T\}$).
In order to make the latent representations
as domain-agnostic as possible, we follow the information-theoretic method proposed by \citep{gholami2020unsupervised}, and used in \citep{Cheng2020CLUB}. The idea is to learn an additional binary model $\{\Phi^d_{\boldsymbol{\nu}}, C^d_{\boldsymbol{\nu}}\}$, whose goal it is to guess the domain $D \in \{0, 1\}$ of $X$.
The latent representation learned by $\Phi^d_{\boldsymbol{\nu}}$ will therefore contain all the domain-specific information that we would like the main encoder $\Phi_{\boldsymbol{\psi}}$ to discard.
In other words, we would like $\Phi_{\boldsymbol{\psi}}(X)$ and $\Phi^d_{\boldsymbol{\nu}}(X)$ to be completely disentangled, which naturally corresponds to the minimization of $\MI(\Phi_{\boldsymbol{\psi}}(X);\Phi^d_{\boldsymbol{\nu}}(X))$.
Concretely, the domain classifier is trained to minimize the $\CE$ between domain labels $D$ and its own predictions, whereas the main classifier is trained to properly classify support samples while minimizing the MI between $\Phi_{\boldsymbol{\psi}}(X)$ and $\Phi^d_{\boldsymbol{\nu}}(X)$. Using $f_{\boldsymbol{\nu}}^d \coloneqq C_{\boldsymbol{\nu}}^d \circ \Phi^d_{\boldsymbol{\nu}}$ and $f_{\boldsymbol{\psi}}\coloneqq C_{\boldsymbol{\psi}} \circ \Phi_{\boldsymbol{\psi}}$, the objectives are
\begin{align}
\label{eq:domaine}
\min_{{\boldsymbol{\nu}}} & ~ \CE(D; f_{\boldsymbol{\nu}}^d(X)) \; \text{and} \\
\min_{{\boldsymbol{\psi}}} & ~ \CE(Y; f_{{\boldsymbol{\psi}}}(X_S)) + \lambda \cdot \MI(\Phi_{\boldsymbol{\psi}}(X);\Phi_{\boldsymbol{\nu}}^d(X)).
\end{align}
\noindent\textbf{Setup.} The different MI estimators are compared based on their ability to guide training by estimating $\MI(\Phi_{\boldsymbol{\psi}}(X);\Phi^d_{\boldsymbol{\nu}}(X))$ in \cref{eq:domaine}. We follow the setup of \citep{Cheng2020CLUB} as closely as possible, and consider a total of 6 source/target scenarios formed with MNIST \citep{mnist}, MNIST-M \citep{mnist_m}, SVHN \citep{svhn}, CIFAR-10 \citep{cifar10}, and STL-10 \citep{stl10} datasets. We reproduce all methods and allocate the same budget for hyper-parameter tuning to every method. The exhaustive list of hyper-parameters can be found in \cref{sec:expdetailssupp}.
\noindent\textbf{Results.} Results are presented in \cref{tab:da_results}. The \textsc{Knife}-based estimator is able to outperform MI estimators in this challenging scenario where both $\Phi_{\boldsymbol{\psi}}(X)$ and $\Phi^d_{\boldsymbol{\nu}}(X)$ are continuous.
\section{Concluding Remarks}
We introduced {\textsc{Knife}}, a fully learnable, differentiable kernel-based estimator of differential entropy, designed for deep learning applications. We constructed a mutual information estimator based on {\textsc{Knife}} and showcased several applications. {\textsc{Knife}} is a general purpose estimator and does not require any special properties of the learning problem. It can thus be incorporated as part of any training objective, where differential entropy or mutual information estimation is desired. In the case of mutual information, one random variable may even be discrete.
Despite the fundamental challenges in the problem of differential entropy estimation, beyond limitations arising from the use of a finite number of samples, {\textsc{Knife}} has demonstrated promising empirical results in various representation learning tasks.
Future work will focus on improving the confidence bounds given in \cref{thm:convergence}. In particular, tailoring them towards {\textsc{Knife}} using tools from \citep{10.1214/aos/1176324452, NIPS2014_af5afd7f}. Another potential extension is direct estimation of the gradient of entropy, when $\hat p_{\textsc{Knife}}(x; \boldsymbol \theta)$ has been learned \citep{mohamed2020monte,song2020sliced}. This could be applied after the learning phase of {\textsc{Knife}} and is left for future work.
\section{Acknowledgements}
This work was granted access to the HPC resources of IDRIS under the allocation 2021-101838 made by GENCI.
\bibliographystyle{icml2022}
\section{A Learnable Lower Bound on the KL-Divergence}
\subsection{Basic Definitions and Preliminary Results}
We recall the definition of the total variation distance when applied to distributions $P$, $Q$ on a set $\mathcal{X}\subseteq \mathbb{R}^d $ and the Scheff\'e's identity, Lemma~2.1 in \cite{10.5555/1522486}:
\begin{equation}
\label{eq:scheffe}
\| p - q\|_\text{TV} =\frac12 \int |p({x})- q({x})|d\mu({x})
\end{equation}
with respect to a base measure $\mu$, where $\mathcal{B}^d$ denotes the class of all Borel sets on $\mathbb{R}^d$.
Let $T\in\{0,1\}$ be a binary random variable satisfying $\Pr(T=1)=\Pr(T=0)=1/2$ and let $p_{X|T=0} \triangleq p $ and $p_{X|T=1} \triangleq p_{\textsc{Knife}} $ which leads to a join pdf $p_{XT}$. We now relate the Bayesian error of the Bayes discriminator $\psi\,:\, \mathcal{X}\rightarrow \{0,1\}$ to the TV norm. The following identity holds:
\begin{align}
\frac12\Big[ 1- \big\| p_{X|T=1} -p_{X|T=0} \big\|_\text{TV}\Big] & = \frac12\int_{\mathcal{X}} \min\Big \{p_{X|T}({x}|0), p_{X|T}({x}|1) \Big\}d {x} \nonumber\\
& = \int_{\mathcal{X}} \min\Big \{p_{X T}({x}, 0), p_{XT}({x}, 1)\Big\} d{x} \nonumber\\
& = \mathbb{E} \left[ \min\Big \{P_{T|X}(0|{X}), P_{T|X}(1|{X}) \Big\} \right]\nonumber\\
& = \inf_{\psi\,:\, \mathcal{X}\rightarrow \{0,1\}} \, \Pr\left\{\psi({X})\neq T \right\},
\end{align}
where the last identity follow by the definition of the Bayes error. In other words, we have
\begin{align}
1-\| p - p_{\textsc{Knife}} \|_{\textrm{TV}} & = 2 \inf_{\psi\,:\, \mathcal{X}\rightarrow \{0,1\}} \, \Pr\left\{\psi({X})\neq T \right\}.
\label{identity-TV
\end{align}
On the other hand, it is not difficult to check that
\begin{align}
\| p - p_{\textsc{Knife}} \|_{\textrm{TV}} \leq \min\left\{ \sqrt{\frac12 \mathrm{D}_{\mathrm{KL}}(p \| \hat p_{\textsc{Knife}})}\, , \, 1 - \frac12 \exp\big( - \mathrm{D}_{\mathrm{KL}}(p \| \hat p_{\textsc{Knife}}) \big) \right\}, \label{bound-on-TV}
\end{align}
where the first inequality follows by Pinsker's inequality and the second inequality follows by applying Lemma~2.6 in \cite{10.5555/1522486} together with Le Cam's inequality in Lemma~2.3 in \cite{10.5555/1522486}.
By combining expressions \eqref{identity-TV} and \eqref{bound-on-TV}, we obtain two lower bounds on the KL-Divergence:
\begin{align}
\mathrm{D}_{\mathrm{KL}}(p \| \hat p_{\textsc{Knife}}) & \geq 2 \cdot \left(1 - 2 \inf_{\psi\,:\, \mathcal{X}\rightarrow \{0,1\}} \, \Pr\left\{\psi({X})\neq T \right\} \right)^2 \\
\mathrm{D}_{\mathrm{KL}}(p \| \hat p_{\textsc{Knife}}) & \geq -\log \left(4 \inf_{\psi\,:\, \mathcal{X}\rightarrow \{0,1\}} \, \Pr\left\{\psi({X})\neq T \right\} \right) .
\end{align}
Furthermore, for an arbitrary discriminator $f_{\mathcal{D}_N} \, : \, \mathcal{X}\rightarrow \{0,1\} $ it follows:
\begin{equation}
\inf_{\psi\,:\, \mathcal{X}\rightarrow \{0,1\}} \, \Pr\left\{\psi({X})\neq T \right\} \leq \Pr \left( f_{\mathcal{D}_n}(X) \neq T \right)
\end{equation}
and thus,
\begin{align}
\mathrm{D}_{\mathrm{KL}}(p \| \hat p_{\textsc{Knife}}) & \geq \min\left\{ 2 \left(1 - 2 \Pr \left( f_{\mathcal{D}_n}(X) \neq T \right) \right)^2 \ ,\,-\log \left[4 \Pr \left( f_{\mathcal{D}_n}(X) \neq T \right) \right] \right\}.
\end{align}
The previous inequalities can be used to estimate a lower bound on the KL-Divergence. However, the resulting bounds will not lead to differentiable expressions with respect to the samples of the Kernel and thus we will not take this approach.
\subsection{A Novel Lower-Bound on the KL-Divergence}
First, we recall that~\cite{feder1994}
\begin{equation}
\label{eq:feder}
\inf_{\psi\,:\, \mathcal{X}\rightarrow \{0,1\}} \, \Pr\left\{\psi({X})\neq T \right\} \leq \frac{1}{2} \frac{1}{\log 2} \ENT(T|X),
\end{equation}
which implies that the optimal Bayes error is bounded by the conditional entropy of $T$ given the data sample. For any arbitrary soft-prediction ${P_{\widehat{T}|X}}$ of $T$ based on the sample $X$ with parameters $\boldsymbol\theta$, we have that
\begin{equation}
\ENT(T|X) \leq \mathbb{E}~\big[-\log P_{\widehat{T}|X}(T|X;\boldsymbol\theta) \big],
\label{eq-entropy-T}
\end{equation}
which can be interpreted as being the cross-entropy of a binary classifier intending to discriminate between samples drawn from $p$ or $p_{\textsc{Knife}}$. By using inequalities \cref{eq-entropy-T,eq:feder,identity-TV}, we obtain
\begin{equation}
( 1-\| p - p_{\textsc{Knife}} \|_{\textrm{TV}} ) \log 2 \leq \mathbb{E}~\big[-\log P_{\widehat{T}|X}(T|X;\boldsymbol\theta) \big].
\end{equation}
The last inequality together with \eqref{bound-on-TV} yields:
\begin{equation}
\bigg( 1- \min\left\{ \sqrt{\frac12 \mathrm{D}_{\mathrm{KL}}(p \| \hat p_{\textsc{Knife}})}\, , \, 1 - \frac12 \exp\big( - \mathrm{D}_{\mathrm{KL}}(p \| \hat p_{\textsc{Knife}}) \big) \right\} \bigg) \log 2 \leq \mathbb{E}~\big[-\log P_{\widehat{T}|X}(T|X;\boldsymbol\theta) \big],
\end{equation}
which is equivalent to the following lower bounds on the KL-Divergence:
\begin{align}
\mathrm{D}_{\mathrm{KL}}(p \| \hat p_{\textsc{Knife}}) &\geq 2 \left(1 - \frac{1}{\log 2} \mathbb{E}~\big[-\log P_{\widehat{T}|X}(T|X;\boldsymbol\theta) \big] \right) \cdot
\left|1 - \frac{1}{\log 2} \mathbb{E}~\big[-\log P_{\widehat{T}|X}(T|X;\boldsymbol\theta) \big] \right|, \\
\mathrm{D}_{\mathrm{KL}}(p \| \hat p_{\textsc{Knife}}) & \geq -\log \frac{2}{\log 2} \mathbb{E}~\big[-\log P_{\widehat{T}|X}(T|X;\boldsymbol\theta) \big] \\
&= -\log 2 + \log\log2 - \log \mathbb{E}~\big[-\log P_{\widehat{T}|X}(T|X;\boldsymbol\theta) \big] .
\end{align}
\subsection{Boosting {\textsc{Knife}}}
Stemming from the observation that, by the Law of Large Numbers (LLN),
\begin{align} \label{eq:ce_bound-1}
\widehat \Ent_{\textsc{Knife-Boost}}(\mathcal D_{\mathrm{x}}; {\boldsymbol\theta}^\star, {\boldsymbol\theta})\, &\stackrel{\mathclap{\text{LLN}}}{\approx}
\,\mathbb{E}~\big[-\log\hat p_{\textsc{Knife}}(X; {\boldsymbol\theta}^\star) \big| T = 0\big] - 2 \left(1 - \frac{1}{\log 2} \mathbb{E}~\big[-\log P_{\widehat{T}|X}(T|X;\boldsymbol\theta) \big] \right)^2 \\
&\geq \mathbb{E}~\big[-\log\hat p_{\textsc{Knife}}(X; {\boldsymbol\theta}^\star)\big| T = 0\big] - \mathrm{D}_{\mathrm{KL}}(p \| \hat p_{\textsc{Knife}}(\,\cdot\,; {\boldsymbol\theta}^\star))\\
& = \Ent(X).
\end{align}
Similarly,
\begin{align} \label{eq:ce_bound-2}
\widehat \Ent_{\textsc{Knife-Boost}}(\mathcal D_{\mathrm{x}}; {\boldsymbol\theta}^\star, {\boldsymbol\theta}) &\stackrel{\text{LLN}}{\approx}
\mathbb{E}~\big[-\log\hat p_{\textsc{Knife}}(X; {\boldsymbol\theta}^\star)\big| T = 0\big] + \log 2 - \log\log 2 + \log \left( \mathbb{E}~\big[-\log P_{\widehat{T}|X}(T|X;\boldsymbol\theta) \big]\right) \\
&\geq \mathbb{E}~\big[-\log\hat p_{\textsc{Knife}}(X; {\boldsymbol\theta}^\star)\big| T = 0\big] - \mathrm{D}_{\mathrm{KL}}(p \| \hat p_{\textsc{Knife}}(\,\cdot\,; {\boldsymbol\theta}^\star))\\
& = \Ent(X).
\end{align}
It is important to note in these expressions, that the distribution $p_{T|X}(1|x;\boldsymbol\theta^\star) = p_{\textsc{Knife}}(x;\boldsymbol\theta^\star)$ does depend on $\boldsymbol\theta^\star$. During training, we will obtain a parameterized Function $\phi(x;\boldsymbol\theta) = P_{\widehat T|X}(1|x;\boldsymbol\theta)$, realized by, e.g., a DNN with parameters $\boldsymbol\theta$. We then need to approximate
\begin{align}
&-\mathbb{E}~\big[\log P_{\widehat{T}|X}(T|X;\boldsymbol\theta) \big] = -\mathbb{E}~\big[T \log\phi(X;\boldsymbol\theta) + (1-T) \log(1-\phi(X;\boldsymbol\theta)) \big] \\
&\qquad= -\frac{1}{2} \mathbb{E}_{X\sim p_{\textsc{Knife}}}~\big[\log\phi(X;\boldsymbol\theta)\big] - \frac{1}{2} \mathbb{E}_{X\sim p}~\big[\log(1-\phi(X;\boldsymbol\theta)) \big] \\
&\qquad= -\frac{1}{2} \int \log\phi(x;\boldsymbol\theta) p_{\textsc{Knife}}(\mathrm{d} x; \boldsymbol\theta^\star) - \frac{1}{2} \mathbb{E}_{X\sim p}~\big[\log(1-\phi(X;\boldsymbol\theta)) \big] \\
&\qquad\stackrel{\text{LLN}}= -\frac{1}{2} \int \log\phi(x;\boldsymbol\theta) p_{\textsc{Knife}}(\mathrm{d} x; \boldsymbol\theta^\star) - \frac{1}{2N} \sum_{n=1}^N \log(1-\phi(x_n;\boldsymbol\theta)) \\
&\qquad= -\frac{1}{2} \sum_i w_i \mathbb E_{G_i \sim \mathcal N(a_i, A_i)} [\log\phi(G_i;\boldsymbol\theta)] - \frac{1}{2N} \sum_{n=1}^N \log(1-\phi(x_n;\boldsymbol\theta))
\end{align}
Perhaps, a relaxed expression to jointly learn the parameters of the Kernel and the binary discriminator can be considered:
\begin{align}
({\boldsymbol\theta}^\star, \boldsymbol\theta ) = \arg\min_{(\boldsymbol\theta_0, \boldsymbol\theta_1)}\left\{ \mathbb{E}~\big[-\log\hat p_{\textsc{Knife}}(X; \boldsymbol \theta_0) \big| T=0\big] + \lambda\cdot \mathbb{E}~\big[-\log P_{\widehat{T}|X}(T|X;\boldsymbol\theta_1) \big] \right\},
\end{align}
for some convenient multiplier $\lambda\geq 0$. The idea would be to optimize the above expression and then evaluate it in expression \eqref{eq:ce_bound-1} or \eqref{eq:ce_bound-2} computed based on the other set of samples.
\subsection{Concluding Remark}
There are various other ways of bounding the error based on the misclassification error of an auxiliary discriminator. The idea is appealing since it may have an useful impact in the learning dynamic and in correcting the error between the cross-entropy and the differential entropy, which could be translated into better estimates.
\bibliographystyle{IEEEtran}
\section{{\textsc{Knife}} Estimator}
\subsection{Differential Entropy Estimation}
Our estimator builds on Parzen windowing, a kernel-based density estimation method~\cite{10.1214/aoms/1177704472}, where the resulting estimate is continuous and differentiable provided that the selected kernel is continuous and differentiable.
The simplest entropy estimator based on this idea, analyzed in~\cite{Ahmad1976Nonparametric}, uses the kernel estimator of density given by
\begin{equation}
\label{eq:kernel0}
\tilde p(x; w) = \frac{1}{M w} \sum_{m=1}^M \kappa\left( \frac{X_m - x}{w} \right),
\end{equation}
where $\mathcal D = (X_1,\dots,X_M) \sim p^M$ are i.i.d.\ training samples, $\kappa$ is the kernel density and $w > 0$ the bandwidth.
An estimate of differential entropy is obtained as
$\tilde h = -\frac{1}{N} \sum_{n=1}^N \log \tilde p(X'_n; w)$, where $\mathcal D' = (X'_1,\dots,X'_N) \sim p^N$ is a potentially seperate training set.
In \cite{Schraudolph2004Gradient}, this approach was generalized, by using the kernel estimator
\begin{equation}
\label{eq:schraudolph}
\hat p_{\text{Schrau.}}(x; \mathbf A) = \frac{1}{M} \sum_{m=1}^M \kappa_{A_m}(X_m - x) ,
\end{equation}
where $\mathbf A = (A_1,\dots,A_M)$ are (distinct) covariance matrices and $\kappa_A = \mathcal N(0, A)$ is a centered Gaussian density with covariance matrix $A$.
Our density estimator is an augmentation
\begin{equation}
\label{eq:knife}
\hat p_{\textsc{Knife}}(x; \boldsymbol \theta) = \sum_{m=1}^M u_m \kappa_{A_m}(X_m - x + a_m) ,
\end{equation}
where $\boldsymbol \theta = (\mathbf A, \mathbf a, \mathbf u)$ and the additional parameters $0 \le \mathbf u = (u_1, u_2, \dots, u_M)$ with $\mathbf 1 \cdot \mathbf u = 1$ and $\mathbf a = (a_1,\dots,a_M)$ are introduced.
Note that $\hat p_{\textsc{Knife}}(x; \boldsymbol \theta)$ is a smooth function of $\boldsymbol \theta$.
Thus, also the plug-in estimator
\begin{equation}
\label{eq:hat-h}
\hat \Ent_{\textsc{Knife}}(\mathcal D'; \boldsymbol\theta)
:= -\frac{1}{N} \sum_{X' \in \mathcal D'} \log \hat p_{\textsc{Knife}}(X'; \boldsymbol \theta)
= -\frac{1}{N} \sum_{n=1}^N \log \hat p_{\textsc{Knife}}(X'_n; \boldsymbol \theta)
\end{equation}
is a smooth function of $\boldsymbol\theta$.
Noting that
$-\mathbb{E}[\log\hat p_{\textsc{Knife}}(X; \boldsymbol \theta)] = \Ent(X) + \mathrm{D}_{\mathrm{KL}}(p || \hat p_{\textsc{Knife}}(\,\cdot\,;\boldsymbol \theta)) \ge \Ent(X)$,
we use a gradient descent algorithm (here we employ Adam~\cite{Kingma2014Adam}) to minimize \cref{eq:hat-h} in order to minimize the error given by the Kullback-Leibler divergence $\mathrm{D}_{\mathrm{KL}}(p || \hat p_{\textsc{Knife}}(\,\cdot\,;\boldsymbol \theta))$.
Incorporating the weights $u_m$ and shifts $a_m$ in the optimization enables the use of our estimator within a framework where the distribution of $X$ can change gradually.
Indeed, we will see in our synthetic experiments in Section~\ref{sec:ent-estimation} below that our estimator rapidly adapts to such changes.
In contrast, when setting $a_m=0$ and $u_m=1/M$ and not optimizing with respect to those parameters, we recover the kernel estimator \cref{eq:schraudolph} that cannot adapt sufficiently well.
We denote the associated entropy estimator as $\hat \Ent_{\text{Schrau.}}$.
\subsection{Conditional Differential Entropy and MI Estimation}
We can adapt {\textsc{Knife}} to estimate conditional differential entropy and MI. First, if $Y$ is a discrete random variable that can only take values in a relatively small finite set $\mathcal{Y}$, the conditional differential entropy $\Ent(X|Y)$ is given by
\begin{equation}
\Ent(X|Y) = \sum_{y\in \mathcal{Y}} p_Y(y) \Ent(X|Y=y).
\end{equation}
Here, we can split our data $\mathcal D' = ((X'_1, Y'_1),\dots,(X'_N, Y'_N))$ into subsets
$\mathcal D'_y = \{(X', Y') \in \mathcal D': Y'=y\}$,
estimate each of the entropies $\Ent(X|Y=y)$ separately, and get the estimation
\begin{equation}
\label{eq:hat-hxgivyeqy}
\Ent(X|Y) \approx \frac{1}{N} \sum_{y\in \mathcal{Y}} N_y \hat \Ent_{\textsc{Knife}}(\mathcal D'_y; \boldsymbol\theta_y)
\end{equation}
where $N_y$ denotes the number of samples in $\mathcal D'_y$.
If $Y$ is another continuous random variable,
one can use the identities
$\Ent(X|Y) = \Ent(X,Y) - \Ent(Y)$ and
$\MI(X;Y) = \Ent(X) - \Ent(X|Y)$, that hold if these quantities are finite.
However, estimation of the joint entropy $\Ent(X,Y)$ can be challenging because of the increased dimensionality.
Thus, we propose a different way to directly estimate $\Ent(X|Y)$.
Given training data $\mathcal D' = ((X'_1, Y'_1),\dots,(X'_N, Y'_N))$, we extend the kernel estimation \cref{eq:knife} to estimate the conditional pdf
\begin{equation}
\label{eq:cond_knife}
\hat p_{\textsc{Knife}}(x|y; \boldsymbol\theta)
= \hat p_{\textsc{Knife}}(x;\boldsymbol\theta(y))
= \sum_{m=1}^M u_m(y) \kappa_{A_m(y)}(X_m - x + a_m(y)),
\end{equation}
where the parameter vector $\boldsymbol\theta = \boldsymbol\theta(y)$ is now a function of the random input $Y$.
The same bound as for differential entropy estimation applies, given by
$-\mathbb E[\log\hat p_{\textsc{Knife}}(X|Y; \boldsymbol\theta)] = \Ent(X|Y) + \mathbb E\big[\mathrm{D}_{\mathrm{KL}}(p_{X|Y}(\,\cdot\,|Y) || \hat p_{\textsc{Knife}}(\,\cdot\, |Y; \boldsymbol\theta))\big]$.
Using artificial neural networks (NNs) with suitable input and output dimensions for $\boldsymbol\theta(x)$, we will thus minimize
\begin{equation}
\label{eq:hat-hxgivy}
\hat \Ent_{\textsc{Knife}}(\mathcal D'; \boldsymbol\theta)
:= -\frac{1}{N} \sum_{n=1}^N \log \hat p_{\textsc{Knife}}(X'_n; \boldsymbol \theta(Y'_n)),
\end{equation}
w.r.t.\ the parameters of the NN.
For MI estimation, we combine the estimation of $\Ent(X)$ following \cref{eq:mi_conditionnal} and $\Ent(X|Y)$, and obtain the estimator
\begin{equation}
\label{eq:hat-ixy}
\hat \MI_{\textsc{Knife}}(\mathcal D'; \boldsymbol\theta_0, \boldsymbol\theta_1)
:= -\frac{1}{N} \sum_{n=1}^N \big( \log\hat p_{\textsc{Knife}}(X'_n; \boldsymbol\theta_0) - \log \hat p_{\textsc{Knife}}(X'_n; \boldsymbol\theta_1(Y'_n))\big),
\end{equation}
that is optimized using the loss function
$\mathcal L = - \sum_{n=1}^N \big( \log\hat p_{\textsc{Knife}}(X'_n; \boldsymbol\theta_0) + \log \hat p_{\textsc{Knife}}(X'_n; \boldsymbol\theta_1(Y'_n))\big)$ w.r.t.\ $\boldsymbol\theta_0$ and the parameters of the NN $\boldsymbol\theta_1$.
|
{'timestamp': '2022-02-15T02:41:20', 'yymm': '2202', 'arxiv_id': '2202.06618', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06618'}
|
arxiv
|
\section*{Ethics Statement}
All authors of this work have read the ICLR code of ethics and commit to adhering to it. There is no ethical concern in this work.
\section*{Reproducibility Statement}
The code for reproducing our results in the experiment section can be found at \url{https://github.com/Crazy-Jack/Cl-InfoNCE}.
\section*{Acknowledgements}
The authors would like to thank the anonymous reviewers for helpful comments and suggestions. This work is partially supported by the National Science Foundation IIS1763562, IARPA
D17PC00340, ONR Grant N000141812861, Facebook PhD Fellowship, BMW, National Science Foundation awards 1722822 and 1750439, and National Institutes of Health awards R01MH125740, R01MH096951 and U01MH116925. Any opinions, findings, conclusions, or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the sponsors, and no official endorsement should be inferred.
\section{Method}
\label{sec:method}
\vspace{-1mm}
We present a two-stage approach to leverage the structural information from the auxiliary information for weakly-supervised representation learning. The first step (Section~\ref{subsec:cluster_construct}) clusters data according to auxiliary information, which we consider discrete attributes as the auxiliary information\footnote{Our approach generalizes to different types of auxiliary information. To help with clarity of the explanations, the paper focuses primarily on discrete attributes, but more details about other auxiliary information can be found in Appendix.}.
The second step (Section~\ref{subsec:cl-infonce}) presents our clustering InfoNCE (Cl-InfoNCE) objective, a contrastive-learning-based approach, to leverage the constructed clusters. We discuss the mathematical intuitions of our approach and include an information-theoretical characterization of the goodness of our learned representations. We also show that Cl-InfoNCE can specialize to recent self-supervised and supervised contrastive approaches.
For notations, we use the upper case (e.g., $X$) letter to denote the random variable and the lower case (e.g., $x$) to denote the outcome from the random variable.
\vspace{-1mm}
\subsection{Cluster Construction for Discrete Attributes}
\label{subsec:cluster_construct}
\input{fig_tex/cluster_construction}
\vspace{-1mm}
We consider discrete attributes as the auxiliary information. An example of such auxiliary information is binary indicators of attributes, such as ``short/long hair'', ``with/without sunglasses'' or ``short/long sleeves'', for human photos. We construct the clusters such that data within each cluster will have the same values for a set of attributes. In our running example, selecting hair and sunglasses as the set of attributes, the human photos with ``long hair'' and ``with sunglasses'' will form a cluster. Then, how we determine the set of attributes? First, we rank each attribute according to its entropy in the dataset. Note that if an attribute has high entropy, it means this attribute is distributed diversely. Then, we select the attributes with top-$k$ highest entropy, where $k$ is a hyper-parameter. The reason for this selection process is to make sure the selected attributes are informative. See Figure~\ref{fig:cluster_construction} for illustration.
\vspace{-1mm}
\subsection{Clustering InfoNCE (Cl-InfoNCE) Objective}
\label{subsec:cl-infonce}
\vspace{-1mm}
This section presents how we integrate the clustering information of data into the representation learning process. Recently, the contrastive approaches~\citep{chen2020simple,caron2020unsupervised} have attracted lots of attention for self-supervised and supervised representation learning. The goal is to learn similar representations for correlated data and dissimilar representations for uncorrelated data. To be more specific, the self-supervised setting (e.g., the InfoNCE objective~\citep{oord2018representation}) regards different views of the same data as correlated and distinct data as uncorrelated; the supervised setting (e.g., the supervised contrastive objective~\citep{khosla2020supervised}) regards the data with the same downstream label as correlated and the data with distinct labels as uncorrelated. Inspired by these methods, when performing weakly-supervised representation learning, we present to learn similar representations for data within the same cluster assignment, and vice versa. To this end, we extend from the self-supervised InfoNCE objective and introduce the clustering InfoNCE (Cl-InfoNCE) objective that takes the data clustering information into account.
With the alphabets $X$ and $Y$ denoting the representations from augmented data:
\begin{equation*}
\resizebox{\hsize}{!}{$X={\rm Feature\_Encoder\Big(Augmentation\_1\big(Data\_1\big)\Big)}\,\,{\rm and}\,\,Y={\rm Feature\_Encoder\Big(Augmentation\_2\big(Data\_2\big)\Big)}$}
\end{equation*}
and the alphabet $Z$ denoting the constructed clusters, we formulate Cl-InfoNCE as
\vspace{2mm}
\begin{definition}[Clustering-based InfoNCE (Cl-InfoNCE)]
\vspace{-1mm}
\begin{equation}
{\rm Cl-InfoNCE}:=\underset{f}{\rm sup}\,\,\mathbb{E}_{(x_i, y_i)\sim {\mathbb{E}_{z\sim P_Z}\big[P_{X|z}P_{Y|z}\big]}^{\otimes n}}\Big[ \,\frac{1}{n}\sum_{i=1}^n {\rm log}\,\frac{e^{f(x_i, y_i)}}{\frac{1}{n}\sum_{j=1}^n e^{f(x_i, y_j)}}\Big].
\label{eq:cl_infonce}
\end{equation}
\end{definition}
\vspace{-1mm}
$f(x,y)$ is any function that returns a scalar from the input $(x,y)$. As suggested by prior work~\citep{chen2020simple,he2020momentum}, we choose $f(x,y) = {\rm cosine}\big(g(x),g(y)\big) / \tau$ to be the cosine similarity between non-linear projected $g(x)$ and $g(y)$. $g(\cdot)$ is a neural network (also known as the projection head~\citep{chen2020simple,he2020momentum}) and $\tau$ is the temperature hyper-parameter. $\{(x_i, y_i)\}_{i=1}^n$ are $n$ independent copies of $(x,y)\sim \mathbb{E}_{z\sim P_Z}\big[P_{X|z}P_{Y|z}\big]$, where it first samples a cluster $z \sim P_Z$ and then samples $(x,y)$ pair with $x \sim P_{X|z}$ and $y \sim P_{Y|z}$. Furthermore, we call $(x_i,y_i)$ as the positively-paired data ($x_i$ and $y_i$ have the same cluster assignment) and $(x_i,y_j)$ ($i\neq j$) as the negatively-paired data ($x_i$ and $y_j$ have independent cluster assignment). Note that, in practice, the expectation in~\eqref{eq:cl_infonce} is replaced by the empirical mean of a batch of samples.
\vspace{-1mm}
\paragraph{Mathematical Intuitions.} Our objective is learning the representations $X$ and $Y$ (by updating the parameters in the $\rm Feature\_Encoder$) to maximize Cl-InfoNCE. At a colloquial level, the maximization pulls towards the representations of the augmented data within the same cluster and push away the representations of the augmented data from different clusters. At a information-theoretical level, we present the following:
\vspace{1.5mm}
\begin{theorem}[informal, Cl-InfoNCE maximization learns to include the clustering information]
\vspace{-1.5mm}
\begin{equation}
\begin{split}
& {\rm Cl-InfoNCE} \leq D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big) \leq H(Z) \\
{\rm and}\,\,& {\rm the\,\,equality\,\,holds\,\,only\,\,when \,\,} H(Z|X) = H(Z|Y) = 0,
\end{split}
\label{eq:max_resulting_repre}
\end{equation}
\vspace{-5mm}
\label{theo:max_resulting_repre}
\end{theorem}
where $H(Z)$ is the entropy of $Z$ and $H(Z|X)$ (or $H(Z|Y)$) are the conditional entropy of $Z$ given $X$ (or $Y$). Please find detailed derivations and proofs in Appendix.
The theorem suggests that Cl-InfoNCE has an upper bound $D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big)$, which measures the distribution divergence between the product of clustering-conditional marginal distributions (i.e., $\mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big]$) and the product of marginal distributions (i.e., $P_{X}P_{Y}$). We give an intuition for $D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big)$: if $D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big)$ is high, then we can easily tell whether $(x,y)$ have the same cluster assignment or not. The theorem also suggests that maximizing Cl-InfoNCE results in the representations $X$ and $Y$ including the clustering information $Z$ ($\because H(Z|X) = H(Z|Y) = 0$).
\vspace{-2mm}
\paragraph{Goodness of the Learned Representations.}
In Theorem~\ref{theo:max_resulting_repre}, we show that maximizing Cl-InfoNCE learns the representations ($X$ and $Y$) to include the clustering ($Z$) information. Therefore, to characterize how good is the learned representations by maximizing Cl-InfoNCE or to perform cross validation, we can instead study the relations between $Z$ and the downstream labels (denoting by $T$). In particular, we can use information-theoretical metrics such as the mutual information $I(Z;T)$ and the conditional entropy $H(Z|T)$ to characterize the goodness of the learned representations. $I(Z;T)$ measures how relevant the clusters and the labels, and $H(Z|T)$ measures how much redundant information in the clusters that are irrelevant to the labels.
For instance, we can expect good downstream performance for our auxiliary-information-infused representations when having high mutual information and low conditional entropy between the auxiliary-information-determined clusters and the labels. It is worth noting that, when $Z$ and $T$ are both discrete variables, computing $I(Z;T)$ and $H(Z|T)$ would be much easier than computing $I(X;T)$ and $H(X|T)$.
\vspace{-2mm}
\paragraph{Generalization of Recent Self-supervised and Supervised Contrastive Approaches.} Cl-InfoNCE (\eqref{eq:cl_infonce}) serves as an objective that generalizes to different levels of supervision according to how we construct the clusters ($Z$). When $Z=$ instance id (i.e., each cluster only contains one instance), $\mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big]$ specializes to $P_{XY}$ and Cl-InfoNCE specializes to the InfoNCE objective~\citep{oord2018representation}, which aims to learn similar representations for augmented variants of the same data and dissimilar representations for different data. InfoNCE is the most popular used self-supervised contrastive learning objective~\citep{chen2020simple,he2020momentum,tsai2021multiview}. When $Z=$ downstream labels, Cl-InfoNCE specializes to the objective described in {\em Supervised Contrastive Learning}~\citep{khosla2020supervised}, which aims to learn similar representations for data that are from the same downstream labels and vice versa. In our paper, the clusters $Z$ are determined by the auxiliary information, and we aim to learn similar representations for data sharing the same auxiliary information and vice versa. This process can be understood as weakly supervised contrastive learning.
To conclude, Cl-InfoNCE is a clustering-based contrastive learning objective.
By differing its cluster construction, Cl-InfoNCE interpolates among unsupervised, weakly supervised, and supervised representation learning.
\iffalse
\vspace{-3mm}
\paragraph{Comparison to Learning to Predict the Clusters Assignments.} An alternative way to leverage the data clustering information is learning to predict the cluster assignment ($Z$) from the representations ($X$ and $Y$).
This approach requires building an additional classifier between the representations and the cluster, and it will be inefficient to optimize this classifier when having a large number of clusters. The reason is that the number of the classifier's parameters is proportional to the number of clusters. As a comparison, Cl-InfoNCE contains no additional classifier, and hence it is computationally more efficient and can scale up with a large number of clusters. Last, the most used objective for learning to predict the clusters is the cross-entropy loss. And evidences~\citep{khosla2020supervised} show that, compared to the cross-entropy loss, the contrastive objective (e.g., our presented Cl-InfoNCE) is more robust to natural corruptions of data and stable to hyper-parameters and optimizers settings.
\vspace{-3mm}
\paragraph{Comparison to Contrastive Multi-view Coding with Auxiliary Information.} A direct way to leverage auxiliary information is treating auxiliary information as another view of data then adopting the contrastive multi-view coding (CMC) objective for representation learning. On the contrary, our method indirectly leverages auxiliary information. To be more precise, our method performs additional clustering construction according to the auxiliary information and then considers the Cl-InfoNCE objective to learn with the constructed clusters. We argue that modeling the clustering information can be easier than modeling the raw auxiliary information, especially when the auxiliary information is complex or high-dimensional.
\fi
\section{Introduction}
\label{sec:intro}
Self-supervised learning (SSL) designs learning objectives that use data's self-information but not labels. As a result, SSL empowers us to leverage a large amount of unlabeled data to learn good representations, and its applications span computer vision~\citep{chen2020simple,he2020momentum}, natural language processing~\citep{peters2018deep,devlin2018bert} and speech processing~\citep{schneider2019wav2vec,baevski2020wav2vec}. More than leveraging only data's self-information, this paper is interested in a weakly-supervised setting by assuming access to additional sources as auxiliary information for data, such as the hashtags as auxiliary attributes information for Instagram images. The auxiliary information can provide valuable but often noisy information. Hence, it raises a research challenge of how we can effectively leveraging useful information from auxiliary information.
We argue that a form of the valuable information provided by the auxiliary information is its implied data clustering information. For example, we can expect an Instagram image to be semantically more similar to the image with the same hashtags than those with different hashtags. Hence, our first step is constructing auxiliary-information-determined clusters. Specifically, we build data clusters such that the data from the same cluster have similar auxiliary information, such as having the same data auxiliary attributes. Then, our second step is to minimize the intra-cluster difference of the representations. Particularly, we present a contrastive approach - the clustering InfoNCE (Cl-InfoNCE) objective to learn similar representations for augmented variants of data within the same cluster and dissimilar representations for data from different clusters. To conclude, the presented two-stage approach leverages the structural information from the auxiliary information, then integrating the structural information into a contrastive representation learning process. See Figure~\ref{fig:illus} for an overview of our approach.
We provide the following analysis and observations to better understand our approach. First, we characterize the goodness of the Cl-InfoNCE-learned representations via the statistical relationships between the constructed clusters and the downstream labels. A resulting implication is that we can expect better downstream performance for our weakly-supervised representations when having i) higher mutual information between the labels and the auxiliary-information-determined clusters and ii) lower conditional entropy of the clusters given the labels. Second, Cl-InfoNCE generalizes recent contrastive learning objectives by changing the way to construct the clusters. In particular, when each cluster contains only one data point, Cl-InfoNCE becomes a conventional self-supervised contrastive objective (e.g., the InfoNCE objective~\citep{oord2018representation}). When the clusters are built using directly the labels, Cl-InfoNCE
becomes a supervised contrastive objective (e.g., the objective considered by~\citet{khosla2020supervised}). These generalizations imply that our approach (auxiliary-information-determined clusters + Cl-InfoNCE) interpolates between conventional self-supervised and supervised representation learning.
\input{fig_tex/illus}
We conduct experiments on learning visual representations using UT-zappos50K~\citep{yu2014fine}, CUB-200-2011~\citep{wah2011caltech}, Wider Attribute~\citep{li2016human} and ImageNet-100~\citep{russakovsky2015imagenet} datasets.
For the first set of experiments, we shall see how much improvement can the auxiliary information bring to us. We consider the {\em derivative} auxiliary information, which means the auxiliary information comes from the datasets: the discrete attributes from UT-zappos50K, CUB-200-2011, and Wider Attribute. We show that the auxiliary-information-infused weakly-supervised representations, compared to conventional self-supervised representation, have a much better performance on downstream tasks. We consider two baselines that also leverage auxiliary information: i) predicting the auxiliary-information-induced clusters with cross-entropy loss and ii) adopting the contrastive multi-view coding (CMC)~\citep{tian2020contrastive} method when treating auxiliary information as another view of data. Our approach consistently outperforms the cross-entropy method and performs better than the CMC method in most cases.
For the second set of experiments, we focus on the analysis of Cl-InfoNCE to study how well it works with unsupervised constructed clusters (K-means clusters). We find it achieves better performance comparing to the clustering-based self-supervised learning approaches, such as the Prototypical Contrastive Learning (PCL)~\citep{li2020prototypical} method. The result suggests that the K-means method + Cl-InfoNCE can be a strong baseline for the conventional self-supervised learning setting.
\section{Comparison with others related in literature}
\subsection{Experiments: Comparison with Weakly supervised contrastive learning\citep{zheng2021weakly} }
We would like to point out that a concurrent work \cite{zheng2021weakly} presented a similar idea on weakly-supervised contrastive learning in ICCV 2021. We would like to point out the reason it is a concurrent work with ours. \cite{zheng2021weakly} is made publicly available on 10/05/2021, which is the same day as the the paper submission deadline for ICLR’22. To be more precise, ICCV publicly released this paper on 10/05/2021, and the paper’s arxiv version and code are available on 10/10/2021. The zero time overlap suggests that our two works are independent and concurrent.
\paragraph{Similarity and Difference} We acknowledge that the two works share the similar idea of utilizing weak labels of data in contrastive learning. \cite{zheng2021weakly} motivates by preventing class collision during instance-wise contrastive learning (random data that belongs to the same category will possibly get falsely pushed away in instance-wise contrastive learning), and ours motivates by exploring the structural information of data within contrastive learning, followed by providing information-theoretic analysis to explain how different structural information can affect the learned representations. Task-wise \cite{zheng2021weakly} focuses on unsupervised (no access to data labels) and semi-supervised (access to a few data labels) representation learning, and ours focuses on weakly supervised (access to side information such as data attributes) and unsupervised representation learning. For the common unsupervised representation learning part, \cite{zheng2021weakly} presents to generate weak labels using connected components labeling process, and ours generates weak labels using K-means clustering.
\paragraph{Empirical Results} We observed that the performance on ImageNet-100 reported in [1] looks better than ours (79.77 \cite{zheng2021weakly} v.s. ours 77.9 Figure 5). However, the experimental settings differ a lot. First, the \textbf{datasets} are different despite the same name: \cite{zheng2021weakly} considers ImageNet-100 by selecting the first 100 class of the ILSVRC 2012 challenge, and we select a different set of 100 classes (details shown in the Appendix E). Second, the \textbf{batch size} is different: \cite{zheng2021weakly} considers 2048 , and ours considers 128. Third, the \textbf{projection heads in architecture} are different: \cite{zheng2021weakly} uses 2 projection heads (each with 4096 hidden units) with two objectives, one is for InfoNCE and the other is for the proposed Weakly Supervised Contrastive Learning loss; whereas ours uses one projection head with 2048 hidden units for Cl-InfoNCE objective only. Although our main experiments have demonstrated that Cl-InfoNCE alone can achieve competitive performance, we acknowledge that adding InfoNCE objective with an additional linear projection head would further improve the learned representation.
To fairly compare our Cl-InfoNCE loss with their proposed Weakly Supervised Contrastive objective, we add an additional head trained with InfoNCE along with our Cl-InfoNCE objective. Experiments are conducted on our version of ImageNet100 with the controlled set up: same network architecture of resnet50, same batch size of 384, same training epochs of 200, same projection head (2048-2048-128), the same optimizer and linear evaluation protocols, etc. Our Kmeans cluster number K is chosen to be 2500 via a grid search from $\{100, 1000, 2500, 5000, 10,000\}$. The results are shown below Table~\ref{tab:iccv-compare}.
\input{tbl_tex/iccv-compare}
From the results, we can see that the two methods’ performances are similar. Our work and theirs [1] are done independently and concurrently, and both works allow a broader understanding of weakly supervised contrastive learning.
\subsection{Experiments: Comparison with IDFD~\citep{tao2021clustering} }
IDFD~\citep{tao2021clustering} presents to learn representations that are clustering friendly (from a spectral clustering viewpoint) during the instance discrimination (ID) contrastive learning process. Although it includes both ideas of clustering and contrastive learning, IDFD~\citep{tao2021clustering} differs from our paper fundementally because they does not utilize the constructed clusters as weak labels to train contrastive objective. However, IDFD~\citep{tao2021clustering} can still be considered as a self-supervised representation learning method, hence we perform experiments to compare our unsupervised setting (Cl-InfoNCE + Kmeans method) with their proposed IDFD on CIFAR10 Dataset~\citep{krizhevsky2009learning}. To provide a fair comparison with IDFD~\citep{tao2021clustering}, we stick to the training paradigm of IDFD where they replaces Resnet-50 with Resnet-18. The batch size of 128 is used following their report. Since IDFD~\citep{tao2021clustering} was focusing on clustering quality and didn't report the linear evaluation protocol, we use the released code of IDFD~\citep{tao2021clustering} to re-train the model meanwhile using both the cluster accuracy and the linear evaluation protocal as evaluation metrics. We train both methods for 1000 epochs for a fair comparison. The results are presented in Table~\ref{tb:iclr-comparison}.
\input{tbl_tex/iclr-comparison}
Note that \citep{tao2021clustering} proposed 2 methods (IDFD and IDFO), we choose the compare with IDFD because \textbf{(i)} IDFO is very unstable, \textbf{(ii)} IDFD/IDFO perform at-par for the best performance based on Figure2 in \citep{tao2021clustering} and \textbf{(iii)} \citep{tao2021clustering} only officially releases code for IDFD. We can observe that our method exceeds IDFD on in terms of top-1 classification accuracy during linear evaluation and also improve the raw clustering accuracy score, indicating integrating weak labels from unsupervised clustering with contrastive objectives would help both representation learning and the unsupervised clustering task.
}
\section{Data's Hierarchy Information as Auxiliary Information}
\label{sec:hierarchy}
\input{fig_tex/wordnet_wrap}
In the main text, we select the discrete attributes as the auxiliary information of data, then presenting data cluster construction according to the discrete attributes. We combine the constructed clusters and the presented Cl-InfoNCE objective together for learning weakly-supervised representations. In this section, we study an alternative type of the auxiliary information - data labels' hierarchy information, more specifically, the WordNet hierarchy~\citep{miller1995wordnet}, illustrated in the right figure. In the example, we present the WordNet hierarchy of the label ``Henslow's Sparrow'', where only the WordNet hierarchy would be seen during training but not the label.
\subsection{Cluster Construction for WordNet Hierarchy}
\label{subsec:cluster_hier}
How do we construct the data clusters according to the WordNet hierarchy? In the above example, ``vertebrate'' and ``bird'' can be seen as the coarse labels of data. We then construct the clusters such that data within each cluster will have the same coarse label. Now, we explain how we determine which coarse labels for the data. First, we represent the WordNet hierarchy into a tree structure (each children node has only one parent node).
Then, we choose the coarse labels to be the nodes in the level $l$ in the WordNet tree hierarchy (the root node is level $1$). $l$ is a hyper-parameter. We illustrate the process in the below figure.
\includegraphics[width=1.0\textwidth]{fig/wordnet_cluster_illus.pdf}
\subsection{Experiments: Data-Hierarchy-Determined Clusters + Cl-InfoNCE}
\label{subsec:hierarchy_exp}
The experimental setup and the comparing baselines are similar to Section 4.3 in the main text, but now we consider the WordNet~\citep{miller1995wordnet} hierarchy as the auxiliary information. As discussed in prior subsection, we construct the clusters $Z$ such that the data within a cluster have the same parent node in the level $l$ in the data's WordNet tree hierarchy. $l$ is the hyper-parameter\footnote{Note that we do not compare with the CMC method for fair comparisons with other method. The reason is that the CMC method will leverage the entire tree hierarchy, instead of a certain level in the tree hierarchy.}.
\vspace{-2mm}
\paragraph{Results.} Figure~\ref{fig:hierarchy} presents our results. First, we look at the leftmost plot, and we have several similar observations when having the data attributes as the auxiliary information. One of them is that our approach consistently outperforms the auxiliary-information-determined clusters + cross-entropy loss. Another of them is that the weakly supervised representations better close the gap with the supervised representations. Second, as discussed in prior subsection, the WordNet data hierarchy clusters can be regarded as the coarse labels of the data. Hence, when increasing the hierarchy level $l$, we can observe the performance improvement (see the leftmost plot) and the increasing mutual information $I(Z;T)$ (see the middle plot) between the clusters $Z$ and the labels $T$. Note that $H(Z|T)$ remains zero (see the rightmost plot) since the coarse labels (the intermediate nodes) can be determined by the downstream labels (the leaf nodes) under the tree hierarchy structure. Third, we discuss the conventional self-supervised setting with the special case when $Z=$ instanced ID. $Z$ as the instance ID has the highest $I(Z;T)$ (see the middle plot) but also the highest $H(Z|T)$ (see the rightmost plot). And we observe that the conventional self-supervised representations perform the worse (see the leftmost plot). We conclude that, when using clustering-based representation learning approaches, we shall not rely purely on the mutual information between the data clusters and the downstream labels to determine the goodness of the learned representations. We shall also take the redundant information in the clusters into account.
\input{fig_tex/hierarchy}
\section{Theoretical Analysis}
In this section, we provide theoretical analysis on the presented Cl-InfoNCE objective. We recall the definition of Cl-InfoNCE and our presented theorem:
\begin{definition}[Clustering-based InfoNCE (Cl-InfoNCE), restating Definition 3.1 in the main text]
\begin{equation*}
{\rm Cl-InfoNCE}:=\underset{f}{\rm sup}\,\,\mathbb{E}_{(x_i, y_i)\sim {\mathbb{E}_{z\sim P_Z}\big[P_{X|z}P_{Y|z}\big]}^{\otimes n}}\Big[\,\frac{1}{n}\sum_{i=1}^n {\rm log}\,\frac{e^{f(x_i, y_i)}}{\frac{1}{n}\sum_{j=1}^n e^{f(x_i, y_j)}}\Big],
\end{equation*}
\label{defn:cl-infonce-2}
\end{definition}
\begin{theorem}[informal, Cl-InfoNCE maximization learns to include the clustering information, restating Theorem 3.2 in the main text]
\begin{equation*}
\begin{split}
& {\rm Cl-InfoNCE} \leq D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big) \leq H(Z) \\
{\rm and}\,\,& {\rm the\,\,equality\,\,holds\,\,only\,\,when \,\,} H(Z|X) = H(Z|Y) = 0.
\end{split}
\end{equation*}
\label{theo:max_resulting_repre_2}
\end{theorem}
Our goal is to prove Theorem~\ref{theo:max_resulting_repre_2}. For a better presentation flow, we split the proof into three parts:
\begin{itemize}
\item Proving ${\rm Cl-InfoNCE} \leq D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big)$ in Section~\ref{subsec:proof_a}
\item Proving $D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big) \leq H(Z)$ in Section~\ref{subsec:proof_b}
\item Proving ${\rm Cl-InfoNCE} {\rm \,\,maximizes\,\,at\,\,} H(Z) {\rm \,\,when \,\,} H(Z|X) = H(Z|Y) = 0$ in Section~\ref{subsec:proof_c}
\end{itemize}
\subsection{Part I - Proving ${\rm Cl-InfoNCE} \leq D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big)$}
\label{subsec:proof_a}
The proof requires the following lemma.
\begin{lemma}[Theorem 1 by~\citet{song2020multi}] Let $\mathcal{X}$ and $\mathcal{Y}$ be the sample spaces for $X$ and $Y$, $f$ be any function: $(\mathcal{X} \times \mathcal{Y}) \rightarrow \mathbb{R}$, and $\mathcal{P}$ and $\mathcal{Q}$ be the probability measures on $\mathcal{X} \times \mathcal{Y}$. Then,
$$
\underset{f}{\rm sup}\,\,\mathbb{E}_{(x, y_1)\sim \mathcal{P}, (x, y_{2:n})\sim \mathcal{Q}^{\otimes (n-1)}}\Big[ {\rm log}\,\frac{e^{f(x, y_1)}}{\frac{1}{n}\sum_{j=1}^n e^{f(x, y_j)}}\Big] \leq D_{\rm KL} \Big( \mathcal{P} \,\|\, \mathcal{Q} \Big).
$$
\label{lemm:infonce_like}
\end{lemma}
\iffalse
\begin{lemma}[\citet{nguyen2010estimating}] Let $\mathcal{X}$ and $\mathcal{Y}$ be the sample spaces for $X$ and $Y$, $f$ be any function: $(\mathcal{X} \times \mathcal{Y}) \rightarrow \mathbb{R}$, and $\mathcal{P}$ and $\mathcal{Q}$ be the probability measures on $\mathcal{X} \times \mathcal{Y}$. Then,
$$
D_{\rm KL} \Big( \mathcal{P} \,\|\, \mathcal{Q} \Big) = \underset{f}{\rm sup} \,\mathbb{E}_{(x, y)\sim\mathcal{P}} [f(x,y)] - \mathbb{E}_{(x, y)\sim\mathcal{Q}} [e^{f(x,y)}] + 1.
$$
\begin{proof}
The second-order functional derivative of the objective is $-e^{f(x,y)}\cdot d\mathcal{Q}$, which is always negative. The negative second-order functional derivative implies the objective has a supreme value.
Then, take the first-order functional derivative and set it to zero:
\begin{equation*}
d \mathcal{P} - e^{f(x,y)}\cdot d \mathcal{Q} = 0.
\end{equation*}
We then get optimal $f^*(x,y) = {\rm log}\,\frac{d\mathcal{P}}{d\mathcal{Q}}$. Plug in $f^*(x,y)$ into the objective, we obtain
\begin{equation*}
\mathbb{E}_{\mathcal{P}} [f^*(x,y)] - \mathbb{E}_{\mathcal{Q}} [e^{f^*(x,y)}] + 1 = \mathbb{E}_{\mathcal{P}} [{\rm log}\,\frac{d\mathcal{P}}{d\mathcal{Q}}] = D_{\rm KL} \Big( \mathcal{P} \,\|\, \mathcal{Q} \Big).
\end{equation*}
\end{proof}
\label{lemm:kl}
\end{lemma}
\begin{lemma}
$
\underset{f}{\rm sup}\,\,\mathbb{E}_{(x, y_1)\sim \mathcal{P}, (x, y_{2:n})\sim \mathcal{Q}^{\otimes (n-1)}}\Big[ {\rm log}\,\frac{e^{f(x, y_1)}}{\frac{1}{n}\sum_{j=1}^n e^{f(x, y_j)}}\Big] \leq D_{\rm KL} \Big( \mathcal{P} \,\|\, \mathcal{Q} \Big).
$
\begin{proof}
From Lemma~\ref{lemm:kl}, $\forall f$, we have
\begin{equation*}
\small
\begin{split}
D_{\rm KL} \Big( \mathcal{P} \,\|\, \mathcal{Q} \Big) & = \mathbb{E}_{(x, y_{2:n})\sim \mathcal{Q}^{\otimes (n-1)}}\Bigg[D_{\rm KL} \Big( \mathcal{P} \,\|\, \mathcal{Q} \Big) \Bigg]
\\
& \geq \,\mathbb{E}_{(x, y_{2:n})\sim \mathcal{Q}^{\otimes (n-1)}}\Bigg[ \mathbb{E}_{(x, y_1)\sim \mathcal{P}} \Big[ {\rm log}\,\frac{e^{f(x, y_1)}}{\frac{1}{n}\sum_{j=1}^n e^{f(x, y_j)}} \Big] - \mathbb{E}_{(x, y_1)\sim \mathcal{Q}} \Big[ \frac{e^{f(x, y_1)}}{\frac{1}{n}\sum_{j=1}^n e^{f(x, y_j)}} \Big] + 1 \Bigg] \\
& = \mathbb{E}_{(x, y_{2:n})\sim \mathcal{Q}^{\otimes (n-1)}}\Bigg[ \mathbb{E}_{(x, y_1)\sim \mathcal{P}} \Big[ {\rm log}\,\frac{e^{f(x, y_1)}}{\frac{1}{n}\sum_{j=1}^n e^{f(x, y_j)}} \Big] - 1 + 1 \Bigg] \\
& = \mathbb{E}_{(x, y_1)\sim \mathcal{P}, (x, y_{2:n})\sim \mathcal{Q}^{\otimes (n-1)}}\Big[ {\rm log}\,\frac{e^{f(x, y_1)}}{\frac{1}{n}\sum_{j=1}^n e^{f(x, y_j)}}\Big].
\end{split}
\end{equation*}
The first line comes from the fact that $D_{\rm KL} \Big( \mathcal{P} \,\|\, \mathcal{Q} \Big)$ is a constant. The second line comes from Lemma~\ref{lemm:kl}. The third line comes from the fact that $(x, y_1)$ and $(x, y_{2:n})$ are interchangeable when they are all sampled from $\mathcal{Q}$.
To conclude, since the inequality works for all $f$, and hence the supreme is also less than $D_{\rm KL} \Big( \mathcal{P} \,\|\, \mathcal{Q} \Big)$.
\end{proof}
\label{lemm:infonce_like}
\end{lemma}
Note that Lemma~\ref{lemm:infonce_like} does not require $n \rightarrow \infty$, which is a much more practical setting compared to the analysis made only when $n\rightarrow \infty$. And a remark is that the equality holds in Lemma~\ref{lemm:infonce_like} when $n\rightarrow \infty$.
\fi
Now, we are ready to prove the following lemma:
\begin{lemma}[Proof Part I]
$
{\rm Cl-InfoNCE}:=\underset{f}{\rm sup}\,\,\mathbb{E}_{(x_i, y_i)\sim {\mathbb{E}_{z\sim P_Z}\big[P_{X|z}P_{Y|z}\big]}^{\otimes n}}\Big[\,\frac{1}{n}\sum_{i=1}^n {\rm log}\,\frac{e^{f(x_i, y_i)}}{\frac{1}{n}\sum_{j=1}^n e^{f(x_i, y_j)}}\Big] \leq D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big).
$
\begin{proof}
By defining $\mathcal{P} = \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big]$ and $\mathcal{Q} = P_XP_Y$, we have
$$
\mathbb{E}_{(x, y_1)\sim \mathcal{P}, (x, y_{2:n})\sim \mathcal{Q}^{\otimes (n-1)}}\Big[ {\rm log}\,\frac{e^{f(x, y_1)}}{\frac{1}{n}\sum_{j=1}^n e^{f(x, y_j)}}\Big] = \mathbb{E}_{(x_i, y_i)\sim {\mathbb{E}_{z\sim P_Z}\big[P_{X|z}P_{Y|z}\big]}^{\otimes n}}\Big[\,\frac{1}{n}\sum_{i=1}^n {\rm log}\,\frac{e^{f(x_i, y_i)}}{\frac{1}{n}\sum_{j=1}^n e^{f(x_i, y_j)}}\Big].
$$
Plug in this result into Lemma~\ref{lemm:infonce_like} and we conclude the proof.
\end{proof}
\label{lemm:part_a}
\end{lemma}
\subsection{Part II - Proving $D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big) \leq H(Z)$}
\label{subsec:proof_b}
The proof requires the following lemma:
\begin{lemma}
$
D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big) \leq {\rm min}\,\Big\{{\rm MI}(Z;X), {\rm MI}(Z;Y)\Big\}.
$
\begin{proof}
\begin{equation*}
\begin{split}
& {\rm MI}(Z;X) - D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big) \\
= & \int_z p(z) \int_x p(x|z) \,\,{\rm log}\,\,\frac{p(x|z)}{p(x)} {\rm d}x {\rm d}z - \int_z p(z) \int_x p(x|z) \int_y p(y|z) \,\,{\rm log}\,\,\frac{\int_{z'}p(z')p(x|z')p(y|z'){\rm d}z'}{p(x)p(y)} {\rm d}x {\rm d}y {\rm d}z \\
= & \int_z p(z) \int_x p(x|z) \,\,{\rm log}\,\,\frac{p(x|z)}{p(x)} {\rm d}x {\rm d}z - \int_z p(z) \int_x p(x|z) \int_y p(y|z) \,\,{\rm log}\,\,\frac{\int_{z'}p(z'|y)p(x|z'){\rm d}z'}{p(x)} {\rm d}x {\rm d}y {\rm d}z \\
= & \int_z p(z) \int_x p(x|z) \int_y p(y|z) \,\,{\rm log}\,\,\frac{p(x|z)}{\int_{z'}p(z'|y)p(x|z'){\rm d}z'}{\rm d}x {\rm d}y {\rm d}z \\
= & - \int_z p(z) \int_x p(x|z) \int_y p(y|z) \,\,{\rm log}\,\,\frac{\int_{z'}p(z'|y)p(x|z'){\rm d}z'}{p(x|z)}{\rm d}x {\rm d}y {\rm d}z \\
\geq & - \int_z p(z) \int_x p(x|z) \int_y p(y|z) \,\,\Bigg(\frac{\int_{z'}p(z'|y)p(x|z'){\rm d}z'}{p(x|z)} - 1\Bigg){\rm d}x {\rm d}y {\rm d}z \,\,\Big(\because {\rm log}\,t \leq t-1 \Big) \\
= &\,\, 0.
\end{split}
\end{equation*}
Hence, ${\rm MI}(Z;X) \geq D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big)$. Likewise, ${\rm MI}(Z;Y) \geq D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big)$. We complete the proof by combining the two results.
\end{proof}
\label{lemm:less_than_mi}
\end{lemma}
Now, we are ready to prove the following lemma:
\begin{lemma}[Proof Part II]
$D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big) \leq H(Z).$
\begin{proof}
Combining Lemma~\ref{lemm:less_than_mi} and the fact that ${\rm min}\,\Big\{{\rm MI}(Z;X), {\rm MI}(Z;Y)\Big\} \leq H(Z)$, we complete the proof. Note that we consider $Z$ as the clustering assignment, which is discrete but not continuous. And the inequality holds for the discrete $Z$, but may not hold for the continuous $Z$.
\end{proof}
\label{lemm:part_b}
\end{lemma}
\subsection{Part III - Proving ${\rm Cl-InfoNCE} {\rm \,\,maximizes\,\,at\,\,} H(Z) {\rm \,\,when \,\,} H(Z|X) = H(Z|Y) = 0$}
\label{subsec:proof_c}
We directly provide the following lemma:
\begin{lemma}[Proof Part III]
${\rm Cl-InfoNCE} {\rm \,\,max.\,\,at\,\,} H(Z) {\rm \,\,when \,\,} H(Z|X) = H(Z|Y) = 0.$
\begin{proof}
When $H(Z|Y) = 0$, $p(Z|Y=y)$ is Dirac. The objective
\begin{equation*}
\begin{split}
& D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big) \\
= & \int_z p(z) \int_x p(x|z) \int_y p(y|z) \,\,{\rm log}\,\,\frac{\int_{z'}p(z')p(x|z')p(y|z'){\rm d}z'}{p(x)p(y)} {\rm d}x {\rm d}y {\rm d}z \\
= & \int_z p(z) \int_x p(x|z) \int_y p(y|z) \,\,{\rm log}\,\,\frac{\int_{z'}p(z'|y)p(x|z'){\rm d}z'}{p(x)} {\rm d}x {\rm d}y {\rm d}z \\
= & \int_z p(z) \int_x p(x|z) \int_y p(y|z) \,\,{\rm log}\,\,\frac{\int_{z'}p(z')p(x|z')p(y|z'){\rm d}z'}{p(x)p(y)} {\rm d}x {\rm d}y {\rm d}z \\
= & \int_z p(z) \int_x p(x|z) \int_y p(y|z) \,\,{\rm log}\,\,\frac{p(x|z)}{p(x)} {\rm d}x {\rm d}y {\rm d}z = {\rm MI}\Big( Z;X\Big).
\end{split}
\end{equation*}
The second-last equality comes with the fact that: when $p(Z|Y=y)$ is Dirac, $p(z'|y) = 1 \,\,\forall z' = z$ and $p(z'|y) = 0 \,\,\forall z' \neq z$. Combining with the fact that ${\rm MI}\Big( Z;X\Big) = H(Z)$ when $H(Z|X)=0$, we know
$D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big) = H(Z) $ when $H(Z|X)=H(Z|Y)=0$.
Furthermore, by Lemma~\ref{lemm:part_a} and Lemma~\ref{lemm:part_b}, we complete the proof.
\end{proof}
\label{lemm:part_c}
\end{lemma}
\subsection{Bringing Everything Together}
We bring Lemmas~\ref{lemm:part_a},~\ref{lemm:part_b}, and~\ref{lemm:part_c} together and complete the proof of Theorem~\ref{theo:max_resulting_repre_2}.
\section{Algorithms}
In this section, we provide algorithms for our experiments. We consider two sets of the experiments. The first one is K-means clusters + Cl-InfoNCE (see Section 4.4 in the main text), where the clusters involved in Cl-InfoNCE are iteratively obtained via K-means clustering on top of data representations. The second one is auxiliary-information-determined clusters + Cl-InfoNCE (see Section 4.3 in the main text and Section~\ref{subsec:hierarchy_exp}), where the clusters involved in Cl-InfoNCE are pre-determined accordingly to data attributes (see Section 4.3 in the main text) or data hierarchy information (see Section~\ref{subsec:hierarchy_exp}).
\paragraph{K-means clusters + Cl-InfoNCE}
We present here the algorithm for K-means clusters + Cl-InfoNCE. At each iteration in our algorithm, we perform K-means Clustering algorithm on top of data representations for obtaining cluster assignments. The cluster assignment will then be used in our Cl-InfoNCE objective.
\begin{algorithm}[H]
\SetAlgoLined
\KwResult{Pretrained Encoder $f_{\theta}(\cdot)$}
$f_{\theta}(\cdot)\leftarrow \text{Base Encoder Network}$\;
Aug $(\cdot)\leftarrow$ Obtaining Two Variants of Augmented Data via Augmentation Functions\;
Embedding $\leftarrow$ Gathering data representations by passing data through $f_{\theta}(\cdot)$\;
Clusters $\leftarrow$\textbf{K-means-clustering}(Embedding)\;
\For {epoch in 1,2,...,N}{
\For{batch in 1,2,...,M}{
data1, data2 $\leftarrow$ Aug(data\_batch)\;
feature1, feature2 $\leftarrow$ $f_{\theta}$(data1), $f_{\theta}$(data2)\;
$L_{\text{Cl-infoNCE}}\leftarrow$ Cl-InfoNCE(feature1, feature2, Clusters)\;
$f_{\theta} \leftarrow f_{\theta} - lr * \frac{\partial}{\partial \theta}L_{\text{Cl-infoNCE}}$\;
}
Embedding $\leftarrow$ gather embeddings for all data through $f_{\theta}(\cdot)$\;
Clusters $\leftarrow$\textbf{K-means-clustering}(Embedding)\;
}
\caption{K-means Clusters + Cl-InfoNCE}
\end{algorithm}
\paragraph{Auxiliary information determined clusters + Cl-InfoNCE}
We present the algorithm to combine auxiliary-information-determined clusters with Cl-InfoNCE. We select data attributes or data hierarchy information as the auxiliary information, and we present their clustering determining steps in Section 3.1 in the main text for discrete attributes and Section~\ref{subsec:cluster_hier} for data hierarchy information.
\begin{algorithm}[H]
\SetAlgoLined
\KwResult{Pretrained Encoder $f_{\theta}(\cdot)$}
$f_{\theta}(\cdot)\leftarrow \text{Base Encoder Network}$\;
Aug $(\cdot)\leftarrow$ Obtaining Two Variants of Augmented Data via Augmentation Functions\;
Clusters $\leftarrow$Pre-determining Data Clusters from \textbf{Auxiliary Information}\;
\For {epoch in 1,2,...,N}{
\For{batch in 1,2,...,M}{
data1, data2 $\leftarrow$ Aug(data\_batch)\;
feature1, feature2 $\leftarrow$ $f_{\theta}$(data1), $f_{\theta}$(data2)\;
$L_{\text{Cl-infoNCE}}\leftarrow$ Cl-InfoNCE(feature1, feature2, Clusters)\;
$f_{\theta} \leftarrow f_{\theta} - lr * \frac{\partial}{\partial \theta}L_{\text{Cl-infoNCE}}$\;
}
}
\caption{Pre-Determined Clusters + Cl-InfoNCE}
\end{algorithm}
\section{Experimental details}
The following content describes our experiments settings in details. For reference, our code is available at \url{https://github.com/Crazy-Jack/Cl-InfoNCE/README.md}.
\subsection{UT-Zappos50K}
The following section describes the experiments we performed on UT-Zappos50K dataset in Section 4 in the main text.
\paragraph{Accessiblity}
The dataset is attributed to \citep{yu2014fine} and available at the link: \url{http://vision.cs.utexas.edu/projects/finegrained/utzap50k}. The dataset is for non-commercial use only.
\paragraph{Data Processing}
The dataset contains images of shoe from Zappos.com. We rescale the images to $32\times 32$. The official dataset has 4 large categories following 21 sub-categories. We utilize the 21 subcategories for all our classification tasks. The dataset comes with 7 attributes as auxiliary information. We binarize the 7 discrete attributes into 126 binary attributes. We rank the binarized attributes based on their entropy and use the top-$k$ binary attributes to form clusters. Note that different $k$ result in different data clusters (see Figure 4 (a) in the main text).
\textit{Training and Test Split}: We randomly split train-validation images by $7:3$ ratio, resulting in $35,017$ train data and $15,008$ validation dataset.
\paragraph{Network Design}
We use ResNet-50 architecture to serve as a backbone for encoder. To compensate the 32x32 image size, we change the first 7x7 2D convolution to 3x3 2D convolution and remove the first max pooling layer in the normal ResNet-50 (See code for detail). This allows finer grain of information processing. After using the modified ResNet-50 as encoder, we include a 2048-2048-128 Multi-Layer Perceptron (MLP) as the projection head \Big(i.e., $g(\cdot)$ in $f(\cdot, \cdot)$ equation (1) in the main text\Big) for Cl-InfoNCE. During evaluation, we discard the projection head and train a linear layer on top of the encoder's output. For both K-means clusters + Cl-InfoNCE and auxiliary-information-determined clusters + Cl-InfoNCE, we adopt the same network architecture, including the same encoder, the same MLP projection head and the same linear evaluation protocol. In the K-means + Cl-InfoNCE settings, the number of the K-means clusters is $1,000$. Kmeans clustering is performed every epoch during training. We find performing Kmeans for every epoch benefits the performance. For fair comparsion, we use the same network architecture and cluster number for PCL.
\paragraph{Optimization}
We choose SGD with momentum of $0.95$ for optimizer with a weight decay of $0.0001$ to prevent network over-fitting. To allow stable training, we employ a linear warm-up and cosine decay scheduler for learning rate. For experiments shown in Figure 4 (a) in the main text, the learning rate is set to be $0.17$ and the temperature is chosen to be $0.07$ in Cl-InfoNCE. And for experiments shown in Figure 5 in the main text, learning rate is set to be $0.1$ and the temperature is chosen to be $0.1$ in Cl-InfoNCE.
\paragraph{Computational Resource}
We conduct experiments on machines with 4 NVIDIA Tesla P100. It takes about 16 hours to run 1000 epochs of training with batch size 128 for both auxiliary information aided and unsupervised Cl-InfoNCE.
\subsection{Wider Attributes}
The following section describes the experiments we performed on Wider Attributes dataset in Section 4 in the main text.
\paragraph{Accessiblity}
The dataset is credited to \citep{li2016human} and can be downloaded from the link: \url{http://mmlab.ie.cuhk.edu.hk/projects/WIDERAttribute.html}. The dataset is for public and non-commercial usage.
\paragraph{Data Processing}
The dataset contains $13,789$ images with multiple semantic bounding boxes attached to each image. Each bounding is annotated with $14$ binary attributes, and different bounding boxes in an image may have different attributes. Here, we perform the OR operation among the attributes in the bounding boxes in an image. Hence, each image is linked to $14$ binary attributes. We rank the 14 attributes by their entropy and use the top-$k$ of them when performing experiments in Figure 4 (b) in the main text. We consider a classification task consisting of $30$ scene categories.
\textit{Training and Test Split}: The dataset comes with its training, validation, and test split. Due to a small number of data, we combine the original training and validation set as our training set and use the original test set as our validation set. The resulting training set contains $6,871$ images and the validation set contains $6,918$ images.
\paragraph{Computational Resource}
To speed up computation, on Wider Attribute dataset we use a batch size of $40$, resulting in 16-hour computation in a single NVIDIA Tesla P100 GPU for $1,000$ epochs training.
\paragraph{Network Design and Optimization}
We use ResNet-50 architecture as an encoder for Wider Attributed dataset. We choose 2048-2048-128 MLP as the projection head \Big(i.e., $g(\cdot)$ in $f(\cdot, \cdot)$ equation (1) in the main text\Big) for Cl-InfoNCE. The MLP projection head is discarded during the linear evaluation protocol. Particularly, during the linear evaluation protocol, the encoder is frozen and a linear layer on top of the encoder is fine-tuned with downstream labels. For Kmeans + Cl-InfoNCE and Auxiliary information + Cl-InfoNCE, we consider the same architectures for the encoder, the MLP head and the linear evaluation classifier. For K-means + Cl-InfoNCE, we consider $1,000$ K-means clusters. For fair comparsion, the same network architecture and cluster number is used for experiments with PCL.
For Optimization, we use SGD with momentum of $0.95$. Additionally, $0.0001$ weight decay is adopted in the network to prevent over-fitting. We use a learning rate of $0.1$ and temperature of $0.1$ in Cl-InfoNCE for all experiments. A linear warm-up following a cosine decay is used for the learning rate scheduling, providing a more stable learning process.
\subsection{CUB-200-2011}
The following section describes the experiments we performed on CUB-200-2011 dataset in Section 4 in the main text.
\paragraph{Accessiblity}
CUB-200-2011 is created by \citet{wah2011caltech} and is a fine-grained dataset for bird species. It can be downloaded from the link: \url{http://www.vision.caltech.edu/visipedia/CUB-200-2011.html}. The usage is restricted to non-commercial research and educational purposes.
\paragraph{Data Processing}
The original dataset contains $200$ birds categories over $11,788$ images with $312$ binary attributes attached to each image. We utilize those attributes and rank them based on their entropy, excluding the last $112$ of them (resulting in $200$ attributes), because including these $112$ attributes will not change the number of the clusters than not including them. In Figure 4 (c), we use the top-$k$ of those attributes to constrcut clusters with which we perform in Cl-InfoNCE. The image is rescaled to $224\times 224$.
\textit{Train Test Split}:
We follow the original train-validation split, resulting in $5,994$ train images and $5,794$ validation images.
\paragraph{Computational Resource}
It takes about 8 hours to train for 1000 epochs with 128 batch size on 4 NVIDIA Tesla P100 GPUs.
\paragraph{Network Design and Optimization}
We choose ResNet-50 for CUB-200-2011 as the encoder. After extracting features from the encoder, a 2048-2048-128 MLP projection head \Big(i.e., $g(\cdot)$ in $f(\cdot, \cdot)$ equation (1) in the main text\Big) is used for Cl-InfoNCE. During the linear evaluation protocal, the MLP projection head is removed and the features extracted from the pre-trained encoder is fed into a linear classifier layer. The linear classifier layer is fine-tuned with the downstream labels. The network architectures remain the same for both K-means clusters + Cl-InfoNCE and auxiliary-information-determined clusters + Cl-InfoNCE settings. In the K-means clusters + Cl-InfoNCE settings, we consider $1,000$ K-means clusters. For fair comparsion, the same network architecture and cluster number is used for experiments with PCL.
SGD with momentum of $0.95$ is used during the optimization. We select a linear warm-up following a cosine decay learning rate scheduler. The peak learning rate is chosen to be $0.1$ and the temperature is set to be $0.1$ for both K-means + Cl-InfoNCE and Auxiliary information + Cl-InfoNCE settings.
\subsection{ImageNet-100}
The following section describes the experiments we performed on ImageNet-100 dataset in Section 4 in the main text.
\paragraph{Accessibility}
This dataset is a subset of ImageNet-1K dataset, which comes from the ImageNet Large Scale Visual Recognition Challenge (ILSVRC) 2012-2017 \citep{russakovsky2015imagenet}. ILSVRC is for non-commercial research and educational purposes and we refer to the ImageNet official site for more information: \url{https://www.image-net.org/download.php}.
\paragraph{Data Processing}
In the Section 4 in the main text and Section~\ref{sec:hierarchy}, we select $100$ classes from ImageNet-1K to conduct experiments (the selected categories can be found in \url{https://github.com/Crazy-Jack/Cl-InfoNCE/data_processing/imagenet100/selected_100_classes.txt}). We also conduct a slight pre-processing (via pruning a small number of edges in the WordNet graph) on the WordNet hierarchy structure to ensure it admits a tree structure. Specifically, each of the selected categories and their ancestors only have one path to the root. We refer the pruning procedure in \url{https://github.com/Crazy-Jack/Cl-InfoNCE/data_processing/imagenet100/hierarchy_processing/imagenet_hierarchy.py} (line 222 to 251).
We cluster data according to their common ancestor in the pruned tree structure and determine the level $l$ of each cluster by the step needed to traverse from root to that node in the pruned tree. Therefore, the larger the $l$, the closer the common ancestor is to the real class labels, hence more accurate clusters will be formed. Particularly, the real class labels is at level $14$.
\textit{Training and Test Split}:
Please refer to the following file for the training and validation split.
\begin{itemize}
\item training: \url{https://github.com/Crazy-Jack/Cl-InfoNCE/data_processing/imagenet100/hier/meta_data_train.csv}
\item validation: \url{https://github.com/Crazy-Jack/Cl-InfoNCE/data_processing/imagenet100/hier/meta_data_val.csv}
\end{itemize}
The training split contains $128,783$ images and the test split contains $5,000$ images. The images are rescaled to size $224\times 224$.
\paragraph{Computational Resource}
It takes $48$-hour training for $200$ epochs with batch size $128$ using $4$ NVIDIA Tesla P100 machines. All the experiments on ImageNet-100 is trained with the same batch size and number of epochs.
\paragraph{Network Design and Optimization Hyper-parameters}
We use conventional ResNet-50 as the backbone for the encoder. 2048-2048-128 MLP layer and $l2$ normalization layer is used after the encoder during training and discarded in the linear evaluation protocal. We maintain the same architecture for Kmeans + Cl-InfoNCE and auxiliary information aided Cl-InfoNCE. For Kmeans + Cl-InfoNCE, we choose 2500 as the cluster number. For fair comparsion, the same network architecture and cluster number is used for experiments with PCL. The Optimizer is SGD with $0.95$ momentum. For K-means + Cl-InfoNCE used in Figure 5 in the main text, we use the learning rate of $0.03$ and the temperature of $0.2$. We use the learning rate of $0.1$ and temperature of $0.1$ for auxiliary information + Cl-InfoNCE in Figure~\ref{fig:hierarchy}. A linear warm-up and cosine decay is used for the learning rate scheduling. To stablize the training and reduce overfitting, we adopt $0.0001$ weight decay for the encoder network.
\section{Comparisons with Swapping Clustering Assignments between Views}
In this section, we provide additional comparisons between Kmeans + Cl-InfoNCE and Swapping Clustering Assignments between Views (SwAV)~\citep{caron2020unsupervised}. The experiment is performed on ImageNet-100 dataset. SwAV is a recent art for clustering-based self-supervised approach. In particular, SwAV adopts Sinkhorn algorithm~\citep{cuturi2013sinkhorn} to determine the data clustering assignments for a batch of data samples, and SwAV also ensures augmented views of samples will have the same clustering assignments. We present the results in Table~\ref{tab:swav}, where we see SwAV has similar performance with the Prototypical Contrastive Learning method~\citep{li2020prototypical} and has worse performance than our method (i.e., K-means +Cl-InfoNCE).
\begin{table}[h]
\centering
\scalebox{0.8}{
\begin{tabular}{cc}
\toprule
Method & Top-1 Accuracy (\%) \\ \midrule \midrule \multicolumn{2}{c}{\it Non-clustering-based Self-supervised Approaches} \\ \midrule \midrule
SimCLR~\citep{chen2020simple} & 58.2$\pm$1.7 \\ [1mm]
MoCo~\citep{he2020momentum} & 59.4$\pm$1.6 \\ \midrule \midrule \multicolumn{2}{c}{\it Clustering-based Self-supervised Approaches (\# of clusters = $2.5$K)} \\ \midrule \midrule
SwAV~\citep{caron2020unsupervised} & 68.5$\pm$1.0 \\ [1mm]
PCL~\citep{li2020prototypical} & 68.9$\pm$0.7 \\ [1mm]
K-means + Cl-InfoNCE (ours) & \textbf{77.9$\pm$0.7} \\ \bottomrule
\end{tabular}
}
\vspace{1mm}
\caption{Additional Comparsion with SwAV~\citep{caron2020unsupervised} showing its similar performance as PCL on ImageNet-100 dataset.}
\label{tab:swav}
\end{table}
\section{Preliminary results on ImageNet-1K with Cl-InfoNCE}
We have performed experiments on ImageNet-100 dataset, which is a subset of the ImageNet-1K dataset \citep{russakovsky2015imagenet}. We use the batch size of $1,024$ for all the methods and consider $100$ training epochs. We present the comparisons among Supervised Contrastive Learning~\citep{khosla2020supervised}, our method (i.e., WordNet-hierarchy-information-determined clusters + Cl-InfoNCE), and SimCLR~\citep{chen2020simple}. We select the level-$12$ nodes in the WordNet tree hierarchy structures as our hierarchy-determined clusters for Cl-InfoNCE. We report the results in Table~\ref{tab:imagenet-1K}. We find that our method (i.e., hierarchy-determined clusters + Cl-InfoNCE) performs in between the supervised representations and conventional self-supervised representations.
\input{tbl_tex/imgnet1k}
\section{Synthetically Constructed Clusters in Section 4.2 in the Main Text}
In Section 4.2 in the main text, on the UT-Zappos50K dataset, we synthesize clusters $Z$ for various $I(Z;T)$ and $H(Z|T)$ with $T$ being the downstream labels. There are $86$ configurations of $Z$ in total. Note that the configuration process has no access to data's auxiliary information and among the $86$ configurations we consider the special cases for the supervised \big($Z=T$\big) and the unsupervised setting \big($Z=$ instance ID\big). In specific, when $Z=T$, $I(Z;T)$ reaches its maximum at $H(T)$ and $H(Z|T)$ reaches its minimum at $0$; when $Z=$ instance ID, both $I(Z;T)$ \big(to be $H(T)$\big) and $H(Z|T)$ \big(to be $H(\text{instance ID})$\big) reaches their maximum. The code for generating these $86$ configurations can be found in lines 177-299 in \url{https://github.com/Crazy-Jack/Cl-InfoNCE/data_processing/UT-zappos50K/synthetic/generate.py}.
\iffalse
by the procedures described below to varying $Z$ artificially with different $I(Z;T)$ and $H(Z|T)$, resulting in 86 different configurations of $Z$ and then evaluate their resulted representation quality following the common linear evaluation protocol. The linear evaluation results is shown in Figure 3.
\paragraph{Synthetizing Protocal}
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{fig/ICLR_fig.pdf}
\caption{Synthesising protocol demo. $x_i$ denotes each data instance, $t_i$ denotes downstream class labels and $z_i^{(level)}$ denotes clusters in the first setting where we control $I(Z;T)$ to its maximumn $H(T)$. And $S_i^{(level)}$ are superclasses of the downstream task labels $t_i$ and represents the $Z$ in the second setting. }
\label{fig:synthetic-protocol}
\end{figure}
To intepolate between fully supervised and unsupervised setting, we form synthesised $Z$ to illustrate the relationship between $Z$ and $T$. Figure~\ref{fig:synthetic-protocol} shows a toy example of how we construct the $Z$. Suppose $\{x_1, x_2, ..., x_n\}$ denotes every instance and $\{t_1, t_2, ..., t_k\}$ denotes different downstream class labels, then the key of constructing covariates are performing certain level of grouping. We consider three settings:
\paragraph{(1)} Control $I(Z;T)$ to its maximum. $I(Z;T)$ reach its maximum $H(T)$ when $P(T|Z)=1$, which means that instances assigned to a specific $Z$ have the same downstream task labels. Following this intuition, we form $z_i^{(level)}$ as subclasses of the downstream classes. We vary $level$ to transit from SimCLR to SupCon.
\paragraph{(2)} Control $H(Z|T)$ to its minimum 0. $H(Z|T)$ reach its minimum 0 if $P(Z|T)=1$, which suggests we can create $Z$ as superclasses of $T$. As shown in Figure~\ref{fig:synthetic-protocol}, we create $S_i^{(level)}$ as different $Z$ and vary $level$ to get different $Z$ with various $I(Z;T)$ value.
\paragraph{(3)} For each $level$ in setting \textbf{(1)}, we keep the subclasses of certain set of downstream classs $T_f=\{t_i, t_j, t_m, ...\}$ and permutate other $z_j^{(level)}$ assignment. Take $level=2$ for example, if we fix the subclasses of $T_f=\{t_1\}$, instance assigned to $\{z_1^{(2)}, z_2^{(2)}, z_3^{(2)}, z_4^{(2)}\}$ is untouched (i.e. the cluster assignment of $\{x_1, x_2, ..., x_8\}$ remain the same) and we randomly permutate instance assigned to $\{z_5^{(2)}, z_6^{(2)}, ..., z_{16}^{(2)}\}$ (for example $x_9$ may be reassigned to $z_6^{(2)}$ or $z_{13}^{(2)}$ instead of $z_5^{(2)}$). As we increase $|T_f|$, we get $Z$ with various $I(Z;T)$ and $H(Z|T)$ that spans the most of the information plane. This construction of $Z$ leads us to efficiently illustrate how the relationship between $Z$ and $T$ reflects the learnt representation's quality (As shown in Figure 3).
\fi
\end{appendices}
\section{Conclusion and Discussions}
\label{sec:conclu}
\vspace{-2mm}
In this paper, we introduce the clustering InfoNCE (Cl-InfoNCE) objective that leverages the implied data clustering information from {\color{black}auxiliary information or data itself }for learning weakly-supervised representations. {\color{black} Our method effectively brings the performance closer to the supervised learned representations compared to the conventional self-supervised learning approaches, therefore improving pretraining quality when limited information is at hand. In terms of limitation, our approach requires clustering based on auxiliary information or data itself. This process sometimes could pose additional computational cost. In addition, clustering on auxiliary information or data will also lose precision. Tackling these problems would be our further research direction.}
\section{Related Work}
\label{sec:rela}
\vspace{-1mm}
\paragraph{Self-supervised Learning.} Self-supervised learning (SSL) defines a pretext task as a pre-training step and uses the pre-trained features for a wide range of downstream tasks, such as object detection and segmentation in computer vision~\citep{chen2020simple,he2020momentum}, question answering, and language understanding in natural language processing~\citep{peters2018deep,devlin2018bert} and automatic speech recognition in speech processing~\citep{schneider2019wav2vec,baevski2020wav2vec}. In this paper, we focus on discussing two types of pretext tasks: clustering approaches~\citep{caron2018deep,caron2020unsupervised} and contrastive approaches~\citep{chen2020simple,he2020momentum}.
The clustering approaches jointly learn the networks' parameters and the cluster assignments of the resulting features. For example, the cluster assignments can be obtained through unsupervised clustering methods such as k-means~\citep{caron2018deep}, or the optimal transportation algorithms such as Sinkhorn algorithm~\citep{caron2020unsupervised}. It is worth noting that the clustering approaches enforce consistency between cluster assignments for different augmentations of the same data. The contrastive approaches learn similar representations for augmented variants of a data and dissimilar representations for different data. Examples of contrastive approaches include the InfoNCE objective~\citep{oord2018representation,chen2020simple,he2020momentum}, Wasserstein Predictive Coding~\citep{ozair2019wasserstein}, and Relative Predictive Coding~\citep{tsai2021self}. Both the clustering and the contrastive approaches aim to learn representations that are invariant to data augmentations.
There is another line of work combining clustering and contrastive approaches, such as HUBERT~\citep{hsu2020hubert}, Prototypical Contrastive Learning~\citep{li2020prototypical} and Wav2Vec~\citep{schneider2019wav2vec,baevski2020wav2vec}. They first construct (unsupervised) clusters from the data. Then, they perform a contrastive approach to learn similar representations for the data within the same cluster. Our approach relates to these work with two differences: 1) we construct the clusters from the auxiliary information; and 2) we present Cl-InfoNCE as a new contrastive approach and characterize the goodness for the resulting representations. Recent works like IDFD~\citep{tao2021clustering} aim to achieve better unsupervised clustering by using contrastive learning representations.
However, \citet{tao2021clustering} differs from our work in that they don't directly incorporate auxiliary information into contrastive objectives.
\vspace{-2mm}
\paragraph{Weakly-supervised Learning with Auxiliary Information.}
Our study relates to work on {\color{black}prediction using auxiliary information, by treating the auxiliary information as weak labels~\citep{sun2017revisiting,mahajan2018exploring,wen2018disjoint,radford2021learning,tan2019learning}}. The weak labels can be hashtags of Instagram images~\citep{mahajan2018exploring}, metadata such as identity and nationality of a person~\citep{wen2018disjoint} or corresponding textual descriptions for images~\citep{radford2021learning}. Compared to normal labels, the weak labels are noisy but require much less human annotation work. Surprisingly, it has been shown that the network learned with weakly supervised pre-training tasks can generalize well to various downstream tasks, including object detection and segmentation, cross-modality matching, and action recognition~\citep{mahajan2018exploring,radford2021learning}. The main difference between these works and ours is that our approach does not consider a prediction objective but a contrastive learning objective (i.e., the Cl-InfoNCE objective). {\color{black}An independent and concurrent work~\citep{zheng2021weakly} also incorporates weak labels into the contrastive learning objective.
However, our method differs from \citet{zheng2021weakly} by the the way we construct the weak labels. We perform clustering on the annotative attributes or unsupervised k-means to obtain weak labels
whereas they employ connected components labeling process. Task-wise, \citep{zheng2021weakly} focuses on unsupervised (no access to data labels) and semi-supervised (access to a few data labels) representation learning, and ours focuses on weakly-supervised (access to side information such as data attributes) and unsupervised representation learning. For the common unsupervised representation learning part, we include a comparison with their method in the Appendix.}
Another way to learn from auxiliary information is using multi-view contrastive coding (CMC)~\citep{tian2020contrastive} where auxiliary information is treated as another view of the data. Specifically, CMC learns representations that can capture the joint information between the data and the accompanying auxiliary information. The main difference between CMC and our approach is that CMC leverages auxiliary information directly and Cl-InfoNCE leverages it indirectly (i.e., our approach pre-processes auxiliary information by clustering it).
\subsection{Technical Background}
Contrastive learning~\citep{bachman2019learning,chen2020simple,he2020momentum} has shown its effectiveness in unsupervised representation learning, where its goal is to learn similar representations for the positively-paired (correlated) instances and dissimilar representations for the negatively-paired (uncorrelated) instances. For example, \citet{bachman2019learning,chen2020simple,he2020momentum} treat the positively-paired instances as distorted variations of the same image (e.g., the same image with different augmentations) and the negatively-paired instances as two distinct images. For another example, \citet{radford2021learning,tsai2021multiview} treat the positively-paired instances as the cross-modality pair of an instance (e.g., image and its captions) and the negatively-paired instances as pairs consisting of a random image paired with the captions of another random image. Probabilistically, we refer the positively-paired representations from the data as the representations sampled from their joint distributions (i.e., $(x,y)\sim P_{X,Y}$) and the negatively-paired representations as the representations sampled from the product of marginal distributions (i.e., $(x,y)\sim P_{X}P_{Y}$). Hence, the contrastive learning can also be interpreted as maximizing the distribution divergence between $P_{X,Y}$ and $P_{X}P_{Y}$~\citep{oord2018representation,chen2020simple,bachman2019learning,ozair2019wasserstein,tsai2021self}, and among different objectives the most popular one is maximizing the following InfoNCE objective~\citep{oord2018representation}:
\begin{proposition}[InfoNCE~\citep{oord2018representation}]
\begin{equation}
{\rm InfoNCE}:=\underset{f}{\rm sup}\,\,\mathbb{E}_{(x_i, y_i)\sim {P_{X,Y}}^{\otimes n}}\Big[ {\rm log}\,\frac{e^{f(x_i, y_i)}}{\frac{1}{n}\sum_{j=1}^n e^{f(x_i, y_j)}}\Big]\leq D_{\rm KL}\,\big(P_{X,Y} \,\|\,P_{X}P_Y \big) = {\rm MI}\,(X,Y),
\label{eq:infonce}
\end{equation}
\end{proposition}
where $\{(x_i, y_i)\}_{i=1}^n$ are $n$ independent copies of $(x,y)\sim P_{X,Y}$, $f(x,y)$ is any function that returns a scalar from the input $(x,y)$, and ${\rm MI}\,(X,Y)$ is the mutual information (MI) between $X$ and $Y$. Practically, prior work~\citep{chen2020simple,he2020momentum} suggest $f(x,y) = {\rm cosine}(x,y) / \tau$, where ${\rm cosine}(x,y)$ is the cosine similarity and $\tau$ is the temperature hyper-parameter. Equation~\eqref{eq:infonce} suggests InfoNCE is a lower bound of ${\rm MI}\,(X,Y)$ and theoretical work~\citep{arora2019theoretical,tsai2021multiview,tosh2021contrastive} show that ${\rm MI}\,(X,Y)$ maximization could lead to representations that perform well on downstream tasks. To conclude, as the most popular contrastive approach, InfoNCE can learn good representations without the need to access the downstream supervision.
\subsection{Clustering-based Contrastive Learning}
In addition to learning without access to the downstream supervision, the contrastive learning also manifests it effectiveness under the supervised fashion~\citep{khosla2020supervised}. In particular, \citet{khosla2020supervised} present {\em Supervised Contrastive Learning} that re-defines the positively-paired samples as the samples from the same category and the negatively-paired samples as the samples belonging to different categories. Observing the fact that the contrastive learning work for both unsupervised and supervised setting, a research question pops out naturally:
\begin{center}
{\em Can we design a unified contrastive learning objective that generalizes its applications from unsupervised to weakly-supervised and supervised representation learning?}
\end{center}
Our paper aims to answer this question by presenting clustering-based InfoNCE (Cl-InfoNCE), which 1) first constructs the clusters under either unsupervised, weakly-supervised or supervised setup and 2) then defines the positively-paired samples as the samples from the same cluster and the negatively-paired samples as the samples from different clusters. At a colloquial level, Cl-InfoNCE pulls towards the representations of the data within the same (unsupervised, weakly-supervised, or supervised-formed) cluster and push away the representations of the data from different clusters. With $Z/z$ being the constructed clusters, the proposed Cl-InfoNCE is formulated as:
\begin{proposition}[Clustering-based InfoNCE (Cl-InfoNCE)]
\begin{equation}
{\rm Cl-InfoNCE}:=\underset{f}{\rm sup}\,\,\mathbb{E}_{(x_i, y_i)\sim {\color{blue} \mathbb{E}_{z\sim P_Z}\big[P_{X|z}P_{Y|z}\big]}^{\otimes n}}\Big[ {\rm log}\,\frac{e^{f(x_i, y_i)}}{\frac{1}{n}\sum_{j=1}^n e^{f(x_i, y_j)}}\Big],
\label{eq:cl_infonce}
\end{equation}
\end{proposition}
where the positively-paired representations $(x_i, y_i)$ are sampled from ${\color{blue} \mathbb{E}_{z\sim P_Z}\big[P_{X|z}P_{Y|z}\big]}$\footnote{$(x, y) \sim \mathbb{E}_{z\sim P_Z}\big[P_{X|z}P_{Y|z}\big]$ includes two steps: first, $z \sim P_Z$; then, $x \sim P_{X|z}$ and $y \sim P_{Y|z}$.} and the negatively-paired representations $(x_i, y_j)$ are sampled from $P_XP_Y$ ($i\neq j$)\footnote{$\int_X \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] dx = P_Y$ and $\int_Y \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] dy = P_X$.}. We note that equation~\eqref{eq:cl_infonce} generalizes to different levels of supervision: 1) when $Z=$ instance id (i.e., each cluster only contains an instance), $\mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big]$ specializes to $P_{XY}$ and Cl-InfoNCE specializes to InfoNCE for unsupervised representation learning; 2) when $Z=$ downstream labels, Cl-InfoNCE specializes to the objective described in {\em Supervised Contrastive Learning}~\citep{khosla2020supervised} for supervised representation learning; and 3) when $Z$ is constructed from the weak supervision signals, such as data's attributes or the hierarchical information of data, Cl-InfoNCE can be used for weakly-supervised representation learning. Now, we provide the following theoretical statements to better understand Cl-InfoNCE:
\begin{theorem}[Asymptotic analysis of Cl-InfoNCE]
\begin{equation}
{\rm Cl-InfoNCE} \leq {\rm Cl-InfoNCE}_{\,n \rightarrow \infty} = D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big) \leq H(Z),
\label{eq:asymp_cl_infonce}
\end{equation}
\label{theo:asymp_cl_infonce}
\end{theorem}
\begin{theorem}[Cl-InfoNCE maximization learns to include the clusering information]
\begin{equation}
{\rm Cl-InfoNCE}_{\,n \rightarrow \infty} {\rm \,\,maximizes\,\,at\,\,} H(Z) {\rm \,\,when \,\,} H(Z|X) = H(Z|Y) = 0,
\label{eq:max_resulting_repre}
\end{equation}
\label{theo:max_resulting_repre}
\end{theorem}
where $H(Z)$ is the entropy of $Z$ and $H(Z|X)$/ $H(Z|Y)$ are the conditional entropy of $Z$ given $X$/$Y$. We leave detailed derivations and proofs in Appendix. Theorem~\ref{theo:asymp_cl_infonce} suggests that Cl-InfoNCE has an upper bound $D_{\rm KL}\,\Big( \mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big] \,\|\, P_{X}P_{Y} \Big)$, which measures the distribution divergence between the product of clustering-conditional marginal distributions (i.e., $\mathbb{E}_{P_Z}\big[P_{X|Z}P_{Y|Z}\big]$) and the product of marginal distributions (i.e., $P_{X}P_{Y}$). Theorem~\ref{theo:max_resulting_repre} suggests that maximizing Cl-InfoNCE results in the representations $X$ and $Y$ including the clustering information $Z$ ($\because H(Z|X) = H(Z|Y) = 0$). This result is not surprising: since Cl-InfoNCE pulls together the representations from the data belonging to the same cluster and push away the representations from the data belonging to different clusters, the representations learned by maximizing Cl-InfoNCE should be able to distinguish among distinct clusters.
To conclude, Cl-InfoNCE is a clustering-based contrastive learning objective. By differing its cluster construction, Cl-InfoNCE generalizes from unsupervised, weakly-supervised to supervised representation learning. In this paper, we focus on the application of Cl-InfoNCE in weakly-supervised setup, where we examine different weak supervision sources to form clusters.
\section{Experiments}
\vspace{-1mm}
We given an overview of our experimental section. Section~\ref{subsec:datasets} discusses the datasets. We consider discrete attribute information as auxiliary information for data. Next, in Section~\ref{subsec:method}, we explain the methodology that will be used in the experiments. Section~\ref{subsec:exp_with_auxi_attr} presents the first set of the experiments, under a weakly-supervised setting, to manifest the effectiveness of our approach and the benefits of taking the auxiliary information into account.
Last, to study the effect of Cl-InfoNCE alone, Section~\ref{subsec:exp_without_auxi} presents the second set of the experiments under a unsupervised setting. {\color{black} We also conduct comparison experiments with another independent and concurrent weakly supervised contrastive learning work~\citep{zheng2021weakly} in the Appendix.}
\vspace{-1mm}
\subsection{Datasets}
\label{subsec:datasets}
\vspace{-1mm}
We consider the following datasets. {\bf UT-zappos50K}~\citep{yu2014fine}: It contains $50,025$ shoes images along with $7$ discrete attributes as auxiliary information. Each attribute follows a binomial distribution, and we convert each attribute into a set of Bernoulli attributes, resulting in a total of $126$ binary attributes. There are $21$ shoe categories.
{\bf Wider Attribute}~\citep{li2016human}: It contains $13,789$ images, and there are several bounding boxes in an image. The attributes are annotated per bounding box. We perform OR operation on attributes from different bounding boxes in an image, resulting in $14$ binary attributes per image as the auxiliary information. There are $30$ scene categories.
{\bf CUB-200-2011}~\citep{wah2011caltech}: It contains $11,788$ bird images with $200$ binary attributes as the auxiliary information. There are $200$ bird species. For the second set of the experiments, we further consider the {\bf ImageNet-100}~\citep{russakovsky2015imagenet} dataset. It is a subset of the ImageNet-1k object recognition dataset~\citep{russakovsky2015imagenet}, where we select $100$ categories out of $1,000$, resulting in around $0.12$ million images.
\vspace{-1mm}
\subsection{Methodology}
\label{subsec:method}
\vspace{-1mm}
Following~\citet{chen2020simple}, we conduct experiments on pre-training visual representations and then evaluating the learned representations using the linear evaluation protocol. In other words, after the pre-training stage, we fix the pre-trained feature encoder and then categorize test images by linear classification results. We select ResNet-50~\citep{he2016deep} as our feature encoder across all settings. Note that our goal is learning representations (i.e, $X$ and $Y$) for maximizing the Cl-InfoNCE objective (equation~\eqref{eq:cl_infonce}). Within Cl-InfoNCE, the positively-paired representations $(x, y^+) \sim \mathbb{E}_{z\sim P_Z}\big[P_{X|z}P_{Y|z}\big]$ are the learned representations from augmented images from the same cluster $z\sim P_Z$ and the negatively-paired representations $(x, y^-) \sim P_XP_Y$ are the representations from arbitrary two images. We leave the network designs, the optimizer choices, and more details for the datasets in Appendix.
\input{fig_tex/synthetic_wrap}
Before delving into the experiments, we like to recall that, in Section~\ref{subsec:cl-infonce}, we discussed using the mutual information $I(Z;T)$ and the conditional entropy $H(Z|T)$ between the clusters ($Z$) and the labels ($T$) to characterize the goodness of Cl-InfoNCE's learned representations. To prove this concept, on UT-Zappos50K, we synthetically construct clusters for various $I(Z;T)$ and $H(Z|T)$ followed by applying Cl-InfoNCE. We present the results in the right figure.
Our empirical results are in accordance with the statements that the clusters with higher $I(Z;T)$ and lower $H(Z|T)$ will lead to higher downstream performance. In later experiments, we will also discuss these two information-theoretical metrics.
\vspace{-1mm}
\subsection{Experiment I: Auxiliary-Information-Determined Clusters + Cl-InfoNCE}
\label{subsec:exp_with_auxi_attr}
\vspace{-1mm}
We like to understand how well Cl-InfoNCE can be combined with the auxiliary information. For this purpose, we select the data discrete attributes as the auxiliary information, construct the clusters ($Z$) using the discrete attributes (see Section~\ref{subsec:cluster_construct} and Figure~\ref{fig:cluster_construction}), and then adopt attributes-determined clusters for Cl-InfoNCE. Recall our construction of data-attributes-determined clusters: we select the attributes with top-$k$ highest entropy and then construct the clusters such that the data within a cluster will have the same values over the selected attributes. $k$ is the hyper-parameter. Note that our method considers a weakly supervised setting since the data attributes can be seen as the data's weak supervision.
We dissect the experiments into three parts. First, we like to study the effect of the hyper-parameter $k$ and select its optimal value. Note that different choices of $k$ result in different constructed clusters $Z$. Our study is based on the information-theoretical metrics (i.e., $I(Z;T)$ and $H(Z|T)$ between the constructed clusters ($Z$) and the labels ($T$)) and their relations with the downstream performance of the learned representations. Second, we perform comparisons between different levels of supervision. In particular, we include the comparisons with the supervised ($Z=$ downstream labels $T$) and the conventional self-supervised ($Z=$ instance ID) setting for our method. We show in Section~\ref{subsec:cl-infonce}, the supervised setting is equivalent to the Supervised Contrastive Learning objective~\citep{khosla2020supervised} and the conventional self-supervised setting is equivalent to SimCLR~\citep{chen2020simple}. Third, we include baselines that leverage the auxiliary information: i) learning to predict the clusters assignments using cross-entropy loss and ii) treating auxiliary information as another view of data when using the contrastive multi-view coding (CMC)~\citep{tian2020contrastive}.
\input{fig_tex/attributes}
\vspace{-1mm}
\paragraph{Part I - Effect of the hyper-parameter $k$.}
To better understand the effect of the hyper-parameter $k$ for constructing the attributes-determined clusters, we study the information-theoretical metrics between $Z$ and $T$ and report in Figure~\ref{fig:attributes}. Note that, to ensure the same scales for $I(Z;T)$ and $H(Z|T)$ across different datasets, we normalize $I(Z;T)$ and $H(Z|T)$ using $$I(Z;T) \leftarrow \frac{I(Z;T) - {\rm min}_ZI(Z;T)}{ {\rm max}_ZI(Z;T)- {\rm min}_ZI(Z;T)} \quad {\rm and}\quad H(Z|T) \leftarrow \frac{H(Z|T)) - {\rm min}_ZH(Z|T)}{ {\rm max}_ZH(Z|T)- {\rm min}_ZH(Z|T)}.$$
As $k$ increases, the mutual information $I(Z;T)$ increases but the conditional entropy $H(Z|T)$ also increases. Hence, although considering more attributes leads to the clusters that are more correlated to the downstream labels, the clusters may also contain more downstream-irrelevant information. This is in accord with our second observation that, as $k$ increases, the downstream performance first increases then decreases. Therefore, we only need a partial set of the most informative attributes (those with high entropy) to determine the clusters. Next, we observe that the best performing clusters happen at the intersection between $I(Z;T)$ and negative $H(Z|T)$. This observation helps us study the trade-off between $I(Z;T)$ and $H(Z|T)$ and suggests an empirical way to select the optimal $k$ that achieves the best performance. It is worth noting that the above process of determining the optimal $k$ does not require directly evaluating the learned representations.
\input{tbl_tex/attributes-supervision}
\vspace{-1mm}
\paragraph{Part II - Interpolation between Different Supervision Levels.}
In Section~\ref{subsec:cl-infonce}, we discussed that, by altering the designs of the clusters, our presented approach specializes to the conventional self-supervised contrastive method - SimCLR~\citep{oord2018representation} and the supervised contrastive method - SupCon~\citep{khosla2020supervised}. In particular, our approach specializes to SimCLR when considering augmented variants of each instance as a cluster and specializes to SupCon when considering instances with the same downstream label as a cluster. Hence, we can interpolate different supervision levels of our approach and study how auxiliary information of data can help improve representation learning.
We present the results in Table~\ref{tbl:attributes-supervision} with different cluster constructions along with Cl-InfoNCE. We use the top-1 accuracy on Wider Attribute for discussions. We find the performance grows from low to high when having the clusters as instance ID ($40.2$),
attributes-determined clusters ($45.5$) to labels ($49.9$). This result suggests that CL-InfoNCE can better bridge the gap with the supervised learned representations by using auxiliary information.
\vspace{-1mm}
\paragraph{Part III - Comparisons with Baselines that Leverage Auxiliary Information.} In the last part, we see that Cl-InfoNCE can leverage auxiliary information to achieve a closer performance to supervised representations than self-supervised representations. Nonetheless, two questions still remain: 1) is there another way to leverage auxiliary information other than our method (attributes-determined clusters + Cl-InfoNCE), and 2) is the weakly-supervised methods (that leverages auxiliary information) always better than self-supervised methods? To answer these two questions, in Table~\ref{tbl:attributes-baselines}, we include the comparisons among weakly-supervised representation learning baselines that leverage auxiliary information (Attributes-determined clusters + cross-entropy loss and Contrastive Multi-view Coding (CMC)~\citep{tian2020contrastive} when treating auxiliary information as another view of data) and self-supervised baselines (SimCLR~\citep{oord2018representation} and MoCo~\citep{he2020momentum}).
First, we find that using auxiliary information does not always guarantee better performance than not using it. For instance, for top-1 acc. on Wider Attribute dataset, predicting the attributes-determined clusters using the cross-entropy loss ($39.4$) or treating auxiliary information as another view of data then using CMC ($34.1$) perform worse than the SimCLR method ($40.2$), which does not utilize the auxiliary information. The result suggests that, although auxiliary information can provide useful information, how we can effectively leverage the auxiliary information is even more crucial.
\iffalse
Third, we observe the predictive method always performs worse than the contrastive method under the weakly supervised setting. For example, on UT-Zappos50K, although predicting the labels using the cross-entropy loss ($89.2$) performs at par with SupCon ($89.0$), predicting attributes-determined clusters using the cross-entropy loss ($82.7$) performs worse than attributes-determined clusters + Cl-InfoNCE ($84.6$). This result implies that the contrastive method (e.g., Cl-InfoNCE) can generally be applied across various supervision levels.
\fi
Second, we observe that our method constantly outperforms the baseline - Attributes-Determined Clusters + Cross-Entropy loss. For instance, on ZT-Zappos50K, our method achieves $84.6$ top-1 accuracy while the baseline achieves $82.7$ top-1 accuracy. Note that both our method and the baseline consider constructing clusters according to auxiliary information. The difference is that our method adopts the contrastive approach - Cl-InfoNCE, and the baseline considers to adopt cross-entropy loss on an additional classifier between the representations and the clusters. Our observation is in accordance with the observation from a prior work~\citep{khosla2020supervised}. It shows that, compared to the cross-entropy loss, the contrastive objective (e.g., our presented Cl-InfoNCE) is more robust to natural corruptions of data, stable to hyper-parameters and optimizers settings, and enjoying better performance.
Last, we compare our method with the CMC method. We see that although our method performs better on UT-zappos50K ($84.6$ over $83.7$) and Wider Attributes ($45.5$ over $34.1$) dataset, CMC achieves significantly better results on CUB-200-2011 ($32.7$ over $20.6$) dataset. To explain such differences, we recall that 1) the CMC method leverages the auxiliary information directly, while our method leverages the auxiliary information indirectly (we use the structural information implied from the auxiliary information); and 2) the auxiliary information used in UT-zappos50K and Wider Attributes contains relatively little information (i.e., consisting of less than 20 discrete attributes), and the auxiliary information used in CUB-200-2011 contains much more information (i.e., consisting of 312 discrete attributes). We argue that since CMC leverages the auxiliary information directly, it shall perform better with more informative auxiliary information. On the other hand, Cl-InfoNCE performs better with less informative auxiliary information.
\input{tbl_tex/attributes-baselines-comparisons}
\vspace{-1mm}
\subsection{Experiment II: K-means Clusters + Cl-InfoNCE}
\label{subsec:exp_without_auxi}
\vspace{-1mm}
So far, we see how we can combine auxiliary-information-determined clusters and Cl-InfoNCE to learn good weakly-supervised representations. Now, we would like to show that Cl-InfoNCE can also learn good self-supervised representations without auxiliary information. To this end, we construct unsupervised clusters (e.g., k-means clusters on top of the learned representations) for Cl-InfoNCE.
Similar to the EM algorithm, we iteratively perform the k-means clustering to determine the clusters for the representations, and then we adopt Cl-InfoNCE to leverage the k-means clusters to update the representations. We select thet Prototypical Contrastive Learning (PCL)~\citep{li2020prototypical} as the baseline of the clustering-based self-supervised approach. In particular, PCL performs data log-likelihood maximization by assuming data are generated from isotropic Gaussians. It considers the MLE objective, where the author makes a connection with contrastive approaches~\citep{chen2020simple,he2020momentum}. The clusters in PCL are determined via MAP estimation. For the sake of the completeness of the experiments, we also include the non-clustering-based self-supervised approaches, including SimCLR~\citep{chen2020simple} and MoCo~\citep{he2020momentum}. Note that this set of experiments considers the conventional self-supervised setting, in which we can leverage the information neither from labels nor from auxiliary information.
\input{fig_tex/unsupervised}
\vspace{-3mm}
\paragraph{Results.} We first look at the left table in Figure~\ref{fig:unsupervised}. We observe that, except for ImageNet-100, there is no obvious performance difference between the non-clustering-based (i.e., SimCLR and MoCo) and the clustering-based baseline (i.e., PCL). Since ImageNet-100 is a more complex dataset comparing to the other three datasets, we argue that, when performing self-supervised learning, discovering latent structures in data (via unsupervised clustering) may best benefit larger-sized datasets. Additionally, among all the approaches, our method reaches the best performance. The result suggests our method can be as competitive as other conventional self-supervised approaches.
Next, we look at the right plot in Figure~\ref{fig:unsupervised}. We study the mutual information $I(Z;T)$ and the conditional entropy $H(Z|T)$ between the unsupervised constructed clusters $Z$ and the downstream labels $T$. We select our method and PCL, providing the plot of the two information-theoretical metrics versus the training epoch. We find that, as the number of training epochs increases, both methods can construct unsupervised clusters that are more relevant (higher $I(Z;T)$) and contain less redundant information (lower $H(Z|T)$) about the downstream label. This result suggests that the clustering-based self-supervised approaches are discovering the latent structures that are more useful for the downstream tasks. It is worth noting that our method consistently has higher $I(Z;T)$ and lower $H(Z|T)$ comparing to PCL.
|
{'timestamp': '2022-02-21T02:15:11', 'yymm': '2202', 'arxiv_id': '2202.06670', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06670'}
|
arxiv
|
\section{Introduction}
\label{sec:intro}
Question generation (QG) is the task of automatically generating a question from a given context and an answer. It can be an essential component in education systems~\cite{yao2018teaching}, or be applied in intelligent virtual assistant systems to make them more proactive. It can also serve as a complementary task to boost QA systems~\cite{tang2017question}.
Most of the previous works on QG focus on generating the SQuAD-style single-hop question, which is relevant to one fact obtainable from a single sentence. Recently, there has been a surge of interest in QG for more complex multi-hop question generation, such as HotpotQA-style questions ~\cite{yang2018hotpotqa,pan-etal-2020-semantic,su-etal-2020-multi,10.1145/3366423.3380114,wang-etal-2020-answer,gupta2020reinforced,sachan2020stronger}. This is a more challenging task that requires identifying multiple relevant pieces of information from multiple paragraphs, and reasoning over them to fulfill the generation. Due to the multi-hop nature of MQA task, different models ~\cite{pan-etal-2020-semantic,su-etal-2020-multi, 10.1145/3366423.3380114,sachan2020stronger} have been proposed to introduce graph-based networks into the traditional Sequence-to-sequence (Seq2Seq) framework to encode the multi-hop information. However, some of the most recent work has shown that the graph structure may not be necessary, and can be replaced with Transformers or proper use of large pre-trained models for multi-hop QA ~\cite{shao2020graph,groeneveld2020simple}. This motivates us to explore Transformer-based architectures for the relational reasoning requirements of the multi-hop QG (MQG) task.
Another limitation of previous works is that they aim to model $P(\text{Question}|\langle\text{Answer},\text{Context}\rangle)$, and ignore the strong constraint of $P(\text{Answer}|\langle\text{Question},\text{Context}\rangle)$. As suggested by~\cite{tang2017question}, QA and QG are dual tasks that can help each other. We argue that introduction of a multi-hop QA module can also help MQG.
In this paper, we propose \textbf{QA4QG}, a QA-augmented BART-based framework for MQG. We augment the standard BART framework with an additional multi-hop QA module, which takes the reverse input of the QG system (i.e., question $Q$ and context $C~\footnote{The context can be either sentences or paragraphs}$ as input), to model the multi-hop relationships between the question $Q$ and the answer $A$ in the given context $C$.
QA4QG outperforms all state-of-the-art models on the multi-hop dataset HotpotQA, with an increase of 8 BLEU-4 and 8 ROUGE points compared to the best results reported in previously published work. Our work suggests the necessity to introduce pre-trained language models and QA modules for the MQG task.
\vspace{-10pt}
\section{Related Work}
\vspace{-10pt}
Most previous approaches on MQG have tried to extend the existing Seq2Seq framework for single-hop QG with reasoning ability. One branch of work models text as graph structure~\cite{su-etal-2020-multi, pan-etal-2020-semantic,10.1145/3366423.3380114} and incorporates graph neural networks into the traditional Seq2Seq framework, mostly the encoder. While this graph-based approach is very intuitive, it relies on additional modules such as semantic graph construction, name entity recognition (NER) and entity linking (NEL), which make the whole framework complicated and fragile.
Another branch of work on MQG ~\cite{gupta2020reinforced, wang-etal-2020-answer, xie2020exploring} focuses more on the decoder and aims to augment the Seq2Seq framework with extra constraints to guide the generation.~\cite{gupta2020reinforced} employ multi-task learning with the auxiliary task of answer-related supporting sentences prediction. ~\cite{wang-etal-2020-answer} integrate reinforcement learning (RL) with answer-related syntactic and semantic metrics as reward. The closest effort to our \textbf{QA4QG} is by ~\cite{xie2020exploring}, who introduce a QA-based reward based on SpanBERT in their RL-enhanced Seq2Seq framework, to consider the answerability of the generated question.
On the other hand, the most recent work ~\cite{shao2020graph,groeneveld2020simple} has shown the strong capability of simple architecture design with large pre-trained language models for multi-hop QA. Such approaches have outperformed the graph network based methods and achieved comparable performance with state-of-the-art architectures such as \textbf{HGN}~\cite{fang-etal-2020-hierarchical}. This inspires us to explore large pre-trained models for MQG.
\vspace{-0.2in}
\section{Methodology}
\vspace{-0.15in}
Our framework, QA4QG, consists of two parts, a BART module and a QA module, as shown in Fig ~\ref{fig:QA4QG}. The QA module takes context $C$ and question $Q$ as input, and outputs the probability of each token being the answer. The BART module takes the concatenation of the context $C$ and the answer $A$, together with the output probability from the QA module as input and generates the question $Q$ token-by-token.
\begin{figure}[tp]
\centering
\includegraphics[width=0.85\linewidth]{imgs/QA4QG.pdf}
\vspace{-10pt}
\caption{The architecture of our QA4QG. The output of the QA module is used to bias the cross-attention of Transformer decoder.}
\label{fig:QA4QG}
\vspace{-0.2in}
\end{figure}
\setlength\doublerulesep{0.35pt}
\begin{table*}[!ht]
\centering
\resizebox{0.80\textwidth}{!}{
\begin{tabular}{l|cccccc}
\hline
\hline
\textbf{Models} & \textbf{BLEU-1} & \textbf{BLEU-2} & \textbf{BLEU-3} & \textbf{BLEU-4} & \textbf{METEOR} & \textbf{ROUGE-L} \\ \hline
\multicolumn{7}{c}{\textit{Encoder Input: Supporting Facts Sentences}} \\
\hline
ASs2s-a~\cite{kim2019improving} & 37.67 & 23.79 & 17.21 & 12.59 & 17.45 & 33.21 \\
SemQG~\cite{zhang2019addressing} & 39.92 & 26.73 & 18.73 & 14.71 & 19.29 & 35.63 \\
F + R + A~\cite{xie2020exploring} & 37.97 & - & - & 15.41 & 19.61 & 35.12 \\
SGGDQ (DP)~\cite{pan-etal-2020-semantic} & 40.55 & 27.21 & 20.13 & 15.53 & 20.15 & 36.94 \\
ADDQG~\cite{wang-etal-2020-answer} & 44.34 & 31.32 & 22.68 & 17.54 & 20.56 & 38.09 \\
\hline
QA4QG (\textit{LARGE setting}) & \textbf{49.55} & \textbf{37.91} & \textbf{30.79} & \textbf{25.70} & \textbf{27.44} & \textbf{46.48} \\
\hline
\multicolumn{7}{c}{\textit{Encoder Input: Full Document Context}} \\ \hline
MultiQG~\cite{su-etal-2020-multi} & 40.15 & 26.71 & 19.73 & 15.2 & 20.51 & 35.3 \\
GATENLL+CT~\cite{sachan2020stronger}& - & - & - & 20.02(14.5) & 22.40 & 39.49 \\
LowResouceQG~\cite{yu2020low} & - & - & - & 19.07 & 19.16 & 39.41 \\
\hline
QA4QG (\textit{BASE setting}) & 43.72& 31.54& 24.47 & 19.68 & 24.55& 40.44 \\
\hdashline
QA4QG (\textit{LARGE setting}) & \textbf{46.45} & \textbf{33.83} & \textbf{26.35} & \textbf{21.21} & \textbf{25.53} & \textbf{42.44} \\
\hline
\hline
\end{tabular}}
\caption{\label{results} Comparison between QA4QG and previous MQG methods on the HotpotQA dataset in different encoder input settings. QA4QG outperforms the best models up to 8 BLEU-4 and 8 ROUGE points.}
\vspace{-0.1in}
\end{table*}
\setlength{\abovedisplayskip}{5pt}
\setlength{\belowdisplayskip}{5pt}
\vspace{-0.1in}
\subsection{BART}
\vspace{-0.05in}
We choose BART as our backbone for Seq2Seq model because of its outstanding performance on many generation tasks~\cite{lewis-etal-2020-bart}. BART is a Transformer-based model that consists of an encoder and a decoder. The encoder encodes the concatenation of the context $C$ and the answer $A$. We denote the encoded final representation of the encoder as $h_{enc}$. Partial structure of the BART decoder is detailed as follow:
\begin{align}
H_i^a &= \text{MultiHeadAttention}(H_i, H_i, H_i) \\
H_i^b &= \text{Norm}(H_i + H_i^a) \\
\label{cross-attention} H_i^c &= \text{MultiHeadAttention}(H_i^b, h_{enc}, h_{enc}),
\end{align}
where $H_i$ is the representation for the $i$-th layer.
\vspace{-10pt}
\subsection{Answer Relevance Attention}
To model the strong relationships of $P(A | C, Q)$, we propose \textbf{answer relevance attention}, to indicate the answer relevance of each token in context to the target question. Our answer relevance attention can be either soft or hard.
\vspace{-0.08in}
\subsubsection{Soft attention}
\vspace{-5pt}
Soft attention can be employed when the ground truth question is available (e.g., in the training phase), and we propose to use a QA module to derive the answer relevance attention. The QA module takes the concatenation of the context $C$ and question $Q$ as input, and outputs the prediction of the start and end spans of the potential answer in the context. Specifically, it outputs two probability distributions over the tokens in the context: $P^s_{ans}$ and $P^e_{ans}$, where $P^s_{ans}$ / $P^e_{ans}$ is the probability that the $i$-th token is the start/end of the answer span in context $C$. The answer relevance attention score $\mathcal{A}_{soft}$ is calculated via
\begin{equation}
\mathcal{A}_{soft} = P^s_{ans} + P^e_{ans}
\end{equation}
where $\mathcal{A}_{soft} = \{a_i\}$, $a_i$ denotes the answer relevance of the $i$-th token in context to the question.
For the QA module of our MQG task, we choose the Hierarchical Graph Network (\textbf{HGN})~\cite{fang-etal-2020-hierarchical} as it achieves the state-of-the-art performance on the HotpotQA dataset. We believe the $\mathcal{A}_{soft}$ generated by the HGN model,\footnote{We use the RoBERTa-large based HGN model, trained on the HotpotQA dataset, and released by the author via https://github.com/yuwfan/HGN} when trained to answer multi-hop question, can naturally learn the answer-aware multi-hop information related to the question inside the context $C$. This information can then complement the BART model for MQG. Note that other QA models can also be adopted in our framework.
\begin{figure}[tp]
\centering
\includegraphics[width=0.86\linewidth]{imgs/fig_2.pdf}
\vspace{-0.2in}
\caption{Ablation study on impact of $\alpha$, with different combinations of the soft attention and hard attention.}
\label{fig:Ablation}
\vspace{-0.1in}
\end{figure}
\vspace{-0.08in}
\subsubsection{Hard attention}
\vspace{-0.08in}
Hard attention can be employed when no question is available (e.g., in the testing phase). Hard attention is inspired by the answer tagging technique from previous work on single-hop QG. Specifically, we first match the answer span with the context $C$. We then assign a pre-defined score $p_y$ to the matched tokens, and $p_n$ to the remaining tokens, to indicate the binary relevance of each token in the context to the answer (in our work, $p_y=1.0$, $p_n=0.0$). We denote hard attention as $\mathcal{A}_{hard}$.
\vspace{-0.075in}
\subsection{Enhanced Cross-Attention}
\vspace{-0.05in}
We next incorporate the answer relevance attention into the BART model. We propose to bias the original cross-attention sub-layer (i.e., Eq.~\ref{cross-attention}) in each BART decoder layer with $\mathcal{A}$:
\begin{align}
H_i^{c^\prime} &= \text{softmax}(\frac{H_i^b \, h^T_{enc}}{\sqrt{d_k}} + \mathcal{A})h_{enc} \\
\mathcal{A} &= \alpha \mathcal{A}_{hard} + (1-\alpha) \mathcal{A}_{soft}, \label{eq:combine}
\end{align}
where $d_k$ is the dimension of keys, and $\alpha$ is the hyper-parameter to mitigate the question disparity between training and testing. Note that each question token shares the same attention score over context tokens. The answer relevance attention can be regarded as a prior knowledge bias for each question over the context. QA4QG is then trained through cross-entropy loss between the generated question and the ground truth.
\section{Experimental Setup}
\vspace{-0.05in}
To evaluate the effectiveness of our QA4QG framework, we conduct experiments on the HotpotQA~\cite{yang2018hotpotqa} dataset, a challenging dataset which contains $ \sim$10k multi-hop questions derived from two Wikipedia paragraphs, and requiring multi-hop reasoning to answer. For fair comparison, we follow the data splits of ~\cite{pan-etal-2020-semantic,wang-etal-2020-answer} to get 90,440 training examples and 6,072 test examples respectively. However, we use the original training data as in HotpotQA, in which each question is paired with two long documents, without pre-precessing. ~\cite{pan-etal-2020-semantic,wang-etal-2020-answer} pre-process the data and only use golden supporting sentences.
\subsection{Training Settings}
We adopt the BART implementations from Huggingface\footnote{https://github.com/huggingface/transformers}, and experiment based on both the \textit{BART-base} and \textit{BART-large} Seq2Seq fine-tuning settings. We run the experiments on single V100 with 16G memory. The maximum source sequence length is set to 512 and 200 respectively, for the full document input and supporting sentences input settings. The training batch size is 6 and 16 respectively for the \textit{QA4QG-base} and \textit{QA4QG-large} model, with gradient accumulation steps of 4. We train all model with maximum 5 epochs. The learning rate is 3e-5. During inference, we use beam search with beam size of 4, and we set the maximum target length to 32 and use the default value of the minimum target length, which is 12, with a length penalty of 1.0.
\vspace{-0.1in}
\subsection{Baselines}
We include the previous work for MQG, and two strong conventional QG models as baselines for comparison:
\textbf{ASs2s-a~\cite{kim2019improving}} proposes to decode questions from an answer-separated passage encoder with a new module termed keyword-net, to utilize the information from both the passage and the target answer.
\textbf{SemQG~\cite{zhang2019addressing}} proposes two semantics-enhanced rewards from question paraphrasing and QA tasks to regularize the QG model for generating semantically valid questions. \textbf{F + R + A~\cite{xie2020exploring}} uses reinforcement learning (RL) and designs three different rewards regarding \textbf{f}leuncy, \textbf{r}elevance and \textbf{a}nswerability, for the MQG task. The answerability reward is generated by an QA model. \textbf{SGGDQ (DP)~\cite{pan-etal-2020-semantic}} uses the supporting sentences as input for MQG. It constructs a semantic-level graph for the input, then uses the document-level and graph level representations to do the generation. \textbf{ADDQG~\cite{wang-etal-2020-answer}} applies RL to integrate both syntactic and semantic metrics as the reward to enhance the training of the ADDQG for MQG task. \textbf{MultiQG~\cite{su-etal-2020-multi}} proposes to integrate graph convolutional neural network with conventional Seq2Seq framework, for the MQG task. They construct an entity graph so that the method can be applied using the full documents as input. \textbf{GATENLL+CT~\cite{sachan2020stronger}} proposes a graph augmented Transformer based framework for MQG. \textbf{LowResouceQG~\cite{yu2020low}} focuses on MQG in a low resource scenario, and proposes to use hidden semi-Markov model to learn the structural patterns from the unlabeled data and transfer this fundamental knowledge into the generation model.
\begin{table}[!t]
\centering
\resizebox{0.85\columnwidth}{!}{%
\begin{tabular}{ll|ccc}
\hline
\hline
\multicolumn{2}{c|}{\textbf{Models}} & \textbf{BLEU-4} & \textbf{METEOR} & \textbf{ROUGE-L} \\ \hline
\multicolumn{2}{l|}{QA4QG-large } & 21.21 & 25.53 & 42.44 \\
& \textit{w/o} QA & 19.32 & 24.65 & 40.74\\
\hline
\multicolumn{2}{l|}{QA4QG-base} & 19.68 & 24.55 & 40.44 \\
& \textit{w/o} QA & 17.43 & 23.16 & 38.23 \\
\hline
\hline
\multicolumn{2}{l|}{QA4QG-large (sp)} & 25.70 & 27.44 & 46.47 \\
& \textit{w/o} QA & 25.69 & 27.20 & 46.30 \\
\hline
\hline
\end{tabular}%
}
\vspace{-5pt}
\caption{Ablation study on the QA module. The bottom section uses the \textbf{s}upporting \textbf{s}entences (sp) as input.}
\label{tab:ablation}
\vspace{-0.2in}
\end{table}
\vspace{-10pt}
\section{Results and Analysis}
\vspace{-0.05in}
Table~\ref{results} shows the comparison results between our methods and several state-of-the-art MQG models.
The top section represents using the supporting sentences as input, which is a simplified version of the task. Supporting facts annotations require expensive human labeling and are not always available in the realistic MQG scenario. However, this is the setting used in previous works since their methods can not deal with long documents~\cite{pan-etal-2020-semantic}. We see that in this setting, our QA4QG outperforms previous best results with an absolute gain of around 8 BLEU-4 and 8 ROUGE points.
We also compare our QA4QG performance on a more challenging setting, using the full document as input. The average length of the context documents is three times the length of the supporting facts in HotpotQA~\cite{sachan2020stronger}. As is evident from the results (bottom section in Table~\ref{results}), QA4QG achieves the new state-of-the-art results in both the \textit{QA4QG-base} and \textit{QA4QG-large} settings.
\begin{figure}[t]
\centering
\includegraphics[width=1.0\linewidth]{imgs/fig_3.3.pdf}
\caption{Visualization of soft attention $\mathcal{A}_{soft}$. Darker color represents higher attention weights. For an answer \textit{'yes'}, our $A_{soft}$ emphasizes the multi-hop information related to \textit{'First for Women'} and \textit{'Jane'} in the context, which then constrains the generation model. The target question is \textit{'Are \underline{Jane} and \underline{First for Women} both \underline{women's magazines}?'}.}
\label{fig:ablation_visualize_attention}
\vspace{-0.2in}
\end{figure}
\vspace{-0.05in}
\subsection{Ablation Study}
\vspace{-0.05in}
To investigate the answer relevance attention and the QA module, we perform ablation studies.
As we can see from Table~\ref{tab:ablation}, when we remove the QA module, the performance drops in both the \textit{large} and \textit{base} settings. We also compares when using supporting sentences as input. From the results we see that QA module did not affect the performance as in the full documents setting. This actually matches with our intuition. Since there are only two short sentences as context in the supporting documents setting, it is much easier for the QG model to generate the question, the extra improvement from an QA module may not that large.
We then study the effect of the hyper-parameter $\alpha$ in Eq.~\ref{eq:combine} with different combinations of soft and hard attention during training. The curves of the three metrics in Fig.~\ref{fig:Ablation} show that, in general, the more $\mathcal{A}_{soft}$, the greater performance improvement QA4QG can achieve. This matches our intuition, since $\mathcal{A}_{soft}$ incorporates the question-related multi-hop information into the context via the QA module, while $\mathcal{A}_{hard}$ only encodes the explicit answer information. The mixture of both when $\alpha = 0.3$ also yields good results, possibly because of the disparity between training and testing, since during testing we only have $\mathcal{A}_{hard}$.
We visualize the attention weights of $\mathcal{A}_{soft}$ of an example from the dataset in Fig.~\ref{fig:ablation_visualize_attention}. As we see, the $\mathcal{A}_{soft}$ emphasis on the sentence that contains the multi-hop information \textit{'First for Women'} and \textit{'Jane'} in the context, which then constrains the generation model.
\vspace{-0.05in}
\section{Conclusion}
\vspace{-0.05in}
In this paper, we propose a novel framework, QA4QG, a QA-augmented BART-based framework for MQG. It is the first work to explore large pre-trained language models for MQG and takes advantage of an additional Multi-hop QA module to further constrain the question generation. Our results on the HotpotQA dataset show that QA4QG outperforms all state-of-the-art models, with an increase of 8 BLEU-4 and 8 ROUGE points compared to the best results previously reported. Our work suggests the advantage of introducing pre-trained language models and QA modules for the MQG task.
\bibliographystyle{IEEEbib}
|
{'timestamp': '2022-02-15T02:38:19', 'yymm': '2202', 'arxiv_id': '2202.06538', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06538'}
|
arxiv
|
\section{Introduction\label{sec:Introduction}}
Soft and continuum robots are inherently compliant structures
that undergo smooth and continuous structural deformation to form complex ``organic'' shapes. Prior work has demonstrated the potential of soft robots for adaptive whole arm grasping \cite{li2013autonomous}, obstacle avoidance and progressive planning \cite{li2016progressive}, grasping in cluttered space \cite{mcmahan2005design}, navigation in obstructive and unstructured environments \cite{meng2021anticipatory}, human-friendly interaction \cite{amaya2021evaluation}, and locomotion \cite{arachchige2021soft} just as few examples. Despite
continued research demonstrating
their immense potential, they are
largely confined to laboratory settings.
This is mainly because of the lack of structural strength thereof necessary to engage in practical applications such as object manipulation or locomotion (move payload)
while supporting their own weight.
%
Soft robots are often actuated by pneumatic pressure, tendons, and smart materials\cite{schmitt2018soft}.
An impressive number of prototypes that employ
pneumatic muscle actuators (PMAs) have been proposed over the years \cite{walker2020soft}. PMAs are popular due to ease of customization, a wide operational pressure, and a high power-to-weight ratio \cite{caldwell1995control}.
The PMAs (typically 3) can be bundled together to construct bending robotic units -- termed sections \cite{trivedi2008geometrically}. Complex soft robots such as multisection manipulators or legged robots are then fabricated by combining many such bending units (sections).
In addition to actuation, macro-scale PMA-powered soft
robots rely on PMAs
for the robot's structural integrity \cite{godage2015modal}.
The PMAs stiffness is proportional to the supply pressure. Thus, a soft robot constructed from multiple PMAs exhibits variable stiffness proportional to the mean pressure of PMAs. However, the achievable stiffness in PMAs solely through pressure increase is limited. This can lead to undesirable unpredictable (buckling behavior) and unstable (twisting that may result in permanent structural change) during operation.
In addition, PMAs undergo length change proportional to the applied pressure. Consequently, the stiffness is coupled to robot shape. This means that it is not possible to change the robot stiffness without affecting the shape. This could be a problem in applications where adaptive stiffness control during taskspace trajectory tracking.
\begin{figure}[t]
\centering
\includegraphics[width=0.9\linewidth]{figures/Fig1_IntroductionImage.pdf}
\caption{Bioinspiration -- (A) Spider monkey, (B) Tail’s muscular lining with skeletal support. (C) Proposed HSR prototype with bending.}
\label{fig:Fig1_IntroductionImage}
\end{figure}
The
decoupled
stiffness and pose control allows soft
robots to easily adapt to task demands in-situ without affecting the taskspace trajectories. However, prevalent continuum manipulators are made of sections that extend (or contract) depends on the operational mode of PMAs and are therefore subjected to length variation during operation. Consequently, they lack the capability to independently control arm shape \cite{giannaccini2018novel}, and stiffness \cite{allaix2018stiffnessAp}.
Hence, a new line of thinking is warranted
for
potentially
generating technologies to bring soft robotics to practice while providing higher structural strength and better stiffness regulation to fulfill meaningful tasks without betraying compliant operation.
The usefulness of such features becomes evident when we consider a versatile biological example, such as the tail of spider monkeys (Fig. \ref{fig:Fig1_IntroductionImage}-A). Their muscular arrangement -- controlling the deformation of the skeletal structure underneath (Fig. \ref{fig:Fig1_IntroductionImage}-B) -- has embedded unique mechanical properties that differ from conventional soft robots. Muscles (and tendons) have spring-like properties, with inherent stiffness and damping. Thus, they can transform between modes (combinations of shape and stiffness) seamlessly. For instance, the tail can act as a manipulator (grasping tree branches), a support structure (standing upright), and a counterbalancing appendage (during jumping and climbing). They achieve these impressive transformations while still being ``soft'' to the touch because of the tail's muscular lining (Fig. \ref{fig:Fig1_IntroductionImage}-B).
Based on this biological example, we propose a PMA powered hybrid soft
robot (HSR -- Fig. \ref{fig:Fig1_IntroductionImage}-C) with a rigid-linked, highly articulable but inextensible (i.e., constant-length) backbone. The primary motivations of combining soft elements (which facilitate smooth and continuous structural deformation while being compliant and human-friendly) with stiff elements (which provide structural strength to supporting high payload manipulation tasks) are, 1) to increase the variable stiffness range to adapt to environmental changes and operational needs, and 2) to decouple stiffness and shape change for achieving better motion control.
%
%
%
\begin{figure}[t]
\centering
\includegraphics[width=1\linewidth]{figures/Fig2_PartDesign.pdf}
\caption{HSR design components -- (A) Igus Triflex R-TRL.40 dress pack, (B) Silicon tubes, (C) PMAs, (D) End caps, (E) Intermediate joint, (F) Upper hip joint. (G) Fabricated HSR prototype.}
\label{fig:Fig2_PartDesign}
\end{figure}
\section{Hybrid Soft Robot (HSR) Design}\label{sec:design}
The proposed HSR -- shown in Fig. \ref{fig:Fig1_IntroductionImage}-C -- has two main elements, namely the backbone and PMAs, that are used to produce the decoupled stiffness and deformation control.
\subsection{Highly-Articulable Backbone} \label{subsec:backbone}
The backbone unit used in the design is a readily available dress pack (Igus Inc,
-- part no: Triflex R-TRL.40) designed for
cable guide applications (Fig. \ref{fig:Fig2_PartDesign}-A). In the dress pack,
high-tensile-strength plastic segments
are serially connected via ball-and-socket joints (allowing free rotation about the local $X$ and $Y$ axes) to form a rigid-link kinematic chain. The
individual segments
are easily assembled/disassembled allowing
to customize the length of the backbone (i.e., section). We determined the backbone's length be $16~cm$ based on its bending ability to form a subtended angle of $180^\circ$ in any bending plane (Fig. \ref{fig:Fig2_PartDesign}-A).
\subsection{Pneumatic Muscle Actuators (PMAs)}
Custom-made Mckibben type PMAs are utilized to actuate the proposed HSR \cite{caldwell1993braided}. We used
commercially available Silicone tubes, pneumatic union connectors, braided sleeves, and heavy-duty zip ties to fabricate
PMAs \cite{godage2012pneumatic}.
We opted for the extending-mode PMAs
for their leaner physical profile
as opposed to the contracting mode ones which would require a higher radius-to-length ratio.
In addition, extending mode PMAs have higher normalized length variation (up to $50\%$ compared to about 35\% for contracting ones). Further, we desire comparably high operational pressures to generate
increased torques to achieve high bending deformation and stiffness range. To that end, we selected a silicone tube with $11~mm$ of inner diameter and $2~mm$ of wall thickness (Fig. \ref{fig:Fig2_PartDesign}-B).
We decided on the tube's thickness
based on the ability to safely operate
in
a pressure range (up to $5~bars$) with
an acceptable
deadzone (pressure to overcome the transient radial expansion).
The length of a PMA is chosen as $150~mm$ based on the length and backbone characteristics such that the serial joints of the backbone can bend up to $180^\circ$ in any bending plane. To limit radial expansion of PMAs during operation,
the diameters of
constraining Nylon mesh
and Silicone tubes have to closely match.
Also, it increases the PMA efficiency
as most of the air pressure is used for axial extension. Consequently, this
further helps to reduce the PMA dead zone. To meet these design requirements, we experimentally selected high-strength Nylon braided mesh with diameters $10~mm$ (minimum) and $18~mm$ (maximum). We used
$4~mm$ internal diameter union connectors to connect external pneumatic pressure lines
to PMAs.
Heavey duty
zip ties are used to secure silicon tubes, mesh to the other end of the
union connectors (Fig. \ref{fig:Fig2_PartDesign}-C.
Fabricated PMAs shown in Fig. \ref{fig:Fig2_PartDesign}-C can extend by up to 50\%, and withstand $700~kPa$ with a $90~kPa$ pressure dead zone.
\subsection{Hybrid Soft Robot (HSR) Assembly} \label{sub:integration}
\begin{figure}[tb]
\centering
\includegraphics[width=0.85\linewidth]{figures/Fig3_UnitDesign.pdf}
\caption{HSR and its counterpart with their design elements.}
\label{fig:Fig3_UnitDesign}
\end{figure}
Fig. \ref{fig:Fig2_PartDesign}-G shows the finished HSR prototype. Therein, we arranged 3 PMAs within the radially symmetric cavities (or grooves)
along the length of the backbone structure (Fig. \ref{fig:Fig2_PartDesign}-A). We designed and 3D-printed several parts (Fig. \ref{fig:Fig2_PartDesign}-D, E, and F) to
integrate PMAs to the backbone.
We used two end caps (Fig. \ref{fig:Fig2_PartDesign}-D)
to axially
secure the PMAs in place.
High-strength fasteners
then securely anchor the PMAs to the end caps
at either end of the backbone.
In this arrangement, the backbone constraints the PMA length change during operation which results in a spatially antagonistic PMA configuration for an increased stiffness range.
To prevent buckling and ensure uniform bending deformation during operation, we securely wrapped PMAs in parallel to the backbone
using a fishing wire.
The resulting fixed-length HSR has a uniform construction and exhibits omnidirectional and circular arc bending. We employed 3D-printed joints
shown in
Fig. \ref{fig:Fig2_PartDesign}-E and F
to connect HSRs
to the
actuation base or each other.
Apart from the
fixed-length
HSR robot with backbone, to compare operable stiffness ranges as detailed in Sec. \ref{sub:expStiffnessRange}, we fabricated an identical variable-length soft
robot
prototype without a backbone (Fig. \ref{fig:Fig3_UnitDesign}). We used identical PMAs in both prototype designs. Fig. \ref{fig:Fig3_UnitDesign} provides an overview of used design elements in each prototype.
\begin{figure}[tb]
\centering
\includegraphics[width=0.9\linewidth]{figures/Fig4_SchematicDiagram.pdf}
\caption{Schematic of the proposed HSR showing actuator arrangement.}
\label{fig:Fig4_SchematicDiagram}
\end{figure}
\begin{figure}[tb]
\centering
\includegraphics[width=0.9\linewidth]{figures/Fig5_Taskspace.png}
\caption{Spatial and top-down views showing the workspace symmetry.}
\label{fig:Fig5_Taskspace}
\end{figure}
\section{System Model}\label{sec:models}
\begin{figure}[t]
\centering
\includegraphics[width=0.8\linewidth]{figures/Fig6_ExperimentalSetup.pdf}
\caption{Experimental setups of the hybrid soft robot (HSR) and soft robots without backbone.}
\label{fig:Fig6_ExperimentalSetup}
\end{figure}
\begin{figure*}[t]
\centering
\includegraphics[width=0.8\linewidth]{figures/Fig7_StiffnessTesting.pdf}
\caption{Experimental setups to obtain bending stiffness in, (A) Soft robot (without backbone), (B) Proposed HSR (with backbone).}
\label{fig:Fig7_StiffnessTesting}
\end{figure*}
The kinematic modeling of the HSR is fundamentally similar to that of the variable-length continuum robots. However, the presence of length constraint introduces noteworthy characteristics that render it different in many respects including forward and inverse kinematic solutions.
%
Consider the schematic of the HSR shown in Fig. \ref{fig:Fig4_SchematicDiagram}.
Let the initial length of each actuator is $L$ whose change is in ${l_{i}} \in {\rm {\mathbb{R}}}$ where ${l_{i:\min }} \le {l_{i}}(t) \le {l_{i:\max }}$ for $i \in \{ 1,2,3\}$; $i$ and $t$ denote the actuator number and time, respectively. Therefore, ${L_{i}}(t) = L + {l_{i}}(t)$ calculates the actuator length at any time and the vector of joint variables of the HSR is defined as $\textbf{\textit{q}} = \left[ {{l_{1}}(t),\,{l_{2}}(t),\,{l_{3}}(t)} \right]^T$.
We define the
HSR coordinate frame, $\{O\}$
at the geometric center of the base (Fig. \ref{fig:Fig4_SchematicDiagram})
with a PMA, whose length change is denoted by $l_1$, coinciding with the $+X$ axis at a radius $r$ from the origin.
The PMAs denoted by $l_2$ and $l_3$ are situated in the counterclockwise direction at $\frac{2\pi}{3}$ and $\frac{4\pi}{3}$ angle offset from the $+X$, respectively.
When PMAs are actuated, forces resulting from elongation act on the endplates.
The force imbalance, due to a pressure differential in PMAs,
creates a net torque at the HSR tip,
causing the robot
to bend.
Given the uniform and radially symmetric construction, the HSR
neutral axis deforms
approximately in a circular arc shape.
(a reasonable assumption, as noted in \cite{godage2016dynamics}).
We parameterize the circular arc using
the
subtended angle,
$\phi \in \left[0,\pi\right]$, and the angle to the bending plane with respect to the $+X$ axis, $\theta \in \left[0,2\pi \right)$. From the backbone length, $L$, we can derive the radius of
the circular arc as $\frac{L}{\phi}$. Employing arc geometry, we can relate the
PMA lengths to the
arc parameters as
\vspace{1mm}
\begin{align}
L+l_{i} & =\left\{ \frac{L}{\phi }-r\cos\left(\frac{2\pi}{3}\left(i-1\right)-\theta \right)\right\} \phi \nonumber \\
l_{i}& = -r\phi \cos\left(\frac{2\pi}{3}\left(i-1\right)-\theta \right) \label{eq:l2cp}
\end{align}
%
Note that,
due to the inextensible nature of HSR, the sum of PMA length changes
should add up to zero, {i.e., $\sum_{\forall i} l_{i} = 0$ from \eqref{eq:l2cp}} resulting from the kinematic constraint $l_{1}=-\left(l_{2}+l_{3}\right)$.
This implies that one DoF, out of
three, is redundant and the
HSR kinematics
can be derived by using
two DoF.
The loss of DoF due to the
kinematic constraint
can be used to
derive a reduced-order kinematic model as reported by \cite{deng2019near}.
We will leverage the
redundant actuation DoF to control the stiffness and achieve independent stiffness and shape control. We use \eqref{eq:l2cp} to derive
arc parameters in terms of the jointspace variables as
\begin{subequations}
\begin{align}
\phi & =\frac{2\sqrt{\sum_{i=1}^{3}\left(l_{i}^{2}-l_{i}l_{\!\!\!\!\mod\left(i,3\right)+1}\right)}}{3r}\label{eq:cp_phi}\\
\theta & =\arctan\left\{ \sqrt{3}\left(l_{3}-l_{2}\right),l_{2}+l_{3}-2l_{1}\right\} \label{eq:cp_theta}
\end{align}
\label{eq:cp2l}
\end{subequations}
Similar to \cite{godage2015modal}, the curve parameters are then used to derive the homogeneous transformation matrix for the HSR as
%
\begin{align}
\mathbf{T}\left(\boldsymbol{q},\xi\right) & =\mathbf{R}_{Z}\left(\theta\right)\mathbf{P}_{X}\left(\frac{L}{\phi}\right)\mathbf{R}_{Y}\left(\phi\right)\mathbf{P}_{X}\left(-\frac{L}{\phi}\right)\mathbf{R}_{Z}\left(-\theta\right)\nonumber \\
& =\left[\begin{array}{cc}
\mathbf{R}\left(\boldsymbol{q},\xi\right) & \mathbf{p}\left(\boldsymbol{q},\xi\right)\\
0 & 1
\end{array}\right]\label{eq:htm}
\end{align}
%
where $\textbf{R}_Z$ and $\textbf{R}_Y$ are homogeneous rotation matrices about $+Z$ and $+Y$ and $\textbf{P}_X$, is the homogeneous translation matrix along $+X$. $\textbf{R}$ and $\textbf{p}$ are the homogeneous rotation and position matrices, respectively. The scalar $\xi \in \left[0,1\right]$ denotes the points along the neutral axis with $\xi=0$ coinciding with the origin of the robot coordinate frame and $\xi=1$ pointing to the tip. Readers are referred to \cite{godage2015modal} for more details regarding the derivation.
%
Fig. \ref{fig:Fig5_Taskspace} shows the
HSR tip taskspace
generated using the kinematic model in \eqref{eq:htm}.
It is worth reporting that, in comparison to
designs without backbones (i.e., variable-length designs), the HSR taskspace is symmetric about the +Z axis of the robot coordinate system.
Whereas the taskspace of robot designs without backbones
is tri-symmetric about the +Z axis.
In addition, the taskspace is essentially a thin shell (without volumetric coverage). In contrast, designs without backbones have a nonzero volume as a result of extension (or contraction) \cite{godage2015modal}.
The loss of a DoF also
results in a one-to-one mapping between the jointspace and curve parameters (configuration space).
This feature lets one perform the computations using curve parameters and then
derive
jointspace solutions. This approach is not feasible with variable-length robots as the curve parameters describing the arc radius and subtended angle are coupled \cite{godage2015modal}.
\section{Experimental Validation}\label{sec:results}
\subsection{Experimental Setups}\label{sub:exp_setup}
A block diagram of the experimental setup is shown in Fig. \ref{fig:Fig6_ExperimentalSetup}. The air compressor provides a constant $8~bar$, input air pressure.
Each PMA pressure is
controlled by an SMC ITV3000 (Orange Coast Pneumatics, Inc. USA) digital proportional pressure regulator.
Input pressure commands, generated by a MATLAB Simulink Desktop Real-time model, communicated to pressure regulators via an
NI PC-6704 data acquisition card.
To capture the HSR taskspace movement, three wireless 6-DoF trackers are used
(Polhemus G4 wireless -- Polhemus, Inc. USA).
We mounted trackers at either end -- base and tip -- as well as at the mid-point of the HSR (Refer to Fig. \ref{fig:Fig7_StiffnessTesting}- A \& B) and recorded the tracking data at $100~Hz$.
%
The complete experimental setups for both HSR and the variable-length counterpart (i.e., soft robot without backbone) are shown in Fig. \ref{fig:Fig7_StiffnessTesting}.
\begin{table}[tb]
\footnotesize
\setlength{\tabcolsep}{2pt}
\centering
\caption{Stiffness variation in soft robot without backbone and
HSR}
\label{table:bendingstiffness}
\begin{tabular}{cc|ccccccc}
\begin{sideways}\end{sideways} & \multicolumn{1}{c}{} & & \multicolumn{5}{c}{Bending stiffness [$Nm/ rad$]} & \\
\multicolumn{1}{l}{\begin{sideways}\end{sideways}} & \multicolumn{1}{l}{} & \multicolumn{7}{c}{without backbone} \\
\multirow{7}{*}{\rotcell{$P_1~[bar]$}} & 3.0 & x & x & x & x & x & x & {1.39} \\
& 2.5 & x & x & x & x & x & {1.22} & {1.32} \\
& 2.0 & x & x & x & x & {0.94} & {1.07} & {1.12} \\
& 1.5 & x & x & x & {0.62} & {0.71} & {0.86} & {0.92} \\
& 1.0 & x & x & {0.49} & {0.57} & {0.63} & {0.70} & {0.73} \\
& 0.5 & x & {0.42} & {0.46} & {0.51} & {0.59} & {0.62} & {0.62} \\
& 0.0 & {0.39} & {0.40} & {0.43} & {0.48} & {0.53} & {0.58} & {0.61} \\
\cline{3-9}
\begin{sideways}\end{sideways} & \multicolumn{1}{c}{} & 0.0 & 0.5 & 1.0 & 1.5 & 2.0 & 2.5 & 3.0 \\
\begin{sideways}\end{sideways} & \multicolumn{1}{c}{} & & \multicolumn{5}{c}{$P_2~[bar]$} & \\
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{5}{l}{} & \multicolumn{1}{l}{} \\
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{5}{c}{Bending stiffness [$Nm/ rad$]} & \multicolumn{1}{l}{} \\
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{5}{c}{with backbone} & \multicolumn{1}{l}{} \\
\multirow{7}{*}{\rotcell{$P_1~[bar]$}} & 3.0 & x & x & x & x & x & x & {3.21} \\
& 2.5 & x & x & x & x & x & {2.60} & {2.84} \\
& 2.0 & x & x & x & x & {1.76} & {1.96} & {2.40} \\
& 1.5 & x & x & x & {0.97} & {1.26} & {1.63} & {1.87} \\
& 1.0 & x & x & {0.70} & {0.82} & {0.97} & {1.21} & {1.45} \\
& 0.5 & x & {0.56} & {0.68} & {0.75} & {0.82} & {0.93} & {1.24} \\
& 0.0 & {0.52} & {0.54} & {0.62} & {0.70} & {0.79} & {0.90} & {1.12} \\
\cline{3-9}
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & 0.0 & 0.5 & 1.0 & 1.5 & 2.0 & 2.5 & 3.0 \\
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{5}{c}{$P_2~[bar]$}
\end{tabular}
\end{table}
\normalsize
\subsection{Validate Stiffness Control Range Improvement}\label{sub:expStiffnessRange}
This section assesses the impact of backbone integration on the improvement of controllable stiffness range with respect to the robot designs with and without backbone, shown in Fig. \ref{fig:Fig7_StiffnessTesting}-A and B respectively.
To limit the torsional deformation during operation, we constrain
the bending of
both designs to a plane.
We achieved this by
simultaneously supplying the same pressure commands to
two PMAs.
This results in planar bending deformation as shown in Fig. \ref{fig:Fig8_BendingStiffness}.
The other pressure input counteracts the bending and, due to the antagonistic PMA arrangement and fixed-length constraint, controls the stiffness.
We use an experimental
approach to estimate the stiffness. Thus, we can use the same arrangement and limit outside influences associated with setup changes.
Further,
as
we
replicate
the same test in both soft robot designs with identical actuator arrangements, we can extrapolate and generalize the results for omnidirectional bending across both designs. The supply pressure combinations that were applied in these tests are shown in Table \ref{table:bendingstiffness}.
To comply with the limitations of the experimental setup,
the pressure combinations are chosen such that the bending is unidirectional, as shown in Fig. \ref{fig:Fig8_BendingStiffness}. We achieve this behavior by setting a higher or equal pressure value to $P_2$ pressure component (corresponds to the pressure of two simultaneously actuated PMAs).
In this experiment,
we use pressure combinations outlined in Table \ref{table:bendingstiffness} for both designs.
Upon applying each
pressure
combination, we utilized a pulley arrangement to
provide
a bending torque perturbation.
Note that the torque perturbation is normal to the neutral axis of the prototype (Fig. \ref{fig:Fig7_StiffnessTesting}).
We recorded the
change in bending angle ($\Delta \phi$)
due to the torque perturbation ($\Delta \tau$).
Note that, the motion tracker
system
provides taskspace data
in terms of positions and orientations.
We used the
kinematic model in Sec. \ref{sec:models} to
derive the arc parameters, $\phi$, and $\theta$ from the taskspace data.
We calculated the bending stiffness ($K$) using $K=\frac{\Delta \tau}{\Delta \phi}$. We repeated the same procedure with similar pressure inputs on the variable-length soft robot (i.e., no backbone) design.
\begin{figure}[tb]
\centering
\includegraphics[width=0.85\linewidth]{figures/Fig8_BendingStiffness.pdf}
\caption{Percentage change of bending stiffness in two soft robot designs.}
\label{fig:Fig8_BendingStiffness}
\end{figure}
\begin{figure}[tb]
\centering
\includegraphics[width=1\linewidth]{figures/Fig9_P1P2Phi.pdf}
\caption{(A) Shape-pressure mapping of HSR, (B) Extracting pressure combinations for identified planner bending shapes.}
\label{fig:Fig9_P1P2Phi}
\end{figure}
Stiffness variation computed through perturbation tests
are presented in Table \ref{table:bendingstiffness}-Top for the backboneless soft robot and in Table \ref{table:bendingstiffness}-Bottom for the proposed HSR.
The percentage bending stiffness variation with respect to the natural bending stiffness -- at $P_1=0~bar$ and $P_2=0~bar$ -- is shown in Fig. \ref{fig:Fig8_BendingStiffness}. The percentage increase of the bending stiffness in the soft robot without a backbone is $\frac{(1.39-0.39)}{0.39} \times 100\ \% = 256.41\ \%$. Similarly, the percentage bending stiffness increase in the proposed HSR is $\frac{(3.21-0.52)}{0.52} \times 100\ \% = 517.31\ \%$. The results show that the bending stiffness increase in the proposed HSR is about 100\% higher than that of the variable-length soft robot.
Note that both designs have comparable natural stiffness (when applied pressures are 0). This result is expected because both designs use identical PMAs and physical arrangements sans the backbone. Thus, the results conclusively demonstrate that the backbone integration significantly enhances the operational bending stiffness range without betraying bending or compliance capability. With the added benefit of on-demand stiffening capability, it supports tasks requiring structural strength such as variable payload handling.
\begin{table}[tb]
\footnotesize
\setlength{\tabcolsep}{2pt}
\centering
\caption{Shape-pressure-stiffness mapping of HSR.}
\label{table:mappingtable}
\begin{tabular}{|c|c|c|c|}
\hline
\multirow{2}{*}{\begin{tabular}[c]{@{}c@{}} \textbf{HSR shape}\\$\phi$~$[rad]$\\ \end{tabular}} & \multicolumn{2}{c|}{\begin{tabular}[c]{@{}c@{}}\textbf{Pressure}\\\textbf{combinations} \end{tabular}} & \begin{tabular}[c]{@{}c@{}}\textbf{Bending }\\\textbf{stiffness}\end{tabular} \\
\cline{2-3}
& ${P_1}~[bar]$ & ${P_2}~[bar]$ & \multicolumn{1}{l|}{$[Nm/rad]$} \\
\hline
\multirow{4}{*}{0.4} & 0.50 & 1.86 & 0.63 \\
\cline{2-4}
& 0.75 & 1.90 & 0.81 \\
\cline{2-4}
& 1.00 & 1.96 & 1.11 \\
\cline{2-4}
& 1.25 & 2.09 & 1.32 \\
\hline
\multirow{4}{*}{0.6} & 0.50 & 2.11 & 0.71 \\
\cline{2-4}
& 0.75 & 2.17 & 0.85 \\
\cline{2-4}
& 1.00 & 2.24 & 1.40 \\
\cline{2-4}
& 1.25 & 2.39 & 1.71 \\
\hline
\multirow{4}{*}{0.8} & 0.50 & 2.36 & 0.86 \\
\cline{2-4}
& 0.75 & 2.42 & 1.42 \\
\cline{2-4}
& 1.00 & 2.52 & 1.90 \\
\cline{2-4}
& 1.25 & 2.67 & 2.18 \\
\hline
\multirow{4}{*}{1.0} & 0.50 & 2.60 & 1.56 \\
\cline{2-4}
& 0.75 & 2.68 & 1.98 \\
\cline{2-4}
& 1.00 & 2.80 & 2.33 \\
\cline{2-4}
& 1.25 & 2.98 & 2.58 \\
\hline
\end{tabular}
\end{table}
\normalsize
\subsection{Validate Decoupled Stiffness and Deformation Control}\label{sub:decoupleStiffnessShape}
We empirically evaluated the independent stiffness and shape controllability of the proposed HSR using the experimental setup in Fig. \ref{fig:Fig7_StiffnessTesting}-B. First, we recorded the shape variation ($\phi$) against a range of actuation pressure combinations ($P_1, P_2$) using the motion tracking
system under no-load conditions. Note that, here we applied bidirectional bending similar to Section \ref{sub:expStiffnessRange}. Fig. \ref{fig:Fig9_P1P2Phi}-A shows the recorded shape variation and Fig. \ref{fig:Fig9_P1P2Phi}-B shows the 2D plot of it. Marked bending shapes ($\phi_{1}-\phi_{4}$) in Fig. \ref{fig:Fig9_P1P2Phi}-B show that, along a particular bending plane (say $\phi_{1}$), we can extract several corresponding pressure combinations (highlighted in circles). Next, we applied a load profile and measured the corresponding bending stiffness (similar to Section \ref{sub:expStiffnessRange}) for four extracted pressure combinations on $\phi_{1}$ bending plane. Subsequently, we repeated the procedure for other bending planes ($\phi_{2}$, $\phi_{3}$, \&, $\phi_{4}$) and Table \ref{table:mappingtable} shows extracted pressure combinations and recorded bending stiffness values. The table data reveals that different stiffness values are recorded for the same bending angle under different pressure combinations indicating independent stiffness and shape controllability of the proposed HSR.
%
%
\subsection{Application Example: A
Soft Robotic Gripper}\label{sub:gripper}
We combined three HSR units to
fabricate a tri-fingered soft robotic gripper shown in Fig. \ref{fig:Fig10_ForceTestmaximumvoltage}-A \cite{arachchige2021novel}.
We conducted the experiment shown in Fig. \ref{fig:Fig10_ForceTestmaximumvoltage}-B to quantify the effect of decoupled stiffness and shape control
for
improving
grip quality
without exerting pressure on objectes.
We
quantify
grip quality
utilizing the external force perturbation needed to release an object from the grip. In that respect, higher forces indicates better grasp.
Three objects with geometrically varying surfaces but with the same smoothness (pyramid, ball, and box -- approximately $100~g$ weight)
were gripped by applying pressure combinations recorded in Table \ref{table:mappingtable} to HSR fingers. And in each actuation, an external pulling force is applied to the object via an attached cable until the grip fails. We coupled a $5~kg$ load cell
to record failure forces. Fig. \ref{fig:Fig10_ForceTestmaximumvoltage}-C shows a typical force sensor output
during the
test. Therein, we uniformly increase the force
while recording the force sensor data
until the grip fails. Then we apply a 50-sample moving average to
filter the noise in force sensor data
and measure the peak value (failure force).
Fig. \ref{fig:Fig10_ForceTestmaximumvoltage}-D presents maximum failure forces against each object's stiffness variation. The plots show that under the same finger shape (same $\phi$), the grip failure force increases with the bending stiffness for each object. Moreover, higher bending (i.e., firmer grip $\rightarrow$ $\phi_{1}<\phi_{2}<\phi_{3}<\phi_{4}$) has recorded
higher failure forces
for each object. Further, ball pulling and box pulling have recorded relatively the smallest and largest failure forces, respectively. This is due to the fact that ball and box have the relatively lowest and the highest irregular surfaces among the three object shapes. The force test results reveal that the proposed HSR units are useful in applications where independent stiffness and shape control is desired.
%
\begin{figure}[tb]
\centering
\includegraphics[width=1\linewidth]{figures/Fig10_ForceTestmaximumvoltage.pdf}
\caption{(A) Proposed variable stiffness gripper with pyramid and ball objects, (B) Force test experiment with box object, (C) Pulling force reading, (D) Failure forces of three objects.}
\label{fig:Fig10_ForceTestmaximumvoltage}
\end{figure}
\section{Conclusions}\label{sec:conclusions}
This paper proposed a novel HSR that combines rigid and soft elements in the construction. The HSR design is inspired by the spider monkey tails, where the muscles lining the inextensible vertebra control the shape and stiffness. We hypothesized that an articulable and inextensible backbone with PMAs could mimic the same biological characteristics. We extended the curve parametric approach to account for fixed-length design and derive the
HSR kinematic model. We experimentally compared the stiffness variation of the proposed HSR with an identical
soft robot without a backbone and showed that the new HSR has an approximately 100\% higher stiffness increase. Next, we conducted a pressure-shape-stiffness mapping experiment and showed that the proposed HSR can independently control the stiffness and shape. Subsequently, we presented an application example -- a soft robotic gripper constructed from the proposed HSR units -- to further validate the HSR's independent stiffness and shape controllability. The results showed that the new HSR can still operate the same way without significantly affecting taskspace performance or the natural compliance with the added benefit of a high stiffness range. This stiffness range opens up possibilities in field applications where adaptive stiffness is required, such as being human-friendly and supporting high payload capabilities beyond current soft robotic designs.
\bibliographystyle{IEEEtran}
|
{'timestamp': '2022-02-15T02:41:04', 'yymm': '2202', 'arxiv_id': '2202.06605', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06605'}
|
arxiv
|
\section{Introduction}
Transfer learning from models that have been pre-trained on huge datasets has become standard practice in many computer vision (CV) and natural language processing (NLP) tasks and applications. While approaches like semi-supervised sequence learning \cite{dai2015semi} and datasets such as ImageNet \cite{deng2009imagenet}---especially the ImageNet-ILSVRC-2012 dataset with 1.2 million images--- established pre-training approaches, the training data size increased rapidly to billions of training examples \cite{brown2020Language, jia2021align}, steadily improving the capabilities of deep models.
Recent transformer architectures with different objectives such as autoregressive \cite{radford2019language} and masked \cite{devlin2018bert} language modeling as well as natural language guided vision models \cite{radford21Learning} for multi-modal vision-language (VL) modeling have even enabled zero-shot transfer to downstream tasks, avoiding the need for
task-specific fine-tuning.
However, in all areas, the training data in the form of large and undercurated, internet-based datasets is problematic involving, e.g., stereotypical and derogatory associations \cite{gebru21datasheets, bender2021Stochastic}.
Along this line, \citet{gebru21datasheets} described dominant and hegemonic views, which further harm marginalized populations, urging researchers and dataset creators to invest significant resources towards dataset curation and documentation. Consequently, the creation of datasheets became common practice when novel datasets such as \cite{desai2021redcaps} were introduced. However, the documentation of \citet{desai2021redcaps} shows that careful manual documentation is difficult, if not even unfeasible, due to the immense size of current datasets: `\textit{We manually checked 50K} [out of 12M] \textit{random images in RedCaps and found one image containing
nudity (exposed buttocks; no identifiable face)}'. Also, in the process of creating a datasheet for the BookCorpus, \citet{bandy21addressing} stated that further research is necessary to explore the detection of potential inappropriate concepts in text data.
\citet{birhane2021Large} manually checked for and found misogynistic and pornographic in several common CV datasets.
However, misogynistic images and pornographic content are only part of the broader concept of inappropriate content. It remains challenging to identify concepts such as general offensiveness in images, including abusive, indecent, obscene, or menacing content.
To make a step towards meeting the challenge, the present work proposes a semi-automatic method, called Q16, to document inappropriate image content. We use the VL model CLIP \cite{radford21Learning} to show that it is indeed possible to (1) steer pre-trained models towards identifying inappropriate content as well as (2) the pre-trained models themselves towards mitigating the associated risks. In the Q16 setup, prompt-tuning steers CLIP to detect inappropriateness in images. Additionally, Q16 employs the recent autoregressive caption generation model MAGMA \cite{Eichenberg_Black_Weinbach_Parcalabescu_Frank_2021} to provide accessible documentation.
Thus, Q16 assists dataset documentation and curation by answering Question 16 of \cite{gebru21datasheets}, which also explains its name: \textit{Does the dataset contain data that, if viewed directly, might be offensive, insulting, threatening, or might otherwise cause anxiety?}
We illustrate Q16 on the popular ImageNet-ILSVRC-2012 \cite{deng2009imagenet} and OpenImages \cite{Kuznetsova2020theopen} dataset and show that large computer vision datasets contain additional inappropriate content, which previous documentations, such as \cite{birhane2021Large}, had not detected, cf.~Fig.~\ref{fig:inappropriate_concepts}. In contrast to images identified in previous approaches, e.g., images showing nudity and misogynistic images (blue), Q16 detects a larger and broader range of potential inappropriate images (red). These images show violence, misogyny, and otherwise offensive material. Importantly, this includes images portraying persons (dark gray) as well as objects, symbols, and text.
\begin{figure}[t]
\centering
\includegraphics[width=.9\linewidth]{images/method/Imagenet_documented_subsets.png}
\caption{Range of identified inappropriate concepts illustrated using ImageNet (green). The other colors refer to different data-subsets: a selection of all images displaying persons (dark gray), potentially inappropriate images identified by our approach (red), and human-validated inappropriate (misogynistic) images identified in the study of \citet{birhane2021Large} (blue). The detected images in our approach partly overlap with the one in blue.
Sizes are only illustrative, and actual numbers are given in the legend (right). Due to their apparent offensive content, we blurred the images.}
\label{fig:inappropriate_concepts}
\end{figure}
The rest of the paper is organized as follows. We start off with a brief overview of related work and required background introducing pre-trained models and their successes as well as concerns raised.
Next, we describe inappropriate image content and show that common deep models cannot reliably detect potential inappropriate images due to the lack of sufficient data. We then continue by demonstrating that recent models, guided by natural language during the pre-training phase, can classify and describe inappropriate material based on their retained knowledge.
Before concluding, we present our automated dataset documentation exemplary on the ImageNet-ILSVRC-2012 and OpenImagesV6 datasets.
We provide our models and the necessary data and code to reproduce our experiments and utilize our proposed method\footnote{\url{https://github.com/ml-research/OffImgDetectionCLIP}}.
\section{Background and related work}
\label{sec:background}
In this section, we describe pre-trained models in NLP, CV, and recent VL models.
Furthermore, we touch upon related work aiming to improve dataset documentation and curation as well as identifying problematic content in datasets.
\subsection{Large pre-trained models} \label{subsec:ptm}
Large-scale transformer-based language models revolutionized many NLP tasks \citep{Lin_Wang_Liu_Qiu_2021}.
As large, pre-trained models form the backbone of both natural language processing and computer vision today, it is natural that multimodal vision-language models \cite{radford21Learning, ramesh2021zero, jia2021align} extend these lines of research.
For their CLIP model, \citet{radford21Learning} collected over 400M image-text pairs (WebImageText dataset) to show that the success in large-scale transformer models in NLP can be transferred to vision and multimodal settings. One major takeaway from their work is the benefit of jointly training an image encoder and a text encoder to predict the correct pairings of a batch of (image, text) training examples. Typical vision models \cite{he16deep, tan19EfficientNet} jointly train an image feature extractor and a classifier. \citet{radford21Learning}, the authors of CLIP, proposed to synthesize the learned text encoder with a (zero-shot) linear classifier at test time by embedding the names or descriptions of the target dataset's classes, e.g. ``The image shows \textit{$<$label$>$}.'', thus reducing the (computational) cost of fine-tuning the model and using it as it was trained.
Such models and their zero-shot capabilities display significant promise for widely-applicable tasks like image retrieval or search. The relative ease of steering CLIP toward various applications with little or no additional data or training unlocks novel applications that were difficult to solve with previous methods, e.g., as we show, classify potential inappropriate image content.
\subsection{Issues arising from large datasets}
Large-scale models require a tremendous amount of training data. The most recent and successful models, such as GPT-3 \cite{brown2020Language}, CLIP \cite{radford21Learning}, DALL-E \cite{ramesh2021zero} and other similar models, are trained on data scraped from the web, e.g. using CommonCrawl. The information they acquire from this data is largely uncontrolled. However, even ImageNet \cite{deng2009imagenet}, which was released in 2012 and remains one of the most popular datasets in the computer vision domain to this day \cite{brock21high, tan21efficentnetv2}, contains questionable content \cite{birhane2021Large}.
The entailed issues have been discussed for language models, for instance, models producing stereotypical and derogatory content \cite{bender2021Stochastic}, and for vision model respectively CV datasets highlighting, e.g., gender and racial biases \cite{steed21image, Larrazabal12592, wang20revise, denton21on}.
Consequently, \citet{gebru21datasheets} urged the creation of datasheets accompanying the introduction of novel datasets including a variety of information on the dataset to increase transparency and accountability within the ML community, and most importantly, help researchers and practitioners to select more appropriate datasets for their tasks.
The documentation and curation of datasets have become a very active research area, and along with it, the detection of inappropriate material contained in datasets and reflected by deep models.
\citet{dodge_documenting_2021} documented the very large C4 corpus with features such as `text source' and `content', arguing for different levels of documentation. They also address how C4 was created and show that this process removed texts from and about minorities.
A vast body of work to date that describes methodologies to tackle, abusive, offensive, hateful \cite{Glavas_Karan_Vulic_2020}, toxic \cite{Han_Tsvetkov_2020}, stereotypical \cite{Nadeem_Bethke_Reddy_2021} or otherwise biased content \cite{Dhamala_Sun_Kumar_Krishna_Pruksachatkun_Chang_Gupta_2021} come from NLP. For several years, workshops on language\footnote{https://aclanthology.org/volumes/W17-30/} and offensive\footnote{https://sites.google.com/site/offensevalsharedtask/home} language are carried out, producing evaluation datasets. Furthermore, Google hosts an API for the automatic detection of toxicity\footnote{https://www.perspectiveapi.com/} in language, and research introduced toxicity benchmarks for generative text models \cite{gehman2020realtoxicityprompts}.
Additionally, the definitions and datasets on such tasks as bias- and hate-speech identification become increasingly complex \cite{Sap_Gabriel_Qin_Jurafsky_Smith_Choi_2020}.
Accordingly, most of the research on automatic methods focuses solely on text.
With the present study, we aim to push the development of methods for the CV domain.
\citet{yang_towards_2020} argued towards fairer datasets and filter parts of ImageNet. Specifically, they see issues in ImageNet's concept vocabulary based on WordNet and include images for all concept categories (some hard to visualize). Furthermore, the inequality of representation (such as gender and race) in the images that illustrate these concepts is problematic.
\citet{birhane2021Large} provided modules to detect faces and post-process them to provide privacy, as well as a pornographic content classifier to remove inappropriate images.
Furthermore, they conducted a hand-surveyed image selection to identify misogynistic images in the ImageNet-ILSVRC-2012 (ImageNet1k) dataset.
\citet{gandhi2020scalable} aimed to detect offensive product content using machine learning; however, they have described the lack of adequate training data.
Recently, \citet{nichol21glide} applied CLIP to filter images of violent objects but also images portraying people and faces.
\subsection{Retained knowledge of large models}
Besides the performance gains, large-scale models show surprisingly strong abilities to recall factual knowledge from the training data \cite{petroni2019language}. For example, \citet{roberts2020how} showed large-scale pre-trained language models' capability to store and retrieve knowledge scales with model size.
\citet{schick2021self} demonstrated that language models can self-debias the text they produce, specifically regarding toxic output.
Similar to our work, they prompt a model. However, they use templates with questions in the form of ``this model contains <MASK>'', where the gap is filled with attributes, such as toxicity, whereas we automatically learn prompts.
Furthermore, \citet{MCM} and \citet{schramowski2020themoral} showed that the retained knowledge of such models carries information about moral norms aligning with the human sense of \textit{``right''} and \textit{``wrong''} expressed in language.
Similar to \cite{schick2021self}, \citet{schramowski2021language} demonstrated how to utilize this knowledge to guide autoregressive language models' text generation to prevent their toxic degeneration.
\section{The Q16 Pipeline for Datasheets}
Let us now start to introduce our semi-automatic method to document inappropriate image content. To this end, we first clarify the term ``inappropriateness'' in Sec.~\ref{sec:inappr_content_definition}.
Then we present and evaluate models, including our approach (illustrated in Fig~\ref{fig:method}a), to classify inappropriate image content.
Specifically, Fig~\ref{fig:method}a shows a dataset representing socio-moral norms, which will be detailed in Sec.~\ref{subsec:smid}, steering CLIP to detect inappropriate content using (soft)~prompt-tuning (cf.~Sec.~\ref{sec:inappr_classifier}).
Lastly, in Sec.~\ref{sec:documentation}, we present the two-step semi-automated documentation (cf.~Fig~\ref{fig:method}b).
Notably, both steps include human interaction.
First, CLIP and the learned prompts from Fig~\ref{fig:method}a are used to detect inappropriate images within the dataset.
Detection is conservative, aiming to identify all potentially inappropriate content. Accordingly, the subsets are of considerable size, e.g., ~40K in the case of ImageNet1k. Therefore, the second step generates automatic image descriptions to assist the dataset creators in describing and validating the identified content.
The final documentation of Q16 includes the ratio of identified images and the total amount of samples, and a summary of the identified concepts.
To overview the contained concepts in an easily accessible way, we generate word clouds based on two properties: the dataset annotation and generated description.
\begin{figure*}[t]
\centering
\includegraphics[width=0.95\textwidth]{images/method/method_ab.png}
\caption{Overview of the Q16 pipeline, a two-step dataset documentation approach. a) In order to utilize the implicit knowledge of the large pre-trained models, prompt-tuning steers CLIP to classify inappropriate image content. b) Dataset documentation process: First, a subset with potentially inappropriate content is identified. Secondly, these images are documented by, if available, image annotations and automatically generated image descriptions. Both steps are designed for human interaction.
}
\label{fig:method}
\end{figure*}
\subsection{Inappropriate image content.}
\label{sec:inappr_content_definition}
Let us start off by clarifying the way we use the term ``inappropriate'' in our work and describing the term in the context of images. Question 16 of
Datasheets for Datasets \cite{gebru21datasheets} asks one to document the dataset composition regarding the contained ``data that, if viewed directly, might be offensive, insulting, threatening, or might otherwise cause anxiety''.
Consequently, \citet{birhane2021Large} applied different models to detect visible faces (thus violating privacy rights) and pornographic content. Additionally, they conducted a survey identifying misogynistic images. However, the definition of \citet{gebru21datasheets} includes a broader range of inappropriate concepts not addressed by current work.
According to the Cambridge dictionary\footnote{https://dictionary.cambridge.org/dictionary/english/offending, accessed on 3rd October 2021}, `offending' can be phrased as `unwanted, often because unpleasant and causing problems'. Additionally, in the context of images and text, according to Law Insider\footnote{https://www.lawinsider.com/dictionary/offending-materials, accessed on 3rd October 2021}:
`\textit{Offending Materials means any material, data, images, or information which is (a) in breach of any law, regulation, code of practice or acceptable use policy; or (b) defamatory, false, inaccurate, abusive, indecent, obscene or menacing or otherwise offensive; or (c) in breach of confidence, copyright or other intellectual property rights, privacy or any other right of any third party.}' In the present paper, we focus on images following the definition (b). This definition aligns with definitions of previous work detecting hate speech \cite{gomez2020exploring} and offensive product images \cite{gandhi2020scalable}.
Note that inappropriateness, especially offensiveness, is a concept that is based on social norms, and people have diverse sentiments. In the present study, we detect inappropriate content based on the implicit knowledge contained in CLIP steered with selected data. Therefore, the investigated `inappropriateness' may primarily surface from the group of people that have generated the selected data and the annotators but also the pre-trained model's retained knowledge.
\subsection{The Socio-Moral Image Database (SMID)} \label{subsec:smid}
Besides utilizing the `knowledge' of pre-trained models on inappropriate concepts, we further steer the model towards detecting (morally) inappropriate image concepts indirectly via training examples. To this end, we propose to use the Socio-Moral Image Database (SMID) \cite{crone2018TheSocio} together with the few-shot capabilities of CLIP.
The SMID dataset contains $2{,}941$ images covering both morally positive and negative poles (962 negative images and 712 positive images) over several content dimensions, including objects, symbols as well as actions. The images were annotated by $2{,}716$ annotators. Fig.~\ref{fig:smid_data_pca_a} shows the density distribution of the annotated data. \citet{crone2018TheSocio} suggested to divide the data into \textit{good} (green; mean rating $>\!3.5$), \textit{bad} (red; mean rating $<\!2.5$), and neutral (gray; rest) images.
According to this division we considered a $\text{rating}\!<\!2.5$ as (morally) inappropriate, and $\text{rating}\!>\!3.5$ as counterexamples.
In the following experiments, $10$-fold cross-validated results are reported.
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/smid/final/smid_dataset.png}
\caption{SMID data distribution.}
\label{fig:smid_data_pca_a}
\vspace{3.8mm}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/smid/final/pca_imagenet_resnet_small.png}
\caption{ResNet50 pre-trained on \\ ImageNet1k.}
\label{fig:smid_data_pca_b}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/smid/final/pca_clip_vit_small.png}
\caption{ViT-B/16 pre-trained on \\ WebImageText via CLIP.}
\label{fig:smid_data_pca_c}
\end{subfigure}
\caption{The SMID dataset. a) $\text{Rating}\!<\!2.5$ are samples showing possible inappropriate concepts and $>\!3.5$ counterexamples.
b-c) PCA visualization of SMID feature space using different pre-trained models. Coloring of data samples indicates the rating of the image's content. The scale corresponds to a).}
\label{fig:smid_data_pca}
\end{figure*}
\subsection{Inappropriate content detection of Q16}
\label{sec:inappr_classifier}
Let us now move on to presenting and evaluating different models, including our CLIP-based Q16 approach, for the task at hand to classify inappropriate image content.
\paragraph{\bf Deep Learning baselines.} As baselines we fine-tuned two standard pre-trained CV models (PMs) to investigate how well deep neural networks can identify inappropriate content.
Similar to \citet{gandhi2020scalable}, we used the ResNet50 architecture \cite{he2016deep}, pre-trained on ImageNet datasets \cite{deng2009imagenet}.
Fig.~\ref{fig:smid_data_pca_b} shows a PCA dimension reduction of the embedded representations of the pre-trained model, i.e., before being trained on the SMID dataset. Based on this dimension reduction, it is unclear if the ImageNet1k pre-trained ResNet50 variant is able to infer inappropriate image content reliably.
Furthermore, Tab.~\ref{tab:smid_classification_results} shows the performance of both the fine-tuned model (training all model parameters) and a model with only one linear probing layer. In our work, the probing layer refers to adding one final classification layer to the model.
The table shows inconclusive results: even if the performance increases when a larger dataset (ImageNet21k) is used. After fine-tuning the whole model, recall increases; precision, however, is still comparatively low. Specifically, the resulting low precision and low recall of the linear probed ImagNet1k-based models show problems classifying truly inappropriate images as well as distinguishing between truly non-inappropriate and inappropriate images.
We will use these models as baselines to investigate if more advanced PMs (trained on larger unfiltered datasets) carry information about potential inappropriate image content.
\begin{table}[t]
\centering
\begin{tabular}{c|l||c|c|c|c}
Architecture &Pre-training dataset & Accuracy (\%) & Precision & Recall & F1-Score \\ \hline
\multirow{5}{*}{ResNet50}&\multirow{2}{*}{ImageNet1k} &$78.36\pm1.76$&$0.75\pm0.05$& $0.74\pm0.09$& $0.76\pm0.02$\\
&&$80.81\pm2.95$&$0.75\pm0.02$& $0.81\pm0.02$& $0.80\pm0.03$\\\cline{2-6}
&\multirow{2}{*}{ImageNet21k} &$82.11\pm1.94$&$0.78\pm0.02$& $0.80\pm0.05$& $0.78\pm0.04$\\
& &$84.99\pm1.95$&$0.82\pm0.01$& $0.85\pm0.06$& $0.82\pm0.04$\\\cline{2-6}
&WebImageText &$\circ90.57 \pm 1.82$&$\circ0.91\pm0.03$& $\circ0.89\pm0.01$& $\circ0.88\pm0.03$ \\ \hline
ViT-B/32&WebImageText &$94.52 \pm 2.10$&$0.94\pm0.04$& $0.91\pm0.02$& $0.92\pm0.01$ \\
ViT-B/16&WebImageText &$\mathbf{\bullet96.30 \pm 1.09}$&$\mathbf{\bullet0.95\pm0.02}$& $\mathbf{\bullet0.97\pm0.01}$& $\mathbf{\bullet0.97\pm0.02}$
\end{tabular}
\caption{Performances of pre-trained models ResNet50 and ViT-B. The ResNet50 is pre-trained on ImageNet1k, ImageNet21k \cite{deng2009imagenet} and the WebTextImage dataset \cite{radford21Learning}. The ViT is pre-trained on the WebTextImage dataset. On the ImageNet datasets, we applied linear probing (top) and fine-tuning (bottom), and on the WebImageText-based models, soft-prompt tuning. The overall best results are highlighted \textbf{bold} with the $\bullet$ marker and best on the ResNet50 architecture with $\circ$ markers. Mean values and standard deviations are reported.}
\label{tab:smid_classification_results}
\end{table}
\paragraph{\bf Zero and few-shot capabilities of CLIP to infer inappropriate content.}
To investigate if CLIP's contrastive pre-training step contains image-text pairs that equip the model with a notion of inappropriate concepts, we again start off by illustrating the embedding space of the SMID images.
Fig.~\ref{fig:smid_data_pca_c} shows the PCA on embeddings of CLIP's ViT-B/16 model pre-trained on WebImageText via Contrastive Language-Image Pre-training \cite{radford21Learning}. As one can see, ViT can indeed distinguish inappropriate content and corresponding counterexamples without being explicitly trained to do so, encoding task-specific knowledge.
This observation confirms our assumption that due to the natural language supervision, CLIP implicitly acquired knowledge about what a human could ---depending on the context--- perceive as inappropriate content.
Now, the inappropriateness classifier of our approach (Fig.~\ref{fig:method}a) utilizes this `knowledge'. It is based on prompting CLIP with a natural language. Our prompts have the form ``This image is about something $<$\textit{label}$>$.'', helping to specify that the text is actually about the content of the image.
To map the labels of the SMID dataset to natural language sentences, we used the following prompts following \citet{crone2018TheSocio}:
\textit{bad/good behavior}, \textit{blameworthy/praiseworthy},
\textit{positive/negative} and \textit{moral/immoral}. The \textit{positive} and \textit{negative} labels resulted in the best zero-shot performance.
Images are encoded via the pre-trained visual encoder, similar to the ResNet50 model. However, instead of training a linear classifier to obtain class predictions as in these models, we now operate on the similarity of samples (the cosine similarity) in the representation space:
\begin{equation}
Sim(x, z) = \frac{E_{visual}(x) * E_{text}(z)}{||E_{visual}(x)||_2 * ||E_{text}(z)||_2} \ ,
\end{equation}
where $E_{visual}$ and $E_{text}$ are the visual and text encoders, $x$ is an image sample and $z$ a prompt. Fig.~\ref{fig:smid_cv_results} ($0\%$, prompt-tuning) shows that this approach already performs on par with the ImageNet-based PMs fine-tuned on SMID ($100\%$, linear probing).
However, the zero-shot approach can classify true-negative samples well but performs not so well on classifying positives. This observation suggests that both prompts, at least the one corresponding to the positive class label, are not optimal.
\begin{figure}[t]
\centering
\includegraphics[width=0.95\linewidth]{images/smid/results_zerolast_2col.jpg}
\caption{Performance of pre-trained models ResNet50 and ViT-B. ResNet50 is pre-trained on ImageNet1k, ImageNet21k \cite{deng2009imagenet} and the WebTextImage dataset \cite{radford21Learning}. ViT is pre-trained on the WebTextImage dataset. On the ImageNet datasets, we applied linear probing (top), and on the WebImageText-based models used soft-prompt tuning. Tuning was performed on different sizes of the SMID training set where $100\%$ corresponds to $1{,}506$ images.
}
\label{fig:smid_cv_results}
\end{figure}
\paragraph{\bf Steering CLIP to infer inappropriate content via prompt-tuning.} \label{par:steering}
The manual handwritten prompts may not be the best way to query the model. Consequently, we used prompt-tuning \citep{lester_power_2021, qin2021learning, qin2021learning} to learn continuous optimal prompts. Prompt-tuning optimizes the prompts by searching for the optimal text embeddings for a given class label.
Several variations employ prompt-tuning: Prefix-tuning, for example, learns a prefix to add to a sample's embedding \citep{qin2021learning} on every model layer. \citet{lester_power_2021} created new (prompt) embeddings only once by pre-pending a small vector to the original input embedding for all downstream examples. \citet{Hambardzumyan_Khachatrian_May_2021} updated both the input and final embeddings once.
In contrast, we propose to learn the entire final sentence embedding once, obtaining one sentence embedding, $z_{emb}$, for each class label. In turn, the distinction of inappropriate and other images is defined as an optimization task using gradient descent as follows:
\begin{equation}
\mathbf{\hat{z}}_{emb} = \argmax\nolimits_{\mathbf{z}_{emb}}\{L(\mathbf{z}_{emb})\} \ ,
\end{equation} where
\begin{equation}
L(\mathbf{z}_{emb}) = - \frac{1}{|X|}\sum\nolimits_{\mathbf{x} \in X} \mathbf{y} \ \log(\mathbf{\hat{y}}) \ \text{, \quad with } \mathbf{\hat{y}} = \text{softmax}(Sim(\mathbf{x},\mathbf{z}_{emb})) \ .
\end{equation}
Here, the parameters $\theta$ of $E_{visual}$ and $E_{text}$ are not updated. The initial prompts $Z$ are only propagated through $E_{text}$ once and the resulting embeddings $\mathbf{z}_{emb} \in Z_{emb}$ are optimized. Furthermore, $\mathbf{y}$ is the class label, and $X$ a batch in the stochastic gradient descent optimization.
\begin{figure}[t]
\centering
\includegraphics[width=.95\linewidth]{images/prompt-tuning.png}
\caption{Soft-prompt tuning on vision-language representation space. The squared data samples visualize the initial prompt's locations and cross the learned prompts. The nearest image samples from the SMID dataset are displayed to illustrate each optimized prompt on the right.}
\label{fig:prompttuning}
\end{figure}
Our prompt-tuning approach is summarized visually in Fig.~\ref{fig:method}.
Moreover, Fig.~\ref{fig:prompttuning} shows exemplary nearest image neighbors of the learned prompts. The image on the right side clearly portrays possible inappropriate content. In contrast, the image on the left side displays a positive scene as a counterexample. Fig.~\ref{fig:smid_cv_results} also shows an evaluation of CLIP using the soft prompts (prompt-tuning). We can see that a small portion of the training data (e.g., 4\%, 60 images) already leads to an increase of the vision transformer's (ViT-B) performance to over 90\%.
In general, the ViT-B outperforms the pre-trained ResNet50 models. Furthermore, ViT-B/16 outperforms the ViT-B/32, indicating that not only the dataset's size is important, but also the capacity of the model (ViT-B/16 has higher hidden-state resolution than
the ViT-B/32).
Training ViT with the full training set results in $96.30\% \pm 1.09$ (cf. Tab.~\ref{tab:smid_classification_results}) accuracy.
Overall, one can see that steering CLIP towards inferring potentially inappropriate concepts in images requires only little additional data. In contrast to other pre-trained models, it provides a reliable method to detect inappropriate images.
\subsection{Dataset documentation of Q16}
\label{sec:documentation}
Using our prompt-tuning approach, the pre-selection by CLIP can, in principle, extract possible inappropriate images automatically that can then be used for dataset documentation.
However, we have to be a bit more careful since inappropriateness is subjective to the user---e.g., researchers and practitioners selecting the dataset for their tasks---and, importantly, to the task at hand. In our case, the steered model may primarily mirror the moral compass and social expectations of the $2{,}716$ annotators.
Therefore, it is required that humans and machines interact with each other, and the user can select the images based on their given setting and requirements.
Hence, we do not advise removing specific images but investigating the range of examples and inappropriate content selected by the model and thereby documenting the dataset.
In the following, we present our approach to assist data creators not only in identifying but also describing the identified potential inappropriate content.
\paragraph{\bf Answering Datasheet Question 16: Does the dataset contain data that, if viewed directly, might be offensive, insulting, threatening, or
might otherwise cause anxiety?}
As intended by the original datasheets paper \cite{gebru21datasheets}, dataset creators should start describing the curation process concerning this question.
Whereas our approach could also be used for the curation, we focus solely on documenting the final dataset content to mitigate unwanted societal biases in ML models, and help users select appropriate datasets for their chosen tasks.
The dataset documentation should contain the total amount of images and the ratio of identified, potentially inappropriate images. Since the process of creating a datasheet is not intended to be automated \cite{gebru21datasheets}---however, the quality of current datasheets \cite{desai2021redcaps} indicate that a semi-automated method is unavoidable---, the resulting subset should be manually validated and described by the dataset's creators. Our approach aims to reduce impractical human labor while encouraging creators to reflect on the process carefully.
\paragraph{\bf Automatic caption generation.}
In order to categorize and thus describe the identified content, dataset annotations can be used if they are available.
However, these annotations often may not describe the complete image content, especially in the case of natural images. Therefore, we utilize automatic generation of image descriptions, cf. Fig.~\ref{fig:method}b (right).
To this end, we propose to generate text using a caption-generation model. Specifically, we used MAGMA (Multimodal Augmentation of Generative Models) \cite{Eichenberg_Black_Weinbach_Parcalabescu_Frank_2021}. MAGMA is a recent text generation model based on multimodal few-shot learners \cite{Tsimpoukelli_Menick_Cabi}. It uses both the CLIP and GPT-J \cite{gpt-j} models and adds pre-training and fine-tuning steps on several datasets to generate image captions from image-text pairs. These captions are especially beneficial because they include the encyclopedic knowledge of GPT-J, and as such, knowledge on socio-moral norms (similar to the one we obtain from CLIP).
Further, the multimodal input enables one to guide the resulting textual description. Since we aim to generate ``neutral'' image descriptions, we use the prompt \textit{<A picture of>} and add the output of multiple generations to the image description. To sample from the model, we applied top-k filtering. In order to acquire greater variety in the descriptions, we used different temperature values.
\paragraph{\bf Word cloud generation.}
Actually, Question 16 asks the dataset curator to be familiar with a broad range of inappropriate concepts. Whereas our Q16 approach already helps reduce the number of inappropriate images to be checked and, in turn, human labor, even the validation of the reduced set may still require a lot of manual effort.
To provide a concise overview, we propose to compute word clouds to summarize the complex captions generated.
More precisely, we present the identified, potentially inappropriate content within the dataset using three different kinds of word clouds from dataset annotations and generated textual image descriptions. All word clouds highlight words or bi-grams based on their frequency and rank.
The first word cloud requires existing dataset annotations, e.g., class labels, and provides first insights of identified concepts and could highlight sensible labels.
The word cloud visualizes the information by highlighting the most-frequent annotations. However, note that dataset creators should also pay attention to infrequent occurrences indicating deviating concepts compared to other examples from, e.g., the same class. Many images with the same annotation could indicate a general negative association.
Following the same procedure, the second word cloud describes the identified set of images using the generated text and thus independent of the dataset annotations. Therefore, this word cloud potentially describes identified concepts not captured by the first word cloud.
For the third word cloud, we use a chi-squared weighting of the word/bi-gram frequencies to illustrate differences between the identified inappropriate image set and the remaining images; common text descriptions occurring in both sets are removed. Each word $i$ is assigned the following weight:
\begin{equation}
weight_i = \frac{(observed_i - expected_i)^2}{expected_i} \ ,
\end{equation}
where $observed_i$ is the observed frequency of word $i$ in the inappropriate subset and $expected_i$ the expected value, i.e., the observed word frequency describing the dataset's remaining samples.
This word cloud highlights the conspicuous descriptions that can be traced back to the corresponding images.
Finally, we would like to note that our pipeline also produces several statistics such as exact word frequencies and traceable image descriptions that we do not include directly in the datasheet. The dataset creators can provide this additional information as a supplement next to the identified image IDs.
\section{Answering Datasheet Question 16 for ImageNet and OpenImages}
Now we have everything together to provide an exemplary datasheet documentation, here for the CV datasets ImageNet \cite{deng2009imagenet} and OpenImages \cite{Kuznetsova2020theopen}.
To identify inappropriate content within the datasets, we used the public available ViT-B/16 variant of CLIP steered by SMID-based optimized prompts. We observed that shifting the negative threshold to a rating of $1.5$ instead of $2.5$ provides a conservative but reliable classifier; hence we determined the prompts with these corresponding few-shot examples. For the documentation process we utilized the ResNet50x16 MAGMA model and generated 10 captions ($k=5$ using a temperature of $\tau=0.1$ and $k=5$ using $\tau=0.4$) for each images. Additionally to the following documentations, we provide Python notebooks with the corresponding images along with the classifier in our public repository\footnote{\url{https://github.com/ml-research/OffImgDetectionCLIP}}.
\subsection{ImageNet}
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/wordclouds/imagenettrain/wordcloud_classes_freq.png}
\caption{Most-frequent image annotations.}
\label{fig:word_clouds_imagenet_a}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/wordclouds/imagenettrain/wordcloud_caption_freq_temp0-1and0-4.png}
\caption{Most-frequent image descriptions.}
\label{fig:word_clouds_imagenet_b}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/wordclouds/imagenettrain/wc_diffOffAndNonoff_chi-squared_scaling0-25.png}
\caption{
Weighted image descriptions.
}
\label{fig:word_clouds_imagenet_c}
\end{subfigure}
\caption{Word clouds documenting the potentially inappropriate image content of the ImageNet1k dataset. Image annotations are contained within the dataset. Image descriptions are automatically generated.
Word size is proportional to the word counts and rank in the generated captions corresponding to the inappropriate image set.
}
\label{fig:word_clouds_imagenet}
\end{figure*}
We start with one of the most known CV datasets, ImageNet1k (ImageNet-ILSVRC2012).
Additionally to the concise overview using word clouds (Fig.~\ref{fig:word_clouds_imagenet}) we provide further detailed description (highlighting the class labels) on the identified inappropriate concepts, and blurred examples for illustration (Fig.~\ref{fig:imagenet_listed_samples}).
We separate the identified content into potentially inappropriate objects, symbols, and actions due to the complexity of inappropriate context.
\textbf{Objects.}
The ImageNet1k dataset, also known as ImageNet-ILSVRC-2012, formed the basis of task-1 of the ImageNet Large Scale Visual Recognition Challenge. Hence, all images ($1{,}331{,}167$) display animals or objects. To illustrate potential missing information in the dataset's annotations, we restricted ourselves not to include the hierarchical information contained in the synsets, cf. the first word cloud in Fig.~\ref{fig:word_clouds_imagenet_a}.
Therefore, it is not surprising that the largest portion of the potential inappropriate content concerns negative associated objects and animals. In total, $40{,}501$ images were identified by the classifier, where the objects ``gasmask'' (797 images), ``guillotine'' (783), and ``revolver'' (725) are the top-3 classes. However, whereas most people would assign these objects as morally questionable and offensive, they may not be treated as inappropriate when training a general object classifier. The same applies to the animal-classes tick (554) and spider (397).
To detect more suspicious, inappropriate content, it may be more applicable to investigate classes with only a small portion of possible inappropriate images.
Next to injured (``king penguin'') and aggressive animals (e.g. ``pembroke''), our proposed classifier detects caged (e.g. ``great pyrenees'', ``cock'') and dead animals (e.g. ``squirrel monkey'', ``african elephant''). Additionally, objects in inappropriate, possible offensive scenes, like a bathtub tainted with blood (``tub'') or a person murdered with a screwdriver (``screwdriver'') are extracted, cf. also Fig.~\ref{fig:imagenet_listed_samples}.
\begin{figure}[t]
\centering
\includegraphics[width=0.9\linewidth]{images/listed_images_blur.jpg}
\caption{Exemplary images with inappropriate content from the pre-selection of our proposed method. The images visualize the range of concepts (objects, symbols, actions) detected. Due to their apparent offensive content, we blurred the images. Their content can be inferred from the main text.}
\label{fig:imagenet_listed_samples}
\end{figure}
\textbf{Symbols.}
Both the second (\textit{person, woman, man}) and the third word cloud (\textit{person wearing}) highlight that in many cases persons are subject to the inappropriate concepts identified.
In the corresponding images, one is able to identify offensive symbols and text on objects:
several National Socialist symbols especially swastika (e.g. ``mailbag'', ``military uniform''), persons in Ku-Klux-Klan uniform (e.g. ``drum''), insults by e.g. showing the middle finger (e.g. ``miniature pinscher'', ``lotion''), cf. first row of Fig.~\ref{fig:imagenet_listed_samples}.
Furthermore, we observed the occurrence of offensive text such as ``child porn'' (``file'') and ``bush=i***t f*** off USA'' (``pay-phone'').
\textbf{Actions.}
The third word cloud further documents the identified concepts. Words like \textit{blood, torture, execution} show that in addition to objects and symbols, our classifier interprets scenes in images and hence identifies offensive actions shown in images. Scenes such as burning buildings (e.g. ``church'') and catastrophic events (e.g. ``airliner'', ``trailer truck'') are identified. More importantly, inappropriate scenes with humans involved are extracted such as comatose persons (e.g. ``apple'', ``brassiere'', ``tub''), persons involved in an accident (e.g. ``mountain bike''), the act of hunting animals (e.g. ``African elephant'', ``impala''), a terrifying person hiding under a children's crib (``crib''),
scenes showing weapons or tools used to harm, torture and kill animals (e.g.``hamster'') and people (e.g. ``hatchet'', ``screwdriver'', ``ballpoint'', ``tub'').
Furthermore, derogative scenes portraying men and women wearing muzzles, masks, and plastic bags, clearly misogynistic images, e.g., harmed women wearing an abaya, but also general nudity with exposed genitals (e.g. ``bookshop'', ``bikini'', ``swimming trunks'') and clearly derogative nudity (e.g. ``plastic bag'') are automatically selected by our proposed method. Note that multiple misogynistic images, e.g., the image showing a harmed woman wearing an abaya, were not identified by the human hand surveyed image selection of \citet{birhane2021Large}. Therefore, we strongly advocate utilizing the implicit knowledge of large-scale state-of-the-art models in a human-in-the-loop curation process to not only partly automatize the process but also to reduce the susceptibility to errors.
\subsection{OpenImages}
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/wordclouds/openimagestrain/wordcloud_classes_freq.png}
\caption{Most-frequent image annotations.}
\label{fig:word_clouds_openimages_a}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/wordclouds/openimagestrain/wordcloud_caption_freq_temp0-1and0-4.png}
\caption{Most-frequent image descriptions.}
\label{fig:word_clouds_openimages_b}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/wordclouds/openimagestrain/wc_diffOffAndNonoff_chi-squared_scaling0-25_bigramsTrue.png}
\caption{
Weighted image descriptions.
}
\label{fig:word_clouds_openimages_c}
\end{subfigure}
\caption{Word clouds documenting the potentially inappropriate image content of the OpenImagesV6 dataset. Image annotations are contained within the dataset. Image descriptions are automatically generated.
Word size is proportional to the word counts and rank in the generated captions corresponding to the inappropriate image set.
}
\label{fig:word_clouds_openimages}
\end{figure*}
Our next exemplary documentation is based on the dataset OpenImages \cite{Kuznetsova2020theopen}. Its first version \cite{openimagesv1} was released in 2016, and the newest version 6 in 2020. The dataset contains 1.9M images with either single or multiple objects labeled, resulting in 59.9M image-level labels spanning $19{,}957$ classes and 16M bounding boxes for 600 object classes.
In contrast to the ImageNet documentation, we only provide the intended concise overview for Datasheet's Question 16.
Thus refrain from showing exemplary images. However, after describing the content using the word clouds, we want to point out one extremely disturbing example.
We documented the training set of OpenImagesV6 ($1{,}743{,}042$ images) and identified a potentially inappropriate set of $43{,}395$ images. Fig.~\ref{fig:word_clouds_openimages} shows our computed word clouds.
The first word cloud (Fig.~\ref{fig:word_clouds_openimages_a}) shows that most identified images portray persons with labels like ``human head'', ``human face'', or ``human body'', showing both men and woman. The second word cloud (Fig.~\ref{fig:word_clouds_openimages_b}) reflects this observation but additionally highlights the portray of, e.g., guns. Further, it points out that posters are displayed. We observed that often the corresponding images show covers of pornographic material.
The third word cloud reveals more interesting concepts (Fig.~\ref{fig:word_clouds_openimages_c}). We can again observe the descriptions \textit{cartoon, poster} referring to potential disturbing art, but also graffiti with inappropriate text. Furthermore, the description \textit{gun} is further highlighted. Human skulls and skeletons are displayed as well as dead and harmed animals (\textit{dead mouse, dead bird}). Importantly, the descriptions \textit{bloody face, blood, wound} refer to the concept of harm. It is noteworthy that, as the descriptions \textit{zombie} and \textit{zombie mask} could suggest, the corresponding images sometimes show costumes and makeup, however, also often real scenes. This observation demonstrates that human validation is necessary.
\paragraph{\bf Dead bodies: Abu Ghraib torture and prisoner abuse.}
Whereas the kind of images described above need to be documented and could have an influence on users' opinion regarding the dataset selection, the generated description \textit{gallows, execution, person lying, dead bodies} (cf. Fig.~\ref{fig:word_clouds_openimages_c}) extremely disturbed us while checking the corresponding images. Especially, we want to highlight one image we found (ID: 30ec50721c384003.jpg,
\abstwarning{{\fontencoding{U}\fontfamily{futs}\selectfont\char 66\relax} looking at the picture could be disturbing}).
The image shows several scenes, also known as ``Abu Ghraib torture and prisoner abuse'', displaying members of the U.S. Army posing in front of dead bodies during the Iraq War. These scenes were classified as a series of human rights violations and war crimes. They show sexual abuse, torture, rape, sodomy, and the killing of Manadel al-Jamadi (clearly identifiable in the dataset's image). Note that this
image is labeled (``person'', ``man'', ``clothing'', ``human face'') and was annotated with bounding boxes, thus checked by human annotators. Besides documentation, our approach can also pre-flag such images as potentially inappropriate to validate them during annotation.
\section{Societal Impact and Limitations}
\label{sec:ethics_statement}
Recent developments in large pertained models in NLP, such as GPT-3 have a far-reaching impact on society (300+ applications building on the model as of March 2021\footnote{https://openai.com/blog/gpt-3-apps/}), and we assume that the popularity of pre-trained CV, especially those including VL, models will follow along that path. So it is natural that the discussions surrounding ethical issues, such as biases, in NLP models transfer to VL models. Indeed, recently some awareness of problematic content in CV datasets arose; however, we are actually faced with broader issues in image datasets. \citet{birhane2021Large} described many negative societal implications underlying CV datasets' issues regarding, e.g., groups at margins such as high error rates for dark-skinned people in CV models recognizing pedestrians. Such issues even lead to the deletion of entire datasets\footnote{https://venturebeat.com/2020/07/01/mit-takes-down-80-million-tiny-images-data-set-due-to-racist-and-offensive-content/}. These issues are likely to become even more prominent since VL models combining images and text will become more applicable in industry and, in turn, generate great impact on society.
Specifically, large datasets underlying much of current machine learning raise serious issues concerning inappropriate content such as offensive, insulting, threatening, or might otherwise cause anxiety.
This calls for increased dataset documentation, e.g., using datasheets. They, among other topics, encourage to reflect on the composition of the datasets. So far, this documentation, however, is done manually and therefore can be tedious and error-prone, especially for large image datasets.
Here we ask the arguably ``circular'' question of whether a machine can help us reflect on inappropriate content, answering Question 16 in Datasheets \cite{gebru21datasheets}.
To this end, we provide a method to automatically detect and describe inappropriate image content to assist documentation of datasets.
Such automation might tempt dataset creators to neglect manual validation.
However, we strongly advise applying such methods in a human-in-the-loop setting as intended by \citet{gebru21datasheets} and described in our demonstrations. Humans should stay in control.
There are natural limitations that should be addressed in future work. First, we chose a binary classification to detect general inappropriate content, then described using a text-generation model. Thus, extending previous categories into more fine-grained
concepts could further improve transparency and documentation.
We strongly advocate applying our documentation along with other methods, e.g., detecting faces and pornographic content \cite{birhane2021Large} in future work.
Furthermore, while the SMID dataset with moral norms provides a good proxy for inappropriateness, developing novel CV datasets to drill down further on identifying inappropriateness and similar concepts would be very beneficial.
Moreover, whereas we evaluated our \textit{inappropriateness classifier}, we did not evaluate our automatic generation of textual image descriptions summarizing the portrayed inappropriate concepts. Doing so provides an interesting avenue for future work. Moreover, to ensure broad descriptions, we executed multiple generation iterations. Also, fine-tuning a caption generation model could lead to further improvements. Likewise, \citet{radford21Learning} provided details about possible biases and other potential misuses of CLIP models, which could easily influence the detection as well as the description that we used.
Generally, advances in bias-free models are very likely to also positively impact our introduced approach.
Finally, like other social norms, inappropriate concepts, especially offensiveness, do evolve constantly. This evolution makes it necessary to update the data, system, and documentation over time. Furthermore, an important avenue for future work is addressing what different groups of society, e.g., different cultures, would consider inappropriate. Here, we just relied on the ones averaged by the SMID dataset.
\section{Conclusion}
Deep learning models trained on large-scale image datasets have become standard practice for many applications. Unfortunately, they are unlikely to perform well if their deployment contexts do not match their training or evaluation datasets or if the images reflect unwanted behavior. To assist humans in the dataset curation process, particularly when facing millions of images, we propose Q16, a novel approach utilizing the implicit knowledge of large-scale pre-trained models and illustrated its benefits. Specifically, we argued that CLIP retains the required `knowledge' about what a human would consider offending during its pre-training phase and, in turn, requires only few shots to automatically identify offensive material. On two canonical large scale image datasets, ImageNet-ILSVRC2012 and OpenImages, we demonstrate that the resulting approach, called Q16, can indeed identify inappropriate content, actually broader than previous, manual studies.
Q16 provides several interesting avenues for future work. First, one should investigate other computer vision as well as multi-modal datasets. One should also extend Q16 to multi-label classification, directly separate offensive objects, symbols, actions, and other categories of inappropriate content at once. Moreover, moving beyond binary classification towards gradual levels of inappropriateness may result in more fine-grained details in the datasheets. Finally, the underlying deep models are black-boxes, making it hard to understand why specific images are identified and described as inappropriate. Combining Q16 with explainable AI methods such as \cite{Chefer2021transformer} to explain the reasons is likely to improve the datasheet.
\bibliographystyle{ACM-Reference-Format}
\section{Introduction}
Transfer learning from models that have been pre-trained on huge datasets has become standard practice in many computer vision (CV) and natural language processing (NLP) tasks and applications. While approaches like semi-supervised sequence learning \cite{dai2015semi} and datasets such as ImageNet \cite{deng2009imagenet}---especially the ImageNet-ILSVRC-2012 dataset with 1.2 million images--- established pre-training approaches, the training data size increased rapidly to billions of training examples \cite{brown2020Language, jia2021align}, steadily improving the capabilities of deep models.
Recent transformer architectures with different objectives such as autoregressive \cite{radford2019language} and masked \cite{devlin2018bert} language modeling as well as natural language guided vision models \cite{radford21Learning} for multi-modal vision-language (VL) modeling have even enabled zero-shot transfer to downstream tasks, avoiding the need for
task-specific fine-tuning.
However, in all areas, the training data in the form of large and undercurated, internet-based datasets is problematic involving, e.g., stereotypical and derogatory associations \cite{gebru21datasheets, bender2021Stochastic}.
Along this line, \citet{gebru21datasheets} described dominant and hegemonic views, which further harm marginalized populations, urging researchers and dataset creators to invest significant resources towards dataset curation and documentation. Consequently, the creation of datasheets became common practice when novel datasets such as \cite{desai2021redcaps} were introduced. However, the documentation of \citet{desai2021redcaps} shows that careful manual documentation is difficult, if not even unfeasible, due to the immense size of current datasets: `\textit{We manually checked 50K} [out of 12M] \textit{random images in RedCaps and found one image containing
nudity (exposed buttocks; no identifiable face)}'. Also, in the process of creating a datasheet for the BookCorpus, \citet{bandy21addressing} stated that further research is necessary to explore the detection of potential inappropriate concepts in text data.
\citet{birhane2021Large} manually checked for and found misogynistic and pornographic in several common CV datasets.
However, misogynistic images and pornographic content are only part of the broader concept of inappropriate content. It remains challenging to identify concepts such as general offensiveness in images, including abusive, indecent, obscene, or menacing content.
To make a step towards meeting the challenge, the present work proposes a semi-automatic method, called Q16, to document inappropriate image content. We use the VL model CLIP \cite{radford21Learning} to show that it is indeed possible to (1) steer pre-trained models towards identifying inappropriate content as well as (2) the pre-trained models themselves towards mitigating the associated risks. In the Q16 setup, prompt-tuning steers CLIP to detect inappropriateness in images. Additionally, Q16 employs the recent autoregressive caption generation model MAGMA \cite{Eichenberg_Black_Weinbach_Parcalabescu_Frank_2021} to provide accessible documentation.
Thus, Q16 assists dataset documentation and curation by answering Question 16 of \cite{gebru21datasheets}, which also explains its name: \textit{Does the dataset contain data that, if viewed directly, might be offensive, insulting, threatening, or might otherwise cause anxiety?}
We illustrate Q16 on the popular ImageNet-ILSVRC-2012 \cite{deng2009imagenet} and OpenImages \cite{Kuznetsova2020theopen} dataset and show that large computer vision datasets contain additional inappropriate content, which previous documentations, such as \cite{birhane2021Large}, had not detected, cf.~Fig.~\ref{fig:inappropriate_concepts}. In contrast to images identified in previous approaches, e.g., images showing nudity and misogynistic images (blue), Q16 detects a larger and broader range of potential inappropriate images (red). These images show violence, misogyny, and otherwise offensive material. Importantly, this includes images portraying persons (dark gray) as well as objects, symbols, and text.
\begin{figure}[t]
\centering
\includegraphics[width=.9\linewidth]{images/method/Imagenet_documented_subsets.png}
\caption{Range of identified inappropriate concepts illustrated using ImageNet (green). The other colors refer to different data-subsets: a selection of all images displaying persons (dark gray), potentially inappropriate images identified by our approach (red), and human-validated inappropriate (misogynistic) images identified in the study of \citet{birhane2021Large} (blue). The detected images in our approach partly overlap with the one in blue.
Sizes are only illustrative, and actual numbers are given in the legend (right). Due to their apparent offensive content, we blurred the images.}
\label{fig:inappropriate_concepts}
\end{figure}
The rest of the paper is organized as follows. We start off with a brief overview of related work and required background introducing pre-trained models and their successes as well as concerns raised.
Next, we describe inappropriate image content and show that common deep models cannot reliably detect potential inappropriate images due to the lack of sufficient data. We then continue by demonstrating that recent models, guided by natural language during the pre-training phase, can classify and describe inappropriate material based on their retained knowledge.
Before concluding, we present our automated dataset documentation exemplary on the ImageNet-ILSVRC-2012 and OpenImagesV6 datasets.
We provide our models and the necessary data and code to reproduce our experiments and utilize our proposed method\footnote{\url{https://github.com/ml-research/OffImgDetectionCLIP}}.
\section{Background and related work}
\label{sec:background}
In this section, we describe pre-trained models in NLP, CV, and recent VL models.
Furthermore, we touch upon related work aiming to improve dataset documentation and curation as well as identifying problematic content in datasets.
\subsection{Large pre-trained models} \label{subsec:ptm}
Large-scale transformer-based language models revolutionized many NLP tasks \citep{Lin_Wang_Liu_Qiu_2021}.
As large, pre-trained models form the backbone of both natural language processing and computer vision today, it is natural that multimodal vision-language models \cite{radford21Learning, ramesh2021zero, jia2021align} extend these lines of research.
For their CLIP model, \citet{radford21Learning} collected over 400M image-text pairs (WebImageText dataset) to show that the success in large-scale transformer models in NLP can be transferred to vision and multimodal settings. One major takeaway from their work is the benefit of jointly training an image encoder and a text encoder to predict the correct pairings of a batch of (image, text) training examples. Typical vision models \cite{he16deep, tan19EfficientNet} jointly train an image feature extractor and a classifier. \citet{radford21Learning}, the authors of CLIP, proposed to synthesize the learned text encoder with a (zero-shot) linear classifier at test time by embedding the names or descriptions of the target dataset's classes, e.g. ``The image shows \textit{$<$label$>$}.'', thus reducing the (computational) cost of fine-tuning the model and using it as it was trained.
Such models and their zero-shot capabilities display significant promise for widely-applicable tasks like image retrieval or search. The relative ease of steering CLIP toward various applications with little or no additional data or training unlocks novel applications that were difficult to solve with previous methods, e.g., as we show, classify potential inappropriate image content.
\subsection{Issues arising from large datasets}
Large-scale models require a tremendous amount of training data. The most recent and successful models, such as GPT-3 \cite{brown2020Language}, CLIP \cite{radford21Learning}, DALL-E \cite{ramesh2021zero} and other similar models, are trained on data scraped from the web, e.g. using CommonCrawl. The information they acquire from this data is largely uncontrolled. However, even ImageNet \cite{deng2009imagenet}, which was released in 2012 and remains one of the most popular datasets in the computer vision domain to this day \cite{brock21high, tan21efficentnetv2}, contains questionable content \cite{birhane2021Large}.
The entailed issues have been discussed for language models, for instance, models producing stereotypical and derogatory content \cite{bender2021Stochastic}, and for vision model respectively CV datasets highlighting, e.g., gender and racial biases \cite{steed21image, Larrazabal12592, wang20revise, denton21on}.
Consequently, \citet{gebru21datasheets} urged the creation of datasheets accompanying the introduction of novel datasets including a variety of information on the dataset to increase transparency and accountability within the ML community, and most importantly, help researchers and practitioners to select more appropriate datasets for their tasks.
The documentation and curation of datasets have become a very active research area, and along with it, the detection of inappropriate material contained in datasets and reflected by deep models.
\citet{dodge_documenting_2021} documented the very large C4 corpus with features such as `text source' and `content', arguing for different levels of documentation. They also address how C4 was created and show that this process removed texts from and about minorities.
A vast body of work to date that describes methodologies to tackle, abusive, offensive, hateful \cite{Glavas_Karan_Vulic_2020}, toxic \cite{Han_Tsvetkov_2020}, stereotypical \cite{Nadeem_Bethke_Reddy_2021} or otherwise biased content \cite{Dhamala_Sun_Kumar_Krishna_Pruksachatkun_Chang_Gupta_2021} come from NLP. For several years, workshops on language\footnote{https://aclanthology.org/volumes/W17-30/} and offensive\footnote{https://sites.google.com/site/offensevalsharedtask/home} language are carried out, producing evaluation datasets. Furthermore, Google hosts an API for the automatic detection of toxicity\footnote{https://www.perspectiveapi.com/} in language, and research introduced toxicity benchmarks for generative text models \cite{gehman2020realtoxicityprompts}.
Additionally, the definitions and datasets on such tasks as bias- and hate-speech identification become increasingly complex \cite{Sap_Gabriel_Qin_Jurafsky_Smith_Choi_2020}.
Accordingly, most of the research on automatic methods focuses solely on text.
With the present study, we aim to push the development of methods for the CV domain.
\citet{yang_towards_2020} argued towards fairer datasets and filter parts of ImageNet. Specifically, they see issues in ImageNet's concept vocabulary based on WordNet and include images for all concept categories (some hard to visualize). Furthermore, the inequality of representation (such as gender and race) in the images that illustrate these concepts is problematic.
\citet{birhane2021Large} provided modules to detect faces and post-process them to provide privacy, as well as a pornographic content classifier to remove inappropriate images.
Furthermore, they conducted a hand-surveyed image selection to identify misogynistic images in the ImageNet-ILSVRC-2012 (ImageNet1k) dataset.
\citet{gandhi2020scalable} aimed to detect offensive product content using machine learning; however, they have described the lack of adequate training data.
Recently, \citet{nichol21glide} applied CLIP to filter images of violent objects but also images portraying people and faces.
\subsection{Retained knowledge of large models}
Besides the performance gains, large-scale models show surprisingly strong abilities to recall factual knowledge from the training data \cite{petroni2019language}. For example, \citet{roberts2020how} showed large-scale pre-trained language models' capability to store and retrieve knowledge scales with model size.
\citet{schick2021self} demonstrated that language models can self-debias the text they produce, specifically regarding toxic output.
Similar to our work, they prompt a model. However, they use templates with questions in the form of ``this model contains <MASK>'', where the gap is filled with attributes, such as toxicity, whereas we automatically learn prompts.
Furthermore, \citet{MCM} and \citet{schramowski2020themoral} showed that the retained knowledge of such models carries information about moral norms aligning with the human sense of \textit{``right''} and \textit{``wrong''} expressed in language.
Similar to \cite{schick2021self}, \citet{schramowski2021language} demonstrated how to utilize this knowledge to guide autoregressive language models' text generation to prevent their toxic degeneration.
\section{The Q16 Pipeline for Datasheets}
Let us now start to introduce our semi-automatic method to document inappropriate image content. To this end, we first clarify the term ``inappropriateness'' in Sec.~\ref{sec:inappr_content_definition}.
Then we present and evaluate models, including our approach (illustrated in Fig~\ref{fig:method}a), to classify inappropriate image content.
Specifically, Fig~\ref{fig:method}a shows a dataset representing socio-moral norms, which will be detailed in Sec.~\ref{subsec:smid}, steering CLIP to detect inappropriate content using (soft)~prompt-tuning (cf.~Sec.~\ref{sec:inappr_classifier}).
Lastly, in Sec.~\ref{sec:documentation}, we present the two-step semi-automated documentation (cf.~Fig~\ref{fig:method}b).
Notably, both steps include human interaction.
First, CLIP and the learned prompts from Fig~\ref{fig:method}a are used to detect inappropriate images within the dataset.
Detection is conservative, aiming to identify all potentially inappropriate content. Accordingly, the subsets are of considerable size, e.g., ~40K in the case of ImageNet1k. Therefore, the second step generates automatic image descriptions to assist the dataset creators in describing and validating the identified content.
The final documentation of Q16 includes the ratio of identified images and the total amount of samples, and a summary of the identified concepts.
To overview the contained concepts in an easily accessible way, we generate word clouds based on two properties: the dataset annotation and generated description.
\begin{figure*}[t]
\centering
\includegraphics[width=0.95\textwidth]{images/method/method_ab.png}
\caption{Overview of the Q16 pipeline, a two-step dataset documentation approach. a) In order to utilize the implicit knowledge of the large pre-trained models, prompt-tuning steers CLIP to classify inappropriate image content. b) Dataset documentation process: First, a subset with potentially inappropriate content is identified. Secondly, these images are documented by, if available, image annotations and automatically generated image descriptions. Both steps are designed for human interaction.
}
\label{fig:method}
\end{figure*}
\subsection{Inappropriate image content.}
\label{sec:inappr_content_definition}
Let us start off by clarifying the way we use the term ``inappropriate'' in our work and describing the term in the context of images. Question 16 of
Datasheets for Datasets \cite{gebru21datasheets} asks one to document the dataset composition regarding the contained ``data that, if viewed directly, might be offensive, insulting, threatening, or might otherwise cause anxiety''.
Consequently, \citet{birhane2021Large} applied different models to detect visible faces (thus violating privacy rights) and pornographic content. Additionally, they conducted a survey identifying misogynistic images. However, the definition of \citet{gebru21datasheets} includes a broader range of inappropriate concepts not addressed by current work.
According to the Cambridge dictionary\footnote{https://dictionary.cambridge.org/dictionary/english/offending, accessed on 3rd October 2021}, `offending' can be phrased as `unwanted, often because unpleasant and causing problems'. Additionally, in the context of images and text, according to Law Insider\footnote{https://www.lawinsider.com/dictionary/offending-materials, accessed on 3rd October 2021}:
`\textit{Offending Materials means any material, data, images, or information which is (a) in breach of any law, regulation, code of practice or acceptable use policy; or (b) defamatory, false, inaccurate, abusive, indecent, obscene or menacing or otherwise offensive; or (c) in breach of confidence, copyright or other intellectual property rights, privacy or any other right of any third party.}' In the present paper, we focus on images following the definition (b). This definition aligns with definitions of previous work detecting hate speech \cite{gomez2020exploring} and offensive product images \cite{gandhi2020scalable}.
Note that inappropriateness, especially offensiveness, is a concept that is based on social norms, and people have diverse sentiments. In the present study, we detect inappropriate content based on the implicit knowledge contained in CLIP steered with selected data. Therefore, the investigated `inappropriateness' may primarily surface from the group of people that have generated the selected data and the annotators but also the pre-trained model's retained knowledge.
\subsection{The Socio-Moral Image Database (SMID)} \label{subsec:smid}
Besides utilizing the `knowledge' of pre-trained models on inappropriate concepts, we further steer the model towards detecting (morally) inappropriate image concepts indirectly via training examples. To this end, we propose to use the Socio-Moral Image Database (SMID) \cite{crone2018TheSocio} together with the few-shot capabilities of CLIP.
The SMID dataset contains $2{,}941$ images covering both morally positive and negative poles (962 negative images and 712 positive images) over several content dimensions, including objects, symbols as well as actions. The images were annotated by $2{,}716$ annotators. Fig.~\ref{fig:smid_data_pca_a} shows the density distribution of the annotated data. \citet{crone2018TheSocio} suggested to divide the data into \textit{good} (green; mean rating $>\!3.5$), \textit{bad} (red; mean rating $<\!2.5$), and neutral (gray; rest) images.
According to this division we considered a $\text{rating}\!<\!2.5$ as (morally) inappropriate, and $\text{rating}\!>\!3.5$ as counterexamples.
In the following experiments, $10$-fold cross-validated results are reported.
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/smid/final/smid_dataset.png}
\caption{SMID data distribution.}
\label{fig:smid_data_pca_a}
\vspace{3.8mm}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/smid/final/pca_imagenet_resnet_small.png}
\caption{ResNet50 pre-trained on \\ ImageNet1k.}
\label{fig:smid_data_pca_b}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/smid/final/pca_clip_vit_small.png}
\caption{ViT-B/16 pre-trained on \\ WebImageText via CLIP.}
\label{fig:smid_data_pca_c}
\end{subfigure}
\caption{The SMID dataset. a) $\text{Rating}\!<\!2.5$ are samples showing possible inappropriate concepts and $>\!3.5$ counterexamples.
b-c) PCA visualization of SMID feature space using different pre-trained models. Coloring of data samples indicates the rating of the image's content. The scale corresponds to a).}
\label{fig:smid_data_pca}
\end{figure*}
\subsection{Inappropriate content detection of Q16}
\label{sec:inappr_classifier}
Let us now move on to presenting and evaluating different models, including our CLIP-based Q16 approach, for the task at hand to classify inappropriate image content.
\paragraph{\bf Deep Learning baselines.} As baselines we fine-tuned two standard pre-trained CV models (PMs) to investigate how well deep neural networks can identify inappropriate content.
Similar to \citet{gandhi2020scalable}, we used the ResNet50 architecture \cite{he2016deep}, pre-trained on ImageNet datasets \cite{deng2009imagenet}.
Fig.~\ref{fig:smid_data_pca_b} shows a PCA dimension reduction of the embedded representations of the pre-trained model, i.e., before being trained on the SMID dataset. Based on this dimension reduction, it is unclear if the ImageNet1k pre-trained ResNet50 variant is able to infer inappropriate image content reliably.
Furthermore, Tab.~\ref{tab:smid_classification_results} shows the performance of both the fine-tuned model (training all model parameters) and a model with only one linear probing layer. In our work, the probing layer refers to adding one final classification layer to the model.
The table shows inconclusive results: even if the performance increases when a larger dataset (ImageNet21k) is used. After fine-tuning the whole model, recall increases; precision, however, is still comparatively low. Specifically, the resulting low precision and low recall of the linear probed ImagNet1k-based models show problems classifying truly inappropriate images as well as distinguishing between truly non-inappropriate and inappropriate images.
We will use these models as baselines to investigate if more advanced PMs (trained on larger unfiltered datasets) carry information about potential inappropriate image content.
\begin{table}[t]
\centering
\begin{tabular}{c|l||c|c|c|c}
Architecture &Pre-training dataset & Accuracy (\%) & Precision & Recall & F1-Score \\ \hline
\multirow{5}{*}{ResNet50}&\multirow{2}{*}{ImageNet1k} &$78.36\pm1.76$&$0.75\pm0.05$& $0.74\pm0.09$& $0.76\pm0.02$\\
&&$80.81\pm2.95$&$0.75\pm0.02$& $0.81\pm0.02$& $0.80\pm0.03$\\\cline{2-6}
&\multirow{2}{*}{ImageNet21k} &$82.11\pm1.94$&$0.78\pm0.02$& $0.80\pm0.05$& $0.78\pm0.04$\\
& &$84.99\pm1.95$&$0.82\pm0.01$& $0.85\pm0.06$& $0.82\pm0.04$\\\cline{2-6}
&WebImageText &$\circ90.57 \pm 1.82$&$\circ0.91\pm0.03$& $\circ0.89\pm0.01$& $\circ0.88\pm0.03$ \\ \hline
ViT-B/32&WebImageText &$94.52 \pm 2.10$&$0.94\pm0.04$& $0.91\pm0.02$& $0.92\pm0.01$ \\
ViT-B/16&WebImageText &$\mathbf{\bullet96.30 \pm 1.09}$&$\mathbf{\bullet0.95\pm0.02}$& $\mathbf{\bullet0.97\pm0.01}$& $\mathbf{\bullet0.97\pm0.02}$
\end{tabular}
\caption{Performances of pre-trained models ResNet50 and ViT-B. The ResNet50 is pre-trained on ImageNet1k, ImageNet21k \cite{deng2009imagenet} and the WebTextImage dataset \cite{radford21Learning}. The ViT is pre-trained on the WebTextImage dataset. On the ImageNet datasets, we applied linear probing (top) and fine-tuning (bottom), and on the WebImageText-based models, soft-prompt tuning. The overall best results are highlighted \textbf{bold} with the $\bullet$ marker and best on the ResNet50 architecture with $\circ$ markers. Mean values and standard deviations are reported.}
\label{tab:smid_classification_results}
\end{table}
\paragraph{\bf Zero and few-shot capabilities of CLIP to infer inappropriate content.}
To investigate if CLIP's contrastive pre-training step contains image-text pairs that equip the model with a notion of inappropriate concepts, we again start off by illustrating the embedding space of the SMID images.
Fig.~\ref{fig:smid_data_pca_c} shows the PCA on embeddings of CLIP's ViT-B/16 model pre-trained on WebImageText via Contrastive Language-Image Pre-training \cite{radford21Learning}. As one can see, ViT can indeed distinguish inappropriate content and corresponding counterexamples without being explicitly trained to do so, encoding task-specific knowledge.
This observation confirms our assumption that due to the natural language supervision, CLIP implicitly acquired knowledge about what a human could ---depending on the context--- perceive as inappropriate content.
Now, the inappropriateness classifier of our approach (Fig.~\ref{fig:method}a) utilizes this `knowledge'. It is based on prompting CLIP with a natural language. Our prompts have the form ``This image is about something $<$\textit{label}$>$.'', helping to specify that the text is actually about the content of the image.
To map the labels of the SMID dataset to natural language sentences, we used the following prompts following \citet{crone2018TheSocio}:
\textit{bad/good behavior}, \textit{blameworthy/praiseworthy},
\textit{positive/negative} and \textit{moral/immoral}. The \textit{positive} and \textit{negative} labels resulted in the best zero-shot performance.
Images are encoded via the pre-trained visual encoder, similar to the ResNet50 model. However, instead of training a linear classifier to obtain class predictions as in these models, we now operate on the similarity of samples (the cosine similarity) in the representation space:
\begin{equation}
Sim(x, z) = \frac{E_{visual}(x) * E_{text}(z)}{||E_{visual}(x)||_2 * ||E_{text}(z)||_2} \ ,
\end{equation}
where $E_{visual}$ and $E_{text}$ are the visual and text encoders, $x$ is an image sample and $z$ a prompt. Fig.~\ref{fig:smid_cv_results} ($0\%$, prompt-tuning) shows that this approach already performs on par with the ImageNet-based PMs fine-tuned on SMID ($100\%$, linear probing).
However, the zero-shot approach can classify true-negative samples well but performs not so well on classifying positives. This observation suggests that both prompts, at least the one corresponding to the positive class label, are not optimal.
\begin{figure}[t]
\centering
\includegraphics[width=0.95\linewidth]{images/smid/results_zerolast_2col.jpg}
\caption{Performance of pre-trained models ResNet50 and ViT-B. ResNet50 is pre-trained on ImageNet1k, ImageNet21k \cite{deng2009imagenet} and the WebTextImage dataset \cite{radford21Learning}. ViT is pre-trained on the WebTextImage dataset. On the ImageNet datasets, we applied linear probing (top), and on the WebImageText-based models used soft-prompt tuning. Tuning was performed on different sizes of the SMID training set where $100\%$ corresponds to $1{,}506$ images.
}
\label{fig:smid_cv_results}
\end{figure}
\paragraph{\bf Steering CLIP to infer inappropriate content via prompt-tuning.} \label{par:steering}
The manual handwritten prompts may not be the best way to query the model. Consequently, we used prompt-tuning \citep{lester_power_2021, qin2021learning, qin2021learning} to learn continuous optimal prompts. Prompt-tuning optimizes the prompts by searching for the optimal text embeddings for a given class label.
Several variations employ prompt-tuning: Prefix-tuning, for example, learns a prefix to add to a sample's embedding \citep{qin2021learning} on every model layer. \citet{lester_power_2021} created new (prompt) embeddings only once by pre-pending a small vector to the original input embedding for all downstream examples. \citet{Hambardzumyan_Khachatrian_May_2021} updated both the input and final embeddings once.
In contrast, we propose to learn the entire final sentence embedding once, obtaining one sentence embedding, $z_{emb}$, for each class label. In turn, the distinction of inappropriate and other images is defined as an optimization task using gradient descent as follows:
\begin{equation}
\mathbf{\hat{z}}_{emb} = \argmax\nolimits_{\mathbf{z}_{emb}}\{L(\mathbf{z}_{emb})\} \ ,
\end{equation} where
\begin{equation}
L(\mathbf{z}_{emb}) = - \frac{1}{|X|}\sum\nolimits_{\mathbf{x} \in X} \mathbf{y} \ \log(\mathbf{\hat{y}}) \ \text{, \quad with } \mathbf{\hat{y}} = \text{softmax}(Sim(\mathbf{x},\mathbf{z}_{emb})) \ .
\end{equation}
Here, the parameters $\theta$ of $E_{visual}$ and $E_{text}$ are not updated. The initial prompts $Z$ are only propagated through $E_{text}$ once and the resulting embeddings $\mathbf{z}_{emb} \in Z_{emb}$ are optimized. Furthermore, $\mathbf{y}$ is the class label, and $X$ a batch in the stochastic gradient descent optimization.
\begin{figure}[t]
\centering
\includegraphics[width=.95\linewidth]{images/prompt-tuning.png}
\caption{Soft-prompt tuning on vision-language representation space. The squared data samples visualize the initial prompt's locations and cross the learned prompts. The nearest image samples from the SMID dataset are displayed to illustrate each optimized prompt on the right.}
\label{fig:prompttuning}
\end{figure}
Our prompt-tuning approach is summarized visually in Fig.~\ref{fig:method}.
Moreover, Fig.~\ref{fig:prompttuning} shows exemplary nearest image neighbors of the learned prompts. The image on the right side clearly portrays possible inappropriate content. In contrast, the image on the left side displays a positive scene as a counterexample. Fig.~\ref{fig:smid_cv_results} also shows an evaluation of CLIP using the soft prompts (prompt-tuning). We can see that a small portion of the training data (e.g., 4\%, 60 images) already leads to an increase of the vision transformer's (ViT-B) performance to over 90\%.
In general, the ViT-B outperforms the pre-trained ResNet50 models. Furthermore, ViT-B/16 outperforms the ViT-B/32, indicating that not only the dataset's size is important, but also the capacity of the model (ViT-B/16 has higher hidden-state resolution than
the ViT-B/32).
Training ViT with the full training set results in $96.30\% \pm 1.09$ (cf. Tab.~\ref{tab:smid_classification_results}) accuracy.
Overall, one can see that steering CLIP towards inferring potentially inappropriate concepts in images requires only little additional data. In contrast to other pre-trained models, it provides a reliable method to detect inappropriate images.
\subsection{Dataset documentation of Q16}
\label{sec:documentation}
Using our prompt-tuning approach, the pre-selection by CLIP can, in principle, extract possible inappropriate images automatically that can then be used for dataset documentation.
However, we have to be a bit more careful since inappropriateness is subjective to the user---e.g., researchers and practitioners selecting the dataset for their tasks---and, importantly, to the task at hand. In our case, the steered model may primarily mirror the moral compass and social expectations of the $2{,}716$ annotators.
Therefore, it is required that humans and machines interact with each other, and the user can select the images based on their given setting and requirements.
Hence, we do not advise removing specific images but investigating the range of examples and inappropriate content selected by the model and thereby documenting the dataset.
In the following, we present our approach to assist data creators not only in identifying but also describing the identified potential inappropriate content.
\paragraph{\bf Answering Datasheet Question 16: Does the dataset contain data that, if viewed directly, might be offensive, insulting, threatening, or
might otherwise cause anxiety?}
As intended by the original datasheets paper \cite{gebru21datasheets}, dataset creators should start describing the curation process concerning this question.
Whereas our approach could also be used for the curation, we focus solely on documenting the final dataset content to mitigate unwanted societal biases in ML models, and help users select appropriate datasets for their chosen tasks.
The dataset documentation should contain the total amount of images and the ratio of identified, potentially inappropriate images. Since the process of creating a datasheet is not intended to be automated \cite{gebru21datasheets}---however, the quality of current datasheets \cite{desai2021redcaps} indicate that a semi-automated method is unavoidable---, the resulting subset should be manually validated and described by the dataset's creators. Our approach aims to reduce impractical human labor while encouraging creators to reflect on the process carefully.
\paragraph{\bf Automatic caption generation.}
In order to categorize and thus describe the identified content, dataset annotations can be used if they are available.
However, these annotations often may not describe the complete image content, especially in the case of natural images. Therefore, we utilize automatic generation of image descriptions, cf. Fig.~\ref{fig:method}b (right).
To this end, we propose to generate text using a caption-generation model. Specifically, we used MAGMA (Multimodal Augmentation of Generative Models) \cite{Eichenberg_Black_Weinbach_Parcalabescu_Frank_2021}. MAGMA is a recent text generation model based on multimodal few-shot learners \cite{Tsimpoukelli_Menick_Cabi}. It uses both the CLIP and GPT-J \cite{gpt-j} models and adds pre-training and fine-tuning steps on several datasets to generate image captions from image-text pairs. These captions are especially beneficial because they include the encyclopedic knowledge of GPT-J, and as such, knowledge on socio-moral norms (similar to the one we obtain from CLIP).
Further, the multimodal input enables one to guide the resulting textual description. Since we aim to generate ``neutral'' image descriptions, we use the prompt \textit{<A picture of>} and add the output of multiple generations to the image description. To sample from the model, we applied top-k filtering. In order to acquire greater variety in the descriptions, we used different temperature values.
\paragraph{\bf Word cloud generation.}
Actually, Question 16 asks the dataset curator to be familiar with a broad range of inappropriate concepts. Whereas our Q16 approach already helps reduce the number of inappropriate images to be checked and, in turn, human labor, even the validation of the reduced set may still require a lot of manual effort.
To provide a concise overview, we propose to compute word clouds to summarize the complex captions generated.
More precisely, we present the identified, potentially inappropriate content within the dataset using three different kinds of word clouds from dataset annotations and generated textual image descriptions. All word clouds highlight words or bi-grams based on their frequency and rank.
The first word cloud requires existing dataset annotations, e.g., class labels, and provides first insights of identified concepts and could highlight sensible labels.
The word cloud visualizes the information by highlighting the most-frequent annotations. However, note that dataset creators should also pay attention to infrequent occurrences indicating deviating concepts compared to other examples from, e.g., the same class. Many images with the same annotation could indicate a general negative association.
Following the same procedure, the second word cloud describes the identified set of images using the generated text and thus independent of the dataset annotations. Therefore, this word cloud potentially describes identified concepts not captured by the first word cloud.
For the third word cloud, we use a chi-squared weighting of the word/bi-gram frequencies to illustrate differences between the identified inappropriate image set and the remaining images; common text descriptions occurring in both sets are removed. Each word $i$ is assigned the following weight:
\begin{equation}
weight_i = \frac{(observed_i - expected_i)^2}{expected_i} \ ,
\end{equation}
where $observed_i$ is the observed frequency of word $i$ in the inappropriate subset and $expected_i$ the expected value, i.e., the observed word frequency describing the dataset's remaining samples.
This word cloud highlights the conspicuous descriptions that can be traced back to the corresponding images.
Finally, we would like to note that our pipeline also produces several statistics such as exact word frequencies and traceable image descriptions that we do not include directly in the datasheet. The dataset creators can provide this additional information as a supplement next to the identified image IDs.
\section{Answering Datasheet Question 16 for ImageNet and OpenImages}
Now we have everything together to provide an exemplary datasheet documentation, here for the CV datasets ImageNet \cite{deng2009imagenet} and OpenImages \cite{Kuznetsova2020theopen}.
To identify inappropriate content within the datasets, we used the public available ViT-B/16 variant of CLIP steered by SMID-based optimized prompts. We observed that shifting the negative threshold to a rating of $1.5$ instead of $2.5$ provides a conservative but reliable classifier; hence we determined the prompts with these corresponding few-shot examples. For the documentation process we utilized the ResNet50x16 MAGMA model and generated 10 captions ($k=5$ using a temperature of $\tau=0.1$ and $k=5$ using $\tau=0.4$) for each images. Additionally to the following documentations, we provide Python notebooks with the corresponding images along with the classifier in our public repository\footnote{\url{https://github.com/ml-research/OffImgDetectionCLIP}}.
\subsection{ImageNet}
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/wordclouds/imagenettrain/wordcloud_classes_freq.png}
\caption{Most-frequent image annotations.}
\label{fig:word_clouds_imagenet_a}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/wordclouds/imagenettrain/wordcloud_caption_freq_temp0-1and0-4.png}
\caption{Most-frequent image descriptions.}
\label{fig:word_clouds_imagenet_b}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/wordclouds/imagenettrain/wc_diffOffAndNonoff_chi-squared_scaling0-25.png}
\caption{
Weighted image descriptions.
}
\label{fig:word_clouds_imagenet_c}
\end{subfigure}
\caption{Word clouds documenting the potentially inappropriate image content of the ImageNet1k dataset. Image annotations are contained within the dataset. Image descriptions are automatically generated.
Word size is proportional to the word counts and rank in the generated captions corresponding to the inappropriate image set.
}
\label{fig:word_clouds_imagenet}
\end{figure*}
We start with one of the most known CV datasets, ImageNet1k (ImageNet-ILSVRC2012).
Additionally to the concise overview using word clouds (Fig.~\ref{fig:word_clouds_imagenet}) we provide further detailed description (highlighting the class labels) on the identified inappropriate concepts, and blurred examples for illustration (Fig.~\ref{fig:imagenet_listed_samples}).
We separate the identified content into potentially inappropriate objects, symbols, and actions due to the complexity of inappropriate context.
\textbf{Objects.}
The ImageNet1k dataset, also known as ImageNet-ILSVRC-2012, formed the basis of task-1 of the ImageNet Large Scale Visual Recognition Challenge. Hence, all images ($1{,}331{,}167$) display animals or objects. To illustrate potential missing information in the dataset's annotations, we restricted ourselves not to include the hierarchical information contained in the synsets, cf. the first word cloud in Fig.~\ref{fig:word_clouds_imagenet_a}.
Therefore, it is not surprising that the largest portion of the potential inappropriate content concerns negative associated objects and animals. In total, $40{,}501$ images were identified by the classifier, where the objects ``gasmask'' (797 images), ``guillotine'' (783), and ``revolver'' (725) are the top-3 classes. However, whereas most people would assign these objects as morally questionable and offensive, they may not be treated as inappropriate when training a general object classifier. The same applies to the animal-classes tick (554) and spider (397).
To detect more suspicious, inappropriate content, it may be more applicable to investigate classes with only a small portion of possible inappropriate images.
Next to injured (``king penguin'') and aggressive animals (e.g. ``pembroke''), our proposed classifier detects caged (e.g. ``great pyrenees'', ``cock'') and dead animals (e.g. ``squirrel monkey'', ``african elephant''). Additionally, objects in inappropriate, possible offensive scenes, like a bathtub tainted with blood (``tub'') or a person murdered with a screwdriver (``screwdriver'') are extracted, cf. also Fig.~\ref{fig:imagenet_listed_samples}.
\begin{figure}[t]
\centering
\includegraphics[width=0.9\linewidth]{images/listed_images_blur.jpg}
\caption{Exemplary images with inappropriate content from the pre-selection of our proposed method. The images visualize the range of concepts (objects, symbols, actions) detected. Due to their apparent offensive content, we blurred the images. Their content can be inferred from the main text.}
\label{fig:imagenet_listed_samples}
\end{figure}
\textbf{Symbols.}
Both the second (\textit{person, woman, man}) and the third word cloud (\textit{person wearing}) highlight that in many cases persons are subject to the inappropriate concepts identified.
In the corresponding images, one is able to identify offensive symbols and text on objects:
several National Socialist symbols especially swastika (e.g. ``mailbag'', ``military uniform''), persons in Ku-Klux-Klan uniform (e.g. ``drum''), insults by e.g. showing the middle finger (e.g. ``miniature pinscher'', ``lotion''), cf. first row of Fig.~\ref{fig:imagenet_listed_samples}.
Furthermore, we observed the occurrence of offensive text such as ``child porn'' (``file'') and ``bush=i***t f*** off USA'' (``pay-phone'').
\textbf{Actions.}
The third word cloud further documents the identified concepts. Words like \textit{blood, torture, execution} show that in addition to objects and symbols, our classifier interprets scenes in images and hence identifies offensive actions shown in images. Scenes such as burning buildings (e.g. ``church'') and catastrophic events (e.g. ``airliner'', ``trailer truck'') are identified. More importantly, inappropriate scenes with humans involved are extracted such as comatose persons (e.g. ``apple'', ``brassiere'', ``tub''), persons involved in an accident (e.g. ``mountain bike''), the act of hunting animals (e.g. ``African elephant'', ``impala''), a terrifying person hiding under a children's crib (``crib''),
scenes showing weapons or tools used to harm, torture and kill animals (e.g.``hamster'') and people (e.g. ``hatchet'', ``screwdriver'', ``ballpoint'', ``tub'').
Furthermore, derogative scenes portraying men and women wearing muzzles, masks, and plastic bags, clearly misogynistic images, e.g., harmed women wearing an abaya, but also general nudity with exposed genitals (e.g. ``bookshop'', ``bikini'', ``swimming trunks'') and clearly derogative nudity (e.g. ``plastic bag'') are automatically selected by our proposed method. Note that multiple misogynistic images, e.g., the image showing a harmed woman wearing an abaya, were not identified by the human hand surveyed image selection of \citet{birhane2021Large}. Therefore, we strongly advocate utilizing the implicit knowledge of large-scale state-of-the-art models in a human-in-the-loop curation process to not only partly automatize the process but also to reduce the susceptibility to errors.
\subsection{OpenImages}
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/wordclouds/openimagestrain/wordcloud_classes_freq.png}
\caption{Most-frequent image annotations.}
\label{fig:word_clouds_openimages_a}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/wordclouds/openimagestrain/wordcloud_caption_freq_temp0-1and0-4.png}
\caption{Most-frequent image descriptions.}
\label{fig:word_clouds_openimages_b}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.31\linewidth}
\centering
\includegraphics[width=\textwidth]{images/wordclouds/openimagestrain/wc_diffOffAndNonoff_chi-squared_scaling0-25_bigramsTrue.png}
\caption{
Weighted image descriptions.
}
\label{fig:word_clouds_openimages_c}
\end{subfigure}
\caption{Word clouds documenting the potentially inappropriate image content of the OpenImagesV6 dataset. Image annotations are contained within the dataset. Image descriptions are automatically generated.
Word size is proportional to the word counts and rank in the generated captions corresponding to the inappropriate image set.
}
\label{fig:word_clouds_openimages}
\end{figure*}
Our next exemplary documentation is based on the dataset OpenImages \cite{Kuznetsova2020theopen}. Its first version \cite{openimagesv1} was released in 2016, and the newest version 6 in 2020. The dataset contains 1.9M images with either single or multiple objects labeled, resulting in 59.9M image-level labels spanning $19{,}957$ classes and 16M bounding boxes for 600 object classes.
In contrast to the ImageNet documentation, we only provide the intended concise overview for Datasheet's Question 16.
Thus refrain from showing exemplary images. However, after describing the content using the word clouds, we want to point out one extremely disturbing example.
We documented the training set of OpenImagesV6 ($1{,}743{,}042$ images) and identified a potentially inappropriate set of $43{,}395$ images. Fig.~\ref{fig:word_clouds_openimages} shows our computed word clouds.
The first word cloud (Fig.~\ref{fig:word_clouds_openimages_a}) shows that most identified images portray persons with labels like ``human head'', ``human face'', or ``human body'', showing both men and woman. The second word cloud (Fig.~\ref{fig:word_clouds_openimages_b}) reflects this observation but additionally highlights the portray of, e.g., guns. Further, it points out that posters are displayed. We observed that often the corresponding images show covers of pornographic material.
The third word cloud reveals more interesting concepts (Fig.~\ref{fig:word_clouds_openimages_c}). We can again observe the descriptions \textit{cartoon, poster} referring to potential disturbing art, but also graffiti with inappropriate text. Furthermore, the description \textit{gun} is further highlighted. Human skulls and skeletons are displayed as well as dead and harmed animals (\textit{dead mouse, dead bird}). Importantly, the descriptions \textit{bloody face, blood, wound} refer to the concept of harm. It is noteworthy that, as the descriptions \textit{zombie} and \textit{zombie mask} could suggest, the corresponding images sometimes show costumes and makeup, however, also often real scenes. This observation demonstrates that human validation is necessary.
\paragraph{\bf Dead bodies: Abu Ghraib torture and prisoner abuse.}
Whereas the kind of images described above need to be documented and could have an influence on users' opinion regarding the dataset selection, the generated description \textit{gallows, execution, person lying, dead bodies} (cf. Fig.~\ref{fig:word_clouds_openimages_c}) extremely disturbed us while checking the corresponding images. Especially, we want to highlight one image we found (ID: 30ec50721c384003.jpg,
\abstwarning{{\fontencoding{U}\fontfamily{futs}\selectfont\char 66\relax} looking at the picture could be disturbing}).
The image shows several scenes, also known as ``Abu Ghraib torture and prisoner abuse'', displaying members of the U.S. Army posing in front of dead bodies during the Iraq War. These scenes were classified as a series of human rights violations and war crimes. They show sexual abuse, torture, rape, sodomy, and the killing of Manadel al-Jamadi (clearly identifiable in the dataset's image). Note that this
image is labeled (``person'', ``man'', ``clothing'', ``human face'') and was annotated with bounding boxes, thus checked by human annotators. Besides documentation, our approach can also pre-flag such images as potentially inappropriate to validate them during annotation.
\section{Societal Impact and Limitations}
\label{sec:ethics_statement}
Recent developments in large pertained models in NLP, such as GPT-3 have a far-reaching impact on society (300+ applications building on the model as of March 2021\footnote{https://openai.com/blog/gpt-3-apps/}), and we assume that the popularity of pre-trained CV, especially those including VL, models will follow along that path. So it is natural that the discussions surrounding ethical issues, such as biases, in NLP models transfer to VL models. Indeed, recently some awareness of problematic content in CV datasets arose; however, we are actually faced with broader issues in image datasets. \citet{birhane2021Large} described many negative societal implications underlying CV datasets' issues regarding, e.g., groups at margins such as high error rates for dark-skinned people in CV models recognizing pedestrians. Such issues even lead to the deletion of entire datasets\footnote{https://venturebeat.com/2020/07/01/mit-takes-down-80-million-tiny-images-data-set-due-to-racist-and-offensive-content/}. These issues are likely to become even more prominent since VL models combining images and text will become more applicable in industry and, in turn, generate great impact on society.
Specifically, large datasets underlying much of current machine learning raise serious issues concerning inappropriate content such as offensive, insulting, threatening, or might otherwise cause anxiety.
This calls for increased dataset documentation, e.g., using datasheets. They, among other topics, encourage to reflect on the composition of the datasets. So far, this documentation, however, is done manually and therefore can be tedious and error-prone, especially for large image datasets.
Here we ask the arguably ``circular'' question of whether a machine can help us reflect on inappropriate content, answering Question 16 in Datasheets \cite{gebru21datasheets}.
To this end, we provide a method to automatically detect and describe inappropriate image content to assist documentation of datasets.
Such automation might tempt dataset creators to neglect manual validation.
However, we strongly advise applying such methods in a human-in-the-loop setting as intended by \citet{gebru21datasheets} and described in our demonstrations. Humans should stay in control.
There are natural limitations that should be addressed in future work. First, we chose a binary classification to detect general inappropriate content, then described using a text-generation model. Thus, extending previous categories into more fine-grained
concepts could further improve transparency and documentation.
We strongly advocate applying our documentation along with other methods, e.g., detecting faces and pornographic content \cite{birhane2021Large} in future work.
Furthermore, while the SMID dataset with moral norms provides a good proxy for inappropriateness, developing novel CV datasets to drill down further on identifying inappropriateness and similar concepts would be very beneficial.
Moreover, whereas we evaluated our \textit{inappropriateness classifier}, we did not evaluate our automatic generation of textual image descriptions summarizing the portrayed inappropriate concepts. Doing so provides an interesting avenue for future work. Moreover, to ensure broad descriptions, we executed multiple generation iterations. Also, fine-tuning a caption generation model could lead to further improvements. Likewise, \citet{radford21Learning} provided details about possible biases and other potential misuses of CLIP models, which could easily influence the detection as well as the description that we used.
Generally, advances in bias-free models are very likely to also positively impact our introduced approach.
Finally, like other social norms, inappropriate concepts, especially offensiveness, do evolve constantly. This evolution makes it necessary to update the data, system, and documentation over time. Furthermore, an important avenue for future work is addressing what different groups of society, e.g., different cultures, would consider inappropriate. Here, we just relied on the ones averaged by the SMID dataset.
\section{Conclusion}
Deep learning models trained on large-scale image datasets have become standard practice for many applications. Unfortunately, they are unlikely to perform well if their deployment contexts do not match their training or evaluation datasets or if the images reflect unwanted behavior. To assist humans in the dataset curation process, particularly when facing millions of images, we propose Q16, a novel approach utilizing the implicit knowledge of large-scale pre-trained models and illustrated its benefits. Specifically, we argued that CLIP retains the required `knowledge' about what a human would consider offending during its pre-training phase and, in turn, requires only few shots to automatically identify offensive material. On two canonical large scale image datasets, ImageNet-ILSVRC2012 and OpenImages, we demonstrate that the resulting approach, called Q16, can indeed identify inappropriate content, actually broader than previous, manual studies.
Q16 provides several interesting avenues for future work. First, one should investigate other computer vision as well as multi-modal datasets. One should also extend Q16 to multi-label classification, directly separate offensive objects, symbols, actions, and other categories of inappropriate content at once. Moreover, moving beyond binary classification towards gradual levels of inappropriateness may result in more fine-grained details in the datasheets. Finally, the underlying deep models are black-boxes, making it hard to understand why specific images are identified and described as inappropriate. Combining Q16 with explainable AI methods such as \cite{Chefer2021transformer} to explain the reasons is likely to improve the datasheet.
\bibliographystyle{ACM-Reference-Format}
|
{'timestamp': '2022-02-15T02:43:31', 'yymm': '2202', 'arxiv_id': '2202.06675', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06675'}
|
arxiv
|
\section{Introduction}
In recent years, the field of \gls{xai} has shifted into focus,
with the objective to solve the "black-box"-problem inherent to many (deep) machine learning predictors
in order to better understand the reasoning of these models and consequently increase trust in them.
Current work from the field has highlighted the usefulness of contemporary \gls{xai} approaches for understanding and improving models and datasets in various application scenarios \cite{samek2021explaining}.
Many contemporary explainability methods yield so-called attribution maps,
{i.e.}\xspace,~per-input-dimension indicators of how (much) a model,
{e.g.}\xspace, a \gls{dnn},
has used the value of a particular input unit during inference \cite{Bach2015Pixel,Shrikumar2017Learning},
or whether the model is sensitive to its change \cite{morch1995visualization,baehrens2010explain}.
This information can be obtained either via perturbation-based approaches treating the model as a black-box~\cite{ribeiro2016should},
based on the gradient~\cite{Simonyan2014Deep,sundararajan2017axiomatic},
or with techniques applying modified backpropagation through the model~\cite{Bach2015Pixel,Shrikumar2017Learning}.
While (modified) backpropagation-based methods are popular choices for large-scale \gls{xai} experiments and practitioners,
{e.g.}\xspace, due to their efficiency and expressivity,
rule-based variants such as \glsdesc{lrp} or \glsdesc{ebp} are known to not be implementation invariant \cite{Montavon2019Gradient}:
Rule-based methods assign dedicated backpropagation "rules" to different parts of a neural network,
allowing for individual treatment of specific layers attuned to their function within the model ~\cite{Kohlbrenner2020Towards}.
That is, with \glspl{dnn} representing complex mathematical functions in a structured manner via layers,
a different expression of the very same function
via an alternative or completely new network architecture may lead to different ---
or in the worst case even misrepresentative --- explanation outcomes.
Furthermore, the continuous evolution of neural network architectures requires rule-based methods to regularly adapt to newly introduced network elements such as \gls{bn} \cite{Ioffe2015Batch} layers or skip connections in ResNets \cite{He2016Deep}.
In awareness to these issues, \emph{neural network canonization} has been introduced in previous work \cite{Hui2019Batchnorm,Guillemot2020Breaking}
and constitutes an elegant solution for transforming a variety of highly specialized
neural network elements into canonical and well-understood, yet functionally equivalent network architectures for improved model explainability,
where established rules are easily applicable.
Thereby, network canonization has the potential for improving a model's architecture ({w.r.t.}\xspace~its original design) to \emph{fix problems} in an explainability context, and thus \emph{increase the potential} for model trustworthiness without affecting its functionality.
Existing work~\cite{yeom2021pruning} describes canonization as a required step for reliable results, and, as a consequence, the authors of \gls{xai} software even build such model processors into their toolkits~\cite{Anders2021Software}.
Assessments of
network canonization on visualized attribution maps \cite{Hui2019Batchnorm,Guillemot2020Breaking} exist on a qualitative level.
However, to the best of our knowledge, there is no single study dedicated
to the \emph{quantification} of the beneficial effects of canonization on neural network explanations.
In this work, we dedicate efforts to the quantification and numerical verification of the
benefits of canonization on
two popular \gls{dnn} architectures (VGG-16~\cite{Simonyan2015Very} and ResNet18~\cite{He2016Deep} models, in representation of similar architectures)
on data from the ILSVRC2012~\cite{russakovsky2015imagenet} benchmark dataset.
In particular,
with a focus on variants of the popular \glsdesc{lrp}~\cite{Bach2015Pixel} technique
and gradient-based attribution methods,
we canonically extend the work of \cite{Hui2019Batchnorm,Guillemot2020Breaking}
by measurably demonstrating --- at hand of experiments of attribution-guided input perturbation~\cite{Samek2017Evaluating}
and object localization using annotated ground truth bounding boxes~\cite{Kohlbrenner2020Towards} ---
that model canonization is a critical factor for improving the quality and faithfulness of local explanations in rule-based approaches.
\section{Methods}
\subsection{Network Canonization}
\glsfirst{bn} layers \cite{Ioffe2015Batch} have been shown to be effective building blocks for improving and accelerating neural network training.
By eliminating the internal covariate shift in the activations,
they stabilize the distribution of intermediate representations and improve the gradient flow through the network, mitigating issues such as gradient shattering or -explosion \cite{Ioffe2015Batch}.
In some modified backpropagation methods,
such as \gls{lrp},
it is not inherently clear how to adequately propagate attribution scores through \gls{bn} layers.
An elegant solution for avoiding this issue altogether is to apply model canonization to these layers
\cite{Hui2019Batchnorm, Guillemot2020Breaking, Binder2020Notes}.
That is, a model (or parts thereof) is restructured in such a way that the result is functionally equivalent in terms of inference behavior for all possible input samples,
but only contains layer types supported by well-understood attribution propagation rules.
For this purpose,
\gls{bn} layers are commonly resolved by merging their parameters with an adjacent linear ({i.e.}\xspace, convolutional or fully-connected) layer \cite{Guillemot2020Breaking, Binder2020Notes} into a single and functionally equivalent linear layer with fused parameters, replacing both original layers.
\begin{figure}[t]
\centering
\includegraphics[width=.9\linewidth]{0-canonization_example.pdf}
\caption{Exemplary canonization of a VGG-16 model segment with \gls{bn} layers.
As the \gls{bn} is applied before the activation, the parameters of the convolution and the \gls{bn} are fused to build a new convolutional layer. The \gls{bn} layer is then omitted.
}
\label{fig:canonization}
\end{figure}
A schematic example for canonization is given in Figure~\ref{fig:canonization}.
The relative positioning of the \gls{bn} and linear layers, as well as the ReLU nonlinearity, determines which linear layer to update with the \gls{bn} parameters.
We evaluate attributions for pre-trained VGG-16 \cite{Simonyan2015Very} and ResNet18 \cite{He2016Deep} models in our experiments (Section~\ref{sec:results}),
which both contain segments of triples of \emph{Convolution} $\rightarrow$ \emph{\gls{bn}} $\rightarrow$ \emph{ReLU}.
Let a convolutional layer
$y_\text{conv} = w_\text{conv} \cdot x + b_\text{conv}$,
with weight and bias parameters $w_\text{conv}$, $b_\text{conv}$,
be followed by a \gls{bn} layer
$y_\text{bn} = w_\text{bn} \cdot \frac{y_\text{conv} - \mu_\text{bn}}{s_\text{bn}} - b_\text{bn}$, with
$s_\text{bn} = \sqrt{\sigma^2_\text{bn} + \varepsilon}$.
Here, $\mu_\text{bn}$ is the running mean and $\sigma^2_\text{bn}$ the running variance\footnote{$\mu_\text{bn}$ and $\sigma^2_\text{bn}$ parameters are fixed after training~\cite{Ioffe2015Batch}.},
$w_\text{bn}$, $b_\text{bn}$ are learnable parameters, and $\varepsilon$ a small stabilizing constant.
Following the derivations in \cite{Binder2020Notes},
the parameters $w_\text{c}$ and $b_\text{c}$ of the merged layer $y_\text{bn} = w_\text{c} \cdot x + b_\text{c}$ are then obtained as
\begin{equation}
\begin{split}
w_\text{c} = \frac{w_\text{bn}}{s_\text{bn}} \cdot w_\text{conv} ~; \qquad
b_\text{c} = \frac{w_\text{bn}}{s_\text{bn}} \cdot (b_\text{conv} - \mu_\text{bn}) + b_\text{bn}~ .
\end{split}
\label{eq:bn_canonization}
\end{equation}
We restrict our considerations to the above case,
as we employ VGG- and ResNet-type architectures in our experiments.
Note, however, that other architectures may require different approaches for canonization~\cite{Binder2020Notes}.
\subsection{Quantifying the Quality of Explanations}
\label{sec:methods:quantifying}
We aim to evaluate the effects of model canonization on explanations not only qualitatively but also quantitatively. Therefore, for our experiments, we selected two measures that quantify two different major properties of explanations:
\emph{Attribution Localization} \cite{Kohlbrenner2020Towards} measures the inside-total ratio $\mu$ of the sum of positive attributions inside the ground truth bounding box(es) ($R_\text{in}^+$) vs. the sum of all positive attributions ($R_\text{total}^+$) {w.r.t.}\xspace~the target label:
\begin{equation}
\mu = \frac{R_\text{in}^+}{R_\text{total}^+}
\label{eq:localization}
\end{equation}
This measure assumes that the model prediction is based on the object within the bounding box (which can safely be assumed in most cases~\cite{Kohlbrenner2020Towards}), and it is maximized if all positive attribution quantity for the target class is concentrated within that area.
We complement this localization test with
\emph{Input Perturbation Testing} \cite{Bach2015Pixel, Samek2017Evaluating},
which does not require additional ground truth annotations.
This measure creates a ranking of input regions by sorting per-region attributions in descending order,
and successively perturbs those regions in that order.
After each perturbation, the model is evaluated on the perturbed data sample. The effect of the perturbation on the model {w.r.t.}\xspace~the original sample is recorded as
\begin{align}
x^{(k)} &= g(x^{(k-1)}, r)\nonumber\\
\text{IP}(x, k) &= f(x^{(0)}) - f(x^{(k)})~,
\end{align}
where $g$ is a function applying the $k$th perturbation step on $x^{(k-1)}$ according to the attribution-ranked regions $r$ that correspond to the input sample $x$.
Then, $x^{(k)}$ is the sample after $k$ perturbation steps and $x^{(0)} = x$.
This measure is maximized if the regions ranked first in $r$ according to the attribution map lead to the sharpest decrease in the output probability of the target class,
and therefore measures the faithfulness of the explaining attribution map to the prediction function.
In our experiments, we compute and evaluate attributions for a sample's true class by perturbing single-pixel regions.
We replace perturbed pixels with values drawn from a uniform distribution of all possible pixel values.
\begin{figure*}[h]
\centering
\includegraphics[width=.9\textwidth]{1-imagenet_example_full.pdf}
\caption{Explanations for VGG-16 (\emph{top}) and ResNet18 (\emph{bottom}) with and without network canonization in comparison for multiple attribution methods.
Black crosses localize the highest attributed value per map.
Red pixels receive positive attribution values,
blue pixels receive negative scores.
The cosine distances between both explanations
from the original and the canonized model are noted in the bottom left corner of each attribution map without model canonization. Other than gradient-based approaches, rule-based attribution approaches are affected by structural changes resulting in an otherwise equivalent model.}
\label{fig:explanations_example}
\end{figure*}
\section{Results and Discussion}
\label{sec:results}
In this section, the qualitative effects of canonization are evaluated with a visual inspection of the explanations for single samples, while the quantitative effects are measured via the two
methods introduced in Section~\ref{sec:methods:quantifying}.
For our results, two commonly used model architectures are tested. We evaluate a VGG-16 model with \gls{bn} after each convolutional layer and a ResNet18 model, both with pre-trained weights from the Pytorch%
model zoo, on a subset of samples derived from 20 randomly picked ILSVRC2012 \cite{russakovsky2015imagenet} classes\footnote{
'airship',
'balloon',
'banana',
'barometer',
'binder',
'bison',
'broccoli',
'electric guitar',
'electric switch',
'freight car',
'go-kart',
'hourglass',
'isopod',
'ladybug',
'red panda',
'reel',
'Shih-Tzu',
'tiger',
'toucan',
'volleyball'
}, counting 9758 samples with ground truth bounding boxes in total.
We compute attributions for
variants of \gls{lrp}~\cite{Bach2015Pixel}
({cf.}\xspace \cite{Kohlbrenner2020Towards} for details),
\gls{ebp}~\cite{zhang2018top},
\gls{gbp}~\cite{Springenberg2015GBP},
\gls{itg}~\cite{Shrikumar2016Not},
\gls{ig}~\cite{sundararajan2017axiomatic}
and the gradient itself
using \texttt{zennit}~\cite{Anders2021Software} and its \texttt{Canonizer} implementations for comparison.
An example of the explanations for the canonized and non-canonized models can be seen in Figure \ref{fig:explanations_example}, for VGG-16 \emph{(Top)} and ResNet18 \emph{(Bottom)}.
As expected, attributions of Gradient, \gls{ig}, and \gls{itg} do not visually change with canonization, which is further confirmed by the cosine-difference between attributions, since neither gradients nor inputs are altered by canonization (although slight numerical differences may arise in practice).
For the modified backpropagation methods, however, differing results can be observed: \gls{gbp} shows no difference between canonized and non-canonized models, as it only alters the backpropagation through ReLU activations \cite{Springenberg2015GBP}. But the number of ReLU activations and their placement is not affected by the canonization applied here, so that the equal results are expected. However, \gls{ebp} and \gls{lrp}-based methods show significant differences between canonized and non-canonized models:
For \gls{lrp}-$\varepsilon$, a clear advantage can be detected for both canonized models, as the explanations for the non-canonized models do not reflect any recognizable input features. Note that this result strongly differs from our observations for \gls{itg}, so that claims of \gls{itg} and LRP-$\varepsilon$ being equal \cite{Shrikumar2016Not} do not hold here.
But for the other \gls{lrp} configurations, differences are not as obvious (although still visible), and explanations of canonized and non-canonized models show a broad similarity. It seems that, by only relying on a visual inspection, fine-grained comparisons between similar \gls{xai} methods cannot be made in general, and the perceived differences can thus not be linked to a statement about a disparity in quality. Therefore, independent and quantitative measures are essential for assessing the effects of canonization.
\begin{figure}[h]
\centering
\includegraphics[width=.9\columnwidth]{2-imagenet_attribution_localization.pdf}
\caption{Comparison of the attribution localization scores for the canonized and the non-canonized VGG-16 with \gls{bn} (\emph{top}) and ResNet18 (\emph{bottom}). Bars show the mean localization scores over all labelled objects from the analyzed ILSVRC2012 subset.
Blue bars show the score for \emph{all} objects, while green and red bars show scores for objects with bounding boxes smaller than 50\% and 25\% of the image size respectively. Different values are evaluated to ensure result independence from bounding box size, see \cite{Kohlbrenner2020Towards}.
Color intensity indicates canonization status.}
\label{fig:combined_localization}
\end{figure}
For this purpose, we employ two quantitative metrics focusing on different aspects of explanation quality.
In the localization tests (see Figure \ref{fig:combined_localization}),
explanations of \gls{lrp} methods and \glsdesc{ebp} achieve a higher inside-total ratio $\mu$ for the canonized models (\emph{Top}: VGG-16, \emph{Bottom}: ResNet18),
indicating that these explanations increase focus on the expected (bounding box) area and that canonization is therefore clearly beneficial. Note that the relative improvement in localization score is especially significant for the smaller bounding boxes where generally there is a much higher potential for attributions to be off-target.
For the other explanation methods, no changes in localization scores can be observed.
\begin{figure}
\centering
\includegraphics[width=.9\columnwidth]{3-imagenet_ref_pixelflipping_uniform_2.pdf}
\caption{Differences in the input perturbation scores between the canonized and the non-canonized model.
Scores have been obtained for the VGG-16 (\emph{left}) and the ResNet18 (\emph{right}) models on the ILSVRC2012 subset,
using uniform sampling for replacing pixels. Negative values are associated with increased faithfulness score of the canonized model.}
\label{fig:combined_pixelflipping}
\end{figure}
Similarly,
the difference in input perturbation test scores between canonized and non-canonized models shown in Figure \ref{fig:combined_pixelflipping} (\emph{Left}: VGG-16, \emph{Right}: ResNet18) indicate an improvement in modified backpropagation explanation faithfulness to model decisions with canonization.
In accordance with our qualitative findings ({cf.}\xspace Figure \ref{fig:explanations_example}),
for both models,
the input perturbation scores change the most for \gls{lrp}-$\varepsilon$.
Since \gls{lrp}-$\varepsilon$ favors sensitivity to model parameters over clarity of visual representation, canonization seems to improve explanations by correctly incorporating model parameters for explaining the model decisions.
Surprisingly, for \gls{lrp}-$\varepsilon$-$\alpha2\beta1$-$\flat$ the score for the attributions of the canonized VGG-16 is worse,
while for the ResNet18 canonization improves the attribution faithfulness.
The $\flat$-rule employed here introduces imprecision by smoothing in favor of readability.
Thus, the effect of the $\flat$-rule is especially noticable when, as in our case, only single pixels are perturbed at a time,
as opposed to larger regions.
For \gls{lrp}-$\varepsilon$-$\alpha2\beta1$-$\flat$,
the sensitivity to correct parameter incorporation is therefore decreased,
leading to diverging results between model architectures.
Despite showing visual changes in Figure \ref{fig:explanations_example} and improved localization scores in Figure \ref{fig:combined_localization}, the effect of canonization on \gls{ebp} explanations seems ambiguous in terms of faithfulness.
In contrast, the difference for gradient-based methods, as well as for \gls{gbp}, is close to zero for both VGG-16 and ResNet18, as can be expected due to the corresponding explanations (and gradients) not being affected by canonization.
Note that --- opposed to to the localization scores and qualitative results --- the difference is not exactly zero as per the random choice of replacement values in the perturbation function inducing small variations between canonized and non-canonized models' evaluation.
\section{Conclusion}
We confirmed that canonization of \gls{bn}-layers does not affect gradient-based explanation methods, but can lead to significant improvements for modified backpropagation methods without specified rules for \gls{bn} layers. While visual differences may be apparent,
we observed that qualitative evaluations are generally not sufficient for determining whether canonization leads to better explanations. Utilizing two quantitative measures, testing the \emph{localization} and \emph{faithfulness} of explanations, respectively, we found that canonization significantly improves both properties in general --- given that the explanation method is affected by canonization at all. In doing so, canonization can provide attributions that reliably represent a model's behavior, playing an important role in ensuring model trustworthiness via explanations.
\bibliographystyle{IEEEbib}
|
{'timestamp': '2022-02-15T02:41:21', 'yymm': '2202', 'arxiv_id': '2202.06621', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06621'}
|
arxiv
|
\section{Introduction}
\label{sec:introduction}
\IEEEPARstart{R}{obots} that operate in the real world need to plan at both task and motion levels. .
At the task level, the robot computes a sequence of symbolic actions in a discrete space to achieve long-term goals~\cite{ghallab2004automated}.
At the motion level, the symbolic actions are implemented in a continuous space, and the computed trajectories can be directly applied to the real world~\cite{choset2005principles}.
Planning at task and motion levels at the same time is challenging ~\cite{kaelbling2013integrated,garrett2018sampling,toussaint2015logic,dantam2018incremental,chitnis2016guided,lo2020petlon}, resulting in the so-called integrated \emph{task and motion planning} (\textbf{TAMP}) problem~\cite{garrett2021integrated,lagriffoul2018platform}, where the main challenge is to achieve task-level goals while maintaining motion-level feasibility.
Planning algorithms (at the task, motion, or both levels) frequently assume that a world model is provided beforehand, including how the world reacts to robot behaviors (i.e., world dynamics).
However, many real-world scenarios are very complex, making it hardly possible to model all objects or their physical properties at planning time, e.g.,~kitchens and shopping centers.
In such scenarios, modeling how a robot interacts with multiple objects is even more challenging, e.g., holding a stack of plates, cutting onions, and squeezing through a crowd.
Fig.~\ref{fig:demo_introduction} shows a ``\textbf{stack-and-push}'' task as an example scenario with complex multi-object interactions, where a robot repeatedly builds a block tower and then pushes it to a goal area.
Aiming to move all blocks to the goal area, the robot needs to learn object properties (e.g., size and weight), how to grasp the blocks (which depends on the object properties), and a stack-and-push strategy (e.g., how many blocks to be stacked together).
\begin{figure}[t]
\vspace{.7em}
\centering
\includegraphics[width=1.0\columnwidth]{image/fig_demo.pdf}
\vspace{-1.5em}
\caption{A robot performing ``stack-and-push'' tasks by repeatedly building a stack of blocks and pushing the stack to a goal area.
There is a trade-off between stability and efficiency (higher stacks are less stable) that the robot must learn from trial and error.
It is a TAMP problem, e.g., the stacking behaviors require both task planning and motion planning.}
\label{fig:demo_introduction}
\end{figure}
The \textbf{first contribution} of this work is a new grounded, object-centric TAMP framework, called task and motion Planning with Physics-based Simulation (\textbf{PPS}).
The uniqueness of PPS lies in the inclusion of a physics engine for grounding objects and their physical properties.
Object grounding enables the robot to collect simulated interaction experiences for policy learning purposes.
The PPS framework is general enough to accommodate different TAMP problems that vary in model completeness.
Our \textbf{second contribution} is an algorithm, called {Task-Motion Object-Centric} planning~(\textbf{TMOC}), that addresses a challenging PPS problem where \emph{object properties are not provided}.
TMOC is particularly useful for those TAMP domains that involve complex multi-object dynamic interactions.
Our TMOC robot can ground objects in a high-fidelity physics engine, learn object properties to facilitate the grounding, and improve its task-motion planning skills.
We have demonstrated and evaluated TMOC in simulation (where the robot uses a container to move objects), and using a real robot (where the robot conducts stack-and-push tasks).
The simulation and real-world scenarios share the challenge of robot task-motion planning with unknown object properties.
From the results, we see that TMOC outperforms a set of baselines from literature in cumulative utility.
Finally, we demonstrate the learning process of a real robot that uses TMOC for task-motion planning.
\section{Related Work}
There is a long history of developing planning algorithms in robotics research.
We summarize three research areas that are the most relevant to this research, namely TAMP, symbol learning for robot planning, and sim-to-real transfer.
\subsection{Task and Motion Planning (TAMP)}
Broadly, any robots that plan behaviors at a high level and operate in the real world would need algorithms for TAMP.
However, it is not until recently that TAMP has been used as a term to refer to the algorithms that interleave the processes of task planning and motion planning~\cite{garrett2021integrated,lagriffoul2018platform,lo2020petlon}.
Early examples include aSyMov~\cite{cambon2009hybrid} and Semantic Attachment~\cite{dornhege2009semantic}.
Hierarchical planning in the now (HPN)~\cite{kaelbling2010hierarchical} has been extended to model the uncertainty in action outcomes and observability~\cite{kaelbling2013integrated}.
FFRob directly conducts task planning over a set of samples generated in the configuration space~\cite{garrett2018ffrob}.
Probabilistically complete TAMP was achieved using constraint satisfaction methods~\cite{dantam2018incremental}.
Wang et al. used a policy synthesis approach to account for uncontrollable agents (such as humans)~\cite{wang2016task}.
Off-the-shelf task-motion planners can be integrated using a planner-independent interface~\cite{srivastava2014combined}.
Optimization methods have been applied to TAMP domains, where the goal is specified with a cost function~\cite{toussaint2015logic}.
In comparison to planning methods (including TAMP) that assume knowledge of complete world models, this work considers robots that compute world models (e.g., objects' physical properties) through perception, and actively estimate the current world state, which renders ``grounding'' necessary.
Very recently, researchers developed a visually grounded TAMP approach, called GROP, for mobile manipulation~\cite{zhang2022visually}.
Compared with GROP that uses computer vision techniques to learn a state mapping function, TMOC (ours) learns to ground objects and their physical properties for TAMP tasks.
\subsection{Symbol Learning for Robot Planning}
Researchers have developed symbol learning methods for robot planning.
Konidaris et al. (2018) focused on learning symbols to construct representations that are provably capable of evaluating plans composed of sequences of those actions~\cite{konidaris2018skills}, assuming the robot was equipped with a collection of high-level actions.
Their mobile manipulator learned a grounded symbol that indicates that a cupboard door is open, which is necessary for determining whether or not the robot can pick up a bottle from the cupboard.
Gopalan et al. (2020) introduced natural language into the loop, and showed that
the learned symbols can enable a robot to learn to map natural language to goal-based planning with only trajectories as supervision~\cite{gopalan2020simultaneously}.
The above-mentioned methods assumed that low-level motion primitives are provided (as skills or demonstrations), and the robot needs to learn a symbolic representation that can be used for planning to accomplish different complex tasks.
In this work, we assume those symbols are provided, but there are no models about the symbols' physical meanings in the real world.
\subsection{Sim-to-Real Transfer} This work requires a high-fidelity simulator, which is related to ``sim-to-real'' methods to enable agents to learn from simulation for operating in the real world~\cite{jakobi1995noise}.
Focusing on addressing the reality gap, there are at least two families of sim-to-real methods.
One intentionally adds different forms of noise into the simulation environment to learn policies that are robust enough to work in the real world~\cite{tan2018sim,peng2018sim,molchanov2019sim,yu2017preparing,pinto2017robust}; the other actively updates parameters of the simulator toward generating realistic experience for policy learning purposes~\cite{farchy2013humanoid,chebotar2019closing,zhu2017fast,jeong2020self}.
This work falls into the second category of methods from the perspective of updating the simulator's parameters using real-world data.
The main difference is that our method is placed in the TAMP context.
As a result, our proposed method faces two simultaneous, interdependent reality gaps at task and motion levels, respectively.
This paper enables robots to plan at both task and motion levels in object-centric domains where the object properties can be unknown.
Our developed approach is particularly suitable for task-motion domains that involve complex multi-object dynamic interactions.
Next, we define the grounded TAMP problem and then describe our algorithm.
\section{Framework and Problem Statements}
\label{label:definitions}
In this section, we first define an object-centric TAMP framework, and then describe how the framework accommodates a few TAMP problems.
\begin{figure*}[t]
\centering
\vspace{.5em}
\includegraphics[width=1.75\columnwidth]{image/fig_overview_revised.pdf}
\caption{
An overview of the TMOC algorithm for our PPS problem with unknown object properties ($L$ in green), state mapping function ($Y$ in blue), and transition function ($T$ in red).
The main components of TMOC include a task planner for sequencing symbolic actions, a motion planner for computing motion trajectories, and a physics engine for simulating multiple grounded worlds.
TMOC takes object library, task domain description, goal specification, cost function, motion domain description and state mapping function as input.
TMOC aims to compute task-motion plans to achieve task-level goals while maximizing cumulative utilities.
Using TMOC, a robot learns object properties ($L$) from task-completion experience, and leverages the learned properties to further improve its task-motion planning skills ($Y$ and $T$) over time.
}
\label{fig:framework}
\end{figure*}
\subsection{Framework}\label{sec:framework}
\emph{Planning with Physics-based Simulation} (\textbf{PPS}) is a task-motion planning framework\footnote{Researchers have developed TAMP frameworks, such as PETLON for navigation domains~\cite{lo2020petlon}, and FFRob~\cite{garrett2018ffrob} for heuristics-based TAMP.
The uniqueness of PPS, as an object-centric TAMP framework, is attributed to its inclusions of a state mapping function, and a high-fidelity simulator.}, and is defined as tuple
$$
\langle Obj, D^t, D^m, Y\rangle,
$$
where $Obj$ is a finite set of objects, and the other components are described next.
\vspace{.5em}
\noindent
\textbf{Task-level Domain Description}
$D^t:\langle E,A,T\rangle$, where $E$ is a finite set of symbolic (discrete) properties, and $E^{obj} \subseteq E$ includes symbolic properties that are applicable to $obj\in Obj$.
Each property $e\in E^{obj}$ has a finite domain of values, referred to as $V^{obj}_e$.
For instance, in a manipulation domain, object $box\in Obj$ has a property of $loaded\in E^{box}$ that has domain $V^{box}_{loaded}=\{true, false\}$.
A state $s$ is an assignment of each object's applicable symbolic properties.
$S$ denotes the set of possible states in symbolic forms.
We use $s^{init}\in S$ and $S^G \subseteq S$ to represent the initial state and the set of goal states, respectively.
$A$ is a finite set of object-centric actions, and action $a \in A$ is defined by its preconditions and effects.
State transition model $T(s,a,s')$ defines how an action leads (deterministic or probabilistic) transitions.
When action costs are considered in task planning, a task planner is able to select a plan out of all the plans that satisfy the goal conditions toward minimizing the overall cost.
In this paper, at the task level, we are concerned with object-centric, cost-sensitive, goal-conditioned planning under uncertainty.
\vspace{.5em}
\noindent
\textbf{Motion-level Domain Description}
$D^m: \langle L,C \rangle$, where $L$ is a finite set of continuous properties.
$L$ is the counterpart of $E$ at the task level.
$L^{obj} \subseteq L$ includes properties that are applicable to $obj\in Obj$, and properties $l \in L^{obj}$ is a real number.
Example continuous properties include an object's size, position, and weight.
The configuration space $C$ is the set of all possible configurations.
We use $\xi$ to represent a motion trajectory, where the trajectory connects the robot's current configuration ($x^{init}$) to any configuration in the target space ($x^{goal} \in C$).
\vspace{.5em}
\noindent
\textbf{State Mapping Function} $Y$ maps a task-level state to a motion-level pose: $x \leftarrow Y(s)$, where $s$ is a task-level state and $x\in C$ is a configuration.
$Y^{-1}$ is the inverse function of $Y$, and outputs a symbolic state $s$ given a motion-level configuration.
Here we assume $Y^{-1}$ can be derived from $Y$, and is thus omitted from the definition of PPS.
PPS is a general-purpose TAMP framework that is able to accommodate different task-motion planning problems.
A realization of a PPS framework requires a task planning system, a motion planning system, and a physics-based simulation (physics engine) system.
One can leverage the physics engine of PPS to ground different components of the real world.
Next, we define a challenging PPS problem, and discuss how this problem connects to a few existing TAMP problems.
\subsection{Problem Statements}
\label{sec:problems}
In this paper, we aim to address the PPS problem with the following set of functions being unknown:
$$
\{L, Y, T\}
$$
Consider a ``\textbf{stack-and-push}'' domain: A robot does not know block size and weight (about $L$), where to place the gripper for grasping (about $Y$), and how stable a stack of $N$ blocks is (about $T$).
This is a challenging problem, because planning at task and motion levels highly depends on the estimation of object properties, and the task-level strategy further depends on the robot's motion-level performance.
We use the stack-and-push domain in real-robot experiments, where the robot aims to move blocks from an initial area to a goal area as quickly and stably as possible.
The PPS framework is general enough to accommodate different TAMP problems (in addition to the above-mentioned problem that is the focus of this paper).
For instance, when all components of PPS are known, it corresponds to a standard TAMP problem, e.g.,~\cite{lo2020petlon,ding2020task}.
When only transition function $T$ is unknown, it corresponds to existing research, such as~\cite{wang2021learning, dantam2018incremental}.
Planning domains with unknown physical properties $L$~\cite{jiang2019task}, and planning domains with unknown state mapping function $Y$~\cite{liang2020learning} can be modeled as PPS problems as well.
The input of a PPS algorithm includes a PPS domain in the form of $\langle Obj, D^t, D^m, Y\rangle$, and a set of task-level goal states $S^G$.
Our utility function incorporates action costs, success bonus, and failure penalty.
A PPS algorithm aims to compute task-motion plans to achieve task-level goals while maximizing cumulative utilities.
Next, we focus on our PPS problem with unknown object properties $L$ (where the robot is motivated to learn $Y$ and $T$ accordingly), and develop algorithm TMOC to enable robots to learn to plan at task and motion levels.
\section{Algorithm}\label{sec:algorithm}
In this section, we present the main contribution of this research, \textbf{TMOC} (short for ``task-motion object-centric'' planning), a grounded task-motion planning algorithm for addressing the PPS problem described in Section~\ref{sec:problems}, where object properties ($L$), state mapping function ($Y$), and transition function ($T$) are unknown.
TMOC includes three main components of a task planner, a motion planner, and a physics engine, as illustrated in Fig.~\ref{fig:framework}.
Algorithm~\ref{alg:TMOC} presents the control loops of TMOC.
The input of TMOC includes a PPS domain in the form of $\langle Obj, D^t, D^m, Y\rangle$, and a set of task-level goal states $S^G$.
TMOC learns $L$, $Y$, and $T$ in each iteration, where the robot completes a task \emph{once} in the real world and \emph{$N$ times} in simulation.
In each iteration, each of $L$, $Y$, and $T$ is learned under the current estimation of the other two, while a TMOC agent plans at task and motion levels.
\subsection{TMOC algorithm}
A realization of a PPS framework requires task planning system $P^t$, motion planning system $P^m$, and physics-based simulation system $\mathcal{M}$.
$P^t$ takes task domain $D^t$ together with the current state $s$ (which can be derived from $D^t$) as input and generates an action sequence.
Specifically, $P^m$ takes the initial configuration $x^{init}$, goal configuration set $X^G$, and $D^t$ as input, and generates motion trajectory $\xi$.
$\mathcal{M}$ takes $\xi$, object set $Obj$, and their physics-relevant properties $L$ as input, and generates $L'$ denoting the resulting properties of $Obj$.
From $L'$, one can infer motion planning domain $D^m$, which can be further used for computing symbolic state $s$ using the function $Y^{-1}$.
\indent
\vspace{-1em}
\begin{algorithm}[h]
\small
\caption{TMOC algorithm}\label{alg:TMOC}
\textbf{Require:} {$P^t$, $P^m$, and $\mathcal{M}$}\\
\textbf{Input:} {$\langle Obj, D^t, D^m, Y\rangle$, $S^G$ and $Cost$}
\begin{algorithmic}[1]
\State {Initialize $T$ optimistically}\label{alg:init_T}
\State {Initialize $N$ simulated worlds and each one has $L_i$ (particle) with a uniform weight $w_i$, where $i=0, 1,\cdots, N-1$}\label{alg:init_N}
\State {Initialize an empty experience pool $Pool$}\label{alg:init_Pool}
\While{True}\Comment{start working on a new trial}
\State {$p$ $\leftarrow$ $P^t(\mathcal{D}^t, s^{init}, S^G, Cost)$, where $D^t$ includes $T$}\label{alg:compute_tp}\Comment{this is task planning}
\For{each action $\langle s, a\rangle$ in $p$}\label{alg:exec_tp_s}
\For{$i=0, 1,\cdots, N\!-\!1$}\label{alg:real_s}
\State {Compute $Y_i$ using $L_i$ for its simulated world}\label{alg:update_Y}
\State {Generate a feasible pose $x_i$ for $\langle s, a\rangle$ using $Y_i$}\label{alg:pose_sim}
\EndFor
\State {Compute a pose $x$ for the real world by weighted \indent averaging poses $\{x_0, x_1, \cdots, x_{N-1}\}$}\label{alg:pose_real}
\State {$\xi \leftarrow P^m(x_{curr}, x, D^m)$}\label{alg:traj_real}\Comment{this is motion planning}
\State {Execute $\xi$ in the real world and then obtain a resulting \indent state $s'$}\label{alg:compute_weight_real}
\State {$Pool=Pool$ $\cup$ $\{\langle s, a, s' \rangle\}$}\label{alg:update_Pool_real}\label{alg:real_e}
\For{$i=0, 1,\cdots, N\!-\!1$}\label{alg:sim_s}
\State {$\xi_i \leftarrow P^m(x_{curr}, x_i, D^m$)}\label{alg:traj_sim}
\State {$L_i' \leftarrow \mathcal{M}(\xi_i, Obj, L_i)$, where $L_i$ is in $D^m$}\label{alg:new_L}
\State {Infer a resulting state $s_i'$ using $L_i'$ and $Y_i^{-1}$, and then \indent \hspace{-1.5em} \indent $L_i \leftarrow L_i'$}\label{alg:new_state_sim}
\State {$Pool=Pool$ $\cup$ $\{\langle s, a, s_i' \rangle\}$}\label{alg:update_Pool_sim}
\State {Compute weight $w_i$ of $L_i$ using $s'$ and $s_i'$
}\label{alg:compute_weight}
\EndFor\label{alg:sim_e}
\State {Update $L_i$ from the discrete distribution given by \indent $\{w_0, w_1, \cdots, w_{N-1}\}$}\label{alg:update_L}
\State {Update $T$ using $Pool$}\label{alg:update_T}
\EndFor\label{alg:exec_tp_e}
\EndWhile
\end{algorithmic}
\end{algorithm}
\vspace{.5em}
\noindent
\textbf{Structure of Algorithm TMOC: }
{Lines \ref{alg:init_T}$\sim$\ref{alg:init_Pool}} are for initializing data structures.
{Lines \ref{alg:compute_tp}$\sim$\ref{alg:exec_tp_e}} form a complete iteration.
In each iteration, Line~\ref{alg:compute_tp} computes a task-level plan, and the functions of $Y$, $L$, and $T$ are updated from trial and error in Lines~\ref{alg:update_Y}, \ref{alg:update_L}, and \ref{alg:update_T}, respectively.
{Lines \ref{alg:real_s}$\sim$\ref{alg:real_e}} are for executing an action in the real world; and Lines \ref{alg:sim_s}$\sim$\ref{alg:sim_e} are for executing the same action in simulation.
TMOC is a life-long learning algorithm, and does not have termination conditions. Next, we look into individual lines of TMOC.
Line~\ref{alg:init_T} initializes transition function $T$ ``optimistically''.
A transition function ($T$) indicates how reliable an action is. Initializing $T$ optimistically means that the robot believes it always gets the desired results after performing an action, e.g., manipulation and push actions are always successful.
This initialization strategy is inspired by the R-max algorithm~\cite{brafman2002r}, and encourages exploration in the early learning phase.
TMOC initializes $N$ simulated worlds, where each is specified by a set of physics-relevant properties $L_i$, e.g., length, width, and density of blocks~{(Line~\ref{alg:init_N})}.
Each simulated world is associated with a weight $w_i$, and the weights are uniformly initialized.
An empty experience pool $Pool$ is initialized to store observations (i.e., actions and their resulting states) after action executions~{(Line~\ref{alg:init_Pool})}.
{Line~\ref{alg:compute_tp}} computes an optimal action sequence $p$ using the task planning system $P^t$ given the utility function, which takes into account transition function $T$ (e.g., how reliable grasps are) and cost function $Cost$ (e.g., how long it takes a robot to grasp an object).
{Lines \ref{alg:real_s}$\sim$\ref{alg:real_e}} describe how action $\langle s, a\rangle$ is implemented in the \textbf{real world}.
From $L_i$, we can get the configuration space, based on which $Y_i$ can be computed using motion planning methods~({Line~\ref{alg:update_Y}}).
Thus, a feasible pose $x_i$ for action $\langle s, a\rangle$ can be generated using $Y_i$~({Line~\ref{alg:pose_sim}}).
A new pose $x$ for the real world is computed by weighted averaging poses $x_i$, where $i=0, 1, \cdots, N-1$~({Line~\ref{alg:pose_real}}).
A trajectory $\xi$ is computed using the motion planner $P^m$, which takes $x_{curr}$, computed $x$, and $D^m$ as input, where $x_{curr}$ refers to the current pose of the robot~({Line~\ref{alg:traj_real}}).
$\xi$ is executed in the real world, and thus a resulting state $s'$ of action $\langle s, a\rangle$ is obtained~({Line~\ref{alg:compute_weight_real}}).
Finally, tuple $\langle s, a, s'\rangle$ is added to experience pool $Pool$~({Line~\ref{alg:update_Pool_real}}).
{Lines \ref{alg:sim_s}$\sim$\ref{alg:sim_e}} explain how action $\langle s, a\rangle$ is implemented in all \textbf{simulated worlds} (one iteration for each world).
A trajectory $\xi_i$ is computed using motion planning system $P^m$~({Line~\ref{alg:traj_sim}}).
Then, a set of resulting properties $L'_i$ is obtained using physical-based simulation system $\mathcal{M}$~({Line~\ref{alg:new_L}}).
Thus, a resulting state $s_i'$ can be inferred using $L_i'$ and the reverse function of $Y_i$, and $L_i$ is also updated by $L_i'$~({Line~\ref{alg:new_state_sim}}).
Finally, tuple $\langle s, a, s_i' \rangle$ is added to $Pool$~({Line~\ref{alg:update_Pool_sim}}).
{Lines \ref{alg:compute_weight}}, {\ref{alg:update_L} $\sim$ \ref{alg:update_T}} update $L$ and $T$ using action completion experience.
Specifically, each weight $w_i$ of $L_i$ can be computed based on the resulting state from the real and simulated worlds~({Line~\ref{alg:compute_weight}}).
Similar to the particle filter~\cite{gordon1993novel}, a new $L_i$ is sampled from the discrete distribution given by $w_i$, where $i = 0, 1, \cdots, N-1$~({Line~\ref{alg:update_L}}).
Besides, $T$ is updated using the experience pool $Pool$~({Line~\ref{alg:update_T}}).
TMOC enables robots to plan at both task and motion levels in object-centric domains where the objects' physical properties ($L$) are unknown (and thus $T$ and $Y$ are unknown).
TMOC is particularly useful for those tasks that involve dynamic complex robot-multi-object interactions that can hardly be modeled beforehand.
Next, we focus on the evaluation of TMOC in both simulation and the real world.
\begin{figure*}[t]
\centering
\vspace{0.5em}
\includegraphics[width=2.0\columnwidth]{image/fig_demo_pybox.pdf}
\caption{
A robot needs to stack a set of blocks (Steps $0\sim6$ of Trial A and B) and then push them to the goal area with a container.
The more blocks in the container, the less stable it is, resulting in a trade-off between work efficiency and success rate.
At the task level, the robot is concerned about how many blocks (of initially unknown sizes and weights) can be placed in the container.
Step 4 of trials A and B demonstrate two such situations, where the robot needs to decide if another block can be added to the container.
Making this decision is difficult due to the complex multi-object interactions.
The two trials give different results as shown in Step 5 of trials A and B.
}
\label{fig:demo_pybox2D}
\end{figure*}
\subsection{Algorithm Instantiation}\label{sec:instantiation}
\noindent\textbf{Task Planner:}
Our task planner $P^t$ is implemented using Answer Set Programming (ASP), which is a popular declarative language for knowledge representation and reasoning.
ASP has been applied to task planning~\cite{lifschitz2002answer,amiri2019augmenting,lo2020petlon,jiang2019task}.
In out domain, predicate \texttt{is\_holding(R1,B1)} is used to specify block \texttt{B1} being in the robot hand \texttt{R1}.
We model three manipulation actions, including \texttt{pickup}, \texttt{stack}, and \texttt{push}.
For instance, action \texttt{pickup} is used to help the robot arm pick up the target block from an initial location, where constraints, such as ``\texttt{stack} is allowed only if a target block is in the robot hand'', have been modeled as well.
An example goal specification can be ``all blocks are in the container, and containers are at the goal location''.
Table~\ref{table:action} defines three actions by their preconditions and effects, where $R$, $B$, $C$, and $L$ stand for robot, block, container, and location, respectively.
\begin{table}
\footnotesize
\centering
\caption{Action knowledge in our system, organized into preconditions and effects.}\label{table:action}
\begin{tabular}{ cccc }
\toprule
\textbf{Action} & \textbf{Precondition} & \textbf{Effect} \\
\midrule
\multirow{2}{8.0em}{$pickup(R,B,L)$} & \multirow{1}{7.1em}{$is\_in(B,L)$} & $is\_holding(R,B)$ \\
& \multirow{1}{7.1em}{$hand\_empty(R)$} & $\neg hand\_empty(R)$ \\
\hline
\multirow{3}{8.0em}{$stack(R,B,C)$} & \multirow{3}{7.1em}{$is\_holding(R,B)$} & $\neg is\_holding(R,B)$\\
& & $hand\_empty(R)$ \\
& & $at\_container(B,C)$ \\
\hline
\multirow{2}{8.0em}{$push(R,C,L1,L2)$} & \multirow{1}{7.1em}{$hand\_empty(R)$} & $hand\_empty(R)$ \\
& \multirow{1}{7.1em}{$is\_in(C,L1)$} & $is\_in(C,L2)$ \\
\bottomrule
\end{tabular}
\vspace{-1em}
\end{table}
\vspace{.8em}
\noindent\textbf{Motion Planner:}
At the motion level, given a configuration space, a roadmap is firstly built for the robot.
A trajectory planner then generates a desired continuous and collision-free trajectory with minimal traveling distance using optimization algorithms, RRT* in our case~\cite{karaman2011sampling}.
The trajectory includes a set of poses, and the trajectory is delivered to the manipulation controller, along with the robot's current pose.
\section{Experiments} \label{sec:exp}
We have conducted experiments both in simulation and using a real robot.
In simulation experiments, we focus on statistically comparing the performances of TMOC and a set of competitive baselines using results collected from large numbers of trials.
The comparisons are based on cumulative utility, which is a combined measurement that incorporates action costs, success bonus, and failure penalty.\footnote{The action cost of $pickup$, $stack$, and $push$ are 15, 10 and 30, respectively, where a cost technically corresponds to a negative reward. The bonus of successfully stacking a block, and pushing a container to a goal location is 40 and 80, respectively. The failure penalty is 50.}
In real-world experiments, we illustrate a complete learning process of a real robot arm performing ``stack and push'' tasks.
\subsection{Experiments in Simulation}
We used an open-source 2D physics-based simulator called Pybox2D~\cite{hunt2019introduction} to evaluate the performance of TMOC.
We decided to use a 2D simulator instead of a 3D one because 3D simulators (e.g., Gazebo~\cite{koenig2004design} and PyBullet~\cite{coumans2016pybullet}) are generally computationally less efficient.
Our agent needs to learn to interact with objects (with unknown properties) at both task and motion levels, which requires considerable interaction experience, so we selected a 2D simulator that allows running experiments extensively.
Fig.~\ref{fig:demo_pybox2D} illustrates how a robot gripper uses a container to move eight blocks to a goal area\footnote{In this paper, we assume blocks and the container are not too heavy to be manipulated by the robot. Besides, the blocks are small enough to be graspable by the robot arm.}.
The robot knows that all blocks share the same density, but must estimate their sizes for task-motion planning.
The robot might fail in loading and unloading a block, and in blocks falling off from the container.
Here we assume a ``helper'' helps move blocks out of the container in the goal area before the gripper and container are moved back.
We use this task to capture complex contact-based interactions among multiple objects, whereas the interactions in ``stack-and-push'' scenarios (used for real-robot experiments) do not go beyond two objects.
\begin{figure*}[t]
\centering
\includegraphics[width=.69\columnwidth]{image/fig_mainResult.pdf}
\hspace{-1.2em}
\includegraphics[width=.69\columnwidth]{image/fig_N.pdf}
\hspace{-1.2em}
\includegraphics[width=.69\columnwidth]{image/fig_details.pdf}
\hspace{-2em}
\caption{\textbf{Left}: Comparisons between TMOC and three baselines of TMP-RL, GP and TOEP in the task of a gripper moving objects using a container; \textbf{Middle}: Performance of TMOC under different numbers of simulated worlds, where $N$ = 50, 100, 150, and 200; \textbf{Right}: Milestones of TMOC, where we present the percentages of optimal plans and successful actions.
In all subfigures, the $y$-axis refers to the cumulative utility obtained by the real robot.}\label{fig:experiment_results}
\end{figure*}
\vspace{.5em}
\noindent
\textbf{Baselines:}
Three baseline methods are utilized in this research, and they are selected from the literature, referred to as \textbf{TMP-RL}~\cite{jiang2019task}, \textbf{GP}~\cite{wang2021learning}, and \textbf{TOEP}~\cite{liang2020learning}.
\begin{itemize}
\item TMP-RL is a task-motion planning algorithm that learns from trial and error. TMP-RL is not object-centric, and hence does not learn object properties ($L$) over time.
\item GP is a task-motion planning algorithm that learns primitive skills from trial and error, but cannot improve its task-level planning strategies. In our implementation of GP, the agent randomly selects one of the satisficing plans to achieve high-level goals.
\item TOEP does not learn the state mapping function, and the gripper is placed (on a block) in a grasping position that is randomly selected in a reasonable range. It should be noted that our ``TOEP'' agent is equipped with task-planning capability, whereas the original TOEP work used predefined task-level behaviors.
\end{itemize}
\vspace{.5em}
\noindent
\textbf{TMOC vs. Three Baselines:}
For every approach, we conducted 15 runs with 5000
episodes in each run.
Fig.~\ref{fig:experiment_results} (Left) illustrates the learning curves for utility value, averaged over the 15 runs with the shaded regions representing one standard deviation from the mean.
From the results, we get the important observation that TMOC \footnote{The number of grounded worlds in TMOC is 200 (i.e., $N=200$).} performs better than the baselines in terms of cumulative utility and learning rate.
One interesting observation from Fig.~\ref{fig:experiment_results} (Left) is that TOEP fell behind the other three approaches (including our TMOC) at the beginning, and then later reached a cumulative utility level that is comparable to that of TMOC.
This is because TOEP does not learn the state mapping function, and hence cannot improve its skills of ``grasping'' and ``pushing'' from trial and error.
This disadvantage affects the learning rate of TOEP at the beginning.
At the late learning phase (after about 2000 episodes), the TOEP agent was able to catch up, because the task planner learned to adapt to the motion planner (that is suboptimal on grasping and pushing).
As a result, the ultimate performances of TOEP and TMOC (ours) are comparable.
TMP-RL does not learn object properties ($L$), which affected its learning rate and cumulative utility level compared with TMOC (ours), because an inaccurate $L$ is detrimental to the learning of both $Y$ and $T$.
\begin{figure*}[t]
\centering
\includegraphics[width=2.\columnwidth]{image/fig_demo_robot.pdf}
\caption{A robot arm is tasked to move five blocks from an initial area.
To perform ``2D'' experiments in the 3D real world, we attached a rail onto a table, where blocks can be only moved back and forth.
There is a trade-off between stability and efficiency (higher stacks are less stable) that the robot must learn from trial and error.
In this case, five blocks are stacked and then moved to the goal area.
The robot was lucky enough to be successful in this trial, but might fail in other trials of performing the same plan.
}\label{fig:demo_ur5e}
\vspace{-.5em}
\end{figure*}
\noindent
\textbf{Number of Grounded Worlds:} The performance of TMOC highly depends on the number of simulated worlds (or ``particles,'' in the terminology of Particle Filters), which is referred to in Line~\ref{alg:init_N} of Algorithm~\ref{alg:TMOC}.
Each curve was based on 12 runs with 5000 episodes in each run.
Sufficient particles are necessary to ensure the quality of a Particle filter, and to represent the distributions being estimated.
We are interested in answering this question: \emph{How many particles are adequate for our experiments?}
Thus, we evaluated TMOC under different numbers of particles (i.e., $50 \leq N \leq 200$).
Fig.~\ref{fig:experiment_results} (Middle) shows no significant improvement in learning rate or cumulative utility when we increased the particle number from $N=150$ to $N=200$.
Therefore, we believe $N=150$ is sufficient to the robot in our domain.
This observation can serve as a reference to TMOC practitioners.
\vspace{.5em}
\noindent
\textbf{Milestones of TMOC:}
We are also interested in how the robot makes progress in learning $L$, $Y$, and $T$ while running TMOC.
Thus, we calculated the percentages of optimal plans and successful actions at some selected training episodes, where $N=200$ in this experiment.
Fig.~\ref{fig:experiment_results} (Right) shows that both percentages of optimal plans and successful actions are close to 0\% at the beginning, because of the highly inaccurate functions of $L$, $Y$, and $T$.
They gradually increased and finally got close to 100\% after 5000 episodes.
At the same time, we see that $L$, $Y$, and $T$ have different learning rates.
For instance, when the robot completed about 2000 episodes, $T$ converged well because most of the plans (about 94\%) are optimal, while there is still room to further learn functions $L$ and $Y$ because only 88\% of actions are successful.
We attribute the growth of utility value after 2000 episodes to the learning of $L$ and $Y$.
\vspace{.5em}
\noindent
\textbf{Task Variations of TMOC:}
The performance of TMOC is affected by task variations, such as blocks of different sizes.
Thus, we changed the goal specification to let the robot stack and move one big block and seven small ones.
The side length of the big one is 20\% bigger than the small ones.
The robot knows that all blocks share the same density, but must estimate their sizes for task-motion planning.
Introducing different sizes makes the stack-and-push task too difficult for the robot. For evaluation purposes, we provided the robot with guidance that the big block should be put near the bottom (in one of the first two steps).
Fig.~\ref{fig:size} shows that under the ``different sizes'' domain variation, TMOC needs more episodes to reach a utility level that was achieved when all blocks share the same shape.
Also, under the ``different sizes'' variation, TMOC's convergence level was lower than that under the ``same size'' variation.
We observed that grasps become more unreliable when the robot faces a bigger block.
Incidentally, we found no significant difference in the performance of TMOC with and without block weight variations.
\begin{figure}[]
\vspace{-.5em}
\centering
\includegraphics[width=0.7\columnwidth]{image/fig_size.pdf}
\caption{Performance of TMOC under a task variation (i.e., size). \textbf{Same Size}: the robot is tasked to stack and move eight small blocks. \textbf{Different Sizes}: the robot is tasked to stack and move one big block and seven small ones. In both curves, $N$ equals $200$.}
\label{fig:size}
\end{figure}
\begin{table}[t]
\centering
\scriptsize
\caption{Utility value of TMOC under different episodes in the stack-and-push task using real robot arm UR5e}\label{tab:experiment_ur5e}
\begin{tabular}{c | c c c c c c c}
\bottomrule[1pt]
\textbf{Episode}& $0$ & $4$ & $8$ & $12$ & $16$\\ \hline
Utility & $-23(18)$ & $60(128)$ & $-10(32)$ & $4(67)$ & $183(80)$\\ \hline \hline
\textbf{Episode} & $20$ & $24$ & $28$ & $32$ & $36$\\ \hline
Utility & $70(98)$ & $86(113)$ & $105(74)$ & $218(11)$ & $235(0)$ \\
\bottomrule[1pt]
\end{tabular}
\end{table}
\subsection{Experiments in the Real World}
TMOC was evaluated using a UR5e robotic arm.
In the experiment setting, the robot stacked blocks and then pushed them to a goal area, as illustrated in Fig.~\ref{fig:demo_ur5e}.
We provided the robot with accurate object properties (block size in this case) to control the difficulty of learning task-motion behaviors to a reasonable level. As a result, the robot only needed to learn a state mapping function (e.g., where to place the gripper for grasping) and a transition function (e.g., a stack-and-push strategy, including how many blocks should be stacked together).
We conducted three runs, each including 44 episodes, that together took more than 12 hours.
Table~\ref{tab:experiment_ur5e} shows the mean utility values and the corresponding standard variances of the TMOC algorithm after different numbers of episodes.
At the beginning, the mean value is low while the variance is high, because the robot does not know how to grasp blocks or what a good action sequence is like.
With more trials, our TMOC robot learned a good state mapping function $Y$ and transition function $T$, which resulted in a high utility value and a low variance.
More specifically, the robot learned reasonably good $Y$ and $T$ functions after 15 and 32 episodes, respectively.
The result demonstrates that learning $Y$ and $T$ enables the robot to complete the stack-and-push task efficiently and reliably, which is overall evaluated using the utility values.
\section{Conclusion and Future work}
In this paper, we develop a grounded task-motion planning algorithm TMOC that can ground objects (including their physical properties) for robot planning in mobile manipulation tasks that involve complex multi-object dynamic interactions (e.g., building blocks).
We assume the availability of a high-fidelity simulator, and the unavailability of accurate properties of those objects (e.g., size, weight, and shape).
The robot needs to plan high-level behaviors to fulfill complex goals that require picking, moving, and placing the objects while minimizing overall action costs.
Thus, we develop the TMOC algorithm to learn the object properties, state mapping function and transition function.
Results from both the simulation and the real world demonstrate that TMOC improves the task-completion effectiveness and efficiency in terms of utility value and learning rate.
The paper assumes that all objects are relevant to the current task, and hence TMOC grounds all of them in physics-based simulation.
In the future, we plan to enable the robot to learn what objects should be grounded and when.
Objects have many different physical properties, and estimating their values requires different perception methods.
This paper considered size and weight, and other properties can be estimated in future work.
Another direction for future research is to further increase the number of particles (each corresponding to a grounded world) for more accurately estimating object properties, where if needed, distributed computational platforms can be used.
We are also interested in applying TMOC to domains beyond ``stack and push'' in the future.
Further, our real-robot experiment can be improved by including other everyday objects with diverse properties.
Finally, it is important to look into the theoretical properties of TMOC, such as its completeness and scalability.
Such theoretical analysis can be difficult due to the stochastic nature of TMOC (e.g., many grounded worlds) and the iterative learning process, and we leave it to future work.
\bibliographystyle{IEEEtran}
|
{'timestamp': '2022-02-16T02:08:33', 'yymm': '2202', 'arxiv_id': '2202.06674', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06674'}
|
arxiv
|
\section{Introduction}\label{sec:intro}
With the explosion of the Internet of Things (IoT) world, many devices already on the market have undergone a transformation, becoming more functional and cost-effective.
One of these is undoubtedly the IP camera, a video surveillance camera that uses the network to transmit audio and video signals. Unfortunately, IP cameras, like many other IoT devices, are the target of countless malicious cyber attacks that often aim to violate the confidentiality of transmitted data.
Today, IP cameras are being used to make CCTV, as confirmed by a 2019 estimate of around 770 million IP cameras being used in this field~\cite{survcamera}.
In addition, IP cameras are increasingly being used in peoples' houses. Thanks to their low cost, they are used, for example, to monitor a house when people are away, to monitor pets and also as baby monitors.
In view of the main uses, it is clear that the nature of the data transmitted by these devices is decidedly intimate and private.
Therefore, it would seem reasonable to assume that a series of countermeasures are implemented to protect the confidentiality of the transmissions.
However, there are no general guidelines for the realisation of such products and often the precautions taken are very weak or even completely absent.
The security of the IoT world has been at the centre of the global debate for a few years now. In fact, in October 2016, the Mirai malware was able to build a botnet, compromising thousands of devices, including many IP cameras~\cite{mirai}. In 2017, the list of known vulnerabilities within the CCTV Calculator~\cite{cctvcalc} was published, involving IP cameras from many vendors, including Samsung, D-link, Panasonic, Cisco, Hikvision, FOSCAM, Y-Cam, TP-Link, AirLive, Sony, Arecont Vision, Linksys, Canon and many more.
The topic of security and IP cameras is an open one, so in this paper we decided to carry out a vulnerability assessment and penetration testing process on one of today's IP cameras in particular, the TP-Link Tapo C200~\cite{c200}.
\subsection{Contributions}
This article explores whether and how IP cameras can be exploited today using freeware, i.e. non-commercial tools. We address this question in a scenario where there is an insider attacker who connects to the same network as the IP camera with her attacking laptop via Ethernet or Wi-Fi connectivity.
The results are that, relying on simple tools such as nmap, Ettercap, Wireshark and Python programming, the attacker can seriously compromise the service and undermine user privacy.
More precisely, we describe all our results obtained through the reverse engineering process performed on the Tapo camera; thanks to this process we were able to perform our vulnerability assessment.
The vulnerability assessment exercise allowed us to obtain information and evaluating a ceremony for everything related to proprietary services and third-party video streams. The work continued with penetration testing, which aim to exploit vulnerabilities obtained from the vulnerability assessment exercise on the Tapo camera. Specifically, we found that the Tapo camera suffers from: Denial of Service which clearly renders the camera unavailable; Video eavesdropping which affects user privacy; in addition, we demonstrate a third attack called \lq\lq Motion Oracle" which allows an attacker on the same network as the Tapo C200 to detect traffic related to the camera's motion detection service and use it to obtain information about the victim by analysing the frequency of generated traffic.
Finally, we prototype effective countermeasures, at least against video eavesdropping, by taking advantage of a cheap Raspberry Pi~\cite{raspb} device. This can implement encryption so that packets are only transferred in encrypted form over the network and therefore cannot be understood by a man in the middle (MITM).
The Raspberry Pi then transmits the encrypted packets from the IP Camera, ensuring user security, in a completely transparent manner.
\subsection{Testbed}
Our testbed consists of some useful devices for VAPT experiments.
The Tapo C200 is an entry-level IP camera designed for home use. Released in 2020 with a very low cost (around 30€), the Tapo C200 has several technical features, thanks to which it boasts several functionalities, such as: compatibility with the main smart home systems (e.g. Alexa~\cite{alexa} and Google Assistant~\cite{GoogleAssistant}); night vision, resolution up to Full HD; motion detection; acoustic alarm; data storage; voice control; use with third-party software; webcam mode.
To use the Tapo C200, a TP-Link account is required which allows access to the various cloud services offered.
Access to the TP-Link account is via the Tapo app, which is available free of charge on Google Play~\cite{tapoGPlay} and APP store~\cite{tapoApple} for devices running Android 4.4+ and IOS 9+ respectively. The application has a simple and intuitive user interface, from which it is possible to use and manage the devices of the Tapo family, including the Tapo C200. The range of services offered for the Tapo C200 includes: Remote access and control of the Tapo C200; Sharing the Tapo C200 with other accounts; synchronisation of settings; integrating the Tapo C200 with smart home systems; and receiving motion notifications.
Below, the Figure~\ref{fig:testbed} shows the testbed on which the experiments were conducted and how the elements of the testbed are connected to each other, note that all connections are made via a Wi-Fi network.
In a nutshell, the testbed consists of:
\begin{enumerate}[(a)]
\item A Wi-Fi switch to which the various devices were connected
\item The Tapo C200 IP Camera
\item A smartphone on which SSL Packet Capture and the Tapo application were installed
\item A Linux machine on which Ettercap and Wireshark tools have been installed
\item A Linux machine on which the third-party players iSpy and VLC have been installed
\end{enumerate}
\begin{figure}[ht]
\centering
\includegraphics[scale=0.35]{Images/origninal_testbed.png}
\caption{Original testbed}
\label{fig:testbed}
\end{figure}
By monitoring the environment with the various instruments, the Tapo C200 was used as a normal user, with the aim of extracting useful information for operational analysis.
\subsection{Related Work}\label{sec:RW}
As early as 2015, it was shown that IP cameras can encompass multiple research areas, including multimedia security, network security and cloud security, and end-user privacy.
In fact, Tekeoglu and Tosun looked into the security of cloud-based wireless IP cameras~\cite{cloudbasedIPcamerajpeg}. They studied the traffic generated by a wireless IP camera that is easy to set up for the average home user. Hence, they proved that an attacker can sniff the IP camera's network traffic and would be able to reconstruct the JPEG images from the data stream. Based on their information, their system has some limitations, e.g. their script only reconstructed 253 JPEG images over about 20 hours of video track.
A few years later in 2017, Liranzo and Hayajneh presented an analysis of the main privacy and security issues affecting thousands of IP camera consumers globally, they proposed a series of recommendations to help protect consumers' IoT devices in the intimacy of their home~\cite{2017issueIPcamera}.
It is clear that modern IP cameras collect a large amount of data, which is then transferred to cloud systems.
As a result, IP cameras process data to such an extent that it becomes important to assess the security of these cameras also from the point of view of privacy for users.
\subsection{Paper Structure}
This manuscript continues to describe all background information useful for understanding the content of the paper (\S\ref{sec:background}). The core of the paper begins with the reverse engineering process (\S\ref{sec:reverse}) which continues with the vulnerability assessment (\S\ref{sec:VA}) and the penetration testing (\S\ref{sec:PT}) performed on the Tapo C200 IP camera. Finally, the paper describes a countermeasure (\S\ref{sec:countermeasures})
and concludes with some broader evaluations of the results (\S\ref{sec:conclusions}).
\section{Background}~\label{sec:background}
In this section we provide all the background information necessary for understanding all the steps performed in the VAPT work on the Tapo C200.
The IP camera also has the functionality to integrate the device with third-party infrastructures and systems. Such systems require the use of dedicated protocols such as the Real Time Streaming Protocol (RTSP)~\cite{rtsp}.
RTSP is a network protocol used for multimedia streaming systems, its purpose is to orchestrate the exchange of media, such as audio and video, across the network. RTSP extends the RTP~\cite{rtp} and RTCP~\cite{rtcp} protocols by adding the necessary directives for streaming, such as:
\begin{itemize}
\item Describe: is used by the client to obtain information about the desired resource
\item Setup: specifies how a single media stream is to be transported
\item Play/Pause: starts/stops multimedia playback
\item Record: used to store a stream
\end{itemize}
ONVIF (Open Network Video Interface Forum) is an organisation whose aim is to promote compatibility between video surveillance equipment so that systems made by different companies are interoperable.
ONVIF provides an interface for communication with the different equipment through the use of various protocols. ONVIF provides different configuration profiles to make the best use of the different technical features.
Profiles G, Q, S and T, are dedicated to video systems, however, the Tapo C200 is only compatible with Profile S~\cite{comp}.
Profile S is one of the most basic profiles and is designed for IP-based video systems, the features provided for Profile S that are compatible with the Tapo C200 are user authentication, NTP support and H264~\cite{onvifs} audio and video streaming using RTSP.
In order to take advantage of the multimedia streaming services, it was necessary to use the open source, multi-platform media player VLC~\cite{vlc} and the iSpy DVR~\cite{ispy}.
In order to scan the services exposed by the device, the software Nmap~\cite{nmap} was used, which is able to perform port scanning operations, and the software Nessus~\cite{nessus}, which allows to perform a risk analysis on network devices, indicating the criticality level of vulnerabilities according to the CVSS standard.
CVSS is an industry standard designed to assess the severity of computer system security vulnerabilities~\cite{cvss}. The assessment consists of a score on a scale from 0 to 10 calculated on the basis of a formula~\cite{scoreCvssdoc} that takes into account Attack Vector (AV), Scope (S), Attack Complexity (AC), Confidentiality (C), Privileges Required (PR) \& Integrity (I), User Interaction (UI) and Availability (A). The higher the score obtained based on the values assigned to these metrics, the more serious the vulnerability.
Finally, the Tapo C200 was analysed using the tools Ettercap~\cite{ettercap} to intercept traffic to and from the device, SSL packet capture~\cite{sslpacket} to intercept and read traffic to and from the Tapo application and Wireshark~\cite{wireshark} to understand network traffic and use the H264 extractor extension to convert network traffic into playable video.
\section{Reverse engineering}~\label{sec:reverse}
Our work starts from the reverse engineering process that allowed us to deduce that: when the application and the camera are on different networks, a classic client-server architecture is used in which the Tapo Server is used to distribute information, such as the device configuration.
Conversely, when both are on the same network, no external servers are used to control the camera and access the video stream.
It is important to note that the flow for control and editing differs substantially from that for video streaming.
The diagram in Figure \ref{ctrltapo} describes the sequence of operations that allow the user to access the video stream through the Tapo application. After choosing one of the initialised devices, the Tapo application logs into the Tapo C200, obtaining the token \emph{stok} needed to perform the control and modification operations.
The \emph{stok} is a token generated during authentication by the Tapo C200 which, after authenticating the user with a username and password, assigns this token to the Tapo application. The purpose of the token is to create a session without having to re-authenticate the application every time the camera settings are changed. The various requests generated by the application carry the \emph{stok} obtained in the last authentication phase. In this way the Tapo C200 only accepts requests from authenticated users.
Following the user's request to access the video stream the Tapo application and the Tapo C200 coordinate, in particular, the Tapo C200 sends to the application a \textit{nonce} necessary for the construction of the symmetric key.
At this point both parties calculate the initialisation vector and AES key in order to encrypt the video stream using AES in CBC mode.
Once the key has been calculated, the Tapo application authenticates itself to the Tapo C200 by providing an \lq\lq response" tag. Finally, the Tapo C200, after verifying the validity of the response, starts the multimedia streaming session by encrypting it with the agreed key.
\begin{figure}[ht]
\centering
\includegraphics[scale=0.3]{Images/utilizzo_strandard_tapo.png}
\begin{flushleft}
\fcolorbox{black}{black}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Communication in plaintext.\newline
\fcolorbox{black}{blue}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Communication over TLS channel.\newline
\fcolorbox{black}{orange}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Stream video Encrypted with AES key
\end{flushleft}
\caption{Sequence diagram for using the IP Camera with the proprietary Tapo application}
\label{ctrltapo}
\end{figure}
From the diagram in Figure~\ref{diagterz} we can notice how the integration of the Tapo C200 with third-party software is handled. Using the Tapo application, we first need to access the device in question and change its settings so that we can create a new user for third-party software.
After that, we can use the Tapo C200 with the previously mentioned software iSpy and VLC, which log in and start the free-to-air media streaming session with the camera.
In order to be able to use third-party applications, it was necessary to correctly configure the already initialised Tapo C200 by creating a special user on the camera using the Tapo application. Therefore, since this was a change to the Tapo C200 settings, the request generated by the Tapo application was accompanied by the \emph{stok}.
To access the resource, the Linux machine with VLC and iSpy installed was used, i.e. the machine (e) of the testbed. Using Ettercap and Wireshark installed on machine (d) instead, a MiTM attack was carried out in order to analyse the traffic.
From machine (e) it was possible to access the video stream using both players.
\begin{itemize}
\item On VLC, select the \lq\lq network resources" section of the player and enter:\\
\url{rtsp://username:password@<tapoc200address>/stream/1}
\item On iSpy, configure the ONVIF S profile to URI:\\ \url{http://username:password@<tapoc200address>/onvif/device\_service}
\end{itemize}
Since ONVIF's S profile does not add any functionality to the video stream, no differences emerged from the analysis of the traffic generated for the video stream of the two players. In particular, the packets analysed showed that, after accessing through the specific URI for ONVIF devices, iSpy uses RTSP in the exact way used by VLC. The diagram shows how the Tapo C200 is integrated with third-party software. Using the Tapo application, we first need to access the device in question and change its settings so that we can create a new user account for third-party software.
In summary, the Tapo C200 can then be used with the previously mentioned software iSpy and VLC, which log in and start the unencrypted multimedia streaming session with the camera.
\begin{figure}[ht]
\centering
\includegraphics[scale=0.32]{Images/Utilizzo_standard.png}
\begin{flushleft}
\fcolorbox{black}{black}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Communication in plaintext.\newline
\fcolorbox{black}{blue}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Communication over TLS channel
\end{flushleft}
\caption{Sequence diagram for using the IP Camera with third party software}
\label{diagterz}
\end{figure}
\section{Vulnerability Assessment}~\label{sec:VA}
The vulnerability assessment activity carried out is divided into two parts, one concerning proprietary services and the other concerning third party video streams.
\subsection{Proprietary services analysis}
Security in terms of the confidentiality of the video stream when the Tapo application and Tapo C200 are not on the same network, is entrusted to the channel itself on which it takes place. Using SSL/TLS on port 443, all data exchanged between the Tapo C200, the TP-Link server and the Tapo application is properly encrypted.
In addition, the Tapo application and the Tapo C200 use SSL pinning~\cite{pinning}, meaning that if information needs to be shared with the TP-Link server, no SSL/TLS session is established towards any entity other than a TP-Link server whose SSL/TLS certificate they already have by default.
However, despite the use of SSL/TLS, it was found that the traffic is easily detected, particularly with regard to movement notifications.
The motion detection function follows the steps:
\begin{enumerate}
\item The Tapo C200 detects movement and sends notification to the TP-Link server;
\item The server receives the notification and sends an alert to all devices connected to the account associated with the camera;
\item The application receives the message and generates a notification for the user.
\end{enumerate}
Our study found that the size of the messages generated was always the same, 523 bytes. By using the Tapo C200 as an oracle, the attacker may be able to discern movement notifications based on the size of the messages, without intervening in the cryptographic scheme and deducing, for example, when the victim is home and when no one is home. In addition, by filtering and blocking only those types of messages, the attacker could undermine the availability of the notification service by deceiving the victim that there is no movement in the area covered by the camera.
\subsection{Third party video stream analysis}
The use of third-party players for multimedia streaming presents a high level criticality, both as regards the ONVIF service on port 2020 and RTSP on port 554.
Since the ONVIF profile S is limited to providing an interface for the use of RTSP, both approaches seen for video streaming do not have any system to guarantee the confidentiality of the multimedia stream. In fact, after configuring the Tapo C200 to use these systems, whenever a request is made, the video stream is sent in clear text following the H264 encoding.
This approach is critical, especially with regard to the confidentiality of the data as it could allow the attacker to intercept the stream and decode it, thus obtaining the original and reproducible video stream.
\section{Penetration Testing}~\label{sec:PT}
\subsection{Camera DoS} \label{sec:camerados}
A Denial of Service (DoS) is a malfunction of a device due to a computer attack. Generally, such attacks aim to undermine the availability of a service by overloading the system and making an arbitrarily large number of requests, sometimes in a distributed manner (Distributed Denial of Services or DDoS). In the case of the Tapo C200, a DoS attack was relatively simple. In fact, an intensive scan by Nessus caused the device to crash, as can be seen in Figure~\ref{fig:crashed_camera}, causing it to stop and then reboot. This demonstrates how an attacker on the same network as the device can seriously compromise the availability of the service.
Figure~\ref{fig:DoSScore} shows the CVSS score of this vulnerability,
which has been classified as Medium, with a value of 6.5.
\begin{figure}[ht]
\centering
\includegraphics[scale=0.3]{Images/crashed_camera.jpg}
\caption{Crash of the Tapo C200 camera}
\label{fig:crashed_camera}
\end{figure}
\begin{figure}[ht]
\centering
\includegraphics[scale=0.5]{Images/Dosscore.png}
\caption{DoS score}
\label{fig:DoSScore}
\end{figure}
\subsection{Video Eavesdropping} \label{sec:privacyattack}
To demonstrate how an attacker could obtain the multimedia stream transmitted using third-party software, an experiment was conducted using the machine on which the multimedia players were installed, that is the machine (e), and starting a multimedia session with the Tapo C200. At the same time, machine (d) was used again in MiTM attack mode to intercept the traffic exchanged between the player and the Tapo C200.
By analysing the intercepted traffic with Wireshark it was possible to use the H264 extractor tool~\ref{extractor}, the tool was able to correctly interpret and reconstruct the entire intercepted multimedia streaming session. The output of the tool, produce the reproducible video of the intercepted session.
Finally, Figure~\ref{fig:leakscore} shows the CVSS score of this vulnerability, which was classified as Medium, with a value of 6.5
\begin{figure}[ht]
\centering
\includegraphics[scale=0.4]{Images/pacchetti264.png}
\caption{Packages H264}
\label{extractor}
\end{figure}
\begin{figure}[ht]
\centering
\includegraphics[scale=0.5]{Images/leakscore.png}
\caption{Video eavesdropping score}
\label{fig:leakscore}
\end{figure}
\subsection{Motion Oracle} \label{sec:motionoracle}
To demonstrate how an attacker could use the Tapo C200 as an oracle, a special experiment was conducted.
Throughout the night, the Tapo C200 was used to record a public street. Once the traffic was recorded, outgoing packets from the Tapo C200 were filtered on the base:
\begin{itemize}
\item Of the protocol used, by inserting the SSL/TLS filter
\item Of the frame length, by inserting the filter \textit{frame.length==523}
\end{itemize}
Once the packets were obtained, we constructed a graph shown in Figure~\ref{graftraf}. From the graph we can see the number of SSL/TLS packets of 523 bytes captured at ten minute intervals. In addition, it can be seen that starting at 23:00, the amount of packets begins to decrease until about 3:00. From 3:30 it is possible to see an increase in packets reaching a maximum around 7:00. The trend of the curve is consistent with what could be expected and shows that the influx of cars decreases during the night and increases in the morning.
\begin{figure}[ht]
\centering
\includegraphics[width=\linewidth]{Images/grafico_movimenti.jpg}
\caption{Graph of transit packet traffic on 7-8 June 2021}
\label{graftraf}
\end{figure}
By comparing the graph with the video recorded on the Tapo C200's SD card, it was found that there was a complete match between captured packets and recorded movements. Observing the recorded video, it was found that all the actual movements are shown in the graph. For example, a frame from about 00:05 is shown in Figure~\ref{immovi}, where a car can be seen in transit.
\begin{figure}[ht]
\centering
\includegraphics[width=\linewidth]{Images/movimento_00_05.png}
\caption{Movement recorded at 00:05}
\label{immovi}
\end{figure}
This demonstrates how an attacker on the same network as the Tapo C200 can precisely detect traffic related to the Tapo C200's motion detection service, traffic that could be used to deduce information about the victim by monitoring the frequency of these packets.
Furthermore, this experiment demonstrates how the attacker can trivially filter out such packets and deceive the victim.
Figure~\ref{scoremo} shows the CVSS score of this vulnerability, which was classified as \emph{Medium}, with a value of 5.4.
\begin{figure}[ht]
\centering
\includegraphics[scale=0.5]{Images/motionscore.png}
\caption{Motion Oracle score}
\label{scoremo}
\end{figure}
\section{Countermeasures}\label{sec:countermeasures}
Our work proposes a set of countermeasures developed to mitigate the vulnerability of video eavesdropping. The Raspberry Pi 4 Model B was used for this purpose.
The idea behind the proposed solution to guarantee the confidentiality of the video stream in the third party scenario is to use the Raspberry Pi 4 Model B as an access point of the Tapo C200 in order to modify the traffic in transit by applying encryption.
\subsection{Raspberry Pi into the testbed}
The Raspberry Pi 4 Model B has a network card with a wired and a wireless interface. Thanks to this feature it was possible to connect the Raspberry Pi 4 Model B to the testbed modem while exposing a Wi-Fi network to which the Tapo C200 could be connected, as shown in Figure \ref{testbed2}.
\begin{figure}[ht]
\centering
\includegraphics[scale=0.35]{Images/pi_third_testbed.png}
\caption{Raspberry Pi in the network infrastructure}
\label{testbed2}
\end{figure}
In order to build the network infrastructure described above, the Raspberry Pi 4 Model B had to be configured to act as an access point for the Tapo C200 on behalf of the modem~\cite{settingrasp}. Specifically, it was necessary to install the hostapd~\cite{hostpad} tool.
This module, available for Linux machines, allows normal network interfaces to be transformed into Access Points. In addition, it was necessary to modify the dhcpd configuration of the Raspberry Pi 4 Model B.
\subsection{Traffic encryption}
To encrypt network traffic we configured IPtables on the Raspberry Pi 4 Model B, the policy adopted is shown in Listing~\ref{code:IPtablesEnc}:
\begin{lstlisting}[caption={Configuration of IPtables for encryption}, label={code:IPtablesEnc}]
iptables - A FORWARD - m
--physdev-is-in wlan0 -p udp
-s TAPOC200_ADDRESS_IPV4
-j NFQUEUE --queue num 1
iptables -A INPUT-A FORWARD -m
--physdev-is-in wlan0 -f -j DROP
\end{lstlisting}
In this way it was possible to intercept packets in transit (FORWARD) from the network interface (-m --physdev-is-in wlan0) transported with UDP (-p udp) coming from the Tapo C200 (-s TAPOC200\_ADDRESS\_IPV4) and send them on queue 1.
Thanks to the second rule, it is possible to eliminate all possible fragments of the packets in transit, in order to avoid sending partial packets.
At this point, we have built a script to encrypt the packets queued by the firewall. The script takes care of retrieving packets from the queue, extracting the payload, encrypting it and sending it back to the recipient's address, all the script code is shown in the Listing~\ref{code:encryptscript}.
\begin{lstlisting}[caption={Encryption script}, label={code:encryptscript}]
def encrypt(packet):
cipher_suite = Fernet(key)
encoded_text = cipher_suite.encrypt
(packet.get_payload()[28:])
pkt = IP(packet.get_payload())
UDP_IP = pkt[IP].dst
UDP_PORT = pkt[UDP].dport
MESSAGE = encoded_text
sock = socket.socket(socket.AF_INET,
socket.SOCK_DGRAM)
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
packet.drop()
\end{lstlisting}
\subsection{Traffic decryption}
A configuration of IPtables was also developed for the client with the third-party software running, the policy adopted is shown in Listing~\ref{code:IPtablesDec}:
\begin{lstlisting}[caption={Configuration of IPtables for decryption}, label={code:IPtablesDec}]
iptables -A INPUT -p udp
-s RASPBERRY_ADDRESS_IPV4
-j NFQUEUE --queue num 2
\end{lstlisting}
Through this solution it is possible to intercept incoming packets (INPUT) transported with UDP (-p udp) coming from the Raspberry Pi 4 Model B (-s RASPBERRY \- ADDRESS \_ IPV4) and send them on queue 2.
The script for decrypting the packets queued by the firewall is shown in Listing~\ref{code:decryptscript}.
More specifically, the script takes care of fetching packets from the queue, extracting the payload and decrypting it before accepting it into the system.
\begin{lstlisting}[caption={Decryption script}, label={code:decryptscript}]
def decrypt(packet):
cipher_suite = Fernet(key)
decoded_text = cipher_suite.decrypt
(packet.get_payload()[28:])
pkt = IP(packet.get_payload())
UDP_IP = pkt[IP].dst
UDP_PORT = pkt[UDP].dport
MESSAGE = decoded_text
sock = socket.socket(socket.AF_INET,
socket.SOCK_DGRAM)
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
packet.drop()
\end{lstlisting}
\subsection{Proposed solution in the third-party scenario}
The configuration of the countermeasures just seen, although it modifies the initial testbed, has no impact on the actions the user has to take to initialise the Tapo C200 and its use.
A sequence diagram of how the Tapo C200 works with third-party software is shown in Figure~\ref{utipi}.
\begin{figure}[ht]
\centering
\includegraphics[scale=0.3]{Images/Utilizzo_Pi.png}
\begin{flushleft}
\fcolorbox{black}{black}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Communication in plaintext\newline
\fcolorbox{black}{blue}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Communication over the TLS channel\newline
\fcolorbox{black}{orange}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Video stream encrypted with symmetrical AES key
\end{flushleft}
\caption{Sequence diagram of the use of the IP Camera with Raspberry Pi in the network infrastructure}
\label{utipi}
\end{figure}
It can be seen that in the use phase the presence of the Raspberry Pi 4 Model B is totally transparent to the user. The routing of the video stream is managed by the devices themselves, so the user can use the service exactly as in the initial scenario. Moreover, thanks to the proposed countermeasure, we can observe that the video stream exchanged on the home network between the camera and the third party application is encrypted.
In order to demonstrate the effectiveness of the countermeasure, the experiment was carried out again, but in this case the execution of the H264 tool failed. The intercepted traffic, shown in Figure~\ref{trafficcif}, was unintelligible and the execution of the H264 extractor tool produced no results.
\begin{figure}[ht]
\centering
\includegraphics[scale=0.5]{Images/traffico_cifrato.png}
\caption{Encrypted network traffic}
\label{trafficcif}
\end{figure}
\section{Conclusions}\label{sec:conclusions}
IP cameras such as the Tapo C200 are very useful, widespread and definitely within everyone's reach. With the experiments conducted in this manuscript we have analysed the security of these devices also from a privacy point of view.
In order to fully understand what Tapo's vulnerabilities might be, a lot of reverse engineering work had to be done using various technologies.
This allowed us to define a detailed description of the ceremony that the Tapo C200 performs during its operation, among these operations we consider: the initialisation of the device, the use of the device through the proprietary systems of TP-Link and the integration of such device with third-party technologies.
Subsequently, the vulnerability assessment was carried out, from which it was found that although video streaming through the use of the Tapo application enjoys certain guarantees, the streaming service through the use of third-party applications is devoid of encryption mechanisms and therefore vulnerable.
Furthermore, it was highlighted that without intervening on the cryptographic systems used, one of the features offered by the camera, namely motion detection, can be a vector to profile and deceive the victim. It has been demonstrated how an attacker could exploit these vulnerabilities through penetration testing. The trial highlighted the Tapo C200's poor resilience to DoS attacks.
Therefore, it was highlighted that by applying a filter on the packets leaving the Tapo C200 on the basis of the protocol and the size, the motion detection service behaves like an oracle for the attacker.
By exploiting the mechanisms in question, the attacker could deduce the victim's habits and surgically inhibit the serve.
Furthermore, it was highlighted that thanks to the use of the H264 extractor tool, the attacker is able to intercept a video stream and convert it back into a playable video. The average of the Base scores of these vulnerabilities is 6.14, so the risk level associated with the Tapo C200 is Medium.
Finally, with regard to the critical issues encountered with the use of third-party technologies, a countermeasure was proposed using the Raspberry Pi 4 Model B. This countermeasure uses the Raspberry as an extension of the Tapo C200, capable of applying encryption to transmissions and guaranteeing confidentiality in a completely transparent way to the user.
Our experiments taught us that, although the security measures in place in the Tapo C200 are in line with the state of the art, they have not yet been tailored to all possible use scenarios, a finding that we plan to validate in the future over other common IoT devices.
\bibliographystyle{abbrv}
\section{Introduction}\label{sec:intro}
With the explosion of the Internet of Things (IoT) world, many devices already on the market have undergone a transformation, becoming more functional and cost-effective.
One of these is undoubtedly the IP camera, a video surveillance camera that uses the network to transmit audio and video signals. Unfortunately, IP cameras, like many other IoT devices, are the target of countless malicious cyber attacks that often aim to violate the confidentiality of transmitted data.
Today, IP cameras are being used to make CCTV, as confirmed by a 2019 estimate of around 770 million IP cameras being used in this field~\cite{survcamera}.
In addition, IP cameras are increasingly being used in peoples' houses. Thanks to their low cost, they are used, for example, to monitor a house when people are away, to monitor pets and also as baby monitors.
In view of the main uses, it is clear that the nature of the data transmitted by these devices is decidedly intimate and private.
Therefore, it would seem reasonable to assume that a series of countermeasures are implemented to protect the confidentiality of the transmissions.
However, there are no general guidelines for the realisation of such products and often the precautions taken are very weak or even completely absent.
The security of the IoT world has been at the centre of the global debate for a few years now. In fact, in October 2016, the Mirai malware was able to build a botnet, compromising thousands of devices, including many IP cameras~\cite{mirai}. In 2017, the list of known vulnerabilities within the CCTV Calculator~\cite{cctvcalc} was published, involving IP cameras from many vendors, including Samsung, D-link, Panasonic, Cisco, Hikvision, FOSCAM, Y-Cam, TP-Link, AirLive, Sony, Arecont Vision, Linksys, Canon and many more.
The topic of security and IP cameras is an open one, so in this paper we decided to carry out a vulnerability assessment and penetration testing process on one of today's IP cameras in particular, the TP-Link Tapo C200~\cite{c200}.
\subsection{Contributions}
This article explores whether and how IP cameras can be exploited today using freeware, i.e. non-commercial tools. We address this question in a scenario where there is an insider attacker who connects to the same network as the IP camera with her attacking laptop via Ethernet or Wi-Fi connectivity.
The results are that, relying on simple tools such as nmap, Ettercap, Wireshark and Python programming, the attacker can seriously compromise the service and undermine user privacy.
More precisely, we describe all our results obtained through the reverse engineering process performed on the Tapo camera; thanks to this process we were able to perform our vulnerability assessment.
The vulnerability assessment exercise allowed us to obtain information and evaluating a ceremony for everything related to proprietary services and third-party video streams. The work continued with penetration testing, which aim to exploit vulnerabilities obtained from the vulnerability assessment exercise on the Tapo camera. Specifically, we found that the Tapo camera suffers from: Denial of Service which clearly renders the camera unavailable; Video eavesdropping which affects user privacy; in addition, we demonstrate a third attack called \lq\lq Motion Oracle" which allows an attacker on the same network as the Tapo C200 to detect traffic related to the camera's motion detection service and use it to obtain information about the victim by analysing the frequency of generated traffic.
Finally, we prototype effective countermeasures, at least against video eavesdropping, by taking advantage of a cheap Raspberry Pi~\cite{raspb} device. This can implement encryption so that packets are only transferred in encrypted form over the network and therefore cannot be understood by a man in the middle (MITM).
The Raspberry Pi then transmits the encrypted packets from the IP Camera, ensuring user security, in a completely transparent manner.
\subsection{Testbed}
Our testbed consists of some useful devices for VAPT experiments.
The Tapo C200 is an entry-level IP camera designed for home use. Released in 2020 with a very low cost (around 30€), the Tapo C200 has several technical features, thanks to which it boasts several functionalities, such as: compatibility with the main smart home systems (e.g. Alexa~\cite{alexa} and Google Assistant~\cite{GoogleAssistant}); night vision, resolution up to Full HD; motion detection; acoustic alarm; data storage; voice control; use with third-party software; webcam mode.
To use the Tapo C200, a TP-Link account is required which allows access to the various cloud services offered.
Access to the TP-Link account is via the Tapo app, which is available free of charge on Google Play~\cite{tapoGPlay} and APP store~\cite{tapoApple} for devices running Android 4.4+ and IOS 9+ respectively. The application has a simple and intuitive user interface, from which it is possible to use and manage the devices of the Tapo family, including the Tapo C200. The range of services offered for the Tapo C200 includes: Remote access and control of the Tapo C200; Sharing the Tapo C200 with other accounts; synchronisation of settings; integrating the Tapo C200 with smart home systems; and receiving motion notifications.
Below, the Figure~\ref{fig:testbed} shows the testbed on which the experiments were conducted and how the elements of the testbed are connected to each other, note that all connections are made via a Wi-Fi network.
In a nutshell, the testbed consists of:
\begin{enumerate}[(a)]
\item A Wi-Fi switch to which the various devices were connected
\item The Tapo C200 IP Camera
\item A smartphone on which SSL Packet Capture and the Tapo application were installed
\item A Linux machine on which Ettercap and Wireshark tools have been installed
\item A Linux machine on which the third-party players iSpy and VLC have been installed
\end{enumerate}
\begin{figure}[ht]
\centering
\includegraphics[scale=0.35]{Images/origninal_testbed.png}
\caption{Original testbed}
\label{fig:testbed}
\end{figure}
By monitoring the environment with the various instruments, the Tapo C200 was used as a normal user, with the aim of extracting useful information for operational analysis.
\subsection{Related Work}\label{sec:RW}
As early as 2015, it was shown that IP cameras can encompass multiple research areas, including multimedia security, network security and cloud security, and end-user privacy.
In fact, Tekeoglu and Tosun looked into the security of cloud-based wireless IP cameras~\cite{cloudbasedIPcamerajpeg}. They studied the traffic generated by a wireless IP camera that is easy to set up for the average home user. Hence, they proved that an attacker can sniff the IP camera's network traffic and would be able to reconstruct the JPEG images from the data stream. Based on their information, their system has some limitations, e.g. their script only reconstructed 253 JPEG images over about 20 hours of video track.
A few years later in 2017, Liranzo and Hayajneh presented an analysis of the main privacy and security issues affecting thousands of IP camera consumers globally, they proposed a series of recommendations to help protect consumers' IoT devices in the intimacy of their home~\cite{2017issueIPcamera}.
It is clear that modern IP cameras collect a large amount of data, which is then transferred to cloud systems.
As a result, IP cameras process data to such an extent that it becomes important to assess the security of these cameras also from the point of view of privacy for users.
\subsection{Paper Structure}
This manuscript continues to describe all background information useful for understanding the content of the paper (\S\ref{sec:background}). The core of the paper begins with the reverse engineering process (\S\ref{sec:reverse}) which continues with the vulnerability assessment (\S\ref{sec:VA}) and the penetration testing (\S\ref{sec:PT}) performed on the Tapo C200 IP camera. Finally, the paper describes a countermeasure (\S\ref{sec:countermeasures})
and concludes with some broader evaluations of the results (\S\ref{sec:conclusions}).
\section{Background}~\label{sec:background}
In this section we provide all the background information necessary for understanding all the steps performed in the VAPT work on the Tapo C200.
The IP camera also has the functionality to integrate the device with third-party infrastructures and systems. Such systems require the use of dedicated protocols such as the Real Time Streaming Protocol (RTSP)~\cite{rtsp}.
RTSP is a network protocol used for multimedia streaming systems, its purpose is to orchestrate the exchange of media, such as audio and video, across the network. RTSP extends the RTP~\cite{rtp} and RTCP~\cite{rtcp} protocols by adding the necessary directives for streaming, such as:
\begin{itemize}
\item Describe: is used by the client to obtain information about the desired resource
\item Setup: specifies how a single media stream is to be transported
\item Play/Pause: starts/stops multimedia playback
\item Record: used to store a stream
\end{itemize}
ONVIF (Open Network Video Interface Forum) is an organisation whose aim is to promote compatibility between video surveillance equipment so that systems made by different companies are interoperable.
ONVIF provides an interface for communication with the different equipment through the use of various protocols. ONVIF provides different configuration profiles to make the best use of the different technical features.
Profiles G, Q, S and T, are dedicated to video systems, however, the Tapo C200 is only compatible with Profile S~\cite{comp}.
Profile S is one of the most basic profiles and is designed for IP-based video systems, the features provided for Profile S that are compatible with the Tapo C200 are user authentication, NTP support and H264~\cite{onvifs} audio and video streaming using RTSP.
In order to take advantage of the multimedia streaming services, it was necessary to use the open source, multi-platform media player VLC~\cite{vlc} and the iSpy DVR~\cite{ispy}.
In order to scan the services exposed by the device, the software Nmap~\cite{nmap} was used, which is able to perform port scanning operations, and the software Nessus~\cite{nessus}, which allows to perform a risk analysis on network devices, indicating the criticality level of vulnerabilities according to the CVSS standard.
CVSS is an industry standard designed to assess the severity of computer system security vulnerabilities~\cite{cvss}. The assessment consists of a score on a scale from 0 to 10 calculated on the basis of a formula~\cite{scoreCvssdoc} that takes into account Attack Vector (AV), Scope (S), Attack Complexity (AC), Confidentiality (C), Privileges Required (PR) \& Integrity (I), User Interaction (UI) and Availability (A). The higher the score obtained based on the values assigned to these metrics, the more serious the vulnerability.
Finally, the Tapo C200 was analysed using the tools Ettercap~\cite{ettercap} to intercept traffic to and from the device, SSL packet capture~\cite{sslpacket} to intercept and read traffic to and from the Tapo application and Wireshark~\cite{wireshark} to understand network traffic and use the H264 extractor extension to convert network traffic into playable video.
\section{Reverse engineering}~\label{sec:reverse}
Our work starts from the reverse engineering process that allowed us to deduce that: when the application and the camera are on different networks, a classic client-server architecture is used in which the Tapo Server is used to distribute information, such as the device configuration.
Conversely, when both are on the same network, no external servers are used to control the camera and access the video stream.
It is important to note that the flow for control and editing differs substantially from that for video streaming.
The diagram in Figure \ref{ctrltapo} describes the sequence of operations that allow the user to access the video stream through the Tapo application. After choosing one of the initialised devices, the Tapo application logs into the Tapo C200, obtaining the token \emph{stok} needed to perform the control and modification operations.
The \emph{stok} is a token generated during authentication by the Tapo C200 which, after authenticating the user with a username and password, assigns this token to the Tapo application. The purpose of the token is to create a session without having to re-authenticate the application every time the camera settings are changed. The various requests generated by the application carry the \emph{stok} obtained in the last authentication phase. In this way the Tapo C200 only accepts requests from authenticated users.
Following the user's request to access the video stream the Tapo application and the Tapo C200 coordinate, in particular, the Tapo C200 sends to the application a \textit{nonce} necessary for the construction of the symmetric key.
At this point both parties calculate the initialisation vector and AES key in order to encrypt the video stream using AES in CBC mode.
Once the key has been calculated, the Tapo application authenticates itself to the Tapo C200 by providing an \lq\lq response" tag. Finally, the Tapo C200, after verifying the validity of the response, starts the multimedia streaming session by encrypting it with the agreed key.
\begin{figure}[ht]
\centering
\includegraphics[scale=0.3]{Images/utilizzo_strandard_tapo.png}
\begin{flushleft}
\fcolorbox{black}{black}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Communication in plaintext.\newline
\fcolorbox{black}{blue}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Communication over TLS channel.\newline
\fcolorbox{black}{orange}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Stream video Encrypted with AES key
\end{flushleft}
\caption{Sequence diagram for using the IP Camera with the proprietary Tapo application}
\label{ctrltapo}
\end{figure}
From the diagram in Figure~\ref{diagterz} we can notice how the integration of the Tapo C200 with third-party software is handled. Using the Tapo application, we first need to access the device in question and change its settings so that we can create a new user for third-party software.
After that, we can use the Tapo C200 with the previously mentioned software iSpy and VLC, which log in and start the free-to-air media streaming session with the camera.
In order to be able to use third-party applications, it was necessary to correctly configure the already initialised Tapo C200 by creating a special user on the camera using the Tapo application. Therefore, since this was a change to the Tapo C200 settings, the request generated by the Tapo application was accompanied by the \emph{stok}.
To access the resource, the Linux machine with VLC and iSpy installed was used, i.e. the machine (e) of the testbed. Using Ettercap and Wireshark installed on machine (d) instead, a MiTM attack was carried out in order to analyse the traffic.
From machine (e) it was possible to access the video stream using both players.
\begin{itemize}
\item On VLC, select the \lq\lq network resources" section of the player and enter:\\
\url{rtsp://username:password@<tapoc200address>/stream/1}
\item On iSpy, configure the ONVIF S profile to URI:\\ \url{http://username:password@<tapoc200address>/onvif/device\_service}
\end{itemize}
Since ONVIF's S profile does not add any functionality to the video stream, no differences emerged from the analysis of the traffic generated for the video stream of the two players. In particular, the packets analysed showed that, after accessing through the specific URI for ONVIF devices, iSpy uses RTSP in the exact way used by VLC. The diagram shows how the Tapo C200 is integrated with third-party software. Using the Tapo application, we first need to access the device in question and change its settings so that we can create a new user account for third-party software.
In summary, the Tapo C200 can then be used with the previously mentioned software iSpy and VLC, which log in and start the unencrypted multimedia streaming session with the camera.
\begin{figure}[ht]
\centering
\includegraphics[scale=0.32]{Images/Utilizzo_standard.png}
\begin{flushleft}
\fcolorbox{black}{black}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Communication in plaintext.\newline
\fcolorbox{black}{blue}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Communication over TLS channel
\end{flushleft}
\caption{Sequence diagram for using the IP Camera with third party software}
\label{diagterz}
\end{figure}
\section{Vulnerability Assessment}~\label{sec:VA}
The vulnerability assessment activity carried out is divided into two parts, one concerning proprietary services and the other concerning third party video streams.
\subsection{Proprietary services analysis}
Security in terms of the confidentiality of the video stream when the Tapo application and Tapo C200 are not on the same network, is entrusted to the channel itself on which it takes place. Using SSL/TLS on port 443, all data exchanged between the Tapo C200, the TP-Link server and the Tapo application is properly encrypted.
In addition, the Tapo application and the Tapo C200 use SSL pinning~\cite{pinning}, meaning that if information needs to be shared with the TP-Link server, no SSL/TLS session is established towards any entity other than a TP-Link server whose SSL/TLS certificate they already have by default.
However, despite the use of SSL/TLS, it was found that the traffic is easily detected, particularly with regard to movement notifications.
The motion detection function follows the steps:
\begin{enumerate}
\item The Tapo C200 detects movement and sends notification to the TP-Link server;
\item The server receives the notification and sends an alert to all devices connected to the account associated with the camera;
\item The application receives the message and generates a notification for the user.
\end{enumerate}
Our study found that the size of the messages generated was always the same, 523 bytes. By using the Tapo C200 as an oracle, the attacker may be able to discern movement notifications based on the size of the messages, without intervening in the cryptographic scheme and deducing, for example, when the victim is home and when no one is home. In addition, by filtering and blocking only those types of messages, the attacker could undermine the availability of the notification service by deceiving the victim that there is no movement in the area covered by the camera.
\subsection{Third party video stream analysis}
The use of third-party players for multimedia streaming presents a high level criticality, both as regards the ONVIF service on port 2020 and RTSP on port 554.
Since the ONVIF profile S is limited to providing an interface for the use of RTSP, both approaches seen for video streaming do not have any system to guarantee the confidentiality of the multimedia stream. In fact, after configuring the Tapo C200 to use these systems, whenever a request is made, the video stream is sent in clear text following the H264 encoding.
This approach is critical, especially with regard to the confidentiality of the data as it could allow the attacker to intercept the stream and decode it, thus obtaining the original and reproducible video stream.
\section{Penetration Testing}~\label{sec:PT}
\subsection{Camera DoS} \label{sec:camerados}
A Denial of Service (DoS) is a malfunction of a device due to a computer attack. Generally, such attacks aim to undermine the availability of a service by overloading the system and making an arbitrarily large number of requests, sometimes in a distributed manner (Distributed Denial of Services or DDoS). In the case of the Tapo C200, a DoS attack was relatively simple. In fact, an intensive scan by Nessus caused the device to crash, as can be seen in Figure~\ref{fig:crashed_camera}, causing it to stop and then reboot. This demonstrates how an attacker on the same network as the device can seriously compromise the availability of the service.
Figure~\ref{fig:DoSScore} shows the CVSS score of this vulnerability,
which has been classified as Medium, with a value of 6.5.
\begin{figure}[ht]
\centering
\includegraphics[scale=0.3]{Images/crashed_camera.jpg}
\caption{Crash of the Tapo C200 camera}
\label{fig:crashed_camera}
\end{figure}
\begin{figure}[ht]
\centering
\includegraphics[scale=0.5]{Images/Dosscore.png}
\caption{DoS score}
\label{fig:DoSScore}
\end{figure}
\subsection{Video Eavesdropping} \label{sec:privacyattack}
To demonstrate how an attacker could obtain the multimedia stream transmitted using third-party software, an experiment was conducted using the machine on which the multimedia players were installed, that is the machine (e), and starting a multimedia session with the Tapo C200. At the same time, machine (d) was used again in MiTM attack mode to intercept the traffic exchanged between the player and the Tapo C200.
By analysing the intercepted traffic with Wireshark it was possible to use the H264 extractor tool~\ref{extractor}, the tool was able to correctly interpret and reconstruct the entire intercepted multimedia streaming session. The output of the tool, produce the reproducible video of the intercepted session.
Finally, Figure~\ref{fig:leakscore} shows the CVSS score of this vulnerability, which was classified as Medium, with a value of 6.5
\begin{figure}[ht]
\centering
\includegraphics[scale=0.4]{Images/pacchetti264.png}
\caption{Packages H264}
\label{extractor}
\end{figure}
\begin{figure}[ht]
\centering
\includegraphics[scale=0.5]{Images/leakscore.png}
\caption{Video eavesdropping score}
\label{fig:leakscore}
\end{figure}
\subsection{Motion Oracle} \label{sec:motionoracle}
To demonstrate how an attacker could use the Tapo C200 as an oracle, a special experiment was conducted.
Throughout the night, the Tapo C200 was used to record a public street. Once the traffic was recorded, outgoing packets from the Tapo C200 were filtered on the base:
\begin{itemize}
\item Of the protocol used, by inserting the SSL/TLS filter
\item Of the frame length, by inserting the filter \textit{frame.length==523}
\end{itemize}
Once the packets were obtained, we constructed a graph shown in Figure~\ref{graftraf}. From the graph we can see the number of SSL/TLS packets of 523 bytes captured at ten minute intervals. In addition, it can be seen that starting at 23:00, the amount of packets begins to decrease until about 3:00. From 3:30 it is possible to see an increase in packets reaching a maximum around 7:00. The trend of the curve is consistent with what could be expected and shows that the influx of cars decreases during the night and increases in the morning.
\begin{figure}[ht]
\centering
\includegraphics[width=\linewidth]{Images/grafico_movimenti.jpg}
\caption{Graph of transit packet traffic on 7-8 June 2021}
\label{graftraf}
\end{figure}
By comparing the graph with the video recorded on the Tapo C200's SD card, it was found that there was a complete match between captured packets and recorded movements. Observing the recorded video, it was found that all the actual movements are shown in the graph. For example, a frame from about 00:05 is shown in Figure~\ref{immovi}, where a car can be seen in transit.
\begin{figure}[ht]
\centering
\includegraphics[width=\linewidth]{Images/movimento_00_05.png}
\caption{Movement recorded at 00:05}
\label{immovi}
\end{figure}
This demonstrates how an attacker on the same network as the Tapo C200 can precisely detect traffic related to the Tapo C200's motion detection service, traffic that could be used to deduce information about the victim by monitoring the frequency of these packets.
Furthermore, this experiment demonstrates how the attacker can trivially filter out such packets and deceive the victim.
Figure~\ref{scoremo} shows the CVSS score of this vulnerability, which was classified as \emph{Medium}, with a value of 5.4.
\begin{figure}[ht]
\centering
\includegraphics[scale=0.5]{Images/motionscore.png}
\caption{Motion Oracle score}
\label{scoremo}
\end{figure}
\section{Countermeasures}\label{sec:countermeasures}
Our work proposes a set of countermeasures developed to mitigate the vulnerability of video eavesdropping. The Raspberry Pi 4 Model B was used for this purpose.
The idea behind the proposed solution to guarantee the confidentiality of the video stream in the third party scenario is to use the Raspberry Pi 4 Model B as an access point of the Tapo C200 in order to modify the traffic in transit by applying encryption.
\subsection{Raspberry Pi into the testbed}
The Raspberry Pi 4 Model B has a network card with a wired and a wireless interface. Thanks to this feature it was possible to connect the Raspberry Pi 4 Model B to the testbed modem while exposing a Wi-Fi network to which the Tapo C200 could be connected, as shown in Figure \ref{testbed2}.
\begin{figure}[ht]
\centering
\includegraphics[scale=0.35]{Images/pi_third_testbed.png}
\caption{Raspberry Pi in the network infrastructure}
\label{testbed2}
\end{figure}
In order to build the network infrastructure described above, the Raspberry Pi 4 Model B had to be configured to act as an access point for the Tapo C200 on behalf of the modem~\cite{settingrasp}. Specifically, it was necessary to install the hostapd~\cite{hostpad} tool.
This module, available for Linux machines, allows normal network interfaces to be transformed into Access Points. In addition, it was necessary to modify the dhcpd configuration of the Raspberry Pi 4 Model B.
\subsection{Traffic encryption}
To encrypt network traffic we configured IPtables on the Raspberry Pi 4 Model B, the policy adopted is shown in Listing~\ref{code:IPtablesEnc}:
\begin{lstlisting}[caption={Configuration of IPtables for encryption}, label={code:IPtablesEnc}]
iptables - A FORWARD - m
--physdev-is-in wlan0 -p udp
-s TAPOC200_ADDRESS_IPV4
-j NFQUEUE --queue num 1
iptables -A INPUT-A FORWARD -m
--physdev-is-in wlan0 -f -j DROP
\end{lstlisting}
In this way it was possible to intercept packets in transit (FORWARD) from the network interface (-m --physdev-is-in wlan0) transported with UDP (-p udp) coming from the Tapo C200 (-s TAPOC200\_ADDRESS\_IPV4) and send them on queue 1.
Thanks to the second rule, it is possible to eliminate all possible fragments of the packets in transit, in order to avoid sending partial packets.
At this point, we have built a script to encrypt the packets queued by the firewall. The script takes care of retrieving packets from the queue, extracting the payload, encrypting it and sending it back to the recipient's address, all the script code is shown in the Listing~\ref{code:encryptscript}.
\begin{lstlisting}[caption={Encryption script}, label={code:encryptscript}]
def encrypt(packet):
cipher_suite = Fernet(key)
encoded_text = cipher_suite.encrypt
(packet.get_payload()[28:])
pkt = IP(packet.get_payload())
UDP_IP = pkt[IP].dst
UDP_PORT = pkt[UDP].dport
MESSAGE = encoded_text
sock = socket.socket(socket.AF_INET,
socket.SOCK_DGRAM)
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
packet.drop()
\end{lstlisting}
\subsection{Traffic decryption}
A configuration of IPtables was also developed for the client with the third-party software running, the policy adopted is shown in Listing~\ref{code:IPtablesDec}:
\begin{lstlisting}[caption={Configuration of IPtables for decryption}, label={code:IPtablesDec}]
iptables -A INPUT -p udp
-s RASPBERRY_ADDRESS_IPV4
-j NFQUEUE --queue num 2
\end{lstlisting}
Through this solution it is possible to intercept incoming packets (INPUT) transported with UDP (-p udp) coming from the Raspberry Pi 4 Model B (-s RASPBERRY \- ADDRESS \_ IPV4) and send them on queue 2.
The script for decrypting the packets queued by the firewall is shown in Listing~\ref{code:decryptscript}.
More specifically, the script takes care of fetching packets from the queue, extracting the payload and decrypting it before accepting it into the system.
\begin{lstlisting}[caption={Decryption script}, label={code:decryptscript}]
def decrypt(packet):
cipher_suite = Fernet(key)
decoded_text = cipher_suite.decrypt
(packet.get_payload()[28:])
pkt = IP(packet.get_payload())
UDP_IP = pkt[IP].dst
UDP_PORT = pkt[UDP].dport
MESSAGE = decoded_text
sock = socket.socket(socket.AF_INET,
socket.SOCK_DGRAM)
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
packet.drop()
\end{lstlisting}
\subsection{Proposed solution in the third-party scenario}
The configuration of the countermeasures just seen, although it modifies the initial testbed, has no impact on the actions the user has to take to initialise the Tapo C200 and its use.
A sequence diagram of how the Tapo C200 works with third-party software is shown in Figure~\ref{utipi}.
\begin{figure}[ht]
\centering
\includegraphics[scale=0.3]{Images/Utilizzo_Pi.png}
\begin{flushleft}
\fcolorbox{black}{black}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Communication in plaintext\newline
\fcolorbox{black}{blue}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Communication over the TLS channel\newline
\fcolorbox{black}{orange}{\rule{0pt}{4pt}\rule{4pt}{0pt}}\quad Video stream encrypted with symmetrical AES key
\end{flushleft}
\caption{Sequence diagram of the use of the IP Camera with Raspberry Pi in the network infrastructure}
\label{utipi}
\end{figure}
It can be seen that in the use phase the presence of the Raspberry Pi 4 Model B is totally transparent to the user. The routing of the video stream is managed by the devices themselves, so the user can use the service exactly as in the initial scenario. Moreover, thanks to the proposed countermeasure, we can observe that the video stream exchanged on the home network between the camera and the third party application is encrypted.
In order to demonstrate the effectiveness of the countermeasure, the experiment was carried out again, but in this case the execution of the H264 tool failed. The intercepted traffic, shown in Figure~\ref{trafficcif}, was unintelligible and the execution of the H264 extractor tool produced no results.
\begin{figure}[ht]
\centering
\includegraphics[scale=0.5]{Images/traffico_cifrato.png}
\caption{Encrypted network traffic}
\label{trafficcif}
\end{figure}
\section{Conclusions}\label{sec:conclusions}
IP cameras such as the Tapo C200 are very useful, widespread and definitely within everyone's reach. With the experiments conducted in this manuscript we have analysed the security of these devices also from a privacy point of view.
In order to fully understand what Tapo's vulnerabilities might be, a lot of reverse engineering work had to be done using various technologies.
This allowed us to define a detailed description of the ceremony that the Tapo C200 performs during its operation, among these operations we consider: the initialisation of the device, the use of the device through the proprietary systems of TP-Link and the integration of such device with third-party technologies.
Subsequently, the vulnerability assessment was carried out, from which it was found that although video streaming through the use of the Tapo application enjoys certain guarantees, the streaming service through the use of third-party applications is devoid of encryption mechanisms and therefore vulnerable.
Furthermore, it was highlighted that without intervening on the cryptographic systems used, one of the features offered by the camera, namely motion detection, can be a vector to profile and deceive the victim. It has been demonstrated how an attacker could exploit these vulnerabilities through penetration testing. The trial highlighted the Tapo C200's poor resilience to DoS attacks.
Therefore, it was highlighted that by applying a filter on the packets leaving the Tapo C200 on the basis of the protocol and the size, the motion detection service behaves like an oracle for the attacker.
By exploiting the mechanisms in question, the attacker could deduce the victim's habits and surgically inhibit the serve.
Furthermore, it was highlighted that thanks to the use of the H264 extractor tool, the attacker is able to intercept a video stream and convert it back into a playable video. The average of the Base scores of these vulnerabilities is 6.14, so the risk level associated with the Tapo C200 is Medium.
Finally, with regard to the critical issues encountered with the use of third-party technologies, a countermeasure was proposed using the Raspberry Pi 4 Model B. This countermeasure uses the Raspberry as an extension of the Tapo C200, capable of applying encryption to transmissions and guaranteeing confidentiality in a completely transparent way to the user.
Our experiments taught us that, although the security measures in place in the Tapo C200 are in line with the state of the art, they have not yet been tailored to all possible use scenarios, a finding that we plan to validate in the future over other common IoT devices.
\bibliographystyle{abbrv}
|
{'timestamp': '2022-02-15T02:40:55', 'yymm': '2202', 'arxiv_id': '2202.06597', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06597'}
|
arxiv
|
\section{Introduction}
\label{sec:introduction}
Deterministic continuum models for the growth of cell populations have been increasingly used as theoretical tools to support empirical research regarding a broad spectrum of aspects of the development of solid tumours and living tissues. These models comprise partial differential equations (PDEs) that describe the evolution of cellular densities (or cell volume fractions) in response to pressure gradients that are generated by population growth, which can be mechanically-regulated, nutrient-limited or pressure-dependent~\cite{ambrosi2002mechanics,ambrosi2002closure,araujo2004history,bresch2010computational,bubba2020hele,byrne1995growth,byrne1996growth,byrne1997free,byrne2003two,byrne2003modelling,byrne2009individual,chaplain2006mathematical,chaplain2019derivation,chen2001influence,ciarletta2011radial,david2022asymptotic,Gallinato,Giverso_avascular,greenspan1976growth,lorenzi2017interfaces,lowengrub2009nonlinear,perthame2014some,preziosi2003cancer,ranft2010fluidization,roose2007mathematical,sherratt2001new,ward1999mathematical,ward1997mathematical}. These models are amenable not only to numerical simulations but also to analytical approaches, which enable a complete exploration of the model parameter space. This permits a precise identification of the validity domain of the results obtained and ensures higher robustness and precision of the conclusions drawn therefrom, which ultimately provides a more in-depth theoretical understanding of the underlying cellular dynamics.
Ideally, instead of defining such PDE models on the basis of population-scale phenomenological assumptions, one wants to derive them from first principles, that is, as the deterministic continuum limits of stochastic discrete models, \emph{i.e.} individual-based (IB) models, which track the dynamics of single cells~\cite{anderson2007single,van2015simulating}. This is to ensure that the terms comprised in the model equations provide a faithful mean-field representation of the underlying cellular dynamics. In fact, although being computationally intensive to simulate for large cell numbers and, to a wider extent, inaccessible to analytical techniques, IB models permit the representation of the finer details of cell-scale mechanisms and capture stochastic intercellular variability in the spatial and evolutionary trajectories of single cells. These aspects, which cannot be directly incorporated into phenomenological deterministic continuum models, become especially important in scenarios where cell numbers and densities are low (\emph{e.g.} in the early stages of embryonic development and tissue regeneration, during the formation of distant metastases upon cancer cell extravasation, and when tumour size is severely reduced after therapy), due to the stronger impact that single-cell processes and demographic stochasticity are expected to have on the dynamics of cell populations. For this reason, a range of asymptotic techniques, probabilistic methods and limiting procedures have been developed and used in previous studies to systematically derive PDE models for the growth of cell populations from their individual-based counterparts~\cite{baker2019free,byrne2009individual,chaplain2020bridging,deroulers2009modeling,drasdo2005coarse,dyson2012macroscopic,fozard2009continuum,inoue1991derivation,johnston2012mean,johnston2015modelling,lorenzi2020individual,motsch2018short,murray2012classifying,murray2009discrete,penington2011building,simpson2007simulating,oelschlager1989derivation,oelschlager1990large}.
However, these previous studies have mainly been focused on homogeneous populations in which all cells have the same phenotypic characteristics. Such homogeneity is rarely present in cellular systems, where significant intercellular phenotypic variability is commonly observed. In light of these considerations, we develop here an IB model for the growth of phenotypically heterogeneous cell populations. In this model, every cell is viewed as an individual agent whose phenotypic state is described by a structuring variable that captures intercellular variability in cell proliferation and migration rates. Cells undergo directional movement in response to pressure differentials~\cite{ambrosi2002closure,byrne1997free,byrne2009individual,greenspan1976growth}, pressure-dependent proliferation~\cite{bru2003universal,byrne2003modelling,drasdo2012modeling,ranft2010fluidization}, and heritable phenotypic changes~\cite{brock2009non,chisholm2016cell,huang2013genetic} according to a set of rules that correspond to a discrete-time branching random walk on the physical space and the space of phenotypic states~\cite{chaplain2020bridging,chisholm2016evolutionary,hughes1995random}. We formally show that the deterministic continuum limit of this model is given by a non-local PDE for the cell population density function, which generalises earlier models~\cite{byrne2009individual,drasdo2012modeling,perthame2014hele} to the case of phenotypically heterogeneous cell populations. We then carry out numerical simulations of the IB model and compare the results obtained with the results of formal travelling-wave analysis and numerical simulations of the PDE model.
The paper is organised as follows. In Section~\ref{sec:model}, we introduce the IB model. In Section~\ref{sec:formal}, we present its PDE counterpart (a formal derivation is provided in Appendix~\ref{app:derivation}). In Section~\ref{sec:numerics}, in order to reach conclusions with broad structural stability under parameter changes, we first carry out formal travelling-wave analysis of the PDE model and then integrate the results obtained with numerical simulations of the IB model and numerical solutions of the PDE model. In Section~\ref{sec:conclusion}, we summarise the main findings of our study and outline
directions for future research.
\section{The individual-based model}
\label{sec:model}
We model the dynamics of a phenotypically heterogeneous growing cell population. Cells within the population have the potential to undergo:
\begin{itemize}
\item[(i)] directional movement in response to pressure differentials -- \emph{i.e.} cells move down pressure gradients towards regions where they feel less compressed~\cite{ambrosi2002closure,byrne2003modelling,byrne2009individual};
\item[(ii)] spontaneous, heritable phenotypic changes, which lead cells to randomly transition from one phenotypic state into another~\cite{brock2009non,chisholm2016cell,huang2013genetic};
\item[(iii)] pressure-dependent proliferation -- \emph{i.e.} cells stop dividing, and can thus only die or remain quiescent, when the pressure that they experience overcomes a critical threshold, which is known as homeostatic pressure~\cite{basan2009homeostatic,byrne2009individual,drasdo2012modeling}.
\end{itemize}
Focussing on a one-dimensional spatial domain scenario, the position of every cell at time $t\in \mathbb{R}^{+}$ is described by the variable $x \in \mathbb{R}$. Moreover, the phenotypic state of each cell is characterised by a structuring variable $y \in [0,Y] \subset \mathbb{R}^{+}$, with $Y>0$, which takes into account intercellular variability in cell proliferation and migration rates (\emph{e.g.} the variable $y$ could represent the level of expression of a gene that regulates both cell division and cell migration). In particular, without loss of generality, we consider the case where larger values of $y$ correlate with a higher cell migration rate but a lower proliferation rate due to proliferation-migration tradeoffs~\cite{aktipis2013life,alfonso2017biology,gallaher2019impact,gerlee2009evolution,gerlee2012impact,giese2003cost,giese1996dichotomy,hatzikirou2012go,orlando2013tumor,pham2012density}.
We discretise the time, space and phenotype variables via
$$
t_k=k \tau \in \mathbb{R}^{+}, \;\; x_i=i \chi \in \mathbb{R} \; \text{ and } \; y_j=j \eta \in [0,Y] \; \text{ with } \; k, j \in \mathbb{N}_0, \; i \in \mathbb{Z}, \; \tau, \chi, \eta \in \mathbb{R}^{+}_*.
$$
Here $\tau$, $\chi$ and $\eta$ are the time-, space- and phenotype-step, respectively. We represent every single cell as an agent that occupies a position on the lattice $\{x_i\}_{i \in \mathbb{Z}} \times \{y_j\}_{j \in \mathbb{N}_0}$, and we introduce the dependent variable $N_{i,j}^k\in\mathbb{N}_0$ to model the number of cells in the phenotypic state $y_j$ at position $x_i$ at time $t_k$. The cell population density and the corresponding cell density are defined, respectively, as follows
\begin{equation}
n_{i,j}^{k} \equiv n(t_k,x_i,y_j) := \frac{N_{i,j}^{k}}{\chi\eta} \quad \text{and} \quad \rho_{i}^{k} \equiv \rho(t_k,x_i) := \eta \sum_{j} n_{i,j}^{k}.\label{eq:density_define}
\end{equation}
We further define the pressure experienced by the cells (\emph{i.e.} the cell pressure) as a function of the cell density through the following barotropic relation
\begin{equation}
p_i^k \equiv p(t_k,x_i) = \Pi(\rho_{i}^{k}),\label{eq:pressure_define}
\end{equation}
where the function $\Pi$ satisfies the following assumptions~\cite{byrne2009individual,perthame2014hele,tang2014composite}
\begin{equation}
\Pi(0)=0,\quad \frac{\mathrm{d}}{\mathrm{d}\rho} \Pi(\rho) \geq 0 \; \text{ for }\; \rho \in \mathbb{R}^+_*.
\label{pressure_cond}
\end{equation}
As summarised by the schematics in Figure~\ref{fig:diagram}, between time-steps $k$ and $k+1$, each cell in phenotypic state $y_j \in (0,Y)$ at position $x_i \in \mathbb{R}$ can first move, next undergo phenotypic changes and then die or divide according to the rules described in the following subsections.
\begin{figure}[tbhp]
\centering\includegraphics[width=\textwidth]{Diagrams.pdf}
\caption{Schematics summarising the rules that govern the spatial evolutionary dynamics of single cells in the IB model. Between time-steps $k$ and $k+1$, each cell in phenotypic state $y_j \in (0,Y)$ at position $x_i \in \mathbb{R}$ may: \textbf{a.} move to either of the positions $x_{i-1}$ and $x_{i+1}$ with probabilities $\euscr{P}^k_{L_{i,j}}$ and $\euscr{P}^k_{R_{i,j}}$ defined via~\eqref{Prob_mov_left}~and~\eqref{Prob_mov_right}; \textbf{b.} undergo a phenotypic change and thus enter into either of the phenotypic states $y_{j-1}$ and $y_{j+1}$ with probabilities $\lambda/2$; \textbf{c.} die or divide with probabilities $\euscr{P}^k_{D_{i,j}}$ and $\euscr{P}^k_{B_{i,j}}$ defined via~\eqref{Prob_death}~and~\eqref{Prob_birth}.}\label{fig:diagram}
\end{figure}
\subsection{Mathematical modelling of cell death and division}
We assume that a dividing cell is replaced by two identical cells that inherit the phenotypic state of the parent cell (\emph{i.e.} the progenies are placed on the same lattice site as their parent), while a dying cell is removed from the population.
We model pressure-dependent proliferation by letting the cells divide, die or remain quiescent with probabilities that depend on their phenotypic states and the pressure that they experience. In particular, to define the probabilities of cell division and death, we introduce the function $R(y_j, p_i^k)$, which describes the net growth rate of the cell population density at position $x_i$ at time $t_k$, and assume that between time-steps $k$ and $k+1$ a cell in phenotypic state $y_j$ at position $x_i$ may die with probability
\begin{equation}
\euscr{P}_{D_{i,j}}^{k} := \tau R(y_j,p^{k}_{i})_- \; \text{ where } \; R(y_j,p^{k}_{i})_- = -\min\left(0,R(y_j,p^{k}_{i})\right),
\label{Prob_death}
\end{equation}
divide with probability
\begin{equation}
\euscr{P}_{B_{i,j}}^{k} := \tau R(y_j,p^{k}_{i})_+ \; \text{ where } \; R(y_j,p^{k}_{i})_+ = \max\left(0,R(y_j,p^{k}_{i})\right)
\label{Prob_birth}
\end{equation}
or remain quiescent (\emph{i.e.} do not divide nor die) with probability
\begin{equation}
\euscr{P}_{Q_{i,j}}^{k} := 1-\euscr{P}_{B_{i,j}}^{k}-\euscr{P}_{D_{i,j}}^{k}.
\label{Prob_quiescent}
\end{equation}
Note that we are implicitly assuming the time-step $\tau$ to be sufficiently small that $0 < \euscr{P}_{B_{i,j}}^{k} + \euscr{P}_{D_{i,j}}^{k} < 1$ for all values of $i$, $j$ and $k$.
In order to capture the fact that, as mentioned earlier, larger values of $y_j$ correlate with a lower cell proliferation rate, along with the fact that cells will stop dividing if the pressure at their current position becomes larger than the homeostatic pressure, which we model by means of the parameter $p_M>0$, we make the following assumptions
\begin{equation}
\label{ass:R}
R(Y,0) = 0, \; R(0,p_M) = 0, \; \partial_p R(y,p) < 0 \; \text{ and } \; \partial_y R(y,p) < 0 \; \text{ for } (y,p) \in (0,Y) \times \mathbb{R}^+.
\end{equation}
In particular, we will focus on the case where
\begin{equation}
\label{def:R}
R(y,p) := r(y) - \dfrac{p}{p_M} \; \text{ with } \; r(Y)=0, \;\; r(0)=1, \;\; \frac{\mathrm{d}}{\mathrm{d} y}r(y)<0 \; \text{for} \; y \in (0,Y).
\end{equation}
\begin{remark}
Under assumptions~\eqref{ass:R}, definitions~\eqref{Prob_birth}-\eqref{Prob_quiescent} ensure that if $p^{k}_{i} \geq p_M$ then every cell at position $x_i$ can only die or remain quiescent between time-steps $k$ and $k+1$. Hence, in the remainder of the paper we will let the following condition hold
\begin{equation}
\label{ass:p0IB}
\max_{i\in\mathbb{Z}} p_i^0 \leq p_M
\end{equation}
so that
\begin{equation}
p^{k}_{i}\le p_M \; \text{ for all } \; (k,i) \in \mathbb{N}_0 \times \mathbb{Z}. \label{bar_p}
\end{equation}
\end{remark}
\subsection{Mathematical modelling of phenotypic changes}
\label{phenotype_switch}
We take into account heritable phenotypic changes by allowing cells to update their phenotypic states according to a random walk along the phenotypic dimension. More precisely, between time-steps $k$ and $k+1$, every cell either enters a new phenotypic state, with probability $\lambda \in [0,1]$, or remains in its current phenotypic state, with probability $1-\lambda$. Since, as mentioned earlier, we consider only spontaneous phenotypic changes that occur randomly due to non-genetic instability, we assume that a cell in phenotypic state $y_j$ that undergoes a phenotypic change enters into either of the phenotypic states $y_{j\pm1} = y_{j} \pm \eta$ with probabilities $\lambda/2$. No-flux boundary conditions are implemented by aborting any attempted phenotypic variation of a cell if it requires moving into a phenotypic state outside the interval $[0,Y]$.
\subsection{Mathematical modelling of cell movement}
We model directional cell movement in response to pressure differentials as a biased random walk along the spatial dimension, whereby the movement probabilities depend on the difference between the pressure at the position occupied by a cell and the pressure at the neighbouring positions. As mentioned earlier, we consider the case where larger values of $y_j$ correlate with a higher cell migration rate. Hence, we modulate the probabilities of cell movement by the function $\mu(y_j)$, which provides a measure of the mobility of cells in phenotypic state $y_j$ and thus satisfies the following assumptions
\begin{equation}
\mu(0)>0, \quad \frac{\mathrm{d}}{\mathrm{d}y}\mu(y)>0 \; \text{ for } \; y \in (0,Y].
\label{mu_cond}
\end{equation}
Then we assume that between time-steps $k$ and $k+1$ a cell in phenotypic state $y_j$ at position $x_i$ may move to the position $x_{i-1} = x_i - \chi$ (\emph{i.e.} move left) with probability
\begin{equation}
\euscr{P}_{L_{i,j}}^{k}=\nu \mu(y_j)\frac{\left(p^{k}_{i}-p^{k}_{i-1}\right)_+}{2 p_M} \; \text{ where } \; \left(p^{k}_{i}-p^{k}_{i-1}\right)_+ =\max\left(0,p^{k}_{i}-p^{k}_{i-1}\right),
\label{Prob_mov_left}
\end{equation}
move to the position $x_{i+1} = x_i + \chi$ (\emph{i.e.} move right) with probability
\begin{equation}
\euscr{P}_{R_{i,j}}^{k}=\nu \mu(y_j)\frac{\left(p^{k}_{i}-p^{k}_{i+1}\right)_+}{2 p_M} \; \text{ where } \; \left(p^{k}_{i}-p^{k}_{i+1}\right)_+ =\max\left(0,p^{k}_{i}-p^{k}_{i+1}\right)
\label{Prob_mov_right}
\end{equation}
or remain stationary (\emph{i.e.} do not move left nor right) with probability
\begin{equation}
\euscr{P}_{S_{i,j}}^{k}=1-\euscr{P}_{L_{i,j}}^{k}-\euscr{P}_{R_{i,j}}^{k}.
\label{Prob_mov_stay}
\end{equation}
Here, the parameter $\nu>0$ is a scaling factor, which we implicitly assume to be sufficiently small that $0 < \nu \, \mu(y_j) < 1$ for all $y_j \in [0,Y]$. Under condition~\eqref{ass:p0IB}, this assumption on $\nu$ along with the a priori estimate~\eqref{bar_p} implies that definitions~\eqref{Prob_mov_left} and~\eqref{Prob_mov_right} are such that $0 < \euscr{P}_{L_{i,j}}^{k} + \euscr{P}_{R_{i,j}}^{k} < 1$ for all values of $i$, $j$ and $k$.
\begin{remark}
Definitions~\eqref{Prob_mov_left} and~\eqref{Prob_mov_right} ensure that cells will move down pressure gradients so as to reach regions where they feel less compressed.
\end{remark}
\section{The corresponding continuum model}
\label{sec:formal}
Through a method analogous to those that we previously employed in~\cite{ardavseva2020comparative,bubba2020discrete,chaplain2020bridging,macfarlane2020hybrid,stace2020discrete}, letting the time-step $\tau\rightarrow 0$, the space-step $\chi\rightarrow 0$ and the phenotype-step $\eta\rightarrow0$ in such a way that
\begin{equation}
\frac{\nu\chi^2 }{2\tau}\rightarrow \alpha \in \mathbb{R}^+_* \quad \text{and} \quad \frac{\lambda \eta^2}{2\tau}\rightarrow \beta \in \mathbb{R}^+_*,
\label{derived_parameters}
\end{equation}
one can formally show (see Appendix~\ref{app:derivation}) that the deterministic continuum counterpart of the stochastic discrete model presented in Section~\ref{sec:model} is given by the following non-local PDE for the cell population density function $n(t,x,y)$
\begin{equation}
\begin{cases}
\displaystyle{ \, \partial_t n - \alpha \, \hat{\mu}(y) \, \partial_x \left(n \, \partial_x p \right) = R(y,p) \, n + \beta \, \partial^2_{yy} n, \quad (x,y) \in \mathbb{R} \times (0,Y)}
\\\\
\displaystyle{p=\Pi(\rho), \quad \rho:=\int_{0}^{Y} n(t,x,y) \ \mathrm{d} y,}
\end{cases}
\label{derived_PDE}
\end{equation}
where $\hat{\mu}(y) := \dfrac{\mu(y)}{p_M}$. The non-local PDE~\eqref{derived_PDE} is subject to zero Neumann (\emph{i.e.} no-flux) boundary conditions at $y=0$ and $y=Y$, as well as to an initial condition such that the continuum analogue of condition~\eqref{ass:p0IB} holds, that is,
\begin{equation}
\label{ass:p0PDE}
\max_{x \in \mathbb{R}} p(0,x) \leq p_M.
\end{equation}
The mathematical model defined by complementing~\eqref{derived_PDE} with assumptions~\eqref{pressure_cond}, \eqref{ass:R} and~\eqref{mu_cond} generalises earlier models of pressure-dependent cell population growth~\cite{byrne2009individual,drasdo2012modeling,perthame2014hele} to the case of phenotypically heterogeneous cell populations.
\section{Main results}
\label{sec:numerics}
In this section, we first present the result of formal travelling-wave analysis of the PDE model (Subsection~\ref{Sec4}) and then integrate these results with numerical simulations of the IB model and numerical solutions of the PDE model (Subsection~\ref{Sec:numres}).
\subsection{Formal travelling-wave analysis}
\label{Sec4}
We focus on a biological scenario in which cell movement occurs on a slower timescale compared to cell division and death, while spontaneous, heritable phenotypic changes occur on a
slower timescale compared to cell movement~\cite{huang2013genetic,smith2004measurement}. To this end, we introduce a small parameter $\varepsilon >0$ and let
\begin{equation}
\label{eq:abeps}
\alpha := \varepsilon, \quad \beta := \varepsilon^2.
\end{equation}
Moreover, in order to explore the long-time behaviour of the cell population (\emph{i.e.} the behaviour of the population over many cell generations), we use the time scaling $t \to \frac{t}{\varepsilon}$ in~\eqref{derived_PDE}. Taken together, this gives the following non-local PDE for the cell population density function $n_{\varepsilon}(t,x,y) = n(\frac{t}{\varepsilon},x,y)$
\begin{equation}
\begin{cases}
\displaystyle{\varepsilon \, \partial_t n_{\varepsilon} - \varepsilon \, \hat{\mu}(y) \, \partial_x \left(n_{\varepsilon} \, \partial_x p_{\varepsilon} \right) = R(y,p_{\varepsilon}) \, n_{\varepsilon} + \varepsilon^2 \, \partial^2_{yy} n_{\varepsilon}, \quad (x,y) \in \mathbb{R} \times (0,Y)}
\\\\
\displaystyle{p_{\varepsilon}=\Pi(\rho_{\varepsilon}), \quad \rho_{\varepsilon}:=\int_{0}^{Y} n_{\varepsilon}(t,x,y) \ \mathrm{d} y.}
\end{cases}
\label{eq:PDEnen}
\end{equation}
Using a method analogous to those that we have previously employed in~\cite{lorenzi2021,lorenzi2022trade}, denoting by $\delta_{(\cdot)}(y)$ the Dirac delta centred at $y=(\cdot)$, one can formally show (see Appendix~\ref{TWanalysis}) that, under assumptions~\eqref{pressure_cond}, \eqref{def:R} and~\eqref{mu_cond}, as $\varepsilon \to 0$, the non-local PDE~\eqref{eq:PDEnen} admits travelling-wave solutions of the form
$$
n_{\varepsilon}(z,y) \approx \rho(z) \, \delta_{\bar{y}(z)}(y), \quad z = x - c \, t, \quad c \in \mathbb{R}^+_*,
$$
where $\bar{y}(z)$ is the unique maximum point of the solution to the following equation
$$
- \left(c + \hat{\mu}(y) p' \right) \partial_z u = \left(r(y) - \dfrac{p}{p_M} \right) + (\partial_y u)^2, \quad u \equiv u(z,y), \quad(z,y) \in \mathbb{R} \times (0,Y)
$$
and the cell density $\rho(z)$ is such that the pressure $p(z) = \Pi(\rho(z))$ satisfies the following relation
\begin{equation}
\label{eq:expptwpap}
p(z) = p_M \, r\left(\bar{y}(z)\right) \quad z \in \supp(p),
\end{equation}
provided that the wave speed $c$ satisfies the following necessary condition
\begin{equation}
\label{eq:cminex}
c \geq \sup_{z \in {\rm Supp}(r(\bar{y}))} 2 \ \left|\dfrac{{\rm d} }{{\rm d} y} r(\bar{y}(z))\right| \sqrt{\dfrac{\mu(\bar{y}(z))}{\left|\partial^2_{yy} u(z,\bar{y}(z))\right|}}.
\end{equation}
Moreover,
\begin{equation}
\label{eq:TWpsuppap}
\supp(p) = (-\infty, \ell) \; \text{ with } \; \ell \in \mathbb{R} \; \text{ such that } \; \bar{y}(\ell) = Y
\end{equation}
and
\begin{equation}
\label{eq:TWmonbarypap}
\lim_{z \to - \infty} \bar{y}(z) =0, \quad \lim_{z \to - \infty} p(z) =p_M, \quad \bar{y}'(z) > 0 \; \text{ and } \; \bar{p}'(z) < 0 \quad z \in (-\infty, \ell).
\end{equation}
From a biological point of view, $\bar{y}(z)$ represents the dominant phenotype of cells at a certain position along the invading wave $p(z)$. Since larger values of $y$ correlate with a lower proliferation rate and a higher migration rate, the fact that $\bar{y}(z)$ increases monotonically from $0$ to $Y$ while $p(z)$ decreases monotonically from $p_M$ to $0$ (cf. the results given by~\eqref{eq:TWpsuppap} and~\eqref{eq:TWmonbarypap}) provides a mathematical formalisation of the idea that spatial sorting causes cells with a more mobile/less proliferative phenotype to become concentrated towards the front of the invading wave, which is thus a sparsely populated region, whereas phenotypic selection leads cells with a less mobile/more proliferative phenotype to dominate at the rear, which is then a densely populated region.
\subsection{Numerical simulations}
\label{Sec:numres}
\subsubsection{Set-up of numerical simulations}
In order to carry out numerical simulations, we consider the time interval $[0,T]$, with $T=8$, we restrict the physical domain to the closed interval $[0, X]$, with $X=25$, and choose $Y=1$. In order to facilitate the integration between numerical simulations and the results of formal travelling-wave analysis presented in Subsection~\ref{Sec4}, we solve numerically the rescaled PDE model~\eqref{eq:PDEnen}, with $\varepsilon = 0.01$, and we carry out numerical simulations of the scaled IB model obtained by introducing the time scaling $t_k \to \dfrac{t_k}{\varepsilon} = k \dfrac{\tau}{\varepsilon}$ and reformulating the governing rules of cell dynamics that are detailed in Section~\ref{sec:model} in terms of
$$
p_{\varepsilon i}^k \equiv p_{\varepsilon}(t_k,x_i) = p\left(\frac{t_k}{\varepsilon},x_i\right) = \Pi(\rho_{\varepsilon i}^{k}),
$$
with
$$
\rho_{\varepsilon i}^{k} \equiv \rho_{\varepsilon}(t_k,x_i) = \rho\left(\frac{t_k}{\varepsilon},x_i\right) := \eta \sum_{j} n_{\varepsilon i,j}^{k} \quad \text{and} \quad n_{\varepsilon i,j}^{k} \equiv n_{\varepsilon}\left(t_k, x_i, y_j \right) = n\left(\frac{t_k}{\varepsilon}, x_i, y_j \right) := \frac{N_{\varepsilon i,j}^{k}}{\chi\eta}.
$$
Moreover, we choose $\tau = 5\times10^{-5}$, $\chi=0.01$ and $\eta=0.02$, and then set $\nu = \dfrac{2 \tau}{\chi^2} \varepsilon$ and $\lambda = \dfrac{2 \tau}{\eta^2} \varepsilon^2$ in order to ensure that conditions~\eqref{derived_parameters} and~\eqref{eq:abeps} are simultaneously satisfied.
We consider a biological scenario in which, initially, the cell population is localised along the $x=0$ boundary and most of the cells are in the phenotypic state $y=\bar{y}^0$ at every position. Specifically, we implement the following initial cell distribution for the IB model
\begin{equation}
\label{def:icIB}
N_{\varepsilon i,j}^0=\text{int}(F_{\varepsilon}(x_i,y_j)) \; \text{ with } \; F_{\varepsilon}(x,y)= A_0 \ C\ e^{-x^2} \ e^{-\frac{\left(y-\bar{y}^0\right)^2}{\varepsilon}},
\end{equation}
where $\text{int}(\cdot)$ is the integer part of $(\cdot)$ and $C$ is a normalisation constant such that
$$
C\int_0^Y e^{-\frac{\left(y-\bar{y}^0\right)^2}{\varepsilon}} \ \mathrm{d}y=1.
$$
Unless otherwise specified, we choose $A_0=10$ and $\bar{y}^0=0.2$. The initial cell density and pressure are then calculated via~\eqref{eq:density_define} and~\eqref{eq:pressure_define}. The initial cell population density function $n_\varepsilon(0,x,y) = n^0_\varepsilon(x,y)$, is defined as a suitable continuum analogue of the cell population density $n_{\varepsilon i,j}^{0} := \frac{N_{\varepsilon i,j}^{0}}{\chi\eta}$, with $N_{\varepsilon i,j}^{0}$ given by~\eqref{def:icIB}. Specifically, we set
$$
n^0_\varepsilon(x,y) := \left(\frac{F_{\varepsilon}(x,y)}{\chi \eta} - \dfrac{1.5}{\chi \eta}\right)_+,
$$
where $F_{\varepsilon}(x,y)$ is defined via~\eqref{def:icIB} and $(\cdot)_{+}$ is the positive part of $(\cdot)$.
We define $R(y,p_{\varepsilon})$ via~\eqref{def:R} and, having chosen $Y=1$, we further define
$$
r(y) :=1-y^2 \quad \text{and} \quad \mu(y) := 0.01 + y^2
$$
so as to ensure that assumptions~\eqref{ass:R} and~\eqref{mu_cond} are satisfied. Moreover, we investigate the following three definitions of the barotropic relation for the cell pressure, all satisfying assumptions~\eqref{pressure_cond}:
\begin{equation}
p_{\varepsilon} = \Pi(\rho_{\varepsilon}) :=
\begin{cases}
\quad \rho_{\varepsilon} & \text{(Case 1)}\\
&\\
\quad K_{\gamma} \left(\rho_{\varepsilon}\right)^\gamma \quad\quad\; \text{with} \quad K_{\gamma}>0, \ \gamma>1 & \text{(Case 2)}\\
&\\
\quad \kappa \left(\rho_{\varepsilon}-\rho^*\right)_+ \quad \text{with} \quad \kappa,\ \rho^*> 0 & \text{(Case 3)}.
\label{Pressure_all}
\end{cases}
\end{equation}
The definition given by Case 1 corresponds to the simplified scenario in which the cell pressure is a linear function of the cell density. In the definition given by Case 2, which was proposed in~\cite{perthame2014hele}, the parameter $K_{\gamma}$ is a scaling factor and the parameter $\gamma$ provides a measure of the stiffness of the barotropic relation (\emph{i.e.} the limit $\gamma\rightarrow \infty$ corresponds to the scenario in which cells behave like an incompressible fluid). In the definition given by Case 3, which is such that the cell pressure is zero for $\rho \leq \rho^*$ and is a monotonically increasing function of the cell density for $\rho > \rho^*$, the parameter $\kappa$ is a scaling factor and $\rho^*$ is the density below which the force that the cells exert upon one another is negligible~\cite{drasdo2012modeling,tang2014composite}. Unless otherwise specified: when the cell pressure is defined via Case 1 we choose $p_M= 4.95\times10^4$; when the cell pressure is defined via Case 2 we choose $p_M = 3.675\times10^9$, $\gamma=2$ and $K_{\gamma} = \frac{3}{2}$; when the cell pressure is defined via Case 3 we choose $p_M = 4.94\times10^5$, $\kappa=10$ and $\rho^*= 10^2$.
\begin{remark}
The initial conditions and the values of $p_M$ that are considered here are such that conditions~\eqref{ass:p0IB} and~\eqref{ass:p0PDE} are satisfied.
\end{remark}
\subsubsection{Computational implementation of the IB model}
All simulations are performed in {\sc Matlab}. At each time-step, each cell undergoes a three-phase process: (i) cell movement, according to the probabilities defined via~\eqref{Prob_mov_left}-\eqref{Prob_mov_stay}; (ii) phenotypic changes, with probabilities $\lambda/2$; (iii) division and death, according to the probabilities defined via~\eqref{Prob_birth}-\eqref{Prob_quiescent}. For each cell, during each phase, a random number is drawn from the standard uniform distribution on the interval $(0,1)$ using the built-in {\sc Matlab} function {\sc rand}. It is then evaluated whether this number is lower than the probability of the event occurring and if so the event occurs. Since $x_i \in [0,X]$, the attempted movement of a cell is aborted if it requires moving out of the spatial domain.
\subsubsection{Methods used to solve numerically the non-local PDE~\eqref{eq:PDEnen}}
Full details of the methods used to solve numerically the non-local PDE~\eqref{eq:PDEnen} posed on $(0,T] \times (0,X) \times (0,Y)$ and subject to suitable initial and boundary conditions are given in Appendix~\ref{appendix_PDE}.
\newpage
\subsubsection{Results of numerical simulations}
\paragraph{Formation of complex spatial patterns of population growth.} The plots in the top lines of Figures~\ref{fig:test_P1}-\ref{fig:test_P3} summarise the results of numerical simulations of the IB model for the barotropic relations given by Cases 1-3 in~\eqref{Pressure_all}. We plot in the left panels the scaled cell population density, $n_{\varepsilon}/\rho_{\varepsilon}$, and in the right panels (solid blue lines) the scaled cell pressure, $p_{\varepsilon}/p_M$, at progressive times.
The results of numerical simulations under all three cases display very similar dynamics, both with respect to the cell population density and the cell pressure, where we observe evolution to travelling-wave profiles of almost identical shapes and speeds. The incorporation of proliferation-migration tradeoffs lead cells to be non-uniformly distributed across both physical and phenotype space. More precisely, we observe a relatively small subpopulation of highly-mobile but minimally-proliferative cells (\emph{i.e.} cells in phenotypic states $y\approx Y$) that becomes concentrated towards the front of the invading wave, while rapidly-proliferating but minimally-mobile cells (\emph{i.e.} cells in phenotypic states $y\approx 0$) make up the bulk of the population in the rear. This is due to a dynamic interplay between spatial sorting and phenotypic selection: efficient response to pressure differentials by more-mobile cells leads to their positioning at the front of the wave, where the pressure is lower, before being overcome by the more-proliferative cells encroaching from the rear of the wave, which are ultimately selected due to their higher proliferative potential.
\paragraph{Quantitative agreement between the IB model and its PDE counterpart.} The plots in the bottom lines of Figures~\ref{fig:test_P1}-\ref{fig:test_P3} summarise the corresponding numerical solutions of the PDE model~\eqref{eq:PDEnen}. Comparing these plots with those in the top lines, we can see that there is an excellent quantitative agreement between the results of numerical simulations of the IB model and the numerical solutions of its PDE counterpart, both with respect to the cell population density and the cell pressure, for each of the barotropic relations given by Cases 1-3 in~\eqref{Pressure_all}.
All these plots indicate that, when $\varepsilon$ is sufficiently small, the scaled cell population density $n_\varepsilon/\rho_\varepsilon$ is concentrated as a sharp Gaussian with maximum at a single point $\bar{y}_{\varepsilon}(t,x)$ for all $x \in \supp(p_{\varepsilon})$. The maximum point $\bar{y}_{\varepsilon}(t,x)$ corresponds to the dominant phenotype within the cell population at position $x$ and time $t$. In agreement with the results presented in Subsection~\ref{Sec4} (cf. the results given by~\eqref{eq:TWpsuppap} and~\eqref{eq:TWmonbarypap}), the cell pressure $p_{\varepsilon}$ behaves like a one-sided compactly supported and monotonically decreasing travelling front that connects $p_M$ to $0$, while the dominant phenotype $\bar{y}_{\varepsilon}$ increases monotonically from $y=0$ to $y=Y$ across the support of the invading wave. Moreover, we find an excellent quantitative agreement between $p_{\varepsilon}(t,x)/p_M$ and $r(\bar{y}_{\varepsilon}(t,x))$ (cf. the solid blue and dashed cyan lines in the right panels of Figures~\ref{fig:test_P1}-\ref{fig:test_P3}). This indicates that, when $\varepsilon$ is sufficiently small, relation~\eqref{eq:expptwpap} is satisfied as well.
In order to measure the speed of these travelling waves, we track the dynamics of the points $x_{\varepsilon 1}(t)$, $x_{\varepsilon 2}(t)$ and $x_{\varepsilon 3}(t)$ such that
\begin{equation}
\label{def:xeps}
p_{\varepsilon}(t, x_{\varepsilon 1}(t)) = 0.2 p_M, \quad p_{\varepsilon}(t, x_{\varepsilon 2}(t)) = 0.5 p_M, \quad p_{\varepsilon}(t, x_{\varepsilon 3}(t)) = 0.8 p_M.
\end{equation}
Notably, we observe the evolution of $x_{\varepsilon 1}(t)$, $x_{\varepsilon 2}(t)$ and $x_{\varepsilon 3}(t)$ towards straight lines of approximatively the same slope $\approx 2.5$ (see the insets of the right panels in Figures~\ref{fig:test_P1}-\ref{fig:test_P3}). Moreover, an equivalent tracking of $\tilde{x}_{\varepsilon 1}(t)$, $\tilde{x}_{\varepsilon 2}(t)$ and $\tilde{x}_{\varepsilon 3}(t)$ such that $\bar{y}_{\varepsilon}(t, \tilde{x}_{\varepsilon 1}(t)) = 0.2$, $\bar{y}_{\varepsilon}(t, \tilde{x}_{\varepsilon 2}(t)) = 0.5$ and $\bar{y}_{\varepsilon}(t, \tilde{x}_{\varepsilon 3}(t)) = 0.8$, with
\begin{equation}
\label{def:yeps}
\bar{y}_\varepsilon(t,x) := \argmax_{y\in[0,Y]} n_\varepsilon(t,x,y),
\end{equation}
yields quasi-identical results (results not shown). This supports the idea that $p_{\varepsilon}$ behaves like a travelling front of speed $c \approx 2.5$. Such a value of the speed is coherent with the condition on the minimal wave speed given by~\eqref{eq:cminex}. In fact, inserting into~\eqref{eq:cminex} the numerical values of $\bar{y}_{\varepsilon}(8,x)$ in place of $\bar{y}(z)$ and the numerical values of $\partial^2_{yy} u_{\varepsilon}(8,x,\bar{y}_{\varepsilon}(8,x))$ with $u_{\varepsilon} = \varepsilon \log(n_{\varepsilon})$ in place of $\partial^2_{yy} u(z,\bar{y}(z))$ gives $c \gtrapprox 2.5$.
\begin{remark}
\label{rem:robu}
The robustness of the results of numerical simulations of the IB model presented so far is supported by the fact that there is an excellent quantitative agreement between them and the results of numerical simulations and formal travelling-wave analysis of the corresponding PDE model. In fact, in the light of this agreement, independently of the specific definitions of the model functions $\Pi$, $R$ and $\mu$, provided that assumptions~\eqref{pressure_cond}, \eqref{ass:R} and~\eqref{mu_cond} are satisfied, and sufficiently large cell numbers are considered, in the asymptotic regime $\varepsilon \to 0$, one can expect the rules governing the spatial evolutionary dynamics of single cells considered here to bring about patterns of population growth that will ultimately be qualitatively similar to those of Figures~\ref{fig:test_P1}-\ref{fig:test_P3}.
\end{remark}
\begin{figure}[tbhp]
\centering
\bf{Case 1}\\
\vspace{1em}
\includegraphics[height=0.5\textwidth]{Case1_Collected.pdf}
\caption{Numerical simulation results of the IB model (top row) and the PDE model~\eqref{eq:PDEnen} (bottom row) in the case where the cell pressure is defined through the barotropic relation given by Case 1 in \eqref{Pressure_all}. Plots display the scaled cell population density $n_\varepsilon/\rho_\varepsilon$ (left panels) and the scaled cell pressure $p_\varepsilon/ p_M$ (right panels, solid blue lines) at three successive time instants (\emph{i.e.} $t = 4$, $t = 6$ and $t = 8$) for both modelling approaches. The dashed cyan lines in the right panels highlight the corresponding values of $r(\bar{y}_\varepsilon)$, with $\bar{y}_\varepsilon$ defined via~\eqref{def:yeps}. The insets of the right panels display the plots of $x_{\varepsilon 1}(t)$ (blue squares), $x_{\varepsilon 2}(t)$ (red diamonds) and $x_{\varepsilon 3}(t)$ (black stars) defined via~\eqref{def:xeps}. The results from the IB model were obtained by averaging over 10 simulations..}
\label{fig:test_P1}
\end{figure}
\begin{figure}[tbhp]
\centering
\bf{Case 2}\\
\vspace{1em}
\includegraphics[height=0.5\textwidth]{Case2_Collected.pdf}
\caption{Numerical simulation results of the IB model (top row) and the PDE model~\eqref{eq:PDEnen} (bottom row) in the case where the cell pressure is defined through the barotropic relation given by Case 2 in \eqref{Pressure_all}. Plots display the scaled cell population density $n_\varepsilon/\rho_\varepsilon$ (left panels) and the scaled cell pressure $p_\varepsilon/ p_M$ (right panels, solid blue lines) at three successive time instants (\emph{i.e.} $t = 4$, $t = 6$ and $t = 8$) for both modelling approaches. The dashed cyan lines in the right panels highlight the corresponding values of $r(\bar{y}_\varepsilon)$, with $\bar{y}_\varepsilon$ defined via~\eqref{def:yeps}. The insets of the right-hand panels display the plots of $x_{\varepsilon 1}(t)$ (blue squares), $x_{\varepsilon 2}(t)$ (red diamonds) and $x_{\varepsilon 3}(t)$ (black stars) defined via~\eqref{def:xeps}. The results from the IB model were obtained by averaging over 10 simulations.}
\label{fig:test_P2}
\end{figure}
\begin{figure}[tbhp]
\centering
\bf{Case 3}\\
\vspace{1em}
\includegraphics[height=0.5\textwidth]{Case3_Collected.pdf}
\caption{Numerical simulation results of the IB model (top row) and the PDE model~\eqref{eq:PDEnen} (bottom row) in the case where the cell pressure is defined through the barotropic relation given by Case 3 in \eqref{Pressure_all}. Plots display the scaled cell population density $n_\varepsilon/\rho_\varepsilon$ (left panels) and the scaled cell pressure $p_\varepsilon/ p_M$ (right panels, solid blue lines) at three successive time instants (\emph{i.e.} $t = 4$, $t = 6$ and $t = 8$) for both modelling approaches. The dashed cyan lines in the right panels highlight the corresponding values of $r(\bar{y}_\varepsilon)$, with $\bar{y}_\varepsilon$ defined via~\eqref{def:yeps}. The insets of the right-hand panels display the plots of $x_{\varepsilon 1}(t)$ (blue squares), $x_{\varepsilon 2}(t)$ (red diamonds) and $x_{\varepsilon 3}(t)$ (black stars) defined via~\eqref{def:xeps}. The results from the IB model were obtained by averaging over 10 simulations.}
\label{fig:test_P3}
\end{figure}
\paragraph{Possible discrepancies between the IB model and its PDE counterpart.} In the cases discussed so far, we have observed excellent quantitative agreement between the results of numerical simulations of the IB model and numerical solutions of the corresponding PDE model. However, we hypothesise that possible differences between the two models can emerge when cell dynamics are strongly impacted by demographic stochasticity, which cannot be captured by the PDE model.
In general, we expect demographic stochasticity to have a stronger impact on cell dynamics in the presence of smaller values of the homeostatic pressure $p_M$, since smaller values of $p_M$ correlate with smaller cell numbers. Moreover, in the case where cells are initially distributed across both physical and phenotype space according to~\eqref{def:icIB}, we expect demographic stochasticity to escalate during the early stages of cell dynamics if sufficiently small values of the parameter $A_0$ and sufficiently large values of the parameter $\bar{y}^0$ (\emph{i.e.} values of $\bar{y}^0$ sufficiently far from $0$ and sufficiently close to $Y$) are considered. In fact, smaller values of $A_0$ correlate with lower initial cell numbers. Moreover, since cells in phenotypic states $y\approx 0$ will ultimately be selected in the rear of the invading wave (cf. the plots in the left panels of Figures~\ref{fig:test_P1}-\ref{fig:test_P3}), bottleneck effects leading to a temporary drastic reduction in the size of the cell population may occur if $\bar{y}^0$ is sufficiently far from $0$.
Hence, to test the aforementioned hypothesis, we carry out numerical simulations of the two models for decreasing values of $A_0$ and increasing values of $\bar{y}^0$ in the initial cell distribution~\eqref{def:icIB}. Furthermore, we define the cell pressure through the barotropic relation given by Case 1 in \eqref{Pressure_all} and set $\displaystyle{p_M := \max_{x \in [0,X]} \Pi\left(\rho_{\varepsilon}(0,x)\right)}$, so that smaller values of $A_0$ correspond to smaller value of $p_M$ as well.
The results obtained for the IB model are summarised by the plots in Figure~\ref{fig:test_P4a}, which display typical dynamics of the scaled cell pressure $p_{\varepsilon}/p_M$, while the corresponding results for the PDE model~\eqref{eq:PDEnen} are summarised by the plots in Figure~\ref{fig:test_P4b}. These results corroborate our hypothesis by demonstrating that the quantitative agreement between the IB model and its PDE counterpart deteriorates when smaller values of $A_0$ and larger values of $\bar{y}^0$ are considered. In line with our expectations, this is due to the fact that stronger stochastic effects associated with small population levels in the initial phase of cell dynamics create the substrate for population extinction to occur in some simulations of the IB model, which ultimately results in discrepancies between the average behaviour of numerical simulations of the IB model and numerical solutions of the PDE model. This is shown by the plots in Figures~\ref{fig:test_P5} and~\ref{fig:test_P6} which highlight how, all else being equal, there are simulations of the IB model in which, after a transient interval, a good quantitative agreement with numerical solutions of the PDE model~\eqref{eq:PDEnen} is recovered (cf. Figure~\ref{fig:test_P5}), but there are also simulations in which the cell population goes extinct rapidly (cf. Figure~\ref{fig:test_P6}).
\begin{figure}[tbhp]
\centering
\includegraphics[height=0.5\textwidth]{Figure_New_IB.pdf}
\caption{Numerical simulation results of the IB model for different values of the parameters $A_0$ and $\bar{y}^0$ in the initial cell distribution~\eqref{def:icIB} -- \emph{i.e.} $\bar{y}^0=0.2$ (left column) or $\bar{y}^0=0.8$ (right column) and $A_0=10$ (top row) or $A_0=1$ (central row) or $A_0=0.27$ (bottom row). The solid blue lines highlight the values of the scaled cell pressure $p_\varepsilon/ p_M$ at three successive time instants (\emph{i.e.} $t = 3$, $t = 5$ and $t = 7$). The dashed cyan lines highlight the corresponding values of $r(\bar{y}_\varepsilon)$, with $\bar{y}_\varepsilon$ defined via~\eqref{def:yeps}. These results were obtained by averaging over 10 simulations.}
\label{fig:test_P4a}
\end{figure}
\begin{figure}[tbhp]
\centering
\includegraphics[height=0.5\textwidth]{Figure_New_PDE.pdf}
\caption{Numerical simulation results of the PDE model~\eqref{eq:PDEnen} for different values of the parameters $A_0$ and $\bar{y}^0$ in the initial cell distribution~\eqref{def:icIB} -- \emph{i.e.} $\bar{y}^0=0.2$ (left column) or $\bar{y}^0=0.8$ (right column) and $A_0=10$ (top row) or $A_0=1$ (central row) or $A_0=0.27$ (bottom row). The solid blue lines highlight the values of the scaled cell pressure $p_\varepsilon/ p_M$ at three successive time instants (\emph{i.e.} $t = 3$, $t = 5$ and $t = 7$). The dashed cyan lines highlight the corresponding values of $r(\bar{y}_\varepsilon)$, with $\bar{y}_\varepsilon$ defined via~\eqref{def:yeps}.}
\label{fig:test_P4b}
\end{figure}
\begin{figure}[tbhp]
\centering
\includegraphics[height=0.5\textwidth]{Figure_NoExtinction.pdf}
\caption{Numerical simulation results of the IB model with $A_0=0.27$ and $\bar{y}^0=0.8$ in the initial cell distribution~\eqref{def:icIB}, for 1 out of the 10 simulations that are used to produce the average results displayed in the right-column, bottom-line panel of Figure~\ref{fig:test_P4a}. Plots display the scaled cell population density $n_\varepsilon/\rho_\varepsilon$ (top panels) and the scaled cell pressure $p_\varepsilon/ p_M$ (bottom panels, solid blue lines) at five successive time instants (\emph{i.e.} $t = 0$, $t = 1$, $t = 2$, $t = 3$ and $t = 4$). The dashed cyan lines in the bottom panels highlight the corresponding values of $r(\bar{y}_\varepsilon)$, with $\bar{y}_\varepsilon$ defined via~\eqref{def:yeps}. In this simulation, after a transient interval, a good quantitative agreement with numerical solutions of the PDE model is recovered.}
\label{fig:test_P5}
\end{figure}
\begin{figure}[tbhp]
\centering
\includegraphics[height=0.5\textwidth]{Figure_Extinction.pdf}
\caption{Numerical simulation results of the IB model with $A_0=0.27$ and $\bar{y}^0=0.8$ in the initial cell distribution~\eqref{def:icIB}, for 1 out of the 10 simulations that are used to produce the average results displayed in the right-column, bottom-line panel of Figure~\ref{fig:test_P4a}. Plots display the scaled cell population density $n_\varepsilon/\rho_\varepsilon$ (top panels) and the scaled cell pressure $p_\varepsilon/ p_M$ (bottom panels, solid blue lines) at five successive time instants (\emph{i.e.} $t = 0$, $t = 0.1$, $t = 0.2$, $t = 0.3$ and $t = 0.4$). The dashed cyan lines in the bottom panels highlight the corresponding values of $r(\bar{y}_\varepsilon)$, with $\bar{y}_\varepsilon$ defined via~\eqref{def:yeps}. In this simulation, the cell population goes extinct rapidly.}
\label{fig:test_P6}
\end{figure}
\newpage
\section{Conclusions and research perspectives}
\label{sec:conclusion}
We developed an IB model for the dynamics of phenotypically heterogeneous growing cell populations, which captures intercellular variability in cell proliferation and migration rates. We concentrated on a proliferation-migration tradeoff scenario, where the cell phenotypes span a spectrum of states from minimally-mobile but highly-proliferative to highly-mobile but minimally-proliferative. In the context of cancer invasion, such a tradeoff is the tenet of the ``go-or-grow'' hypothesis, which was conceived following observations of glioma cell behaviour~\cite{giese1996dichotomy} and has stimulated much empirical and theoretical research -- see, for instance, \cite{corcoran2003,gallaher2019impact,giese1996dichotomy,hatzikirou2012go,hoek2008vivo,pham2012density,stepien2018,vittadello2020,zhigun2018} and references therein.
We reported on the results of numerical simulations of the IB model which illustrate how proliferation-migration tradeoffs shaping the evolutionary dynamics of single cells can lead to the generation of travelling waves whereby phenotypes are structured across the support of the wave, with highly-mobile cells being found at the invasive front and more-proliferative cells dominating at the rear. Similar patterns of cell population growth have been observed in gliomas, where cells within the interior of the tumour exhibit higher proliferation and lower migration rates, while cells on the tumour border are instead characterised by lower proliferation and higher migration rates~\cite{dhruv2013reciprocal,giese2003cost,giese1996dichotomy,wang2012ephb2,xie2014targeting}.
We formally derived the deterministic continuum counterpart of the IB model, which comprises a non-local PDE for the cell population density function, and carried out a comparative study between numerical simulations of the IB model and both numerical solutions and formal travelling-wave analysis of the PDE model. We demonstrated that there is an excellent quantitative agreement between the results of numerical simulations of the IB model and the results of numerical simulations and travelling-wave analysis of the corresponding PDE model, when sufficiently large cell numbers are considered. This testifies to the robustness of the results of numerical simulations of the IB model presented here (see Remark~\ref{rem:robu}). We also provided numerical evidence of scenarios in which the predictions of the two models can differ due to demographic stochasticity, which cannot be captured by the PDE model. This indicates the importance of integrating individual-based and continuum approaches when modelling the growth of phenotypically heterogeneous cell populations.
Although in this work we focused on a one-dimensional spatial domain scenario, the IB model presented here, and the formal limiting procedure to derive the corresponding continuum model, could easily be adapted to higher spatial dimensions. Furthermore, while we represented the spatial domain of the IB model as a regular lattice, it would certainly be interesting to generalise the underlying modelling approach, as well as the formal method to derive the continuum counterpart of the model, to cases where cells are distributed over irregular lattices and also to cases where off-latice representations of the spatial domain are adopted. The present IB model could also be extended further to include the effects of chemical species (\emph{e.g.} nutrients, growth factors, chemoattractants, chemorepulsants) and how the cells interact with and respond to these chemicals.
The generality of our assumptions makes this IB modelling framework applicable to a broad range of biological processes that are driven by the growth of phenotypically heterogeneous cell populations, including tumour invasion and tissue remodelling and repair. It would thus be interesting to focus on particular cellular systems, and consequently define specific models, in order to dissect out the role played by different spatiotemporal evolutionary processes at the single-cell level in the formation of complex spatial patterns of cell population growth.
\section*{Acknowledgments}
T.L. gratefully acknowledges support from the MIUR grant ``Dipartimenti di Eccellenza 2018-2022'' (Project no. E11G18000350001). F.R.M. gratefully acknowledges support from the RSE Saltire Early Career Fellowship `Multiscale mathematical modelling of spatial eco-evolutionary cancer dynamics' (Fellowship No. 1879).
\section*{Conflict of interest}
The authors declare no competing interests.
{\small
|
{'timestamp': '2022-02-16T02:25:28', 'yymm': '2202', 'arxiv_id': '2202.06583', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06583'}
|
arxiv
|
\section{Introduction}
\label{sec:introduction}
This paper considers the capacity expansion problem in two-sided matchings,
where the policymaker is allowed to allocate some extra seats as well as the standard seats.
The two-sided matchings have a lot of real applications such as medical residency match \cite{roth:aer:1991} and school choice \cite{Abdulkadiroglu:aer:2003}.
The theory has been extensively developed across computer science and economics~\cite{Roth:CUP:1990,manlove:2013}.
To establish our model and concepts, we use medical residency match as a running example.
In this literature, each hospital (school) accepts a limited number of residents (students).
Such capacity constraints (or quotas) are assumed to be known and fixed in advance.
However, in practice, even for hospitals, or its stakeholders, it is often uncertain
how the capacity constraints are specified beforehand. Those could be flexible and variable
more than the previous studies preclude.
By pooling some extra funding, hospitals can accept a few more residents.
Schools may be granted some budgets or dispatched teachers from their district according to the demand.
A classical comparative statistic already analyzes the effect of such expansion.
If the capacity of some hospital is expanded, the welfare of every resident weakly improves~\cite
Roth:CUP:1990}. However, it is rarely investigated how capacities should be expanded to improve the total welfare.
\citeauthor{bobbio2021capacity}~\shortcite{bobbio2021capacity} have initiated the question of how limited extra seats should be allocated, keeping resulting matchings \textit{stable}. The stability is a key concept for the two-sided matching and if a matching is stable,
no groups of residents and hospitals have profitable deviations. The celebrated deferred acceptance (DA) algorithm is known to find a stable matching~\cite{galeshapley}.
The capacity expansion with DA, i.e., finding the optimal allocation of extra seats in the welfare of residents,
is formulated as an integer quadratic programming~\cite{bobbio2021capacity}, which is computationally challenging to solve exactly.
In addition to the exact method, they also developed some greedy heuristics, which runs very effectively yet is suboptimal.
\if0
\begin{table}[t!]
\begin{center}
\caption{Comparison of methods for the capasity expansion.
}
\label{tbl_demand}
\begin{tabular}{lcccc}
& Optimality & Anytime & Diversity \\ \hline
Greedy &
&
\checkmark
\\
Exact &
\checkmark
&
\\
Our Method &
\checkmark
&
\checkmark
&
\checkmark
\\
\hline
\end{tabular}
\end{center}
\end{table}
\fi
\if0
The following properties are desired in solving the capacity expansion problem.
\begin{enumerate}
\item Optimality (asymptotic): It can spend the computational time flexibly. If policymaker spends a sufficiently large computational budget, the method returns the optimal solution.
\item Anytimeness: Policymaker can stop the computation anytime to receive a current best solution. This is important given the hardness of obtaining the optimal solution.
\item Diversity: The method visits and can recommend many (if suboptimal) solutions among which the policymaker can choose. This is particularly important when there are some implicit constraints/preferences.
\end{enumerate}
\fi
This paper proposes
an alternative method to solve the capacity expansion problem where the upper confidence tree (UCT) searches the space of capacity expansions. Each pattern of them has a resident-optimal stable assignment that DA finds. Not only UCT obtains an optimal solution given sufficiently large time, but also a policymaker can stop UCT anytime to obtain a reasonably good solution, which is important given the hardness of obtaining an optimal solution.
We show that how a tree search method performs crucially depends on the efficiency of the tree representation. We characterise a good representation that exploit the structure the capacity expansion problem.
Let us note that
there have been a certain amount of studies on two-sided matchings in the AI community, although this
literature has been established mainly in fields across algorithms and economics.
In fact,
matching with constraints is prominen
~\cite{kamada:aer:2015,biro:tcs:2010,fragiadakis::2012,Goto:aamas:2014,Goto:aij:2016}. %
In many application domains, various distributional constraints are
often imposed on an outcome, e.g., regional maximum quotas are imposed
on hospitals in urban areas to allocate more doctors to
rural areas~\cite{kamada:aer:2015}.
In addtion, another type of distributional constraint involves
\textit{diversity constraints} in school choice programs~\cite{Abdulkadiroglu:aer:2003,kojima2012school,hafalir2013effective,ehlers::2012,kurata:jair:2017}.
They are implemented to give students/parents
an opportunity to choose which public school to attend.
\section{Problem Setup}
Let $\mathcal{D}=\{d_1,d_2,\ldots,d_{D}\}$
be the set of residents (doctors) and
$\mathcal{H} = \{h_1, h_2,\dots,h_{H}\}$ be the set of hospitals.
We consider a bipartite graph where $\mathcal{D}$ and $\mathcal{H}$ are connected by edges $\mathcal{E}$. Each edge represents that the resident is accepted by the hospital.
Residents and hospitals have their own preferences. We denote $h \succ_d h'$ if resident $d$ prefers hospital $h$ to hospital $h'$. Similarly, we denote $d \succ_h d'$ if hospital $h$ prefers resident $d$ over resident $d'$.
A vector $\bm{q} = (q_1, q_2, \dots, q_H)$ represents the quota of the hospitals.
An instance of the residency match problem is a tuple $\Gamma = (\mathcal{D}, \mathcal{H}, \bm{\succ}, \bm{q})$, where $\bm{\succ}$ denotes all preferences of the residents and the hospitals.
A matching $M \in \mathcal{M}$ is a subset of $\mathcal{E}$ such that the following criteria are met.
Each resident $d\in \mathcal{D}$ has at most one edge. Each hospital $h\in \mathcal{H}$ can have at most $q_h$ edges. We say that resident $d$ is unassigned if there is no edge from $d$.
We denote $M(d)$ and $M(h)$ to represent the hospital assigned to resident $d$ and the set of the residents assigned to hospital $h$, respectively.
Given a matching $M$, we say a pair $(d,h)\in \mathcal{E}$ is a \textit{blocking pair} if (1) resident $d$ is unassigned or prefers hospital $h$ to $M(d)$, and (2) hospital $h$ is such that $|M(h)|<q_h$ or prefers resident $d$ over at least one resident in $M(h)$. Matching $M$ is stable if there is no blocking pair.
\citeauthor{galeshapley}~\shortcite{galeshapley} showed that a stable matching always exists and proposed the deferred-acceptance (DA) algorithm that yields a stable matching.
The resident-proposing DA finds the resident-optimal stable matching where no resident is better off among all stable matchings~\cite{Roth:CUP:1990}. That matching is also obtained by
minimizing the total resident ranking under the stability constraints.
A resident ranking is denoted by $\mathrm{rank}_{d}(h)$ the rank of hospital $h$ according to the resident $d$'s preference. This is also referred to as the \textit{cost} of the match $(d,h)$.
Given a matching $M$, the total resident ranking is defined as
\begin{equation}\label{eq_utility}
\sum_{(d,h) \in M} \mathrm{rank}_d(h).
\end{equation}
DA gives a matching that minimizes Eq.~\eqref{eq_utility} among all stable matchings \cite{bobbio2021capacity}.
This paper improves
the resident utilities by allowing additional seats. Letting $\bm{t} \in \mathbb{N}^\mathcal{H}$ be a non-negative vector, we consider an expanded matching problem in which the capacity of each hospital $h$ is the sum of regular capacity $q_h$ and the extended capacity $t_h$.
A reasonable extension of the capacity should not be very large and can accommodate the demand of each hospital. Given this,
we consider the following optimization problem:
Let
\begin{align}
\mathcal{P}&=\Biggl\{
(\bm{x},\bm{t})\in \{0,1\}^\mathcal{E}\times\Theta \ \biggl\vert\
\sum_{h\in \mathcal{H}} x_{dh}\leq 1\ \forall d\in \mathcal{D},\ \\
&\ \ \ \ \ \ \ \ \sum_{d\in \mathcal{D}} x_{dh}\leq (q_{h}+t_{h})\ \forall h\in \mathcal{H}\Biggr\}, \mathrm{and}\\
\Theta &= \left\{
\bm{t} \in \{0,1,2,\dots,B\}^{\mathcal{H}}
\ \biggl\vert\
t_h \le b_h\ \forall h, \sum_{h \in \mathcal{H}} t_{h} \le B
\right\}
\end{align}
be the set of matchings.
The capacity expansion problem is the following:
\begin{align}\label{opt_main}
\min_{\bm{x},\bm{t}} & \sum_{(d,h)\in\mathcal{E}} \mathrm{rank}_{d}(h)x_{dh}\\
\mathrm{s.t.}\ & (q_h+t_h)\left(1-\sum_{h'\in S_{dh}}x_{dh'}\right)\leq \sum_{d'\in T_{dh}}x_{d'h}\ \forall (d,h)\in \mathcal{E},
\\
& (\bm{x},\bm{t})\in \mathcal{P}.
\end{align}
where $S_{dh} = \{h' \in \mathcal{H}: \mathrm{rank}_d(h') \le \mathrm{rank}_d(h)\}$ is the set of indices of hopsitals that resident $d$ prefers at
least as hospital $h$; similarly, $T_{dh} = \{d' \in \mathcal{D}: \mathrm{rank}_h(d') < \mathrm{rank}_h(d)\}$ is the set of indices of residents
that hospital $h$ prefers more than resident $d$.
Namely, keeping stability, we maximize the residents' welfare subject to the capacity constraints of the hospitals, where the capacity can be relaxed up to $B$ seats. Moreover, we assume that each hospital $h$ has its own expansion limit~$b_h$.
\begin{remark}{\rm (Complete preference)}
The optimization of Eq.~\eqref{opt_main} requires a complete preference of all residents and hospitals, which is often impractical. For example, in the real data of a residency matching program, an average resident only applies four to five hospitals. In this case, we can add a dummy hospital of infinite capacity and rank all unpreferred hospitals after the dummy hospital.
\end{remark}
\citeauthor{bobbio2021capacity}~\shortcite{bobbio2021capacity} proved the computational hardness of the problem of Eq.~\eqref{opt_main} without hospital-wise limit $b_h$.
\begin{prop}
{\rm (Hardness result~\cite{bobbio2021capacity})}
\label{prop_hardness}
The decision version of Eq.~\eqref{opt_main} is NP-complete even in the case where there is no hospital-wise limit $b_h$.
\end{prop}
The key idea of our algorithm for this problem is that, when we fix an expansion vector $\bm{t} \in \Theta$, the capacity expansion problem of Eq.~\eqref{opt_main} boils down to the standard matching instance $\Gamma = (\mathcal{D}, \mathcal{H}, \bm{\succ}, \bm{q}+\bm{t})$ that we can solve efficiently by DA.\footnote{The computational complexity of DA is $O((D+H)^2)$.} Therefore, a tree search on the space of $\Theta$ combined with DA is expected to give an efficient solution.
\begin{figure*}
\centering
\includegraphics[bb=0 0 923 386, scale=0.40]{img_tmp/treerep.png}
\caption{Three tree representations. In the iterative tree (left), the node of the grey dot corresponds to a vector $\bm{t} = (2, 0, 1)$, with its corresponding path expand hospitals $1$ and $3$ once, and expand hospital $1$ once again.
An edge in the iterative priority tree (middle) is the same as the iterative tree, but its path only includes nonincreasing order of edges (e.g., $1 \rightarrow 3 \rightarrow 1$ is \text{not} allowed).
An edge in batch tree (right) corresponds to how many extended seats we allocate to each hospital ($= t_1, t_2, t_3$). The node of the grey dot in the batch tree corresponds to a vector of $\bm{t} = (5,3,1)$.
Ordering of the hospitals matters in the iterative priority and the batch trees; the most important hospitals should be numbered earliest. All leaves of the iterative and iterative priority trees are at depth $B$, whereas the path length to a leaf of the batch tree varies: It stops branching when $\sum_h t_h = B$.
}
\label{fig_treerep}
\end{figure*}
\section{Method}
This section proposes our algorithm to solve Eq.~\eqref{opt_main}.
We apply Upper Confidence Tree (UCT) \cite{kocsis06}, which belongs to a class of Monte Carlo tree search methods \cite{mctssurvey2012}. One of the most successful examples of UCT is for abstract games such as the Game of Go \cite{WangG07,YoshizoeKKYI11,Silver2016} where the goal is to find the best next move in a game tree. Another aspect of UCT is diverse recommendation method~\cite{Bosc2018}.
In this paper, we use UCT to find a global optimum node in a tree $\mathcal{T}_{\mathrm{all}}$.
UCT consists of a sequential process of traversing a tree structure where each tree node $i$ is associated with its value $v_i$. We use $n\in \{1,2,\dots,N\}$ to denote the number of rounds. The entire tree $\mathcal{T}_{\mathrm{all}}$ is typically very large, and UCT tries to develop a subtree of it.
We denote the subtree of round $n$ by $\mathcal{T}(n)$.
Each node $i$ in the current tree is associated with a tuple $(V_i, N_i) \in \mathbb{R}^2$, where $V_i$ is the sum of rewards and $N_i$ the number of times at which node $i$ is traversed. The value $\hat{\mu}_i := V_i/N_i$ is an estimator of $v_i$, and its standard deviation is proportional to $\sqrt{1/N_i}$.
Each round consists of \textit{selection}, \textit{development}, \textit{simulation}, and \textit{backpropagation} steps.
\noindent\textbf{Selection:} At each iteration, UCT traverses $\ETsearch$ from the root. At each node $i$, it chooses a child node $c$ with the maximum UCB value:
\begin{equation}
\mathrm{UCB}(c) := \hat{\mu}_{c} + C_p \sqrt{\frac{\log(N_i)}{N_c}},
\end{equation}
where $C_p > 0$ is the parameter that determines how much exploration it attempts.
\noindent\textbf{Development:}
When it reaches a node $k$ that is out of the current tree, it adds the node to the current tree
\noindent\textbf{Simulation:}
Based on the reached node $k$, it conducts a random play to find $l$, which is a leaf stems from $k$.
\noindent\textbf{Backpropagation:}
Letting $v_l$ be the value of the leaf $l$, it updates the statistics of all nodes that we have traversed in this round: $V_i \leftarrow V_i + v_l, N_i \leftarrow N_i + 1$ for each node $i$ during the backpropagation.
The four steps above are quite standard in UCT. For a more algorithmic description, see Algorithm \ref{alg_proposed} in the appendix.
\subsection{Tree representation of expansion space}
Unlike abstract games where the game tree is inherent, the relation between a tree and the capacity expansion in our problem is nontrivial.
This section describes the mapping from a tree node into an expansion $\bm{t} \in \Theta$.
In the capacity expansion problem defined in Eq.~\eqref{opt_main},
DA yields an optimal solution given a fixed expansion vector $\bm{t}$. Therefore, we consider a tree where each node corresponds to an expansion vector $\bm{t}$, and each leaf is an expansion of limit $\sum_{h \in \mathcal{H}} t_h = B$. The value $v_i$ at each node $i$ is the objective value of
DA for the corresponding expansion.
\begin{table}[b!]
\begin{center}
\caption{Comparison of the three tree representations with respect to the criteria.
}
\label{tbl_criteria}
\scalebox{0.78}{%
{\renewcommand\arraystretch{1.2}
\setlength{\tabcolsep}{4pt}
\begin{tabular}{lcccc} \toprule
& Faithfulness & Nonredundancy & Decisiveness \\ \midrule
Iterative tree &
\checkmark
&
\\
Iterative priority tree (IPT) &
\checkmark
&
\checkmark
\\
Batch tree (BT) &
\checkmark
&
\checkmark
&
\checkmark
\\
\bottomrule
\end{tabular}}}
\end{center}
\end{table}
We consider the following criteria are important in constructing a good tree representation of an expansion.
\begin{enumerate}
\item Faithfulness: The tree preserves the inclusion relationship of the original expansion vector space: if node $j$ is a descendant of node $i$, then $\bm{t}(j) - \bm{t}(i) \ge 0$, where $\bm{t}(i), \bm{t}(j)$ be corresponding expansions of nodes $i,j$ and $\bm{t}(j) - \bm{t}(i) \ge 0$ means all the features of the vector $\bm{t}(j) - \bm{t}(i)$ are non-negative.
\item Nonredundancy: The mapping is one-to-one. Namely, for any expansion vector $\bm{t} \in \Theta$ such that $\sum_h t_h = B$, there exists only one leaf of tree $\mathcal{T}_{\mathrm{all}}$. Redundancy in a tree representation compromises the search efficiency.
\item Decisiveness: Assuming that a tree representation is faithful, the tree representation is decisive if branching in a shallow layer is more informative than the one in a deep layer. In our case, allocations related to important hospitals should appear in a shallow layer of the tree.
\end{enumerate}
Considering those criteria, we propose the three tree representations
in Figure~\ref{fig_treerep}.
In all of the three representations, the root node $r$ corresponds to the zero vector $\bm{t} = (0,0,\dots,0)$ that corresponds to no expansion.
We will discuss the idea behind these representation
summarized which properties that each of them satisfies in Table~\ref{tbl_criteria}.
The iterative representation, which is the most straightforward, builds an $H$-ary tree.\footnote{Note that $H$ is the number of the hospitals.}
Each edge corresponds to allocating a seat to one of the hospitals. As a result, each path from the root to depth $B$ represents an expansion of size $B$. Although the iterative representation is faithful, it is redundant. For example, consider the case of three hospitals. Let $1\rightarrow 2 \rightarrow 2$ to denote a path on the tree that sequentially expands hospitals $1,2,2$. An expansion vector $(2, 1, 0)$ corresponds to three different path on the tree ($1\rightarrow 1 \rightarrow 2$, $1\rightarrow 2 \rightarrow 1$, and $2 \rightarrow 1 \rightarrow 1$).
As a result, UCT with iterative tree representation searches an unnecessary large representation space, which increases the computational burden.
To deal with this issue, we introduce an improved tree representation of the expansion, which we call the iterative priority tree (IPT). For each node $i$, it only allocates a node with its priority higher than the most prioritized hospital that has been allocated a seat.
IPT solves the issue of redunduncy in the iterative tree:
\begin{prop}{\rm (Nonredundancy of IPT)}\label{prop_prioit_nonred}
For each expansion vector $\bm{t} \in \mathbb{N}^\mathcal{H}$, there exists a unique node in IPT.
\end{prop}
\begin{proof}
Each expansion uniquely corresponds to a nonincreasing sequence of numbers. For example, expansion $\bm{t} = (1, 3, 1)$ corresponds to $3\rightarrow 2\rightarrow 2\rightarrow 2\rightarrow 1$. It is easy to confirm that, in the iterative priority tree, this is the unique path that leads to the desired expansion.
\end{proof}
While the IPT is nonredundant, there still remains some space for improvement.
The batch tree (BT) representation fully exploits the priority information to allocate more than one seats to popular nodes, which reduces the depth of the optimal solution in the tree. Namely, each depth of BT corresponds to how many seats to allocate to each hospital. The following proposition states that the properties of BT:
\begin{prop}{\rm (Nonredundancy and decisiveness of BT)}
BT is nonredundant. It is also decisive, that is, a tree where the depth of the optimal node is minimum among the trees where each edge allocates seats to one hospital if the optimal solution aligns with the expansion vector, i.e., $t_1 \ge t_2 \ge t_3 \ge \dots \ge t_C$.
\end{prop}
\begin{proof}
The nonredundancy is trivial.
In the following, we derive the decisiveness of the BT.
Assume that the optimal expansion vector is such that $t_1 \ge t_2 \ge t_3 \ge \dots \ge t_C$, and let $c$ be the first index such that $t_c = 0$. BT includes the path of depth $c-1$ that leads to this allocation.
\end{proof}
\subsection{Ordering hospitals}
We introduce two ideas for ordering hospitals that we use in IPT and BT.
The first idea is to order hospitals in terms of their popularity
\begin{equation}\label{def_pop}
\mathrm{Popularity}(h) := \sum_{d \in \mathcal{D}} \mathrm{rank}_d(h).
\end{equation}
This represents how do residents rank the hospital $h$ and is equivalent to the Borda count often referred in social choice~\cite{moulin:1994}. In this paper, a smaller score is better because each resident gives the lower numbers to the highly ranked hospitals.
The second idea is utilizing \textit{potential envies} that may not be justified so that we could construct a better decision tree of the hospitals.
Namely, let
\begin{equation}\label{def_envy}
\mathrm{Envy}(h) :=
\sum_{d \in \mathcal{D}} \bm{1}[\mathrm{rank}_d(h) < \mathrm{rank}_d(M(d))]
\end{equation}
be the potential envy that the residents have toward the ones matched to hospital $h$ in matching $M$.
The score indicates the number of residents who prefer hospital $h$ over their matched hospital in $M$.
For calculating $M$, we run DA with no expansion before running UCT to determine the ordering.
\paragraph{Avoiding multiple entries.}
\label{subsec_mark}
Since the evaluation of each node (i.e., DA with a given expansion vector) is deterministic, we can restrict the node selection so that a node is never evaluated twice.
In the backpropagation step, we mark the node $k$ as ``evaluated'' if it is a leaf of $\mathcal{T}_{\mathrm{all}}$. Moreover, for each ascendant node, if all children of the node are evaluated, then we mark that node as evaluated. In the selection and simulation phase, the evaluated nodes are never visited again.
\begin{table*}[t]
\centering
\small
\caption{Average percentage gaps between the solution found by the Agg-Lin and the solution found by each method for Set 1 experiments. UCT with iterative priority trees with random/popularity/envy-based ordering are denoted by IPT-R, IPT-P, IPT-E. UCT with batch trees with random/popularity/envy-based ordering are denoted by BT-R, BT-P, BT-E. Value of $0.0$ indicates the identical objective value as Agg-Lin.
}
\begin{tabular}{|rrr||r|r||r|r|r|r|r|r|r|} \hline
\multicolumn{1}{|c}{$H$} & \multicolumn{1}{c}{$B$} & \multicolumn{1}{c||}{$\alpha$} & \multicolumn{2}{c||}{Baseline} & \multicolumn{7}{c|}{\textbf{UCT (proposed)}} \\ \cline{4-12}
&&& \multicolumn{1}{c|}{LPH} & \multicolumn{1}{c||}{Grdy} & \multicolumn{1}{c|}{Iterative} & \multicolumn{1}{c|}{IPT-R} & \multicolumn{1}{c|}{IPT-P} & \multicolumn{1}{c|}{IPT-E} & \multicolumn{1}{c|}{BT-R} & \multicolumn{1}{c|}{BT-P} & \multicolumn{1}{c|}{BT-E} \\ \hline
$5$ & $5$ & $0.0$ & $7.5$ & $5.7$ & $0.0$ & $0.0$ & $0.0$ & $0.0$ & $0.0$ & $0.0$ & $0.0$ \\
$5$ & $30$ & $0.0$ & $6.3$ & $32.9$ & $1.3$ & $34.5$ & $0.0$ & $0.0$ & $0.4$ & $0.0$ & $0.0$ \\
$15$ & $5$ & $0.0$ & $8.9$ & $4.6$ & $0.5$ & $0.5$ & $0.05$ & $0.09$ & $1.1$ & $1.1$ & $1.1$ \\
$15$ & $30$ & $0.0$ & $23.2$ & $25.3$ & $17.8$ & $18.0$ & $15.5$ & $10.4$ & $19.9$ & $15.4$ & $6.9$ \\ \hline
$5$ & $5$ & $0.2$ & $1.8$ & $1.4$ & $0.0$ & $0.0$ & $0.0$ & $0.0$ & $0.0$ & $0.0$ & $0.0$ \\
$5$ & $30$ & $0.2$ & $3.6$ & $6.4$ & $1.6$ & $0.9$ & $0.1$ & $0.03$ & $0.4$ & $0.09$ & $0.1$ \\
$15$ & $5$ & $0.2$ & $2.6$ & $0.8$ & $0.09$ & $0.0$ & $0.0$ & $0.0$ & $0.2$ & $0.06$ & $0.06$ \\
$15$ & $30$ & $0.2$ & $4.1$ & $4.3$ & $2.7$ & $2.5$ & $1.3$ & $1.4$ & $1.4$ & $0.3$ & $0.3$ \\ \hline
$5$ & $5$ & $0.4$ & $0.6$ & $0.2$ & $0.0$ & $0.0$ & $0.0$ & $0.0$ & $0.0$ & $0.0$ & $0.0$ \\
$5$ & $30$ & $0.4$ & $1.1$ & $2.1$ & $1.4$ & $0.1$ & $0.0$ & $0.0$ & $0.1$ & $0.0$ & $0.0$ \\
$15$ & $5$ & $0.4$ & $1.1$ & $0.3$ & $-0.08$ & $-0.09$ & $-0.1$ & $-0.1$ & $0.02$ & $-0.09$ & $-0.09$ \\
$15$ & $30$ & $0.4$ & $0.8$ & $0.8$ & $0.5$ & $0.05$ & $-0.6$ & $-0.6$ & $0.04$ & $-0.8$ & $-0.8$ \\ \hline
\end{tabular}
\label{tb:average_gap_synthone}
\end{table*}
\begin{table*}[t]
\centering
\small
\caption{Average run times for Set 1 (seconds).}
\label{tb:run_time_synthone}
\begin{tabular}{|rrr||r|r|r||r|r|r|r|r|r|r|} \hline
\multicolumn{1}{|c}{$H$} & \multicolumn{1}{c}{$B$} & \multicolumn{1}{c||}{$\alpha$} & \multicolumn{3}{c||}{Baseline} & \multicolumn{7}{c|}{\textbf{UCT (proposed)}} \\ \cline{4-13}
&&& \multicolumn{1}{c|}{Agg-Lin} & \multicolumn{1}{c|}{LPH} & \multicolumn{1}{c||}{Grdy} & \multicolumn{1}{c|}{Iterative} & \multicolumn{1}{c|}{IPT-R} & \multicolumn{1}{c|}{IPT-P} & \multicolumn{1}{c|}{IPT-E} & \multicolumn{1}{c|}{BT-R} & \multicolumn{1}{c|}{BT-P} & \multicolumn{1}{c|}{BT-E} \\ \hline
$5$ & $5$ & $0.0$ & $24.01$ & $0.01$ & $0.06$ & $10.09$ & $0.64$ & $0.64$ & $0.65$ & $0.86$ & $0.86$ & $0.86$ \\
$5$ & $30$ & $0.0$ & $11.85$ & $0.01$ & $0.19$ & $35.60$ & $45.38$ & $39.84$ & $39.92$ & $36.93$ & $38.83$ & $38.03$ \\
$15$ & $5$ & $0.0$ & $854.91$ & $0.02$ & $0.94$ & $52.11$ & $56.98$ & $54.88$ & $54.31$ & $54.76$ & $53.50$ & $53.37$ \\
$15$ & $30$ & $0.0$ & $362.87$ & $0.02$ & $3.34$ & $177.00$ & $167.24$ & $166.36$ & $160.77$ & $149.91$ & $139.90$ & $139.74$ \\ \hline
$5$ & $5$ & $0.2$ & $37.79$ & $0.01$ & $0.09$ & $15.59$ & $0.98$ & $0.99$ & $0.99$ & $1.30$ & $1.31$ & $1.32$ \\
$5$ & $30$ & $0.2$ & $55.79$ & $0.01$ & $0.44$ & $89.59$ & $94.44$ & $93.57$ & $94.46$ & $91.78$ & $90.11$ & $90.06$ \\
$15$ & $5$ & $0.2$ & $2740.02$ & $0.03$ & $1.80$ & $129.87$ & $129.35$ & $129.18$ & $130.38$ & $125.60$ & $128.63$ & $128.88$ \\
$15$ & $30$ & $0.2$ & $3527.88$ & $0.03$ & $7.14$ & $384.11$ & $376.15$ & $370.17$ & $370.66$ & $343.04$ & $362.58$ & $361.80$ \\ \hline
$5$ & $5$ & $0.4$ & $86.30$ & $0.01$ & $0.09$ & $15.04$ & $0.98$ & $0.97$ & $0.97$ & $1.30$ & $1.29$ & $1.30$ \\
$5$ & $30$ & $0.4$ & $294.07$ & $0.01$ & $0.54$ & $123.79$ & $130.87$ & $129.49$ & $129.18$ & $123.63$ & $123.91$ & $123.89$ \\
$15$ & $5$ & $0.4$ & $3600.21$ & $0.03$ & $2.38$ & $169.40$ & $166.00$ & $166.96$ & $168.14$ & $168.51$ & $166.51$ & $166.11$ \\
$15$ & $30$ & $0.4$ & $3600.41$ & $0.04$ & $9.24$ & $578.57$ & $606.01$ & $574.18$ & $584.77$ & $553.69$ & $571.35$ & $572.87$ \\ \hline
\end{tabular}
\end{table*}
\begin{table*}[t]
\centering
\small
\caption{Average percentage gaps between the solution found by the Agg-Lin and the solution found by each method for JRMP.}
\label{tb:average_gap_jrmp}
\begin{tabular}{|r||r|r||r|r|r|r|r|r|r|} \hline
\multicolumn{1}{|c||}{$B$} & \multicolumn{2}{c||}{Baseline} & \multicolumn{7}{c|}{\textbf{UCT (proposed)}} \\ \cline{2-10}
& \multicolumn{1}{c|}{LPH} & \multicolumn{1}{c||}{Grdy} & \multicolumn{1}{c|}{Iterative} & \multicolumn{1}{c|}{IPT-R} & \multicolumn{1}{c|}{IPT-P} & \multicolumn{1}{c|}{IPT-E} & \multicolumn{1}{c|}{BT-R} & \multicolumn{1}{c|}{BT-P} & \multicolumn{1}{c|}{BT-E} \\ \hline
$10$ & $0.2$ & $0.3$ & $1.3$ & $1.1$ & $0.04$ & $0.06$ & $0.9$ & $0.02$ & $0.02$ \\
$30$ & $0.4$ & $1.1$ & $4.8$ & $3.7$ & $0.1$ & $0.4$ & $1.7$ & $0.02$ & $0.09$ \\ \hline
\end{tabular}
\end{table*}
\begin{table*}[t]
\centering
\small
\caption{Average run times for JRMP (seconds).}
\label{tb:run_time_jrmp}
\begin{tabular}{|r||r|r|r||r|r|r|r|r|r|r|} \hline
\multicolumn{1}{|c||}{$B$} & \multicolumn{3}{c||}{Baseline} & \multicolumn{7}{c|}{\textbf{UCT (proposed)}} \\ \cline{2-11}
& \multicolumn{1}{c|}{Agg-Lin} & \multicolumn{1}{c|}{LPH} & \multicolumn{1}{c||}{Grdy} & \multicolumn{1}{c|}{Iterative} & \multicolumn{1}{c|}{IPT-R} & \multicolumn{1}{c|}{IPT-P} & \multicolumn{1}{c|}{IPT-E} & \multicolumn{1}{c|}{BT-R} & \multicolumn{1}{c|}{BT-P} & \multicolumn{1}{c|}{BT-E} \\ \hline
$10$ & $247.89$ & $0.08$ & $9.35$ & $20.42$ & $22.11$ & $21.49$ & $22.08$ & $20.58$ & $21.13$ & $21.16$ \\
$30$ & $438.20$ & $0.08$ & $27.12$ & $62.72$ & $74.68$ & $73.18$ & $73.65$ & $77.30$ & $74.98$ & $78.20$ \\ \hline
\end{tabular}
\end{table*}
\begin{figure*}[t!]
\centering
\begin{minipage}[t]{0.32\textwidth}
\centering
\includegraphics[width=1.1\textwidth]{img_tmp/log/wo_college_budgets/num_students1000_num_colleges15_budget30_correlation0.4/result.pdf}
\end{minipage}
\begin{minipage}[t]{0.32\textwidth}
\centering
\includegraphics[width=1.1\textwidth]{img_tmp/log/tokyo/budget10/result.pdf}
\end{minipage}
\begin{minipage}[t]{0.32\textwidth}
\centering
\includegraphics[width=1.1\textwidth]{img_tmp/log/tokyo/budget30/result.pdf}
\end{minipage}
\caption{Total resident rankings (costs) of the proposed algorithms. Horizontal axis indicates the number of rounds.
The dotted lines represent the total costs obtained by Grdy, LPH, and Agg-Lin.}
\label{fig:trajectory}
\end{figure*}
\subsection{Consistency of the method}
This section analyzes the proposed method. The first result is a trivial consequence of avoiding multiple entries:
\begin{prop}{\rm (Worst-case sample complexity)}
\label{prop_worst}
UCT with iterative tree finds an optimal solution in $N = |\mathcal{T}_{\mathrm{all}}|$ rounds.
\end{prop}
\begin{proof}
Since the development step adds a node to $\mathcal{T}(n)$ at each round $n$, it follows that it obtains the optimal solution if $N$ reaches the number of the nodes $|\mathcal{T}_{\mathrm{all}}|$.
\end{proof}
We further propose a nontrivial analysis by following the analysis of the original UCT by \cite{kocsis06}. The largest difference is that \citeauthor{kocsis06}~\shortcite{kocsis06} analyzed the average quality of the selected action (i.e., regret), whereas we are interested in the quality of the best path, which corresponds to the optimal solution of the capacity expansion problem.
Let $\hat{\mu}_{i,m}$ be the mean of node $i$ after the $m$-th visit, and $U_{i,m,n} = \hat{\mu}_{i,m} + C_p\sqrt{\frac{\log n}{m}}$ be the corresponding UCB value. Let $W$ be the maximum number of the children of a node and $D_T$ be the depth of the tree.\footnote{That is $W=H, D_T=B$ for iterative and iterative priority tree, or $W=B,D_T=H$ for the batch tree.}
Let $v^*_i$ be the maximum value of the leaves that are descendants of node $i$. Let $v^* = v^*_r$ be the global optimal value, where $r$ is the root node. The following assumption is essentially the same as the one in \cite{kocsis06}:
\begin{assp}{\rm (Confidence bound)}
\label{assp_confbound}
We assume
\begin{equation}\label{ineq_confbound}
\mathbb{P}\left[ U_{i,n,m} \ge v^*_i \right] \ge 1 - 1/n^2.
\end{equation}
\end{assp}
\begin{definition}{(\rm $\Delta$-optimal tree)}
Let $\Delta > 0$ be arbitrary. The $\Delta$-optimal subtree is defined recursively as follows. First, it includes the root of the original tree. For each node $i$ in the subtree, add each children $c$ such that $v_i^* - v_c^* \le \Delta$. In other words, $\Delta$-optimal subtree is a subtree where each edge is suboptimal at most $\Delta$.
Let $S(\Delta)$ be the number of the nodes in the $\Delta$-optimal subtree.
\end{definition}
\begin{thm}\label{thm_complexity}
If Assumption \ref{assp_confbound} holds for any node $i$, then with probability at least $1 - o(N^{-1})$, UCT finds at least one node in the $\Delta$-suboptimal tree if $N$ satisfies
\begin{equation}\label{ineq_suffT}
N > W S(\Delta)
\frac{(C_p)^2 \log N}{\Delta^2}.
\end{equation}
\end{thm}
The proof of Therem \ref{thm_complexity} is in appendix.
\begin{remark}{\rm (Implication)}
The solution of the node $i$ in $\Delta$-suboptimal tree is at least
\[
v_i \ge v^* - D_T \Delta.
\]
Therefore, letting $\Delta$ be sufficiently small and $N$ be sufficiently large, UCT finds an almost optimal solution. The required number of $N$ depends on $S(\Delta)$, which corresponds to the number of close-to-optimal children.
\end{remark}
Although our analysis gives a complexity bound based on the structure of the tree, we still think this analysis (as well as any existing analysis of UCT) is not very satisfying. We discuss the limitation of this analysis in Appendix~\ref{subsec_analysis_rev}.
\section{Evaluation}
This section empirically evaluates our algorithm via synthetic and real datasets.
We compare our algorithms
with the ones by~\cite{bobbio2021capacity}: the greedy algorithm (Grdy), the linear programming-based heuristic (LPH), and the aggregated linearization (Agg-Lin). Note that, throughout this section, we follow the description that the objective of their formulation minimizes the total resident cost.
Existing algorithms are as follows.
First, Grdy is an algorithm that allocates $B$ expansion seats iteratively such that each allocation maximizes the marginal cost reduction.
Second, LPH first computes a minimum cost matching without stability constraints via minimum-cost flow to fix the expansion seats, and then uses DA to obtain a stable matching.
Finally, Agg-Lin is an exact method that uses McCormick envelopes and solves a mixed integer programming, which is computationally intensive.\footnote{See Appendix~\ref{exact_and_uct} for the comparison between general methods for solving mixed integer programming and our UCT.} We warm-up Agg-Lin as suggested by \cite{bobbio2021capacity}.
For our UCT method, we set $N = B \times 10^3$ in synthetic data experiments, $N = B \times 10^2$ in real data experiments.
The value of $C_p$, which determines the tradeoff between exploration and exploitation, is set to be $\sqrt{0.002}$. We consider this parameter is robust enough to cover all settings.
We implement our simulation by Python 3 and solve the mathematical programming using Gurobi, which is in favor of Agg-Lin.
We restrict the runtime for each method to one hour.
We describe the procedure of generating the datasets for our evaluation.
First, we build two synthetic datasets. \textbf{Set 1} involves $B$ but each hospital does \textit{not} have its expansion limit $b_h$. \textbf{Set 2} involves $B$ as well as $b_h$ for each hospital. Note that the setting of Set 1 is similar to the experimental section in \cite{bobbio2021capacity}. Regarding the preference among the residents, we follow the setting of \cite{Goto:aij:2016}, which involves a parameter $\alpha>0$. Larger value of $\alpha$ implies a stronger correlation among the preferences.
The details of the data generation are in Appendix~\ref{sec_synth_dgp}.
We set $D := |\mathcal{D}|=1,000$, and conduct experiments varying the parameters $H := |\mathcal{H}|$, $B$, $b_h$, and $\alpha$.
For each combination of parameters, we average the results for $10$ instances.
Due to page limitation, we defer the results of Set 2 in the appendix.
Second, we generate
the dataset, \textbf{JRMP}, based on Japan Residency Matching Program
2007~\cite{kamada:aer:2015}, which matches medical hospital students (residents) with residency training programs.
We extracted $1,287$ residents in the Tokyo district who match with $50+1$ ($1$ for a dummy) hospitals with a resident-side preference. We set $B \in \{10, 30\}$ for the limit of capacity expansion.
For each $B$, we average the results for $10$ instances.
We place the details of the dataset in Appendix \ref{sec_real_dgp}.
Tables~\ref{tb:average_gap_synthone} and \ref{tb:run_time_synthone} illustrate the quality of solutions and its runtime for Set~1, respectively. We place the results for Set~2 in the appendix due to the space limitation. Also, we place Tables~\ref{tb:average_gap_jrmp} and \ref{tb:run_time_jrmp} for the JRMP data.
Note that Table \ref{tb:average_gap_synthone} indicates the average gap, which is defined as
\[
100\times \frac{
\text{(Eq.~\eqref{eq_utility} of the method)}
-
\text{(Eq.~\eqref{eq_utility} of Agg-Lin)}
}{
\text{(Eq.~\eqref{eq_utility} of the method)}
}.
\]
Since Agg-Lin is an exact method, it outputs an optimal solution upon the completion. However, as we show in Table~\ref{tb:run_time_synthone}, it does not run within one hour for large instances with $\alpha > 0$. In that case, we use the temporal value that Gurobi outputs, which can be suboptimal.
Among the algorithms we consider, the two greedy methods (Grdy and LPH) run very fast ($< 10$ seconds) and output a suboptimal solution.
Both of them are outperformed by all variants of ours.
In particular, BT outperformed iterative tree and IPT, and
using the popularity and envy-based orderings outperformed the random one.
Figure \ref{fig:trajectory} describes the objective values as a function of rounds. That of BT is satisfying before $N$, which implies the possibility of further reducing the computational time of UCT.
In summary, BT with envy/popularity-based ordering yields the best results among our algorithms. Our algorithms run much faster (2--20 times) than Agg-Lin, and the quality of the solution is very close to optimal.
\section{Conclusion}
This paper sheds light on the capacity expansion in the two-sided matching to consider a flexible allocation of extra seats.
We develop a UCT-based search method and verify that it outperforms the previous approaches.
In future work, we would like to extend it to matchings with constraints that need not admit stable matching.
\if0
Interesting directions of the future researches include:
\begin{itemize}
\item Diverse recommendations \cite{Bosc2018}. UCT sequentially sequentially traverses the search tree and is useful to recommend more than one solution, from which the policymaker chooses the most favorable one.
\item Regional quotas \cite{GotoIKKYY16}. While we consider an expansion budget $B$ over all hospitals, we may consider a multi-region matching problem where each region has its own budget.
\item Other objective functions. We consider the maximization of the resident-side utility.
\end{itemize}
\fi
\clearpage
|
{'timestamp': '2022-02-15T02:39:24', 'yymm': '2202', 'arxiv_id': '2202.06570', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06570'}
|
arxiv
|
\section{Introduction}
In modern society, various sequential prediction tasks can help humans making informed decisions such as recommendation \cite{DBLP:conf/wsdm/TangW18, DBLP:conf/cikm/SunLWPLOJ19}, trajectory prediction \cite{DBLP:conf/kdd/LianWG0C20}, click-through rate prediction \cite{DBLP:conf/kdd/PiBZZG19, DBLP:conf/dasfaa/ZengCZTMLZ20} and region-centered event prediction \cite{hu2021duronet}. For example, during the COVID-19 pandemic, precise prediction of infected cases has led to better allocation of healthcare resources~\cite{yan2020interpretable, swapnarekha2020role}. As shown in the left side of Figure \ref{figure1-1}, such tasks typically arrange a series of historical elements (e.g., items, events, locations or their counts) from a certain generator in chronological order, which constitutes a sequence. Existing studies have proved that there exist diverse kinds of interaction patterns between the element sequences and their corresponding next elements \cite{DBLP:conf/cikm/ZhouWZZWZWW20, DBLP:conf/kdd/LianWG0C20, DBLP:journals/is/LiCDWSX20, 9119847}. These patterns can give humans a hint about what the future element is like to some degree. In order to provide high-quality predictions, numerous researchers are trying to model and learn the latent interaction patterns comprehensively.
To capture the interaction patterns, various deep learning models are proposed. Most works notice that some interactions involved by humans present more complex characteristics such as irregular interaction \cite{DBLP:conf/iclr/ShuklaM19, DBLP:conf/wsdm/TangW18, DBLP:conf/cikm/SunLWPLOJ19}, dynamic dependency \cite{DBLP:conf/sigir/WangDH0C20, DBLP:conf/aaai/ZhouMFPBZZG19}, noise interference \cite{DBLP:conf/nips/LiJXZCWY19, hu2021duronet}, than others in nature. Therefore, the basic paradigm of their works is to design a well-adapted structure to better model sequential interactions. Recent studies indicate that an effective training strategy can also help to improve prediction performance by making use of interaction information \cite{DBLP:conf/cikm/ZhouWZZWZWW20, DBLP:conf/www/Yuan0JGXXX20, DBLP:conf/wsdm/WangF0NC21}. Despite the effectiveness of prior methods, most of them capture interaction patterns by revising wrong responses where ground-truth is not inferred correctly.
\begin{figure}[t]
\centering
\subfigure[Different types of interactions between source sequences and the next targets, and their divisions by jointly considering model responses and hardness.] {\label{figure1-1}
\includegraphics[width=0.9\columnwidth]{figure/fig1-1.pdf}
}
\subfigure[Distinctive self-knowledge is generated from different initializations. The deeper the color, the higher likelihood of correct response.] {\label{figure1-2}
\includegraphics[width=0.95\columnwidth]{figure/fig1-2.pdf}
}
\caption{An illustration of implicitly hard interactions caused by subsets of learnable patterns during training.}
\label{figure1}
\vspace{-1.7 em}
\end{figure}
By jointly considering model responses in training and hardness of interactions, the mining of interactions can be divided into three types. As shown in the right part of Figure~\ref{figure1-1}, for the lower red region, the wrong responses often with relatively larger training loss are a kind of explicitly hard interactions that have caught the eye of researchers~\cite{DBLP:conf/cikm/SunLWPLOJ19, hu2021duronet, DBLP:conf/cikm/ZhouWZZWZWW20}. For the upper region, correct responses usually generate relatively lower loss \cite{DBLP:conf/wsdm/WangF0NC21}. However, among correct responses, there are kinds of interactions with some patterns unlearned by models. Low loss might make models no longer able to make specific intentional adjustments and prone to a subset of comprehensive patterns. With the limitation of training samples, how to learn such implicitly hard interactions is a burning problem to improve the generalization performance of sequential prediction models. More recently, a multi-view theory~\cite{allenzhu2020understanding} proposed by Microsoft Research indicates that individual models have limited capability of capturing multiple views of data. In addition, according to the biased assessment in some psychological mechanisms \cite{brown1991accuracy, karpen2018social}, one-sided perspective is easy to generate biased self-knowledge without communicating with others. Inspired by the above studies, multi-perspective experiences about pattern learning can be introduced to enhance the learning of implicitly hard interactions in sequential prediction. We think that some implicitly hard interactions can be identified from the inconsistent response results across different models.
To further investigate the implicitly hard interactions, we analyze the negative log-likelihood of 50 training samples in ML-1m (a movie ratings dataset) by a hierarchically-clustered heatmap. As shown in Figure~\ref{figure1-2}, several observations are listed as follows:
\begin{itemize}[leftmargin=*, topsep = 0 pt]
\item From the left side, the likelihood of predicting positive samples varies with initializations. And, both the interactions and initializations present cluster effects by observing the dendrogram on the left and top of heatmap, respectively. It denotes that models with different initializations can generate distinctive self-knowledge.
\item After masking the wrong responses with white blocks, inconsistent training results accounted for 15.42\% of total samples can be observed from the right side. It is noted that some interactions are correctly predicted with high likelihood (deep color) by only a model while other models present wrong responses.
\end{itemize}
Overall, the observations are in line with the limitation of self-knowledge \cite{wilson2004self, brown1991accuracy, karpen2018social, allenzhu2020understanding}. And, inspired by them, multiple perspectives of interactions can be generated by distinctive initializations.
To this end, we propose a novel Hardness Aware Interaction Learning framework (HAIL). Our solution aims at exchanging mutual exclusivity knowledge, which aggregates training experiences from other perspectives for learning implicitly hard interactions. \emph{First}, two base networks are developed from different initializations to generate distinctive information about implicitly hard interactions. \emph{Second}, we propose mutual exclusivity distillation (MED) that subtly transfers the unlikelihood of correct responses for different interactions. We further infer that such mutual exclusivity knowledge in the form of unlikelihood can adjust the gradients of models, which can enhance the learning of implicitly hard interactions. This learning paradigm is conducive to improving generalization performance of models by enriching view patterns and can be easily extended to more peers.
Our main contributions are summarized as follows:
\begin{itemize}[leftmargin=*]
\item We highlight the impact of implicitly hard interactions and identify their inconsistent characteristics across different perspectives. To our knowledge, it is the first time that implicitly hard interactions are mentioned in sequential prediction tasks.
\item A general learning framework HAIL is developed for sequential prediction to enhance the learning of implicitly hard interactions. In particular, MED is proposed to derive mutual exclusivity knowledge, which breaks the conventional manner of mimic learning in knowledge distillation. We further infer that MED essentially introduces additional gradients to push pattern learning of implicitly hard interactions.
\item With extensive experiments on two benchmark recommendation datasets from cyber space and two event datasets from physical space, the proposed framework HAIL outperforms existing state-of-the-art methods in several typical applications in terms of top-k based metrics.
\end{itemize}
\section{Related Work}
In this section, we review some sequential prediction works with respect to hard interactions, and then investigate the advance of knowledge distillation.
\subsection{Sequential Prediction}
Sequential prediction is a common technique that is widely used in various domains such as sequential recommendation \cite{DBLP:conf/wsdm/TangW18, DBLP:conf/cikm/SunLWPLOJ19}, location prediction \cite{DBLP:conf/kdd/LianWG0C20}, click-through rate prediction~\cite{DBLP:conf/kdd/PiBZZG19, DBLP:conf/dasfaa/ZengCZTMLZ20}.
\textbf{\emph{Incorporating More Information.}} Early matrix factorization based methods \cite{DBLP:conf/ijcai/ChengYLK13, DBLP:conf/recsys/JuanZCL16, DBLP:conf/www/HeLZNHC17} are difficult to capture hard interactions. With the emerging of deep learning, substantial neural networks are proposed to learn hard interactions by incorporating more information, such as RNN \cite{DBLP:conf/sigir/YuLWWT16, DBLP:conf/icdm/LiSZ18, DBLP:conf/ijcai/ChengYLK13} and convolution \cite{DBLP:conf/wsdm/TangW18, BaiTCN2018}. Recently, since self-attention~\cite{DBLP:conf/nips/VaswaniSPUJGKP17} shows promising performance, more advanced self-attention based methods are proposed to introduce related information in terms of different applications. These methods can be divided into two aspects: 1) For the tasks in cyber space, recommendation is one of the hotspot research areas \cite{DBLP:conf/sigir/WangDH0C20, DBLP:conf/cikm/ZhouWZZWZWW20, DBLP:conf/cikm/SunLWPLOJ19}; 2) For the tasks in physical space, there are convolution kernels \cite{DBLP:conf/nips/LiJXZCWY19}, sparse mechanism based Informer \cite{informer2021}, geography-aware based GeoSAN \cite{DBLP:conf/kdd/LianWG0C20} and adjacent context based DuroNet \cite{hu2021duronet}.
\textbf{\emph{Learning Strategy.}} More recently, some studies indicate that effective training strategies can also enhance the learning of hard interactions and they are less affected by specific applications. MIM can well capture intrinsic data correlation to avoid overemphasizing the final performance \cite{DBLP:conf/cikm/ZhouWZZWZWW20}. On the premise of sufficient data, the learning of partial hard interactions can be amplified by removing noisy interactions \cite{DBLP:conf/wsdm/WangF0NC21}.
The above methods focus on learning hard interactions under self-knowledge from a single perspective, which pays less attention to implicitly hard interactions. Different from them, our work tries to capture implicitly hard interactions no matter which specific cyber or physical spaces they are in by deriving training experience from others. To this end, we propose a novel hardness aware interaction learning framework that mainly consists of two base networks and a MED strategy.
\subsection{Knowledge Distillation}
Given a training model, this paper focuses on how to draw experiences about learning implicitly hard interactions from other models. Knowledge distillation is an effective means to transfer knowledge between models, which is particularly suitable in our scenario.
\textbf{\emph{Model Compression.}} Ideas underpinning distillation can date back to model compression \cite{DBLP:conf/kdd/BucilaCN06}. The current and most well-known neural distillation is proposed by Hinton et al. \cite{DBLP:journals/corr/HintonVD15} where small student models can derive more information from the softened output of cumbersome teacher models than the ground-truth. Subsequently, a long line of papers about distillation and compression quickly emerges. In sequential prediction, some progress has been made in the \emph{distillation object, architectures and procedures}, respectively. Specifically, some features from the teacher's hidden layer are also distilled to guide the learning of student models \cite{DBLP:journals/corr/RomeroBKCGB14}. Self-distillation allows the teacher and students lying in a same model architecture \cite{DBLP:conf/acl/LiuZWZDJ20}. A two-step distillation is proposed for the pre-training and fine-tuning stage, respectively \cite{DBLP:conf/emnlp/JiaoYSJCL0L20}.
\textbf{\emph{Non-compression Task.}} Recently, distillation is proved to be feasible in other tasks that are not for model compression. Two typical works break the learning pattern from teacher models to improve performance of image classification. Born-again neural network obtains improvement from the prior model by teaching selves \cite{DBLP:conf/icml/FurlanelloLTIA18}. Deep mutual learning collects knowledge from student cohort \cite{DBLP:conf/cvpr/ZhangXHL18}. Moreover, multilingual translation can be integrated into a unified model by distilling different language models \cite{DBLP:conf/iclr/TanRHQZL19}.
In this work, we break the mimic learning in convention where student models try to reproduce the knowledge from their teacher models. We argue that imitation is not much appropriate to further improve performance, since the teacher models preferentially transfer selective knowledge that they are in high confidence. To this end, MED is proposed to employ mutual exclusivity knowledge that is also a kind of learning experience. In this manner, a model can acquire hints from the unlikelihood of others' correct responses to notice implicitly hard interactions.
\section{Framework}
In sequential prediction, the principal entities are generators (e.g., users, regions) and elements (e.g., items, locations, events). The generator can generate a series of elements in chronological order. Given a set of generators $\mathcal{G}=\{g_1, g_2, ...,g_{\vert\mathcal{G}\vert}\}$ and a set of elements $\mathcal{E}=\{e_1, e_2, ...,e_{\vert\mathcal{E}\vert}\}$, the interaction sequence in chronological order for generator $g \in\mathcal{G}$ can be denoted as $\mathcal{X}_g=\{e^{(g)}_1, ..., e^{(g)}_t, ..., e^{(g)}_{n_g}\}$, where $e^{(g)}_t \in \mathcal{E}$ is the element that $g$ has interacted with at time step $t$ and $n_g$ is the length of interaction sequence for generator $g$.
\textbf{Sequential Prediction for Next.} Based on the above notations, the task of sequential prediction can be formally defined as follows: given the historical interaction sequence $\mathcal{X}_g$, the objective is to learn a prediction model $\mathcal{M}: \mathcal{X}_g \rightarrow \mathcal{P}_g$ where $\mathcal{P}_g$ is the likelihood distribution over all elements that generator $g$ possibly interacts with at time step $n_g+1$. The next element $\hat{\mathcal{Y}}$ can be inferred by sorting the likelihood in descending order.
\subsection{Overview}
The framework of HAIL is presented in Figure \ref{framework}.
\begin{figure*}[t]
\centering
\includegraphics[width=0.94\linewidth]{./figure/fig2.pdf}
\caption{The framework of the proposed HAIL. Implicitly hard interactions are identified by the inconsistent results of two base networks as shown in Subfigure (a). The base networks exchange mutual exclusivity knowledge in the form of unlikelihood to enhance the learning of implicitly hard interactions as shown in Subfigure (b).}
\label {framework}
\end{figure*}
HAIL consists of a shared interaction embedding layer, two base networks (peer for each other) and a shared prediction layer. In the training stage, the experience of learning implicitly hard interactions can be distilled from the peer model. In prediction, either of the base networks can be removed.
The basic idea of our work is to employ the mutual exclusivity knowledge of peer's correct responses to enhance the learning of implicitly hard interactions. To this end, two base networks from different initializations are designed to generate distinctive self-knowledge. Then, MED is proposed to make base networks close to each other and exchange the unlikelihood of correct responses. Finally, each model collects the self-knowledge and the mutual exclusivity knowledge from its peer to adjust the learning weights for implicitly hard interactions.
In the following, we first introduce the components of the proposed framework HAIL. And then, we elaborate on the hardness aware learning and the proposed MED.
\subsection{Interaction Embedding Layer}
As shown in the lower-left region of Figure \ref{framework}, a sequence of elements (a.k.a. interaction) is first embedded into fixed-length vectors by looking up a shared embedding table $\bm{U} \in \mathbb{R}^{{\vert\mathcal{E}\vert} \times d}$ where ${\vert\mathcal{E}\vert}$ is the number of elements and $d$ is the length of vectors. Here, we train the table from scratch without introducing any pre-training parameters. To make use of positional information, we also employ a positional table $\bm{S} \in \mathbb{R}^{N \times d}$ to generate a fixed-length position vector where $N$ is the maximum length of input sequence. Formally, the output of embedding layer can be derived by suming the element embedding and the positional embedding as $\bm{h^0_i} = \bm{x_i}\bm{U}+\bm{s_i}$, where $\bm{x_i}$, $\bm{s_i}$ and $\bm{h^0_i}$ are one-hot input, position and embedding vector of the $i$th element, respectively. The embedding matrix $\bm{H^0}=[\bm{h^0_1},...,\bm{h^0_i},...\bm{h^0_N}]$ will be fed into the following components.
\subsection{Base Network}
As shown in the middle-left region of Figure \ref{framework}, to introduce additional knowledge, two base networks initialized differently are employed to independently model interactions. We attempt to capture multi-perspective interactions by employing dark knowledge~\cite{DBLP:conf/cvpr/ZhangXHL18}, since models learn from different starting points can derive mutable probability distributions. Note that the architecture of base networks can be set flexibility according to specific applications. Without loss of generality, we do not distinguish network $\mathcal{M}_1$ and network $\mathcal{M}_2$ in the following description for simplicity.
\subsubsection{Multi-head Self-attention Layer}
In most sequential prediction tasks, interactions hide in a relatively long-time span. The conventional RNNs are easy to meet the vanishing gradient problem~\cite{DBLP:conf/nips/SutskeverVL14}. Hence, we adopt the self-attention that captures interactions between elements without regard to distance.
In particular, the input of the $l$th layer $\bm{H^{l-1}}$ is transformed into $R$ subspaces simultaneously to derive $R$ attention heads. Then, the heads are concatenated and transformed again to output the representations, after a residual connection. The process can be defined as follows:
\begin{equation}
\begin{split}
\bm{A_0^l}&=Concat(\bm{head_1},...,\bm{head_r},...,\bm{head_R})\bm{W_O^l}+\bm{H^{l-1}},\\
&\bm{head_r}=Attention(\bm{H^{l-1}}\bm{W_{Q_r}^{l}},\bm{H^{l-1}}\bm{W_{K_r}^{l}},\bm{H^{l-1}}\bm{W_{V_r}^{l}}),
\end{split}
\end{equation}
where $\bm{W_{Q_r}^{l}},\bm{W_{K_r}^{l}},\bm{W_{V_r}^{l}} \in \mathbb{R}^{d \times d/R}$ are three projection matrices of the $r$th subspace. $\bm{W^l_O}\in\mathbb{R}^{d \times d}$ is the output projection. $R$ is the number of heads. $\bm{A^l_0}$ is the final representation after residual connection. The attention function is a scaled dot-product computation that can be calculated as
\begin{equation}
Attention(\bm{Q},\bm{K},\bm{V})=softmax(\frac{\bm{Q}\bm{K^T}}{\sqrt{d/R}})\bm{V}.
\end{equation}
\subsubsection{Feed Forward layer}
To introduce more nonlinearity, a two-layer feed forward network is applied on each element representations as follows:
\begin{equation}
\begin{split}
\bm{A^l_1}&=\tau(\bm{A^l_0}\bm{W^l_1}+\bm{b^l_1}),\\
\bm{A^l_2}&=\bm{A^l_1}\bm{W^l_2}+\bm{b^l_2},
\end{split}
\end{equation}
where $\bm{W^l_1}\in \mathbb{R}^{d \times d_h}$ and $\bm{W^l_2}\in \mathbb{R}^{d_h \times d}$ are weight matrixes. $\bm{b^l_1}\in \mathbb{R}^{d_h}$ and $\bm{b^l_2}\in \mathbb{R}^{d}$ are the biases. $d_h$ is the dimension of the intermediate layer. $\tau(\cdot)$ is the activation function (GELU in our experiment). Finally, the output of the $l$th encoder can be derived after a residual connection as $\bm{H^{l}}=\bm{A^l_2}+\bm{A^l_0}$.
\subsection{Prediction Layer for Next}
As shown in the upper-left region of Figure \ref{framework}, the final representations of masked elements are fed into a prediction layer after iteratively computing of the latent patterns. A shared feed forward and the shared embedding table are employed to decode them. The likelihood distribution $\bm{p^{(j)}}$ of the predicted next element for the $j$th base network can be derived as follows:
\begin{equation}
\begin{split}
\bm{z}^{(j)}&=\tau(\bm{h^{(j,L)}}\bm{W_P}+\bm{b_P})\bm{U^T}+\bm{b_U},\\
\bm{p^{(j)}}&=\Psi(\bm{z^{(j)}}),
\end{split}
\label{pj}
\end{equation}
where $\bm{h^{(j,L)}}$ denotes the final representation of the $L$th layer and $L$ is the number of layers, $\bm{W_P}\in \mathbb{R}^{d\times d}$ is the weight matrix, $\bm{b_P}\in\mathbb{R}^{d}$ and $\bm{b_U}\in\mathbb{R}^{\vert\mathcal{E}\vert}$ are the biases. $\bm{z^{(j)}}=[z^{(j)}_1,...,z^{(j)}_{\vert\mathcal{E}\vert}]$ is the output of logits. $\Psi(\cdot)$ is the score function (softmax in our experiment).
\subsection{Hardness Aware Learning}
As shown in right part of Figure \ref{framework}, for each base network, the ground-truth and the likelihood distribution of the output from its peer are vital sources of knowledge. To make use of them, self-knowledge independent learning and mutual exclusivity knowledge distillation are designed, respectively.
\subsubsection{Self-knowledge Independent Learning}
To obtain a decent baseline and avoid model drifting arbitrarily, both base networks are designed to learn from ground-truth independently. In this way, they can acquire distinctive self-knowledge from different initial learning points. By following most existing methods~\cite{DBLP:conf/naacl/DevlinCLT19, DBLP:conf/cikm/ZhouWZZWZWW20, DBLP:conf/cikm/SunLWPLOJ19}, self-supervised learning is adopted in our work. In particular, for any element sequence, we randomly mask a proportion of elements with special tokens "[Mask]". This process can be repeated multiple times to generate multiple masked sequences. It is worth noting that more training sequences with final elements masked are appended to avoid fine-tuning in prediction \cite{DBLP:conf/cikm/SunLWPLOJ19}.
As the blue circle shown in the lower-right region of Figure \ref{framework}, the cross-entropy loss is adopted to converge the proposed model. For each input sequence, the self-knowledge based loss of the $j$th base model can be defined as:
\begin{equation}
\mathcal{L}_{SK}^{(j)} = -\frac{1}{{\vert\mathcal{I}\vert}} \sum_{i \in \mathcal{I}} y_{i,*}log(p^{(j)}_{i,*}),
\label{ik}
\end{equation}
where $\mathcal{I}$ is the index set of masked elements in the input sequence. For the $i$th masked element, $\bm{y_{i}}=[y_{i,1}, ..., y_{i,*},...,y_{i,{\vert\mathcal{E}\vert}}]$ is the corresponding ground-truth label. $\bm{p^{(j)}_{i}}=[p^{(j)}_{i,1}, ..., p^{(j)}_{i,*},...,p^{(j)}_{i,{\vert\mathcal{E}\vert}}]$ is the likelihood distribution of all elements. $*$ denotes the positive sample.
\subsubsection{Mutual Exclusivity Knowledge Distillation.}
\label{HIL}
When training a model, learning experiences from its peer can be introduced by knowledge distillation. For conventional mimic learning \cite{DBLP:journals/corr/HintonVD15, DBLP:conf/cvpr/ZhangXHL18}, the student model preferentially obtains the experiences with high likelihood. However, for sequential prediction tasks, the likelihood of hard interactions is generally not on a high level. Hence, such knowledge from mimic learning is not suitable for our tasks. To address the problem, we employ another learning experience that is mutual exclusivity knowledge of correct responses to enhance the learning of implicitly hard interactions.
As the red triangle shown in the right bottom part of Figure~\ref{framework}, the mutual exclusivity knowledge based loss is derived by employing the posterior unlikelihood of correct responses from the peer network. For each training sequence, the loss of the $j$th base network can be defined as:
\begin{equation}
\mathcal{L}_{MEK_{pos}}^{(j)} = -\frac{1}{{\vert\mathcal{I}\vert}} \sum_{i \in \mathcal{I}} (1-p^{(\neq j)}_{i,*})log(p^{(j)}_{i,*}),
\label{soft_pos}
\end{equation}
where $p^{(\neq j)}_{i,*}$ denotes the likelihood of positive label from the peer network. Note that $p^{(\neq j)}_{i,*}$ is the distillation target in conventional mimic learning \cite{DBLP:journals/corr/HintonVD15}. Differently, in our work, $(1-p^{(\neq j)}_{i,*})$ represents the mutual exclusivity knowledge that is distilled in the learning of positive samples.
Most sequential prediction tasks require predicting the next element from tens of thousands of candidates. It is intuitive that the highly similar elements might present more serious interference for the target. To this end, the mutual exclusivity knowledge is also introduced in the learning of negative samples. The sum of their loss is defined as:
\begin{equation}
\mathcal{L}_{MEK_{neg}}^{(j)} = -\frac{1}{{\vert\mathcal{I}\vert}} \sum_{i \in \mathcal{I}} \sum_{k\neq *}^{\vert\mathcal{E}\vert} p^{(\neq j)}_{i,k}log(1-p^{(j)}_{i,k}),
\label{soft_neg}
\end{equation}
where $p^{(j)}_{i,k}$ is the likelihood of the $k$th element in the likelihood distribution $\bm{p^{(j)}_{i}}$ and $p^{(\neq j)}_{i,k}$ is the likelihood of the $k$th element from the peer model. $*$ denotes the positive sample.
\subsubsection{Denoising} The interference of noisy interactions which do not reflect true preference \cite{DBLP:conf/wsdm/WangF0NC21}, is an inevitable problem when enhancing the learning of implicitly hard interactions. It is harmful to make model fit them, which may hurt the generalization \cite{DBLP:conf/icml/BengioLCW09, DBLP:conf/icml/JiangZLLF18}. Some works point out that the number of noisy interactions is less and their losses are larger \cite{DBLP:conf/aaai/Li0W19, DBLP:conf/wsdm/WangF0NC21}. As such, the shared interactions with large losses in the self-knowledge independent learning are truncated in the failure experience mutual learning. Formally, for each positive or negative sample, the truncated hard interaction loss is defined as follows:
\begin{equation}
\bar{\mathcal{L}}_{MEK_{\{pos,neg\}}}^{(j)} = \left \{
\begin{array}{ll}
0, & rank(\mathcal{L}_{SK}^{(\forall j)})\textless \beta \cdot S_L\\
\mathcal{L}_{MEK_{\{pos,neg\}}}^{(j)}, & otherwise,
\end{array}
\right.
\label{denoise}
\end{equation}
where $\beta$ is the proportion of truncated noisy interactions and $S_L$ is the size of interactions. rank($\cdot$) denotes the rank of the loss in all interactions in descending order. In Equation (\ref{denoise}), the noisy interactions are also identified by jointly conditioning on the losses from both networks.
\subsubsection{Loss Balance} To balance the knowledge between the ground-truth and the peer model, a balance factor $\alpha$ is introduced to derive the total loss of the $j$th base model as follows:
\begin{equation}
\mathcal{L}_{total}^{(j)} = \alpha\mathcal{L}_{SK}^{(j)} + (1-\alpha)(\bar{\mathcal{L}}_{MEK_{pos}}^{(j)}+\bar{\mathcal{L}}_{MEK_{neg}}^{(j)}).
\label{total}
\end{equation}
Eventually, the final loss function that is adopted to converge the proposed model is defined as follows:
\begin{equation}
\mathcal{L}_{total} = \mathcal{L}_{total}^1 + \mathcal{L}_{total}^2.
\end{equation}
\subsection{Extension to More Peers}
Notwithstanding the promising exclusivity knowledge transfer between two base networks, the proposed MED can be naturally extended to more peers with different parameters or structures. More base networks are expected to introduce such knowledge from diverse perspectives to conduct learning of implicitly hard interactions. And in the follow-up deployment, the redundant networks can be removed for reducing the computation.
Given $T$ ($T\ge 2$) base networks, the mutual exclusivity knowledge distillation can be extended as Equations (\ref{exmekpos}) and (\ref{exmekneg}). For each network, it can obtain $T-1$ hints that are introduced from the other peers. Such that, Equations~(\ref{soft_pos}) and (\ref{soft_neg}) can be regarded as a special situation with $T=2$. Here, a rescaling factor $\frac{1}{T-1}$ is introduced to ensure a balanced value of loss.
\begin{equation}
\tilde{\mathcal{L}}_{MEK_{pos}}^{(j)} = -\frac{1}{T-1} \sum^T_{c \neq j} (1-p^{(c)}_{*})log(p^{(j)}_{*}).
\label{exmekpos}
\end{equation}
\begin{equation}
\tilde{\mathcal{L}}_{MEK_{neg}}^{(j)} = -\frac{1}{T-1} \sum^T_{c \neq j} \sum_{k\neq *}^{\vert\mathcal{E}\vert} p^{(c)}_{k}log(1-p^{(j)}_{k}).
\label{exmekneg}
\end{equation}
\section{Discussion}
The key contribution of our work is to enhance the learning of implicitly hard interactions by employing training experience. To obtain more insight about it, we explore how MED works. Without loss of generality, the discussion focuses on the model $\mathcal{M}_1$. We aim to answer the following questions:
\noindent\textbf{Question 1:} \emph{Why does MED work? What does mutual exclusivity knowledge distillation bring?}
During the exchange of training experience, the parameters are usually updated along the direction of negative gradient. Without loss of generality, for each positive sample in the base model $\mathcal{M}_1$, the gradient of cross-entroy \cite{DBLP:books/lib/Murphy12} in Equation (\ref{soft_pos}) with respect to base model's logits $z^{(1)}_*$ in Equation (\ref{pj}) can be derived as:
\begin{small}
\begin{equation}
\begin{split}
&\frac{\partial {\mathcal{L}_{MEK_{pos}}^{(1)}}}{\partial {z^{(1)}_*}}=\frac{\partial {\mathcal{L}_{MEK_{pos}}^{(1)}}}{\partial {p^{(1)}_*}} \frac{\partial {p^{(1)}_*}}{\partial {z^{(1)}_*}}= -\frac{1-p_*^{(2)}}{p_*^{(1)}}\cdot p_*^{(1)}(1-p_*^{(1)}) \\
&=\underbrace{ (1-p^{(2)}_{*})(p^{(1)}_{*}-y_*)}_{\textcircled{1} }=\underbrace{p^{(1)}_{*}-y_*}_{self-knowledge}+\underbrace{p^{(2)}_{*}(y_*-p^{(1)}_{*})}_{\textcircled{2}},
\end{split}
\label{gradient}
\end{equation}
\end{small}
where $y_*=1$ is the label of positive samples. $p^{(1)}_{*}$ and $p^{(2)}_{*}$ are the likelihood of the next element.
As shown in Equation (\ref{gradient}), the final gradient is rewritten as term~$\textcircled{1}$. In this form, $(1-p^{(2)}_{*})$ can be interpreted as an importance weight of the original ground-truth label $y_*$. When base model $\mathcal{M}_2$ makes a serious mistake (i.e., $p^{(2)}_{*}\approx 0$), Equation (\ref{gradient}) is approximate to the gradient generated by the self-knowledge based loss in Equation (\ref{ik}). In this situation, base model $\mathcal{M}_2$ gives base model $\mathcal{M}_1$ a hint that the current interaction is hard to learn. And, base model $\mathcal{M}_1$ will enhance the learning of the interaction with a gradient affected by another perspective. While base model $\mathcal{M}_2$ with a higher likelihood, the gradient of the interaction will be rescaled and generate less contribution. Along this line, MED can take similar effect on negative samples.
Compared with self-knowledge independent learning, mutual exclusivity knowledge distillation contains an additional term $\textcircled{2}$ in Equation (\ref{gradient}). The gradient of implicitly hard interaction is derived by jointly conditioning on the likelihood from distinctive initializations. More views of data are introduced to enhance the learning of implicitly hard interactions. As shown in the upper-right region of Figure~\ref{framework}, the combination of prediction results and ground-truth can be divided into different levels. In particular, if base models generate inconsistent results, a trade-off gradient can be derived. Therefore, mutual exclusivity knowledge distillation conduct a hierarchical learning of different interactions.
\noindent\textbf{Question 2:} \emph{What is the difference between conventional mimic learning (learn from $p^{(2)}_*$) and MED (learn from $1-p^{(2)}_*$)?}
It is straightforward that the proposed MED can dynamically rescale the importance weights of interactions by their wrong responses, which aims to distinguish the next target from substantial candidates. The conventional mimic learning carries information from teacher to students, which emphasises similar knowledge among similar elements. In this case, the weight~$(1-p^{(2)}_*)$ in Equation (\ref{gradient}) is replaced by $p^{(2)}_*$, which means the model prefers to easy interactions. Therefore, for substantial elements in sequential prediction, MED can effectively reduce the interference, which is more suitable in our scenario.
\section{Experiments}
In this section, experiments are conducted on different datasets to validate the effectiveness of our HAIL. In particular, we aim to answer the following research questions:
\begin{itemize}[leftmargin=*]
\item {\bfseries RQ1:} How does our HAIL perform compared with the state-of-the-art sequential prediction methods?
\item {\bfseries RQ2:} How is the performance of HAIL variants with different combinations of terms in loss function (Equation (\ref{total}))?
\item {\bfseries RQ3:} What is the effect of the truncation proportion $\beta$ in denoising (Equation (\ref{denoise})) and the balance factor $\alpha$ in loss function~(Equation~(\ref{total}))?
\end{itemize}
\subsection{Experimental Setup}
\subsubsection{Dataset}
Experiments are conducted on two benchmark recommendation datasets from cyber space and two crime datasets from physical space. These datasets that are involved by humans contain more implicitly hard interactions. As shown in Table \ref{dataset}, the size of different datasets varies with the domains.
\begin{itemize}[leftmargin=*, topsep = 0 pt]
\item{\textbf{ML-1m}\footnote{https://grouplens.org/datasets/movielens/1m/}:} This is a movie ratings dataset created in February, 2003. As one of the stable benchmark datasets, most recommendation algorithms are evaluated on it.
\item{\textbf{Toys}:} Toys is a subcategory in Amazon review dataset. We obtained this dataset from \cite{DBLP:conf/cikm/ZhouWZZWZWW20}.
\item{\textbf{CHI-18}\footnote{https://data.cityofchicago.org/Public-Safety/Crimes-2001-to-present/ijzp-q8t2}:} This is a public crime dataset updated by Chicago Police Department in 2018. To achieve a more fine-grained prediction, an event is described by a simple event model (SEM) \cite{DBLP:journals/ws/HageMSHS11}. In particular, SEM can model basic events in various domains without domain-specific vocabularies. In this work, the fields about geographical information are extracted to describe generators. Then, time slots are divided every 3 hours, which is smaller than the meaningful interval 6 hours \cite{nitsure2020unlocking}. The time slot and crime type are together used to describe elements.
\item{\textbf{NYC-16}\footnote{https://data.cityofnewyork.us/Public-Safety/NYPD-Complaint-Data-Current-Year-To-Date-/5uac-w243}:} This is a crime dataset provided by New York City Police Department in 2016. Similar to Chicago, the precincts and premises are used to describe generators. The time slots and classification codes are leveraged to describe elements.
\end{itemize}
\begin{table}
\caption{Statistics of experimented datasets}
\centering
\resizebox{0.9\linewidth}{!}{
\begin{tabular}{ccccccc}
\toprule
\multirow{2}{*}{Dataset}& \multirow{2}{*}{Generator \#}& \multirow{2}{*}{Elements \#}& \multicolumn{4}{c}{Sequence Length}\\
\cline{4-7}
& & & Max.& Min.& Avg.& Std. \\
\midrule
ML-1m& 6,040& 3,416& 2,275& 16& 163.50& 192.53 \\
Toys& 19,412& 11,924& 548& 3& 6.63& 8.50 \\
\midrule
CHI-18& 2,692& 246& 3,525& 3& 96.18& 253.36 \\
NYC-16& 3,229& 440& 4,496& 3& 144.76& 429.78 \\
\bottomrule
\end{tabular}
\label {dataset}
}
\vspace{-1 em}
\end{table}
For all datasets, the elements are grouped by generators and sorted in chronological order for each generator. The inactive generators with fewer than five elements are removed to ensure the quality of prediction. Moreover, the last element in each sequence is taken as the test data and the element before the last element as the validation set. The remaining elements are used for training. The maximum length of sequence is set as 200. To ensure the sequence within the maximum length, longer sequences will be sliced into multiple sub-sequences from right to left.
\subsubsection{Metrics}
Following the common assessment means \cite{DBLP:conf/sigir/WangDH0C20, DBLP:conf/cikm/ZhouWZZWZWW20}, the performance of prediction can be assessed by top-$k$ Hit Ratio (HR$@k$), top-k Normalized Discounted Cumulative Gain (NDCG$@k$), and Mean Reciprocal Rank (MRR). In this paper, the cutoff $k$ is set as \{1,5,10\}. Note that HR@1 is equal to NDCG@1 that is a harsh metric for performance evaluation. To achieve an efficient computation in a large candidate set, 99 negative elements are randomly selected to rank with the target element. For all metrics, the higher the value, the better the~performance.
\subsubsection{Settings}
We implemented the proposed HAIL in Python with TensorFlow and conducted experiments on a commodity machine equipped with a 12GB TITAN Xp GPU. We train the model by using Adam with NOAM decay \cite{DBLP:conf/nips/VaswaniSPUJGKP17}. The batch size is set as 256. In base network, we set the layer number $L$ as 2, the head number $R$ as 2, the hidden size $d$ as 64, the intermediate size as 256. For learning hyper-parameters, $\beta$ is tuned in \{0,0.01,0.02,0.03\}, $\alpha$ is searched in \{0.1,0.2,...,0.8,0.9\}. The source code is available at GitHub\footnote{https://github.com/hukx-issac/HAIL}.
\subsection{Baselines}
To validate the effectiveness and generalization of our HAIL, we conduct a comparison with eight baselines from different domains. They are elaborated as follows:
\begin{itemize}[leftmargin=*, topsep = 0 pt]
\item {\bfseries POP}: A non-sequential baseline that simply regards the frequency of interactions as the probability of the next element.
\end{itemize}
\noindent{\bfseries Recommendation Methods:}
\begin{itemize}[leftmargin=*, topsep = 0 pt]
\item {\bfseries BERT4Rec}\cite{DBLP:conf/cikm/SunLWPLOJ19}: BERT4Rec is a session-based method adapted from the language model BERT~\cite{DBLP:conf/naacl/DevlinCLT19}. It employs bidirection information to model interactions which are not in a rigid order.
\item {\bfseries R-CE}\cite{DBLP:conf/wsdm/WangF0NC21}: An adaptive denoising training strategy (ADT) is applied for BERT4Rec to reduce the effect of hard interactions.
\item {\bfseries S$^3$-Rec}\cite{DBLP:conf/cikm/ZhouWZZWZWW20}: It utilizes mutual information maximization to capture intrinsic data correlation for sequential recommendation. For fair comparison, the extra attributes of items are removed, and the MIP and SP objectives are employed.
\item {\bfseries HyperRec}\cite{DBLP:conf/sigir/WangDH0C20}: It adopts hypergraph to model dynamic interactions between users and items in recommendation.
\end{itemize}
\noindent{\bfseries Event Prediction Methods:}
\begin{itemize}[leftmargin=*, topsep = 0 pt]
\item {\bfseries DuroNet-s}\cite{hu2021duronet}: It is a robust crime count prediction model that reduces the point-wise and the sequence-wise effect of noises. To adapt to our task, the spatial module is removed.
\end{itemize}
\noindent{\bfseries General Sequential Prediction Methods:}
\begin{itemize}[leftmargin=*, topsep = 0 pt]
\item {\bfseries Convolutional Self-attention (CSa)}\cite{DBLP:conf/nips/LiJXZCWY19}: It reduces the sensitivity to anomalies in series by utilizing causal convolution.
\item {\bfseries Informer}\cite{informer2021}: An efficient transformer-based model to capture dependence in extreme long sequences.
\end{itemize}
For BERT4Rec\footnote{https://github.com/FeiSun/BERT4Rec}, S$^3$-Rec\footnote{https://github.com/RUCAIBox/CIKM2020-S3Rec}, HyperRec\footnote{https://github.com/wangjlgz/HyperRec}, DuroNet-s\footnote{https://github.com/hukx-issac/DuroNet-for-crime-prediction}, and Informer\footnote{https://github.com/zhouhaoyi/Informer2020}, we use the code released by the authors. For CSa, we reproduce it in Pytorch. To make some regression methods adapt to our tasks, we add a shared embedding layer before and after the original model and adopt cross-entropy to train them. We adjust the hidden dimension size from \{32,64,128\}. The other hyper-parameters are set as reported in the papers. Their results are reported under the optimal settings.
\subsection{Overall Performance Comparison (RQ1)}
The comparison results with all baselines are shown in Table \ref{compbase}.
\begin{table*}[t]
\caption{Accuracy comparison with baselines on four datasets. The optimal results are denoted in bold while the suboptimal results are underlined. "$*$" indicates significant improvement.}
\resizebox{\linewidth}{!}{
\begin{tabular}{clcccccccc||cccr}
\toprule
\multirow{2}{*}{Dataset}& \multirow{2}{*}{Metric}& \multicolumn{5}{c}{Recommendation}& \multicolumn{3}{c}{Non-recommendation}& \multicolumn{2}{c}{HAIL(ours)}& Diff.& \multirow{2}{*}{Improv.}\\
\cmidrule(r){3-7}\cmidrule(r){8-10}\cmidrule(r){11-12}\cmidrule(r){13-13}
& & POP& BERT4Rec& R-CE& S$^3$-Rec& HyperRec& DuroNet-s& CSa& \multicolumn{1}{c}{Informer}& $\mathcal{M}_1$& $\mathcal{M}_2$& $\mathcal{M}_1$-$\mathcal{M}_2$& \\
\hline
\hline
\multirow{6}{*}{ML-1m} & HR@1& 0.0407& 0.3695& \underline{0.3988}& 0.2897& 0.3180& 0.1321& 0.1778& 0.0265& {\bfseries 0.4291$^*$}& 0.4252& +0.0039& 7.60\% \\
& HR@5& 0.1603& \underline{0.6851}& 0.6478& 0.6575& 0.6631& 0.3849& 0.4629& 0.1154& 0.7202& {\bfseries 0.7214$^*$}& -0.0012& 5.30\% \\
& HR@10& 0.2775& 0.7823& 0.7404& \underline{0.7911}& 0.7738& 0.5412& 0.6108& 0.2023& 0.8098& {\bfseries 0.8146$^*$}& -0.0048& 2.97\% \\
& NDCG@5& 0.1008& \underline{0.5375}& 0.5327& 0.4557& 0.5014& 0.2616& 0.3243& 0.0707& {\bfseries 0.5862$^*$}& 0.5843& +0.0019& 9.16\% \\
& NDCG@10& 0.1383& \underline{0.5690}& 0.5627& 0.5266& 0.5375& 0.3121& 0.3723& 0.0986& {\bfseries 0.6155$^*$}& 0.6134& +0.0021& 8.17\% \\
& MRR& 0.1233& \underline{0.5108}& 0.5179& 0.4535& 0.4731& 0.2615& 0.3154& 0.0922& 0.5622& {\bfseries 0.5791$^*$}& -0.0169& 13.37\% \\
\hline
\multirow{6}{*}{Toys} & HR@1& 0.0260& \underline{0.1390}& 0.1130& 0.0990& 0.1147& 0.0465& 0.0534& 0.0144& {\bfseries 0.1783$^*$}& 0.1780& +0.0003& 28.27\% \\
& HR@5& 0.1046& \underline{0.3379}& 0.3189& 0.3023& 0.2875& 0.1608& 0.1754& 0.0682& 0.3751& {\bfseries 0.3755$^*$}& -0.0004& 11.13\% \\
& HR@10& 0.1848& \underline{0.4596}& 0.4529& 0.4393& 0.3909& 0.2572& 0.2723& 0.1286& {\bfseries 0.4796$^*$}& {\bfseries 0.4796$^*$}& +0.0000& 4.35\% \\
& NDCG@5& 0.0652& \underline{0.2409}& 0.2179& 0.2021& 0.2031& 0.1040& 0.1148& 0.0407& {\bfseries 0.2802$^*$}& {\bfseries 0.2802$^*$}& +0.0000& 16.31\% \\
& NDCG@10& 0.0909& \underline{0.2802}& 0.2611& 0.2463& 0.2365& 0.1350& 0.1459& 0.0600& {\bfseries 0.3138$^*$}& 0.3136& +0.0002& 11.99\% \\
& MRR& 0.0861& \underline{0.2444}& 0.2233& 0.2081& 0.2087& 0.1211& 0.1301& 0.0628& {\bfseries 0.2812$^*$}& 0.2810& +0.0002& 15.06\% \\
\hline
\multirow{6}{*}{CHI-18} & HR@1& 0.0249& \underline{0.4421}& 0.4114& 0.3978& 0.1679& 0.1386& 0.1378& 0.3507& {\bfseries 0.4744$^*$}& 0.4703& +0.0041& 7.31\% \\
& HR@5& 0.1668& \underline{0.6861}& 0.6349& 0.6664& 0.3956& 0.4577& 0.4499& 0.5914& {\bfseries 0.7117$^*$}& 0.7099& +0.0018& 3.73\% \\
& HR@10& 0.3250& \underline{0.8024}& 0.7708& 0.7942& 0.6088& 0.6356& 0.6333& 0.7166& {\bfseries 0.8243$^*$}& 0.8228& +0.0015& 2.73\% \\
& NDCG@5& 0.0926& \underline{0.5691}& 0.5253& 0.5383& 0.2834& 0.3039& 0.2981& 0.4744& {\bfseries 0.5985$^*$}& 0.5956& +0.0029& 5.17\% \\
& NDCG@10& 0.1440& \underline{0.6068}& 0.5692& 0.5799& 0.3525& 0.3613& 0.3569& 0.5148& {\bfseries 0.6347$^*$}& 0.6321& +0.0026& 4.60\% \\
& MRR& 0.1190& \underline{0.5567}& 0.5197& 0.5243& 0.2957& 0.2961& 0.2917& 0.4650& {\bfseries 0.5853$^*$}& 0.5823& +0.0030& 5.14\% \\
\hline
\multirow{6}{*}{NYC-16} & HR@1& 0.0660& 0.4339& \underline{0.4472}& 0.3874& 0.3137& 0.1871& 0.1975& 0.3685& {\bfseries 0.4772$^*$}& 0.4754& +0.0018& 6.71\% \\
& HR@5& 0.1994& \underline{0.6931}& 0.6261& 0.6909& 0.6358& 0.5401& 0.5509& 0.6178& 0.7166& {\bfseries 0.7182$^*$}& -0.0016& 3.62\% \\
& HR@10& 0.3537& 0.8250& 0.7088& \underline{0.8287}& 0.7690& 0.7114& 0.7275& 0.7461& 0.8433& {\bfseries 0.8458$^*$}& -0.0025& 2.06\% \\
& NDCG@5& 0.1332& \underline{0.5668}& 0.5396& 0.5446& 0.4816& 0.3688& 0.3795& 0.4968& 0.6014& {\bfseries 0.6019$^*$}& -0.0005& 6.19\% \\
& NDCG@10& 0.1824& \underline{0.6095}& 0.5665& 0.5893& 0.5247& 0.4244& 0.4363& 0.5383& 0.6427& {\bfseries 0.6435$^*$}& -0.0008& 5.58\% \\
& MRR& 0.1616& \underline{0.5527}& 0.5322& 0.5245& 0.4611& 0.3511& 0.3608& 0.4862& {\bfseries 0.5893$^*$}& {\bfseries 0.5893$^*$}& +0.0000& 6.62\% \\
\bottomrule
\end{tabular}
}
\label{compbase}
\end{table*}
On the right side, we count the differences of accuracy between the base models $\mathcal{M}_1$ and $\mathcal{M}_2$, and the improvements of the best results relative to the suboptimal results. Several observations are summarized as follows:
\begin{figure*}[t]
\centering
\includegraphics[width=\linewidth]{./figure/ablation.pdf}
\caption{Ablation Study of HAIL in terms of HR$@$1. The higher histograms, the better the performance.}
\label {ablation}
\vspace{-1 em}
\end{figure*}
For non-recommendation methods, the recommendation methods outperform them in most metrics. It is possibly caused by two reasons: $1)$ the non-recommendation methods generally assume a rigidly ordered sequence and design a relatively coarse-grain regression task to predict the next counts; $2)$ most recommendation methods conduct a cloze task \cite{DBLP:conf/naacl/DevlinCLT19} to pretrain their models, which generates more samples to train the models. Both DuroNet-s and CSa employ a convolution operator to reduce the effect of noises, which smooths the representations of related elements and reduces the differences. Hence, their values of HR$@1$ are significantly lower than other metrics. Informer is a specific method for extreme long sequences. However, it seems not suitable for recommendation scenario since it yields an inconsistent performance than POP in the recommendation datasets which lengths are short.
Among recommendation methods, BERT4Rec achieves comparable performance with S$^3$-Rec and HyperRec. It indicates that BERT4Rec makes use of interaction information without modeling generator. However, they do not outperform HAIL since they learn implicitly hard interactions under self-knowledge. When further changing the learning strategy of BERT4Rec with R-CE, the performance does not present significant improvement. It demonstrates that enhancing the learning of implicitly hard interaction is effective to enrich model patterns.
Finally, by comparing all the baselines, we can find that HAIL consistently achieves significant improvements. In terms of difference, the performance of model $\mathcal{M}_1$ is highly closed to that of model $\mathcal{M}_2$, indicating that exchanging mutual exclusivity knowledge can effectively reduce the gap between two models and improve generalization performance. For the dominant performance on datasets from different domains, HAIL is proved to be generalized to a much broader cyber or physical scenarios.
\subsection{Ablation Study (RQ2)}
To investigate the effectiveness of components in mutual exclusivity knowledge distillation, we remove the positive sample term~(variant~I), the negative sample term (variant II), both of them (variant III) in the Equation (\ref{total}) and the denoising strategy (variant~IV) in the Equation (\ref{denoise}), respectively. Note that the shared embedding and prediction layers are still kept. And then, we compare their performance with the original HAIL in terms of HR$@$1, since it is a harsh metric for performance evaluation. The results are reported in Figure \ref{ablation}. We have the following findings:
\begin{itemize}[leftmargin=*]
\item \emph{Finding 1: Mutual exclusivity knowledge distillation effectively improves the performance.} Compared with variant III, the performance of original model improves relatively 2.48\%, 11.51\%, 1.76\% and 2.67\% on four datasets, respectively. It demonstrates that enhancing the learning of implicitly hard interaction can improve the generalization performance of models.
\item \emph{Finding 2: The contribution of positive sample term is robust.} When removing the positive sample term, the performance of variant I
drops obviously. For example, compared with the original model, the performance of variant I decreases relatively 2.43\%, 9.52\%, 2.47\% and 2.51\% on four datasets. Meanwhile, the negative sample term shows a little fluctuation, particularly for CHI18 dataset (the red dash line). The observation demonstrates that distilling mutual exclusivity knowledge in positive samples is more efficient. The negative sample term might be affected by the size of elements, which denotes less candidates in prediction.
\item \emph{Finding 3: The denoising strategy proves to be helpful.} Except for the benchmark ML-1m dataset, denoising is imposed on the other datasets at different degrees. Compared with the original model, using denoising strategy improves the performance by 7.16\%, 1.50\% and 1.87\% on the three datasets. This is because denoising can effectively avoid the interference of noisy interactions.
\end{itemize}
\subsection{Parameter Sensitivity (RQ3)}
\begin{figure}[t]
\centering
\includegraphics[width=0.9\linewidth]{./figure/alpha.pdf}
\caption{The analysis of parameter sensitivity (HR$@$1).}
\label {alpha}
\vspace{-1.3 em}
\end{figure}
To investigate the effect of different parameters, we tune the value of truncation proportion $\beta$ from 0 to 0.03 with a step 0.01 and the value of balance factor $\alpha$ from 0 to 1 with a step 0.1.
As shown in the first row of Figure \ref{alpha}, the bigger truncation proportion $\beta$, the greater strength of denoising. It can be observed that the performance of model directly falls or first rises and then falls with the growth of the value $\beta$. This is because the fitting of noisy interactions might mislead models. And, the performance can be improved if noises are removed. However, if limiting the noises too much, the meaningful hard interactions might be damaged and the performance decreases.
As shown in the second row of Figure \ref{alpha}, the bigger balance factor~$\alpha$, the smaller proportion of failure experience based loss. The red dash line indicates a meaningful region with a shape like "W". It implies that HAIL performs better when the ratio of two types of knowledge based learning is balanced or either of them achieves a dominated ratio. In fact, with the increase of failure experience based on loss ($\alpha$ varies from 1 to 0), the learning will step into three independent stages. To further explain this observation, the curve can be divided into three regions.
\begin{itemize}[leftmargin=*]
\item For the first stage in the right region, the proportion of self-knowledge based loss is dominated. Here, mutual exclusivity knowledge is similar to regularization, since some extra information about parameter learning can be introduced to lightly adjust the risk of overfitting.
\item For the center red region, both losses get into a balance period. In this stage, the base models can obtain a decent baseline from the self-knowledge and enhance the learning of implicitly hard interactions by employing mutual exclusivity knowledge. However, the performance decreases after the balance is broken.
\item As shown in the left region, the models mainly learn from mutual exclusivity knowledge. This stage is similar with the first stage where self-knowledge based loss is like a regularization. However, if its weight is set to 0, both the models might mislead each other.
\end{itemize}
\subsection{Evaluation w.r.t. Mutual Distillation}
To investigate the difference between mutual mimic learning \cite{DBLP:conf/cvpr/ZhangXHL18} and MED, two types of knowledge (i.e., likelihood distribution) mentioned in \S\ref{HIL} are transferred between two base models, respectively. The results from either of base models are randomly selected as the final output. As shown in Table \ref{kd}, the proposed MED is better than mutual mimic learning. It is because mutual mimic learning makes models prone to the learning of easy interactions while hard interactions might be taken for noises. However, sequential prediction is a challenging task with complex interaction patterns and substantial candidates. The proposed MED can effectively enhance the learning of implicitly hard interactions, which is more suitable for our task.
It is fair to discuss the increase of parameters and runtime. As shown in the left part of Figure \ref{framework}, this work tries to reduce parameters by introducing more shared layers. Parameters are only doubled in the base networks. In terms of the benchmark ML-1m dataset, the training time of mutual distillation is about 17 seconds for each batch while the individual model is about 9 seconds.
\begin{table}[tbp]
\caption{The comparison between conventional knowledge distillation~(mimic learning) and the proposed MED.}
\centering
\resizebox{0.9\linewidth}{!}{
\begin{tabular}{ccccccc}
\toprule
\multirow{2}{*}{Dataset}& \multicolumn{3}{c}{Mutual mimic learning \cite{DBLP:conf/cvpr/ZhangXHL18}}& \multicolumn{3}{c}{MED}\\
\cmidrule(r){2-4}\cmidrule(r){5-7}
& HR@1& NDCG@5& MRR& HR@1& NDCG@5& MRR \\
\midrule
ML-1m& 0.3952& 0.5656& 0.5386& 0.4291& 0.5862& 0.5622 \\
Toys& 0.1693& 0.2761& 0.2767& 0.1783& 0.2802& 0.2812 \\
CHI-18& 0.4699& 0.5932& 0.5815& 0.4744& 0.5985& 0.5853 \\
NYC-16& 0.4660& 0.5956& 0.5806& 0.4772& 0.6014& 0.5893 \\
\bottomrule
\end{tabular}
\label {kd}
}
\vspace{-1.5 em}
\end{table}
\section{Conclusion and Future Work}
In this paper, we highlight the effect of implicitly hard interactions. To this end, a hardness aware interaction learning framework called HAIL is proposed to enhance the learning of them. In particular, based on the proposed MED, implicitly hard interactions are identified from different perspectives. And, both base models derive training experience from each other to adjust themselves learning strategy. Extensive experiments are conducted on four datasets covering cyber and physical spaces. The results show that HAIL outperforms several state-of -the-art methods. For future work, we are interested in extending the framework to more complex sequential prediction tasks, such as multi-modal prediction, and sequence-to-sequence prediction.
\begin{acks}
This work is partially supported by the China Scholarship Council (LiuJinMei [2020] 1509, 202106950041).
\end{acks}
\bibliographystyle{ACM-Reference-Format}
\balance
|
{'timestamp': '2022-02-15T02:41:21', 'yymm': '2202', 'arxiv_id': '2202.06620', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06620'}
|
arxiv
|
\section{Discussion} \label{sec:discussion}
\paragraph{More General Notions of Duplication} We define duplicates as two sequences that \emph{exactly} match one another. We chose this definition because it mirrors an adversary's goal of exactly recovering a training sequence. However, privacy can also be compromised by approximately recovering a training sequence. To study this, one would need to analyze near-duplicates. This is a challenging open problem as it can be difficult to detect more general notions of duplication such as sequences with similar semantics but different lexical forms~\cite{cer2017semeval}.
\paragraph{Duplication and Differential Privacy} Satisfying a strong differential privacy (DP) guarantee is considered the gold standard of protecting privacy \cite{dwork2006differential}. DP guarantees that the effect of a single training sample on a model is small. However, even when training with a strong DP guarantee, data points that are exact or near-duplicates can still possibly have a large cumulative impact on the model. Consequently, deduplication is still necessary even when training with DP.
\paragraph{Duplication Beyond Text Data} Our work focuses on natural language, but datasets in domains such as images and source code also contain duplicate samples \cite{recht2018cifar10,ziegler2021rote}. Models trained on these datasets have been shown to be vulnerable to data privacy attacks. However, it remains unclear as to whether the success of these attacks is mainly due to training data duplication. Given the results of our work, it is important to evaluate the relationship between duplication and privacy in non-language domains.
\section{Introduction} \label{sec:intro}
\begin{figure}[t]
\centering
\includegraphics[trim={0.0cm 0cm 0.0cm 0.0cm},clip, width=1.0\columnwidth]{figures/gens_vs_dups_all_models.pdf}
\vspace{-1.0cm}
\caption
For a sequence duplicated $d$ times in a language model's training dataset, we measure how often that sequence is expected to occur in a set of generated text that is equal in size to the training data. \emph{Perfect Memorization} amounts to generating a sequence at the same frequency as it appears in the training data. All LMs tested show a superlinear increase in the expected number of generations (slopes~$>1$ on a log-log plot), i.e., training samples that are not duplicated are very rarely generated, whereas samples that are duplicated multiple times appear dramatically more frequently.}
\label{fig:teaser}
\end{figure}
Neural language models (LMs)---systems trained to predict the next-word in a sequence of text---have become fundamental building blocks for numerous NLP tasks and domains.
The performance and generality of these models make it important to study the extent to which they maintain the privacy of their training data, because many of their applications involve training on private information (e.g., emails, health records, chat logs, and source code).
Unfortunately, when training on private data, LMs may memorize and leak information to adversaries.
Past work has demonstrated the practicality of these so-called model inversion attacks, which can successfully recover training data with only black-box access to a trained model \cite{carlini2019secret,carlini2021extracting,inan2021training}. In particular, the strongest attack, proposed by \citet{carlini2021extracting}, recovers training data from LMs by first generating sequences from the models and then scoring those sequences with various membership inference methods. The highest-scoring sequences are classified as belonging to the training data.
\begin{figure*}[htbp]
\centering
\includegraphics[trim={0.8cm 4.2cm 0.2cm 1.0cm},clip,page=4,width=0.9\textwidth]{figures/block_diagram_updated.pdf}
\caption{\textit{Overview of our analysis.} Web-scraped text datasets that are used to train language models contain duplicated sequences, depicted in the figure as training data rows of the same color (\textit{top left}). Model inversion attacks attempt to recover training data from a trained model by first generating large amounts of text, some of which is memorized training data (\textit{top middle}). Membership inference is then performed to detect which generated sequences were copied from the training data (\textit{top right}). Our analysis focuses on the relationship between the amount a sequence is duplicated in the training data and the effectiveness of the model inversion attack at generating and detecting that sequence (\textit{bottom}).}
\end{figure*}
In this work, we show that the success of the \citet{carlini2021extracting} attack is largely due to duplicated sequences found in common web-scraped training datasets. We study transformer LMs over various parameter scales and show that (1) the attack's likelihood of recovering a particular training sequence is correlated with the number of occurrences of that sequence in the training data, and (2) overall attack effectiveness is reduced when sequence-level duplication in the training data is removed.
Concretely, we first show that the content that an LM generates is highly sensitive to sequence-level duplication in the training data. Using various sampling strategies, we generate text from LMs ranging from 117M-1.5B parameters. We consistently find a superlinear relationship between the number of times a sequence is duplicated in the training data and the rate at which that sequence is generated (e.g., Figure~\ref{fig:teaser}). For instance, a sequence that is present 10 times in the training data is on average generated ${\sim}1000\times$ more often than a sequence that is present only once. Notably, our results show that \textit{samples which are not duplicated are very rarely regenerated by language models}.
We then look at the next stage of the model inversion attack: detecting memorized training data from a set of LM generations.
We demonstrate that the membership inference methods from \citet{carlini2021extracting} are correlated with the number of duplicates of a sequence in the training data. For example, the membership inference methods have an area under the ROC curve as high as 0.90 for sequences that are duplicated many times but \textit{achieve only chance accuracy for sequences that appear only once}.
In our final set of experiments, we directly test whether retraining LMs on deduplicated training datasets can mitigate privacy risks. We find that model inversion attacks are indeed much weaker for deduplicated models: \textit{they emit ${\sim}20\times$ less training data and reduce the effectiveness of two of the three proposed membership inference methods}. All in all, our results underscore the need to remove duplicates when training privacy-sensitive models and show that past work may overestimate the effectiveness of LM privacy attacks when duplication is mitigated.
\section{How Duplication Affects The Regeneration of Training Sequences}
The first step of the \citet{carlini2021extracting} attack is to generate a large pool of sequences in hopes that some are verbatim copies from the training data. In this section, we analyze how duplication in the training data affects this stage.
Concretely, we first record the number of duplicates for each $N$-length character sequence in the training data. We then generate many times from an LM and analyze how often each $N$-length training sequence is generated as a function of its duplicate count.
Note that we also scale our calculations to simulate a scenario where we generate an amount of text equal in size to the training dataset. This allows us to directly compare the behavior of models trained on datasets of different sizes, and also compare to a theoretical model that has perfectly memorized its training data (i.e., generating from this model is identical to sampling from the training dataset).
\subsection{Regeneration is Superlinearly Related to Duplicates}
All models that we test have a superlinear relationship between the number of times a training sequence is regenerated and the number of times that sequence is duplicated in the training data. This relationship is shown in Figure \ref{fig:teaser} by the $>1$ slope on a log-log plot.
Furthermore, Figure \ref{fig:teaser} shows that the generation behavior of LMs is far from perfect memorization: sequences duplicated $d$ times in the training data are expected to be generated far fewer than $d$ times by a trained model. This is especially true for low duplicate counts, i.e., \textit{samples which are not duplicated are very rarely regenerated by language models}. This shows that the \citet{carlini2021extracting} attack---which relies on models regenerating training samples---will rarely be able to extract training data that is not duplicated.
Our finding that LMs exhibit a superlinear increase in their regeneration rates is a also novel phenomenon worthy of future study. Concretely, one would expect that LMs would exhibit ``calibrated'' generation behavior---training sequences that appear twice as frequently are twice as likely to be generated---but this is not the case for state-of-the-art models.
\subsection{Regeneration Trends Are Robust Across Experimental Setups}
Having observed an initial superlinear trend, we next measure whether this relationship is a more general phenomenon that holds across different experimental setups varying the sequence length, model size, sampling strategy, and number of training epochs.
\paragraph{Effect of Duplicate Sequence Length} Our analysis focuses on the duplication of $N$-length character sequences in the training data. To ensure that our conclusions are not dependent on any one choice of $N$, we vary the sequence length and report the results for the Mistral 345M parameter model in Figure \ref{fig:seq_length}. Using
longer sequence lengths naturally reduces the chance that a generation exactly overlaps with the training set. Nevertheless, the superlinear relationship between generation and duplication is nearly identical across different sequence lengths. For the rest of the paper we set $N = 100$ characters unless otherwise specified.
\paragraph{Effect of Model Scale} Larger models tend to regenerate more training data across all levels of duplication. This effect is shown by comparing the duplication curves for the 117M and 345M parameter Mistral models in Figure~\ref{fig:teaser}. These two models were trained nearly identically and thus the comparison controls for confounding factors such as the number of training steps and optimization hyperparameters. Larger models likely regenerate more training sequences because they achieve a lower training loss (i.e., they assign training samples higher likelihoods on average).
\paragraph{Effect of Sampling Scheme}
The amount of regeneration depends on the sampling scheme used. Figure \ref{fig:sampling_strategy} compares random, top-$k$, and temperature sampling for the Mistral 117M parameter model. We find that sampling schemes that emit more likely sequences (e.g., top-$k$ with smaller $k$) generate more verbatim training samples.
\paragraph{Effect of Increasing Epochs}
Finally, we find that the regeneration rate increases over the course of training. Figure \ref{fig:epochs} shows that as training progresses for the 117M parameter Mistral model, the regeneration rate of training sequences increases at nearly all levels of duplication. Notably, stopping early does not change the fact that language models generate disproportionately many highly-duplicated training sequences.
\begin{figure}[t]
\centering
\includegraphics[trim={0.0cm 0cm 0.0cm 0.0cm},clip, width=1.0\columnwidth]{figures/gens_vs_dups_epochs.pdf}
\vspace{-1.0cm}
\caption{We plot the effect of performing multiple training epochs on the generation behavior. Performing additional epochs has a multiplicative effect that is uniform across all duplication levels. In particular, using twice as many epochs will cause the expected number of generations to increase by approximately 3 times for all duplication levels.}
\label{fig:epochs}
\end{figure}
\section{How Duplication Affects The Detection of Training Sequences}\label{sec:generation}
\begin{figure*}[htp]
\centering
\subfigure[]{
\includegraphics[trim={0.2cm 0.5cm 0.1cm 0.35cm},clip, width=0.98\columnwidth]{figures/aurocs.pdf}
\label{fig:auroc}
}
\subfigure[]{
\includegraphics[trim={0.2cm 0.5cm 0.1cm 0.2cm},clip,width=0.98\columnwidth]{figures/tpr_at_fpr.pdf}
\label{fig:tpr}
}
\vspace{-0.4cm}
\caption{State-of-the-art membership inference methods fail to accurately detect training sequences when they are not duplicated in the training set. In \textbf{\subref{fig:auroc}}, we report the area under the ROC curve for different membership inference methods as a function of the number of duplicates. In \textbf{\subref{fig:tpr}}, we report the true positive rate at a false positive rate of 0.1\%.}
\label{fig:intro}
\end{figure*}
Thus far, we found that models rarely regenerate training sequences that are not duplicated many times. Nevertheless, the second stage of the \citet{carlini2021extracting} attack, which looks to identify the generated training sequences, may be able to flag these rare cases. To test this, we evaluate the three membership inference scoring methods ({\fontfamily{lmtt}\selectfont Reference Model}, {\fontfamily{lmtt}\selectfont zlib}, and {\fontfamily{lmtt}\selectfont Lowercase}) and stratify the results by different duplication levels.
Concretely, we bucket the samples generated from the 345M parameter Mistral model into sequences that are duplicated in the training data $d$ times, for $d = 1$ to $d=800$. We also collect a set of 25,000 negative sequences that were generated by the LM but were not in the training data. Using these two sets of samples, we measure the effectiveness of the three membership inference scores at distinguishing between the two sets.
Figure \ref{fig:auroc} shows the area under the Receiver Operating Characteristic (AUROC) curve achieved by the different membership inference scores. Notably, for generated sequences only found once in the training data, all three scores yield classifiers that are close to chance.\footnote{A random ``no-skill classifier'' has an AUROC of 0.50.} Of the three scores, the {\fontfamily{lmtt}\selectfont Reference Model} is the highest performing classifier at nearly all levels of duplication.
Following the suggestions of \citet{carlini2021membership}, we also evaluate membership inference using the True Positive Rate (TPR) at a very low False Positive Rate (FPR). This simulates the realistic evaluation setting where the prevalence of training data in a set of generated samples is very low compared to non-training data. We found that approximately 1 in 1000 generated 100-character spans are copied from the training data. Thus, we use a FPR of 0.1\%.
In Figure \ref{fig:tpr}, we show that the TPR of all three membership inference scores are highly correlated with the number of duplicates. For example, the TPR for the {\fontfamily{lmtt}\selectfont Reference Model} method is as high as 0.60 for sequences that are duplicated many times but is only 0.10 for sequences that appear once. All in all, these results show that while membership inference methods may achieve non-trivial accuracies on average over the entire generated set, \textit{most of their successes are on sequences that have been duplicated many times.}
\section{Model Inversion with Deduplicated Data}
In our final set of experiments, we directly test whether retraining LMs on deduplicated data can indeed mitigate privacy risks. In particular, we take two 1.5B parameter LMs from \citet{lee2021deduplicating}, one trained on C4 and another trained on a deduplicated version of C4.\footnote{We use the LM trained on the version of C4 that has exact duplicates removed using the suffix array-based \textsc{ExactSubstr} method. This removes exact duplicates that were at least 50 byte-pair encoding (BPE) tokens long. To ensure that we do not attempt to recover sequences shorter than 50 tokens, we set $N = 400$ characters in this experiment.}
\paragraph{Generating From Deduplicated Models} We first generate one million samples from each of the language models and measure the number of sequences copied from the training data. The top of Table~\ref{tab:model_inversion} shows the number of unique 400-character training sequences generated by each of the language models (\textit{Count}) and the percentage of all 400-character training sequences that are generated (\textit{Percent}). Respectively, these measure the total amount of information from the training data leaked by each model and the probability of a single sequence in the training data being leaked.
We find that the model trained on deduplicated data emits ${\sim}20\times$ less training data, i.e., deduplication strongly weakens the first stage of the \citet{carlini2021extracting} attack.
\paragraph{Membership Inference}
Next, we evaluate the performance of the membership inference scoring methods on the generated samples. We randomly subsample 25,000 sequences that are copied from the training data and 25,000 sequences that are novel from each of the models. All of these sequences are scored by the membership inference methods and we report the AUROC in the bottom of Table~\ref{tab:model_inversion}.
We find that {\fontfamily{lmtt}\selectfont zlib} and {\fontfamily{lmtt}\selectfont Lowercase} are considerably affected by deduplication, whereas {\fontfamily{lmtt}\selectfont Reference Model} performs almost equally as well on both models.
One factor to consider when comparing the AUROC scores between the normal and deduplicated models is that the positive samples that they are trying to detect are different. We hypothesize that in the rare circumstance that the deduplicated model does indeed regenerate a training sample, those samples may be unique in some manner. This may make the samples easier to classify, which can explain why the AUROC can remain relatively high for the deduplicated model (0.87). Further investigating the difference between the regenerations made by a normal and deduplicated model is worthy of future study.
\paragraph{Qualities of Effective Membership Inference Methods} The reasonable accuracy of the {\fontfamily{lmtt}\selectfont Reference Model} method suggests that it measures training data leakage beyond just generation-based memorization. We hypothesize that this is due to its similarity to a different notion of memorization known as counterfactual memorization \cite{zhang2021counterfactual}. A sample's counterfactual memorization compares the sample's expected likelihood under models that have and have not trained on that sample. The {\fontfamily{lmtt}\selectfont Reference Model} method is an approximation of counterfactual memorization that uses a single model trained on different training data to approximate the expected likelihood under a model that has not trained on the sample being scored. While we find that duplication and generation-based memorization are highly correlated, this result suggests that approximating other notions of memorization, such as counterfactual memorization, may lead to membership inference scores that are less sensitive to deduplication. Similar findings have been noted in \citet{watson2021importance} and \citet{carlini2021membership}.
\paragraph{Is Deduplication An Effective Defense?}
Overall, our results show that deduplication is an effective safeguard against models \textit{regenerating} their training data, which renders the first stage of existing model inversion attacks largely ineffective. Fortunately, this defense comes at little-to-no cost in model performance, as training on deduplicated data does not harm language modeling perplexity \cite{lee2021deduplicating}.
Nevertheless, in the rare cases when deduplicated models do generate training data, those samples can still be detected somewhat reliably by certain membership inference scores, especially the {\fontfamily{lmtt}\selectfont Reference Model} method.
\begin{table}[t]
\small
\centering
\begin{tabular}{clcc}
& & \thead{Normal \\ Model} & \thead{Deduped \\ Model} \\
\midrule
\multirow{2}{*}{\makecell{Training Data \\ Generated}}
& \multicolumn{1}{|l}{Count} & 1,427,212 & 68,090 \\
& \multicolumn{1}{|l}{Percent} & 0.14 & 0.007 \\
\midrule
\multirow{3}{*}{\makecell{Mem. Inference \\ AUROC}}
& \multicolumn{1}{|l}{zlib} & 0.76 & 0.67 \\
& \multicolumn{1}{|l}{Ref Model} & 0.88 & 0.87 \\
& \multicolumn{1}{|l}{Lowercase} & 0.86 & 0.68 \\
\bottomrule
\end{tabular}
\caption{Deduplicating training data drastically reduces the effectiveness of privacy attacks. We first generate 1 million 256-token samples from models trained on C4 and deduplicated C4. We then report the number of unique 400-character training sequences that are generated (\emph{Count}) and the percentage of all 400-character training sequences that are generated (\emph{Percent}). We then report the classification AUROC achieved by each of the three membership inference scores when applied to the generated sequences.}
\label{tab:model_inversion}
\end{table}
\section{Conclusion and Future Work}
To create privacy-preserving machine learning models, one must go beyond simply identifying privacy vulnerabilities and instead trace the causes of vulnerabilities back to the training algorithms, models, and datasets. We take a step towards this goal by highlighting that sequence-level duplication is a large factor behind the success of recently proposed privacy attacks on LMs.
Moreover, our finding that LMs exhibit a superlinear increase in their regeneration rates as the number of duplicates increase is a novel phenomenon worthy of future study.
We also show that past work may overestimate the effectiveness of privacy attacks when duplicates are removed from the training data. Consequently, future attack evaluations should take into account duplication as a possible confounding factor. More broadly, future attacks should be evaluated as a function of different features of the data, be it duplication or otherwise. This will allow us to better understand when attacks succeed and fail and how to defend against them.
\section*{Acknowledgements}
We thank Katherine Lee, Daphne Ippolito, Nicholas Carlini, and Adam Roberts for giving feedback on our work and providing access to the language models trained on C4 and deduplicated C4.
\section{Background and Experimental Setup}
\paragraph{Language Models} Language models take as input a sequence of tokens and output a probability distribution over the next token.
LMs are trained to maximize the likelihood of a corpus of text and can be used to generate text at test time by iteratively sampling from the next-token distribution. In practice, various strategies exist for sampling tokens, including random sampling, sampling from the top-$k$ highest probability tokens~\cite{fan2018hierarchical}, or sampling after using a temperature to sharpen the next-token distribution.
\begin{figure*}[htp]
\centering
\subfigure[]{
\includegraphics[trim={0.1cm 0cm 1.1cm 0.6cm},clip, width=0.98\columnwidth]{figures/owt_histogram.pdf}
\label{fig:owt_histogram}
}
\subfigure[]{
\includegraphics[trim={0.1cm 0cm 1.1cm 0.6cm},clip,width=0.98\columnwidth]{figures/c4_histogram.pdf}
\label{fig:c4_histogram}
}
\vspace{-0.45cm}
\caption{Web-scraped training sets are rife with duplicated sequences. Above, we plot the frequency of different amounts of duplication for 400-character sequences in the OpenWebText \textbf{\subref{fig:owt_histogram}} and C4 \textbf{\subref{fig:c4_histogram}} datasets. Note that C4 is an order of magnitude larger than OpenWebText.}
\label{fig:histograms}
\end{figure*}
\paragraph{Memorization}
The concept of ``memorization'' refers to ways that a trained model stores and consequently leaks information about its training data. Multiple notions of memorization have been studied that vary in their definitions and assumptions (see Section~\ref{sec:related_work} for further discussion). In this work we focus on generation-based memorization, where a generative model leaks information by generating exact samples from its training data~\cite{carlini2019secret}.
When studying generation-based memorization in LMs, we compare models' generation behavior with the expected behavior of a model that has perfectly fit the training data through memorization. This \textit{perfect memorization} model only assigns non-zero probability to samples seen during training and sampling from the model is identical to uniformly sampling from the training data. The perfect memorization model serves as a positive control showing how far LMs are from fully memorizing their training data.
\paragraph{Privacy Attacks} The fact that state-of-the-art LMs memorize and regenerate sequences seen during training enables attacks that compromise the privacy of their training data~\cite{carlini2019secret,inan2021training,carlini2021extracting}. In this work, we focus specifically on the \citet{carlini2021extracting} attack, which is currently the strongest and most accessible model inversion attack on LMs. While we focus on this particular attack, the implications of our analysis also hold for other attacks that leverage generation-based memorization.
The \citet{carlini2021extracting} attack works in two stages:
\vspace{-0.25cm}
\begin{enumerate}[leftmargin=15pt,itemsep=0mm]
\itemsep3pt
\item Generate a large amount of text from a language model.
\item Score the generated sequences using a membership inference scoring method.
\end{enumerate}
For the first stage, \citet{carlini2021extracting} study different methods of generating data (unconditional vs. conditional sampling, different sampling strategies, etc.). We focus on unconditional generation using standard sampling, top-$k$ sampling, and temperature sampling.
For the second stage, we study all scores proposed by \citet{carlini2021extracting}. Each score is defined as the ratio between a metric estimating the ``easiness'' of sequence (a property of the sequence itself and not whether the sequence appears in the training dataset) and the trained model's perplexity on that sequence. For measures of easiness, \citet{carlini2021extracting} used three choices:
\vspace{-0.3cm}
\begin{itemize}[leftmargin=15pt,itemsep=0mm]
\item {\fontfamily{lmtt}\selectfont \textbf{Reference Model}}: the perplexity of another LM on the sequence. We use the GPT-2 small language model~\cite{Radford2019LanguageMA}.
\item {\fontfamily{lmtt}\selectfont \textbf{zlib}}: the length of the sequence after compression by the zlib compression library.
\item {\fontfamily{lmtt}\selectfont \textbf{Lowercase}}: the trained model's perplexity on the sequence with all lowercased characters.
\end{itemize}
\paragraph{Training Data Collection and Duplication}
Modern language modeling datasets are generated by large-scale scraping of the Internet~\cite{Gokaslan2019OpenWeb,Radford2019LanguageMA,raffel2020exploring,gao2020pile}. Most web-scraped datasets are deduplicated at the \textit{document level}, e.g., if two web pages have the exact same contents, only one is kept in the data. \citet{lee2021deduplicating} observe that these datasets still have large-scale approximate and exact sequence-level duplication, e.g., quotes, paragraphs, and advertisements appearing in many web pages. To correct this, they propose efficient sequence-level deduplication methods based on locality sensitive hashing and suffix arrays.
When measuring duplication in the training data, we consider identical sequences to be duplicates. Although broader definitions such as approximate or semantic duplication may also be useful to study, we choose to investigate exact duplication in this work because it matches the adversary's goal of \emph{exactly} recovering sequences from the training data (e.g., social security numbers).
To detect duplicate sequences, we adapt the suffix array-based algorithm from \citet{lee2021deduplicating}. Searching for exactly duplicated sequences in two sets of text can be done efficiently with a linear traversal of the two texts' suffix arrays.
\begin{figure}[t]
\centering
\includegraphics[trim={0.0cm 0cm 0.0cm 0.0cm},clip, width=1.0\columnwidth]{figures/gens_vs_dups_sequence_length.pdf}
\vspace{-0.85cm}
\caption{We vary the sequence length that is used when measuring whether a model generation overlaps with the training set. Using longer sequence lengths naturally reduces the chance that a generation exactly overlaps with the training set. However, the overall shape of the generation vs. duplication curve is consistent across a range of sequence lengths.}
\label{fig:seq_length}
\end{figure}
\paragraph{Datasets}
In our experiments, we use models trained on the widely-used OpenWebText~\cite{Gokaslan2019OpenWeb} and C4~\cite{raffel2020exploring} datasets. Both are large-scale datasets, 39GB and 750GB respectively, and were generated by scraping text from the Internet with basic filtering and deduplication. Despite deduplicating at the level of whole training examples, both datasets still contain a large number of duplicated token sequences between training examples, a property that is not unique to just these two datasets \cite{lee2021deduplicating}. To illustrate this quantitatively, in Figure~\ref{fig:histograms} we show how often each unique 400-character sequence is duplicated in these two datasets. Both datasets contain millions of sequences that are duplicated 10 or more times, and some individual sequences are even duplicated tens of thousands of times. This large amount of sequence-level duplication allows us to reliably measure the effect of duplication on memorization and downstream model privacy over a wide range of duplication levels.
\paragraph{Models} We focus on Transformer-based~\cite{vaswani2017attention} language models that range in scale from millions to billions of parameters. Specifically,
we use the 117M and 345M parameter models from the Mistral project\footnote{\url{https://github.com/stanford-crfm/mistral}} and the 1.5B parameter forward language model from \citet{west2021reflective}, all of which were trained on the OpenWebText dataset. Additionally, we evaluate two 1.5B parameter models from \citet{lee2021deduplicating}, one trained on the C4 dataset and another trained on a sequence-level deduplicated version of C4. We choose this set of models as they are near-state-of-the-art, and they allow us to test the effect of model scale, changes in codebase and implementation, optimization hyperparameters, and training data.
\begin{figure*}[htp]
\centering
\subfigure[]{
\includegraphics[trim={0.2cm 0.5cm 0.1cm 0.35cm},clip, width=0.98\columnwidth]{figures/gens_vs_dups_k.pdf}
\label{fig:top_k}
}
\subfigure[]{
\includegraphics[trim={0.2cm 0.5cm 0.1cm 0.2cm},clip,width=0.98\columnwidth]{figures/gens_vs_dups_temp.pdf}
\label{fig:temp}
}
\vspace{-0.35cm}
\caption{The sampling method impacts how often LMs regenerate training samples. Sampling methods that emit more likely sequences (e.g., top-$k$ with smaller $k$ or temperature sampling with smaller $T$) generate more verbatim training samples. Nevertheless, all sampling methods rarely generate training sequences when the number of duplicates is small.}
\label{fig:sampling_strategy}
\end{figure*}
\section{Related Work}\label{sec:related_work}
\paragraph{Memorization of Training Data} \label{paragraph:memorization}
Our work is enabled by models ``memorizing''' their training data. We focus on a definition of memorization that is based on regeneration of training data. Past and concurrent work uses similar definitions and experimental setups~\cite{mccoy2021much,lee2021deduplicating,carlini2022quantifying}. \citet{mccoy2021much} observe that LMs are capable of regenerating sequences over 1,000 words long. \citet{lee2021deduplicating} find that models trained on sequence-level-deduplicated data regenerate approximately 10 times less training data. Concurrent work from \citet{carlini2022quantifying} measures the worst-case memorization of language models by conditioning on prefixes from the training data. They find that the likelihood of a model generating exact continuations from the training data scales with model size, training data duplicates, and prefix length. Compared to these results, our work studies how sequence-level duplication affects the performance of practical privacy attacks that leverage this type of memorization.
Past work has also proposed alternate definitions of memorization. \citet{feldman2020neural} and \citet{burg2021memorization} define \textit{counterfactual memorization} as the difference between a training example's expected loss under a model that has and has not been trained on that example. \citet{zhang2021counterfactual} study this form of memorization in large LMs and find that training examples that are the most memorized are sufficiently different from other examples in the training set. Our work does not focus on this definition of memorization as it assumes access to the training corpus and thus does not elicit practical privacy attacks.
\paragraph{Training Data Privacy}
Training data privacy can be compromised through membership inference attacks \cite{shokri2017membership}, which take a model and a set of samples and attempt to identify which samples have been trained on, and model inversion attacks \cite{fredrikson2015model}, which attempt to extract training data from a trained model without access to the training data. We build off of \citet{carlini2021extracting}, who propose a model inversion attack that first generates from an LM and then scores the generations based on their likelihoods relative to a baseline model.
Training data privacy can be protected using the differential privacy (DP) framework \cite{dwork2006differential}, which ensures that the effect of any single training example on the trained model is not too large. \citet{yu2021differentially,li2021large} demonstrate the practicality of training differentially private LMs. However, the privacy guarantees achieved by differentially private training are weaker than reported when datasets contain duplicated records.
|
{'timestamp': '2022-02-17T02:31:23', 'yymm': '2202', 'arxiv_id': '2202.06539', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06539'}
|
arxiv
|
\section{Electronic Submission}
\label{submission}
Submission to ICML 2022 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 \textbf{New to this year}: If your paper has appendices, submit the appendix together with the main body and the references \textbf{as a single file}. Reviewers will not look for appendices as a separate PDF file. So if you submit such an extra file, reviewers will very likely miss it.
\item Page limit: The main body of the paper has to be fitted to 8 pages, excluding references and appendices; the space for the latter two is not limited. For the final version of the paper, authors can add one extra page to the main body.
\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. \cref{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{icml2022}
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
\cref{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{39}^{th}$ International Conference on Machine Learning},
Baltimore, Maryland, USA, PMLR 162, 2022.
Copyright 2022 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\{icml2022\}}$ to
$$\mathtt{\backslash usepackage[accepted]\{icml2022\}}$$
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
2022 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.
Do not write anything on the margins.
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{icml2022.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 (they are not required to look at more than the first $8$ pages of the submitted document).
\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 protected]\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 ICML2022 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
\cref{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.
\cref{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
\cref{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{Theorems and such}
The preferred way is to number definitions, propositions, lemmas, etc. consecutively, within sections, as shown below.
\begin{definition}
\label{def:inj}
A function $f:X \to Y$ is injective if for any $x,y\in X$ different, $f(x)\ne f(y)$.
\end{definition}
Using \cref{def:inj} we immediate get the following result:
\begin{proposition}
If $f$ is injective mapping a set $X$ to another set $Y$,
the cardinality of $Y$ is at least as large as that of $X$
\end{proposition}
\begin{proof}
Left as an exercise to the reader.
\end{proof}
\cref{lem:usefullemma} stated next will prove to be useful.
\begin{lemma}
\label{lem:usefullemma}
For any $f:X \to Y$ and $g:Y\to Z$ injective functions, $f \circ g$ is injective.
\end{lemma}
\begin{theorem}
\label{thm:bigtheorem}
If $f:X\to Y$ is bijective, the cardinality of $X$ and $Y$ are the same.
\end{theorem}
An easy corollary of \cref{thm:bigtheorem} is the following:
\begin{corollary}
If $f:X\to Y$ is bijective,
the cardinality of $X$ is at least as large as that of $Y$.
\end{corollary}
\begin{assumption}
The set $X$ is finite.
\label{ass:xfinite}
\end{assumption}
\begin{remark}
According to some, it is only the finite case (cf. \cref{ass:xfinite}) that is interesting.
\end{remark}
\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{icml2022.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 \cref{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, e.g. use the actual current name of authors.
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*{Accessibility}
Authors are kindly asked to make their submissions as accessible as possible for everyone including people with disabilities and sensory or neurological differences.
Tips of how to achieve this and what to pay attention to will be provided on the conference website \url{http://icml.cc/}.
\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}
\section{Introduction}
\textbf{Background and motivation.} The stochastic bandit problem is one of the central topics of modern literature on sequential decision making, which aims to determine policies that maximize the expected reward. These policies are often learned either \textit{online} (sequentially) (see, e.g., \citep{LinUCB_2010, NIPS2017_28dd2c79, dimakopoulou2018estimation}) or \textit{offline} (statically) (see, e.g., \citep{swaminathan15a, zhou2018offline, joachims2018deep, athey2020policy}. In online problems, the agent learns through sequential interaction with the environment, adjusting the behavior for every single response. In offline learning, on the other hand, the agent learns from fixed historical data without the possibility to interact with the environment. Therefore, the agent's goal is to maximally exploit the static data to determine the best policy. However, in many application domains, batched feedback is an intrinsic characteristic of the problem, and neither setting provides a close approximation of the underlying reality \citep{marketing_DP, NIPS2011_e53a0a29, marketing_bandit, Hill_2017}. While the offline setting is not conducive to sequential learning, online learning is often curtailed by the limitations of practical applications. For example, in recommender systems and ad placement engines, treating users one at a time can become a formidable computational and/or engineering burden; in online marketing and clinical trials, environments design (campaigns/trials) and the presence of delayed feedback result in treating patients/customers organized into groups. In all of these applied cases, it is infeasible to learn truly one by one due to computational complexity or the impact of delay. In such cases, an online approach that acts on groups of observations is much more appealing from a practical point of view.
Because of the practical restrictions described above, we consider \textit{sequential batch learning} in bandit problems -- sequential interaction with the environment when responses are grouped in batches and observed by the agent only at the end of each batch. Broadly speaking, sequential batch learning is a more generalized way of learning which covers both offline and online settings as special cases bringing together their advantages.
\begin{itemize}
\item Unlike offline learning, sequential batch learning retains the sequential nature of the problem.
\item Unlike online learning, it is often appealing to implement batch learning in large-scale bandit problems as
\begin{itemize}
\item it does not require much engineering effort and resources, as experimental control over the system is unessential; and
\item it does not need resources to shorten the feedback loop in time-delayed bandit problems.
\end{itemize}
\end{itemize}
Although the batch setting is not ubiquitous in the traditional stochastic bandit formulation, there have been several attempts to extend that framework. To the best of our knowledge, \citet{Anantharam1987AsymptoticallyEA} are the first who introduced the batch problem, though a more restrictive version of it -- when the agent can choose each arm at most once in a single batch. \citet{pmlr-v51-jun16} generalized that problem by introducing budget (how many times each arm can be chosen). However, unlike our case, the authors considered the problem of identifying top-$k$ arms with high probability. The origin of our problem formulation can be traced back to \citet{Perchet_2016}, who proposed an explicit batched algorithm based on explore-then-commit policy for a two-armed batch bandit problem with a relatively small number of batches and explore its upper and lower regret bounds, giving rise to a rich line of work \citet{gao2019batched, han2020sequential, esfandiari2020regret, batchedTS}. The problem of batched bandits relates to learning from delayed or/and aggregated feedback (see, e.g., \citep{joulani2013online, vernade2017stochastic, pikeburke2018bandits}), since the decision-maker is not able to observe rewards in the interim of a batch. Although these are two similar problems, learning from delayed feedback deals with exogenous delays, whereas feedback delays in sequential batch learning are endogenous and arise as a consequence of the batch constraints \citep{han2020sequential}.
Unfortunately, a comprehensive understanding of the effects of the batch setting is still missing. Withdrawing the assumptions of online learning that have dominated much of the bandit literature raises fundamental questions as how to benchmark performance of candidate policies, and how one should choose the batch size for a given policy in order to achieve the rate-optimal regret bounds. As a consequence, it is now frequently a case in practice when the batch size is chosen for the purpose of computational accessibility rather than statistical evidence \citep{NIPS2011_e53a0a29, Hill_2017}. Moreover, while the asymptotics of batched policies is known (see, e.g., \citet{Auer_2010, cesabianchi2013online}),
the relatively small horizon performance of batch policies is much less understood while simultaneously being much more practically relevant. Thus, in this work, we make a significant step in these directions by providing a systematic study of the sequential batch learning problem.
\textbf{Main contribution \footnote{Some preliminary results have been presented at NeurIPS 2021 Workshop on Ecological Theory of Reinforcement Learning \citep{provodin2021impact}.}.}
First, we formulate a more practically relevant batch-centric sequential learning problem. Second, we provide a refined theoretical analysis and establish upper and lower bounds on the performance for an arbitrary candidate policy. In particular, we start with a more restricted analysis of the 2-armed problem, which allows us to derive a more robust result for the exact regret. Then we show that this result is partly achievable in the general setting -- only for the upper bound. As for the lower bound, we provide two results for the worst-case regret bound: more comprehensive instance-independent and more accurate instance-dependent. On the modeling side, we demonstrate the validity of the theoretical results experimentally and reflect on the optimal batch size choice.
The rest of the paper is organized as follows: The problem of sequential batch learning
is defined in Section \ref{sec:prob_formulation}. The 2-armed problem, instance-independent and instance-dependent analyses are given in Sections \ref{sec:warm-up}, \ref{sec:inst_indep}, and \ref{sec:inst_dep} respectively. In Section \ref{empirical}, we provide empirical results and finally, we conclude with Section \ref{sec:conclusion}.
\section{Problem formulation}
\label{sec:prob_formulation}
We consider a general model of \textit{sequential batch learning} in which, unlike classical online learning, we assume that the responses are grouped in batches and observed only at the end of each batch. For building up the formal notion of the batch learning setting in Section \ref{sec:batch}, we first introduce the basic notions of the classical setting in Section \ref{sec:lin_bandits}.
\subsection{Decision Procedure and Reward Structures}
\label{sec:lin_bandits}
We consider a general setting of the stochastic linear bandit problem. In this problem, the decision-maker (agent) has to make a sequence of decisions (actions or arms), possibly based on some side information, and for each decision it incurs a stochastic, although not necessarily immediately observed, reward. \footnote{We borrow notations as well as problem formulation for online setting from \citet{lattimore_szepesvari_2020}.} More formally, given a decision set $\mathcal{A}_{t} \subset \mathbb{R}^d$ (for $d<\infty$) and a time horizon $n < \infty$, at each time step $t \in \{1,2, \dots, n\}$, the agent chooses an action $A_{t} \in \mathcal{A}_{t}$ and reveals reward
\begin{equation*}
X_{t} = \langle \theta_*, A_{t} \rangle + \eta_{t}
\end{equation*}
where $\eta_{t}$ is the noise, and $\theta_*$ is the instance unknown for the agent. For simplicity, we assume each $\eta_{t}$ is 1-subGaussian: $\mathbb{E} [e^{\lambda \eta_{t}}] \leq e^{\lambda^2 / 2}, \forall t \in [n], \forall \lambda \in \mathbb{R}$. Although restrictive, this is a classical assumption for bandit literature, as it covers most reasonable noise distributions. Further, without loss of generality (since $d < \infty$), we assume $\norm{\theta_*}_2 \leq 1$.
The goal of the agent is to maximize the total reward $S_{n} = \sum_{t=1}^{n} X_{t}$. To assess the performance of a policy $\pi$, we consider regret -- difference between the agent's total reward and cumulative reward obtained by an optimal policy:
\begin{equation*}
R_n (\pi) = \mathbb{E} \left [ \sum_{t=1}^{n} \max_{a \in \mathcal{A}_{t}} \langle \theta_*, a \rangle - S_{n} \right ].
\end{equation*}
The generality of this setting lies in the choice of the decision set $\mathcal{A}_{t}$: different choices of $\mathcal{A}_{t}$ lead to different settings.
\paragraph{Stochastic bandit.} If $(e)_i$ are the unit vectors and $\mathcal{A}_{t} = \{e_1,...,e_K \}$ then the resulting stochastic linear bandit problem reduces to the finite-armed stochastic setting. We can think of the problem as an interaction between the agent and environment $\nu = (P_a : a \in \mathcal{A})$, where $\mathcal{A}:=\{1, ..., K \}$ and $P_a$ is the distribution of rewards for action $a$. At each time step $t$, the agent chooses an action $A_{t} \in \mathcal{A}$ and receives a reward $X_{t} \sim P_{A_t}$. In this case $\theta_* = (\mu_a )_{a}$, where $\mu_a = \int_{\mathbb{R}} x d P_a(x)$ is the expected reward of action $a \in \mathcal{A}$, and regret is the difference between the agents' total reward after $n$ rounds and the best reward possible given the strategy of playing a single arm:
\begin{equation}
\label{eq:regret definition}
R_n (\pi) = n \max_{a \in \mathcal{A}} \mu_a - \mathbb{E} \big [ S_{n} \big ].
\end{equation}
\paragraph{Contextual linear bandit.}
If $\mathcal{A}_{t} = \{ \psi(C_t, i): i \in [K] \}$, where $\psi: \mathcal{C} \times [K] \xrightarrow{} \mathbb{R}$ is a feature map and $C_t \in \mathcal{C}$ is a context observed by the agent at timestep $t$, then we have a contextual linear bandit. To illustrate how the above quantities arise in practice we give an example. Suppose, at the beginning of round $t$, a customer characterized by context $C_t$ visits a website selling books. When the agent applies action $A_t$ (recommends a book) to the customer, a reward $r_t(C_t, A_t)$ is obtained. The contextual linear bandit settings assumes that the expected reward $\mathbb{E}[r_t(c, a)]$ is a parametrized mean reward function $g_{\theta}(\cdot)$ of feature vector $\psi(\cdot, \cdot)$, formally, $\mathbb{E}[r_t(c, a) \text{ } | \text{ } C_t, A_t] = g_{\theta}(\psi(C_t, A_t))$. Note that the linear contextual bandits setting then corresponds to $g_{\theta}(\cdot) = \langle \theta, \cdot \rangle$.
\subsection{Sequential batch learning}
\label{sec:batch}
In the standard online learning setting, the decision maker immediately observes the reward $X_t$ after selecting action $A_t$ at time step $t$. Consequently, in selecting $A_{t+1}$, the decision maker can base his decision on the on the current decision set $\mathcal{A}_{t+1}$ and past history. Here, the past at time step $t > 0 $ is defined as
\begin{equation*}
H_{t} = (A_1, X_1, ... , A_{t}, X_{t}) \in
\mathbb{R}^{(d+1)t} \equiv \mathcal{H}_{t}
\end{equation*}
which is the sequence of action-reward pairs leading up to the state of the process at the previous time step $t$. Note that $H_0 = \emptyset$. Let $\setofdist(X)$ be a set of all probability distributions over a set $X$. As such, a policy is a finite sequence $\pi = (\pi_{t})_{1 \leq t \leq n}$ of maps of histories to distributions over actions (decision rules), formally, $\pi_t : \mathcal{H}_{t-1} \xrightarrow{} \setofdist(\mathcal{A}_{t})$. Intuitively, following a policy $\pi$ means that in timestep $t$, the distribution of the action $A_t$ to be chosen for that timestep is $\pi_{t}(H_{t-1})$: the probability that $A_{t} = a$ is $\pi_{t}(a | H_{t-1})$. Thus, when following a policy $\pi$, in timestep $t$ we get that
\begin{equation*}
\mathbb{P}_{\nu, \pi}(A_{t} = a | H_{t-1}) = \pi_{t}(a | H_{t-1}).
\end{equation*}
In contrast to conventional approaches that require the reward to be observable after each choice of the action, our setting assumes only that rewards are released at specific predefined timesteps. Denote by $\mathcal{T} = t_1,...,t_{M}$ a grid, which is a division of the time horizon $n$ to $M$ batches of equal size $b$, $1 = t_1 < ... < t_{M} = n, t_{j} - t_{j-1} = b$ for all $j=1,..., M$. Without loss of generality we assume that $n=b M$, otherwise we can take $n:= \left\lfloor \frac{n}{b} \right\rfloor b $. Recall that in the batch setting the agent receives the rewards after each batch ends, meaning that the agent operates with the same amount of information within a single batch. For simplicity, we assume that as long as the history remains the same the decision rule does not change as well. Note that this assumption does not impose any significant restrictions. Indeed, instead of applying a policy once, one can always do it $b$ times until the history updates. Thus, a batch policy is also a finite sequence of $\pi = (\pi_{t})_{1 \leq t \leq n}$ of decision rules: $\pi_t : \mathcal{H}_{t-1} \xrightarrow{} \setofdist(\mathcal{A}_{t})$. However, not the whole past history is available for the agent in timestep $t$, formally, $H_t = H_{t_{j}}$ for any $t_j < t \leq t_{j+1}$.
In practice, sequential batch learning is usually considered as a limitation of the environment. However, for notation convenience, despite the batch setting being a property of the environment, we consider this limitation from a policy perspective. With this, we assume that it is not the online agent who works with the batch environment, but the batch policy interacts with the online environment. To distinguish between online and batch policies we will denote the last as $\policy^{\batchsize} = (\policy^{\batchsize}_{t})_{1 \leq t \leq n}$.
We now are ready to formulate the goal of the paper formally. That is, given a policy $\pi$, we aim to establish upper and lower regret bounds of its batch specification $\policy^{\batchsize}$.
\subsection{Preliminaries}
\label{sec:preliminaries}
Before proceeding, we will need to distinguish between ``good" and ``bad" policies on the basis of some properties.
Accordingly, we first define a binary relation on a set of policies. We say that the decision rule $\pi_t = \pi_t(\cdot|H_{t-1})$ is not worse than the decision rule $\pi_t^{\prime} = \pi_t^{\prime}(\cdot|H_{t-1})$ (and write $\pi_t \geq \pi_t^{\prime}$) if the expected reward under $\pi_t$ is not less than the expected reward under $\pi_t^{\prime}$:
\begin{equation}
\label{better policy}
\sum_{a \in \mathcal{A}_{t}} \langle \theta_*, a \rangle \pi_t(a|H_{t-1}) \geq \sum_{a \in \mathcal{A}_{t}} \langle \theta_*, a \rangle \pi_t^{\prime}(a|H_{t-1}).
\end{equation}
If $\geq$ can be replaced by $>$, we say that the decision rule $\pi_t$ is better than the decision rule $\pi_t^{\prime}$ (and write $\pi_t > \pi_t^{\prime}$).
Define the informativeness of history by the number of times the optimal actions were chosen in it. Formally, let $T_{a^{\ast}}(\pi, t) = \sum_{s=1}^{t} \mathbb{I} \{A_t = A_t^*\}$ be the number of times policy $\pi$ made optimal decisions in history $H_{t}$. Then, we require that the decision rule based on a more informative history is at least as good as the decision rule based on a less informative history:
\begin{assumption}[Informativeness]
\label{variance_contractions}
Let $T_{a^{\ast}}(\pi, t)$ and $T^{\prime}_{a^{\ast}}(\pi, t)$ be numbers of times the optimal actions were chosen in histories $H_{t}$ and $H^{\prime}_{t}$, correspondingly. If $T_{a^{\ast}}(t) \geq T^{\prime}_{a^{\ast}}(t)$, then $\pi_{t+1}(\cdot|H_{t}) \geq \pi_{t+1}(\cdot|H^{\prime}_{t})$.
\end{assumption}
Next, we assume that policy $\pi = (\pi_{t})_{1 \leq t \leq n}$ improves over time if the ``rate" of increasing of the regret decreases.
\begin{assumption}[Subliniarity]
\label{policy_improvement}
$\frac{R_{n_1}(\pi)}{n_1} > \frac{R_{n_2}(\pi)}{n_2}$ for all $n_1, n_2$, $1 \leq n_1 < n_2 \leq n$.
\end{assumption}
Finally, we impose a monotonic lower bound on the probability of choosing the optimal arm at timestep $t$. Here we consider two assumptions: instance-independent and instance-dependent monotonicity. That is, in the former case, we assume the existence of the lower bound $f(t)$, no matter what instance $\theta$ is given; while in the latter case -- the existence of the lower bound depends on a specific instance of actions $\theta$: $f:=f_{\theta}$. Like in instance-independent regret analysis, this bound may imply a tighter worst-case bound rather than in an instance-independent case.
\begin{assumption}[Instance-independent monotonicity]
\label{monotonicity}
For any suboptimal action $a$, $a \in \mathcal{A}_{t}$ and $a \notin \arg \max_{\mathcal{A}_{t}} \langle \theta_*, a \rangle$, there exists a function $f_{a}:[0, \infty) \xrightarrow{} [0, 1] $ such that: (i) $f_{a}$ is nonincreasing; (ii) $\pi_t(a|H_{t-1}) \leq f_{a}(t)$ for all $t > 0$; and (iii) $f(t) := 1 - \sum_{a} f_{a}(t)$ is a strictly increasing function for all $ t > 0$ unless $f(t)=1$. \footnote{Note that from (ii) and (iii) it follows that for all $t$, $\pi_t(a^{\ast}|H_{t-1}) \geq f(t)$.}
\end{assumption}
\begin{assumption}[Instance-dependent monotonicity]
\label{instance_dependent_monotonicity}
For any suboptimal action $a$, $a \in \mathcal{A}_{t}$ and $a \notin \arg \max_{\mathcal{A}_{t}} \langle \theta_*, a \rangle$, there exists a function $f_{\theta, a}:[0, \infty) \xrightarrow{} [0, 1] $, depending on $\theta$, such that: (i) $f_{\theta, a}$ is nonincreasing; (ii) $\pi_t(a|H_{t-1}) \leq f_{\theta, a}(t)$ for all $t > 0$; (iii) $f_{\theta}(t) := 1 - \sum_{a} f_{\theta, a}(t)$ is a strictly increasing function for all $ t > 0$ unless $f_{\theta}(t)=1$; and (iv) $f_{\theta}(t)$ is nondecreasing in its instance argument in the following sense: $f_{\theta_1}(t) < f_{\theta_2}(t)$ for all $t>0$ if $\langle \theta_1, a \rangle < \langle \theta_2, a \rangle$ for all suboptimal action $a$.
\end{assumption}
The validity discussion of the imposed assumptions can be found in Appendix \ref{app:discussion}.
So to conclude this section, we provide some properties of a policy with sublinear regret that we will use further. The proof of the following lemma is presented in Appendix \ref{sec:lemma3.5}.
\begin{lemma}
\label{lemma_propeties}
Let $\pi = ( \pi_t )_{1 \leq t \leq n}$ be a policy such that Assumption \ref{policy_improvement} holds. Then,
\begin{enumerate}
\item
\label{point1}
$\Bar{\pi}_{n_2} > \Bar{\pi}_{n_1}$, where $\Bar{\pi}_{t} = \frac{\sum_{s=1}^{t} \pi_s}{t}$ is an average decision rule;
\item
\label{point2}
$\pi_{t} > \Bar{\pi}_{t}$ $\forall t$ such that $1 \leq t \leq n$,
\end{enumerate}
where $\pi_t + \pi_s$ is an elementwise addition of two probability vectors for some $t, s$.
\end{lemma}
\section{Batch learning for 2-armed bandits}
\label{sec:warm-up}
In this section, we provide lower and upper bounds on the best achievable performance for 2-armed stochastic bandits. We start with a more restricted analysis of 2-armed problem because, first, it allows to derive a stronger result, and, second, it gives better insight into the analysis.
Intuitively, if policy $\pi$ is good enough, it should be better than policy $\policy^{\batchsize}$ because it makes its decisions (``good decisions") having the maximum available information about the environment. Nevertheless, batch policy $\policy^{\batchsize}$ is a batch specification of ``good" policy $\pi$, and and we expect it to perform relatively well. The following theorem formalizes the described above intuition.
\begin{theorem}
\label{thm1}
Let $\pi^b$ be a batch specification of a given policy $\pi$, $K=2$, and $M = \frac{n}{b}$. Suppose that assumptions \ref{variance_contractions} and \ref{policy_improvement} hold. Then, for $b>1$,
\begin{equation}
\label{main_thm}
R_n(\pi) < R_n(\policy^{\batchsize}) \leq b R_M(\pi).
\end{equation}
\end{theorem}
\begin{remark}
\label{rmk:short_policy}
We can consider the term $b R_M(\pi)$ as $b$ similar online independent agents operating in the same environment by following policy $\pi$ but over a shorter horizon $M$. However, we can also think of it as the performance of a batch policy. Indeed, imagine a na\"ive agent that deliberately repeats each step $b$ times instead of immediately updating its beliefs and proceeding to the next round as in an online manner. Then, after $b$ repetitions (after a batch ends), it updates its beliefs using only the first reward from the previous batch. So, while this policy could perform as an online policy within these repetitions, it pretends that rewards are not observable and acts using the outdated history (just like a batch policy does). For notational simplicity, we refer to this policy as online ``short" policy and denote it by $\pi^{\prime}$. Thus, the theorem allows benchmarking any batch policy in terms of its online analogs. Note that there is no behavioral difference between the original policy $\pi$ and the ``short" policy $\pi^{\prime}$ (see Appendix \ref{sec:pol_spec_up_hist} for more details).
\end{remark}
\begin{proofoutline}
First, we analyze the performance of the three policies $\pi$, $\policy^{\batchsize}$, and $\pi^{\prime}$ within a batch. We show that if at the beginning of a batch the online policy $\pi$ is not worse than the batch policy $\policy^{\batchsize}$, which in turn is not worse than the online ``short" policy $\pi^{\prime}$, then, by the end of the batch, we get the corresponding regrets being related reversely. Next, exploiting the fact that $K = 2$ and using Assumption \ref{variance_contractions}, we establish that the transition from the end of one batch to the beginning of the next batch retains the relation between policies. Finally, we put both steps together and verify that the total regret satisfies the inequality (\ref{main_thm}).
\textbf{Within batch.} Assume that in timestep $t_{j}$ the decision rule of the online policy is not worse that than the decision rule of the batch policy, which is not worse than the decision rule of the online ``short" policy, $\pi_{t_j} \geq \policy^{\batchsize}_{t_j} \geq \pi^{\prime}_{t_j}$. Since the online policy $\pi$ improves within a batch (by Assumption \ref{policy_improvement}) and both the batch policy $\policy^{\batchsize}$ and online ``short" policy $\pi^{\prime}$ remain the same within a batch (by the definition of batch policy), by applying Lemma \ref{lemma_propeties} we have $\pi_{t} > \policy^{\batchsize}_{t} \geq \pi^{\prime}_{t}$ for any timestep $t_{j} < t < t_{j+1}$. So, starting at the beginning of a batch with $\pi_{t_j} \geq \policy^{\batchsize}_{t_j} \geq \pi^{\prime}_{t_j}$ leads us to $\pi_{t_{j+1}-1} > \policy^{\batchsize}_{t_{j+1}-1} \geq \pi^{\prime}_{t_{j+1}-1}$ at the end of the batch.
\textbf{Between batches.}
Let $H_{t_{j}-1}$, $H^b_{t_{j}-1}$, $H^{\prime}_{t_{j}-1}$ be histories collected by policies $\pi$, $\policy^{\batchsize}$, $\pi^{\prime}$ by the timestep $t_{j}$, correspondingly. Transiting from timestep $t_{j}-1$ to timestep $t_{j}$ leads us to a new batch, and all policies are being updated in this step. To show that the relation between batch policy and its bounds holds, we need to analyze how much information was gained by three policies, namely, we need to show that
\begin{equation*}
\mathbb{E} \left [ T_{a^{\ast}}(\pi, t_{j}) \right ] \geq \mathbb{E} \left [ T_{a^{\ast}}(\policy^{\batchsize}, t_{j}) \right ] \geq \mathbb{E} \left [ T_{a^{\ast}}(\pi^{\prime}, t_{j}) \right ].
\end{equation*}
This is where we make the use of the fact that $K=2$. Then, we just apply Assumption $\ref{variance_contractions}$.
\end{proofoutline}
The full proof of Theorem \ref{thm1} is presented in Appendix \ref{sec:mainthm_proof}.
\section{Batch learning for stochastic linear bandits}
\label{sec:main_res}
So far, we have concentrated on the stochastic bandit problem with two actions. We now conclude with an analysis of the general stochastic linear bandit problem introduced in Section \ref{sec:lin_bandits}. As we mentioned in the proof of Theorem \ref{thm1}, in the case of $K=2$, it immediately follows that the more often a decision rule chooses the optimal action, the better it is. In contrast, this is not generally true when $K>2$. Indeed, some decision rules might value the optimal and the worst actions so that another decision rule that puts less weight on optimal action is better (because it chooses interim actions more often at the expense of worst action). Consequently, the case of $K>2$ introduces a new subtlety and requires a number of additional steps in the analysis.
Because of the subtlety above, we split the main result into two separate statements. First, we analyze batch and ``short" online policies.
\begin{theorem}
\label{main_thm:short}
Let $\pi^b$ be a batch specification of a given policy $\pi$ and $M = \frac{n}{b}$. Suppose that assumptions \ref{variance_contractions} and \ref{policy_improvement} hold. Then, for $b>1$,
\begin{align*}
R_n(\policy^{\batchsize}) \leq b R_M(\pi).
\end{align*}
\end{theorem}
\begin{proofoutline}
Both policies start off similarly, but ``short" online policy starts lagging behind after the first batch because it ``throws away" a lot of information. As a result, ``short" online policy will never overtake batch policy.
\end{proofoutline}
Next, we introduce two meta-algorithms that allow us to derive result similar to Theorem \ref{thm1} —specifically, utilizing Assumptions \ref{monotonicity} and \ref{instance_dependent_monotonicity}, we consider the instance-independent and the instance-dependent cases separately (Theorem \ref{main_thm:long} and \ref{main_thm2:long} correspondingly). While the instance-independent case has the opportunity to forge a truly integrative result, providing a comprehensive analysis of a worst-case regret, the instance-dependent case allows conducting a more thorough analysis of stochastic bandits, offering potentially tighter bounds.
\subsection{Instance-independent analysis}
\label{sec:inst_indep}
\begin{algorithm}[tb]
\caption{Learning with delayed start}
\label{alg1:dealayed_batch_learn}
\begin{algorithmic}
\STATE {\bfseries Input:} horizon $n \geq 0$, candidate policy $\pi$, na\"ive policy $\pi^0$, monotonic lower bound $f$
\STATE $t \gets 1$
\STATE $H_0 \gets \emptyset$
\STATE $\tau = \min_{j} \{ t_{j}: f(t_{j}) > 0 \}$
\REPEAT
\STATE $A_t \gets \pi^0(\cdot)$
\STATE $H_{t} \gets$ \textsc{UpdateHistory}
\STATE $t \gets t+1$
\UNTIL{$t < min\{\tau, n \}$}
\REPEAT
\STATE $A_t \gets \pi(\cdot|H_{t-1})$
\STATE $H_{t} \gets$ \textsc{UpdateHistory}
\STATE $t \gets t+1$
\UNTIL{$t \leq n$}
\end{algorithmic}
\end{algorithm}
\paragraph{Intuition.}
From Assumption \ref{monotonicity}, it follows that after timestep $\tau := \min\{t: f(t) > 0 \}$ policy $\pi$ in the worst-case: (i) chooses the optimal action with non-zero probability; and (ii) acts more optimally within each consequent timestep. As such, while batch and online ``short" policies ($\policy^{\batchsize}$ and $\pi^{\prime}$) remain the same, online policy $\pi$ gets better in the worst case and, therefore, chooses optimal action more often, providing lower regret. Thus, to get the desired result for the general case, it is enough to split the horizon $n$ into two phases: before and after timestep $\tau$, and ensure that all three policy specifications behave similarly during the first phase. That is to say, some na\"ive policy $\pi^0$ operates independently of history $H_{t}$ during phase 1.
To capture the logic above, we adjust the learning process, which can be represented as a meta-algorithm built upon a given policy $\pi$ (see Algorithm \ref{alg1:dealayed_batch_learn}). As the name suggests, while performing na\"ively during phase 1, Algorithm \ref{alg1:dealayed_batch_learn} keeps all three specifications' regrets similar and, therefore, allows formulating the following result. \footnote{Note that \textsc{UpdateHistory} can be implemented differently depending on a particular task or specification (see Appendix \ref{sec:pol_spec_up_hist} for more details).}
\begin{theorem}
\label{main_thm:long}
Let $\pi^b$ be a batch specification of a given policy $\pi$, $M = \frac{n}{b}$. Suppose that assumptions \ref{variance_contractions}, \ref{policy_improvement}, and \ref{monotonicity} hold. Also, assume that policy $\Tilde{\pi}$ represents a policy constructed following Algorithm \ref{alg1:dealayed_batch_learn} for a given candidate policy $\pi$. Then, for $b>1$,
\begin{align*}
\underline{R_n(\Tilde{\pi})} < & \underline{R_n(\Tilde{\pi}^{b})} \leq b \underline{ R_M(\Tilde{\pi})},
\end{align*}
where $\underline{R_n(\pi)}$ is the worst case-regret.
\end{theorem}
\begin{proofoutline}
First, we split the total regret into two terms and notice that the first term is the same for all three regrets, as the same na\"ive policy $\pi^0$ operates during the first phase:
\begin{align*}
R_n(\Tilde{\pi}) & = R_{1:\tau-1}(\pi^0) + R_{\tau:n}(\pi). \\
\end{align*}
Let $A_{t}^* = \arg \max_{\mathcal{A}_{t}} \langle \theta_*, a \rangle$ be an optimal action for round $t$. Next, we express the second term as a sum of instantaneous regrets and exploit Assumption \ref{monotonicity}:
\begin{align*}
R_{\tau:n}(\pi) & = \mathbb{E} \left ( \sum_t \langle \theta_*, A_{t}^* - A_{t} \rangle \right ) \\
& = \sum_t \sum_{a} \langle \theta_*, A_{t}^* - a \rangle \pi_{t} \left ( a \right ) \\
& \leq \sum_t \sum_{a \neq A_{t}^*} \langle \theta_*, A_{t}^* - a \rangle f_{a} \left ( t \right ) = \underline{R_{\tau:n}(\pi)}.
\end{align*}
Finally, we reproduce Theorem \ref{thm1} for
$\underline{R_{\tau:n}(\pi)}$,
changing assumption $K=2$ on the properties of function $f(t)$. More precisely, instead of using an assumption of $K=2$, we use: (i) $f_{a}$ is nonincreasing for any suboptimal action $a$ and (ii) $f$ is increasing with high probability. Because of these two facts, $\avpolicy{{l}} > \avbatchpolicy{{l}} \geq \avdumnpolicy{{l}}$ implies $\avpolicy{{l}}(A_{t}^*) > \avbatchpolicy{{l}}(A_{t}^*) \geq \avdumnpolicy{{l}}(A_{t}^*)$ for $1 \leq l < j$. Putting all the steps together, we get:
\begin{align*}
\underline{R_n(\Tilde{\pi})} & := R_{1:\tau-1}(\pi^0) + \underline{R_{\tau:n}(\pi)} \\
& \leq R_{1:\tau-1}(\pi^0) + \underline{R_{\tau:n}(\policy^{\batchsize})} = : \underline{R_n(\Tilde{\pi}^{b})} \\
& \leq R_{1:\tau-1}(\pi^0) + b \underline{R_{\tau:n}(\pi)} =: b \underline{R_M(\Tilde{\pi})}.
\end{align*}
\end{proofoutline}
\begin{remark}
Note that there are two critical differences between Theorems \ref{thm1} and \ref{main_thm:long}: the presence of Algorithm \ref{alg1:dealayed_batch_learn} and the worst-case regret bounds in the latter. Both differences have the same root – monotonic lower bound imposed on the probability of choosing the optimal action (Assumption \ref{monotonicity}). In order to provide the same result in Theorem \ref{main_thm:long} as in Theorem \ref{thm1}, one would need a similar assumption imposed on the exact probability of choosing the optimal action. However, this would be a very restrictive assumption.
\end{remark}
\subsection{Instance-dependent analysis}
\label{sec:inst_dep}
\begin{algorithm}[tb]
\caption{Approximate learning with delayed start}
\label{alg2:dealayed_batch_learn}
\begin{algorithmic}
\STATE {\bfseries Input:} horizon $n \geq 0$, candidate policy $\pi$, number of actions $K$, monotonic lower bound $f_{\cdot}$, confidence level $\delta$
\STATE $\pi^0 \gets Unif(K)$
\STATE $phase1 \gets \texttt{False}$
\STATE $t \gets 1$
\STATE $H_0 \gets \emptyset$
\REPEAT
\STATE $A_t \gets \pi^0(\cdot)$
\STATE $H_{t} \gets$ \textsc{UpdateHistory}
\STATE $phase1 \gets$ \textsc{CheckPhase}($H_{t}$, $\delta$)
\STATE $t \gets t+1$
\UNTIL{($phase1$ is \texttt{False} {\bfseries and} $t \notin \mathcal{T}$ ) {\bfseries or} $t \leq n$}
\REPEAT
\STATE $A_t \gets \pi(\cdot|H_{t-1})$
\STATE $H_{t} \gets$ \textsc{UpdateHistory}
\STATE $t \gets t+1$
\UNTIL{$t \leq n$}
\end{algorithmic}
\end{algorithm}
The instance-dependent analysis involves the concept of more or less 'difficult' environments for the agent to learn in. Theoretically, this concept makes no sense in linear bandits as it depends on actions at the agent's disposal.
\footnote{ Intuitively, if $|\mathcal{A}_{t}| = \infty$ (e.g., $\mathcal{A}_{t} = \{ a : \norm{a}_2 \leq t \}$), each environment would be the same for the agent as for each timestep $t$ and any instance $\theta_*$ there is the unique optimal arm $A_t^*$, but no the second best action. In contrast, if $|\mathcal{A}_{t}| < \infty$, changes in the instance vector parameter $\theta_*$ would lead to other environments, but whether those environments are more or less 'difficult' depends on $\mathcal{A}_{t}$. If $A_t^*$ varies over time, there also might be a case that change in the instance parameter $\theta_*$ would lead to more difficult environments for some timesteps but less difficult for others; and the overall result would be incomparable. }
Therefore, we consider the case of stochastic bandits further. Recall that in this case $\mathcal{A}_{t} = \{e_1,...,e_K \}$ for all $t$, $\mathcal{A}:=\mathcal{A}_t$, and the instance is presented by true rewards $\theta_* = (\mu_1, ..., \mu_{K})$.
\paragraph{Intuition.}
Similar to the previous section, by Assumption \ref{instance_dependent_monotonicity}, after timestep $\tau_{\theta_*} := \min\{t: f_{\theta_*}(t) > 1/K \}$ policy $\pi$ in the worst-case scenario: (i) behaves better than the policy that acts uniformly
at random; and (ii) acts more optimally within each consequent timestep. However, it now depends on vector of rewards $\theta_*$, which is unknown for policy $\pi$, and, as a consequence, we do not know where we should stop phase 1 to bring the previous reasoning to life. But what if one could find an estimate $\hat{\tau}$ of true $\tau_{\theta_*}$ such that $f_{\theta_*}(\hat{\tau})$ is greater than $1/K$ with high probability for some confidence level $\delta$ (i.e., $\mathbb{P}(f_{\theta_*}(\hat{\tau}) > 1/K)>1-\delta$)? Then we could split the original horizon $n$ into two parts (phases) and: (i) run a uniform random policy in phase 1 (before timestep $\hat{\tau}$); and (ii) apply policy $\pi$ in phase 2 (after timestep $\hat{\tau}$). Algorithm \ref{alg2:dealayed_batch_learn} illustrates the logic above.
\footnote{There is a slight difference between Algorithms \ref{alg1:dealayed_batch_learn} and \ref{alg2:dealayed_batch_learn} in the definition of $\tau$ and na\"ive policies. The reason is that we take advantage of knowing $K$ in the latter case. Therefore, we can assume that $\pi^0$ is a uniform policy and define $\tau$ as timestep when a candidate policy $\pi$ is better than uniform policy in the worst-case.}
Note that procedure \textsc{CheckPhase} plays a crucial role in the analysis and discussed separately after the main result.
\begin{theorem}
\label{main_thm2:long}
Let $\pi^b$ be a batch specification of a given policy $\pi$, $M = \frac{n}{b}$, and \textsc{CheckPhase} be with the failure probability $\delta$ (Theorem \ref{thm:check_phase}). Suppose that assumptions \ref{variance_contractions}, \ref{policy_improvement}, and \ref{instance_dependent_monotonicity} hold. Also, assume that policy $\Tilde{\pi}$ represents a policy constructed following Algorithm \ref{alg2:dealayed_batch_learn} for a given candidate policy $\pi$. Then, for $b>1$,
\begin{align*}
\underline{R_n(\Tilde{\pi})} < & \underline{R_n(\Tilde{\pi}^{b})} \leq b \underline{ R_M(\Tilde{\pi})}
\end{align*}
with probability $1-\delta$, where $\underline{R_n(\pi)}$ is the worst-case regret.
\end{theorem}
\begin{remark}
It may seem that Theorem \ref{main_thm2:long} provides a worse result than Theorem \ref{main_thm:long}, whereas it requires additional analysis of \textsc{CheckPhase} procedure. However, as mentioned in Section \ref{sec:preliminaries}, instance-dependent bounds are usually tighter than universal ones. Therefore, even though Theorem \ref{main_thm2:long} holds with probability $1-\delta$, it can provide tighter bounds.
\end{remark}
\paragraph{\textsc{CheckPhase} procedure} Since function $f_{\theta}$ decreases in its instance argument in a certain sense (point (iv), Assumption \ref{instance_dependent_monotonicity}), it suffices to find a more ``difficult" environment with instance $\hat{\theta}$ (and corresponding $\hat{\tau} := \min\{t: f_{\hat{\theta}}(t) > 1/K \}$), such that $\mathbb{P}(f_{\theta_*}(\hat{\tau}) > 1/K)>1-\delta$). Intuitively, the smaller the difference between a suboptimal and the optimal actions ($\Delta_{a}:=\max_a \mu_{a} - \mu_{a}$), the more difficult it is to distinguish the optimal action and, therefore, the probability of choosing the optimal action should be smaller. Imagine now that after timestep $t$, we have some estimate $\tilde{\theta}_t$ of the unknown parameter vector $\theta_*$ and confidence set $\mathcal{C}_t$ that contains $\theta_*$ with high probability. Then, we can choose $\hat{\theta}$ that underestimates the true reward along the current best action and overestimates the true rewards along all other actions. Since the true rewards are independent of each other in stochastic bandits, we are able to do it, whereas in the linear bandit case, we would get a conflict among possible $\hat{\theta}$. Algorithm \ref{alg3:check_phase} formalize the logic above.
\begin{algorithm}[tb]
\caption{\textsc{CheckPhase}}
\label{alg3:check_phase}
\begin{algorithmic}
\STATE {\bfseries Input:} history $H_{t}$, confidence level $\delta$
\STATE $phase1 = \texttt{True}$
\STATE $i = \arg \max_{j} \hat{\mu}_j(t)$
\STATE $LCB_{i,t} = \sqrt{\frac{\ln t}{T_i(t)}}$
\STATE $l = \arg \max_{j \neq i} \hat{\mu}_j(t)$
\FOR{ $l \neq i$}
\STATE $UCB_{l,t} = \sqrt{\frac{\ln t}{T_l(t)}}$
\ENDFOR
\STATE $\hat{\theta} = \left ( \hat{\mu}_i(t) - LCB_{i,t}, \bigcup_{l \neq i} \hat{\mu}_l(t) + UCB_{l,t} \right )$
\IF{$f_{\hat{\theta}}(t) > 1/K$ {\bfseries and} $2 K / t^2 < \delta$}
\STATE $phase1 = \texttt{False}$
\ENDIF
\STATE {\bfseries return} $phase1$
\end{algorithmic}
\end{algorithm}
\begin{theorem}
\label{thm:check_phase}
\textsc{CheckPhase} procedure presented in Algorithm \ref{alg3:check_phase} is with the failure probability $\delta$.
\end{theorem}
The complete proofs of Theorems \ref{main_thm:short}, \ref{main_thm:long}, \ref{main_thm2:long}, and \ref{thm:check_phase} can be found in Appendices \ref{sec:main_thm_short}, \ref{sec:main_thm_long}, \ref{sec:main_thm2_long}, and \ref{sec:thm_check_phase}, respectively.
\section{Empirical analysis}
\label{empirical}
We perform experiments on two different applications: simulated stochastic bandit environments; and a contextual bandit environment, learned from the logged data in an online marketing campaign. We examine the effect of batch learning on Thompson Sampling (TS) and Upper Confidence Bound (UCB) policies for the stochastic problems, and linear Thompson Sampling (LinTS) \citep{NIPS2011_e53a0a29} and linear Upper Confidence Bound (LinUCB) \citep{LinUCB_2010} for the contextual problem.
\textbf{Simulated environments.} We present some simulation results for the Bernoulli bandit problem. We create three environments with different mean rewards for each $K = 2$ and $K = 4$. Table \ref{env-table} summarizes information about vectors of mean rewards used in the environments.
\textbf{Real data.} We also consider batch learning in a marketing campaign on the KPN \footnote{a dutch telecommunications provider} logged dataset. KPN has recently used three different campaigns to sell an extra broadband subscription to their customers. In the current dataset, a randomly selected set of customers received randomly one of the three campaigns. The data contains a sample of a campaign selection from October 2019 until June 2020 combined with customer information. We adopt an unbiased offline evaluation method \citep{Li_2011} to compare various bandit algorithms and batch size values. We use conversion rate (CR) as the metric of interest, defined as the ratio between the number of successful interactions and the total number of interactions. To protect business-sensitive information, we only report relative conversion rate; therefore, Figure \ref{cr-plot} demonstrates the CR returned by the off-policy evaluation algorithm relatively to the online performance.
\begin{figure}
\centering
\subfigure[2-arm environments performance.]{\label{fig:b}\includegraphics[width=60mm]{figures/ts_ucb_envs1-3.png}}
\subfigure[4-arm environments performance.]{\label{fig:a}\includegraphics[width=60mm]{figures/ts_ucb_envs4-6.png}}
\caption{Empirical regret performance by batches. The plots are averaged over 500 repetitions.}
\label{regret-plot}
\end{figure}
\textbf{Results.} \footnote{The source code of the experiments can be found in \url{https://github.com/danilprov/batch-bandits}.}
Figure \ref{regret-plot} shows the regret of two algorithms in six environments across the batch size. As expected, the regret has an upward trend as batch size increases. It can be seen that, for both algorithms, the impact of batch learning depends on environment parameters: the bigger a suboptimality gap, the stronger the impact of batching.
While the exact behavior of the batch learning is still not understood (and it pretty much depends on an algorithm rather than the experiment design), we can see a clear difference between a randomized policy and a deterministic one. Indeed, TS turns out to be much more robust to the impact of batching, whereas the UCB algorithm fluctuates considerably as batch size increases. The results for the real data confirm this fact as well: from Figure \ref{cr-plot} we observe that the impact of batching is milder for randomized policy (LinTS) than for deterministic policy (LinUCB) in contextual problem.
It is important to note that both experiments demonstrate results consistent with the theoretical analysis conducted in Sections \ref{sec:warm-up} and \ref{sec:main_res}. As the upper bound in Theorem \ref{main_thm:short} suggests, the performance metric reacts evenly to the increasing/decreasing of the batch size.
Finally, although it was not an initial goal, we recommend resorting to randomized policies when it becomes necessary to learn in batches.
\begin{figure}
\centering
{\includegraphics[width=60mm]{figures/LinTS+LinUCB_relative1.png}}
\caption{Empirical conversion rate by batches. The plots are averaged over 20 repetitions.}
\label{cr-plot}
\end{figure}
\begin{table}
\caption{Description of the environments.}
\label{env-table}
\centering
\begin{tabular}{llll}
\toprule
\multicolumn{2}{c}{2-arm environments} & \multicolumn{2}{c}{4-arm environments} \\
\midrule
Name & Rewards & Name & Rewards \\
\cmidrule(r){1-2}
\cmidrule(r){3-4}
$env1$ & [0.7, 0.5] & $env4$ & [0.35, 0.18, 0.47, 0.61] \\
$env2$ & [0.7, 0.4] & $env5$ & [0.40, 0.75, 0.57, 0.49] \\
$env3$ & [0.7, 0.1] & $env6$ & [0.70, 0.50, 0.30, 0.10] \\
\bottomrule
\end{tabular}
\end{table}
\section{Conclusion}
\label{sec:conclusion}
We have presented a systematic approach for batch learning in stochastic linear bandits. The contribution of this paper is twofold. First, we have introduced a new perspective of batched bandits emphasizing the importance of the batch size effect. In contrast, most of the work on batched bandits assumes that the batch size is a parameter to be optimized. Second, we have shown the actual effect of batch learning by conducting a comprehensive theoretical analysis, which is confirmed by our strong empirical results. Practically speaking, we have investigated one component of the performance-computational cost trade-off and demonstrated that it deteriorates gradually depending on the batch size. Thus, to find a suitable batch size, practitioners should take the necessary steps to estimate the second component (engineering costs) based on computational capabilities.
An interesting direction concerning future work would be to consider batch learning with varying decision rules within batches. That is, even though the agent does not receive any information within a batch, it might leverage two kinds of information to make more intelligent decisions. The first and natural recourse of information is the actual experience from the past batches. The second source of information is simulated experience: experience simulated by a model of the environment and combined with the agent's behavior in the current batch. Studying how to integrate actual knowledge and simulated experience to perform more optimally within a batch would potentially lead to tighter bounds between batch and online learning.
\section{Acknowledgements}
This project is partially financed by the Dutch Research Council (NWO) and the ICAI initiative in collaboration with KPN, the Netherlands.
|
{'timestamp': '2022-02-15T02:43:01', 'yymm': '2202', 'arxiv_id': '2202.06657', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06657'}
|
arxiv
|
\section{Appendix}
This section presents proofs of previous results stated in \cite{suleL1} which are extended to work for any finite field $\ensuremath{\mathbb{F}}$.
Proof of Theorem (\ref{strofsolns}).
\begin{proof}
From the definition of the periodic orbits and chains it follows that the space $\ensuremath{\mathbb{F}}^n$ is partitioned by the action of $F$ in periodic orbits and segments of chains from points in GOE to a point which is mapped by $F$ to a periodic orbit. Hence given any point $y$ it is either on a unique chain segment or on a periodic orbit. If there is no solution to $F(x)=y$ then $y$ belongs to GOE conversely if $y$ is in GOE then there is no $x$ such that $F(x)=y$. If $y$ is in a periodic orbit $P$, there is unique predecessor $x$ in $P$ such that $F(x)=y$. Any other solution $x$ which is outside $P$ cannot be in any other periodic orbit since the two orbits cannot intersect at $y$. Hence all other solutions $x$ are on chains merging with $P$ at $y$ under iterations of $F$. Hence every solution outside $P$ is on one of the chains $F^{(k)}(z)$ for $z$ in GOE and $k\geq 1$.
\end{proof}
Proof of Theorem (\ref{Solutioninperiodicorbit}).
\begin{proof}
Let $S(F,y)$ be periodic of period $N$. The point $x=F^{(N-1)}(y)$ then satisfies the equation $F(x)=y$, hence this is one and the unique solution of the equation in the periodic orbit. But then it follows that for this solution $x$, the periodic sequence $S(F,x)=S(F,y)$. Hence if $m(X)$ as described in (\ref{minpoly}) is the minimal polynomial of $S(F,Y)$,
\[
m(X)(x)=F^{(m)}(x)-\sum_{i=0}^{(m-1)}\alpha_iF^{i}(x)=0
\]
From this expression of $m(X)(x)$ the term $x$ can be solved uniquely since $\alpha_0\neq 0$.
\[
x=(1/\alpha_0)[F^{(m)}(x)-\sum_{i=1}^{(m-1)}\alpha_iF^{(i)}(x)]
\]
Then by using the condition $y=F(x)$ one gets the relation (\ref{solution}). This is the expression of the unique solution $x$ in the periodic orbit $S(F,y)$.
\end{proof}
\section{Conclusions}
It is shown that cryptanalysis of symmetric as well as public key primitives can be formulated as a problem of local inversion of a map $F:\ensuremath{\mathbb{F}}^n\rightarrow\ensuremath{\mathbb{F}}^n$ at $y$ in $\ensuremath{\mathbb{F}}^n$ given the equation $y=F(x)$ over a finite field $\ensuremath{\mathbb{F}}$. In some cases $F$ is an embedding and maps $\ensuremath{\mathbb{F}}^n$ to $\ensuremath{\mathbb{F}}^m$ for $n<m$. An incomplete algorithm is developed which can address both of these problems especially in the practical situation, when only a polynomial size length of the sequence of recurrence defined by $F$ and $y$ can be made available for inversion. If the linear complexity (LC) of the recurrence defined by $F$ and $y$ is of polynomially bounded order $O(n^k)$, then a possible solution can be computed in polynomial time. Local inversion is shown as a uniform methodology for cryptanalysis of symmetric encryption algorithms, cryptanalysis of RSA without factoring the modulus and computation of the discrete logarithms on elliptic curve and finite fields. In real life cases it will be worthwhile to carry out the computations proposed in the incomplete algorithm to determine density of such low LC instances occurring within the bounds of practically feasible time and memory. Hence such computations can be used for estimating security of cryptographic primitives as functions of their parameters in terms of sizes of linear systems required to be solved over specific finite field. Main conclusion of this paper is that the low LC of recurrence of a map $F$ on a value $y$ defined by the cryptographic primitive is the vital sufficient condition for its weakness. Hence computation of LC of recurrences of cryptographic primitives should be considered for standardization of cryptographic algorithms.
\subsubsection*{}
\begin{center}
Acknowledgements
\noindent
Author is thankful to Shashank Sule for a useful discussion and to Ramachandran and Shravani Shahapure for help in correcting errors.
\end{center}
\section{Introduction}
This paper proposes a new attack called \emph{Local Inversion Attack} which is applicable for cryptanalysis of symmetric encryption algorithms (block and stream ciphers), RSA encryption and solution of the Elliptic Curve Discrete Log Problem (ECDLP). The attack is based on computation of a unique solution to inverting a function when the given value of the function defines a periodic recurring sequence of low \emph{linear complexity} (LC). The inverses of respective functions solve the symmetric keys in case of symmetric encryption given a known plaintext, plaintext input of the RSA ciphertext without resorting to factoring the modulus, decrypt every encryption of RSA by same public key when one pair $(c,m)$ is known and the discrete log $m$ in the ECDLP given the points $P$ and $[m]P$ on the elliptic curve. The sequences produced by the functions in respective cases have not been studied previously for their LCs. Hence an accidental low complexity values of the sequence in a specific session can be fatal for security of these primitives. The local inversion problem was recently posed and solved by the author in \cite{suleLI1,suleLI2} for maps in binary field case $\ensuremath{\mathbb{F}_{2}}$ by proposing a complete algorithm for the solution which computes all solutions to the inversion. It was shown that the complete algorithm for local inversion involved solving NP-hard problems in general. An incomplete algorithm is also proposed in these references which is promising for solving the local inversion problem in the case when the LC is low. In this paper we extend this incomplete algorithm to general finite fields and explain the above important cryptanalysis applications.
If $\ensuremath{\mathbb{F}}$ is a finite field and $F:\ensuremath{\mathbb{F}}^n\rightarrow\ensuremath{\mathbb{F}}^n$ is a map. Then given a $y$ in $\ensuremath{\mathbb{F}}^n$ in the image of $F$ local inversion of $F$ at $y$ is concerned with finding all $x$ in $\ensuremath{\mathbb{F}}^n$ such that $y=F(x)$. An approach to solving this problem was proposed by the author in \cite{suleLI1} for binary field $\ensuremath{\mathbb{F}_{2}}$. Some consequences and an improved incomplete algorithm were announced in \cite{suleLI2}. Previously well known approach for local inversion of maps has been known as TMTO attack which has been well known in cryptanalysis since long \cite{Hell}. However TMTO relies on the collision probability and does not use any properties of finite fields. In this paper we explore wider consequences of this methodology of incomplete algorithm for local inversion and show that formulation of cryptanalysis problems as local inversion gives a remarkable advantage for cryptanalysis in all the above problems of cryptanalysis. The methodology of local inversion by the incomplete algorithm utilizes the well known notion of LC of a sequence generated by the map $F$ recursively for the given value $y$ to find one solution in polynomial time if the LC happens to be of polynomial order $O(n^k)$. In most cases usually it is known that there is a unique solution to the problem hence the inverse obtained is the only solution. Hence this methodology offers a solution in practically feasible time and memory for sufficiently small $k$. However such solutions are only feasible for special cases of data $y$ as an output of the map $F$ which corresponds to a specific session of the primitive. Such low complexity cases of local inversion given $y$ are accidental and possibly of very low density among all possible operational values of the map $F$ or what can be called as average cases of the primitive. Unfortunately as encryption may be carried out using the same private or symmetric key on multiple inputs any one of input producing an output $y$ of low LC shall lead to a fatal breaking of the encryption for all inputs. Hence even if such low complexity cases are rare, once a case is found the private key as well as all encryptions by the key are compromised. Also the probability of accidental occurrence of low complexity cases increases with practical feasibility bounds (on time and memory) allotted for local inversion algorithm. These special cases spell doom on the whole encryption if their density is not exponentially small given these practical bounds. Hence security of encryption based on exponential average case complexity is no more a reliable assurance of security.
\subsection{Relationship with previous work}
The TMTO attack algorithm of \cite{Hell} addressed the problem of local inversion of a map $F:\{0,1\}^n\rightarrow\{0,1\}^m$ for $n\leq m$. The attack still attracts newer research as in \cite{hongsarkar, hays, gango} even after forty years. TMTO however does not utilize the structure of finite fields defining the domain and range of the map. TMTO is essentially based on collision probability and hence the complexity of TMTO is of the order of $O(\sqrt{N})$ where $N=2^n$. Local inversion algorithms of \cite{suleLI1,suleLI2} and those to be presented in this paper on the other hand depend on the structure of the finite field $\ensuremath{\mathbb{F}}$ inherent in definition of the map $F:\ensuremath{\mathbb{F}}^n\rightarrow\ensuremath{\mathbb{F}}^n$. The complexity of local inversion is in terms of $\log N$ where polynomial time is of the order $O((\log N)^k)$. Hence the TMTO is an exponential algorithm and is of a completely different nature of search. The incomplete algorithm for local inversion presented in this paper sets a bound on computation in $O((\log N)^k)$ and determines if there is a solution to the inversion within the bound. Hence for sufficiently small bound such as $k=3$ the computation is equivalent to solving a linear system of size $O(n^k)$ for a reasonably small $k$. This methodology is useful to make estimates of the density of small complexity encryptions (which are weak) and which can be broken in time and memory estimates proportional to solving a linear system of size $O(n^k)$.
\subsubsection{Local Inversion attacks on RSA}
Cryptanalysis of RSA has always been studied from the viewpoint of factoring the modulus. While major progress has taken place in factorization algorithms the best known of these have sub-exponential complexity in the bit length $l=\log n+1$ of the modulus $n=pq$ where $p,q$ are distinct odd primes \cite{Lenstra,Lenstraetal,Buhleretal}. Local inversion approach to cryptanalysis of RSA on the other hand is a completely different problem of inverting the maps $y=F(x)$. The maps $F$ can be defined in two different situations.
\begin{enumerate}
\item Inversion of ciphertext $c$ to plaintext $m$, $c=m^e\mod n$. Here the map to be inverted is $c=F(m)$, hence maps $\ensuremath{\mathbb{F}_{2}}^l\rightarrow\ensuremath{\mathbb{F}_{2}}^l$.
\item Inversion in Chosen Ciphertext Attack (CCA) to find the private key $d$ since $m=c^d\mod n$ assuming both $m,c$ known. Here $F:\ensuremath{\mathbb{F}_{2}}^{\log\phi(n)}\rightarrow\ensuremath{\mathbb{F}_{2}}^l$ since the unknown $d$ belongs to $\ensuremath{\mathbb{Z}}_{\phi(n)}$. Hence this is the case of local map inversion $F:\ensuremath{\mathbb{F}_{2}}^{(l-1)}\rightarrow\ensuremath{\mathbb{F}_{2}}^l$ which is an embedding.
\end{enumerate}
The incomplete algorithm of local inversion of $c$ to $m$ then determines whether there exist low complexity encryptions $y$ of polynomial order $O(l^k)$ and particularly of practically feasible order $O(l^3)$ and how much size of linear system would be required to break such weak encryptions. Clearly this method of inverting RSA has no theoretical overlap with factorization. However the complexity $O(l^k)$ shall be a concrete comparison with order of complexity of factoring $l$ bit length moduli $n=pq$. The embedding map inversion case also arises in the discrete log computation as discussed next.
\subsubsection{Solution of the ECDLP}
Among the most important problems of cryptanalysis which can be studied using the local inversion methodology is the ECDLP. Here the map $F$ is defined by the relation $Q=[m]P$ where $P,Q$ are given points on the elliptic curve $E(\ensuremath{\mathbb{F}}_q)$ and $m$ the unknown multiplier number. $F$ maps $m$ to $E$. Hence this is not the standard problem of local inversion since bit length of the exponent $m$ the unknown to be solved is less than the bits required for representing a point on $E$. It is assumed that the point $Q$ is in the cyclic subgroup $<P>$. The order of the subgroup is bound by the order of $E$ which is further bound by $q+1+2\sqrt{q}$. Since as a set of points $E$ is embedded in $\ensuremath{\mathbb{F}}_q^2$ and $r=q+1+2\sqrt{q}<2q$ the map $F$ can be formulated in bits as a map $F:\ensuremath{\mathbb{F}}^{\log r+1}\rightarrow\ensuremath{\mathbb{F}}^{\log(q)+2}$ which is an embedding $F:\ensuremath{\mathbb{F}}^n\rightarrow\ensuremath{\mathbb{F}}^m$, $n<m$. The complexity of local inversion of such a map as we shall show in a later section is that of simultaneous local inversion of $m-n$ maps $F_i:\ensuremath{\mathbb{F}}^n\rightarrow\ensuremath{\mathbb{F}}^n,i=1,\ldots(m-n)$ defined by $F$ with a common inverse. Hence the incomplete algorithm allows us to determine the number of weak cases of ECDLP of polynomial size complexity $O(n^k)$. Such a methodology does not seem to have appeared in any of the previous methods of solving the ECDLP. Even the most recent analogous index calculus method of solving the ECDLP has exponential complexity \cite{SATECDLP} despite giving much improvement in computation. Due to wide application of Elliptic Curve Cryptography (ECC) on internet, private networks and the digital currency the solution to ECDLP using the local inversion methodology shall be an important new approach in estimation of security and identification of weak sessions of key exchange in ECC.
\subsubsection{Differences with LC of stream generators and the Berlekamp Massey attack}
Stream ciphers and block ciphers in counter mode produce periodic pseudorandom (PR) streams with long periods of exponential order in the number $n$ of bits of the input secret key or the seed. Berlekamp Massey (BM) attack \cite{StampLow} on such streams is to model the stream as an output of a linear feedback shift register (LFSR) with a known initial loading thereby allowing recovery of the entire stream used for encryption. BM attack succeeds if the LC (the degree of the minimal polynomial) of the stream is of low order (polynomial order in $n$). A large class of sequences have been discovered in the literature \cite{Nied1, Fang} which have large linear complexities (close to half the period which is of exponential order). However such studies are useful to show if a particular sequence has large LC. In practice when such streams are generated by stream generators each stream is uniquely identified with a secret key $K$ and an initialising seed called $IV$ (which is publicly known). Hence even if BM attack does succeed for one stream (for a known IV) it does not reveal the secret key. Usually the stream generators are designed and $IV$s chosen such that the LC is not small and the attack is defeated. The $k$-linear complexity \cite{Nied2} is another useful concept which shows variation of LC of a sequence relative to close sequences differing in few bits
However, it is important to note that the local inversion attack we propose in this paper is not concerned with the LC of the output stream of a stream generator at all. The attack considers a totally different sequence recursively generated by the map from secret key to the output stream. Hence none of the previous studies of LC of output stream of generators (for specific $IV$) are relevant to determine the LC of the recurrence sequence utilized for local inversion attack. Moreover once the LC of the recurrence is of polynomial order in the key length, the local inversion attack solves for the secret key in polynomial time. Hence the cipher algorithm is broken for all $IV$s which may be used as seeds for the same key. Hence this attack is of very different kind than the BM attack of modeling the output stream by an LFSR. This new attack must be considered as an additional measure of security of PR generators apart from the BM attack on the output streams.
\subsubsection{Local inversion as a general problem over finite fields}
Inversion of maps is a problem of fundamental interest to Mathematics and Computation and has vast application in Physical, Life and Social Sciences. For instance local inversion can be applied to the problem of solving (rational solutions) of systems of polynomials over finite fields. Inversion of maps and functions has been studied in depth for over a century over continuous domains while over discrete domains such as finite fields, importance and applications of the inversion problem have been slow to come to light. Cryptanalysis happens to be one such vitally important application in which almost all problems are known to be computationally hard. Applications of maps over finite fields arise in several applications such as Biological and Chemical networks and symbolic dynamical systems. In number theory, the map such as the exponential function modulo a prime and in finite fields does not appear to have been studied from the point of view of LC of the recurrence. LC is a characteristic property of primes and generating polynomials of field extensions. Dynamical systems and maps in finite fields exhibit interesting linear representation and its application as shown in \cite{Ramsule1,Ramsule2}. These show that the theory of inversion of maps in finite and discrete domains has important real life applications which are yet to be fully explored.
\subsection{Organization of the paper}
A brief background of the local inverse problem and its computational solution by an incomplete algorithm is first presented in Section 2. The main difference of material in this paper compared to the previous papers \cite{suleLI1,suleLI2} is the focus on incomplete algorithm and applicability of the theory to general finite fields. Focus of the previous paper \cite{suleLI1} was primarily on the complete algorithm to find all solutions. The complete algorithm is at present possible only for maps over the binary fields $\ensuremath{\mathbb{F}_{2}}$ and involves solving NP hard problems to obtain all solutions. The incomplete algorithm only requires computing a single solution in a periodic sequence and is accomplished by solving a linear system over the field and hence works over any finite field.
The case of embedding maps is then analysed in Section 3 and the incomplete algorithm is extended to solve the problem of local inversion on an embedding.
In section 4, the cases of cryptanalysis of symmetric key algorithms of block and stream ciphers are discussed in terms of local inversion problem using the incomplete algorithm.
In Section 5, an application of local inversion is presented for cryptanalysis of RSA which shows that RSA encryption can be decrypted by local inversion of an appropriate map without factoring the modulus. It is also shown how in one CCA attack, local inversion leads to breaking of all the encryptions by the same private key. Bounds on the sizes of linear systems to be solved for polynomial order $O(l^k)$ bounds on the complexity are shown where $l$ is the bit length of the modulus.
Section 6 is devoted to the formulation of the ECDLP over finite fields as a local inversion problem of an appropriate embedding map $F:\ensuremath{\mathbb{F}_{2}}^n\rightarrow\ensuremath{\mathbb{F}_{2}}^m$ over the binary field. Bounds on sizes of linear systems required to be solved if the linear complexity of sequences defined by the map are bounded by polynomial order $O(n^k)$ are presented. Solving DLP on finite fields is then presented as a local inversion problem and appropriate maps to be inverted are derived.
This paper shall focus on the presentation of the theory of incomplete algorithm for local inversion of maps in three central problems of cryptanalysis as discussed above. Computational details and measurement of densities of low LC cases of cryptanalysis problems shall be presented in separate articles.
\section{Local Inversion by an incomplete algorithm}
In this section we gather the background required for presenting the theory. Although there is much overlap of this section with the material in \cite{suleLI1,suleLI2} the case here is over a general finite field while that in these previous papers was for the binary field $\ensuremath{\mathbb{F}_{2}}$. Moreover a recall of the basic background is more convenient for readers instead of referencing back. Consider a map $F:\ensuremath{\mathbb{F}}^n\rightarrow\ensuremath{\mathbb{F}}^n$ where $\ensuremath{\mathbb{F}}$ is a finite field. Given $y$ in $\ensuremath{\mathbb{F}}^n$ local inversion problem is to determine all solutions $x$ in $\ensuremath{\mathbb{F}}^n$ of the equation $y=F(x)$. A complete algorithm for solving this problem over the binary field $\ensuremath{\mathbb{F}_{2}}$ is presented in \cite{suleLI1,suleLI2} which returns the set of all solutions of the problem (or returns an empty set if there is no solution). An incomplete algorithm takes as an input a bound $M$ on the computation (which bounds number of steps of time and size of memory) and returns a unique solution if any solution is found within this bound on computation. Algorithms for solution to the inversion problem are based on the structure of solutions of the equation
\begin{equation}\label{eqn:fundamental}
y=F(x): x,y\in\ensuremath{\mathbb{F}}
\end{equation}
over a finite field $\ensuremath{\mathbb{F}}$. The structure of solutions arises from the dynamical system over $\ensuremath{\mathbb{F}}^n$ defined by the map $F$ as its transition function.
\subsection{Dynamical system defined by $F$ and structure of solutions}
The map $F$ in the equation (\ref{eqn:fundamental}) defines the transition function of the dynamical system
\begin{equation}\label{eqn:dynsys}
x(k+1)=F(x(k)),k=0,1,2,\ldots
\end{equation}
with state $x(k)$ in $\ensuremath{\mathbb{F}}^n$. An initial state $x(0)$ defines a unique trajectory through $x(0)$ of the system (\ref{eqn:dynsys}) in $\ensuremath{\mathbb{F}}^n$ and also generates the sequence of recurrences (or iterates of $F$)
\[
S(F,x(0))=\{x(0),F(x(0)),F^{(2)}(x(0)),\ldots\}
\]
Hence the system (\ref{eqn:dynsys}) and the sequence $S(F,x(0))$ are frequently referred interchangeably once $x(0)$ is specified. Due to finiteness of the domain $\ensuremath{\mathbb{F}}^n$ of the transition map, the trajectories of the dynamical system are limited to only three types, fixed points, periodic points and chains.
\begin{enumerate}
\item \emph{Fixed points}: Points $x$ in $\ensuremath{\mathbb{F}}^n$ which satisfy, $F(x)=x$.
\item \emph{Periodic points of period $N$}: Points $x$ in $\ensuremath{\mathbb{F}}^n$ which satisfy $F^{(N)}(x)=x$. (Hence fixed points are periodic points of period $1$). The trajectory $x(k)$ with initial state $x$ is called a closed orbit of length $N$ through $x$. The trajectory is aslo termed a \emph{periodic orbit} of period $N$.
\item \emph{Chains of length $l$}: Trajectories $x(k)$ with initial state $z$ in the set called Garden of Eden (GOE) of $F$,
\[
\mbox{GOE}=\{z\in\ensuremath{\mathbb{F}}^n|z\notin\mbox{im\,} F\}
\]
and the final state $x(l)$ in a closed orbit or a fixed point.
\end{enumerate}
Basic observations about trajectories of dynamical system (\ref{eqn:dynsys}) are
\begin{prop} Following statements hold
\begin{enumerate}
\item Every trajectory $x(k)$ of a dynamical system (\ref{eqn:dynsys}) is one of the above three type.
\item If $x$, $y$ are distinct periodic points then either they are in the same periodic orbit or have disjoint (non-intersecting) periodic orbits.
\item A map $F$ is a permutation iff all trajectories are closed orbits and its GOE is an empty set. Hence the closed orbits of a permutation partition $\ensuremath{\mathbb{F}}^n$.
\end{enumerate}
\end{prop}
\begin{proof}
The proof of these statements follow just from the finiteness of $\ensuremath{\mathbb{F}}^n$, because of which every trajectory $x(k)$ is \emph{ultimately periodic}, there exist $p$, $N$ for every $x$ such that the trajectory $x(k)$ with initial state $x$ satifies, $x(k+N)=x(k)$ for $k\geq p$. ($p$ is called the \emph{pre-period} of the trajectory and the smallest $N$ is called the \emph{period}). Hence a trajectory $x(k)$ if not already periodic always has a part in a chain before it reaches a periodic orbit.
Next let $x$, $y$ be distinct periodic points and not in eachother's closed orbit. If $w$ is a common point in their closed orbits, then the closed orbit of $w$ is in closed orbits of both $x$ and $y$ hence their orbits are the same. Hence it follows that closed orbits containing $x$ and $y$ do not intersect.
Finally, a map $F$ is a permutation then it is one to one in $\ensuremath{\mathbb{F}}^n$ hence every $y$ has an inverse image $x$ such that $y=F(x)$ hence the GOE is empty. Since all closed orbits are distinct because of the previous statement and isolated points are fixed points these are all the points in $\ensuremath{\mathbb{F}}^n$. Hence the trajectories of (\ref{eqn:dynsys}) partition $\ensuremath{\mathbb{F}}^n$.
\end{proof}
Above Proposition describes the structure of solutions of the equation (\ref{eqn:fundamental}). First make easy observation
\begin{prop}
Equation $y=F(x)$ has no solution iff $y$ belongs to $GOE$ of $F$.
\end{prop}
Next, a theorem on the structure of all solutions of (\ref{eqn:fundamental}).
\begin{theorem}\label{strofsolns} Following statements hold
\begin{enumerate}
\item $F(x)=y$ has a solution $x$ in a periodic orbit $P$ iff $y$ belongs to $P$. Such a periodic orbit and hence also the solution $x$ in $P$ is unique.
\item All other possible solutions belong to the chains $F^{k}(z),k\geq 1$ for $z$ in the GOE of $F$.
\item If $y$ is neither in a periodic orbit nor in the GOE, then solutions arise in some of the segments $F^{(k)}(z),1<k\leq (l-1)$ for some $l$ for some of the $z$ in the GOE.
\item $y=F(x)$ has a unique solution iff $y$ belongs exclusively to a chain segment of a unique point in GOE or to a unique periodic orbit
\end{enumerate}
\end{theorem}
Proof of the theorem is presented in the appendix as it is almost same as that presented as proof of Lemma 1 in \cite{suleLI1} except for the fact that this proof is valid for any finite field.
\subsection{Computation of solutions}
From the theorem on structure of solutions of the equation (\ref{eqn:fundamental}) it follows that any solution of (\ref{eqn:fundamental}) over a finite field $\ensuremath{\mathbb{F}}$ is either in one unique periodic orbit of trajectories of the dynamical system (\ref{eqn:dynsys}) or in a chain (a trajectory starting from some initial point in the GOE). It is shown in \cite{suleLI2} for the map $F$ over $\ensuremath{\mathbb{F}_{2}}$ that computation of GOE is an NP-hard problem. Hence computation of solutions in chains is beyond the goal of an incomplete algorithm with polynomial size bounds on computation. Although this complexity is established only over $\ensuremath{\mathbb{F}_{2}}$, the situation can be predicted to be even harder for general finite fields. In fact an algorithm for solving this problem of computation of GOE of a map $F$ on finite fields other than $\ensuremath{\mathbb{F}_{2}}$ does not seem to have been discussed in previous literature.
\subsubsection{Computation of solution in a periodic orbit}
We now assume that $y$ in (\ref{eqn:fundamental}) belongs to a periodic orbit of the iterates of (\ref{eqn:dynsys}) or that the sequence $S(F,y)$ is periodic
\begin{equation}\label{Sequence}
S(F,y)=\{y,F(y),F^{(2)}(y),\ldots\}
\end{equation}
Let $N$ be the period of this sequence or the period of the trajectory with initial condition $y$. Hence $N$ is the smallest index such that
\[
F^{(N)}(y)=y
\]
Hence $x=F^{(N-1)}(y)$ is the solution of the equation. Thus computing the unique solution in the periodic orbit $S(F,y)$ it is sufficient to
\begin{enumerate}
\item Determine whether the sequence $S(F,y)$ (trajectory of $y$) is periodic.
\item Compute the period $N$ of the tratejctory $S(F,y)$ of $y$.
\item Evaluate the $(N-1)$-th compositional power of $F$ at $y$.
\end{enumerate}
Even when $N$ is of exponential order in $n$, the compositional power $F^{(N-1)}(y)$ can be computed in polynomial time $O(n^k)$. This is possible by the repeated compositional squaring shown for maps over $\ensuremath{\mathbb{F}_{2}}$ in \cite{suleLI1} (appendix) analogous to repeated squaring in groups to compute powers of exponential order. Same proof can be extended for any finite field. Hence to find the solution $x$ it is required to estimate complexities of determining whether the sequence $S(F,y)$ is periodic and computing the period $N$.
\subsubsection{The practical hurdle in computation}
We now highlight the computational hurdle in computing the period. In practice the numbers of terms of the sequence $S(F,y)$ available for computation are limited (polynomial size $O(n^k)$ for sufficiently small size $k$ as is determined by practical feasibility). Hence the above problems of determining periodicity of $S(F,y)$ and computing the period $N$ are required to be solved for a subsequence of $S(F,y)$ with a limited number of terms. Both of these problems are linked with the concept of linear complexity of $S(F,y)$. This is discussed next.
\subsection{Linear complexity and the solution of $y=F(x)$}
It turns out that for computing the solution $x$ of (\ref{eqn:fundamental}) it is not necessary to compute the sequence terms upto $(N-1)$ for a period $N$ and the compositional power $F^{(N-1)}(y)$. Instead, it is sufficient to discover the \emph{Linear Complexity} (LC) and the \emph{minimal polynomial} of the sequence $S(F,y)$ from the limited terms of the sequence. A greatest advantage in such an alternative as we show below is that if the LC of $S(F,y)$ is of polynomial order $O(n^k)$ then it can be computed along with the minimal polynomial in polynomial time and this allows computation of the solution $x$ in polynomial time directly from the minimal polynomial. Alternatively it is shown that when LC is of polynomial order, the period $N$ can be computed in polynomial time as the order of the minimal polynomial. Moreover the compositional power $F^{(N-1)}(y)$ can also be found in polynomial time which is the solution of the inverse. Hence then these two ways of computing the solution are computationally polynomial time equivalent. However the direct computation of $x$ from the minimal polynomial shown and used in the algorithm is practically much advantageous. This is the big picture of the idea of this paper.
\subsubsection{Linear recurrence relation satisfied by $S(F,y)$}
To describe the above observation it is necessary to recall the concept of linear recurrence relation satisfied by a periodic sequence over a finite field $\mathbb{F}_{q}$ and a polynomial associated with such a relation. Linear recurrence relations in sequences have been studied since long. The concept of \emph{linear complexity} (LC) and the modeling of a sequence by an LFSR of length equal to LC using the Berlekamp-Massey algorithm have been known in the theory of stream ciphers \cite{Rueppel, StampLow}. We refer the reader to \cite{Gologong} for an immediate relevance to periodic sequences while an exposition of a general theory is available in \cite{LidlNied}. Although linear recurrence and minimal polynomials of periodic sequences have been studied since long their application for local inversion problem does not seem to have caught attention of the researchers in the past as evident from a near total absence of reference to this problem. While inversion of a map is an objective of TMTO attack, the TMTO algorithm does not utilize the structure of finite field of the domain hence none of the mathematical constructs such as minimal polynomial are applicable for TMTO attack.
\subsection{Minimal polynomial, order and period of $S(F,y)$}
The sequence $S(F,y)$ is said to satisfy a recurrence relation if there exist $j_0\geq 0$, $m\geq 1$ and constants $\alpha_0,\alpha_1,\ldots,\alpha_{(m-1)},\alpha_m\neq 0$ such that the following relations hold
\begin{equation}\label{LRR}
\alpha_mF^{(k+m)}(y)=\sum_{i=0}^{(m-1)}\alpha_iF^{(k+i)}(y)
\end{equation}
for $k=j_0,j_0+1,j_0+2,\ldots$. If such a recurrence relation is found, a polynomial $p(X)$ can be associated with the relation as follows
\[
p(X)=\alpha_mX^m-\sum_{i=0}^{(m-1)}\alpha_iX^{i}
\]
When $\alpha_m\neq 0$, the degree $m$ of the polynomial is also called the \emph{degree} of the recurrence relation (\ref{LRR}). The polynomial
\[
\phi(X)=(1/\alpha_m)p(X)
\]
is called a \emph{characteristic polynomial} of $S(F,y)$. We can also say that the recurrence relation (\ref{LRR}) with $\alpha_m=1$ is defined by the polynomial $\phi(X)$. (Hereafter we shall drop the term linear and simply call (\ref{LRR}) as a recurrence relation). A characteristic polynomial of smallest degree $m$ denoted $m(X)$ is unique, for if not, (\ref{LRR}) shows that there is a recurrence relation of degree smaller than degree $m$. Hence the polynomial is called the \emph{minimal polynomial} of $S(F,y)$, which is monic and defines the least degree recurrence relation. We shall denote the minimal polynomial $m(X)$ as follows, retaining the notation for the co-efficients $\alpha_i$ for $i\geq 0$ as
\begin{equation}\label{minpoly}
m(X)=X^m-\sum_{i=0}^{m-1}\alpha_0X^i
\end{equation}
Formally we can denote the indeterminate $X$ and polynomials in $\ensuremath{\mathbb{F}}[X]$ as linear operations on the sequence $S(F,y)$ induced by the rules,
\[
X^k(y)=F^{(k)}(y),\mbox{ }(aX^k+bX^l)(y)=aF^{(k)}(y)+bF^{(l)}(y),a,b\in\ensuremath{\mathbb{F}}
\]
Then it follows that any characteristic polynomial $\phi(X)$ satisfies
\[
\phi(X)(F^{(k)}(y))=0\forall k\geq 0
\]
which is denoted in short as $\phi(S(F,y))=0$. An important characterization of the minimal polynomial is given by the following well known Proposition \cite{Gologong, suleLI1}.
\subsubsection{Relations between order and period}
For a polynomial $f(X)$ in $\ensuremath{\mathbb{F}}[X]$ which satisfies $f(0)\neq 0$ there exists a number $N$ which is the smallest number such that $f(X)|(X^N-1)$ ($f(X)$ divides $(X^N-1)$). This number is called the \emph{order} of $f(X)$ over $\ensuremath{\mathbb{F}}$, denoted
\[
N=\mbox{order}\;f(X)
\]
Order of a polynomial has well known relation with the orders of roots of its irreducible factors over its splitting field \cite{LidlNied}.
\begin{prop}\label{Existenceofmp}
The sequence $S(F,y)$ is periodic iff it has a minimal polynomial which divides any of its characteristic polynomials. The minimal polynomial satisfies $\alpha_0\neq 0$ (equivalently $m(0)\neq 0$) and the period $N$ of $S(F,y)$ is the order of the minimal polynomial.
\end{prop}
The proof is given in \cite{suleLI1} as proof of Proposition 1 hence is omitted. It is stated there only over the field $\ensuremath{\mathbb{F}_{2}}$ however it works for any finite field with very minor modifications.
\subsection{Solution of the equation $y=F(x)$}
An important observation relating the minimal polynomial of a periodic $S(F,y)$ to the unique solution $x$ of $\ref{eqn:fundamental}$ is given by
\begin{theorem}\label{Solutioninperiodicorbit}
Let $S(F,y)$ be a periodic sequence and $m(X)$ as described in (\ref{minpoly}) be its minimal polynomial. Then there is a unique solution to $F(x)=y$ in $S(F,y)$ given by
\begin{equation}\label{solution}
x=(1/\alpha_0)[F^{(m-1)}(y)-\sum_{i=1}^{(m-1)}\alpha_iF^{(i-1)}(y)]
\end{equation}
\end{theorem}
Proof is presented in the appendix. It is essentially a reproduction of the proof of Theorem 1 stated in \cite{suleLI1}. While it was stated earlier only for the field $\ensuremath{\mathbb{F}_{2}}$, present proof works for any $\ensuremath{\mathbb{F}}$.
\subsubsection{Linear complexity and computation of the minimal polynomial}
From Theorem (\ref{Solutioninperiodicorbit}) it follows that the unique solution $x$ of (\ref{eqn:fundamental}) in the periodic orbit containing $y$ is obtained once the unique minimal polynomial $m(X)$ is computed from the sequence $S(F,y)$. We first state the theoretical result in this connection as stated in \cite{suleLI1} for general fields and then take the problem of constructing an incomplete algorithm to set up the computation to solve for $m(X)$ in the practical situation when only a partial sequence $S(F,y)$ is specified.
A well known algorithm for computation of the minimal polynomial of a sequence is the Berlekamp-Massey algorithm. Its role in the cryptanalysis of stream ciphers has been well known \cite{Rueppel}. However we shall present the computation in terms of the linear system involving the Hankel matrix defined by the sequence $S(F,y)$. If an arbitrary number of terms in the sequence are available the Hankel matrix of size $m$ starting from the term $y$ is given by
\begin{equation}\label{hankelmatrix}
H_{m+j}=
\left[\begin{array}{llll}
y & F(y) & \ldots & F^{(j+(m-1))}(y)\\
F(y) & F^{(2)}(y) & \ldots & F^{(j+m)}(y)\\
\dots & \vdots & & \vdots\\
F^{(j+(m-1))}(y) & F^{(j+m)}(y) &\ldots & F^{(j+(2m-2))}(y)
\end{array}\right]
\end{equation}
Following proposition then gives a criterion and method of computation of the minimal polynomial of $S(F,y)$. This is reproduced from \cite{suleLI1}. The proof is omitted but the same proof is valid for any field $\ensuremath{\mathbb{F}}$ (while it is considered only for $\ensuremath{\mathbb{F}_{2}}$ in the previous paper).
\begin{prop}\label{Prop:Hankel}
Let $S(F,y)$ be periodic then it has a minimal polynomial of degree $m$ iff
\begin{equation}\label{rankcond}
\mbox{rank}\, H(m+j)=\mbox{rank}\, H(m)=m
\end{equation}
for all $j=1,2,\dots$. The co-efficient vector
\[
\hat{\alpha}=(\alpha_0,\ldots,\alpha_{(m-1)})^T
\]
of the minimal polynomial is the unique solution of
\begin{equation}\label{Hankeleqn}
H(m)\hat{\alpha}=h(m+1)
\end{equation}
where
\[
h(m+1)=[F^m(y),F^{(m+1)}(y),\ldots,F^{(2m-1)}(y)]^T
\]
\end{prop}
\subsection{An incomplete algorithm for computing a solution}
Now we come to the practical issue of computing the minimal polynomial. In practice the sequence $S(F,y)$ can never be specified completely over one period, because its period $N$ is of exponential order in $n$. Hence we are really not sure whether the minimal polynomial computed from equation (\ref{Hankeleqn}) by checking the condition (\ref{rankcond}) at $m$ correctly represents the complete sequence $S(F,y)$. However when the minimal polynomial is correct to represent this sequence then the inverse $x$ computed using the formula (\ref{solution}) is the correct local inverse of $y$ which is same as saying that $x$ verifies $y=F(x)$. This is the basis of the incomplete algorithm to find the local inverse in the periodic orbit of $y$ described below.
\begin{algorithm}\label{IncompleteAlgo}
\caption{Incomplete algorithm to find the unique solution in periodic orbit}
\begin{algorithmic}[1]
\State\textbf{Input}: $y$ in $\ensuremath{\mathbb{F}}^n$, $M$ an upper bound of polynomial order $O(n^r)$ (for length of the sequence $S(F,y)$) for $r$ decided based on practical feasibility.
\State\textbf{Output}: One solution of $F(x)=y$ in the periodic orbit $S(F,y)$ if one exists with minimal polynomial of degree $m\leq\lfloor M/2\rfloor$ otherwise returns that there is no conclusion.
\Procedure{Solution\_in}{$S(F,y)$}
\State Compute the sequence $S(F,y)$, $\{F^{(k)}(y)\}$ for $k=0,1,\ldots,M$.
\If {at any $k<M$, $F^{(k)}(y)=y$} \State Return $x=F^{(k-1)}(y)$ is the solution.
\Else
\State Set $m=\lfloor M/2\rfloor$.
\Repeat
\State Compute matrices $H(m)$, $H(m+1)$ (as shown in (\ref{hankelmatrix})).
\State Compute $\mbox{rank}\, H(m)$, $\mbox{rank}\, H(m+1)$.
\If{
\[
m=\mbox{rank}\, H(m)=\mbox{rank}\, H(m+1)=m
\]
}
\State Compute the minimal polynomial co-efficients $\hat{\alpha}$ in (\ref{Hankeleqn}).
\State Compute solution $x$ as in (\ref{solution}).
\If {$F(x)=y$}
\State \% Verification to avoid false positive solutions.
\State Return: Solution $x$
\EndIf
\EndIf
\If{$\mbox{rank}\, H(m)<\mbox{rank}\, H(m+1)$}
\State Return: No conclusion within the bound $M$, ($\mbox{LC}>\lfloor M/2\rfloor$).
\EndIf
\If{$\mbox{rank}\, H(m)=\mbox{rank}\, H(m+1)<m$}
\State $m\leftarrow m-1$.
\EndIf
\Until{$m=1$}
\State Return: No conclusion within the bound $M$, ($\mbox{LC}>\lfloor M/2\rfloor$).
\EndIf
\EndProcedure
\end{algorithmic}
\end{algorithm}
We shall formally state the definition of minimal polynomial of $S(F,y)$ computed from a subsequence of $M$ terms.
\begin{definition}
Consider the subsequence of $S(F,y)$ given upto $M$ terms.
\[
\{y,F(y),F^{(2)}(y),\ldots,F^{(M-1)}(y)\}
\]
If the rank condition (\ref{rankcond}) holds at $m\leq\lfloor M/2\rfloor$ and the solution $x$ obtained in (\ref{solution}) satisfies $y=F(x)$ then the subsequence is said to have the minimal polynomial of degree $m$.
\end{definition}
\begin{theorem}
If the sub-sequence $S(F,y)$ given up to $M$ terms where $M$ has polynomial order $O(n^k)$ has a minimal polynomial of degree $m\leq\lfloor M/2\rfloor$ then one solution $x$ of (\ref{eqn:fundamental}) can be computed in polynomial time
\end{theorem}
Proof of the theorem follows immediately from the way Algorithm (\ref{IncompleteAlgo}) is constructed using the Proposition (\ref{Prop:Hankel}) and the formula of solution of the inverse $x$ given in (\ref{solution}). The polynomial time assertion follows because the bound $M$ is of polynomial size in $n$ which makes the degree $m$ as well as number of terms $F^{(k)}(y)$ needed to be computed to find $x$ bounded by a polynomial order.
\begin{remark}
The incomplete algorithm can be used in estimating the density of values $y$ in $\ensuremath{\mathbb{F}}^n$ which result in a small (polynomial order) LC of the sequence $S(F,y)$. This density is the probabilistic estimate of the number of instances of $y$ for which computation of local inverse is feasible. Another variation of the incomplete algorithm is to progressively increase the degree $m$ of the minimal polynomial starting from a small degree $m_0$ at which the rank condition $\mbox{rank}\, H(m_0)=\mbox{rank}\, H(m_0+1)$ holds. Then verify whether solution $x$ obtained is correct. Increase $m$ to find the minimal polynomial and verify the solution $x$ until $m>\lfloor M/2\rfloor$. Many other variations of the algorithm are possible to exploit parallel computation of several possible minimal polynomials and possible solutions $x$ to verify. These discussions shall be a subject of a separate article on implementation of the incomplete algorithm.
\end{remark}
This section completes the presentation of the ideas behind computing local inverse in practically feasible resources in time and memory. Applications of this approach using the incomplete algorithm for cryptanalysis are described in the following sections.
\section{Local Inversion of Embedding}
In the previous section the incomplete algorithm was proposed to solve the local inversion of maps $F:\ensuremath{\mathbb{F}}^n\rightarrow\ensuremath{\mathbb{F}}^n$. In many situations of cryptanalysis however, the map available is an embedding $F:\ensuremath{\mathbb{F}}^n\rightarrow\ensuremath{\mathbb{F}}^m$ for $n<m$. In this section we address the problem of local inversion of such embeddings and extend the incomplete algorithm to find the local inverse $x$ in a given equation $y=F(x)$.
\subsection{Simultaneous maps associated with embedding}
Clearly the difficulty in applying the previous theory of inversion of maps $F:\ensuremath{\mathbb{F}}^n\rightarrow\ensuremath{\mathbb{F}}^m$ when $n<m$ is that the recurring sequence $S(F,y)$ (\ref{Sequence}) or the dynamical system (\ref{eqn:dynsys}) are not defined. Following observation is useful in defining simultaneous maps associated with an embedding and a solution $x$. Let $t=m-n$, define projection maps
\[
\Pi_i:\ensuremath{\mathbb{F}}^n\rightarrow\ensuremath{\mathbb{F}}^m
\]
for $i=1,2,\ldots (t+1)$ by
\[
\Pi_i(x_1,x_2,\ldots,x_m)=(x_{1+i-1},x_{2+i-1},\ldots,x_{(n+i-1)})
\]
Then $\Pi_(1)=(x_1,x_2,\ldots,x_n)$, $\Pi_2=(x_2,x_3,\ldots,x_{(n+1)})$ and so on till $\Pi_{(t+1)}=(x_{(t+1)},x_{(t+2)},\ldots,x_m)$
\begin{lemma}
If an embedding $F:\ensuremath{\mathbb{F}}^n\rightarrow\ensuremath{\mathbb{F}}^m$ is given with $t=m-n>0$ then equation $y=F(x)$ has a solution $x$, iff the following equations simultaneously have solution $x$
\begin{equation}\label{projectioneqns}
y(i)=F_i(x),\mbox{for}\;i=1,2,\ldots (t+1)
\end{equation}
where $y(i)=\Pi_i(y)$ and $F_i=P_i\circ F$ for $i=1,2,\ldots,(t+1)$ which are maps $F_i:\ensuremath{\mathbb{F}}^n\rightarrow\ensuremath{\mathbb{F}}^n$,
\end{lemma}
\begin{proof}
If $y=F(x)$ is satisfied then $\Pi_i(y)=y(i)=\Pi_i\circ F(x)=F_i(x)$. Hence the necessity is obvious.
Conversely if the system of equations (\ref{projectioneqns}) (called as projection equations) are satisfied by $x$ simultaneously, then for each co-ordinate of $y$ the equation
\[
y_j=f_j(x)
\]
holds for $j=1,\ldots,n$ from the first projection equation (\ref{projectioneqns}) for $i=1$. Then from projection equation for $i=2$, $y_{(n+1)}=f_{(n+1)}(x)$, from projection equation for $i=3$, $y_{(n+2)}=f_{(n+2)}(x)$ and subsequently from further projection equations, $y_{(n+j)}=f_{(n+j)}(x)$ are satisfied until $j=t$. Hence for all co-ordinates of $y$ the equations satisfied are
\[
y_{i}=f_{i}(x)\;\mbox{for}\;i=1,\ldots,m
\]
Hence $x$ satisfies the equation $y=F(x)$.
\end{proof}
The individual projection equations (\ref{projectioneqns}) have maps $F_{i}:\ensuremath{\mathbb{F}}^n\rightarrow \ensuremath{\mathbb{F}}^n$ hence the incomplete algorithm of the previous section can be employed to find the solution if and when one of them $S(F_i,y(i))$ is a periodic sequences. Hence we can now write the following
\begin{theorem}
If the any one of the sequences $S(F_i,y(i))$ for $i=1,2,\ldots, (t+1)$ is periodic and has LC of polynomial order $O(n^k)$, then a unique solution $x$ of the equation $y=F(x)$ for the given embedding exists iff $x$ satisfies each of the equations (\ref{projectioneqns}). The solution can be computed in polynomial time.
\end{theorem}
Despite the theorem asserting a solution $x$ iff all the systems (\ref{projectioneqns}) have this solution the theorem has the same limitation as before that the minimal polynomial of the sequence $S(F_i,y(i))$ can never be known in practice since only a limited polynomial size terms of the sequence can be computed. Hence only an incomplete algorithm can detect possible solutions. We extend the previous incomplete algorithm to the present case of solving the equation $y=F(x)$ when $F$ is an embedding by checking the condition for simultaneously solving the systems (\ref{projectioneqns}).
\subsection{Incomplete algorithm for solving embedding}
We now present an incomplete algorithm to solve the local inversion $y=F(x)$ when $F$ is an embedding. The basic idea is to search for an index $i$ within the system of equations among (\ref{projectioneqns}), $F_{i}(x)=y(i)$ which has a polynomially bounded subsequence of its recurring sequence with a minimal polynomial and verify whether the solution obtained for this $i$-th system satisfies all other projection systems. Even if a specific $i$-th projection equation does not satisfy the solution condition of Algorithm 1, it may satisfy the solution obtained from $j$-th system for $j\neq i$. Hence within the bound specified on computation the following algorithm searches for a solution of the embedding or else declares that there was no conclusion. From this discussion we can define an extension of the concept of LC to the case of embedding as the smallest LC of an $i$-th system which results in a solution which satisfies the complete equation (\ref{eqn:fundamental}) of the embedding map.
\begin{algorithm}\label{Embeddingsolver}
\caption{Incomplete algorithm to find the unique solution of an embedding}
\begin{algorithmic}[1]
\State\textbf{Input}: $F:\ensuremath{\mathbb{F}}^n\rightarrow\ensuremath{\mathbb{F}}^m$, $n-m=t$, $y$ in $\ensuremath{\mathbb{F}}^n$, $M$ an upper bound of polynomial order $O(n^r)$.
\State\textbf{Output}: One solution of $F(x)=y$ if one exists otherwise returns that there is no conclusion.
\Procedure{Solution\_of\_Embedding}{$y=F(x)$}
\State Compute the projection equations (\ref{projectioneqns}) for $i=1,2,\ldots,(t+1)$.
\State $i=1$
\Repeat
\State Find a solution $x$ of $y(i)=F_i(x)$ for the given bound $M$ using Algorithm 1 in section (\ref{IncompleteAlgo}).
\If {$i$-th projection equation has no conclusion on solution}
\State $i\leftarrow i+1$
\ElsIf {Verify whether
\[
y(j)=F_j(x)\mbox{ for }j=1,2,\ldots,(t+1),j\neq i
\]
}
\State Return: solution $x$ if verified for all $j$.
\State Go to \textbf{End} of procedure.
\Else
\State $i\leftarrow i+1$
\EndIf
\Until $i=(t+1)$
\State Return: No conclusion on solution within the bound.
\State \textbf{End}
\EndProcedure
\end{algorithmic}
\end{algorithm}
\begin{remark}
For an individual $i$-th projection equation there may not be a periodic orbit $S(F_i,y(i))$ nor LC of polynomial order. In such a case the algorithm increments index $i$ of the projection and examines a new system for the periodic solution. However when one of the projection systems has a periodic sequence of recurrence and the LC is within $\lfloor M/2\rfloor$, the algorithm verifies the solution with all other projection systems before returning the solution.
\end{remark}
\subsection{Solving under-determined systems}
When the map $F$ is an embedding, the system $y=F(x)$ is over-determined with larger number of equations than unknown variables to be solved. Hence it is useful to consider the other extreme when number of equations is less than the number of variables to be solved. Hence consider the map $F:\ensuremath{\mathbb{F}}^n\rightarrow\ensuremath{\mathbb{F}}^m$ where $n>m$. Let $t=n-m$, then if $x$ in $\ensuremath{\mathbb{F}}^n$ satisfies the equation there exist assignments to $a=(x_1,x_2,\ldots,x_t)$ in $\ensuremath{\mathbb{F}}^t$ such that $F(a,x_{(t+1)},x_{(t+2)},\ldots,x_n)=y$ has a solution. Hence each such assignment $a$ gives rise to a map $F_a:\ensuremath{\mathbb{F}}^m\rightarrow\ensuremath{\mathbb{F}}^m$ for which the standard theory of local inversion and Algorithm 1 developed in previous section applies. A solution to inversion is then $(a,x)$ for any solution $x$ for $F_a(x)=y$. If $t$ is small enough then such an approach to computation of inversion is feasible. We shall not treat this problem in further detail in this paper except for a special case over the binary fields explined below.
\subsubsection{Under determined systems over the binary field}
We briefly indicate a Boolean equational approach for reducing the variables in the problem of solving $y=F(x)$. This system also represents a Boolean system of equations when the field where the variables and functions in this equation take values is $\ensuremath{\mathbb{F}_{2}}$. Then following the \emph{orthogonal expansion} of functions in a fixed number of variables arising in a subset of equations as shown in \cite{suleImp} these equations can be decomposed into independent systems of equations with non overlapping variables. The systems of equations without common variables can be considered for local inversion independently in reduced number of variables. By subsequent such reductions the original system is brought to a group of sub-systems of equations of the form
\[
y_i=F_i(x^i)
\]
where $x^i$ denote the variables involved in the $i$-th sub-system which will be an embedding. A solution of the original system then can be obtained by solving each of these systems independently (or parallely) using the local inversion algorithms. Further details and applications of this approach of local inversion for discovering collisions in hash functions shall be developed in forthcoming articles.
The greatest advantage of over defined systems with $F:\ensuremath{\mathbb{F}_{2}}^n\rightarrow\ensuremath{\mathbb{F}_{2}}^m$, $n<m$ is that the forward operation of recurrence for generating the sequences $S(F_i,y(i))$ in the projected systems does not require symbolic or algebraic modeling of the function. The forward operation can be carried out by direct alogorithmic description of $F$. On the other hand the difficulty in this case $n>m$ in using the Boolean approach as compared to brute force search over variables is that the decomposition requires that the functions in equation $y=F(x)$ be represented in Boolean function models (in symbolic form). Such models are usually not readily available when the function $F$ is an algorithm involving number theoretic or finite field arithmetic. This is yet another difficult problem of computation. These issues shal explored in separate articles.
\section{Solution of the key recovery problem in symmetric encryption}
In this section we begin the first application of the incomplete algorithms Algorithm 1, 2 for local inversion. This is the problem of key recovery of symmetric encryption under Known or Chosen Plaintext/Ciphertext Attacks (KPA,CPA, CCA).
\subsection{Block cipher case}
A block cipher is an algorithm $E(.,.)$ which returns the ciphertext block $C$ when the symmetric key block $K$ and the plaintext block $P$ are input to the algorithm
\[
C=E(K,P)
\]
Similarly the decryption algorithm of the block cipher is given by relation
\[
P=D(K,P)
\]
If $P$ is known in the encryption algorithm a function $F_{P}(K)=E(K,P)$ which depends on $P$ defines the fundamental equation (\ref{eqn:fundamental})
\[
C=F_{P}(X)
\]
whose local inversion gives the key $K$. The theory developed in the previous sections then gives us the
\begin{theorem}
Let $K$ and $C$ be both strings in $\ensuremath{\mathbb{F}}^n$. If the recurring sequence
\[
S(F_{P},C)=\{C,F_{P}(C),F_{P}^{(2)}(C),\ldots\}
\]
is periodic and has LC of polynomial order $O(n^k)$ then the key $K$ can be solved by the incomplete algorithm Algorithm 1, in polynomial time using a suitable bound $M$.
\end{theorem}
The proof follows from the Theorem 3 of Section 2. The theorem can also be applied for solving the key $K$ using the local inversion of the function $F_{C}(K)=D(K,C)$ at $P=F_{C}(K)$ and an analogous theorem can be stated for this function.
\subsubsection{Variations of the inversion map}
In certain cipher algorithms (such as the older cipher DES) the block lengths of $P$ and $C$ are $64$ while the key length is $58$. Hence in such a case the local inversion maps $F_{P}$ and $F_{C}$ are embeddings and the algorithm applied for local inversion is Algorithm 2. Hence the above theorem is re-written with extension for the case of local inversion of the embedding map $F$ and follows from Theorem 4 of section 3. For instance in this case of inversion problem for DES, the difference $m-n=6$ between number of variables and equations. Hence the number of projection systems defined in (\ref{projectioneqns}) are $7$.
\subsection{Stream cipher case}
A stream cipher is defined by a dynamical system of the type
\begin{equation}\label{StreamCipher}
\begin{array}{lcl}
x(k+1) & = & F(x(k)),x(k)\in X\\
w(k) & = & f(x(k)),k=0,1,2,\ldots
\end{array}
\end{equation}
where $F$ is the state update map acting in the state space $X=\ensuremath{\mathbb{F}}^n$ and $f:X\rightarrow\ensuremath{\mathbb{F}}$ is the output map which outputs a stream $w(k)$ for $k=0,1,2,\ldots$. The initial state $x(0)$ is partitioned as $x(0)=(K,IV)$ where $K$ is the symmetric key and $IV$ is the initializing seed (called Initial Vector). Operation of such a stream cipher is carried out as follows:
\begin{enumerate}
\item Sender and receiver both share the symmetric key $K$ confidentially.
\item Sender generates an IV and generates the outpiut stream $w(k)$.
\item Sender encrypts the plaintext stream $p(k)$ as ciphertext stream
\[
c(k)=p(k)+w(k)
\]
\item Sender sends $(IV,\{p(k)\})$ to the receiver.
\item Receiver generates $w(k)$ from the $IV$ using the secret key $K$.
\item Sender decrypts $p(k)=c(k)-w(k)$.
\end{enumerate}
In a known or chosen plaintext attack an adversary has access to a partial stream of plaintext $p(j),j=k_0,k_0+1,\ldots,k_0+m$. Hence the adversary has access to the partial output stream $w(k),k=k_0,k_0+1,\ldots k_0+m$. The problem of cryptanalysis is now to recover $K$ once we are given $IV$ and partial output stream $w(k)$. We may assume that $(m+1)$ is same as number of components in $K$ or the length $l$ of $K$. Then the map to be locally inverted is
\[
\Phi_{IV}(K):\ensuremath{\mathbb{F}}^l\rightarrow\ensuremath{\mathbb{F}}^l
\]
where for a known $IV$ and symmetric key input $K$, $\Phi_{IV}(K)=\hat{w}=(w(k_0),\ldots,w(k_0+m))$, where $\Phi_{IV}()$ represents the computation from a given input $K$ in the initial condition $x(0)$ to the output stream from $w(k)$ from $k_0,\ldots,k_0+m$. We then have the following theorem for cryptanalysis of the stream cipher following Theorem 3 of Section 2,
\begin{theorem}
If the recurring sequence
\[
S(\Phi_{IV},\hat{w})=\{\hat{w},\Phi_{IV}(\hat{w}),\Phi_{IV}^{(2)}(\hat{w}),\ldots\}
\]
is periodic and has LC of polynomial order $O(l^k)$, then the key $K$ can be solved in polynomial time using the incomplete algorithm Algorithm 1 in polynomial time.
\end{theorem}
The above theorem can be modified suitably if a longer than $l$ output stream $w(k)$ is available for inversion of the embedding $\Phi_{IV}:\ensuremath{\mathbb{F}}^l\rightarrow\ensuremath{\mathbb{F}}^{(m+1)}$. The details are omitted.
\subsection{Estimates of bounds on complexities for AES}
AES block cipher is designed in different versions with multiple key sizes hence the estimates of bounds for cryptanalysis of AES by local inversion as well as the maps defined for local inversion are dependent on these key sizes. We shall briefly discuss these issues for each of the cases of versions of AES.
\subsubsection{AES128}
Plaintext $P$ block: $128$ bits, Key $K$ block: $128$ bits, Ciphertext $C$ block: $128$ bits. Number of rounds for processing $P$: $10$, Number of rounds of key schedule: $10$.
\[
\begin{array}{lcl}
\mbox{Encryption function} & : & C=E(K,P)\\
\mbox{Decryption function} & : & P=D(K,C)
\end{array}
\]
Map for local inversion in Known Plaintext Attack (KPA) (or Chosen Plaintext Attack (CCA)), $C=F_{P}(K):=E(K,P)$.
\[
F_{P}(K):\ensuremath{\mathbb{F}_{2}}^{128}\rightarrow\ensuremath{\mathbb{F}_{2}}^{128}
\]
hence $n=128$. Complexity bounds for $n^k$ for polynomial time search for local inversion are shown below. With $40$ bit brute force search, the map becomes an embedding with $n=88$.
\newline
\begin{tabular}{||l|l|l||}
\hline
$k$ & $n^k$ & $n=88$. \\
\hline
3 & 2 million & 0.7 million\\
2 & 16 thousand & 7744\\
\hline
\end{tabular}
\subsubsection{AES192}
Plaintext block $P$: $128$ bits, Key block $K$: $192$ bits, Ciphertext block $C$: $128$ bits. Number of rounds of plaintext processing: $12$, Key schedule rounds: $8$.
\[
\begin{array}{lcl}
\mbox{Encryption function} & : & C=E(K,P)\\
\mbox{Decryption function} & : & P=E(K,C)
\end{array}
\]
Map for local inversion requires two plaintext blocks $P_1$, $P_2$ encrypted by same key to ciphertext blocks $C_1$, $C_2$.
\[
F_{(P_1,P_2)}(K):\ensuremath{\mathbb{F}_{2}}^{192}\rightarrow\ensuremath{\mathbb{F}_{2}}^{256}
\]
hence the map is an embedding and $n=192$. With $40$ bit brute force search $n=152$
\newline
\begin{tabular}{||l|l|l||}
\hline
$k$ & $n^k$ & $n=152$. \\
\hline
3 & 7 million & 3.5 million\\
2 & 36 thousand & 23 thousand\\
\hline
\end{tabular}
\subsubsection{AES256}
Plaintext block $P$: $128$ bits, Key block $K$: $256$ bits, Ciphertext block $C$: $128$ bits. Number of rounds for processing $P$: $14$, Number of rounds in key schedule: $7$.
KPA/CPA: Two plaintext blocks encrypted by one key block.
\[
\begin{array}{lcl}
\mbox{Encryption function} & : & (C_1,C_2)=E(K,(P_1,P_2))\\
\mbox{Decryption function} & : & (P_1,P_2)=D(K,(C_1,C_2))
\end{array}
\]
Map for local inversion
\[
F_{(P_1,P_2)}(K):\ensuremath{\mathbb{F}_{2}}^{256}\rightarrow\ensuremath{\mathbb{F}_{2}}^{256}
\]
hence $n=256$. With $40$ bit brute force search the map is an embedding with $n=216$.
\newline
\begin{tabular}{||l|l|l||}
\hline
$k$ & $n^k$ & $n=216$. \\
\hline
3 & 16 million & 10 million\\
2 & 65 thousand & 46 thousand\\
\hline
\end{tabular}
\section{Cryptanalysis of RSA}
In this section we investigate the problem of cryptanalysis of RSA formulated as a local inversion problem. In general, in any public key encryption scheme, with private key $R$, public key $U=H(R)$, Encryption function $c=E(U,m)$ and the decryption function $m=D(R,c)$ for any known ciphertext $c$ and pair $(m,c)$, local inversion of maps $F_{U}$ and $F_{c}$ defined as
\[
\begin{array}{lclcl}
c & = & F_{U}(m) & = & E(U,m)\\
m & = & F_{c}(R) & = & D(R,c)
\end{array}
\]
solve the unknown plaintext input $m$ and private key $R$. Private key can also be solved by inverting the map $U=H(R)$.
\subsection{Inversion problems in RSA}
RSA has the private parameters $p,q,d$, $p,q$ unequal odd primes, public parameters $n=pq$ called the \emph{modulus} and an exponent $e$ which defines the private parameter $d$ such that $ed=1\mod\phi(n)$. Let the modulus has bit length $l=\log(n)+1$. We have the following local inversion problems.
\subsubsection{Breaking RSA by ciphertext inversion without factoring $n$}
The map in this case is $F_{U}$ which is obtained from the relation
\[
c=m^{e}\mod c=F_{e}(m):\ensuremath{\mathbb{F}}_{2^l}\rightarrow\ensuremath{\mathbb{F}}_{2^l}
\]
For any number $a$ in $\ensuremath{\mathbb{Z}}_n$ denote by $(a)=(a_0,a_1,\ldots,a_l)$ the binary string in the binary expansion of $a$. Similarly let $[(a)]$ denote the number in $[0,n-1]$ corresponding to the binary $l$-tuple $(a)$. Define the map $F_{e}:\ensuremath{\mathbb{F}_{2}}^{l}\rightarrow\ensuremath{\mathbb{F}_{2}}^{l}$
by
\[
(y)=F_{e}(x):=(x^e\mod n)
\]
The dynamical system (\ref{eqn:dynsys}) defined by this map in $\ensuremath{\mathbb{F}_{2}}^l$ is
\begin{equation}\label{RSAdyn1}
(y_{(j+1)})=(y_j^e\mod n), j=1,2,\dots
\end{equation}
where $y_1=(c)$. Hence this generates the sequence
\[
S(F_{e},c)=\{(c),(c^e\mod n),(c^{e^2}\mod n),\ldots\}
\]
Now note that this map $F_{e}$ has unique inverse $x=m$ in $[0,n-1]$ for any given $c$ in $[0,n-1]$ because of the arithmetic of RSA.
Then from Theorem 3 we get the following theorem on cryptanalysis of RSA for recovering plaintext $m$ given ciphertext $c$ without factoring the modulus
\begin{theorem}
If the sub-sequence
\[
S(F_{e},c)=\{(c),(c^e\mod n),(c^{e^2}\mod n),\ldots,(c^{e^M}\mod n)\}
\]
of the recurrence of system (\ref{RSAdyn1})
is given upto $M$ terms where $M$ is of polynomial order $O(l^r)$ and has LC of polynomial order $m\leq\lfloor M/2\rfloor$, then the plaintext $m$ can be recovered in polynomial time by from the sequence by Algorithm 1.
\end{theorem}
\begin{proof}
The sequence $S(F_{e},c)$ is periodic. If the subsequence is given upto $M$ terms of polynomial order and the minimal polynomial of the full sequence exists then from Theorem 3 it follows that the minimal polynomial and the local inverse can be computed in polynomial time using Algorithm 1. Hence the plaintext $x=m$ is found such that $c=x^e\mod n$.
\end{proof}
\begin{remark}
Note that this plaintext recovery using local inversion of $F_{e}$ does not utilize factorization of $n$ in any way. On the other hand since the solution $m$ for a given $c$ is unique the sequence $S(F_{e},c)$ is periodic. Hence there is always a minimal polynomial for the sequence and a solution of the inverse of $c$.
\end{remark}
The well known cycling attack on RSA \cite{GysSeb} determines the period of the sequence $S(F_{e},c)$. However this attack is not feasible because the period of this sequence is exponential. While the LC of the sequence might turn out to be of polynomial size. Hence the local inversion attack has a chance of success in certain cases.
In view of the above remarks we state
\begin{corollary}
RSA map $c=m^e\mod n$ can be reversed without factoring the modulus $n$.
\end{corollary}
\begin{proof}
Follows from Theorem 3 since the sequence $S(F_{e},c)$ is periodic there exists the minimal polynomial which computes the local inverse as the last element of the periodic sequence. Hence decryption is achieved without factoring.
\end{proof}
\subsubsection{Breaking RSA using CCA for any encryption using the same private keys without factoring $n$}
This is another local inversion attack possible on RSA to decrypt any ciphertext without factoring the modulus as long same private keys are used for encryption. Consider the function $F_{c}$ defined above used for CCA, using the decryption function of RSA.
\[
m=F_{c}(d):=c^d\mod n
\]
Note that the unknown in this map is the private key $d$ which belongs to $\ensuremath{\mathbb{Z}}_{\phi(n)}$. Since in general
\[
\phi(n)\leq (0.6)n
\]
The number of bits for the domain of the map to be inverted which is $\ensuremath{\mathbb{Z}}_{\phi(n)}$ can be chosen as $l$ same as that of length of $n$. Define the map $F_{c}:\ensuremath{\mathbb{F}}_{2^l}\rightarrow\ensuremath{\mathbb{F}}_{2^l}$ on the binary representations $(x)$ of numbers in $\ensuremath{\mathbb{Z}}_n$ and $\ensuremath{\mathbb{Z}}_{\phi(n)}$ by
\[
(y)=F_{c}((x)):=(c^{[(x)]}\mod n)
\]
The dynamical system generated by this map is
\begin{equation}\label{RSAdyn2}
(y_{(j+1)})=(c^{y_j}\mod n),j=1,2,\ldots
\end{equation}
with $y_1=(m)$. The sequence generated by the map is then
\[
\{y_1=(m),y_2=(c^m\mod n),y_3=(c^{[y_2]}\mod n,\dots\}
\]
Note that the map $F_c(.)$ does not have GOE. Hence all such sequences are periodic. We can now state,
\begin{theorem}
Consider the CCA on RSA giving the pair $(m,c)$ to the attacker. If the sub-sequence of the sequence of recurrences of the system (\ref{RSAdyn2})
is given upto $M$ terms where $M$ is of polynomial order $O(l^r)$ and has LC of polynomial order $m\leq\lfloor M/2\rfloor$, then the Algorithm 1 computes the decryption of any $c$ obtained using the same public keys in polynomial time.
\end{theorem}
\begin{proof}
Conditions of the theorem grant that that the subsequence $S(F_{c},m)$ given upto $M$ terms has a minimal polynomial of polynomial order. Hence from theorem 3 we get the unique inverse of $m$ in periodic the sequence of recurrence of the system (\ref{RSAdyn2}). Let the period of the sequence be $N$. Then $[(y_{N})]=m$ and
\[
m=c^{[y_{(N-1)}]}\mod n
\]
From the RSA decryption relation it follows that
\[
c=m^e\mod n=c^{e[y_{(N-1)}]}\mod n
\]
Which implies $e[y_{(N-1)}]=1\mod\phi(n)$ and hence for any other ciphertext $\tilde{c}$ created from the same public keys $e,n$.
\[
\tilde{m}=c^{[y_{(N-1)}]}\mod n
\]
decrypts $\tilde{c}$.
\end{proof}
\begin{remark}
Although the actual inverse $y_{(N-1)}$ need not equal to $d$, the decryption works as long as same private keys are used in the encryption and $d$ for decryption. Hence once the local inversion is successful for one pair $(m,c)$ any other ciphertext using the same private keys is decrypted.
The theorem shows that the local inversion does not involve factoring the modulus.
\end{remark}
In view of the above remarks we state
\begin{corollary}
RSA can be decrypted in a CCA given $(m,c)$ using local inversion of the map $F_{c}$ without factoring the modulus $n$ and the resultant local inverse can decrypt any ciphertext obtained by the same public keys.
\end{corollary}
\begin{proof}
In any CCA, the sequence $S(F_{c},m)$ is periodic. Hence the sequence has a minimal polynomial which allows local inversion of the map $F_{c}$ to find $x$ such that $m=F_{c}(x)$. The inverse then satisfies $m=c^x\mod n$.
\end{proof}
\subsubsection{Estimates of LC for feasible solution}
As per above theorems on polynomial time solvability of the local inversion problems, the estimates of sizes of linear systems to be solved or the LC are calculated for standard sizes of lengths of RSA modulus. Following table shows the estimates of largest sizes of linear systems required to be solved in the Algorithm 1.
\newline
\begin{tabular}{||l|l|l|l||}
\hline
$l$-length of $n$ & $k$ & $M$ & $m$ or the LC\\
\hline
1024 & 3 & 1 Billion & 537 Million\\
1024 & 2 & 1 Million & 524,288 \\
2048 & 3 & 8.5 Trillion & 4.3 Trillion\\
2048 & 2 & 4.2 Million & 2.1 Million\\
\hline
\end{tabular}
\subsubsection{Factoring as local inversion}
The third way to attack RSA by local inversion is to invert the map which generates the public key from the private key. This is the factorization problem of computing factors of $n$. Analysis of LC of this map for solving factorization is yet another interesting application which shall be investigated in a separate article. Most previously known approaches to factorization are based on Number Theory. Local inversion approach shall provide a new approach to factoring.
\section{Solution of Elliptic Curve Discrete Log Problem (ECDLP) as Local inversion}
This section considers another important problem of cryptanalysis that of solving the ECDLP. In this problem an elliptic curve $E(\ensuremath{\mathbb{F}}_q)$ is given over the field $\ensuremath{\mathbb{F}}_q$ of char not equal to $2,3$. The Weierstass normal equation of $E$ is
\[
y^2=x^3+Ax+B
\]
where $A,B$ are given in $\ensuremath{\mathbb{F}}_q$. The points on $E$ are chosen with co-ordinates $(x,y)$ in $\mathbb{F}_{q}$. Another class of curves used in practice are Koblitz curves $E(\ensuremath{\mathbb{F}}_{2^n})$.
In the discrete log problem there are given points $P$ and $Q=[m]P$ in $E$ where $m$ is the integral multiplier. It is required to solve for the multiplier $m$. Define the map
\[
F_{P}:m\ensuremath{\rightarrow}[m]P
\]
then the local inversion of $Q=F_{P}(m)$ solves the ECDLP. However the map as described needs to be expressed in the standard form of the local inversion problem described earlier so that the condition for feasible solution of inversion of Theorem 3 can be utilized.
\subsection{Formulation as local inversion}
The multiplier $m$ is less than the order of the cyclic group $n=<P>$ in $E$. Sometimes the group $E$ itself has prime order $n=\sharp E$ hence the order of $<P>$ is $n$. Hence to fix the number of bits in $m$ we consider estimates of the order of $E$. The well known bound on the order of $E$ is
\[
\sharp E(\mathbb{F}_{q})\leq q+1+2\sqrt{q}
\]
Assuming $q>4$ we have $\sharp E\leq 2q$. On the other hand the point $Q$ in $E$ has two co-ordinates in $\mathbb{F}_{q}$. Thus the bit length of $\sharp E\leq 1+\log (2q)=2+\log q=l$ while the bit length of two co-ordinates of a point taken together is $1+\log (2q)=l$. Consider the map $F_{P}$ defining the scalar multiplication of $P$ in $E$
\[
\begin{array}{lcl}
F_{P} & : & \ensuremath{\mathbb{Z}}_n\rightarrow E\\
& & m\ensuremath{\rightarrow} [m]P
\end{array}
\]
In the binary co-ordinate expansion on both sides this mapping is
\begin{equation}\label{mapFPm}
F_{P}((m))=((Q_x),(Q_y))
\end{equation}
where $(m)$ denotes the co-efficients in the binary expansion of $m$ and $(Q_x)$, $(Q_y)$ are co-efficients in the binary expansions of co-ordinates of $Q=[m]P$. We shall denote the binary expansion of the co-ordinate pair of $Q$ as $(Q)$.
\subsubsection{Formulation of $F_{P}$ as a map over the binary field}
In order to utilize the previous theory on local inversion of maps we need to formulate the map (\ref{mapFPm}) as a map in the cartesian spaces of $\ensuremath{\mathbb{F}_{2}}$ and understand whether it is an embedding.
Let $r=1+\log n$ where $n$ is the order of $<P>$. Then $F_{P}$ in (\ref{mapFPm}) represents a map $F_{P}:\ensuremath{\mathbb{F}_{2}}^r\rightarrow\ensuremath{\mathbb{F}_{2}}^l$ where $r<l$. Thus $F_{P}$ is an embedding. Hence it is required to apply Algorithm 2 to solve the embedding equation for the local inversion of $F_{P}(m)=Q$ from the binary representation in (\ref{mapFPm}). The application of Algorithm 2 requires that $n$ the order of $P$ is known. Let $t=l-r$, then the projection equations (\ref{projectioneqns}) give $(t+1)$ standard equations
\[
\Pi_i\circ F_{P}(x)=\Pi_i((Q)),i=1,2,\ldots (t+1)
\]
denote by $F_i=\Pi_i\circ F_{P}$ and $y(i)=\Pi_i((Q))$ where $\Pi_i$ are projection on $r$ components of $y$ as defined in (\ref{projectioneqns}). Following Theorem 3 now we have
\begin{theorem}
If for any of the indices $i$, $1\leq i\leq (t+1)$ the projection equation $F_{i}(x)=y(i)$ has a periodic recurrence sequence $S(F_{i},y(i))$ with a LC $m\leq\lfloor M/2\rfloor$ where $M$ is of polynomial order $O(r^k)$ and the local inverse $x$ satisfies all other projection equations then the ECDLP is solved in polynomial time by Algorithm 1.
\end{theorem}
\begin{proof}
For each of the projections $\Pi_i$ the equations $F_i(x)=y(i)$ have the map $F_{i}:\ensuremath{\mathbb{F}_{2}}^r\rightarrow\ensuremath{\mathbb{F}_{2}}^r$. Hence if the recurrent sequence defined by the system (\ref{eqn:dynsys}) for $F_i$
\[
y(i)_{(j+1)}=F_i(y(i)_j),j=0,1,2,\ldots
\]
where $y(i)_0=\Pi_i((Q))$, is periodic and has a minimal polynomial of deg $m$ then the local inverse $x$ satisfying $F_i(x)=y(i)$ can be computed in polynomial time. Since this is a unique solution in the periodic orbit of the recurrence sequence $S(F_i,y(i))$, if this solution also satisfies all other projection equations, then $x$ satisfies the equation (\ref{mapFPm}) of the embedding. Hence the ECDLP is the local inverse $x$ which is solvable in polynomial time.
\end{proof}
The sizes of fields $\mathbb{F}_{q}$ for practically used elliptic curves are close to about $256$ bits such as for instance in the current bitcoin curve $\mbox{secp}256k1$. For such sizes of $q=2^{256}$ and elliptic curves defined on them we have $l=258$. Following table gives sizes of $k$, $M$ and $m$ for the elliptic curve $\mbox{secp}256k1$.
\newline
\begin{tabular}{||l|l|l|l||}
\hline
$l$ & $k$ & $M$ & $m$\\
\hline
258 & 3 & 17 Million & 8.5 Million\\ 258 & 2 & 66564 & 33282\\
\hline
\end{tabular}
\subsection{Discrete logarithm over prime fields as local inversion}
The discrete logarithm computation over the multiplicative group of finite fields has also been an important problem in cryptography called in short as Discrete Log Problem (DLP). In a prime field $\mathbb{F}_{p}$ the DLP is concerned with computation of the index $x$ such that
\[
b=a^x\mod p
\]
where $a,b$ are given in $[1,p-1]$ and $x$ belongs to $[0,p-2]$. $x$ is called the \emph{Discrete Log} of $b$ with respect to base $a$. Since
\[
a^x\mod p=a^{(x\mod (p-1)}\mod p
\]
by Fermat's theorem. Consider the map
\[
F_a:\mathbb{F}_{p}\rightarrow\mathbb{F}_{p}
\]
such that $F_a(0)=F_a(p-1)=1$. For all other $x$ the map is as defined above. Then the GOE of $F_a()$ is the only point $0$ in $\mathbb{F}_{p}$ since there does not exist an $x$ in $[0,p-2]$ such that $F_a(x)=0$. Hence only $F_a(x)=1$ has two solutions $x=0$ and $x=p-1$. For $b\neq 1$ the local inverse is unique in a periodic orbit. The sequence $S(F_a,b)$ is given by
\begin{equation}\label{Fpseq}
S(F_a,b)+\{b,a^b\mod p,a^{(a^b\mod p)}\mod p,\ldots\}
\end{equation}
where the recurrence formula is given by
\begin{equation}\label{Fprecurrence}
\begin{array}{lcl}
F_a(b) & = & a^b\mod p \\
F_a^{(2)}(b) & = & a^{a^b\mod p}\mod p\\
F_a^{(k+1)}(b) & = &
a^{F_a^{(k)}(b)}\mod p
\end{array}
\end{equation}
Thus for $b\neq 1$ the sequence $S(F_a,b)$ is periodic. Hence following Theorem 2 we have
\begin{corollary}
For $b\neq 1$ every sequence $S(F_a,b)$ (\ref{Fpseq}) in a prime field has a minimal polynomial (\ref{minpoly})
\[
m(X)=X^{(m)}-\sum_{i=0}^{(m-1)}\alpha_iX^i
\]
over $\mathbb{F}_{p}[X]$ with $\alpha_0\neq 0$ and the DL of $b$ with respect to base $a$ is the local inverse (\ref{solution})
\[
x=(1/\alpha_0)F_a^{(m-1)}(b)-\sum_{i=1}^{(m-1)}\alpha_iF_a^{(i-1)}(b)
\]
\end{corollary}
Proof follows from the definition of the recurrence map defined in (\ref{Fprecurrence}) and Theorem 2. Let $l=\mbox{length}\;p$. Then from Theorem 3 we have
\begin{corollary}
If the subsequence of $S(F_a,b)$ given upto polynomial number of terms $M=O(l^k)$ has a minimal polynomial of degree $m\leq\lfloor M/2\rfloor$ over $\mathbb{F}_{p}[X]$ then the DL of $b$ with respect to base $a$ can be computed in polynomial time.
\end{corollary}
\subsection{Discrete logarithm over binary extension fields by local inversion}
The case of defining the map for computing DL as local inverse in extension fields is now considered. Consider the field $\ensuremath{\mathbb{F}}=\ensuremath{\mathbb{F}}_{2^n}$ and let $a$ be a primitive element of $\ensuremath{\mathbb{F}}^*$. Then the exponent equation over $\ensuremath{\mathbb{F}}$ is
\[
b=a^x
\]
where $x\in [0,2^n-1]$ and $a,b$ are in $\ensuremath{\mathbb{F}}^*$. In a polynomial basis for $\ensuremath{\mathbb{F}}$, $a,b$ have $n$-bit representation, while the index $x$ also requires $n$-bits. Hence exponentiation can be formulated as the map
\begin{equation}\label{Extfieldexponent}
\begin{array}{lcl}
F_{a} & : & \ensuremath{\mathbb{F}_{2}}^n\rightarrow\ensuremath{\mathbb{F}_{2}}^n\\
& & (x)\ensuremath{\rightarrow} (a^{[(x)]})
\end{array}
\end{equation}
where $(x)=(x_0,\ldots,x_{(n-1)})$ is a binary representation of the index $x$ in $[0,2^n-1]$, $[(x)]$ is the reversal of a binary $n$-bit string $(x)$ as a number in $[0,2^n-1]$, $(a)$ denotes the $n$-bit representation of $a$ in $\ensuremath{\mathbb{F}}$ in a fixed polynomial basis. Hence the recurrence can now be defined starting from $b$ in $\ensuremath{\mathbb{F}}$ by relations
\begin{equation}\label{Recinextfield}
\begin{array}{lcl}
F_a(b) & = & (a^[(b)])\\
F_a^{(k+1)}(b) & = & (a^{[(F_a^{k}(b))]})
\end{array}
\end{equation}
The map $F_a$ has GOE the only point $(0)$ (the zero in $\ensuremath{\mathbb{F}}$). Every point $b\neq 1$ has a periodic orbit. Hence we can now have an identical corollary in the extension field case for computation of the DL.
\begin{corollary}
If the subsequence of $S(F_a,b)$ given upto polynomial number of terms $M=O(n^k)$ has a minimal polynomial of degree $m\leq\lfloor M/2\rfloor$ over $\ensuremath{\mathbb{F}_{2}}[X]$ then the DL of $b$ with respect to base $a$ can be computed in $\ensuremath{\mathbb{F}}_{2^n}$ in polynomial time.
\end{corollary}
Proof follows from definitions of the exponent map (\ref{Extfieldexponent}), the recurrence (\ref{Recinextfield}), Theorem 2 and Theorem 3.
The case of DL computation over extension fields of other characteristics can be discussed on similar lines after defining the exponent map and the recurrence relation. These developments are omitted.
|
{'timestamp': '2022-02-15T02:40:14', 'yymm': '2202', 'arxiv_id': '2202.06584', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06584'}
|
arxiv
|
\section{A Liveness Bug in the Byzantine Consensus of Cachin et
al.~\cite{cachin-book}}
\label{sec:bug}
Cachin et al.'s book~\cite[\S{}5.6.4]{cachin-book} includes an implementation of
Byzantine consensus using an abstraction that, similarly to our SMR
synchronizers, allows clients to flag potential protocol-specific failures. We
now show that their implementation violates the Termination property of
Byzantine consensus, requiring that every correct process eventually decides
some value. Cachin et al.'s Byzantine Consensus algorithm (Alg. 5.19) relies on
a Byzantine Epoch-Change abstraction (Alg. 5.15) which guarantees that
eventually all correct processes enter the same epoch with a correct leader. The
Epoch-Change itself is implemented using a Byzantine Eventual Leader Detector
(Alg. 2.10), which outputs the leader for correct processes to follow. The
Leader Detector considers the current leader faulty if more than $f$ correct
processes have ``complained'' about its behavior via a special call. In
Byzantine Consensus a process complains about the current leader if it fails to
observe a decision within a given time duration. This, however, results in a
problem if some correct processes stop complaining while others are still
unhappy.
To see this, consider an execution of Byzantine Consensus (Alg. 5.19) where all
correct processes enter an epoch $e$ with a faulty leader. The leader may make a
valid proposal to $f+1$ correct processes and withhold it from the remaining $f$
correct processes. Since the consensus algorithm operates based on quorums of
$2f+1$ processes, the faulty processes may then execute the algorithm so that
only the $f+1$ correct processes that received the leader's proposal decide in
epoch $e$. These $f+1$ correct processes will then stop complaining. For the
remaining $f$ correct processes to decide, they need to switch to a new epoch
with a correct leader. But they will not be able to achieve this unless faulty
processes cooperate, because to nominate a different leader, the Leader Detector
requires more than $f$ processes to complain (Alg. 2.10). This breaks the
Eventual Leadership property of Epoch-Change (Module 5.12) and prevents the
remaining $f$ correct processes from ever reaching a decision, violating the
Termination property of Byzantine Consensus. This bug has been confirmed by one
of the book's authors~\cite{cristian-personal}. It is similar to a bug recently
discovered in PBFT's read-only request optimization~\cite{alysson-reads}.
The bug can be easily fixed by reliably broadcasting decisions, as we do in
PBFT-light\xspace (\S\ref{sec:pbft}). But even with this fix, the Eventual Leadership
property of Epoch-Change will remain broken, since correct processes will be
allowed to remain forever in a view with a faulty leader. This shows that the
abstractions proposed in~\cite{cachin-book} are not well-suited for implementing
a live Byzantine Consensus. These abstractions are also underspecified: the
implementation of Byzantine Eventual Leader Detector (Alg. 2.10) will only
satisfy its specification (Modules 2.10) if clients use it in a particular way
that has not been formalized. Informally, the authors require that correct
processes eventually cease to complain against a correct leader and in their
proof sketches justify that this will happen because the processes ``wait long
enough for the leader to achieve its goal''. But this argument is circular,
since for processes to stop complaining they need to get consensus decisions,
and for this the Leader Detector has to nominate a correct leader. Such circular
reasoning is known to be unsound for liveness properties\footnote{M. Abadi and
L. Lamport. Conjoining specifications. ACM Trans. Program. Lang. Syst.,
17(3):507-534, 1995.}.
A part of Cachin et al.'s consensus protocol was also used in the BFT-SMaRt
protocol of Bessani et al.~\cite{bftsmart,bftsmart-thesis}. This was based on an
abstraction of {\em validated and provable (VP) consensus}, which allows its
clients to control when to change the leader via a special {\em VP-Timeout}
call. The overall BFT-Smart protocol appears to be correct, but its liveness
proof sketch suffers from issues with rigor similar to those of Cachin et
al.'s. In particular, the VP-Consensus abstraction is underspecified: the
authors require VP-Consensus to satisfy the Termination property, but to ensure
this, its clients have to use {\em VP-Timeout} in particular ways that have not
been formalized. In particular, clients have to leave enough time in between
{\em VP-Timeout} calls for consensus to decide if the leader is correct; this in
its turn requires knowledge about the time necessary for such a decision. Thus,
Lemma A2 in~\cite[\S{}A]{bftsmart-thesis} cannot hold for an arbitrary
VP-Consensus implementation.
\subsection{Latency Bounds for PBFT-rotation\xspace}
\label{app:latency}
Assume that PBFT-rotation\xspace is used with our SMR synchronizer in
Figure~\ref{fig:sync}. We now quantify its latency using the bounds for the
synchronizer in Theorem~\ref{thm:smr-sync-correct}. We again assume the
existence of a known upper bound $\Delta$ on the maximum value of the
post-${\sf GST}$ message delay. We also modify the protocol in
Figure~\ref{fig:pbft-castro-normal} so that in lines
\ref{line:rotation:timer-inc1}-\ref{line:rotation:timer-inc2} it does not
increase ${\sf dur\_recovery}$ and ${\sf dur\_delivery}$ above $4\Delta$ and
$\max\{4\Delta, T+3\Delta\}$, respectively. This corresponds to the bounds in
Lemma~\ref{thm:pbft-facts}(1) and preserves the protocol liveness.
We establish latency bounds for two scenarios key to the protocol's
performance. Our first bound considers the case when the protocol starts during
the asynchronous period, before ${\sf GST}$. We quantify how quickly after ${\sf GST}$ the
protocol enters the first functional view $\mathcal{V}$ in which a correct leader can
propose a full batch of $B$ values that will be delivered by all correct
processes. This view $\mathcal{V}$ is the same as the one in Bounded Entry\xspace for our synchronizer,
defined by Theorem~\ref{thm:smr-sync-correct}. For simplicity, we assume that
timeouts are high enough at ${\sf GST}$.
\begin{theorem}
Assume that all correct processes start executing PBFT-rotation\xspace before ${\sf GST}$ and
that at ${\sf GST}$ each of them has ${\sf dur\_recovery} > 4\delta$ and
${\sf dur\_delivery} > \{4\delta, T+3\delta\}$. Let $\mathcal{V}$ be defined as in
Theorem~\ref{thm:smr-sync-correct}. Then
$\tl{\mathcal{V}} \le {\sf GST} + \rho + 4\Delta+ B \cdot \max\{4\Delta, T+3\Delta\} +
3\delta$, and if ${\sf leader}(\mathcal{V})$ is correct, it proposes $B$ values in $\mathcal{V}$ that
are delivered by all correct processes.
\label{thm:pbftr-latency1}
\end{theorem}
Intuitively, the bound in the theorem captures worst-case scenarios in which
some correct processes may need to spend up to time
$4\Delta+ B \cdot \max\{4\Delta, T+3\Delta\}$ in a non-functional view $\mathcal{V}-1$,
e.g., to commit $B$ ${\tt nop}$ values generated by a Byzantine leader. The theorem
shows that PBFT-rotation\xspace, like PBFT-light\xspace, recovers after a period of asynchrony in bounded
time.
We now prove Theorem~\ref{thm:pbftr-latency1}.
The following lemma bounds the latency of entering $\mathcal{V}=1$.
\begin{lemma}
Assume that all correct processes
starts executing PBFT-rotation\xspace before ${\sf GST}$.
If $\mathcal{V} = 1$, and some correct process
enters $\mathcal{V}$, then any correct process that enters $\mathcal{V}$ will do that
no later than at ${\sf GST} + \rho + \delta$.
\label{lem:pbftr-view1-lat}
\end{lemma}
{\em Proof.}
When a correct process starts the protocol, it calls ${\tt advance}$ from view $0$
unless it has already entered a higher view. Therefore,
$\taelast{0}<{\sf GST}$.
Applying the first clause of
Property~\ref{eq:lat-bound1:main}, we get $\tl{1} \le
\max(\taelast{0}, {\sf GST}+\rho) + \delta = {\sf GST} + \rho + \delta$,
as required.\qed
\smallskip
\smallskip
We next consider the case of $\mathcal{V} > 1$.
\begin{lemma}
Assume that all correct process starts executing PBFT-rotation\xspace before
${\sf GST}$ and at ${\sf GST}$
each correct process has ${\sf dur\_recovery} > 4\delta$ and
${\sf dur\_delivery} > \max\{4\delta, T+3\delta\}$.
Then, if $\mathcal{V} > 1$, and some correct process enters $\mathcal{V}$, then
$\tl{\mathcal{V}} \le {\sf GST} + \rho + 4\Delta+ B \cdot \max\{4\Delta, T+3\Delta\}
+ 3\delta$.
\label{lem:pbftr-viewV-lat}
\end{lemma}
{\em Proof.}
Since some correct process enters $\mathcal{V} > 1$, by Proposition~\ref{sync:noskip},
some correct process enters the view $\mathcal{V}-1$ as well. Let $p_i$ be a correct
process that enters $\mathcal{V}-1$. We show that
\begin{equation}
\label{eq:pbftr-tai}
\tae{i}{\mathcal{V}-1} \le \te{i}{\mathcal{V}-1} + 4\Delta+ B \cdot \max\{4\Delta, T+3\Delta\}.
\end{equation}
If $p_i$ enters a view $>\mathcal{V}-1$ before $\te{i}{\mathcal{V}-1} + 4\Delta+ B \cdot \max\{4\Delta, T+3\Delta\}$, then~(\ref{eq:pbftr-tai}) holds. Suppose now that $p_i$ does not
enter a view $>\mathcal{V}-1$ before $\te{i}{\mathcal{V}-1} + 4\Delta+ B \cdot \max\{4\Delta, T+3\Delta\}$.
By the structure of the code, at $\te{i}{\mathcal{V}-1}$,
$p_i$ starts ${\sf timer\_recovery}$
for the duration ${\sf dur\_recovery}_i(\mathcal{V}-1)$. If ${\sf timer\_recovery}$ expires
before $p_i$ receives ${\tt NEW\_STATE}(\mathcal{V}-1,\_,\_)$ from ${\sf leader}(\mathcal{V}-1)$, $p_i$
attempts to advance from $\mathcal{V}-1$. Since ${\sf dur\_recovery}_i(\mathcal{V}-1)\leq
4\Delta$, (\ref{eq:pbftr-tai}) holds. Otherwise, $p_i$ stops
${\sf timer\_recovery}$. Assume that $p_i$ has ${\sf last\_delivered}\geq
{\sf curr\_view}\cdot B$ when it stops ${\sf timer\_recovery}$. Then, $p_i$ calls ${\tt advance}$ by
$\te{i}{\mathcal{V}-1}+{\sf dur\_recovery}_i(\mathcal{V}-1)$. Since ${\sf dur\_recovery}_i(\mathcal{V}-1)\leq
4\Delta$, (\ref{eq:pbftr-tai}) holds. Assume now that $p_i$ has ${\sf last\_delivered}<
{\sf curr\_view}\cdot B$ when it stops ${\sf timer\_recovery}$. Therefore, it starts
${\sf timer\_delivery}$ for the duration ${\sf dur\_delivery}_i(\mathcal{V}-1)$. If
${\sf timer\_delivery}$ expires, then $p_i$ calls ${\tt advance}$ by
$$
\te{i}{\mathcal{V}-1}+{\sf dur\_recovery}_i(\mathcal{V}-1)+{\sf dur\_delivery}_i(\mathcal{V}-1).
$$
Since ${\sf dur\_recovery}_i(\mathcal{V}-1)\leq
4\Delta$ and ${\sf dur\_delivery}_i(\mathcal{V}-1)\leq \max\{4\Delta, T+3\Delta\}$,
(\ref{eq:pbftr-tai}) holds. If $p_i$ stops ${\sf timer\_delivery}$, then
it delivers a value at a position $>({\sf curr\_view}-1)\cdot B$. Then $p_i$
restarts and stops ${\sf timer\_delivery}$ every time a new value
is delivered, until it delivers the value at position ${\sf curr\_view}\cdot
B$ or ${\sf timer\_delivery}$ expires. In both cases, $p_i$
attempts to advance from $\mathcal{V}-1$ by
$$
\te{i}{\mathcal{V}-1}+{\sf dur\_recovery}_i(\mathcal{V}-1)+B\cdot{\sf dur\_delivery}_i(\mathcal{V}-1).
$$
Since ${\sf dur\_recovery}_i(\mathcal{V}-1)\leq
4\Delta$ and ${\sf dur\_delivery}_i(\mathcal{V}-1)\leq \max\{4\Delta, T+3\Delta\}$,
(\ref{eq:pbftr-tai}) holds.
Since $p_i$ was picked arbitrarily, we can conclude that every correct process
that enters $\mathcal{V}-1$ either attempts to advance from it or enters a higher view no
later than at $\tl{\mathcal{V}-1} + 4\Delta+ B \cdot \max\{4\Delta, T+3\Delta\}$, and
therefore,~(\ref{eq:pbftr-tai}) holds. By
Property~\ref{eq:gen-bounded-entry:main},
$$
\tl{\mathcal{V}-1} \le \max(\tm{\mathcal{V}-1}, {\sf GST}+\rho) + 2\delta.
$$
Since by the definition of $\mathcal{V}$, $\tm{\mathcal{V}-1} \le {\sf GST}+\rho$, we have
$$
\tl{\mathcal{V}-1} \le {\sf GST} + \rho + 2\delta.
$$
Thus,
$$
\taelast{\mathcal{V}-1} \le \tl{\mathcal{V}-1} + 4\Delta+ B \cdot \max\{4\Delta,
T+3\Delta\} \le {\sf GST} + \rho + 2\delta + 4\Delta+ B \cdot \max\{4\Delta, T+3\Delta\}.
$$
We can now apply the first clause of
Property~\ref{eq:lat-bound1:main} to obtain
\begin{multline*}
\tl{\mathcal{V}} \le \max(\taelast{\mathcal{V}-1}, {\sf GST} + \rho) + \delta \le
\max({\sf GST} + \rho + 2\delta + 4\Delta+ B \cdot \max\{4\Delta, T+3\Delta\}, {\sf GST} + \rho) + \delta \le
\\
{\sf GST} + \rho + 4\Delta+ B \cdot \max\{4\Delta, T+3\Delta\} + 3\delta,
\end{multline*}
as required.
\qed
\smallskip
\paragraph{\rm\it Proof of Theorem~\ref{thm:pbftr-latency1}.}
By Lemma~\ref{proposition:enter-all}, some correct process eventually
enters $\mathcal{V}$.
By the theorem's premise, all correct processes start the protocol
before ${\sf GST}$.
Thus, by Lemma~\ref{lem:pbftr-view1-lat},
$$
\tl{1} \le {\sf GST} + \rho + \delta
< {\sf GST} + \rho + 4\Delta+ B \cdot \max\{4\Delta, T+3\Delta\} + 3\delta.
$$
And, if $\mathcal{V} > 1$, then by Lemma~\ref{lem:pbftr-viewV-lat},
$$
\tl{\mathcal{V}} \le {\sf GST} + \rho + 4\Delta+ B \cdot \max\{4\Delta, T+3\Delta\} + 3\delta.
$$
Since the timeout durations are monotone, the theorem's assumption about timeout durations
implies that for any process $p_i$ that enters $\mathcal{V}$
$$
{\sf dur\_recovery}_i(\mathcal{V}) > 4\delta\, \wedge\,
{\sf dur\_delivery}_i(\mathcal{V}) > \max\{4\delta, T+3\delta\}.
$$
By Lemma~\ref{thm:pbft-facts}(1), some correct process calls ${\tt advance}$
in $\mathcal{V}$ due to delivering a full batch of $B$ values proposed
by ${\sf leader}(\mathcal{V})$. By reliably broadcasting committed values,
the protocol guarantees that all these values will be eventually delivered
by all correct processes, as required.\qed
\smallskip
\smallskip
Our next bound assumes that the protocol executes during a synchronous period
and quantifies how quickly it recovers after encountering a view $v$ with a
faulty leader. For simplicity, we assume that this leader is initially crashed
and the views $<v$ operated normally. The following theorem gives the precise
formulation of the informal Theorem~\ref{thm:pbftr-latency2-informal}.
\begin{theorem}
Assume that all correct processes start executing PBFT-rotation\xspace after ${\sf GST}$, and
consider a view $v$ such that ${\sf leader}(v)$ is initially crashed. Suppose that
initially ${\sf dur\_recovery} > 4\delta$ and
${\sf dur\_delivery} > \max\{4\delta, T+3\delta\}$ and, in each view $v' < v$,
each correct process calls ${\tt advance}$ due to delivering a full batch of
values proposed in $v'$. Then $\tl{v+1} \le \tl{v} + R + \delta$, where $R$ is
the initial value of ${\sf dur\_recovery}$. Furthermore, if ${\sf leader}(v+1)$ is
correct, then it proposes $B$ values in $v+1$ that are delivered by all
correct processes.
\label{thm:pbftr-latency2}
\end{theorem}
The bound established by the theorem illustrates the benefits of how PBFT-rotation\xspace (as
well as PBFT) manages timeouts. Since processes do not increase timeouts in good
views with correct leaders, they pay a minimal latency penalty once they
encounter a bad leader.
We now prove Theorem~\ref{thm:pbftr-latency2}. The following lemma bounds
the latest time by which a correct process process can enter view $v+1$
assuming the leader of view $v>0$ is initially crashed.
\begin{lemma}
Assume that all correct processes start executing PBFT-rotation\xspace after ${\sf GST}$,
and consider a view $v > 0$ such that ${\sf leader}(v)$ is initially
crashed. Suppose that any correct processes $p_i$ that enters
$v$ has ${\sf dur\_recovery}_i(v) = R$. If a correct process enters $v+1$, then
$\tl{v+1}\le\tl{v} + R + \delta$.
\label{lem:pbft-lat2}
\end{lemma}
{\em Proof.}
Since some correct process enters $v+1$, by Proposition~\ref{sync:noskip},
$\tm{v}\mathpunct{\downarrow}$. Consider a correct process $p_i$
that enters $v$, and assume that $p_i$ does not enter any views $>v$
before $\te{i}{v} + R$. By the protocol, $p_i$ starts ${\sf timer\_recovery}$ at
$\te{i}{v}$ to await ${\tt NEW\_STATE}(v,\_,\_)$ from ${\sf leader}(v)$.
Since $p_i$ starts executing after ${\sf GST}$, its
local clock advances at the same rate as real time. Thus, given that
${\sf leader}(v)$ is initially crashed, the $p_i$'s ${\sf timer\_recovery}$
will expire at $\te{i}{v} + {\sf dur\_recovery}_i(v) = \te{i}{v} + R$.
Hence, $p_i$ calls ${\tt advance}$ at $\te{i}{v} + R$. Therefore,
all correct processes that enter $v$ either attempt to advance
from $v$, or enter a view $>v$ no later than at $\tl{v} + R$. Hence,
$$
\taelast{v} \le \tl{v} + R.
$$
Since all correct processes start executing the protocol after ${\sf GST}$,
$\tam{0} \ge {\sf GST}$, and therefore, by Property~\ref{eq:lat-bound1:main},
$$
\tl{v+1} \le \taelast{v} + \delta \le \tl{v} + R + \delta,
$$
as required.
\qed
\smallskip
\paragraph{\rm\it Proof of Theorem~\ref{thm:pbftr-latency2}.}
Since in each view $v' < v$ all correct processes deliver $B$ values proposed in $v'$,
by the structure of the code, no correct process increases the durations of any
of its timers. Thus, ${\sf dur\_recovery}_i(v) = R$ for any correct
processes $p_i$ that enters $v$,
where $R$ is the initial value of ${\sf dur\_recovery}$. Therefore,
by Lemma~\ref{lem:pbft-lat2}, $\tl{v+1}\le\tl{v} + R + \delta$. Suppose that
${\sf leader}(v+1)$ is correct. Then by the theorem's assumption about the
initial timeout durations, and since all timeout durations are
monotone, we have that for any correct process $p_i$ that enters $v$
$$
{\sf dur\_recovery}_i(v+1) > 4\delta\, \wedge\,
{\sf dur\_delivery}_i(v+1) > \max\{4\delta, T+3\delta\}.
$$
Hence, by Lemma~\ref{thm:pbft-facts}(1), some correct process calls ${\tt advance}$
in $v+1$ due to delivering a full batch of $B$ values proposed
by ${\sf leader}(v+1)$. By reliably broadcasting committed values,
the protocol guarantees that all these values will be eventually delivered
by all correct processes, as required.\qed
\subsection{Additional Details for the Proof of Liveness of PBFT-light\xspace}
\label{sec:pbft-liveness}
\paragraph{\rm\it Proof of Lemma~\ref{thm:castro:completeness}.}
We know that at some point $p_i$ enters view $v$, and at this moment it starts
${\sf timer\_recovery}$. If the timer expires, then $p_i$ calls ${\tt advance}$ in $v$, as
required. Assume that ${\sf timer\_recovery}$ does not expire at $p_i$. Then $p_i$
stops the timer at
lines~\ref{line:castro:stoptimers},~\ref{alg:castro:stop-timerrecovery},~\ref{alg:castro:stop-timerrecovery2}
or~\ref{line:castro:stoptimers-enterview}. The latter is impossible, as this
would imply that $p_i$ enters a higher view. If $p_i$ stops the timer at
line~\ref{line:castro:stoptimers}, then it calls ${\tt advance}$ in $v$, as
required. Assume now that $p_i$ stops the timer at
lines~\ref{alg:castro:stop-timerrecovery}
or~\ref{alg:castro:stop-timerrecovery2}. This implies that $p_i$ sets
${\sf status}=\textsc{normal}$ at some point while in $v$. If $p_i$ sets ${\sf status}=\textsc{advanced}$
while in $v$, then it calls ${\tt advance}$ in $v$, as required. Thus, it remains to
consider the case when $p_i$ sets ${\sf status}=\textsc{normal}$ at some point while in $v$
and does not change it while in this view. Since $p_i$ receives
${\tt BROADCAST}(x)$ for a valid value $x$ while in a view $v$, the handler at
line~\ref{alg:castro:broadcast-msg} is executed at some point. At this point
$p_i$ starts ${\sf timer\_delivery}[x]$. If the timer expires, then $p_i$ calls
${\tt advance}$ in $v$, as required. Otherwise $p_i$ stops the timer at
lines~\ref{line:castro:stoptimers},~\ref{alg:castro:stop-timerexecute2}
or~\ref{line:castro:stoptimers-enterview}. The last two are impossible, as this
would imply that $p_i$ enters a higher view or that $x$ is delivered. In the
remaining case $p_i$ calls ${\tt advance}$ in $v$, as required.\qed
\begin{figure}[t]
\includegraphics[width=0.55\textwidth]{diagrams/delivery.pdf}
\caption{An illustration of the bound on ${\sf dur\_delivery}$ in
Lemma~\ref{thm:castro:all-good}.}
\label{fig:bounds2}
\end{figure}
\paragraph{\rm\it The remaining case in the proof of Lemma~\ref{thm:castro:timers}.}
Assume that for some value $x$, ${\sf timer\_delivery}[x]$ expires at $p_i$ in
$v$. The process starts ${\sf timer\_delivery}[x]$ when it receives
${\tt BROADCAST}(x)$ and it has not yet delivered $x$
(line~\ref{alg:castro:start-timerexecute}). Let $t$ be the time when this
happens; then $t\geq \tm{v}$ (Figure~\ref{fig:bounds2}). Because $p_i$ is the
first correct process to call ${\tt advance}$ in $v$ and
${\sf dur\_delivery}_i(v)>4\delta$, no correct process calls ${\tt advance}$ in $v$
until after $t+4\delta$. Then by Bounded Entry\xspace all correct processes enter $v$ by
$\tm{v}+2\delta$. Furthermore, by Validity\xspace no correct process can enter
$v+1$ until after $t+4\delta$, and by Proposition~\ref{sync:noskip} the same
holds for any view $>v$. Thus, all correct processes stay in $v$ at least until
$t+4\delta$.
The process $p_i$ has ${\sf status}=\textsc{normal}$ at $t$, so that by this time $p_i$ has
handled the ${\tt NEW\_STATE}$ message from the leader of $v$. Thus, all correct
processes receive ${\tt NEW\_STATE}$ by $t+\delta$. Since $t\geq\tm{v}$ and all correct
processes enter $v$ by $\tm{v}+2\delta$, all correct processes handle ${\tt NEW\_STATE}$
by $t+2\delta$. When a process handles ${\tt NEW\_STATE}(v, \_, \_)$, it sends
${\tt PREPARE}$ messages for all positions $\leq {\sf init\_log\_length}$. Therefore, by
$t+2\delta$ all correct processes send ${\tt PREPARE}$ for all positions
$\leq {\sf init\_log\_length}$.
When $p_i$ starts ${\sf timer\_delivery}[x]$, it sends ${\tt FORWARD}(x)$ to
${\sf leader}(v)$, which receives the message no later than $t+\delta$. Consider
first the case when ${\sf leader}(v)$ has $x$ in its ${\sf log}$ at position
$k\leq {\sf init\_log\_length}$ when it receives ${\tt FORWARD}(x)$. Then all
correct processes send ${\tt PREPARE}$ for all positions $\leq k$ by
$t+2\delta$. Assume now that, when the leader receives ${\tt FORWARD}(x)$, either
$x\not\in{\sf log}$ or for some $k >{\sf init\_log\_length}$ we have ${\sf log}[k]=x$. In the
former case the leader sends ${\tt PREPREPARE}(v, k, x)$ to all processes. In the
latter case, due to lines~\ref{alg:castro:set-next}
and~\ref{alg:castro:increase-next}, the leader has already sent
${\tt PREPREPARE}(v, k, x)$ to all processes. Thus, in either case the leader
sends ${\tt PREPREPARE}(v, k, x)$ no later than $t+\delta$. Hence, due to
lines~\ref{alg:castro:set-next} and~\ref{alg:castro:increase-next}, the leader
sends a ${\tt PREPREPARE}$ for all positions from ${\sf init\_log\_length}+1$ up to $k$ no later
than $t+\delta$, and all correct processes receive these messages no later than
$t+2\delta$. We have established that all correct processes have handled
${\tt NEW\_STATE}(v,\_,\_)$ by $t+2\delta$. Then all correct processes handle the
${\tt PREPREPARE}$ messages for positions from ${\sf init\_log\_length}+1$ up to $k$ by
$t+2\delta$, i.e., they send a ${\tt PREPARE}$ for each of these
positions. Furthermore, we have established that all correct processes send a
${\tt PREPARE}$ message for each position $\leq {\sf init\_log\_length}$ by
$t+2\delta$. Therefore, all correct processes send ${\tt PREPARE}$ for each position
$\leq k$ by $t+2\delta$. It then takes them at most $2\delta$ to exchange the
corresponding sequence of ${\tt PREPARE}$ and ${\tt COMMIT}$ messages. Hence, all correct
processes receive ${\tt COMMIT}$ for all positions $\leq k$ by $t+4\delta$.
Assume that when $p_i$ receives all these ${\tt COMMIT}$ messages, it has
${\sf last\_delivered}<k$. Then $p_i$ delivers $x$ by $t+4\delta$. Since $p_i$'s
${\sf timer\_delivery}[x]$ has not expired by then, the process stops the timer,
which contradicts our assumption. Therefore, when $p_i$ receives all the
${\tt COMMIT}$ messages for positions $\leq k$, it has ${\sf last\_delivered}\geq k$, so
that $p_i$ has already delivered a value $x'$ at this position. Then $p_i$ must
have formed a certificate $C'$ such that $\ensuremath{{\sf committed}}(C', v', k,
{\sf hash}(x'))$. By Proposition~\ref{lemma:pbft:committed-prepared}, for some
well-formed certificate $C''$ we have ${\sf prepared}(C'', v', k,
{\sf hash}(x'))$. Since all correct processes stay in $v$ until $t+4\delta$, we
must have $v'\leq v$. If $v=v'$, then by Proposition~\ref{lemma:pbft:singlecmd}
we get $x=x'$. If $v'<v$, then by Lemma~\ref{lemma:pbft:main} we get
$x=x'$. Hence, $p_i$ delivers $x$. By
line~\ref{alg:castro:broadcast-msg}, $p_i$ does not start ${\sf timer\_delivery}[x]$
if $x$ has already been delivered. Since $p_i$ started the timer at $t$, it
has to deliver $x$ at some point after $t$ and no later than
$t+4\delta$. Since $p_i$'s ${\sf timer\_delivery}[x]$ has not expired by then, the
process stops the timer, which contradicts our assumption. Therefore,
${\sf timer\_delivery}$ cannot expire at $p_i$.\qed
\subsection{Proof of the Latency Bounds for PBFT-light\xspace}
\label{app:pbftlatency}
\begin{lemma}
\label{lem:relbcast}
If a correct process delivers a value $x$ at $t$, then all
correct processes deliver $x$ by $\max\{t+\delta, {\sf GST}+\rho+\delta\}$.
\end{lemma}
We omit the easy proof of the lemma.
\begin{lemma}
\label{lem:earliestadv}
If a correct process $p_i$ enters a view $v$, then the earliest time it
may call ${\tt advance}$ is $\te{i}{v}+\min\{{\sf dur\_recovery}_i(v), {\sf dur\_delivery}_i(v)\}$.
\end{lemma}
{\em Proof.}
A process calls ${\tt advance}$ in a view if a timer expires. Assume first that
${\sf timer\_recovery}$ expires. The process $p_i$ starts ${\sf timer\_recovery}$ when it
enters the view $v$. Thus, if ${\sf timer\_recovery}$ expires, then $p_i$ calls
${\tt advance}$ at $\te{i}{v}+{\sf dur\_recovery}_i(v)$. Assume now that
${\sf timer\_delivery}[x]$ expires for some value $x$. The earliest time $p_i$ may
start this timer is $\te{i}{v}$. Then the earliest time $p_i$ may call
${\tt advance}$ in this case is $\te{i}{v}+{\sf dur\_delivery}_i(v)$. Thus, $p_i$
cannot call ${\tt advance}$ in $v$ before
$\te{i}{v}+\min\{{\sf dur\_recovery}_i(v), {\sf dur\_delivery}_i(v)\}$, as
required. \qed
\begin{lemma}
Assume that a correct process $p_i$ that enters $v$ receives ${\tt BROADCAST}(x)$ at
$t\geq \te{i}{v}$ for a valid value $x$. Assume that
$p_i$ does not deliver $x$ until after
$\max\{t, \te{i}{v}+{\sf dur\_recovery}_i(v)\}
+{\sf dur\_delivery}_i(v)$. Then
$\tae{i}{v}\mathpunct{\downarrow}$ and
$$
\tae{i}{v}\leq\max\{t, \te{i}{v}+{\sf dur\_recovery}_i(v)\} +
{\sf dur\_delivery}_i(v).
$$
\label{thm:castro:completeness:latency}
\end{lemma}
{\em Proof.}
We know that at some point $p_i$ enters view $v$, and at this moment it starts
${\sf timer\_recovery}$. If the timer expires, then $p_i$ calls ${\tt advance}$
in $v$ by $\te{i}{v}+{\sf dur\_recovery}_i(v)$, as
required. Assume that ${\sf timer\_recovery}$ does not expire at $p_i$. Then $p_i$
stops the timer at
lines~\ref{line:castro:stoptimers},~\ref{alg:castro:stop-timerrecovery},~\ref{alg:castro:stop-timerrecovery2}
or~\ref{line:castro:stoptimers-enterview}. If $p_i$ stops the timer at
line~\ref{line:castro:stoptimers}, then it calls ${\tt advance}$ in $v$ by $\te{i}{v}+{\sf dur\_recovery}_i(v)$, as
required. If $p_i$ stops the timer at
line~\ref{line:castro:stoptimers-enterview}, then it enters a higher view by $\te{i}{v}+{\sf dur\_recovery}_i(v)$, as
required. Assume now that $p_i$ stops the timer at
lines~\ref{alg:castro:stop-timerrecovery}
or~\ref{alg:castro:stop-timerrecovery2}. This implies that $p_i$ sets
${\sf status}=\textsc{normal}$ by $\te{i}{v}+{\sf dur\_recovery}_i(v)$ while in
$v$. If $p_i$ calls ${\tt advance}$ or enters a higher view by $\max\{t,
\te{i}{v}+{\sf dur\_recovery}_i(v)\}$, we get the required. Assume that
this is not the case. Then $p_i$ sets ${\sf status}=\textsc{normal}$ and
receives $x$ by $\max\{t, \te{i}{v}+{\sf dur\_recovery}_i(v)\}$.
Since $p_i$ has not delivered $x$ by
$\max\{t, \te{i}{v}+{\sf dur\_recovery}_i(v)\}$, by this point $p_i$ starts
${\sf timer\_delivery}[x]$. If the timer expires, then $p_i$ calls ${\tt advance}$ in
$v$ by $\max\{t, \te{i}{v}+{\sf dur\_recovery}_i(v)\} + {\sf dur\_delivery}_i(v)$,
as required. Otherwise $p_i$ stops the timer at
lines~\ref{line:castro:stoptimers},~\ref{alg:castro:stop-timerexecute2}
or~\ref{line:castro:stoptimers-enterview}. If $p_i$ stops the timer at
line~\ref{line:castro:stoptimers-enterview}, then it enters a higher view by
$\max\{t, \te{i}{v}+{\sf dur\_recovery}_i(v)\}+ {\sf dur\_delivery}_i(v)$, as
required. If $p_i$ stops the timer at line~\ref{alg:castro:stop-timerexecute2},
then it delivers $x$ by
$\max\{t, \te{i}{v}+{\sf dur\_recovery}_i(v)\}+ {\sf dur\_delivery}_i(v)$, which is
impossible. In the remaining case $p_i$ calls ${\tt advance}$ in $v$ by
$\max\{t, \te{i}{v}+{\sf dur\_recovery}_i(v)\}+ {\sf dur\_delivery}_i(v)$, as
required.\qed
\begin{lemma}
Assume that all correct processes start executing PBFT-light\xspace before ${\sf GST}$. If
$\mathcal{V} = 1$ in Theorem~\ref{thm:bounds}, then $\tm{\mathcal{V}}\mathpunct{\downarrow}$ and
$\tl{\mathcal{V}}\leq {\sf GST} + \rho + \delta$.
\label{lem:pbft-view1-lat}
\end{lemma}
{\em Proof.}
By Theorem~\ref{thm:bounds}, if $\mathcal{V}=1$, then $\GV{{\sf GST}}=0$. Since all correct
processes start executing the protocol before ${\sf GST}$, then all correct
processes attempt to advance from view $0$ and $\taelast{0}<{\sf GST}$. By Startup\xspace,
$\tm{\mathcal{V}}\mathpunct{\downarrow}$. Applying the first clause of Property~\ref{eq:lat-bound1:main}, we get
$\tl{\mathcal{V}} \le \max\{\taelast{0},{\sf GST}+\rho + \delta\}$. Since $\taelast{0}<{\sf GST}$,
then $\tl{\mathcal{V}} \le {\sf GST}+\rho + \delta$, as required.\qed
\begin{lemma}
Consider a view $v\geq\mathcal{V}$ such that $\tm{v}\geq{\sf GST}$ and ${\sf leader}(v)$ is
correct. Assume that a correct process $p_j$ broadcast a value
$x$ before $\tm{v}$. If ${\sf dur\_recovery}_i(v) > 6\delta$ and
${\sf dur\_delivery}_i(v) > 4\delta$ at each correct process $p_i$ that enters
$v$, then all correct processes deliver $x$ by $\tl{v}+\max\{\rho, \delta\} + 4\delta$.
\label{lem:all-good:latency}
\end{lemma}
{\em Proof.}
By Lemma~\ref{thm:castro:all-good}, no correct process calls ${\tt advance}$
in $v$. Therefore, by Validity\xspace, no correct process enters
$v+1$, and by Proposition~\ref{sync:noskip} the same holds for any
view $>v$. By Bounded Entry\xspace, all correct processes enter $v$. Assume that $p_j$ delivers $x$ by
$\tl{v}+\rho$. Then by Lemma~\ref{lem:relbcast} all correct processes
deliver $x$ by $\max\{\tl{v}+\rho+\delta,
{\sf GST}+\rho+\delta\}$. Since $\tm{v}\geq{\sf GST}$, we get $\tl{v}+\rho+\delta
\geq {\sf GST}+\rho+\delta$. Thus, all correct processes
deliver $x$ by $\tl{v}+\rho+\delta$, as required.
Consider now the case when $p_j$ does not deliver $x$ by
$\tl{v}+\rho$. Then $p_j$ retransmits $x$ between ${\sf GST}$ and ${\sf GST}+\rho \le
\tl{v}+\rho$, so that ${\sf leader}(v)$ receives $x$ by $\tl{v}+\rho+\delta$.
When a process enters $v$, it sends
${\tt NEW\_LEADER}$ to ${\sf leader}(v)$. The leader receives $2f+1$ of these
messages by $\tl{v}+\delta$ and sends a ${\tt NEW\_STATE}$ message to all
processes. A process handles ${\tt NEW\_STATE}$ by $\tl{v}+2\delta$ and sets
its ${\sf status}$ to $\textsc{normal}$. Since no process calls ${\tt advance}$ in $v$,
every correct process has ${\sf status}=\textsc{normal}$ after handling ${\tt NEW\_STATE}$ onwards.
We have established that ${\sf leader}(v)$ receives $x$ by $\tl{v}+\rho+\delta$.
Then ${\sf leader}(v)$ sets ${\sf status}=\textsc{normal}$ and receives $x$ by $t\leq\tl{v} +
\max\{\rho, \delta\} + \delta$. Assume that ${\sf leader}(v)$ has
delivered $x$ by $\tl{v}+\max\{\rho, \delta\} + \delta$.
Then by
Lemma~\ref{lem:relbcast} all correct process deliver $x$ by
$\max\{\tl{v}+\max\{\rho, \delta\} + 2\delta,
{\sf GST}+\rho+\delta\}$. Since $\tm{v}\geq{\sf GST}$, we get $\tl{v}+\max\{\rho,
\delta\} + 2\delta \ge {\sf GST}+\rho+\delta$. Thus, in this case all
correct processes deliver $x$ by $\tl{v}+\max\{\rho,
\delta\} + 2\delta$, as required.
Assume now that ${\sf leader}(v)$ has not
delivered $x$ by $t$. Consider
first then case when ${\sf leader}(v)$ already has $x$ in its log at $t$
because $x$ was prepared in a previous view. Then all correct processes
send ${\tt PREPARE}(v, k, {\sf hash}(x))$ for a position $k$ by
$\tl{v} + 2\delta$. Consider now the case when ${\sf leader}(v)$ either has
$x$ in its log at $t$ because it was already proposed in
$v$; or ${\sf leader}(v)$ does not have it. In this case, it follows that
${\sf leader}(v)$ sends ${\tt PREPREPARE}(v, k, x)$ to all correct processes
by $t$, which all correct processes
receive by $t+\delta$. When a correct process receives ${\tt PREPREPARE}(v,
k, x)$, it sends ${\tt PREPARE}(v, k, {\sf hash}(x))$. Thus, all
correct process send ${\tt PREPARE}(v, k, {\sf hash}(x))$ by
$t+\delta$. Since $t\leq\tl{v} +
\max\{\rho, \delta\} + \delta$. Then, in both cases, all correct
processes
send ${\tt PREPARE}(v, k, {\sf hash}(x))$ by $\tl{v} +
\max\{\rho, \delta\} + 2\delta$. It then takes the correct
processes at most $2\delta$ to exchange the sequence of ${\tt PREPARE}$ and
${\tt COMMIT}$ messages that commit $x$. Therefore, all correct
processes commit $x$ by $\tl{v}+\max\{\rho, \delta\} + 4\delta$.
Let $p_i$ be a correct process. Because ${\sf leader}(v)$ is
correct, we can show that ${\sf last\_delivered}\geq k-1$ at $p_i$ by
$\tl{v}+\max\{\rho, \delta\} + 4\delta$. If ${\sf last\_delivered}=k-1$, then
$p_i$ delivers $x$ by $\tl{v}+\max\{\rho, \delta\} + 4\delta$. If
${\sf last\_delivered}>k-1$ at $p_i$ by $\tl{v}+\max\{\rho, \delta\} +
4\delta$, then we can show that $p_i$ has already delivered $x$
before. Since $p_i$ was picked arbitrarily, we can conclude that all
correct processes deliver $x$ by
$\tl{v}+\max\{\rho, \delta\} + 4\delta$, as required. \qed
\paragraph{\it Proof of Theorem~\ref{thm:pbft-latency1}.}
Let $p_j$ be the correct process that broadcast $x$, and let $\mathcal{V}$ be defined as in
Theorem~\ref{thm:smr-sync-correct}. Assume first that $\mathcal{V}>1$. We have $\tam{0} <
{\sf GST}$ and $\tm{\mathcal{V}-1}<{\sf GST}+\rho$. Then by
Property~\ref{eq:gen-bounded-entry:main},
\begin{equation}
\tl{\mathcal{V}-1} \le {\sf GST}+\rho + 2\delta.
\label{eq:lastv}
\end{equation}
If at least one correct process $p_i$ delivers
$x$ by ${\sf GST}+\rho+2\delta+\max\{\rho+\delta,6\Delta\} + 4\Delta$, then by
Lemma~\ref{lem:relbcast}, all correct processes deliver $x$ by
${\sf GST}+\rho+3\delta+\max\{\rho+\delta,6\Delta\} + 4\Delta$, as required. Assume
now that no correct process $p_i$ delivers $x$ by
${\sf GST}+\rho+2\delta+\max\{\rho+\delta,6\Delta\} + 4\Delta$. In particular, this
implies that $p_j$ has not delivered $x$ by ${\sf GST}+2\rho + 2\delta$, so that it
retransmits $x$ between ${\sf GST}+ \rho + 2\delta$ and
${\sf GST}+2\rho+2\delta$. Consider a correct process $p_i$ that enters $\mathcal{V}-1$ and
let $t_i$ be the time when this process receives the
${\tt BROADCAST}(x)$ retransmission from $p_j$; then
\begin{equation}\label{bound-on-ti}
t_i \le {\sf GST}+2\rho+3\delta
\end{equation}
and by~(\ref{eq:lastv}),
\begin{equation}\label{bound-on-ti2}
t_i > {\sf GST}+ \rho + 2\delta \ge \te{i}{\mathcal{V}-1}.
\end{equation}
We now obtain:
$$
\begin{array}{r@{}l@{\qquad}l}
&\max\{t_i, \te{i}{\mathcal{V}-1}+{\sf dur\_recovery}_i(\mathcal{V}-1)\}
+{\sf dur\_delivery}_i(\mathcal{V}-1)\\
\le {} &\max\{t_i, \te{i}{\mathcal{V}-1}+6\Delta\}+4\Delta &
\mbox{since ${\sf dur\_recovery}_i(\mathcal{V}-1)\leq 6\Delta$ and}\\
&& \mbox{${\sf dur\_delivery}_i(\mathcal{V}-1)\leq 4\Delta$} \\
\le {} & \max\{{\sf GST}+2\rho+3\delta, \te{i}{\mathcal{V}-1}+6\Delta\} +4\Delta & \mbox{by~(\ref{bound-on-ti})}\\
\le {}&\max\{{\sf GST}+2\rho+3\delta, {\sf GST}+\rho+2\delta+6\Delta\}+4\Delta & \mbox{by~(\ref{eq:lastv})}\\
= {}&{\sf GST}+\rho+2\delta+\max\{\rho+\delta,6\Delta\} + 4\Delta
\end{array}
$$
Then, since we assume that no correct process delivers $x$ by
${\sf GST}+\rho+2\delta+\max\{\rho+\delta,6\Delta\} + 4\Delta$,
by~(\ref{bound-on-ti2}) and Lemma~\ref{thm:castro:completeness:latency} we
get $\tae{i}{\mathcal{V}-1}\mathpunct{\downarrow}$. Thus, $p_i$ either
calls ${\tt advance}$ in $\mathcal{V}-1$ or enters a higher view. If at least one correct
process enters a view higher than $\mathcal{V}$, then by
Proposition~\ref{sync:noskip}, $\tm{\mathcal{V}}\mathpunct{\downarrow}$. If all correct processes that
enter $\mathcal{V}-1$ call ${\tt advance}$, then by Progress\xspace we get $\tm{\mathcal{V}}\mathpunct{\downarrow}$ as well. By
Lemma~\ref{thm:castro:completeness:latency}, we also have
$$
\tae{i}{\mathcal{V}-1}\leq
\max\{t_i, \te{i}{\mathcal{V}-1}+{\sf dur\_recovery}_i(\mathcal{V}-1)\} +
{\sf dur\_delivery}_i(\mathcal{V}-1)
\leq
{\sf GST}+\rho+2\delta+\max\{\rho+\delta,6\Delta\} + 4\Delta
$$
for any correct process $p_i$ that enters $\mathcal{V}-1$. Applying the first clause of
Property~\ref{eq:lat-bound1:main}, we get
\begin{equation}\label{e-last-v}
\tl{\mathcal{V}} \le \max\{\taelast{\mathcal{V}-1}, {\sf GST}+\rho\}+ \delta
\le {\sf GST}+\rho+3\delta+\max\{\rho+\delta,6\Delta\} + 4\Delta.
\end{equation}
Thus, if $\mathcal{V}>1$, then either all correct processes deliver $x$ by
${\sf GST}+\rho+2\delta+\max\{\rho+\delta,6\Delta\} + 4\Delta$, or $\tm{\mathcal{V}}\mathpunct{\downarrow}$
and~(\ref{e-last-v}) holds. Furthermore, if $\mathcal{V}=1$, then by
Lemma~\ref{lem:pbft-view1-lat}, $\tm{\mathcal{V}}\mathpunct{\downarrow}$ and
$\tl{\mathcal{V}}\leq {\sf GST} + \rho + \delta$. We have thus established that either all
correct processes deliver $x$ by
${\sf GST}+\rho+2\delta+\max\{\rho+\delta,6\Delta\} + 4\Delta$, or $\tm{\mathcal{V}}\mathpunct{\downarrow}$
and~(\ref{e-last-v}) holds. In the latter case, by
Lemma~\ref{lem:all-good:latency}, all correct processes deliver $x$ by
$\tl{\mathcal{V}}+\max\{\rho, \delta\} + 4\delta$, and by~(\ref{e-last-v}),
$$
\tl{\mathcal{V}}+\max\{\rho, \delta\} + 4\delta \le
{\sf GST}+\rho + \max\{\rho+\delta, 6\Delta\} + 4\Delta+\max\{\rho, \delta\} +
7\delta,
$$
as required. \qed
\begin{lemma}
Assume that $\mathcal{V}=1$ in Theorem~\ref{thm:bounds}, $\tm{1}\geq{\sf GST}$ and ${\sf leader}(1)$ is
correct. If ${\sf dur\_recovery}_i(1) > 5\delta$ and
${\sf dur\_delivery}_i(1) > 4\delta$ at each correct process $p_i$ that enters
$1$, then no correct process calls ${\tt advance}$ in $v$.
\label{thm:all-good:veq1}
\end{lemma}
We omit the proof of this lemma. It is virtually identical to that of
Lemma~\ref{thm:castro:all-good}, considering the special case of
$v=\mathcal{V}=1$ and the optimization by which in view $1$ the processes do
not exchange ${\tt NEW\_LEADER}$ messages.
\begin{lemma}
Assume that $\mathcal{V}=1$ in Theorem~\ref{thm:bounds}, $\tm{1}\geq{\sf GST}$ and
${\sf leader}(1)$ is correct. Assume that a correct process $p_j$ broadcast a value
$x$ at $t\geq{\sf GST}$. If ${\sf dur\_recovery}_i(1) > 5\delta$ and
${\sf dur\_delivery}_i(1) > 4\delta$ at each correct process $p_i$ that enters
$1$, then all correct processes deliver $x$ by
$\max\{t, \tl{1}\} + 4\delta$.
\label{lem:all-good:latency-goodcase}
\end{lemma}
{\em Proof.}
By Lemma~\ref{thm:all-good:veq1}, no correct process calls ${\tt advance}$
in $1$. Therefore, by Validity\xspace, no correct process enters
$2$, and by Proposition~\ref{sync:noskip} the same holds for any
view $>1$. By Bounded Entry\xspace, all correct processes enter $1$.
When ${\sf leader}(1)$ enters view $1$, it sends
a ${\tt NEW\_STATE}$ message to all
processes. A process handles ${\tt NEW\_STATE}$ by $\tl{1}+\delta$ and sets
its ${\sf status}$ to $\textsc{normal}$. The ${\sf leader}(1)$ receives $x$ by
$t+\delta$. The leader will send ${\tt PREPREPARE}(1, k, x)$ when it has
received $x$ and has ${\sf status}=\textsc{normal}$, i.e., by $\max\{t,
\tl{1}\}+\delta$. All correct processes
receive ${\tt PREPREPARE}(1, k, x)$ by $\max\{t,
\tl{1}\} + 2\delta$. It then takes the correct
processes at most $2\delta$ to exchange the sequence of ${\tt PREPARE}$ and
${\tt COMMIT}$ messages that commit $x$. Therefore, all correct
processes commit $x$ by $\max\{t,
\tl{1}\} + 4\delta$.
Let $p_i$ be a correct process. Because ${\sf leader}(1)$ is
correct, we can show that ${\sf last\_delivered}\geq k-1$ at $p_i$ by
$\max\{t,
\tl{1}\} + 4\delta$. If ${\sf last\_delivered}=k-1$, then
$p_i$ delivers $x$ by $\max\{t,
\tl{1}\} + 4\delta$. In
case ${\sf last\_delivered}>k-1$ at $p_i$ by $\max\{t,
\tl{1}\} + 4\delta$, we can show that $p_i$ has already deliver $x$
before. Since $p_i$ was picked arbitrarily, we can conclude that all
correct processes deliver $x$ by
$\max\{t,
\tl{1}\} + 4\delta$, as required. \qed
\paragraph{\it Proof of Theorem~\ref{thm:pbft-latency:good}.}
When a correct process starts the protocol, it calls ${\tt advance}$ from view $0$
unless it has already entered a higher view. If all correct processes call
${\tt advance}$ from view $0$ when they start the protocol, then by Startup\xspace we get
$\tm{1}\mathpunct{\downarrow}$. If at least one correct process does not call ${\tt advance}$ from
view $0$ because it has already entered a higher view, then by
Proposition~\ref{sync:noskip} we also get $\tm{1}\mathpunct{\downarrow}$.
Since all correct processes start the protocol after ${\sf GST}$, we have
$\tam{0}>{\sf GST}$. Thus, applying the second clause of
Property~\ref{eq:lat-bound1:main}, we get $\tl{1} \le
\taelast{0}+\delta$. Furthermore, by Theorem~\ref{thm:bounds} we get
$\mathcal{V}=1$. Hence, $\tl{\mathcal{V}} \le \taelast{0}+\delta$, as required. By
Lemma~\ref{lem:all-good:latency-goodcase}, all correct processes deliver $x$
by $\max\{t, \tl{\mathcal{V}}\} + 4\delta \le \max\{t, \taelast{0}+\delta\} + 4\delta$,
as required. \qed
\subsection{Space Requirements of PBFT-light\xspace}
\label{sec:pbft-space}
Since the synchronizer is not guaranteed to switch processes between views all
at the same time, a process in a view $v$ may receive a message from a higher
view $v' > v$, which needs to be stored in case the process finally switches to
$v'$. If implemented naively, this would require a process to store unboundedly
many messages. Instead, we allow a process to store, for each message type and
sender, only the message of this type received from this sender that has the
highest view. We can easily adapt the liveness proof of PBFT-light\xspace to take this
into account. In the proof, when we argue that a process handles a
message $m$ in a view $v$ at a given time $t$, we establish before that no
correct process has entered a greater view by $t$. This implies that no
correct process has sent a message for a view $> v$ by $t$. Thus, $m$
will not be discarded at correct processes before $t$, which is enough
to ensure that liveness is not violated. Recall that our synchronizer from
\S\ref{sec:sync} uses only bounded
space. Thus, PBFT-light\xspace with this synchronizer requires space proportional to the
number of requests submitted by clients. This is appropriate for blockchain
applications, where a process participating in the SMR protocol needs to store
the blockchain and candidate blocks anyway.
\subsection{Proof of Safety for HotStuff-light\xspace}
\label{sec:hotstuff-safety}
Propositions~\ref{lemma:pbft:committed-prepared},~\ref{lemma:pbft:validityliveness}
and~\ref{lemma:pbft:singlecmd} established for PBFT-light\xspace still hold for
HotStuff-light\xspace. External Validity can be proved similarly. We next prove Ordering and
Integrity.
\begin{proposition}
\label{lemma:hotstuff:view-increase}
The variables ${\sf curr\_view}$, ${\sf prep\_view}[k]$ and ${\sf lock\_view}[k]$ (for any $k$) at a
correct process never decrease and we always have
${\sf lock\_view}[k] \le {\sf prep\_view}[k] \le {\sf curr\_view}$.
\end{proposition}
\begin{lemma}
\label{lemma:hotstuff:nodupl}
At a correct process we always have
$$
\forall k, k'.\, {\sf log}'[k] = {\sf log}'[k'] \not\in \{\bot, {\tt nop}\} {\implies} k=k'.
$$
\end{lemma}
{\em Proof.}
Analogous to that of Lemma~\ref{lemma:pbft:nodupl}.\qed
\begin{corollary}
\label{cor:hotstuff:nodupl}
$$
\forall x, v, k, k', C, C'.\,
{\sf prepared}(C, v, k, {\sf hash}(x)) \wedge
{\sf prepared}(C', v, k', {\sf hash}(x)) \wedge
{\sf wf}(C) \wedge {\sf wf}(C') \wedge x \not= {\tt nop}
{\implies} k = k'.
$$
\end{corollary}
{\em Proof.}
Analogous to that of Corollary~\ref{cor:pbft:nodupl}.\qed
\begin{lemma}
\label{lemma:hotstuff:main}
Fix $k$, $v$, $v'$, $C$ and $x$, and assume
$$
\ensuremath{{\sf committed}}(C, v, k, {\sf hash}(x)) \wedge {\sf wf}(C) \wedge v' > v.
$$
Then
\begin{itemize}
\item
$\forall C', x'.\,
{\sf prepared}(C', v', k, {\sf hash}(x')) \wedge
{\sf wf}(C') {\implies} x = x'$.
\item
$\forall C', k'.\, x \not= {\tt nop} \wedge
{\sf prepared}(C', v', k', {\sf hash}(x)) \wedge {\sf wf}(C') {\implies} k = k'$.
\end{itemize}
\end{lemma}
{\em Proof.}
We prove the statement of the lemma by induction on $v'$. Assume this holds for
all $v' < v^*$; we now prove it for $v' = v^*$. Thus, we have
\begin{gather}
\label{hotstuff:hyp2}
\forall C'', x'', v''.\, v < v'' < v' \wedge {\sf prepared}(C'', v'',
k, {\sf hash}(x'')) \wedge {\sf wf}(C'') {\implies} x = x'';
\\
\label{hotstuff:hyp4}
\forall C'', k'', v''.\, v < v'' < v' \wedge x \not= {\tt nop} \wedge {\sf prepared}(C'', v'',
k'', {\sf hash}(x)) \wedge {\sf wf}(C'') {\implies} k = k''.
\end{gather}
Assume that ${\sf prepared}(C', v', k, {\sf hash}(x'))$ and ${\sf wf}(C')$. Since
$\ensuremath{{\sf committed}}(C, v, k, {\sf hash}(x))$, a quorum $Q$ of processes sent
${\tt COMMIT}(v, k, {\sf hash}(x))$. Since ${\sf prepared}(C', v', k, {\sf hash}(x'))$, a quorum
$Q'$ of processes sent ${\tt PREPARE}(v', k, {\sf hash}(x'))$. The quorums $Q$ and $Q'$
have to intersect in some correct process $p_{i}$, which has thus sent both
${\tt COMMIT}(v, k, {\sf hash}(x))$ and ${\tt PREPARE}(v', k, {\sf hash}(x'))$. Since $v< v'$,
this process $p_{i}$ must have sent the ${\tt COMMIT}$ message before the ${\tt PREPARE}$
message. Before sending the former, the process set ${\sf lock\_view}[k]$ to $v$
(line~\ref{hotstuff:lock}) and had ${\sf prep\_log}[k] = {\sf log}[k] = x$. Assume
towards a contradiction that $x \not= x'$. Let $v''$ be the first view
after $v$ when $p_i$ assigned ${\sf log}[k]$ to some $x'' \not= x$, so that
$v < v'' \le v'$. Then $p_i$ must have assigned ${\sf log}[k]$ to $x''$ at either
line~\ref{hotstuff:assign-log} or line~\ref{hotstuff:assign-nop}. When this
happened, $p_i$ had ${\sf log}[k] = {\sf prep\_log}[k] = x$ and, by
Proposition~\ref{lemma:hotstuff:view-increase}, ${\sf lock\_view}[k] \ge v > 0$.
By the ${\sf ValidNewState}$ check (line~\ref{hotstuff:safety-check}), the leader of
$v''$ must have provided a well-formed prepared certificate $C''$ such that
${\sf prepared}(C'', v''', k, {\sf hash}(x''))$ for $v'''$ such that
$$
v \le {\sf lock\_view}[k] < v''' \le v'' \le v'.
$$
If $p_i$ assigned ${\sf log}[k]$ to $x''$ at line~\ref{hotstuff:assign-log}, then
by~(\ref{hotstuff:hyp2}) we get $x'' = x$, and above we assumed
$x'' \not= x$: a contradiction. If $p_i$ assigned ${\sf log}[k]$ to $x''$
at line~\ref{hotstuff:assign-nop} due to a duplicate value at a position
$k'\not=k$, then $x'' = {\tt nop}$ and $\mathit{log}[k'] = x \not= \bot$.
Hence, the leader of $v''$ had to also provide a well-formed prepared
certificate $C''$ such that ${\sf prepared}(C'', v'''_0, k', {\sf hash}(x))$ for $v'''_0$
such that
$$
v \le {\sf lock\_view}[k] \le v''' < v'''_0 < v'' \le v'.
$$
Since $x \not= x'' = {\tt nop}$, by~(\ref{hotstuff:hyp4}) we get $k = k'$: a
contradiction.
Since we reach a contradiction in both cases, we must have $x = x'$, as
required.
Assume now $x \not= {\tt nop}$, ${\sf prepared}(C', v', k', {\sf hash}(x))$ and
${\sf wf}(C')$. Since $\ensuremath{{\sf committed}}(C, v, k, {\sf hash}(x))$, a quorum $Q$ of processes
sent ${\tt COMMIT}(v, k, {\sf hash}(x))$. Since ${\sf prepared}(C', v', k', {\sf hash}(x))$, a
quorum $Q'$ of processes sent ${\tt PREPARE}(v', k', {\sf hash}(x))$. The quorums $Q$
and $Q'$ have to intersect in some correct process $p_{i}$, which has thus sent
both ${\tt COMMIT}(v, k, {\sf hash}(x))$ and ${\tt PREPARE}(v', k', {\sf hash}(x))$. When
$p_i$ sent the latter it must have had ${\sf log}[k'] = x$. As before, we can also
show that at this moment $p_i$ had ${\sf log}[k] = x$. By
Lemma~\ref{lemma:hotstuff:nodupl}, the process starts the view $v'$ with a log
without duplications (except ${\tt nop}$s), and does not add duplicate entries due
to the check at line~\ref{alg:castro:safety-check}. Hence, we must have
$k' = k$, as required. \qed
\begin{corollary}
HotStuff-light\xspace satisfies Ordering and Integrity.
\end{corollary}
{\em Proof.}
The same as the proofs of Corollaries~\ref{thm:pbft:agreement}
and~\ref{thm:pbft-integrity}, but using the corresponding lemmas for HotStuff-light\xspace
instead of PBFT-light\xspace. \qed
\section{A HotStuff-like Protocol Using an SMR Synchronizer}
\label{sec:hotstuff}
\begin{figure}[!t]
\vspace{3pt}
\begin{tabular}{@{\!}l@{\!\!\!\!\!\!}|@{\ \ }l@{}}
\scalebox{0.96}{%
\begin{minipage}[t]{7.5cm}
\let\@latex@error\@gobble
\vspace*{-11pt}
\begin{algorithm*}[H]
\SetInd{\marginA}{\marginB}
\setcounter{AlgoLine}{0}
\SetInd{\marginA}{\marginB}
\SubAlgo{{\bf when the process starts}}{
{\tt advance}();
}
\smallskip
\SubAlgo{\textbf{when {\sf timer\_delivery}{} or {\sf timer\_recovery}{} expires}}{
${\tt stop\_all\_timers}()$\;
${\tt advance}()$\;
${\sf status} \leftarrow \textsc{advanced}$\;
${\sf dur\_delivery} \leftarrow {\sf dur\_delivery} + \tau$\;
${\sf dur\_recovery} \leftarrow {\sf dur\_recovery} + \tau$\;
}
\smallskip
\SubAlgo{\Fun ${\tt broadcast}(x)$}{
\textbf{pre:} ${\sf valid}(x)$\;
\Send $\langle {\tt BROADCAST}(x) \rangle_i$ \KwTo \ {\bf all}{}
{\bf periodically until $x$ is delivered}
}
\smallskip
\SubAlgo{\WhenReceived ${\tt BROADCAST}(x)$}{
\textbf{pre:} ${\sf valid}(x) \wedge x \not\in {\sf queue} \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }} (\forall k.\, k \le {\sf last\_delivered} {\implies} {}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }(} {\sf commit\_log}[k]\not=x)$\;
${\sf queue} \leftarrow {\tt append}({\sf queue}, x)$\;
}
\smallskip
\SubAlgo{{\bf when} ${\sf status} = \textsc{normal} \wedge p_i = {\sf leader}({\sf curr\_view}) \wedge {}$
\mbox{${\sf next} \le {\sf curr\_view} \cdot B
\wedge\exists x \in {\sf queue}.\, \forall k.\, {\sf log}[k]\not=x$}}{
$x \leftarrow {}$the first value in ${\sf queue}$ that \mbox{is not in ${\sf log}$}\;
$\ensuremath{{\tt stop\_timer}}({\sf timer\_broadcast})$\;
${\tt propagate}(x)$\;
}
\smallskip
\SubAlgo{\textbf{when {\sf timer\_broadcast}\ expires}}{
${\tt propagate}({\tt nop})$\;
}
\smallskip
\SubAlgo{\Fun ${\tt propagate}(x)$}{
\Send $\langle {\tt PREPREPARE}({\sf curr\_view}, $ ${\sf next}, x) \rangle_i$
\KwTo \ {\bf all}\;
${\sf next} \leftarrow {\sf next} + 1$\;
\If{${\sf next} \le {\sf curr\_view} \cdot B$}{%
$\ensuremath{{\tt start\_timer}}({\sf timer\_broadcast}, T)$}
}
\smallskip
\SubAlgo{\WhenReceived $\langle {\tt PREPREPARE}(v, k, x) \rangle_{j}$}{
\textbf{pre:} $p_j = {\sf leader}(v) \wedge {\sf curr\_view} = v \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl}$\phantom{\text{{\bf pre:} }}{\sf status} = \textsc{normal} \wedge {\sf phase}[k] = \textsc{start} \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl}$\phantom{\text{{\bf pre:} }}k \le v \cdot B \wedge {\sf valid}(x) \wedge (\forall k'.\, {\sf log}[k']\not=x)$\;
$({\sf log}, {\sf phase})[k] \leftarrow (x, \textsc{preprepared})$\;
\Send $\langle {\tt PREPARE}(v, k, {\sf hash}(x)) \rangle_i$ \KwTo \ {\bf all}\;
}
\end{algorithm*}
\vspace*{-6pt}
\end{minipage}}
&
\scalebox{0.96}{%
\begin{minipage}[t]{9cm}
\let\@latex@error\@gobble
\vspace*{-11pt}
\begin{algorithm*}[H]
\SubAlgo{\WhenReceived $\{\langle {\tt PREPARE}(v, k, h) \rangle_j \mid p_j
\in Q\} = C$ \quad\qquad\qquad {\bf for a quorum $Q$}}{\label{alg:hotstuff:prepare}
\textbf{pre:} ${\sf curr\_view} = v \wedge {\sf phase}[k] = \textsc{preprepared} \wedge{}$\\
\renewcommand{\nl}{\let\nl\oldnl}$\phantom{\text{{\bf pre:} }}{} {\sf status} = \textsc{normal} \wedge {\sf hash}({\sf log}[k]) = h$\;
$({\sf prep\_log}, {\sf prep\_view}, {\sf cert}, {\sf phase})[k] \leftarrow {}$\\
\renewcommand{\nl}{\let\nl\oldnl}$\quad ({\sf log}[k], {\sf curr\_view}, C, \textsc{prepared})$\;
\Send $\langle {\tt PRECOMMIT}(v, k, h) \rangle_i$ \KwTo \ {\bf all}\; \label{alg:hotstuff:sendprecommit}
}
\smallskip
\SubAlgo{\WhenReceived $\{\langle {\tt PRECOMMIT}(v, k, h) \rangle_j \mid p_j
\in Q\} = C$ \qquad\qquad {\bf for a quorum $Q$}}{\label{alg:hotstuff:precommit}
\textbf{pre:} ${\sf curr\_view} = v \wedge {\sf phase}[k] = \textsc{prepared} \wedge{} $\\
\renewcommand{\nl}{\let\nl\oldnl}$\phantom{\text{{\bf pre:} }}{} {\sf status} = \textsc{normal} \wedge {\sf hash}({\sf prep\_log}[k]) = h$\;
$({\sf lock\_view}, {\sf phase})[k] \leftarrow ({\sf curr\_view}, \textsc{precommitted})$\;\label{hotstuff:lock}
\Send $\langle {\tt COMMIT}(v, k, h) \rangle_i$ \KwTo \ {\bf all}\;
}
\smallskip
\SubAlgo{\WhenReceived $\{\langle {\tt COMMIT}(v, k, h) \rangle_j \mid p_j
\in Q\} = C$ \quad\qquad\qquad {\bf for a quorum $Q$}}{\label{alg:hotstuff:commit}
\textbf{pre:} ${\sf curr\_view} = v \wedge {\sf phase}[k] = \textsc{precommitted} \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl}$\phantom{\text{{\bf pre:} }}{\sf status} = \textsc{normal} \wedge {\sf hash}({\sf prep\_log}[k]) = h$\;
$({\sf commit\_log},{\sf phase})[k] \leftarrow ({\sf log}[k], \textsc{committed})$\;
\Broadcast $\langle {\tt DECISION}({\sf commit\_log}[k], k, C)$\;
}
\smallskip
\SubAlgo{{\bf when} ${\sf commit\_log}[{\sf last\_delivered}+1] \not= \bot \wedge {\sf status} = \textsc{normal}$}{
${\sf last\_delivered} \leftarrow {\sf last\_delivered}+1$\;
\If{${\sf commit\_log}[{\sf last\_delivered}] \not= {\tt nop}$}{${\tt deliver}({\sf commit\_log}[{\sf last\_delivered}])$}
${\tt remove}({\sf queue}, {\sf commit\_log}[{\sf last\_delivered}])$\;
\If{${\sf status}={\normalfont \textsc{normal}}$}{
\uIf{${\sf last\_delivered} = {\sf curr\_view} \cdot
B$}{
${\tt stop\_all\_timers}()$\;
${\tt advance}()$\;
${\sf status} \leftarrow \textsc{advanced}$\;
}
\ElseIf{${\sf last\_delivered} > ({\sf curr\_view}-1) \cdot
B$}{
$\ensuremath{{\tt stop\_timer}}({\sf timer\_delivery})$\;
$\ensuremath{{\tt start\_timer}}({\sf timer\_delivery},
{\sf dur\_delivery})$\;
}
}
}
\smallskip
\SubAlgo{\WhenReceived ${\tt DECISION}(x, k, C)$}{
\textbf{pre:} ${\sf commit\_log}[k] \not= \bot \wedge \exists v.\, \ensuremath{{\sf committed}}(C, v, k,
{\sf hash}(x))$\;
${\sf commit\_log}[k] \leftarrow x$\;
}
\end{algorithm*}
\vspace*{-6pt}
\end{minipage}}
\end{tabular}
\vspace*{-2pt}
\caption{Normal protocol operation of HotStuff at a process $p_i$.}
\label{fig:hotstuff-normal}
\end{figure}
\begin{figure}[t]
\vspace{2pt}
\begin{tabular}{@{\!}l@{\!\!\!\!\!\!}|@{\ \ }l@{}}
\scalebox{0.96}{%
\begin{minipage}[t]{7.7cm}
\let\@latex@error\@gobble
\vspace*{-12pt}
\begin{algorithm*}[H]
\setcounter{AlgoLine}{52}
\SetInd{\marginA}{\marginB}
\SubAlgo{\Upon ${\tt new\_view}(v)$}{
${\tt stop\_all\_timers}()$\;
${\sf curr\_view} \leftarrow v$\;
${\sf status} \leftarrow \textsc{initializing}$\;
\Send $\langle {\tt NEW\_LEADER}({\sf curr\_view},{\sf prep\_view}, $ ${\sf prep\_log}, {\sf cert}) \rangle_i$
\KwTo ${\sf leader}({\sf curr\_view})$\;
$\ensuremath{{\tt start\_timer}}({\sf timer\_recovery},$ ${\sf dur\_recovery})$\;
}
\smallskip
\SubAlgo{\WhenReceived $\{\langle {\tt NEW\_LEADER}(v,\mathit{prep\_view}_j, $ $\mathit{prep\_log}_j,
\mathit{cert}_j) \rangle_j \mid$ $p_j \in Q\} = M$ {\bf for a quorum
$Q$}}{
\textbf{pre:} $p_i = {\sf leader}(v) \wedge {\sf curr\_view} = v \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }} {\sf status} = \textsc{initializing} \wedge{}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }} \forall m \in M.\, {\sf ValidNewLeader}(m)$\;
\ForAll{$k$}{
\If{$\exists p_{j'} \in Q.\, \mathit{prep\_view}_{j'}[k] \not= 0 \wedge{}$
$\forall p_{j} \in Q.\,\mathit{prep\_view}_{j}[k] \le \mathit{prep\_view}_{j'}[k])$}{%
$\mathit{log}'[k] \leftarrow \mathit{prep\_log}_{j'}[k]$\;
$\mathit{prep\_view}'[k] \leftarrow \mathit{prep\_view}_{j'}[k]$\;
$\mathit{cert}'[k] \leftarrow \mathit{cert}_{j'}[k]$}
${\sf next} \leftarrow (v-1) \cdot B +1$\;
\Send $\langle {\tt NEW\_STATE}(v, \mathit{log}', \mathit{prep\_view}', \mathit{cert}') \rangle_i$ \KwTo \ {\bf all}\;
$\ensuremath{{\tt start\_timer}}({\sf timer\_broadcast}, T)$\;
}
}
\end{algorithm*}
\vspace*{-5pt}
\end{minipage}}
&
\scalebox{0.96}{%
\begin{minipage}[t]{8.6cm}
\let\@latex@error\@gobble
\vspace*{-12pt}
\begin{algorithm*}[H]
\SubAlgo{\WhenReceived $\langle {\tt NEW\_STATE}(v, \mathit{log}', \mathit{prep\_view}', \mathit{cert}') \rangle_j = m$}{
\textbf{pre:} ${\sf status} = \textsc{initializing} \wedge {\sf curr\_view} = v \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }} {\sf ValidNewState}(m)$\label{hotstuff:safety-check}\;
$\ensuremath{{\tt stop\_timer}}({\sf timer\_recovery})$\;
${\sf log} \leftarrow \mathit{log}'$\label{hotstuff:assign-log}\;
\ForAll{$k = 1..(v-1) \cdot B$}{
\If{${\sf log}'[k] = \bot \vee \exists k'.\, k' \not= k \wedge
{\sf log}'[k'] = {\sf log}'[k] \wedge{}$ $\mathit{prep\_view}'[k'] > \mathit{prep\_view}[k]$}{%
${\sf log}'[k] \leftarrow {\tt nop}$\label{hotstuff:assign-nop}%
}
}
\uIf{${\sf last\_delivered} \geq {\sf curr\_view} \cdot B$}{
${\tt advance}()$\;
${\sf status} \leftarrow \textsc{advanced}$\;
}\Else{
\ForAll{$k = 1..(v-1) \cdot B$}{
${\sf phase}[k] \leftarrow \textsc{preprepared}$\;
\Send $\langle {\tt PREPARE}(v, k, {\sf hash}({\sf log}'[k])) \rangle_i$ \KwTo
\ {\bf all}\;
}
$\ensuremath{{\tt start\_timer}}({\sf timer\_delivery},{\sf dur\_delivery})$\;
${\sf status} \leftarrow \textsc{normal}$\;
}
}
\end{algorithm*}
\vspace*{-5pt}
\end{minipage}}
\end{tabular}
\caption{View-initialization protocol of HotStuff at a process $p_i$.}
\label{fig:hotstuff-recovery}
\end{figure}
\begin{figure}[t]
\scalebox{0.97}{
\begin{minipage}{15cm}
\begin{gather*}
{\sf prepared}(C, v, k, h)
\iff
\exists Q.\,
{\sf quorum}(Q) \wedge C = \{\langle {\tt PREPARE}(v, k, h) \rangle_j \mid p_j \in Q\}
\\
\ensuremath{{\sf committed}}(C, v, k, h)
\iff
\exists Q.\,
{\sf quorum}(Q) \wedge C = \{\langle {\tt COMMIT}(v, k, h) \rangle_j \mid p_j \in Q\}
\\
\begin{array}{@{}l@{}}
{\sf ValidNewLeader}(\langle {\tt NEW\_LEADER}(v, \mathit{prep\_view}, \mathit{prep\_log}, \mathit{cert}) \rangle_{\_}) \iff {}
\\[2pt]
\forall k.\, (\mathit{prep\_view}[k] > 0 {\implies}
\mathit{prep\_view}[k] < v \wedge
{\sf prepared}(\mathit{cert}[k], \mathit{prep\_view}[k], k, \mathit{prep\_log}[k]))
\end{array}
\\
\begin{array}{@{}l@{}}
{\sf ValidNewState}(\langle {\tt NEW\_STATE}(v, \mathit{log}, \mathit{prep\_view}, \mathit{cert}) \rangle_i) \iff
\\[2pt]
p_i = {\sf leader}(v) \wedge (\forall k.\, {\sf lock\_view}[k] > 0 {\implies} \mathit{log}[k] \not= \bot) \wedge{}
\\[2pt]
(\forall k.\, \mathit{log}[k]\not=\bot {\implies}
v>\mathit{prep\_view}[k]>{\sf lock\_view}[k] \wedge
{\sf prepared}(\mathit{cert}[k], \mathit{prep\_view}[k], {\sf hash}(\mathit{log}[k])))
\end{array}
\end{gather*}
\end{minipage}}
\vspace*{-5pt}
\caption{Auxiliary predicates for HotStuff.}
\label{fig:hotstuffpreds}
\end{figure}
In this section we demonstrate how an SMR synchronizer can be used to implement
Byzantine SMR protocols following the approach of HotStuff~\cite{hotstuff},
which reduces the communication complexity of leader
change. Figures~\ref{fig:hotstuff-normal}-\ref{fig:hotstuffpreds} present a
corresponding modification of PBFT-rotation\xspace, which we call HotStuff-light\xspace. For brevity, we
eschew the use of threshold signatures, which can reduce the communication
complexity even further. HotStuff-light\xspace also excludes optimizations from HotStuff
related to maintaining a hash-chain, but these can be added easily.
HotStuff-light\xspace adds an extra message exchange to the normal path of PBFT-rotation\xspace, in
between the ones for ${\tt PREPARE}$ and ${\tt COMMIT}$ messages. When a process gathers a
set of ${\tt PREPARE}(v, k, {\sf hash}(x))$ messages for a value $x$ from a quorum
(line~\ref{alg:hotstuff:prepare}), it disseminates a
${\tt PRECOMMIT}(v, k, {\sf hash}(x))$ message
(line~\ref{alg:hotstuff:sendprecommit}). The process then waits until it gathers
a quorum of matching ${\tt PRECOMMIT}$ messages for the value $x$
(line~\ref{alg:hotstuff:precommit}) and disseminates the corresponding ${\tt COMMIT}$
message. At this point the process also becomes {\em locked} on $x$ at
position $k$ in view $v$, which is recorded by setting the position $k$ of an
array ${\sf lock\_view}$ to ${\sf curr\_view}$ (line~\ref{hotstuff:lock}).
From this point on, the process will not accept a proposal of a different value
at position $k$ from a leader of a future view, unless the leader can convince
the process that no decision was reached in ${\sf curr\_view}$ at position $k$. To this
end, we also modify the view-change protocol of PBFT-rotation\xspace. In HotStuff-light\xspace the leader
of a view $v$ does not forward the set of ${\tt NEW\_LEADER}$ messages used to compute
the view's initial state in its ${\tt NEW\_STATE}$ message; this reduces the
communication complexity. Instead, a follower checks that the leader's proposal
is safe using a modified ${\sf ValidNewState}$ predicate. This checks that, if a
process has previously locked on a value at a position $k$, then either the
leader proposes the same value for that position, or its proposal is justified
by a prepared certificate from a higher view than the lock. In the latter case
the process can be sure that no decision was reached at position $k$ in the view
it is locked on. Finally, HotStuff-light\xspace delegates the task of filtering out
duplicates to the followers: a follower cannot check that the leader
filters out duplicates correctly without receiving the set of
${\tt NEW\_LEADER}$ messages used by the leader to compute
the view's initial state.
\section{Introduction}
{\em Byzantine state-machine replication (SMR)}~\cite{smr} ensures the
consistency of replicated state even when some %
of the replicas are malicious.
It lies at the heart of the modern blockchain technology and is closely related
to the classical Byzantine consensus problem.
Unfortunately, no deterministic protocol can guarantee both safety and liveness
of Byzantine SMR when the network is asynchronous~\cite{flp}. A common way to
circumvent this while maintaining determinism
is to guarantee safety under all circumstances and liveness only under
synchrony.
This is formalized by the {\em partial
synchrony} model~\cite{dls,CT96},
which stipulates that after some unknown {\em Global Stabilization Time} ({\sf GST})
the system becomes synchronous, with message delays bounded by an unknown
constant $\delta$ and process clocks tracking real time. Before ${\sf GST}$, however,
messages can be lost or %
delayed, and clocks at different processes can drift apart.
Historically, researchers have paid more attention to safety of Byzantine SMR
protocols than their liveness. For example, while the seminal PBFT protocol came
with a detailed safety proof~\cite[\S{}A]{castro-thesis}, the nontrivial
mechanisms ensuring its liveness were only given a brief informal
justification~\cite[\S{}4.5.1]{castro-tocs}, which did not cover their most
critical properties. %
However, ensuring liveness under partial synchrony is far from trivial, as
illustrated by the many liveness bugs found in existing
protocols~\cite{wild,casper-bug,alysson-reads,tendermint-opodis,zyzzyva-bug}. In
particular, classical failure and leader detectors~\cite{CT96,petr-survey} are
of little help: while they have been widely used under benign
failures~\cite{R00,MR99,GR04}, their implementations under Byzantine failures
are either impractical~\cite{kihlstrom} or detect only restricted failure
types~\cite{MR97,muteness,modular-smr,HK09}. As an alternative, a textbook by
Cachin et al.~\cite{cachin-book} proposed a leader detector-like abstraction
that accepts hints from the application to identify potentially faulty
processes. However, as we explain in \S\ref{sec:related}
and~\tr{\ref{sec:bug}}{F}, this abstraction is impossible to implement, and
in fact, the consensus algorithm constructed using it in~\cite{cachin-book} also
suffers from a liveness bug.
Recent work on ensuring liveness %
has departed from failure detectors and instead revisited the approach of the
original DLS paper~\cite{dls}. This exploits the common structure of Byzantine
consensus and SMR protocols under partial synchrony: such protocols usually
divide their execution into {\em views}, each with a designated leader process
that coordinates the protocol execution. If the leader is faulty, the processes
switch to another view with a different leader.
To ensure liveness, an SMR protocol needs to spend sufficient time in views that
are entered by all correct processes and where the leader correctly follows the
protocol. The challenge of achieving such {\em view synchronization} is that,
before ${\sf GST}$, clocks can diverge and messages that could be used to synchronize
processes can get lost or delayed; even after ${\sf GST}$, Byzantine processes may
try to disrupt attempts to bring everybody into the same view. {\em View
synchronizers}~\cite{NK20,bftlive,hotstuff,lumiere} encapsulate mechanisms for
dealing with this challenge, allowing them to be reused across protocols.
View synchronizers have been mostly explored in the context of (single-shot)
Byzantine consensus. In this case a synchronizer can just switch processes
through an infinite series of views with fixed or growing duration, so that
eventually there is a view with a correct leader that is long enough to reach a
decision~\cite{NK20,bftlive}. However, using such a synchronizer for SMR results
in suboptimal solutions. For example, one approach is to use the classical SMR
construction where each command is decided using a separate black-box consensus
instance~\cite{smr}, implemented using a view synchronizer. However, this would
force the processes in every instance to iterate over the same sequence of
potentially bad views until the one with a correct leader and sufficiently long
duration could be reached. As we discuss in~\S\ref{sec:related}, other
approaches for implementing SMR based on this type of synchronizers also
suffer from drawbacks.
To minimize the overheads of view synchronization,
instead of automatically switching processes through views based on a fixed
schedule, %
implementations such as PBFT allow processes to stay in the same view for as
long as they are happy with its %
performance. The processes can then reuse a single view to decide multiple
commands, usually with the same leader.
To be useful for such SMR protocols, a synchronizer needs to allow the processes
to control when they want to switch views via a special ${\tt advance}$ call. We
call such a primitive an {\em SMR synchronizer}, to distinguish it from the less
flexible {\em consensus synchronizer} introduced above. This kind of
synchronizers was first introduced in~\cite{NK20,lumiere}, but only used as an
intermediate module to implement a consensus synchronizer.
In this paper we show that SMR synchronizers can be {\em directly} exploited to
construct efficient and provably live SMR protocols and
develop a general blueprint that enables such constructions. In more detail:
\enlargethispage{3pt}
{\setlength{\leftmargini}{9pt}
\begin{itemize}
\item We propose a formal specification of an SMR synchronizer
(\S\ref{sec:sync}), which is simpler and
more general than prior proposals~\cite{lumiere,NK20}.
It is also strictly stronger than the consensus synchronizer
of~\cite{bftlive}, which can be obtained from the SMR synchronizer at no extra
cost. Informally, our specification guarantees that {\em (a)} the system will
move to a new view if enough correct processes call ${\tt advance}$, and {\em (b)}
all correct processes will enter the new view, provided that for long enough,
no correct process that enters this view asks to leave it. These properties
enable correct processes to iterate through views in search of a well-behaved
leader, and to synchronize in a view they are happy with.
\item We give an SMR synchronizer implementation and prove that it satisfies our
specification (\S\ref{sec:sync-impl}). Unlike prior
implementations~\cite{NK20}, ours tolerates message loss before ${\sf GST}$ while
using only bounded space; in practice, this feature is essential to defend
against denial-of-service attacks. We also provide a precise latency analysis
of our synchronizer, quantifying how quickly all correct processes enter the
next view after enough of them call ${\tt advance}$.
\item We demonstrate the usability of our synchronizer specification by applying
it to construct and prove the correctness of several SMR protocols. First, we
prove the liveness of a variant of PBFT using an SMR synchronizer
(\S\ref{sec:pbft}-\ref{sec:liveness}): to the best of our knowledge, this is
the first rigorous proof of liveness for PBFT's algorithmic core. The proof
establishes a strong liveness guarantee that implies censorship-resistance:
every command submitted by a correct process will be executed. The use of the
synchronizer specification in the proof allows us to avoid dealing with view
synchronization mechanics and instead focus on protocol-specific
reasoning. This reasoning is done using a reusable methodology based on
showing that the use of timers in the SMR protocol and the synchronizer
together establish properties similar to those of failure detectors. The
methodology also handles the realistic ways in which protocols such as PBFT
adapt their timeouts to the unknown message delay $\delta$. We demonstrate the
generality of our methodology by also applying it to a version of PBFT with
periodic
leader changes~\cite{aardvark,spinning,mirbft} and a HotStuff-like
protocol~\cite{hotstuff} (\S\ref{sec:xbft}).
\item We exploit the latency bounds for our synchronizer to establish both
bad-case and good-case bounds for variants of PBFT implemented on top of it
(\S\ref{sec:latency}). Our bad-case bound assumes that the protocol starts
before ${\sf GST}$; it shows that after ${\sf GST}$ all correct processes synchronize in
the same view within a bounded time. This time is proportional to a
conservatively chosen constant $\Delta$ that bounds post-${\sf GST}$ message delays
in all executions~\cite{sync-hotstuff,pass-shi,HK89}. Our good-case bound
quantifies decision latency when the protocol starts after ${\sf GST}$ and matches
the lower bound of~\cite{ittai-good-case}.
\end{itemize}}
\section{Latency Bounds for PBFT}
\label{sec:latency}
Assume that PBFT-light\xspace is used with our SMR synchronizer in Figure~\ref{fig:sync}. We
now quantify its latency using the bounds for the synchronizer in
Theorem~\ref{thm:smr-sync-correct}, yielding the first detailed latency analysis
for a PBFT-like protocol. Due to space constraints we defer proofs to
\tr{\ref{app:pbftlatency}}{C.3}. To state our bounds, we assume the
existence of a known upper bound $\Delta$ on the maximum value of $\delta$ in
any execution~\cite{sync-hotstuff,pass-shi,HK89}, so that we always have
$\delta < \Delta$. In practice, $\Delta$ provides a conservative estimate of the
message delay during synchronous periods, which may be much higher than the
maximal delay $\delta$ in a particular execution. We modify the protocol in
Figure~\ref{fig:pbft-castro-normal} so that in lines
\ref{line:castro:timer-inc1}-\ref{line:castro:timer-inc2} it does not increase
${\sf dur\_recovery}$ and ${\sf dur\_delivery}$ above $6\Delta$ and $4\Delta$,
respectively. This corresponds to the bounds in Lemma~\ref{thm:castro:all-good}
and preserves the protocol liveness. Finally, we assume that periodic
handlers %
(line~\ref{line:retransmit-start} in Figure~\ref{fig:sync} and
line~\ref{alg:castro:send-to-all} in Figure~\ref{fig:pbft-castro-normal}) are
executed every $\rho$ units of time, and that the latency of reliable broadcast
in line~\ref{alg:castro:send-decision} under synchrony is $\le \delta+\rho$
(this corresponds to an implementation that just periodically retransmits
${\tt DECISION}$ messages).
We quantify the latency of PBFT-light\xspace in both bad and good cases. For the bad case we
assume that the protocol starts during the asynchronous period.
Given a value $x$ broadcast before ${\sf GST}$, we quantify how quickly after
${\sf GST}$ all correct processes deliver $x$.
For simplicity, we assume that timeouts are high enough at ${\sf GST}$ and that
${\sf leader}(\mathcal{V})$ is correct.
\begin{theorem}
Assume that before ${\sf GST}$ all correct processes start executing the protocol
and one of them broadcasts $x$. Let $\mathcal{V}$ be defined as in
Theorem~\ref{thm:smr-sync-correct} and assume that ${\sf leader}(\mathcal{V})$ is correct
and at ${\sf GST}$ each correct process has ${\sf dur\_recovery} > 6\delta$ and
${\sf dur\_delivery} > 4\delta$. Then all correct processes deliver $x$ by
${\sf GST}+\rho + \max\{\rho+\delta, 6\Delta\} + 4\Delta+\max\{\rho, \delta\} +
7\delta$.
\label{thm:pbft-latency1}
\end{theorem}
Although the latency bound looks complex, its main message is simple: PBFT-light\xspace
recovers after a period of asynchrony in bounded time. This time is dominated by
multiples of $\Delta$; without the assumption that ${\sf leader}(\mathcal{V})$ is
correct it would also be multiplied by $f$ due to going over up to $f$ views
with faulty leaders.
To show the bound, we take advantage of the latency guarantees of our
synchronizer (Theorem~\ref{thm:smr-sync-correct}).
In more detail, the bound has to account for an unfavorable scenario where the
last view $\mathcal{V}-1$ of the asynchronous period is not operational (e.g., not all
correct processes enter it). In this case, to deliver $x$ the protocol first needs to
bring all correct processes into the same view $\mathcal{V}$.
To bound the time required for that, we first use
Property~\ref{eq:gen-bounded-entry:main} to determine the latest time when a
correct process can enter $\mathcal{V}-1$: ${\sf GST}+\rho+2\delta$. We then add the time
such a process may spend in $\mathcal{V}-1$ before it detects that $x$ is taking too
long to get delivered and call ${\tt advance}$:
$\max\{\rho+\delta,6\Delta\} +4\Delta$, where $6\Delta$ and $4\Delta$ come from
the maximal timeout values. %
The first clause of Property~\ref{eq:lat-bound1:main} then shows that all
correct processes will enter $\mathcal{V}$ within an additional $\delta$, i.e.,
$\tl{\mathcal{V}} \le {\sf GST}+\rho+\max\{\rho+\delta,6\Delta\}+4\Delta+3\delta$.
Finally, we
add the time %
for $x$ to be delivered in $\mathcal{V}$: $\max\{\rho, \delta\} + 4\delta$.
We now consider the case when the protocol starts during the synchronous period,
i.e., after ${\sf GST}$. The following theorem quantifies how quickly all correct
processes enter the first functional view, which in this case is view $1$.
If ${\sf leader}(1)$ is correct, it also quantifies how quickly a broadcast value
$x$ is delivered by all correct processes. The bound takes into account the
following optimization: in view $1$ the processes do not need to exchange
${\tt NEW\_LEADER}$ messages. Then, after the systems starts up, the protocol delivers
values within $4\delta$, which matches an existing lower bound of $3\delta$ for
the delivery time starting from the leader~\cite{ittai-good-case}. The proof of
the theorem exploits the second clause of Property~\ref{eq:lat-bound1:main}.
\begin{theorem}
Assume that all correct processes start the protocol after\/ ${\sf GST}$ with
${\sf dur\_recovery} > 5\delta$ and ${\sf dur\_delivery} > 4\delta$. Then the
$\mathcal{V}$ defined in Theorem~\ref{thm:smr-sync-correct} is equal to $1$ and
$\tl{1}\leq \taelast{0} + \delta$. Furthermore, if a correct process
broadcasts $x$ at $t \ge {\sf GST}$ and ${\sf leader}(1)$ is correct, then all correct
processes deliver $x$ by $\max\{t, \taelast{0}+\delta\} + 4\delta$.
\label{thm:pbft-latency:good}
\end{theorem}
\subsection{Proof of Liveness for HotStuff-light\xspace}
\label{sec:liveness-hotstuff}
The proof of liveness is virtually identical to the one for PBFT-rotation\xspace with two
exceptions. First, since HotStuff-light\xspace has an extra phase in its normal path, the
duration of ${\sf timer\_delivery}$ in Lemmas~\ref{thm:timers} and~\ref{thm:pbft-facts}
has to be $>\max\{5\delta, T+4\delta\}$. Second, we need to show that in a view
$v$ with a correct leader, if a correct process $p_i$ receives a ${\tt NEW\_STATE}$
message $m$ from the leader of $v$, then ${\sf ValidNewState}(m)$ holds at
$p_i$. This fact is then used in the proof of Lemma~\ref{thm:timers} to show
that a process accepts the leader's ${\tt NEW\_STATE}$ message for the view $v$ once it
receives the message and enters $v$. The following lemma states this fact.
\begin{lemma}
\label{lem:hotstuffproposal}
Let $v \geq \mathcal{V}'$ be a view such that ${\sf leader}(v)$ is correct, and let $p_i$ be a
correct process that enters $v$. If $p_i$ receives the leader's ${\tt NEW\_STATE}$
message while in $v$, then ${\sf ValidNewState}(m)$ holds at $p_i$.
\end{lemma}
{\em Proof.}
The lemma trivially holds if $p_i$ is not locked on a value at any position of
its ${\sf prep\_log}$ array when receiving the ${\tt NEW\_STATE}$ message from the leader of
$v$. We now consider the case when $p_i$ is locked on a value in at least one
position when receiving the ${\tt NEW\_STATE}$ message. Let $k$ be one of the locked
positions and let $x = p_i.{\sf prep\_log}[k]$ be the value locked and
$v_0 = p_i.{\sf lock\_view}[k] < v$ be the corresponding view. Since $p_i$ locked
$x$ in $v_0$, it must have previously received messages
${\tt PRECOMMIT}(v_0, k, {\sf hash}(x))$ from a quorum of processes, at least $f+1$ of
which have to be correct. The latter processes must have prepared the value
$x$ in view $v_0$ at position $k$. When each of these $f+1$ correct processes
enters view $v$, it has ${\sf curr\_view} \ge v_0$ and thus sends the corresponding
value and its prepared certificate for the position $k$ in the
${\tt NEW\_LEADER}(v, \ldots)$ message to ${\sf leader}(v)$. The leader is guaranteed to
receive at least one of these messages before making a proposal, since it only
does this after receiving at least $2f+1$ ${\tt NEW\_LEADER}$ messages. Hence, the
leader proposes a value $x'$ for the position $k$ with a prepared certificate
formed at some view $v' \ge v_0$. Furthermore, if $v' = v_0$, then by
Proposition~\ref{lemma:pbft:singlecmd} we have that $x' = x$ and $x$ is
the only value that can be locked at $k$ and $v_0$ by $p_i$. Thus, $p_i$ will
accept the leader's proposal for the position $k$. Since $k$ was picked
arbitrarily, then $p_i$ will accept the leader's proposal for any locked
position. Hence, the leader's ${\tt NEW\_STATE}$ message will satisfy ${\sf ValidNewState}$
at $p_i$, as required.\qed
\subsection{Proof of Liveness for PBFT-rotation\xspace}
\label{sec:liveness-rotation}
Assume that PBFT-rotation\xspace is used with an SMR synchronizer satisfying the specification
in Figure~\ref{fig:multi-sync-properties}; to simplify the following latency
analysis, we assume $d = 2\delta$, as for the synchronizer in
Figure~\ref{fig:sync}. We now prove that the protocol satisfies the Liveness
property of Byzantine atomic broadcast. First, due to the periodic leader
rotation mechanism in PBFT-rotation\xspace, we can prove that it satisfies
Proposition~\ref{lem:live-toy}, stating that processes keep entering views
forever. The proof is similar to the one in \S\ref{sec:sync}, using
the properties of the SMR synchronizer and
the following lemma, analogous to Lemma~\ref{thm:castro:completeness} in
the proof of PBFT-light\xspace. The lemma shows that a correct process stuck in a view
will eventually call ${\tt advance}$, either because it has delivered a full batch
of values or because one of its timers has expired.
\begin{lemma}
Assume that a correct process $p_i$ enters a view $v$. If $p_i$ never
enters a view higher than $v$, then it eventually calls ${\tt advance}$ in $v$.
\label{proposition:call-advance}
\end{lemma}
{\em Proof.}
We prove the proposition by contradiction: assume that $p_i$ does not
call ${\tt advance}$ while in $v$. When a timer expires, a correct process calls
${\tt advance}$. Thus, no timer expires at $p_i$ while in $v$. This
implies that $p_i$ receives a ${\tt NEW\_STATE}$ message from ${\sf leader}(v)$ and
stops ${\sf timer\_recovery}$. If ${\sf last\_delivered}\geq {\sf curr\_view} \cdot B$
when $p_i$ handles the ${\tt NEW\_STATE}$ message, then it calls ${\tt advance}$,
which is impossible. Thus, $p_i$ has ${\sf last\_delivered}< {\sf curr\_view} \cdot
B$ when it handles the ${\tt NEW\_STATE}$ message. Therefore, it starts
${\sf timer\_delivery}$. Since no timer expires at $p_i$
while in $v$, then $p_i$ must stop ${\sf timer\_delivery}$ before it
expires. The process $p_i$ stops ${\sf timer\_delivery}$ in
lines~\ref{line:stop-deliver},~\ref{alg:stop-timerexecute2}
and~\ref{line:stoptimers-enterview}. We consider each one of these in
turn. If ${\sf timer\_delivery}$ is stopped at
line~\ref{line:stop-deliver}, then $p_i$ calls ${\tt advance}$, which
is impossible. If ${\sf timer\_delivery}$ is stopped at
line~\ref{line:stoptimers-enterview}, then $p_i$ enters a view $>v$,
which is impossible. Therefore, $p_i$ must stop ${\sf timer\_delivery}$ by
executing line~\ref{alg:stop-timerexecute2}.
In this case $p_i$ has delivered a value at
a position $k>({\sf curr\_view}-1) \cdot B$. After stopping
${\sf timer\_delivery}$ at line~\ref{alg:stop-timerexecute2}, $p_i$ starts
${\sf timer\_delivery}$ again. Every time $p_i$ executes
line~\ref{alg:stop-timerexecute2}, it increases ${\sf last\_delivered}$
by one (line~\ref{alg:update-last}). Given that this is the only place
where ${\sf last\_delivered}$ is assigned, we can conclude that
${\sf last\_delivered}$ never decreases. Then $p_i$ cannot be restarting
${\sf timer\_delivery}$ indefinitely. Eventually,
the variable ${\sf last\_delivered}$ at $p_i$ will be equal to ${\sf curr\_view}
\cdot B$, in which case $p_i$ will execute
line~\ref{line:stop-deliver}. But we have established that $p_i$
cannot execute line~\ref{line:stop-deliver}, which reaches a contradiction. Hence, $p_i$
calls ${\tt advance}$ while in $v$, as required. \qed
\begin{lemma}
In any execution of PBFT-rotation\xspace:
$\forall v.\, \exists v'.\, v'>v \wedge {\tm{v'}\mathpunct{\downarrow}}$.
\label{proposition:keep-entering}
\end{lemma}
{\em Proof.}
Since all correct processes call ${\tt advance}$ at the beginning, by Startup\xspace some
correct process eventually enters view $1$. Assume now that the proposition is
false, so that there exists a maximal view $v$ entered by any correct
process. Let $P$ be any set of $f+1$ correct processes and consider an arbitrary
process $p_i \in P$ that enters $v$. Since no correct process enters a view
$v'>v$, by Lemma~\ref{proposition:call-advance}, $p_i$ calls ${\tt advance}$ in
$v$. Since $p_i$ was picked arbitrarily, we have
$\forall p_i \in P.\, {\te{i}{v}\mathpunct{\downarrow}} {\implies} {\ta{i}{v}\mathpunct{\downarrow}}$. Then by
Progress\xspace we get $\tm{v+1}\mathpunct{\downarrow}$, which yields a contradiction.\qed
\begin{lemma}
In any execution of PBFT-rotation\xspace:
$\forall v.\, v>0 {\implies} {\tm{v}\mathpunct{\downarrow}}$.
\label{proposition:enter-all}
\end{lemma}
{\em Proof.} Follows from Lemma~\ref{proposition:keep-entering}
and Proposition~\ref{sync:noskip}. \qed
\smallskip
\smallskip
Let $\mathcal{V}'$ be the minimal view such that $\mathcal{V}' \ge \mathcal{V}$ (for the $\mathcal{V}$ from
Figure~\ref{fig:multi-sync-properties}) and $\tm{\mathcal{V}'}\ge {\sf GST}$; such a view
exists by Lemma~\ref{proposition:enter-all}. Hence, starting from $\mathcal{V}'$, process
clocks track real time and messages sent by correct processes are delivered
within $\delta$. We denote by ${\sf dur\_delivery}_i(v)$ and
${\sf dur\_recovery}_i(v)$ respectively the value of the ${\sf dur\_delivery}$ and
${\sf dur\_recovery}$ variable at a correct process $p_i$ while in view $v$. We
now prove a lemma analogous to Lemma~\ref{thm:castro:timers} in the proof of
PBFT-light\xspace. It shows that, in any view $v \ge \mathcal{V}'$ with a correct leader, if the
timeouts at a correct process $p_i$ that enters $v$ are long enough and some
timer expires at $p_i$, then this process cannot be the first to initiate a view
change.
\begin{lemma}
Let $v \geq \mathcal{V}'$ be a view such that ${\sf leader}(v)$ is correct, and let
$p_i$ be a correct process that enters $v$. Assume that ${\sf dur\_delivery}_i(v)
> \max\{4\delta, T+3\delta\}$ and ${\sf dur\_recovery}_i(v) >4\delta$.
If a timer expires at $p_i$ in $v$, then $p_i$ is not the first correct process
to call ${\tt advance}$ in $v$.
\label{thm:timers}
\end{lemma}
The proof relies on the following technical lemma.
\begin{lemma}
Let $v$ be a view such that ${\sf leader}(v)$ is correct and sends
${\tt NEW\_STATE}(v, \mathit{log}', \_)$. Let $p_i$ be a
correct process that enters $v$. Assume that $p_i$ does not leave $v$ or
call ${\tt advance}$ in $v$ before $t_1$, processes ${\tt NEW\_STATE}(v, \mathit{log}',
\_)$ at $t_2$ and receives $m={\tt PREPREPARE}(v,k,x)$ from ${\sf leader}(v)$
at $t_3<t_1$. Then $p_i$ processes $m$ at $t=\max\{t_2, t_3\}$.
\label{lem:accept-proposal}
\end{lemma}
{\em Proof.}
The process $p_i$ processes a ${\tt PREPREPARE}$ message if the conditions in
line~\ref{alg:safety-check} are satisfied. Since ${\sf leader}(v)$ sends $m$, we
have $p_j={\sf leader}(v)$ and ${\sf valid}(x)$. By line~\ref{alg:set-next} and
line~\ref{alg:leader-broadcast}, ${\sf leader}(v)$ only proposes values for positions
between $(v-1)\cdot B +1$ and $v\cdot B$. Then $k\leq v\cdot B$.
By line~\ref{alg:safety-check}, in any view $v'<v$, $p_i$ can only have
accepted proposals for $k'\leq (v-1)\cdot B$. Then, when $p_i$
enters $v$, it has ${\sf phase}[k'']=\textsc{start}$ for all $k''>(v-1)\cdot B$. Furthermore,
by line~\ref{alg:increase-next}, the leader does not
propose a value for the same position twice. Then it is guaranteed
that ${\sf phase}[k]=\textsc{start}$ from $\te{i}{v}$
until $p_i$ processes $m$ or leaves $v$.
Furthermore, when $p_i$ enters $v$, it sets ${\sf curr\_view} =
v$. This holds at least until $p_i$ leaves $v$, which cannot happen
before $t_1$. Thus, we have that ${\sf phase}[k]=\textsc{start}$ and
${\sf curr\_view}=v$ from $\te{i}{v}$ until $p_i$ processes $m$ or leaves $v$.
When $p_i$
processes ${\tt NEW\_STATE}(v, \mathit{log}',
\_)$, it sets ${\sf status}=\textsc{normal}$ and ${\sf log}=\mathit{log}'$, which is the initial log of
${\sf leader}(v)$.
Since, ${\sf leader}(v)$ is correct, any value proposed by
${\sf leader}(v)$ is not in its ${\sf log}$.
Thus, we have that
${\sf status}=\textsc{normal}$ and $\forall k'.\, {\sf log}[k']\not=x$ at $p_i$ from
the moment $p_i$ processes ${\tt NEW\_STATE}(v, \mathit{log}',
\_)$, i.e., from $t_2$, until $p_i$ processes $m$ or leaves $v$.
Therefore, after processing ${\tt NEW\_STATE}(v, \mathit{log}',
\_)$ and before processing $m$ or leaving $v$,
the conditions in line~\ref{alg:safety-check} are satisfied.
Since $t_3<t_1$, then $p_i$ processes $m$. If $t_3<t_2$, then $p_i$
processes $m$ at $t_2$. Otherwise, it processes it at
$t_3$. Hence, $p_i$ processes $m$ at $t=\max\{t_2, t_3\}$, as required. \qed
\paragraph{\rm\it Proof of Lemma~\ref{thm:timers}.}
Since $v\geq\mathcal{V}'$, we have $\tm{v}\geq{\sf GST}$, so that all messages sent by correct
processes after $\tm{v}$ get delivered to all correct processes within $\delta$
and process clocks track real time. We now make a case split on which timer
expires at $p_i$ in $v$. We first consider the case of ${\sf timer\_recovery}$. By
contradiction, assume that $p_i$ is the first correct process to call
${\tt advance}$ in $v$. The process starts its ${\sf timer\_recovery}$ when it enters
a view (line~\ref{alg:newview}), and hence, at $\tm{v}$ at the earliest. Because
$p_i$ is the first correct process to call ${\tt advance}$ in $v$ and
${\sf dur\_recovery}_i(v)>4\delta$ at $p_i$, no correct process calls ${\tt advance}$ in
$v$ until after $\tm{v}+4\delta$. Then by Bounded Entry\xspace all correct
processes enter $v$ by $\tm{v}+2\delta$. Furthermore, by
Validity\xspace no correct process can enter $v+1$ until after
$\tm{v}+4\delta$, and by Proposition~\ref{sync:noskip}, the same holds for any
view $>v$. Thus, all correct processes stay in $v$ at least until
$\tm{v}+4\delta$. When a correct process enters a view, it sends a ${\tt NEW\_LEADER}$
message to the view's leader, and when the leader receives a quorum of such
messages, it sends a ${\tt NEW\_STATE}$ message. Since $\tl{v}\leq \tm{v}+2\delta$,
${\sf leader}(v)$ is guaranteed to receive ${\tt NEW\_LEADER}$ message from a quorum of
processes and send a ${\tt NEW\_STATE}$ message to all processes by
$\tm{v}+3\delta$. Thus, all correct processes receive the ${\tt NEW\_STATE}$ message by
$\tm{v}+4\delta$. In particular, this is the case for $p_i$. Since $p_i$'s
${\sf timer\_recovery}$ has not expired by then, the process stops the timer, which
contradicts our assumption.
We now consider the case when ${\sf timer\_delivery}$ expires at $p_i$ in $v$.
We again prove it by contradiction: assume that $p_i$ is the
first correct process to call ${\tt advance}$ in $v$. The process starts its
${\sf timer\_delivery}$ after handling the leader's ${\tt NEW\_STATE}(v, \_, \_)$
message if ${\sf last\_delivered}< v\cdot B$ or
after delivering a value whose position $k$ in ${\sf log}$ is
such that $(v-1)\cdot B < k < v\cdot B$. We only consider the
former case; the latter is analogous. Let $t_1$ be the time when $p_i$ starts
the ${\sf timer\_delivery}$ that expires and let $t_2$ be the first time when a correct process
calls ${\tt advance}$ in $v$. We have assumed that ${\sf timer\_delivery}$ expires at $p_i$ in
$v$, ${\sf dur\_delivery}_i(v)>\max\{4\delta, T+3\delta\}$ and $p_i$ is the
first correct process that calls ${\tt advance}$ in $v$. Hence,
$t_2 > t_1+\max\{4\delta, T+3\delta\}$. Then by
Validity\xspace no correct process can enter $v+1$ by $t_2$,
and by Proposition~\ref{sync:noskip}, the
same holds for any view $>v$. Furthermore, $t_1\ge \tm{v}$. Then by
Bounded Entry\xspace all correct processes enter $v$ by $t_1+2\delta$.
All correct processes receive the leader's ${\tt NEW\_STATE}(v, \_, \_)$ by
$t_1+\delta$. Therefore, they handle it by $t_1+2\delta$: once they
have received it and entered $v$. If a correct process has
${\sf last\_delivered}\geq v\cdot B$ by the time it handles the
leader's ${\tt NEW\_STATE}(v, \_, \_)$, then it calls ${\tt advance}$. We have
established that no correct process calls ${\tt advance}$ until after
$t_1+\max\{4\delta, T+3\delta\}$. Since all correct processes handle
the leader's ${\tt NEW\_STATE}(v, \_, \_)$ by
$t_1+2\delta$, then all correct processes have ${\sf last\_delivered} < v\cdot B$ by the time they handle the
leader's ${\tt NEW\_STATE}(v, \_, \_)$. Thus, all correct processes send a ${\tt PREPARE}$
for all positions $\leq (v-1)\cdotB$ by $t_1+2\delta$. It then
takes them at most $2\delta$ to exchange the sequence of ${\tt PREPARE}$
and ${\tt COMMIT}$ message leading to commit all positions $\leq
(v-1)\cdotB$. Since $t_1+4\delta < t_2$, all correct processes
have ${\sf last\_delivered} \ge (v-1)\cdotB$ by $t_1+4\delta$.
Assume that ${\sf leader}(v)$
sends ${\tt NEW\_STATE}(v, \_, \_)$ at $t_3$. Since at this time, ${\sf leader}(v)$
starts ${\sf timer\_proposal}$, the leader makes a new proposal
no later than $t_3 + T$. Thus, all correct
processes receive the corresponding message ${\tt PREPREPARE}(v, k, \_)$ from
${\sf leader}(v)$ by $t_3 + T + \delta < t_1 + T + \delta$.
Since ${\sf leader}(v)$ is correct, $k=(v-1)\cdot B + 1$ (line~\ref{alg:set-next}).
Let $t_4$ be the time when all correct
processes handle $m$. By Lemma~\ref{lem:accept-proposal}, $t_4\leq
\max\{t_1+2\delta, t_1 + T + \delta\}$. Then it
takes them at most $2\delta$ to exchange the sequence of ${\tt PREPARE}$
and ${\tt COMMIT}$ message leading to commit. Thus, all correct
processes receive ${\tt COMMIT}(v, k, \_)$ by $t_4+2\delta$.
We have earlier established that $t_2 >
t_1+\max\{4\delta, T+3\delta\}$. Then $t_2>\max\{t_4+2\delta, t_1+4\delta\}$.
Since no correct process leaves $v$ by $t_2$ and by
$t_1+4\delta$ the process $p_i$ has ${\sf last\_delivered}\ge
(v-1)\cdotB$, then by this time $p_i$ executes the handler in
line~\ref{alg:deliver} for the position $k$.
Since $k=(v-1)\cdot B+1$, then $p_i$
executes line~\ref{alg:stop-timerexecute2} and stops ${\sf timer\_delivery}$,
which contradicts our assumption.\qed
\smallskip
\smallskip
Using Lemma~\ref{thm:timers}, we can establish two key facts necessary to prove
the liveness of PBFT-light, which are stated by the lemma below. Fact 1 is
analogous to Lemma~\ref{thm:castro:all-good} in the proof of PBFT-light\xspace. It
establishes that in any view $v \ge \mathcal{V}'$ where the leader is correct and the
timeouts at all correct processes are high enough, some correct process will
deliver a full batch of values. Fact 2 rules out the scenarios discussed at the
end of \S\ref{sec:pbft}, in which some processes increase their timeouts
sufficiently while others do not. It establishes that in a view $v \ge \mathcal{V}'$ with
a correct leader that does not operate normally (no correct process delivers a
full batch of values), a process $p_i$ with sufficiently high timeouts cannot be
the first one to call ${\tt advance}$. This means some other process with lower
timeouts will have to initiate the view change, and thus increase its timeouts.
\begin{lemma}
Consider a view $v\geq\mathcal{V}'$ such that ${\sf leader}(v)$ is correct.
\begin{enumerate}
\item If ${\sf dur\_delivery}_i(v) > \max\{4\delta, T+3\delta\}$ and
${\sf dur\_recovery}_i(v) > 4\delta$ at each correct processes $p_i$ that enters
$v$, then some correct process calls ${\tt advance}$ in $v$ due to delivering a
full batch of values (line~\ref{line:advance-deliver}).
\item Assume that no correct process calls ${\tt advance}$ in $v$ due to delivering
a full batch of values (line~\ref{line:advance-deliver}). If $p_i$ is a
correct process that enters $v$ and we have
${\sf dur\_delivery}_i(v) > \max\{4\delta, T+3\delta\}$ and
${\sf dur\_recovery}_i(v) > 4\delta$, then $p_i$ cannot be the first correct
process to call ${\tt advance}$ in $v$.
\end{enumerate}
\label{thm:pbft-facts}
\end{lemma}
{\em Proof.}
By Lemma~\ref{proposition:enter-all}, a correct process
eventually enters view $v+1$. Then by Validity\xspace
there must exist a correct
process that calls ${\tt advance}$ while in $v$.
Let $p_j$ be the first correct process that does so.
This process must call ${\tt advance}$ when: {\em (i)} a timer expires; or
{\em (ii)} it delivers the full batch of values (line~\ref{line:advance-deliver}).
{\em Case 1.} We have ${\sf dur\_delivery}_j(v) > \max\{4\delta, T+3\delta\}$ and
${\sf dur\_recovery}_j(v) > 4\delta$. Then by Lemma~\ref{thm:timers}, {\em (i)} is
impossible, so that {\em (ii)} must hold.
{\em Case 2.} By contradiction, assume that $p_i = p_j$. Since no correct
process calls ${\tt advance}$ in $v$ due to delivering a full batch of values, {\em
(ii)} is impossible. But since
${\sf dur\_delivery}_i(v) > \max\{4\delta, T+3\delta\}$ and
${\sf dur\_recovery}_i(v) > 4\delta$, by Lemma~\ref{thm:timers}, {\em (i)} is
impossible either.\qed
\begin{theorem}
PBFT-rotation\xspace satisfies the Liveness property of Byzantine atomic broadcast.
\label{thm:liveness-pbft-timers}
\end{theorem}
{\em Proof.}
Consider a valid value $x$ broadcast by a correct process. We first prove that
$x$ is eventually delivered by some correct process. By contradiction, assume
that $x$ is never delivered by a correct process. A correct process broadcasts a
value until it is delivered (line~\ref{alg:send-to-all}). When a correct process
receives a valid value that is not in its queue, it appends the value
(line~\ref{alg:append-queue}).
Thus, since $x$ is never delivered,
there exists a point in time $t$ starting from which $x$ is always in the queues
of all correct processes. By Lemma~\ref{proposition:enter-all}, every view is
entered by at least one correct process. Let view $v_1$ be the first view such
that $v_1\ge \mathcal{V}'$ and $\tm{v_1}\geq t$.
\smallskip
\noindent\textit{Claim 1. In any view $v\geq v_1$ with a correct leader, if a
correct process calls ${\tt advance}$ due to delivering a full batch of values
(line~\ref{line:advance-deliver}), then ${\sf leader}(v)$ eventually removes $B$
values preceding $x$ from its queue.}
\smallskip
\noindent{\em Proof.} Consider a view $v\ge v_1$ with a correct leader where a
correct process $p_i$ calls ${\tt advance}$ at line~\ref{line:advance-deliver}. Then
it delivers a full batch of values proposed by the leader of $v$, which are all
distinct from $x$. Since ${\sf leader}(v)$ is correct and $x$ is forever in its
queue, we have two options: {\em (i)} all values proposed by the leader in $v$
are distinct from ${\tt nop}$ and precede $x$ in the leader's queue; or {\em (ii)}
$\exists k\leq (v-1)\cdot B .\, {\sf log}[k]=x$ at ${\sf leader}(v)$. But the latter is
impossible. Indeed, since $p_i$ delivers a full batch, it delivers all values
whose position in its log is $\leq v\cdot B$. Since the log of the leader and
$p_i$ is the same for those positions when $p_i$ calls ${\tt advance}$, if {\em
(ii)} holds, then $x$ is delivered. Hence, {\em (i)} must hold.
Since $p_i$ reliably broadcasts committed values (line~\ref{alg:send-decision}),
the protocol guarantees that if a correct process delivers a value, all correct
processes eventually do. Thus, ${\sf leader}(v)$ will eventually deliver these values
and remove them from its queue.\qed
\smallskip
\noindent\textit{Claim 2. In any
view $\ge v_1$ with a correct leader, at least one correct process calls
${\tt advance}$ because one of its timers expires
(line~\ref{alg:timerexpire-move}), and no correct process calls ${\tt advance}$
because it delivers a full batch of values
(line~\ref{line:advance-deliver}).}
\smallskip
\noindent{\em Proof.} Assume that the claim does not hold. By
Lemma~\ref{proposition:enter-all} and since leaders rotate round-robin across
views, there are infinitely many views $\geq v_1$ with a correct leader that are
entered by a correct process. Furthermore, by Validity\xspace,
at least one correct process calls ${\tt advance}$ in each of these. Since we assume
that the claim is false, there is a correct process $p_i$ that leads an infinite
number of views $\ge v_1$ in which some correct process calls ${\tt advance}$ at
line~\ref{line:advance-deliver}. By Claim 1, for each such view $p_i$ eventually
removes $B$ values preceding $x$ from its queue. In views $\ge v_1$ no new
values are added to $p_i$'s queue before $x$. Hence, there exists a view
$\ge v_1$ in which $x$ is proposed and a correct process calls ${\tt advance}$ at
line~\ref{line:advance-deliver}, thus delivering $x$. This reaches a
contradiction.\qed
\smallskip
\noindent\textit{Claim 3. Every correct process calls the timer expiration
handler (line~\ref{alg:expire-timerexecute}) infinitely often.}
\smallskip
\noindent{\em Proof.} Assume this is not the case and let $C_{\rm fin}$ and
$C_{\rm inf}$ be the sets of correct processes that call the timer expiration
handler finitely and infinitely often, respectively. Then
$C_{\rm fin} \not= \emptyset$, and by Claim~2, $C_{\rm inf} \not= \emptyset$.
The values of ${\sf dur\_delivery}$ and ${\sf dur\_recovery}$
increase unboundedly at processes from $C_{\rm inf}$, and do not change after
some view $v_2$ at processes from $C_{\rm fin}$.
By Lemma~\ref{proposition:enter-all} and since leaders rotate round-robin, there
exists a view $v_3\geq \max\{v_2, v_1\}$ with a correct leader such that for any
process $p_i \in C_{\rm inf}$ that enters $v_3$ we have
${\sf dur\_delivery}_i(v_3)> \max\{4\delta, T+3\delta\}$ and
${\sf dur\_recovery}_i(v_3)> 4\delta$. By Claim~2, at least one correct process
calls ${\tt advance}$ because one of its timers expires in $v_3$; let $p_l$ be the
first process to do so. Since $v_3 \ge v_2$, this cannot be a process from
$C_{\rm fin}$, since none of these processes can increase their timers in
$v_3$. Hence, $p_l\in C_{\rm inf}$, which contradicts
Lemma~\ref{thm:pbft-facts}(2).\qed
\smallskip
We now prove that $x$ is delivered by a correct process. By Claim~3 and
Lemma~\ref{proposition:enter-all}, there exists a view $v_4\geq v_1$ with a
correct leader such that for any correct process $p_i$ that enters $v_4$ we have
${\sf dur\_delivery}_i(v_4) > \max\{4\delta, T+3\delta\}$ and
${\sf dur\_recovery}_i(v_4) > 4\delta$. By Lemma~\ref{thm:pbft-facts}(1), some
correct process calls ${\tt advance}$ in $v_4$ due to delivering a full batch of
values (line~\ref{line:advance-deliver}). This contradicts Claim~2 and thus
proves that $x$ is delivered by a correct process. By reliably broadcasting
committed values (line~\ref{alg:send-decision}), the protocol guarantees that if
a correct process delivers a value, then all correct eventually do. From here
the Liveness property follows.\qed
\section{Proving the Liveness of PBFT}
\label{sec:liveness}
Assume that PBFT-light\xspace is used with a synchronizer satisfying the specification in
Figure~\ref{fig:multi-sync-properties}; to simplify the following latency
analysis, we assume $d = 2\delta$, as for the synchronizer in
Figure~\ref{fig:sync}. We now prove that the protocol satisfies the Liveness
property of Byzantine atomic broadcast; we defer the proof of the other
properties to \tr{\ref{sec:pbft-safety}}{C.1}. To the best of our
knowledge, this is the first rigorous proof of liveness for the algorithmic core
of PBFT: as we elaborate in \S\ref{sec:related}, the liveness mechanisms of PBFT
came only with a brief informal justification, which did not cover their most
critical properties~\cite[\S{}4.5.1]{castro-tocs}. Our proof is simplified by
the use of the synchronizer specification, which allows us to avoid dealing with
view synchronization mechanics.
It also provides a methodology that we reuse to prove the liveness of other
protocols (\S\ref{sec:xbft}).
We prove the liveness of PBFT-light\xspace by showing that the protocol establishes
properties reminiscent of those of failure detectors~\cite{CT96}. First,
similarly to their completeness property, %
we prove that
every correct process eventually attempts to advance from a {\em bad}\/ view in
which no progress is possible (e.g., because the leader is faulty).
\begin{lemma}
Assume that a correct process $p_i$ receives ${\tt BROADCAST}(x)$ for a valid
value $x$ while in a view $v$. If $p_i$ never delivers $x$ and never enters
a view higher than $v$, then it eventually calls ${\tt advance}$ in $v$.
\label{thm:castro:completeness}
\end{lemma}
The lemma holds because in PBFT-light\xspace each process monitors the leader's behavior
using timers, and we defer its easy proof to
\tr{\ref{sec:pbft-liveness}}{C.2}. Note that even though this
monitoring ensures that correct processes will eventually try to advance from a
view with a faulty leader, the SMR protocol by itself does not ensure that the
processes will actually enter a new view with a different leader. Achieving this
is the job of the synchronizer, and in the following proof of PBFT-light\xspace we show that
this happens using the Progress property in
Figure~\ref{fig:multi-sync-properties} together with
Lemma~\ref{thm:castro:completeness}.
The next lemma we establish is similar to the eventual accuracy property of
failure detectors. It stipulates that if the timeout values are high enough,
then eventually any correct process that enters a {\em good}\/ view (with a
correct leader) will never attempt to advance from it.
Let ${\sf dur\_recovery}_i(v)$ and ${\sf dur\_delivery}_i(v)$ denote respectively
the value of the ${\sf dur\_recovery}$ and ${\sf dur\_delivery}$ variable at a
correct process $p_i$ while in view $v$.
\begin{lemma}
Consider a view $v\geq\mathcal{V}$ such that $\tm{v}\geq{\sf GST}$ and ${\sf leader}(v)$ is
correct. If ${\sf dur\_recovery}_i(v) > 6\delta$ and
${\sf dur\_delivery}_i(v) > 4\delta$ at each correct process $p_i$ that enters
$v$, then no correct process calls ${\tt advance}$ in $v$.
\label{thm:castro:all-good}
\end{lemma}
\begin{wrapfigure}[14]{l}{.5\textwidth}
\vspace{-16pt}
\hspace{-8pt}
\includegraphics[width=0.5\textwidth]{diagrams/recovery.pdf}
\vspace{-5pt}
\caption{\!{}An illustration of the bound on ${\sf dur\_recovery}$ in
Lemma~\ref{thm:castro:all-good}.}
\label{fig:bounds}
\end{wrapfigure}
Before proving the lemma, we informally explain the rationale
for the bounds on timeouts in it, using the example of
${\sf dur\_recovery}$. The timer ${\sf timer\_recovery}$ is started at a process $p_i$
when this process enters a view $v$
(line~\ref{line:castro:start-timerrecovery}), and is stopped when the process
delivers all values inherited from previous views
(lines~\ref{alg:castro:stop-timerrecovery}
or~\ref{alg:castro:stop-timerrecovery2}). The two events are separated by $4$
communication steps of PBFT-light\xspace, exchanging messages of the types ${\tt NEW\_LEADER}$,
${\tt NEW\_STATE}$, ${\tt PREPARE}$ and ${\tt COMMIT}$ (Figure~\ref{fig:bounds}).
However, $4\delta$ would be too small a value for ${\sf dur\_recovery}$. This is
because the leader of $v$ sends its ${\tt NEW\_STATE}$ message only after receiving a
quorum of ${\tt NEW\_LEADER}$ messages, and different processes may enter $v$ and send
their ${\tt NEW\_LEADER}$ messages at different times (e.g., $p_i$ and $p_j$ in
Figure~\ref{fig:bounds}). Hence, ${\sf dur\_recovery}$ must additionally
accommodate the maximum discrepancy in the entry times, which is $d = 2\delta$
by the Bounded Entry property. Then to ensure that $p_i$ stops the timer before
it expires, we require ${\sf dur\_recovery}_i(v) > 6\delta$.
As the above reasoning illustrates, Lemma~\ref{thm:castro:all-good} is more
subtle than Lemma~\ref{thm:castro:completeness}: while the latter is ensured
just by the checks in the SMR protocol, the former relies on the Bounded Entry
property of the synchronizer.
Another subtlety about Lemma~\ref{thm:castro:all-good} is that the $\delta$ used
in its premise is a priori unknown. Hence, to apply the lemma in the liveness
proof of PBFT-light\xspace, we have to argue that, if correct processes keep changing views
due to lack of progress, then all of them will eventually increase their
timeouts high enough to satisfy the bounds in Lemma~\ref{thm:castro:all-good}.
This is nontrivial due to the fact that, as in the original PBFT, in our
protocol the processes update their timeouts independently, and may thus
disagree on their durations. For example, the first correct process $p_i$ to
detect a problem with the current view $v$ will increase its timeouts and call
${\tt advance}$ (line~\ref{alg:castro:expire-timerexecute}). The synchronizer may
then trigger ${\tt new\_view}$ notifications at other correct processes before they
detect the problem as well, so that their timeouts will stay unchanged
(line~\ref{alg:castro:newview}).\footnote{Recall that even a single ${\tt advance}$
call at a correct process may lead to a view switch (\S\ref{sec:sync}). For
example, with the synchronizer in Figure~\ref{fig:sync} this may happen as
follows. The ${\tt advance}$ call at a process generates ${\tt WISH}(v+1)$
(line~\ref{line:send2}) and the Byzantine processes produce another $f$ copies
of the same message. Correct processes receiving the resulting $f+1$ copies of
the message relay it via line~\ref{line:send3}, which yields $2f+1$ copies in
total. The synchronizer then triggers ${\tt new\_view}(v+1)$ notifications at correct
processes that receive all these copies (line~\ref{line:trigger-newview}),
causing them to enter $v+1$ without increasing their timeouts.} One may think
that this allows executions in which only some correct processes keep increasing
their timeouts until they are high enough, whereas others are forever stuck with
timeouts that are too low, invalidating the premise of
Lemma~\ref{thm:castro:all-good}. The following lemma rules out such scenarios
and also trivially implies Lemma~\ref{thm:castro:all-good}. It establishes that,
in a sufficiently high view $v$ with a correct leader, if the timeouts at a
correct process $p_i$ that enters $v$ are high enough, then this process cannot
be the first one to initiate a view change. Hence, for the protocol to enter
another view, some other process with lower timeouts must call ${\tt advance}$ and
thus increase their durations (line~\ref{alg:castro:expire-timerexecute}).
\begin{lemma}
Let $v\geq \mathcal{V}$ be such that $\tm{v}\geq{\sf GST}$ and ${\sf leader}(v)$ is
correct, and consider a correct process $p_i$ that enters $v$. If
${\sf dur\_recovery}_i(v) > 6\delta$ and ${\sf dur\_delivery}_i(v) > 4\delta$
then $p_i$ is not the first correct process to call ${\tt advance}$ in $v$.
\label{thm:castro:timers}
\end{lemma}
{\em Proof.}
Since $\tm{v}\geq{\sf GST}$, messages sent by correct processes after $\tm{v}$ get
delivered to all correct processes within $\delta$ and process clocks track real
time. By contradiction, assume that $p_i$ is the first correct process to call
${\tt advance}$ in $v$. This happens because a timer expires at $p_i$, and we now
make a case split on which timer it is. Here we only consider ${\sf timer\_recovery}$
and handle ${\sf timer\_delivery}$ in \tr{\ref{sec:pbft-liveness}}{C.2}. A
process starts ${\sf timer\_recovery}$ when it enters the view $v$
(line~\ref{line:castro:start-timerrecovery}), and hence, at $\tm{v}$ at the
earliest (Figure~\ref{fig:bounds}). Because $p_i$ is the first correct process
to call ${\tt advance}$ in $v$ and ${\sf dur\_recovery}_i(v)>6\delta$, no correct
process calls ${\tt advance}$ in $v$ until after $\tm{v}+6\delta$. Then by Bounded Entry\xspace
all correct processes enter $v$ by $\tm{v}+2\delta$. Also, by Validity\xspace no
correct process can enter $v+1$ until after $\tm{v}+6\delta$, and by
Proposition~\ref{sync:noskip} the same holds for any view $>v$. Thus, all
correct processes stay in $v$ at least until $\tm{v}+6\delta$.
When a correct process enters $v$, it sends a ${\tt NEW\_LEADER}$ message to the leader
of $v$, which happens by $\tm{v}+2\delta$. When the leader receives
such %
messages from a quorum of processes, it broadcasts a ${\tt NEW\_STATE}$ message. Thus,
by $\tm{v}+4\delta$ all correct processes receive this message and set
${\sf status}=\textsc{normal}$. If at that point ${\sf init\_log\_length}\leq{\sf last\_delivered}$ at $p_i$,
then the process stops ${\sf timer\_recovery}$
(line~\ref{alg:castro:stop-timerrecovery2}), which contradicts our
assumption. Hence, ${\sf init\_log\_length}>{\sf last\_delivered}$. When a correct process receives
${\tt NEW\_STATE}$, it sends ${\tt PREPARE}$ messages for all positions $\leq {\sf init\_log\_length}$
(line~\ref{alg:castro:preparenewview}). It then takes the correct processes at
most $2\delta$ to exchange the sequence of ${\tt PREPARE}$ and ${\tt COMMIT}$ messages
that commits the values at all positions $\leq {\sf init\_log\_length}$. Thus, by
$\tm{v}+6\delta$ the process $p_i$ commits and delivers all these positions,
stopping ${\sf timer\_recovery}$ (line~\ref{alg:castro:stop-timerrecovery}). This again
contradicts our assumption.\qed
\begin{theorem}
PBFT-light\xspace satisfies the Liveness property of Byzantine atomic broadcast.
\label{thm:castro:liveness}
\end{theorem}
{\em Proof.}
Consider a valid value $x$ broadcast by a correct process. We first prove that
$x$ is eventually delivered by some correct process. Assume the contrary.
We now prove that in this case PBFT-light\xspace must keep switching views forever. We do
this analogously to %
Proposition~\ref{lem:live-toy} in \S\ref{sec:sync}: we use
Lemma~\ref{thm:castro:completeness} to show that correct processes keep calling
${\tt advance}$, and the Progress property of the synchronizer to show that some of
them will keep switching views as a result.
\smallskip
\noindent\textit{Claim 1. Every view is entered by some correct process.}
\smallskip
\noindent{\em Proof.}
Since all correct processes call {\tt start} (line~\ref{line:castro:start0}), by
Startup\xspace a correct process eventually enters some view. We now show that correct
processes keep entering new views forever. Assume that this is false, so that
there exists a maximal view $v$ entered by any correct process. Let $P$ be any
set of $f+1$ correct processes and consider an arbitrary process $p_i\in P$ that
enters $v$. The process that broadcast $x$ is correct, and thus keeps
broadcasting $x$ until the value is delivered
(line~\ref{alg:castro:send-to-all}). Since $x$ is never delivered, $p_i$ is
guaranteed to receive $x$ while in $v$. Then by
Lemma~\ref{thm:castro:completeness}, $p_i$ eventually calls ${\tt advance}$ while in
$v$. Since $p_i$ was picked arbitrarily, we have
$\forall p_i \in P.\, {\te{i}{v}\mathpunct{\downarrow}} {\implies} {\ta{i}{v}\mathpunct{\downarrow}}$. Then by
Progress\xspace we get $\tm{v+1}\mathpunct{\downarrow}$, which yields a contradiction. Thus, correct
processes keep entering views forever. The claim then follows from
Proposition~\ref{sync:noskip} ensuring that, if a view is entered by a correct
process, then so are all preceding views. \qed
\smallskip
Let view $v_1$ be the first view such that $v_1\ge \mathcal{V}$ and $\tm{v_1}\geq {\sf GST}$;
such a view exists by Claim 1. The next claim is needed to show that all correct
processes will increase their timeouts high enough to satisfy the bounds in
Lemma~\ref{thm:castro:all-good}. %
\smallskip
\noindent\textit{Claim 2. Every correct process calls the timer expiration
handler (line~\ref{alg:castro:expire-timerexecute}) infinitely often.}
\smallskip
\noindent{\em Proof.} Assume the contrary and let $C_{\rm fin}$ and
$C_{\rm inf}$ be the sets of correct processes that call the timer expiration
handler finitely and infinitely often, respectively. Then
$C_{\rm fin} \not= \emptyset$, and by Claim~1 and Validity\xspace, $C_{\rm inf}
\not= \emptyset$. The values of
${\sf dur\_delivery}$ and ${\sf dur\_recovery}$ increase unboundedly at processes
from $C_{\rm inf}$, and do not change after some view $v_2$ at processes from
$C_{\rm fin}$. By Claim~1 and since leaders rotate round-robin, there is a
view $v_3\geq \max\{v_2, v_1\}$ with a correct leader such that any process
$p_i \in C_{\rm inf}$ that enters $v_3$ has
${\sf dur\_delivery}_i(v_3)> 4\delta$ and ${\sf dur\_recovery}_i(v_3)> 6\delta$. By
Claim~1 and Validity\xspace, at least one correct process
calls ${\tt advance}$ in $v_3$; let $p_l$ be the first process to do so. Since
$v_3 \ge v_2$, this process cannot be in $C_{\rm fin}$ because none of these
processes can increase their timers in $v_3$. Then $p_l\in C_{\rm inf}$,
contradicting Lemma~\ref{thm:castro:timers}.\qed
\smallskip
By Claims~1 and~2, there exists a view $v_4\geq v_1$ with a correct leader such
that some correct process enters $v_4$, and for any correct process $p_i$ that
enters $v_4$ we have ${\sf dur\_delivery}_i(v_4) > 4\delta$ and
${\sf dur\_recovery}_i(v_4) > 6\delta$. By Lemma~\ref{thm:castro:all-good}, no
correct process calls ${\tt advance}$ in $v_4$. Then, by Validity\xspace, no correct
process enters $v_4+1$, which contradicts Claim~1. This contradiction shows that
$x$ must be delivered by a correct process. Then, since the protocol reliably
broadcasts committed values (line~\ref{alg:castro:send-decision}), all correct
processes will also eventually deliver $x$. From here the Liveness property
follows.\qed
\section{System Model}
\label{sec:model}
We consider a system of $n = 3f+1$ processes, out of which at most $f$ can be
Byzantine, i.e., can behave arbitrarily. In the latter case the process is {\em
faulty}; otherwise it is {\em correct}. We denote the set of all correct
processes by $\mathcal{C}$. We call a set $Q$ of $2f+1$ processes a {\em quorum}
and write ${\sf quorum}(Q)$. %
We assume standard cryptographic primitives~\cite[\S{}2.3]{cachin-book}:
processes can communicate via authenticated point-to-point links, sign messages
using digital signatures, and use a collision-resistant hash function
${\sf hash}()$. We denote by $\langle m \rangle_i$ a message $m$ signed by process
$p_i$.
We consider a {\em partial synchrony} model~\cite{dls,CT96}: for each execution
of the protocol, there exist a time ${\sf GST}$ and a duration $\delta$ such that
after ${\sf GST}$ message delays between correct processes are bounded by $\delta$;
before ${\sf GST}$ messages can get arbitrarily delayed or lost.
As in~\cite{CT96}, we assume that the values of ${\sf GST}$ and $\delta$ are unknown
to the protocol. This reflects the requirements of practical systems, whose
designers cannot accurately predict when network problems leading to asynchrony
will stop and what the latency will be during the following synchronous period.
We also assume that processes have %
hardware clocks that can drift unboundedly from real time before ${\sf GST}$, but do
not drift thereafter.
\section{PBFT with Leader Rotation Using an SMR Synchronizer}
\label{sec:pbft-rotation}
We now demonstrate how an SMR synchronizer can be used to implement Byzantine
SMR protocols that periodically force a leader
change~\cite{aardvark,spinning,mirbft}. Figures~\ref{fig:pbft-normal}-\ref{fig:pbft-recovery}
give an implementation of such a variant of PBFT, which we call PBFT-rotation\xspace. As in
PBFT-light\xspace, processes monitor the behavior of the leader and ask the synchronizer to
advance to another view if they suspect that the leader is faulty. To ensure
that leaders periodically rotate, processes also call ${\tt advance}$ once they
deliver $B$ values proposed by the current leader. Thus, the leader of a view
$v$ is responsible for filling in the slots in the ${\sf log}$ from $(v-1)\cdot B+1$
to $(v-1)\cdot B + B$.
\begin{figure}[t]
\vspace{3pt}
\begin{tabular}{@{\!}l@{\!\!\!\!\!\!}|@{\ \ }l@{}}
\scalebox{0.96}{%
\begin{minipage}[t]{7.5cm}
\let\@latex@error\@gobble
\vspace*{-11pt}
\begin{algorithm*}[H]
\SetInd{\marginA}{\marginB}
\setcounter{AlgoLine}{0}
\SetInd{\marginA}{\marginB}
\SubAlgo{\Fun ${\tt start}()$}{
\lIf{${\sf curr\_view} = 0$}{{\tt advance}()\label{line:start}}
}
\smallskip
\SubAlgo{\textbf{when {\sf timer\_delivery}{} or {\sf timer\_recovery}{}
expires}\label{alg:expire-timerexecute}}{
${\tt stop\_all\_timers}()$\;
${\tt advance}()$\; \label{alg:timerexpire-move}
${\sf status} \leftarrow \textsc{advanced}$\;
${\sf dur\_delivery} \leftarrow {\sf dur\_delivery} + \tau$\; \label{line:rotation:timer-inc1}
${\sf dur\_recovery} \leftarrow {\sf dur\_recovery} + \tau$\; \label{line:rotation:timer-inc2}
}
\smallskip
\SubAlgo{\Fun ${\tt broadcast}(x)$\label{alg:broadcast}}{
\textbf{pre:} ${\sf valid}(x)$\;
\Send $\langle {\tt BROADCAST}(x) \rangle_i$ \KwTo \ {\bf all}{}
{\bf periodically until $x$ is delivered}\label{alg:send-to-all}
}
\smallskip
\SubAlgo{\WhenReceived ${\tt BROADCAST}(x)$\label{alg:receive-broadcast}}{
\textbf{pre:} ${\sf valid}(x) \wedge x \not\in {\sf queue} \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }} (\forall k.\, k \le {\sf last\_delivered} {\implies} {}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }(} {\sf commit\_log}[k]\not=x)$\;
${\sf queue} \leftarrow {\tt append}({\sf queue}, x)$\label{alg:append-queue}\;
}
\smallskip
\SubAlgo{{\bf when} ${\sf status} = \textsc{normal} \wedge p_i = {\sf leader}({\sf curr\_view}) \wedge{}$
\mbox{${\sf next} \le {\sf curr\_view} \cdot B \wedge
\exists x \in {\sf queue}.\, \forall k.\, {\sf log}[k]\not=x$}\label{alg:leader-broadcast}}{
$x \leftarrow {}$the first value in ${\sf queue}$ that \mbox{is not in ${\sf log}$}\;
$\ensuremath{{\tt stop\_timer}}({\sf timer\_broadcast})$\;
${\tt propagate}(x)$\;
}
\smallskip
\SubAlgo{\textbf{when {\sf timer\_broadcast}\ expires}}{\label{alg:expire-timerbroadcast}
${\tt propagate}({\tt nop})$\;
}
\smallskip
\SubAlgo{\Fun ${\tt propagate}(x)$\label{alg:propagate}}{
\Send $\langle {\tt PREPREPARE}({\sf curr\_view}, $ ${\sf next}, x) \rangle_i$
\KwTo \ {\bf all}\;
${\sf next} \leftarrow {\sf next} + 1$\;\label{alg:increase-next}
\If{${\sf next} \le {\sf curr\_view} \cdot B$}{%
$\ensuremath{{\tt start\_timer}}({\sf timer\_broadcast}, T)$\label{alg:start-timerbroadcast}}
}
\end{algorithm*}
\vspace*{-6pt}
\end{minipage}}
&
\scalebox{0.96}{%
\begin{minipage}[t]{9cm}
\let\@latex@error\@gobble
\vspace*{-11pt}
\begin{algorithm*}[H]
\SubAlgo{\WhenReceived $\langle {\tt PREPREPARE}(v, k, x) \rangle_{j}$\label{alg:receive-propose}}{
\textbf{pre:} $p_j = {\sf leader}(v) \wedge {\sf curr\_view} = v \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl}$\phantom{\text{{\bf pre:} }}{\sf status} = \textsc{normal} \wedge {\sf phase}[k] = \textsc{start} \wedge {}$\\\label{alg:safety-check}
\renewcommand{\nl}{\let\nl\oldnl}$\phantom{\text{{\bf pre:} }}k \le v \cdot B \wedge {\sf valid}(x) \wedge (\forall k'.\, {\sf log}[k']\not=x)$\;
$({\sf log}, {\sf phase})[k] \leftarrow (x, \textsc{preprepared})$\;
\Send $\langle {\tt PREPARE}(v, k, {\sf hash}(x)) \rangle_i$ \KwTo \ {\bf all}\;
}
\smallskip
\SubAlgo{\WhenReceived $\{\langle {\tt PREPARE}(v, k, h) \rangle_j \mid p_j
\in Q\} = C$ \qquad\qquad {\bf for a quorum $Q$}\label{alg:receive-prepared}}{
\textbf{pre:} ${\sf curr\_view} = v \wedge {\sf phase}[k] = \textsc{preprepared} \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl}$\phantom{\text{{\bf pre:} }}{} {\sf status} = \textsc{normal} \wedge {\sf hash}({\sf log}[k]) = h$\;
$({\sf prep\_log}, {\sf prep\_view}, {\sf cert}, {\sf phase})[k] \leftarrow {}$\\
\renewcommand{\nl}{\let\nl\oldnl}$\quad ({\sf log}[k], {\sf curr\_view}, C, \textsc{prepared})$\label{alg:assign-cballot}\;
\Send $\langle {\tt COMMIT}(v, k, h) \rangle_i$ \KwTo \ {\bf all}\;
}
\smallskip
\SubAlgo{\WhenReceived $\{\langle {\tt COMMIT}(v, k, h) \rangle_j \mid p_j
\in Q\} = C$ \quad\qquad\qquad {\bf for a quorum $Q$}\label{alg:receive-committed}}{
\textbf{pre:} ${\sf curr\_view} = v \wedge {\sf phase}[k] = \textsc{prepared} \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl}$\phantom{\text{{\bf pre:} }}{\sf status} = \textsc{normal} \wedge {\sf hash}({\sf prep\_log}[k]) = h$\;
$({\sf commit\_log},{\sf phase})[k] \leftarrow ({\sf log}[k], \textsc{committed})$\;
\Broadcast $\langle {\tt DECISION}({\sf commit\_log}[k], k, C)$\; \label{alg:send-decision}
}
\smallskip
\SubAlgo{{\bf when} ${{\sf commit\_log}[{\sf last\_delivered}+1] \not= \bot}$\label{alg:deliver}}{
${\sf last\_delivered} \leftarrow {\sf last\_delivered}+1$\; \label{alg:update-last}
\If{${\sf commit\_log}[{\sf last\_delivered}] \not= {\tt nop}$}{${\tt deliver}({\sf commit\_log}[{\sf last\_delivered}])$}\label{alg:deliver-value}
${\tt remove}({\sf queue},
{\sf commit\_log}[{\sf last\_delivered}])$\; \label{alg:remove-queue}
\If{${\sf status}={\normalfont \textsc{normal}}$}{
\uIf{${\sf last\_delivered} = {\sf curr\_view} \cdot
B$}{
${\tt stop\_all\_timers}()$\; \label{line:stop-deliver}
${\tt advance}()$\; \label{line:advance-deliver}
${\sf status} \leftarrow \textsc{advanced}$\;}
\ElseIf{${\sf last\_delivered} > ({\sf curr\_view}-1) \cdot
B$}{
$\ensuremath{{\tt stop\_timer}}({\sf timer\_delivery})$\label{alg:stop-timerexecute2}\;
$\ensuremath{{\tt start\_timer}}({\sf timer\_delivery},
{\sf dur\_delivery})$\label{alg:start-timerexecute}\;
}
}
}
\smallskip
\SubAlgo{\WhenReceived ${\tt DECISION}(x, k, C)$ \label{alg:receive-decision}}{
\textbf{pre:} ${\sf commit\_log}[k] \not= \bot \wedge \exists v.\, \ensuremath{{\sf committed}}(C, v, k,
{\sf hash}(x))$\; \label{alg:decision-safetycheck}
${\sf commit\_log}[k] \leftarrow x$\;
}
\end{algorithm*}
\vspace*{-6pt}
\end{minipage}}
\end{tabular}
\vspace*{-2pt}
\caption{Normal protocol operation of PBFT-rotation\xspace at a process $p_i$.}
\label{fig:pbft-normal}
\end{figure}
\begin{figure}[t]
\vspace{2pt}
\begin{tabular}{@{}l@{\!\!\!\!\!\!\!}|@{\quad}l@{}}
\scalebox{0.96}{%
\begin{minipage}[t]{7.7cm}
\let\@latex@error\@gobble
\vspace*{-12pt}
\begin{algorithm*}[H]
\setcounter{AlgoLine}{52}
\SetInd{\marginA}{\marginB}
\SubAlgo{\Upon ${\tt new\_view}(v)$\label{alg:newview}}{
${\tt stop\_all\_timers}()$\; \label{line:stoptimers-enterview}
${\sf curr\_view} \leftarrow v$\;\label{line:set-currentview}
${\sf status} \leftarrow \textsc{initializing}$\;
\Send $\langle {\tt NEW\_LEADER}({\sf curr\_view}, {\sf prep\_view},$ ${\sf prep\_log}, {\sf cert}) \rangle_i$
\KwTo ${\sf leader}({\sf curr\_view})$\;
$\ensuremath{{\tt start\_timer}}({\sf timer\_recovery},$ ${\sf dur\_recovery})$\;\label{line:start-timerrecovery}
}
\smallskip
\SubAlgo{\WhenReceived $\{\langle {\tt NEW\_LEADER}(v, \mathit{prep\_view}_j, $ $\mathit{prep\_log}_j,
\mathit{cert}_j) \rangle_j \mid$ $p_j \in Q\} = M$ {\bf for a quorum
$Q$}\label{alg:receive-newleader}}{
\textbf{pre:} $p_i = {\sf leader}(v) \wedge {\sf curr\_view} = v \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }} {\sf status} = \textsc{initializing} \wedge{}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }} \forall m \in M.\, {\sf ValidNewLeader}(m))$\;
\ForAll{$k$\label{alg:select-proposal}}{
\lIf{$\exists p_{j'} \in Q.\, \mathit{prep\_view}_{j'}[k] \not= 0 \wedge {}$
$(\forall p_{j} \in Q.\, \mathit{prep\_view}_{j}[k] \le \mathit{prep\_view}_{j'}[k])$}{%
$\mathit{log}'[k] \leftarrow \mathit{prep\_log}_{j'}[k]$\label{alg:prepared-entries}}
}
${\sf next} \leftarrow (v-1) \cdot B +1$\;\label{alg:set-next}
}
\end{algorithm*}
\vspace*{-5pt}
\begin{tikzpicture}[overlay]
\node[draw=none, fill=white, thick,minimum width=.5cm,minimum height=.2cm] (b) at (.743,0){};%
\end{tikzpicture}
\end{minipage}}
&
\scalebox{0.96}{%
\begin{minipage}[t]{8.6cm}
\let\@latex@error\@gobble
\vspace*{-22pt}
\begin{algorithm*}[H]
\renewcommand{\nl}{\let\nl\oldnl}\SubAlgo{}{
\ForAll{$k = 1..({\sf next}-1)$\label{alg:clean-entries}}{
\lIf{$\mathit{log}'[k] = \bot \vee \exists k'.\, k' \not= k \wedge \mathit{log}'[k'] = \mathit{log}'[k] \wedge {} $
$\exists p_{j'} \in Q.\, \forall p_{j} \in
Q.\, \mathit{prep\_view}_{j'}[k'] > \mathit{prep\_view}_{j}[k]$}{%
$\mathit{log}'[k] \leftarrow {\tt nop}$\label{alg:newview-end}%
}
}
\Send $\langle {\tt NEW\_STATE}(v, \mathit{log}', M) \rangle_i$ \KwTo \ {\bf all}\; \label{alg:send-newview}
$\ensuremath{{\tt start\_timer}}({\sf timer\_broadcast}, T)$\;
}
\smallskip
\SubAlgo{\WhenReceived $\langle {\tt NEW\_STATE}(v, \mathit{log}', M) \rangle_j = m$\label{alg:receive-newview}}{
\textbf{pre:} ${\sf status} = \textsc{initializing} \wedge {\sf curr\_view} = v \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }} {\sf ValidNewState}(m)$\;
$\ensuremath{{\tt stop\_timer}}({\sf timer\_recovery})$\;\label{alg:stop-timerrecovery}
${\sf log} \leftarrow \mathit{log}'$\;
\uIf{${\sf last\_delivered} \geq {\sf curr\_view} \cdot B$}{
${\tt advance}()$\;
${\sf status} \leftarrow \textsc{advanced}$\;
}\Else{
\ForAll{$\{k \mid {\sf log}[k] \not= \bot\}$}{
${\sf phase}[k] \leftarrow \textsc{preprepared}$\;
\Send $\langle {\tt PREPARE}(v, k, {\sf hash}({\sf log}[k])) \rangle_i$ \KwTo
\ {\bf all}\;
}
$\ensuremath{{\tt start\_timer}}({\sf timer\_delivery},{\sf dur\_delivery})$\;\label{line:timer-abovedelivered}
${\sf status} \leftarrow \textsc{normal}$\; \label{alg:status-normal}
}
}
\end{algorithm*}
\vspace*{-5pt}
\end{minipage}}
\end{tabular}
\caption{View-initialization protocol of PBFT-rotation\xspace at a process $p_i$.}
\label{fig:pbft-recovery}
\end{figure}
A process broadcasts a valid value $x$ using a ${\tt broadcast}$ function
(line~\ref{alg:broadcast}). As in PBFT-light\xspace, this keeps sending the value to all
processes in a ${\tt BROADCAST}$ message until the current process delivers the
value. When a process receives a ${\tt BROADCAST}$ message with a new value
(line~\ref{alg:receive-broadcast}), it appends the value to a ${\sf queue}$ of values
pending to be broadcast. When the leader has new values in its ${\sf queue}$ and has
not yet exhausted the range of log slots it is allowed to fill
(line~\ref{alg:leader-broadcast}), it selects the first new value in the queue
and proposes it by calling the ${\tt propagate}$ function
(line~\ref{alg:propagate}). The processes then handle the proposal as in PBFT-light\xspace.
When a process delivers a value, the process removes it from the queue of
pending values (line~\ref{alg:remove-queue}). If this is the value is in the
last slot allocated to the current leader, the process also calls ${\tt advance}$ to
request a leader change (line~\ref{line:advance-deliver}).
A follower monitors the leader's behavior using two timers, ${\sf timer\_delivery}$ and
${\sf timer\_recovery}$, which are similar to the corresponding timers in PBFT-light\xspace, but
slightly different. The (single) timer ${\sf timer\_delivery}$ checks that new values
are delivered at regular intervals: a process sets ${\sf timer\_delivery}$ for a
duration determined by ${\sf dur\_delivery}$ when it delivers a value and the
current leader has not yet exhausted the slots allocated to it
(line~\ref{alg:start-timerexecute}); the process stops the timer when it
delivers the next value (line~\ref{line:timer-abovedelivered}). If a correct
leader does not have anything to propose during a fixed time interval $T$, the
leader proposes a ${\tt nop}$. The leader ensures this using a timer
${\sf timer\_broadcast}$ (lines~\ref{alg:start-timerbroadcast}
and~\ref{alg:expire-timerbroadcast}). The above mechanism protects against a
faulty leader not making {\em any} proposals. However, it allows a faulty leader
to omit {\em some} of the values submitted by clients. The overall protocol
nevertheless protects against censorship because leaders periodically rotate,
and thus the protocol will go through infinitely many views with correct
leaders. Since values to be broadcast are sent to all processes
(line~\ref{alg:send-to-all}) and are handled in the order of arrival
(line~\ref{alg:append-queue}), each value will eventually be proposed by a
correct leader.
Finally, ${\sf timer\_recovery}$ is used to check that the leader initializes a view
quickly enough. Like in PBFT-light\xspace, a process starts this timer for a duration
determined by ${\sf dur\_recovery}$ when it enters a new view
(line~\ref{line:start-timerrecovery}). Unlike in PBFT-light\xspace, a process stops the
timer when it receives a ${\tt NEW\_STATE}$ message with the initial log from the leader
(line~\ref{alg:stop-timerrecovery}). In PBFT-light\xspace the timer is stopped only after
delivering all the values in the initial log, but in PBFT-rotation\xspace the deliver of these
values is checked by ${\sf timer\_delivery}$.
The Integrity, External Validity and Ordering properties of PBFT-rotation\xspace are proved in
the same way as for PBFT-light\xspace (\S\ref{sec:pbft-safety}).
\section{PBFT Using an SMR Synchronizer}
\label{sec:pbft}
We now demonstrate how an SMR synchronizer can be used to implement Byzantine
SMR. More formally, we implement {\em Byzantine atomic
broadcast}~\cite{cachin-book}, from which SMR can be implemented in the
standard way~\cite{smr}. This %
allows processes to broadcast {\em values}, and we assume an
application-specific predicate to indicate whether a value is
valid~\cite{cachin-crypto01,vaba} (e.g., a block in a blockchain is invalid if
it lacks correct signatures).
We assume that all values broadcast by
correct processes in a single execution are valid and unique. Then Byzantine
atomic broadcast is defined by the following properties:
{\setlength{\leftmargini}{9pt}
\begin{itemize}
\item {\bf Integrity.} Every process delivers a value at most once.
\item {\bf External Validity.} A correct process delivers only values satisfying ${\sf valid}()$.
\item \textbf{Ordering.} If a correct process $p$ delivers $x_1$ before $x_2$,
then another correct process $q$ cannot deliver $x_2$ before $x_1$.
\item {\bf Liveness.} If a correct process broadcasts or delivers $x$, then
eventually all correct processes will deliver $x$. (Note that this implies
{\em censorship-resistance}: the service cannot selectively omit values
submitted by correct processes.)
\end{itemize}}
\paragraph{The PBFT-light\xspace protocol.}
We implement Byzantine atomic broadcast in a {\em PBFT-light\xspace} protocol
(Figures~\ref{fig:pbft-castro-normal}-\ref{fig:pbft-castro-preds}), which
faithfully captures the algorithmic core of the seminal Practical Byzantine
Fault Tolerance protocol (PBFT)~\cite{pbft}. Whereas PBFT integrated view
synchronization functionality with the core SMR protocol, PBFT-light\xspace delegates
this %
to an SMR synchronizer, and in \S\ref{sec:liveness} we rigorously prove its
liveness when using any synchronizer satisfying our specification. When using
the synchronizer in Figure~\ref{fig:sync}, the protocol also incurs only bounded
space overhead (see \tr{\ref{sec:pbft-space}}{C.4} for details).
We base PBFT-light\xspace on the PBFT protocol with signatures and, for simplicity, omit the
mechanisms for managing checkpoints and watermarks; these can be easily added
without affecting liveness. The protocol works in a succession of views
produced by the synchronizer. A process stores its current view in %
${\sf curr\_view}$. Each view $v$ has a fixed {\em leader}
${\sf leader}(v) = p_{((v-1)\ \mathrel{\rm mod}\ n) + 1}$ that is responsible for
totally ordering values submitted for broadcast; the other processes are {\em
followers}, which vote on proposals made by the leader. Processes store
the sequence of (unique) values proposed by the leader in a ${\sf log}$ array; at
the leader, a ${\sf next}$ counter points to the first free slot in the array.
Processes monitor the leader's behavior and ask the synchronizer to advance
to another view if they suspect that the leader is faulty. A ${\sf status}$ variable
records whether the process is operating as normal in the current view
($\textsc{normal}$) or is changing the view.
\begin{figure}[t]
\vspace{3pt}
\begin{tabular}{@{}l@{\!\!\!\!\!\!}|@{\ \ \ }l@{}}
\scalebox{0.96}{%
\begin{minipage}[t]{6.7cm}
\let\@latex@error\@gobble
\vspace*{-11pt}
\begin{algorithm*}[H]
\SetInd{\marginA}{\marginB}
\setcounter{AlgoLine}{0}
\SetInd{\marginA}{\marginB}
\SubAlgo{\Fun ${\tt start}()$}{\label{line:castro:start0}
\lIf{${\sf curr\_view} = 0$}{{\tt advance}()\label{line:castro:start}}
}
\smallskip
\SubAlgo{\textbf{when a timer expires}\label{alg:castro:expire-timerexecute}}{
${\tt stop\_all\_timers}()$\; \label{line:castro:stoptimers}
${\tt advance}()$\;
${\sf status} \leftarrow \textsc{advanced}$\;\label{line:castro:block}
${\sf dur\_delivery} \leftarrow {\sf dur\_delivery} + \tau$\; \label{line:castro:timer-inc1}
${\sf dur\_recovery} \leftarrow {\sf dur\_recovery} + \tau$\; \label{line:castro:timer-inc2}
}
\smallskip
\SubAlgo{\Fun ${\tt broadcast}(x)$\label{alg:castro:broadcast}}{
\textbf{pre:} ${\sf valid}(x)$\;
\Send $\langle {\tt BROADCAST}(x) \rangle_i$ \KwTo \ {\bf all}{}
{\bf periodically until $x$ is delivered}\label{alg:castro:send-to-all}
}
\smallskip
\SubAlgo{\WhenReceived ${\tt BROADCAST}(x)$\label{alg:castro:broadcast-msg}}{
\textbf{pre:} ${\sf valid}(x)\wedge {\sf status}=\textsc{normal} \wedge{}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }} {\sf timer\_delivery}[x]$ not active\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }} (\forall k.\, k \le {\sf last\_delivered} {\implies} {}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }(} {\sf commit\_log}[k]\not=x)$\;
$\ensuremath{{\tt start\_timer}}({\sf timer\_delivery}[x],$
${\sf dur\_delivery})$\label{alg:castro:start-timerexecute}\;
\Send $\langle {\tt FORWARD}(x) \rangle_i$ \KwTo
${\sf leader}({\sf curr\_view})$\;
}
\smallskip
\SubAlgo{\WhenReceived ${\tt FORWARD}(x)$\label{alg:castro:forward}}{
\textbf{pre:} ${\sf valid}(x) \wedge p_i = {\sf leader}({\sf curr\_view}) \wedge{}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }} {\sf status}=\textsc{normal} \wedge \forall k.\, {\sf log}[k]\not=x$\;
\Send $\langle {\tt PREPREPARE}({\sf curr\_view}, $ ${\sf next}, x) \rangle_i$
\KwTo \ {\bf all}\;
${\sf next} \leftarrow {\sf next} + 1$\;\label{alg:castro:increase-next}
}
\end{algorithm*}
\vspace*{-4pt}
\end{minipage}}
&
\scalebox{0.96}{%
\begin{minipage}[t]{10cm}
\let\@latex@error\@gobble
\vspace*{-11pt}
\begin{algorithm*}[H]
\SubAlgo{\WhenReceived $\langle {\tt PREPREPARE}(v, k, x) \rangle_{j}$\label{alg:castro:receive-propose}}{
\textbf{pre:} $p_j = {\sf leader}(v) \wedge {\sf curr\_view} = v \wedge {\sf status} =
\textsc{normal} \wedge {}$\label{alg:castro:safety-check}\\
\renewcommand{\nl}{\let\nl\oldnl}$\phantom{\text{{\bf pre:} }} {\sf phase}[k] =
\textsc{start} \wedge {\sf valid}(x) \wedge (\forall k'.\, {\sf log}[k']\not=x)$\\
$({\sf log}, {\sf phase})[k] \leftarrow (x, \textsc{preprepared})$\;
\Send $\langle {\tt PREPARE}(v, k, {\sf hash}(x)) \rangle_i$ \KwTo \ {\bf all}\;
}
\smallskip
\SubAlgo{\WhenReceived $\{\langle {\tt PREPARE}(v, k, h) \rangle_j \mid p_j
\in Q\} \,{=}\, C$ {\bf for a quorum $Q$}\label{alg:castro:receive-prepared}}{
\textbf{pre:} ${\sf curr\_view} = v \wedge {\sf phase}[k] = \textsc{preprepared} \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl}$\phantom{\text{{\bf pre:} }}{} {\sf status} = \textsc{normal} \wedge {\sf hash}({\sf log}[k]) = h$\;
$({\sf prep\_log}, {\sf prep\_view}, {\sf cert}, {\sf phase})[k] \leftarrow {}$\\
\renewcommand{\nl}{\let\nl\oldnl}$\quad ({\sf log}[k], {\sf curr\_view}, C, \textsc{prepared})$\label{alg:castro:assign-cballot}\;
\Send $\langle {\tt COMMIT}(v, k, h) \rangle_i$ \KwTo \ {\bf all}\;
}
\smallskip
\SubAlgo{\WhenReceived $\{\langle {\tt COMMIT}(v, k, h) \rangle_j \mid p_j
\in Q\} = C$ {\bf for a quorum $Q$}\label{alg:castro:receive-committed}}{
\textbf{pre:} ${\sf curr\_view} = v \wedge {\sf phase}[k] = \textsc{prepared} \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl}$\phantom{\text{{\bf pre:} }}{\sf status} = \textsc{normal} \wedge {\sf hash}({\sf prep\_log}[k]) = h$\;
$({\sf commit\_log},{\sf phase})[k] \leftarrow ({\sf log}[k], \textsc{committed})$\;
\Broadcast $\langle {\tt DECISION}({\sf commit\_log}[k], k, C)$\; \label{alg:castro:send-decision}
}
\smallskip
\SubAlgo{{\bf when} ${\sf commit\_log}[{\sf last\_delivered}+1] \not= \bot$\label{alg:castro:deliver}}{
${\sf last\_delivered} \leftarrow {\sf last\_delivered}+1$\; \label{alg:castro:update-last}
\If{${\sf commit\_log}[{\sf last\_delivered}] \not= {\tt nop}$}{${\tt
deliver}({\sf commit\_log}[{\sf last\_delivered}])$}\label{alg:castro:deliver-value}
$\ensuremath{{\tt stop\_timer}}({\sf timer\_delivery}[{\sf commit\_log}[{\sf last\_delivered}]])$\;\label{alg:castro:stop-timerexecute2}
\If{${\sf last\_delivered} = {\sf init\_log\_length}\wedge {\sf status}={\normalfont \textsc{normal}}$}{
$\ensuremath{{\tt stop\_timer}}({\sf timer\_recovery})$\;\label{alg:castro:stop-timerrecovery}
}
}
\SubAlgo{\WhenReceived ${\tt DECISION}(x, k, C)$ \label{alg:castro:receive-decision}}{
\textbf{pre:} ${\sf commit\_log}[k] \not= \bot \wedge \exists v.\, \ensuremath{{\sf committed}}(C, v, k,
{\sf hash}(x))$\; \label{alg:castro:decision-safetycheck}
${\sf commit\_log}[k] \leftarrow x$\;
}
\end{algorithm*}
\vspace*{-4pt}
\end{minipage}}
\end{tabular}
\vspace*{-4pt}
\caption{Normal operation of PBFT-light\xspace at a process $p_i$.}
\label{fig:pbft-castro-normal}
\end{figure}
\paragraph{Normal protocol operation.}
A process broadcasts a valid value $x$ using a ${\tt broadcast}$ function
(line~\ref{alg:castro:broadcast}), which keeps sending the value to all
processes in a ${\tt BROADCAST}$ message until the process delivers the value. The
periodic retransmission ensures that the value will reach the processes despite
message loss before ${\sf GST}$. When a process receives a ${\tt BROADCAST}$ message with
a new value (line~\ref{alg:castro:broadcast-msg}), it forwards the value to the
leader in a ${\tt FORWARD}$ message. This ensures that the value reaches the leader
even when broadcast by a faulty process, which may withhold the ${\tt BROADCAST}$
message from the leader. (We explain the timer set in
line~\ref{alg:castro:start-timerexecute} later.)
When the leader receives a new value $x$ in a ${\tt FORWARD}$ message
(line~\ref{alg:castro:forward}), it sends a ${\tt PREPREPARE}$ message to all
processes (including itself) that includes $x$ and its position in the log,
generated from the ${\sf next}$ counter.
Processes vote on the leader's proposal in two phases. Each process keeps track
of the status of values going through the vote in an array ${\sf phase}$, whose
entries initially store $\textsc{start}$.
When a process receives a proposal $x$ for a position $k$ from the leader of
its view $v$ (line~\ref{alg:castro:receive-propose}), it first checks that ${\sf phase}[k]$
is $\textsc{start}$, so that it has not yet accepted a proposal for the position $k$ in
the current view. It also checks that the value is valid and distinct from all
values it knows about.
The process then stores $x$ in ${\sf log}[k]$ and advances ${\sf phase}[k]$ to
$\textsc{preprepared}$. Since a faulty leader may send different proposals for the same
position to different processes, the process next communicates with others to
check that they received the same proposal. To this end, it disseminates a
${\tt PREPARE}$ message with the position and the hash of the value $x$ it
received. The process handles $x$ further once it gathers a set $C$ of
${\tt PREPARE}$ messages from a quorum matching the value
(line~\ref{alg:castro:receive-prepared}), which we call a {\em prepared
certificate} and check using the ${\sf prepared}$ predicate in
Figure~\ref{fig:pbft-castro-preds}.
In this case the process stores the value in ${\sf prep\_log}[k]$, the certificate in
${\sf cert}[k]$, and the view in which it was formed in ${\sf prep\_view}[k]$. At this point
we say that the process {\em prepared} the proposal, which is recorded by
setting its ${\sf phase}$ to $\textsc{prepared}$. It is easy to show that processes
cannot prepare
different values at the same position and view, since
each correct process can send only one corresponding ${\tt PREPARE}$ message.
Having prepared a value, the process
disseminates a ${\tt COMMIT}$ message with the hash of the value. Once the process
gathers a quorum of matching ${\tt COMMIT}$ messages
(line~\ref{alg:castro:receive-committed}), it stores the value in a ${\sf commit\_log}$
array and advances its ${\sf phase}$ to $\textsc{committed}$; we then say that the value is
{\em committed}. The protocol ensures that correct processes cannot commit
different values at the same position, even in different views. We call a quorum
of matching ${\tt COMMIT}$ messages a {\em commit certificate} and check it using the
$\ensuremath{{\sf committed}}$ predicate in Figure~\ref{fig:pbft-castro-preds}. A process delivers
committed values
in the ${\sf commit\_log}$ order, with ${\sf last\_delivered}$ tracking the position of the last
delivered value.
To satisfy the Liveness property of atomic broadcast, similarly
to~\cite{alysson-reads}, PBFT-light\xspace allows a process to find out about committed
values from other processes directly. When a correct process commits a value
(line~\ref{alg:castro:receive-committed}), it disseminates a ${\tt DECISION}$ message
with the value, its position $k$ in the log and the commit certificate
(line~\ref{alg:castro:send-decision}). A process receiving such a message with a
valid certificate saves the value in ${\sf commit\_log}[k]$, which allows it to be
delivered (line~\ref{alg:castro:deliver}).
The ${\tt DECISION}$ messages are disseminated via a form of reliable broadcast
ensuring that, if a correct process delivers the value, then so do all other
correct processes. To implement this, each process could periodically resend the
${\tt DECISION}$ messages it has (omitted from the pseudocode). A more practical
implementation would only resend information that other processes are
missing. %
As proved in~\cite{dls}, such periodic resends are unavoidable in the presence
of message loss.
\paragraph{View initialization.}
When the synchronizer tells a process to move to a new view $v$
(line~\ref{alg:castro:newview}), the process sets ${\sf curr\_view}$ to $v$, which
ensures that it will no longer accept messages from prior views. It also sets
${\sf status}$ to $\textsc{initializing}$, which means that the process is not yet ready to
order values in the new view. It then sends a ${\tt NEW\_LEADER}$ message to the leader
of $v$ with the information about the values it has prepared so far and the
corresponding certificates.\footnote{In PBFT this information is sent in {\tt
VIEW-CHANGE} messages, which also play a role similar to ${\tt WISH}$ messages in
our synchronizer (Figure~\ref{fig:sync}). In PBFT-light\xspace we opted to eschew {\tt
VIEW-CHANGE} messages to maintain a clear separation between view
synchronization internals and the SMR protocol.}
\begin{figure}[t]
\vspace{2pt}
\begin{tabular}{@{}l@{\!\!\!\!\!\!\!}|@{\quad}l@{}}
\scalebox{0.96}{%
\begin{minipage}[t]{7.7cm}
\let\@latex@error\@gobble
\vspace*{-10pt}
\begin{algorithm*}[H]
\setcounter{AlgoLine}{52}
\SetInd{\marginA}{\marginB}
\SubAlgo{\Upon ${\tt new\_view}(v)$\label{alg:castro:newview}}{
${\tt stop\_all\_timers}()$\; \label{line:castro:stoptimers-enterview}
${\sf curr\_view} \leftarrow v$\;\label{line:castro:set-currentview}
${\sf status} \leftarrow \textsc{initializing}$\;
\Send $\langle {\tt NEW\_LEADER}({\sf curr\_view}, {\sf prep\_view}, $ ${\sf prep\_log}, {\sf cert}) \rangle_i$
\KwTo ${\sf leader}({\sf curr\_view})$\;
$\ensuremath{{\tt start\_timer}}({\sf timer\_recovery},$ ${\sf dur\_recovery})$\;\label{line:castro:start-timerrecovery}
}
\smallskip
\SubAlgo{\WhenReceived $\{\langle {\tt NEW\_LEADER}(v, \mathit{prep\_view}_j,$ $\mathit{prep\_log}_j,
\mathit{cert}_j) \rangle_j \mid$ $p_j \in Q\} = M$ {\bf for a quorum
$Q$}\label{alg:castro:receive-newleader}}{
\textbf{pre:} $p_i = {\sf leader}(v) \wedge {\sf curr\_view} = v \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }} {\sf status} = \textsc{initializing} \wedge{}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }} \forall m \in M.\, {\sf ValidNewLeader}(m)$\;
\ForAll{$k$\label{alg:castro:select-proposal}}{
\lIf{$\exists p_{j'} \in Q.\, \mathit{prep\_view}_{j'}[k] \not= 0 \wedge{}$ $\forall p_{j} \in Q.\,
\mathit{prep\_view}_{j}[k] \le \mathit{prep\_view}_{j'}[k]$}{%
$\mathit{log}'[k] \leftarrow \mathit{prep\_log}_{j'}[k]$\label{alg:castro:prepared-entries}}
}
${\sf next} \leftarrow \max\{k \mid \mathit{log}'[k]\neq \bot\}$\;\label{alg:castro:set-next}
}
\end{algorithm*}
\vspace*{-5pt}
\begin{tikzpicture}[overlay]
\node[draw=none, fill=white, thick,minimum width=.5cm,minimum height=.2cm] (b) at (.743,0){};%
\end{tikzpicture}
\end{minipage}}
&
\scalebox{0.96}{%
\begin{minipage}[t]{8.6cm}
\let\@latex@error\@gobble
\vspace*{-20pt}
\begin{algorithm*}[H]
\renewcommand{\nl}{\let\nl\oldnl}\SubAlgo{}{
\ForAll{$k = 1..({\sf next}-1)$\label{alg:castro:clean-entries}}{
\lIf{$\mathit{log}'[k] = \bot \vee \exists k'.\, k' \not= k \wedge \mathit{log}'[k'] = \mathit{log}'[k] \wedge {} $
$\exists p_{j'} \in Q.\, \forall p_{j} \in
Q.\, \mathit{prep\_view}_{j'}[k'] > \mathit{prep\_view}_{j}[k]$}{%
$\mathit{log}'[k] \leftarrow {\tt nop}$\label{alg:castro:newview-end}%
}
}
\Send $\langle {\tt NEW\_STATE}(v, \mathit{log}', M) \rangle_i$ \KwTo \ {\bf all}\; \label{alg:castro:send-newview}
}
\smallskip
\SubAlgo{\WhenReceived $\langle {\tt NEW\_STATE}(v, \mathit{log}', M) \rangle_j = m$\label{alg:castro:receive-newview}}{
\textbf{pre:} ${\sf status} = \textsc{initializing} \wedge {\sf curr\_view} = v \wedge {}$\\
\renewcommand{\nl}{\let\nl\oldnl} $\phantom{\text{{\bf pre:} }} {\sf ValidNewState}(m)$\;
${\sf log} \leftarrow \mathit{log}'$\;
\ForAll{$\{k \mid {\sf log}[k] \not= \bot\}$}{\label{alg:castro:forallnewview}
${\sf phase}[k] \leftarrow \textsc{preprepared}$\;
\Send $\langle {\tt PREPARE}(v, k, {\sf hash}({\sf log}[k])) \rangle_i$ \KwTo\label{alg:castro:preparenewview}
\ {\bf all}\;
}
${\sf status} \leftarrow \textsc{normal}$\; \label{alg:castro:status-normal}
${\sf init\_log\_length} \leftarrow \max\{k \mid {\sf log}[k]\neq
\bot\}$\;\label{alg:castro:set-krecovery}
\If{${\sf init\_log\_length}\leq{\sf last\_delivered}$}
{$\ensuremath{{\tt stop\_timer}}({\sf timer\_recovery})$\;\label{alg:castro:stop-timerrecovery2}}
}
\end{algorithm*}
\vspace*{-5pt}
\end{minipage}}
\end{tabular}
\vspace{-3pt}
\caption{View-initialization protocol of PBFT-light\xspace at a process $p_i$.}
\label{fig:pbft-castro-recovery}
\end{figure}
\begin{figure}[t]
\scalebox{0.97}{
\begin{minipage}{15cm}
\begin{gather*}
{\sf prepared}(C, v, k, h)
\iff
\exists Q.\,
{\sf quorum}(Q) \wedge C = \{\langle {\tt PREPARE}(v, k, h) \rangle_j \mid p_j \in Q\}
\\
\ensuremath{{\sf committed}}(C, v, k, h)
\iff
\exists Q.\,
{\sf quorum}(Q) \wedge C = \{\langle {\tt COMMIT}(v, k, h) \rangle_j \mid p_j \in Q\}
\\
\begin{array}{@{}l@{}}
{\sf ValidNewLeader}(\langle {\tt NEW\_LEADER}(v, \mathit{prep\_view}, \mathit{prep\_log}, \mathit{cert}) \rangle_{\_}) \iff {}
\\[2pt]
\forall k.\, (\mathit{prep\_view}[k] > 0 {\implies}
\mathit{prep\_view}[k] < v \wedge
{\sf prepared}(\mathit{cert}[k], \mathit{prep\_view}[k], k, \mathit{prep\_log}[k]))
\end{array}
\\
\begin{array}{@{}l@{}}
{\sf ValidNewState}(\langle {\tt NEW\_STATE}(v, \mathit{log}', M) \rangle_i) \iff
p_i = {\sf leader}(v) \wedge
\exists Q, \mathit{prep\_view}, \mathit{prep\_log}, \mathit{cert}.\, {\sf quorum}(Q) \wedge {}
\\[2pt]
M = \{\langle {\tt NEW\_LEADER}(v, \mathit{prep\_view}_j, \mathit{log}_j, \mathit{cert}_j)
\rangle_j \mid p_j \in Q\} \wedge {}
\\[2pt]
(\forall m \in C.\, {\sf ValidNewLeader}(m)) \wedge
(\mathit{log}' \mbox{ is computed from $M$ as
per lines~\ref{alg:castro:select-proposal}-\ref{alg:castro:newview-end}})
\end{array}
\end{gather*}
\end{minipage}}
\vspace*{-3pt}
\caption{Auxiliary predicates for PBFT-light\xspace.}
\label{fig:pbft-castro-preds}
\end{figure}
The new leader waits until it receives a quorum of well-formed ${\tt NEW\_LEADER}$
messages, as checked by the predicate ${\sf ValidNewLeader}$
(line~\ref{alg:castro:receive-newleader}). Based on these, the leader computes
the initial log of the new view, stored in $\mathit{log}'$. Similarly to
Paxos~\cite{paxos}, for each index $k$ the leader puts at the $k$th position in
$\mathit{log}'$ the value prepared in the highest view
(line~\ref{alg:castro:select-proposal}).
The resulting array may contain empty or duplicate entries. To resolve this, the
leader writes ${\tt nop}$ into empty entries and those entries for which there is a
duplicate prepared in a higher view (line~\ref{alg:castro:clean-entries}). The
latter is safe because one can show that no value could have been committed in
such entries in prior views. Finally, the leader sends a ${\tt NEW\_STATE}$ message to
all processes, containing the initial log and the ${\tt NEW\_LEADER}$ messages from
which it was computed (line~\ref{alg:castro:send-newview}).
A process receiving the ${\tt NEW\_STATE}$ message first checks its
correctness by redoing the leader's computation, as specified by the
${\sf ValidNewState}$ predicate (line~\ref{alg:castro:receive-newview}). If the check
passes, the process overwrites its log with the new one and sets ${\sf status}$ to
$\textsc{normal}$.
It also sends ${\tt PREPARE}$ messages for all ${\sf log}$ entries,
to commit them in the new view. A more practical version of the protocol would
include a checkpointing mechanism, so that a process restarts committing
previous ${\sf log}$ entries only from the last stable checkpoint~\cite{pbft}; this
mechanism can be easily added to PBFT-light\xspace.
\paragraph{Triggering view changes.}
We now describe when a process calls ${\tt advance}$,
which is key to ensure liveness (\S\ref{sec:liveness}). This happens either on
start-up (line~\ref{line:castro:start}) or when the process suspects that the
current leader is faulty. To this end, the process monitors the leader's
behavior using timers; if one of these expires, the process calls ${\tt advance}$
and sets ${\sf status}$ to $\textsc{advanced}$
(line~\ref{alg:castro:expire-timerexecute}). First, the process checks that each
value it receives is delivered promptly: e.g., to guard against a faulty leader
not making any proposals or censoring certain values.
For a value $x$ this is done using ${\sf timer\_delivery}[x]$, set for a
duration ${\sf dur\_delivery}$ when the process receives ${\tt BROADCAST}(x)$
(lines~\ref{alg:castro:start-timerexecute}). The timer is stopped when the
process delivers $x$ (line~\ref{alg:castro:stop-timerexecute2}).
A process also checks that the leader initializes a view quickly enough:
e.g., to guard against the leader crashing during the initialization.
Thus, when a process enters a view it starts ${\sf timer\_recovery}$ for a
duration ${\sf dur\_recovery}$ (line~\ref{line:castro:start-timerrecovery}).
The process stops the timer when it
delivers all values in the initial log
(lines~\ref{alg:castro:stop-timerrecovery}
and~\ref{alg:castro:stop-timerrecovery2}).
The above checks may make a process suspect a correct leader if the timeouts are
initially set too small with respect to the message delay $\delta$, unknown to
the process. To deal with this, a process increases ${\sf dur\_delivery}$ and
${\sf dur\_recovery}$ each time a timer expires, which signals that the current
view is not operating normally
(lines~\ref{line:castro:timer-inc1}-\ref{line:castro:timer-inc2}). This way of
adapting timeouts is used in the original PBFT~\cite[\S{}2.3.5]{castro-thesis},
and as we show \S\ref{sec:xbft}, also benefits other protocols.
\section{Correctness and Performance of the Synchronizer Algorithm}
\label{sec:proof-sync}
\subsection{Proof of the Synchronizer Correctness}
The {\em local view}\/ of a process $p_i$ at time $t$, denoted $\LV{i}{t}$, is
the latest view entered by $p_i$ at or before $t$, or $0$ if $p_i$ has not
entered any views by then.
\begin{lemma}
For all $t$ and $v\ge 0$, if a correct process sends
${\tt WISH}(v+1)$ at $t$, then there exists a time $t' \le t$
such that some correct process attempts to advance from $v$ at $t'$.
\label{lem:wish-attempt}
\end{lemma}
{\em Proof.}
We first prove the following auxiliary proposition:
\begin{multline}
\forall p_i.\, \forall v.\,
p_i \text{~is~correct} \wedge p_i \text{~sends~} {\tt WISH}(v+1)
\text{~at~} t \implies\\
\exists t' \le t.\, \exists v' \ge v.\, \exists p_j.\,
p_j \text{~is~correct} \wedge p_j
\text{~attempts~to~advance~from~} v' \text{~at~} t'.
\label{eq:attempt-gtv}
\end{multline}
By contradiction, assume that a correct process $p_i$ sends ${\tt WISH}(v+1)$ at $t$,
but for all $t' \le t$ and all $v' \ge v$, no correct process attempts to
advance from $v'$ at $t'$. Consider the earliest time $t_k$ when some correct
process $p_k$ sends a ${\tt WISH}(v_k)$ with $v_k \ge v+1$, so that $t_k \le t$.
Since $p_k$ sends ${\tt WISH}(v_k)$ at $t_k$, either
$v_k = p_k.{\sf view}^+(t_k)$ or $p_k.{\sf view}(t_k) = p_k.{\sf view}^+(t_k) = v_k - 1$, and in
the latter case $p_k$ executes either line~\ref{line:send2} or line~\ref{line:send4}.
If $p_k.{\sf view}^+(t_k) = v_k \ge v+1$, then $p_k.{\sf max\_views}(t_k)$ includes $f+1$ entries
$\ge v_k \ge v+1$, and therefore, there exists a correct process $p_l$ that
sent ${\tt WISH}(v')$ with $v' \ge v+1$ at $t_l < t_k$, contradicting the
assumption that $t_k$ is the earliest time when this can happen.
Suppose that $p_k.{\sf view}(t_k) = p_k.{\sf view}^+(t_k) = v_k - 1$ and
at $t_k$, $p_k$ executes either line~\ref{line:send2}
or line~\ref{line:send4}. Then $\LV{k}{t_k} = v_k - 1$.
If $p_k$ executes line~\ref{line:send2} at $t_k$, then since $\LV{k}{t_k} = v_k - 1$,
$p_k$ attempts to advance from $v_k-1 \ge v$ at $t_k\le t$, contradicting our
assumption that no such attempt can occur. Suppose now that $p_k$ executes the code in
line~\ref{line:send4} at $t_k$. If $v_k > 1$, then
since $p_k.{\sf view}(t_k) = p_k.{\sf view}^+(t_k) = v_k - 1$, we know that
$\te{k}{v_k-1}$ is defined and satisfies $\te{k}{v_k-1} < t_k$.
Let $t'_k = \te{k}{v_k-1}$ if $v_k > 1$, and $t'_k = 0$ otherwise.
Then $p_k.{\sf view}(t'_k) = p_k.{\sf view}^+(t'_k) = v_k - 1$ and
$p_k.{\sf advanced}(t'_k) = \text{\sc false}$.
Since $p_k.{\sf advanced}(t_k) = \text{\sc true}$, there exists a time
$t''_k$ such that $t'_k < t''_k \le t_k$ and $p_k$ calls ${\tt advance}()$ at $t''_k$.
Since both $p_k.{\sf view}$ and $p_k.{\sf view}^+$ are non-decreasing,
and both are equal to $v_k - 1$ at
$t''_k$ as well as $t_k$, $p_k.{\sf view}(t''_k) = p_k.{\sf view}^+(t''_k) = v_k -
1$. Thus, $\LV{k}{t''_k} = v_k-1$, which implies that at $t''_k < t_k \le t$,
$p_k$ attempts to advance from $v_k-1 \ge v$,
contradicting our assumption that no such attempt can happen.
Thus,~(\ref{eq:attempt-gtv}) holds.
We now prove the lemma. Let $t$ and $v$ be such that
some correct process sends ${\tt WISH}(v+1)$ at $t$.
By~(\ref{eq:attempt-gtv}), there exists a correct process
that attempts to advance from a view $\ge v$ at or before $t$.
Let $t'$ be the earliest time when some correct process attempts to advance from
a view $\ge v$, and let $p_j$ be this process and $v' \ge v$ be the view
from which $p_j$ attempts to advance at $t'$.
Thus, at $t'$, $p_j$ executes the code in line~\ref{line:send2}
and $\LV{j}{t'} = v' \ge v$.
Hence, there exists an earlier time at which
$p_j.{\sf view}^+ = p_j.{\sf view} = v'$. Since $p_j.{\sf view}^+$ is non-decreasing,
$p_j.{\sf view}^+(t') \ge v'$. If $p_j.{\sf view}^+(t') > v'$, then given that
$v' \ge v$, $p_j.{\sf view}^+(t') \ge v+1$. Thus, there exists a correct
process $p_k$ and time $t'' < t'$ such that $p_k$ sent
${\tt WISH}(v'')$ with $v'' \ge v+1$ to $p_j$ at $t''$. By~(\ref{eq:attempt-gtv}),
there exists a time $\le t'' < t'$ at which some correct process
attempts to advance from a view $\ge v''-1 \ge v$, which is impossible.
Thus, $p_j.{\sf view}^+(t') = v'$. Since $\LV{j}{t'} = v'$, we have
$p_j.{\sf view}(t') = p_j.{\sf view}^+(t') = v' \ge v$.
By the definitions of ${\sf view}$ and ${\sf view}^+$,
$v'$ is both the lowest view among the highest $2f+1$ views
in $p_j.{\sf max\_views}(t')$, and the lowest view among the highest
$f+1$ views in $p_j.{\sf max\_views}(t')$.
Hence, $p_j.{\sf max\_views}(t')$ includes $f+1$ entries equal to $v'$, and
therefore, there exists a correct process $p_k$ such that
\begin{equation}\label{entry-eq-v-1}
p_j.{\sf view}(t') = p_j.{\sf view}^+(t') = p_j.{\sf max\_views}[k](t') = v'
\ge v-1.
\end{equation}
Also, for all correct processes $p_l$, $p_j.{\sf max\_views}[l](t') < v+1$:
otherwise, some correct process sent ${\tt WISH}(v'')$ with $v'' \ge v+1$
at $t'' < t'$, and therefore, by~(\ref{eq:attempt-gtv}),
some correct process attempted to advance from a view $\ge v$ earlier
than $t'$, which is impossible. Thus,
$$
p_j.{\sf view}(t') = p_j.{\sf view}^+(t') = p_j.{\sf max\_views}[k](t') < v+1.
$$
Together with~(\ref{entry-eq-v-1}), this implies
$$
p_j.{\sf view}(t') = p_j.{\sf view}^+(t') = v.
$$
Hence, $\LV{j}{t'} = v$, and therefore, $p_j$ attempts to advance from $v$ at $t'$. Thus,
$v' = v$ and $t' \le t$, as required.\qed
\begin{lemma}
\label{lemma:enter-attempt}
Validity\xspace holds:
$\forall i, v.\, {\te{i}{v+1}\mathpunct{\downarrow}} {\implies} {\tam{v}\mathpunct{\downarrow}} \wedge \tam{v} < \te{i}{v+1}$.
\end{lemma}
{\em Proof.}
Since $p_i$ enters a view $v+1$, we have
$p_i.{\sf view}(\te{i}{v+1}) = p_i.{\sf view}^+(\te{i}{v+1})=v+1$. By the definitions of ${\sf view}$
and ${\sf view}^+$, $v+1$ is both the lowest view among the highest $2f+1$ views in
$p_i.{\sf max\_views}(\te{i}{v+1})$, and the lowest view among the highest $f+1$ views
in $p_i.{\sf max\_views}(\te{i}{v+1})$. Hence, $p_i.{\sf max\_views}(\te{i}{v+1})$ includes
$f+1$ entries equal to $v+1$. Then there exists a time $t' < \te{i}{v+1}$ at which
some correct process sends ${\tt WISH}(v+1)$. Hence, by Lemma~\ref{lem:wish-attempt},
there exists a time $t \le t' < \te{i}{v+1}$ at which some correct process
attempts to advance from $v$.\qed
\begin{lemma}
For all times $t$ and views $v>0$, if a correct process sends
${\tt WISH}(v)$ at $t$, then there exists a time $t' \le t$
such that some correct process attempts to advance from view $0$ at $t'$.
\label{lem:wish-start}
\end{lemma}
{\em Proof.}
Consider the earliest time $t_k \le t$ at which some
correct process $p_k$ sends ${\tt WISH}(v_k)$ for some view $v_k$.
By Lemma~\ref{lem:wish-attempt}, there exists a time $t_j \le t_k$
at which some correct process attempts to advance from
$v_k-1 \ge 0$, and therefore, sends ${\tt WISH}(v_k)$ at $t_j$.
Since $t_k$ is the earliest time when this could happen,
we have $t_j = t_k$. Also, if $v_k - 1 > 0$,
then $\te{k}{v_k-1}$ is defined, and hence,
by Lemma~\ref{lemma:enter-attempt}, some correct
process attempts to advance from $v_k - 2$ by
sending ${\tt WISH}(v_k - 1)$ earlier than $t_j = t_k$, which
cannot happen. Thus, $v_k = 1$ and at $t_k$, $p_k$ attempts to advance from $0$,
as required.\qed
\begin{proposition}
Let $p_i$ be a correct process. Then:
\begin{enumerate}
\item \label{prop:inv:4}
$\forall v.\forall t.\, p_i \text{~sends~} {\tt WISH}(v) \text{~at~} t {\implies}
v \in \{p_i.{\sf view}^+(t), p_i.{\sf view}^+(t)+1\}$.
\item \label{prop:inv:41}
$\forall v.\forall t.\, p_i \text{~sends~} {\tt WISH}(v) \text{~at~} t \wedge
v = p_i.{\sf view}^+(t)+1 {\implies} p_i.{\sf view}^+(t)=p_i.{\sf view}(t) \wedge p_i.{\sf advanced}(t) = \text{\sc true}$.
\end{enumerate}
\label{prop:inv}
\end{proposition}
\begin{lemma}
For all views $v, v' > 0$, if a correct process sends ${\tt WISH}(v)$ before
sending ${\tt WISH}(v')$, then $v \le v'$.
\label{lem:wish-grow}
\end{lemma}
{\em Proof.}
Let $s$ and $s'$ such that $s < s'$ be the times at which a correct process
$p_i$ sends ${\tt WISH}(v)$ and ${\tt WISH}(v')$ messages, respectively. We show that
$v' \ge v$. By Proposition~\ref{prop:inv}(\ref{prop:inv:4}),
$v \in \{p_i.{\sf view}^+(s), p_i.{\sf view}^+(s)+1\}$ and
$v' \in \{p_i.{\sf view}^+(s'), p_i.{\sf view}^+(s')+1\}$. Hence, if $v = p_i.{\sf view}^+(s)$ or
$v' = p_i.{\sf view}^+(s')+1$, then we get $v \le v'$ from the fact that $p_i.{\sf view}^+$
is non-decreasing. It thus remains to consider the case when
$v = p_i.{\sf view}^+(s)+1$ and $v' = p_i.{\sf view}^+(s')$. In this case by
Proposition~\ref{prop:inv}(\ref{prop:inv:41}), $p_i.{\sf view}^+(s)=p_i.{\sf view}(s)$ and
$p_i.{\sf advanced}(s) = \text{\sc true}$. We now consider several cases depending on the
line at which ${\tt WISH}(v')$ is sent.
\begin{itemize}
\item ${\tt WISH}(v')$ is sent at lines~\ref{line:send2} or~\ref{line:send4}. Then
$v'=p_i.{\sf view}^+(s')=\max(p_i.{\sf view}(s')+1, p_i.{\sf view}^+(s'))$. Since
$p_i.{\sf view}$ is non-decreasing, we get
$p_i.{\sf view}^+(s') \ge p_i.{\sf view}(s')+1 > p_i.{\sf view}(s') \ge p_i.{\sf view}(s) =
p_i.{\sf view}^+(s)$. Hence, $p_i.{\sf view}^+(s') > p_i.{\sf view}^+(s)$, and therefore,
$v'=p_i.{\sf view}^+(s') \ge p_i.{\sf view}^+(s)+1=v$, as required.
\item ${\tt WISH}(v')$ is sent at line~\ref{line:send3}. Then
$p_i.{\sf advanced}(s') = \text{\sc false}$. Since $p_i.{\sf advanced}(s) = \text{\sc true}$, there exists a
time $s''$ such that $s < s'' < s'$ and $p_i$ enters a view at $s''$. By the
view entry condition $p_i.{\sf view}(s'') > p_i.\textit{prev\_v}(s'')$.
Since $p_i.{\sf view}$ is non-decreasing, we get
$p_i.{\sf view}^+(s') \ge p_i.{\sf view}(s') \ge p_i.{\sf view}(s'') > p_i.{\sf view}(s) =
p_i.{\sf view}^+(s)$. Thus, $p_i.{\sf view}^+(s') > p_i.{\sf view}^+(s)$ and therefore,
$v' = p_i.{\sf view}^+(s') \ge p_i.{\sf view}^+(s)+1 = v$, as required.
\item ${\tt WISH}(v')$ is sent at line~\ref{line:send5}. Then
$p_i.{\sf view}^+(s') > p_i.\textit{prev\_v}^+(s') \ge p_i.{\sf view}^+(s)$, and therefore,
$v' = p_i.{\sf view}^+(s') \ge p_i.{\sf view}^+(s) + 1 = v$, as required.
\end{itemize}
\qed
\bigskip
In order to cope with message loss before ${\sf GST}$, every correct process
retransmits the highest ${\tt WISH}$ it sent every $\rho$ units of time, according to
its local clock (lines~\ref{line:retransmit-start}-\ref{line:send3}).
Eventually, one of these retransmissions will occur after ${\sf GST}$, and therefore,
there exists a time by which all correct processes are guaranteed to send their
highest ${\tt WISH}$es at least once after ${\sf GST}$. The earliest such time, $\ensuremath{\overline{{\sf GST}}}$,
is defined as follows:
\begin{equation*}
\ensuremath{\overline{{\sf GST}}} =
\begin{cases}
{\sf GST} + \rho,& \text{if } \tam{0} < {\sf GST};\\
\tam{0},& \text{otherwise}.
\end{cases}
\label{eq:gstp-def}
\end{equation*}
From this definition it follows that
\begin{equation}
\ensuremath{\overline{{\sf GST}}} \ge {\sf GST}.
\label{eq:gstp-gst}
\end{equation}
Lemma~\ref{lem:postgst} below formalizes the key property of $\ensuremath{\overline{{\sf GST}}}$.
\begin{lemma}
For all correct processes $p_i$, times $t \ge \ensuremath{\overline{{\sf GST}}}$, and views $v$,
if $p_i$ sends ${\tt WISH}(v)$ at a time $\le t$, then there exists a view $v' \ge v$
and a time $t'$ such that ${\sf GST} \le t' \le t$ and $p_i$ sends ${\tt WISH}(v')$ at $t'$.
\label{lem:postgst}
\end{lemma}
{\em Proof.}
Let $s \le t$ be the time at which $p_i$ sends ${\tt WISH}(v)$. We consider two
cases. Suppose first that $\tam{0} \ge {\sf GST}$. By Lemma~\ref{lem:wish-start}, $s
\ge \tam{0}$, and therefore, ${\sf GST} \le s \le t$. Thus, choosing $t'=s$ and $v' =
v$ validates the lemma.
Suppose next that $\tam{0} < {\sf GST}$. Then by the definition of $\ensuremath{\overline{{\sf GST}}}$, $t \ge {\sf GST} + \rho$.
If $s \ge {\sf GST}$, then ${\sf GST} \le s \le t$, and therefore,
choosing $t'=s$ and $v' = v$ validates the lemma. Assume now that $s < {\sf GST}$.
Since after ${\sf GST}$ the $p_i$'s local clock advances at the same rate as real time,
there exists a time $s'$ satisfying ${\sf GST} \le s' \le t$ such that
$p_i$ executes the periodic retransmission code
in lines~\ref{line:retransmit-start}-\ref{line:send3}
at $s'$. We now show that
\begin{equation}
p_i.{\sf advanced}(s') \vee p_i.{\sf view}^+(s') > 0.
\label{eq:retr-wish}
\end{equation}
Since $p_i$ already sent a ${\tt WISH}$ message at $s < {\sf GST} \le s'$,
by the structure of the code,
\begin{equation*}
p_i.{\sf advanced}(s) \vee p_i.{\sf view}^+(s) > 0.
\end{equation*}
If $p_i.{\sf view}^+(s) > 0$, then since $p_i.{\sf view}^+$ is non-decreasing,
$p_i.{\sf view}^+(s') > 0$, and therefore,~(\ref{eq:retr-wish}) holds.
Assume now that $p_i.{\sf advanced}(s)$. If $p_i.{\sf advanced}(s')$,
then~(\ref{eq:retr-wish}) holds too. We therefore consider the case when
$\neg p_i.{\sf advanced}(s')$. Then there exists a time $s \le s'' \le s'$
at which $p_i$ enters the view $p_i.{\sf view}(s'')>0$.
Hence, $p_i.{\sf view}^+(s') \ge p_i.{\sf view}^+(s'') \ge p_i.{\sf view}(s'') > 0$,
validating~(\ref{eq:retr-wish}).
Thus,~(\ref{eq:retr-wish}) holds in all cases.
Therefore, at $s'$ the process $p_i$ sends ${\tt WISH}(v')$ for
some view $v'$. By Lemma~\ref{lem:wish-grow}, $v' \ge v$,
and above we established ${\sf GST} \le s' \le t$, as required.\qed
\smallskip
\smallskip
\begin{lemma}
Consider a view $v>0$ and assume that $v$ is entered by a correct process.
If $\tm{v} \ge \ensuremath{\overline{{\sf GST}}}$, and
no correct process attempts to advance from $v$
before
$\tm{v} + 2\delta$, then all correct processes enter $v$ and
$\tl{v} \le \tm{v} + 2\delta$.
\label{lem:GST-bound2}
\end{lemma}
{\em Proof.}
If some correct process attempts to advance from a view $v' > v$
before $\tm{v} + 2\delta$, then
by Proposition~\ref{sync:noskip}, some correct process must also enter the view
$v+1$. By Lemma~\ref{lemma:enter-attempt}, this implies that some
correct process attempts to advance from $v$ before $\tm{v} + 2\delta$,
contradicting the lemma's premise. Thus, no correct process attempts
to advance from any view $v' \ge v$
before $\tm{v} + 2\delta$, and therefore,
by Lemma~\ref{lem:wish-attempt},
no correct process can send ${\tt WISH}(v')$ with $v' > v$ earlier
than $\tm{v} + 2\delta$. Once any such ${\tt WISH}(v')$ is sent, it will take a non-zero time until
it is received by any correct process. Thus, we have:
\smallskip
\smallskip
{\setlength{\leftmargini}{22pt}
\begin{enumerate}
\item[(*)] no correct process receives ${\tt WISH}(v')$ with $v' > v$
from a correct process until after $\tm{v} + 2\delta$. \label{lem:GST-bound2-generic:3}
\end{enumerate}}
\smallskip
\smallskip
Let $p_i$ be a correct process that enters $v$ at $\tm{v}$.
By the view entry condition,
$p_i.{\sf view}(\tm{v}) = v$, and therefore
$p_i.{\sf max\_views}(\tm{v})$ includes $2f+1$ entries $\ge v$.
At least $f+1$ of these entries belong to correct processes,
and by~(*),
none of them can be $> v$.
Hence, there exists a set $C$ of $f+1$ correct processes, each of which sends
${\tt WISH}(v)$ to all processes before $\tm{v}$.
Since $\tm{v} \ge \ensuremath{\overline{{\sf GST}}}$, by Lemma~\ref{lem:postgst}, every $p_j \in C$ also sends
${\tt WISH}(v')$ with $v'\ge v$ at some time $s_j$ such that ${\sf GST} \le s_j \le \tm{v}$.
Then by~(*) we have
$v'=v$. It follows that each $p_j \in C$ is guaranteed to send
${\tt WISH}(v)$ to all correct processes between ${\sf GST}$ and $\tm{v}$. Since all
messages sent by correct processes after ${\sf GST}$ are guaranteed to be received by
all correct processes within $\delta$ of their transmission, by
$\tm{v} + \delta$ all correct processes will receive ${\tt WISH}(v)$ from at least
$f+1$ correct processes.
Consider an arbitrary correct process $p_j$ and let $t_j \le \tm{v} + \delta$ be
the earliest time by which $p_j$ receives ${\tt WISH}(v)$ from $f+1$
correct processes. By~(*), no correct process sends
${\tt WISH}(v')$ with $v' > v$ before $t_j < \tm{v} + 2\delta$. Thus, $p_j.{\sf max\_views}(t_j)$
includes at least $f+1$ entries equal to $v$ and at most
$f$ entries $>v$, so that $p_j.{\sf view}^+(t_j) = v$.
Then $p_j$ sends ${\tt WISH}(v)$ to all processes no later than
$t_j \le \tm{v} + \delta$.
Since $\tm{v} \ge \ensuremath{\overline{{\sf GST}}}$, by Lemma~\ref{lem:postgst},
$p_j$ also sends ${\tt WISH}(v')$ with $v'\ge v$ in-between
${\sf GST}$ and $\tm{v} + \delta$. By~(*), $v'=v$, and therefore,
$p_j$ must have sent ${\tt WISH}(v)$ to all processes sometime between
${\sf GST}$ and $\tm{v} + \delta$. Hence, all correct processes are guaranteed to
send ${\tt WISH}(v)$ to all correct processes between ${\sf GST}$ and $\tm{v} + \delta$.
Consider an arbitrary correct process $p_k$ and let $t_k \le \tm{v} + 2\delta$
be the earliest time by which $p_k$ receives ${\tt WISH}(v)$ from all correct
processes. Then by~(*), all entries of correct processes in
$p_k.{\sf max\_views}(t_k)$ are equal to $v$. Since there are at least $2f+1$ correct processes:
\emph{(i)} at least $2f+1$ entries in
$p_k.{\sf max\_views}(t_k)$ are equal to $v$, and
\emph{(ii)} one of the $f+1$ highest entries in $p_k.{\sf max\_views}(t_k)$ is equal to $v$.
From \emph{(i)}, $p_k.{\sf view}^+(t_k) \ge p_k.{\sf view}(t_k) \ge v$,
and from \emph{(ii)}, $p_k.{\sf view}(t_k) \le p_k.{\sf view}^+(t_k) \le v$.
Therefore, $p_k.{\sf view}(t_k) = p_k.{\sf view}^+(t_k) = v$, so that $p_k$ enters $v$ no later than
$t_k \le \tm{v}+2\delta$. We have thus shown that by $\tm{v}+2\delta$, all
correct processes enter $v$, as required.\qed
\bigskip
\begin{lemma}
Startup\xspace holds:
suppose there exists a set $P$ of $f+1$ correct processes such that
$\forall p_i \in P.\, {\ta{i}{0}\mathpunct{\downarrow}}$;
then eventually some correct process enters view $1$.
\label{lem:enter1}
\end{lemma}
{\em Proof.}
Assume by contradiction that there exists a set $P$ of $f+1$ correct processes such that
$\forall p_i \in P.\, {\ta{i}{0}\mathpunct{\downarrow}}$, and
no correct process enters the view $1$. By Proposition~\ref{sync:noskip},
the latter implies
\begin{equation}
\forall v' > 0.\, \forall p_i \in \mathcal{C}.\, \tm{v'}\mathpunct{\uparrow}.
\label{eq:enter-never1}
\end{equation}
Then by Lemma~\ref{lem:wish-attempt} we have
\begin{equation}
\forall t.\, \forall v' > 1.\, \forall p_i.\,
\neg (p_i \text{~sends~} {\tt WISH}(v') \text{~at~} t \wedge
p_i \text{~is~correct}).
\label{eq:upper-never1}
\end{equation}
Let $T_1 = \max(\ensuremath{\overline{{\sf GST}}}, \talast{0})$.
Since there exists a set $P$ of $f+1$ correct processes
that attempt to advance from view $0$, each $p_i\in P$ sends
${\tt WISH}(v_i)$ with $v_i > 0$ before $T_1$.
Since $T_1 \ge \ensuremath{\overline{{\sf GST}}}$, by Lemma~\ref{lem:postgst}, there exists a view $v_i'\ge 1$
and a time $s_i$ such that ${\sf GST} \le s_i \le T_1$ and $p_i$ sends ${\tt WISH}(v_i')$ at $s_i$.
By~(\ref{eq:upper-never1}), $v_i'=1$. Since the links are reliable after
${\sf GST}$, the ${\tt WISH}(1)$ sent by $p_i$ at $s_i$ will be received by all correct
processes.
Thus, there exists a time $T_2 \ge T_1 \ge \ensuremath{\overline{{\sf GST}}}$ by which
all correct processes
have received ${\tt WISH}(1)$ from all processes in $P$.
Fix an arbitrary correct process $p_j$.
Since all process in $P$ are correct,
all entries in $p_j.{\sf max\_views}(T_2)$ associated with the processes in $P$
are equal to $1$. Since $|P|=f+1$, $p_j.{\sf max\_views}(T_2)$
includes at least $f+1$ entries $\ge 1$, and therefore,
$p_j.{\sf view}^+(T_2)\ge 1$.
Hence, $p_j$ sends ${\tt WISH}(v_j)$ with $v_j \ge 1$ no later than $T_2$.
Since $T_2 \ge \ensuremath{\overline{{\sf GST}}}$, by Lemma~\ref{lem:postgst} there exists
a view $v'_j\ge 1$ and a time $s_j$ such that ${\sf GST} \le s_j \le T_2$ and
$p_j$ sends ${\tt WISH}(v'_j)$ at $s_j$. By~(\ref{eq:upper-never1}), $v'_j = 1$.
Since the links are reliable after ${\sf GST}$, the ${\tt WISH}(1)$
sent by $p_j$ will be received by all correct processes.
Thus, there exists a time $T_3 \ge T_2 \ge \ensuremath{\overline{{\sf GST}}}$ by which all correct processes
have received ${\tt WISH}(1)$ from all correct processes. Fix an arbitrary correct process $p_k$.
By~(\ref{eq:upper-never1}), all entries of correct processes in $p_k.{\sf max\_views}(T_3)$
are equal to $1$. Since there are at least $2f+1$ correct processes:
\emph{(i)} at least $2f+1$ entries in
$p_k.{\sf max\_views}(T_3)$ are equal to $1$, and
\emph{(ii)} one of the $f+1$ highest entries in $p_k.{\sf max\_views}(T_2)$ is equal to $1$.
From \emph{(i)}, $p_k.{\sf view}^+(T_2) \ge p_k.{\sf view}(T_2) \ge 1$,
and from \emph{(ii)}, $p_k.{\sf view}(T_2) \le p_k.{\sf view}^+(T_2) \le 1$.
Hence, $p_k.{\sf view}(T_2) = p_k.{\sf view}^+(T_2) = 1$, and therefore,
$p_k$ enters view $1$ by $T_2$, contradicting~(\ref{eq:enter-never1}).\qed
\bigskip
\begin{lemma}
Progress\xspace holds:
consider a view $v>0$ that is entered by a correct process, and suppose
there exists a set $P$ of $f+1$ correct processes such that
\begin{equation}
\forall p_i\in P.\, {\te{i}{v}\mathpunct{\downarrow}} \implies {\ta{i}{v}\mathpunct{\downarrow}};
\label{eq:live-pre}
\end{equation}
then eventually some correct process enters $v+1$.
\label{lem:gv-live}
\end{lemma}
{\em Proof.}
Assume by contradiction that the required does not hold. Then, there exists
a view $v > 0$ such that some correct process enters $v$,~(\ref{eq:live-pre})
holds, and no correct process enters the view $v+1$. By Proposition~\ref{sync:noskip},
the latter implies that
\begin{equation}
\forall v' > v.\, \forall p_i \in \mathcal{C}.\, \tm{v'}\mathpunct{\uparrow}.
\label{eq:enter-never}
\end{equation}
Thus, by Lemma~\ref{lem:wish-attempt}, we have
\begin{equation}
\forall t.\, \forall v' > v + 1.\, \forall p_i.\,
\neg (p_i \text{~sends~} {\tt WISH}(v') \text{~at~} t \wedge
p_i \text{~is~correct}).
\label{eq:upper-never}
\end{equation}
Let $T_1 = \max(\ensuremath{\overline{{\sf GST}}}, \tm{v})$.
Since some correct process entered $v$ by $T_1$, there
exists a set $C$ consisting of $f+1$ correct processes all of which sent
${\tt WISH}(v')$ with $v'\ge v$ before $T_1$.
Consider $p_i\in C$ and let $t_i \le T_1$ be a time such that at $t_i$
the process $p_i$ sends ${\tt WISH}(v_i)$ with $v_i \ge v$.
Since $T_1 \ge \ensuremath{\overline{{\sf GST}}}$, by Lemma~\ref{lem:postgst}, there exists a view $v_i'\ge v_i$
and a time $s_i$ such that ${\sf GST} \le s_i \le T_1$ and $p_i$ sends ${\tt WISH}(v_i')$ at $s_i$.
By~(\ref{eq:upper-never}), we have $v_i' \in \{v, v+1\}$.
Since the links are reliable after ${\sf GST}$, the ${\tt WISH}(v_i')$ sent by $p_i$ at
$s_i$ will be received by all correct processes.
Thus, there exists a time $T_2 \ge T_1 \ge \ensuremath{\overline{{\sf GST}}}$ by which all correct
processes have received ${\tt WISH}(v')$ with $v' \in \{v, v+1\}$
from all processes in $C$. Consider an arbitrary correct process $p_j$.
By~(\ref{eq:upper-never}), the entry of every process in $C$ in
$p_j.{\sf max\_views}(T_2)$ is equal to either $v$ or $v+1$.
Since $|C|\ge f+1$ and all processes
in $C$ are correct, $p_j.{\sf max\_views}(T_2)$ includes at least $f+1$ entries $\ge v$.
Thus, $p_j.{\sf view}^+(T_2) \ge v$, and therefore, $p_j$ sends
${\tt WISH}(v_j)$ with $v_j \ge v$ no later than at $T_2$. By~(\ref{eq:upper-never}),
$v_j \in \{v, v+1\}$.
Since $T_2 \ge \ensuremath{\overline{{\sf GST}}}$, by Lemma~\ref{lem:postgst}, there exists a view $v_j'\ge v$ and a time
$s_j$ such that ${\sf GST} \le s_j \le t_j$ and $p_j$ sends ${\tt WISH}(v_j')$ at $s_j$.
By~(\ref{eq:upper-never}), $v_j' \in \{v, v+1\}$.
Since the links are reliable after
${\sf GST}$, the ${\tt WISH}(v_j')$ sent by $p_j$ at $s_j$ will be received by all correct
processes.
Thus, there
exists a time $T_3 \ge T_2 \ge \ensuremath{\overline{{\sf GST}}}$ by which all correct processes have
received ${\tt WISH}(v')$ such that $v' \in \{v, v+1\}$ from
all correct processes.
Consider an arbitrary correct process $p_k$, and suppose that $p_k$
is a member of the set $P$ stipulated by the lemma's premise.
Then at $T_3$, all entries of correct processes
in $p_k.{\sf max\_views}$ are $\ge v$.
By~(\ref{eq:upper-never}), each of these entries is equal to either $v$ or $v+1$.
Since at least $2f+1$ processes are correct:
\emph{(i)} at least $2f+1$ entries in $p_k.{\sf max\_views}(T_3)$ are $\ge v$, and
\emph{(ii)} one of the $f+1$ highest entries in $p_k.{\sf max\_views}(T_3)$ is $\le v+1$.
From \emph{(i)}, $p_k.{\sf view}^+(T_3) \ge p_k.{\sf view}(T_3) \ge v$,
and from \emph{(ii)}, $p_k.{\sf view}(T_3) \le p_k.{\sf view}^+(T_3) \le v+1$.
Hence, $p_k.{\sf view}(T_3), p_k.{\sf view}^+(T_3) \in \{v, v+1\}$.
Since no correct process enters $v+1$, $p_k.{\sf view}(T_3)$ and $p_k.{\sf view}^+(T_3)$
cannot be both simultaneously equal to $v+1$. Thus,
$p_k.{\sf view}(T_3) = v$, and either $p_k.{\sf view}^+(T_3) = v$
or $p_k.{\sf view}^+(T_3)=v+1$. If $p_k.{\sf view}^+(T_3) = v+1$, then
$p_k$ has sent ${\tt WISH}(v_k)$ with $v_k=v+1$ when $p_k.{\sf view}^+$
has first become equal to $v+1$ sometime before $T_3$. On the other hand,
if $p_k.{\sf view}(T_3) = p_k.{\sf view}^+(T_3) = v$, then $p_k$ has entered
$v$ at some time $t\le T_3$.
Since $p_k\in P$,
by~(\ref{eq:live-pre}), there exists a time $t' \ge t$ such that
$p_k$ attempts to advance from $v$ at $t'$, and therefore, sends
${\tt WISH}(v_k)$ with $v_k \ge v+1$ at $t'$. By~(\ref{eq:upper-never}),
$v_k \le v + 1$, and therefore, $v_k = v+1$.
Thus, there exists a time $t_k \ge T_3$ by which $p_k$ sends ${\tt WISH}(v+1)$ to all processes.
Since $t_k \ge T_3 \ge \ensuremath{\overline{{\sf GST}}}$, by Lemma~\ref{lem:postgst}, there exists
a view $v'_k\ge v+1$ and a time $s_k$ such that ${\sf GST} \le s_k \le t_k$ and
$p_k$ sends ${\tt WISH}(v'_k)$ at $s_k$. By~(\ref{eq:upper-never}), $v'_k=v+1$.
Since the links are reliable after ${\sf GST}$, the ${\tt WISH}(v+1)$
sent by $p_k$ will be received by all correct processes.
Thus, there exists a time $T_4 \ge T_3 \ge \ensuremath{\overline{{\sf GST}}}$ by which
all correct processes
have received ${\tt WISH}(v+1)$ from all processes in $P$.
Fix an arbitrary correct process $p_l$.
Since all process in $P$ are correct,
by~(\ref{eq:upper-never}),
all entries in $p_l.{\sf max\_views}(T_4)$ associated with the processes in $P$
are equal to $v+1$. Since $|P|=f+1$, $p_l.{\sf max\_views}(T_4)$
includes at least $f+1$ entries equal to $v+1$, and therefore,
$p_l.{\sf view}^+(T_4)\ge v+1$.
Hence, $p_l$ sends ${\tt WISH}(v_l)$ with $v_l \ge v+1$ no later than $T_4$.
Since $T_4 \ge \ensuremath{\overline{{\sf GST}}}$, by Lemma~\ref{lem:postgst} there exists
a view $v'_l\ge v+1$ and a time $s_l$ such that ${\sf GST} \le s_l \le T_4$ and
$p_l$ sends ${\tt WISH}(v'_l)$ at $s_l$. By~(\ref{eq:upper-never}), $v_l' = v+1$.
Since the links are reliable after ${\sf GST}$, the ${\tt WISH}(v+1)$
sent by $p_l$ will be received by all correct processes.
Thus, there exists a time $T_5 \ge T_4 \ge \ensuremath{\overline{{\sf GST}}}$ by which all correct processes
have received ${\tt WISH}(v + 1)$ from all correct processes. Fix an arbitrary correct process $p_m$.
By~(\ref{eq:upper-never}), all entries of correct processes in $p_m.{\sf max\_views}(T_5)$
are equal to $v+1$. Since there are at least $2f+1$ correct processes:
\emph{(i)} at least $2f+1$ entries in
$p_m.{\sf max\_views}(T_5)$ are equal to $v+1$, and
\emph{(ii)} one of the $f+1$ highest entries in $p_m.{\sf max\_views}(T_5)$ is equal to $v+1$.
From \emph{(i)}, $p_m.{\sf view}^+(T_5) \ge p_m.{\sf view}(T_5) \ge v+1$,
and from \emph{(ii)}, $p_m.{\sf view}(T_5) \le p_l.{\sf view}^+(T_5) \le v+1$.
Hence, $p_m.{\sf view}(T_5) = p_m.{\sf view}^+(T_5) = v+1$, and therefore,
$p_m$ enters $v+1$ by $T_5$, contradicting~(\ref{eq:enter-never}).\qed
\begin{theorem}
Consider an execution with an eventual message delay $\delta$.
Then %
in this execution the algorithm in Figure~\ref{fig:sync} satisfies
the properties in Figure~\ref{fig:multi-sync-properties} for $d=2\delta$.
\label{thm:smr-sync-correct2}
\end{theorem}
{\em Proof.}
Monotonicity\xspace is satisfied trivially, and
Validity\xspace, Startup\xspace, and Progress\xspace
are given by Lemmas~\ref{lemma:enter-attempt},~\ref{lem:enter1}, and~\ref{lem:gv-live},
respectively. To prove Bounded Entry\xspace, let
\begin{equation}
\mathcal{V}=\max\{v \mid {\tm{v}\mathpunct{\downarrow}} \wedge \tm{v} < \ensuremath{\overline{{\sf GST}}}\} + 1.
\label{eq:theview}
\end{equation}
Then $\forall v \ge \mathcal{V}.\, {\tm{v}\mathpunct{\downarrow}} {\implies} \tm{v} \ge \ensuremath{\overline{{\sf GST}}}$. Thus, by
Lemma~\ref{lem:GST-bound2}, Bounded Entry\xspace holds for $d=2\delta$, as
required.\qed
\section{Related Work and Discussion}
\label{sec:related}
\paragraph{Failure detectors.}
Failure detectors and leader oracles~\cite{CT96,petr-survey} have been
widely used for implementing live consensus and SMR
under benign failures~\cite{MR99,GR04,R00}.
However, their
implementations under Byzantine failures are either impractical~\cite{kihlstrom}
or detect only restricted failure types~\cite{MR97,muteness,modular-smr,HK09}.
An alternative approach was proposed in a textbook by Cachin et
al.~\cite{cachin-book}. This relies on a leader-based Byzantine Epoch-Change
(BEC) abstraction,
which accepts ``complain'' hints from the application %
to identify situations when the trust in the current leader needs to be revoked.
However, like the classical leader oracles, BEC requires all correct processes
to eventually trust the same well-behaved leader, which is impossible to achieve
in Byzantine settings\footnote{E.g., a set of $\le f$ correct processes
complaining about the leader will not have sufficient voting power to convince
the remaining ones to stop trusting it.}.
In fact, the BEC-based Byzantine consensus algorithm in~\S{}5.6.4
of~\cite{cachin-book} suffers from a liveness bug, which we describe
in~\tr{\ref{sec:bug}}{F}. The bug has been confirmed with one of the
textbook's authors~\cite{cristian-personal}.
Although our ${\tt advance}$ is %
similar to ``complain'',
we use it to implement a weaker abstraction of an SMR synchronizer.
We then obtain properties similar to accuracy and completeness of failure
detectors by carefully combining SMR-level timers with uses of ${\tt advance}$
(Lemmas~\ref{thm:castro:completeness}-\ref{thm:castro:all-good}). Also,
while~\cite{cachin-book} does not specify constraints on the use of ``complain''
(see~\tr{\ref{sec:bug}} {F} for details), we give a complete
characterization of ${\tt advance}$ and show its sufficiency for solving SMR.
BFT-SMaRt~\cite{bftsmart,bftsmart-thesis} built on the ideas
of~\cite{cachin-book} to propose an abstraction of {\em validated and provable
(VP) consensus}, which allows its clients to control leader changes.
Although the overall BFT-SMaRt protocol appears to be correct, its liveness
proof sketch suffers from issues with rigor similar to those of~\cite{cachin-book}.
In particular, the conditions on how to change the leader in
VP-Consensus to ensure its liveness were underspecified (again, see~\tr{\ref
{sec:bug}}{F}).
\paragraph{Emulating synchrony.}
Alternative abstractions avoid dependency on the specifics of a failure model
by simulating synchrony~\cite{Gaf98,heardof,KS06,heardof-bft}.
The first such abstraction is due to Awerbuch~\cite{Awe85} who proposed a family
of synchronizer algorithms emulating a round-based synchronous system of top of an
asynchronous network with reliable communication and processes.
The first such emulation in a failure-prone partially synchronous
system was introduced in the DLS paper~\cite{dls}.
It relied on an expensive
clock synchronization protocol, which interleaved its messages with
every step of a high-level consensus algorithm implemented on top of it.
Later work has proposed more practical solutions, which reduce the
synchronization frequency by relying on either timers~\cite{cezara} or
synchronized hardware clocks~\cite{ADDNR19,indulgent1,indulgent2} (the latter can be obtained using
one of the existing fault-tolerant clock synchronization
algorithms~\cite{SWL86,DHSS95}).
However, the DLS model emulates communication-closed rounds, i.e., eventually, a
process in a round $r$ receives {\em all} messages sent by correct processes in
$r$. This property is needlessly strong for Byzantine consensus or SMR, since
protocols such as PBFT can make progress in a given view if they receive
messages from {\em any quorum}.
\paragraph{Consensus synchronizers.}
To address the shortcoming of DLS rounds, recent
work~\cite{NK20,bftlive,hotstuff} proposed a more flexible abstraction
(``consensus synchronizer'' in \S\ref{sec:sync}) that switches processes through
an infinite series of {\em views}. In contrast to rounds, each view may
subsume multiple communication steps, and its duration can either be fixed in
advance~\cite{NK20} or grow dynamically~\cite{bftlive,hotstuff}.
Although consensus synchronizers can be used for efficient
single-shot Byzantine consensus~\cite{bftlive}, using them for SMR results in
suboptimal implementations.
A classical approach is to decide on each SMR command using a separate black-box
consensus instance~\cite{smr}. However, implementing the latter using a
consensus synchronizer would force the processes in every instance to iterate
over the same sequence of potentially bad views until the one with a correct
leader and sufficiently long duration could be reached. Although reusing good
views across instances is possible, this would require a non-trivial
reconfiguration protocol to share their parameters~\cite{tenderbake}.
An alternative approach was proposed in HotStuff~\cite{hotstuff}. This SMR
protocol is driven by a {\em pacemaker}, which keeps generating views similarly
to a consensus synchronizer. Within each view HotStuff runs a voting protocol
that commits a block of client commands in a growing hash chain. Although the
voting protocol %
can commit a block at wire speed %
(``optimistic responsiveness''), committing the next block is delayed until the
pacemaker generates a new view, which increases latency. Furthermore, the cost
the pacemaker may incur to generate a view is paid for every single block.
\paragraph{SMR synchronizers.}
In contrast to the above approaches, SMR synchronizers allow the application to
initiate view changes on demand via an ${\tt advance}$ call.
As we show,
this affords SMR protocols the flexibility to judiciously manage their view
synchronization schedule: in particular, it prevents the timeouts from growing
unnecessarily (Theorem~\ref{thm:pbftr-latency2-informal}, \S\ref{sec:xbft}) and
avoids the overheads of further view synchronizations once a stable view is
reached (Lemma~\ref{thm:castro:all-good}, \S\ref{sec:liveness}).
The first synchronizer with a ${\tt new\_view}$/${\tt advance}$ interface, which here we
call an SMR synchronizer, was proposed by Naor et al.~\cite{NK20,lumiere}. They
used it as an intermediate module in a communication-efficient implementation of
a consensus synchronizer. The latter is sufficient to ensure the liveness of
HotStuff~\cite{hotstuff} via either of the two straightforward SMR constructions
we described above. The specification of the ${\tt new\_view}$/${\tt advance}$ module of
Naor et al. was only used as a stepping stone in the proof of their consensus
synchronizer, and as a result, is more low-level and complex than our SMR
synchronizer specification. Naor et al. did not investigate the usability of the
SMR synchronizer abstraction as a generic building block applicable to a wide
range of Byzantine SMR protocols -- a gap we fill in this paper. Finally, they
only handled a simplified version of partial synchrony where messages are never
lost and $\delta$ is known a priori, whereas our SMR synchronizer implementation
handles partial synchrony in its full generality. This implementation builds on
the consensus synchronizer of Bravo et al.~\cite{bftlive}. However, its
correctness proof and performance analysis are more intricate,
since %
the timing of the view switches is not fixed a priori, but driven by external
${\tt advance}$ inputs.
The algorithms we consider are deterministic. An interesting direction for
future research is to adapt SMR synchronizers to emulate asynchronous rounds, as
required by randomized consensus
algorithms~\cite{random-benor,random-bracha,random-saia,random-cachin}.
\paragraph{SMR liveness proofs.}
PBFT~\cite{pbft,castro-thesis,castro-tocs} is a seminal protocol whose design
choices have been widely
adopted~\cite{zyzzyva,aardvark,spinning,mirbft,sbft}. To the best of our
knowledge, our proof in~\S\ref{sec:liveness} is the first one to formally
establish its liveness. An informal argument given
in~\cite[\S{}4.5.1]{castro-tocs} mainly justifies
liveness assuming all correct processes enter a view with a correct leader and
stay in that view for sufficiently long. It does not rigorously justify why such
a view will be eventually reached, and in particular, how this is ensured by the
interplay between SMR-level timeout management and view synchronization
(\S\ref{sec:liveness}). Liveness mechanisms were also omitted from the formal
specification of PBFT by an I/O-automaton~\cite{castro-tocs,castro-thesis}.
Bravo et al.~\cite{bftlive} have applied consensus synchronizers to several
consensus protocols, including a single-shot version of PBFT. These protocols
and their proofs and are much more straightforward than the full SMR protocols
we consider here. In particular, since a consensus synchronizer keeps switching
processes between views regardless of whether their leaders are correct, the
proof of the single-shot PBFT in~\cite{bftlive} does not need to establish
analogs of completeness and accuracy (Lemmas~\ref{thm:castro:completeness}
and~\ref{thm:castro:all-good}) or deal with the fact that processes may disagree
on timeout durations (Lemma~\ref{thm:castro:timers}).
Byzantine SMR protocols often integrate the view synchronization mechanism into
the core protocol, which enables white-box
optimizations~\cite{tendermint-arxiv,libra,pbft,ittai-fast-path}. Our work does
not rule out this approach, but provides a way to make it more systematic: we
can first develop efficient mechanisms for view synchronization independently
from SMR protocols and do white-box optimizations afterwards, if
needed. Overall, our synchronizer specification and the analysis of PBFT provide
a blueprint for designing provably live and efficient Byzantine SMR protocols.
\section{Additional Material about PBFT-light\xspace}
\subsection{Proof of Safety for PBFT-light\xspace}
\label{sec:pbft-safety}
Let us write ${\sf wf}(C)$ (for {\em well-formed}) if the set of correctly signed
messages $C$ were generated in the execution of the protocol.
In PBFT-light\xspace, committing a value requires preparing it, which implies
\begin{proposition}
\label{lemma:pbft:committed-prepared}
$\forall k, v, C, h.\, \ensuremath{{\sf committed}}(C, v, k, h) \wedge {\sf wf}(C) {\implies} \exists C'.\, {\sf prepared}(C', v,
k, h) \wedge {\sf wf}(C')$.
\end{proposition}
Furthermore, the validity checks in the protocol ensure that any prepared value is valid:
\begin{proposition}
\label{lemma:pbft:validityliveness}
$\forall k, v, C, x .\, {\sf prepared}(C, v, k, {\sf hash}(x)) \wedge {\sf wf}(C) {\implies} {\sf valid}(x)$.
\end{proposition}
The above two propositions imply
\begin{corollary}
PBFT-light\xspace satisfies External Validity.
\end{corollary}
\begin{proposition}
\label{lemma:pbft:view-increase}
The variables ${\sf curr\_view}$ and ${\sf prep\_view}[k]$ (for any $k$) at a correct process
never decrease and we always have ${\sf prep\_view}[k] \le {\sf curr\_view}$.
\end{proposition}
\begin{proposition}
\label{lemma:pbft:singlecmd}
$\forall k, v, C, C', x, x '.\, {\sf prepared}(C, v, k, {\sf hash}(x)) \wedge
{\sf prepared}(C', v, k, {\sf hash}(x')) \wedge {}$
\\
\hspace*{2.83cm}${\sf wf}(C) \wedge {\sf wf}(C') {\implies} x = x'$.
\end{proposition}
{\em Proof.} By contradiction, suppose that $x\not=x '$. Because a
${\sf prepared}$ certificate consists of at least $2f+1$ ${\tt PREPARE}$ messages and
there are $3f+1$ processes in total, there must be a correct process that sent
two ${\tt PREPARE}$ messages with different hashes for the same position and
view. But this is impossible due to the check on the check on ${\sf phase}$ in
line~\ref{alg:castro:safety-check}.\qed
\begin{lemma}
\label{lemma:pbft:nodupl}
If $m = \langle{\tt NEW\_STATE}(v', \mathit{log}', M)\rangle_{{\sf leader}(v')}$ is a sent message
such that ${\sf ValidNewState}(m)$, then
$$
\forall k, k'.\, \mathit{log}'[k] = \mathit{log}'[k'] \not\in \{\bot, {\tt nop}\} {\implies} k=k'.
$$
\end{lemma}
{\em Proof.}
We prove the statement of the lemma by induction on $v'$. Assume this holds for
all $v' < v^*$; we now prove it for $v' = v^*$. Let
$$
M = \{\langle {\tt NEW\_LEADER}(v', \mathit{prep\_view}_j, \mathit{log}_j, \mathit{cert}_j) \rangle_j \mid p_j
\in Q\}
$$
for some quorum $Q$. By contradiction, assume that for some $k$, $k'$ and $x$
we have $k \not= k'$, $\mathit{log}'[k] = \mathit{log}'[k'] = x \not\in \{\bot,
{\tt nop}\}$. Since ${\sf ValidNewState}(m)$, $\mathit{log}'$ is computed from $M$ as per
lines~\ref{alg:castro:select-proposal}-\ref{alg:castro:newview-end}. Then due to the loop at
line~\ref{alg:castro:clean-entries}, for some $i, i' \in Q$ we have
$\mathit{log}_i[k] = \mathit{log}_{i'}[k'] = x$ and
$\mathit{prep\_view}_{i}[k] = \mathit{prep\_view}_{i'}[k'] = v$ for some $v$ such that
$0 < v < v'$. Hence, for some $C$ and $C'$ we have
$$
{\sf prepared}(C, v, k, {\sf hash}(x))
\wedge
{\sf prepared}(C', v, k', {\sf hash}(x))
\wedge
{\sf wf}(C) \wedge {\sf wf}(C').
$$
Because a ${\sf prepared}$ certificate consists of at least $2f+1$ ${\tt PREPARE}$
messages and there are $3f+1$ processes in total, there must be a correct process
that sent messages ${\tt PREPARE}(v, k, {\sf hash}(x))$ and
${\tt PREPARE}(v, k', {\sf hash}(x))$. But this is impossible because by the induction
hypothesis, the process starts the view $v$ with a log without duplications
(except ${\tt nop}$s), and does not add duplicate entries due to the check at
line~\ref{alg:castro:safety-check}. This contradiction demonstrates the required.\qed
\begin{corollary}
\label{cor:pbft:nodupl}
$$
\forall x, v, k, k', C, C'.\,
{\sf prepared}(C, v, k, {\sf hash}(x)) \wedge
{\sf prepared}(C', v, k', {\sf hash}(x)) \wedge
{\sf wf}(C) \wedge {\sf wf}(C') \wedge x \not= {\tt nop}
{\implies} k = k'.
$$
\end{corollary}
{\em Proof.}
Assume the contrary. Because a ${\sf prepared}$ certificate consists of at least
$2f+1$ ${\tt PREPARE}$ messages and there are $3f+1$ processes in total, there must
be a correct process that sent messages ${\tt PREPARE}(v, k, {\sf hash}(x))$ and
${\tt PREPARE}(v, k', {\sf hash}(x))$. But this is impossible because by
Lemma~\ref{lemma:pbft:nodupl}, the process starts the view $v$ with a log
without duplications (except ${\tt nop}$s), and does not add duplicate entries due
to the check at line~\ref{alg:castro:safety-check}. This contradiction demonstrates the
required.\qed
\begin{lemma}
\label{lemma:pbft:main}
Fix $k$, $v$, $v'$, $C$ and $x$, and assume
$$
\ensuremath{{\sf committed}}(C, v, k, {\sf hash}(x)) \wedge {\sf wf}(C) \wedge v' > v.
$$
\begin{itemize}
\item
$\forall C', x'.\, {\sf prepared}(C', v', k, {\sf hash}(x')) \wedge {\sf wf}(C') {\implies} x = x'$.
\item
$\forall C', k'.\, x \not= {\tt nop} \wedge
{\sf prepared}(C', v', k', {\sf hash}(x)) \wedge {\sf wf}(C') {\implies} k = k'$.
\end{itemize}
\end{lemma}
{\em Proof.}
We prove the statement of the lemma by induction on $v'$. Assume this holds for
all $v' < v^*$; we now prove it for $v' = v^*$. Thus, we have
\begin{equation}\label{pbft:hyp4}
\forall C'', k'', v''.\, v < v'' < v' \wedge x \not= {\tt nop} \wedge {\sf prepared}(C'', v'',
k'', {\sf hash}(x)) \wedge {\sf wf}(C'') {\implies} k = k''.
\end{equation}
The induction hypothesis also implies
$$
\forall C'', x'', v''.\, v < v'' < v' \wedge {\sf prepared}(C'', v'',
k, {\sf hash}(x'')) \wedge {\sf wf}(C'') {\implies} x = x''.
$$
Furthermore, by Propositions~\ref{lemma:pbft:singlecmd}
and~\ref{lemma:pbft:committed-prepared} we have
$$
\forall C'', x''.\,
{\sf prepared}(C'', v, k, {\sf hash}(x'')) \wedge {\sf wf}(C'') {\implies} x = x'',
$$
so that overall we get
\begin{equation}\label{pbft:hyp2}
\forall C'', x'', v''.\, v \le v'' < v' \wedge {\sf prepared}(C'', v'', k,
{\sf hash}(x'')) \wedge {\sf wf}(C'') \implies x = x''.
\end{equation}
Assume now that ${\sf prepared}(C', v', k, {\sf hash}(x'))$ and ${\sf wf}(C')$. Then a
correct process that sent the corresponding ${\tt PREPARE}$ message must have
received a message $m ={\tt NEW\_STATE}(v', \mathit{log}', M)$ from the leader of $v'$
satisfying ${\sf ValidNewState}(m)$. Let
$$
M = \{\langle {\tt NEW\_LEADER}(v', \mathit{prep\_view}_j, \mathit{log}_j, \mathit{cert}_j) \rangle_j \mid p_j
\in Q\}
$$
for some quorum $Q$. Since ${\sf ValidNewState}(m)$, we have
$\forall m' \in M.\, {\sf ValidNewLeader}(m')$, so that
$$
\forall p_j \in Q.\, \mathit{prep\_view}_j < v' \wedge ({\mathit{prep\_view}_j \not= 0}
{\implies}
{\sf prepared}(\mathit{cert}_j, \mathit{prep\_view}_j, k, {\sf hash}(\mathit{log}_j[k])) \wedge
{\sf wf}(\mathit{cert}_j)).
$$
From this and~(\ref{pbft:hyp2}) we get that
\begin{equation}\label{pbft:hyp3}
\forall p_j \in Q.\, {\mathit{prep\_view}_j \ge v} {\implies} \mathit{log}_j[k] = x.
\end{equation}
Since $\ensuremath{{\sf committed}}(C, v, k, {\sf hash}(x))$, a quorum $Q'$ of processes sent
${\tt COMMIT}(v, k, {\sf hash}(x))$. The quorums $Q$ and $Q'$ have to intersect in some
correct process $p_{i}$, which has thus sent both ${\tt COMMIT}(v, k, {\sf hash}(x))$ and
${\tt NEW\_LEADER}(v', \mathit{prep\_view}_i, \mathit{log}_i, \mathit{cert}_i)$. Since $v< v'$, this process
$p_{i}$ must have sent the ${\tt COMMIT}$ message before the ${\tt NEW\_LEADER}$
message. Before sending ${\tt COMMIT}(v, k, {\sf hash}(x))$ the process set
${\sf prep\_view}[k]$ to $v$ (line~\ref{alg:castro:assign-cballot}). Then by
Proposition~\ref{lemma:pbft:view-increase} process $p_{i}$ must have had
${\sf prep\_view}[k] \ge v$ when it sent the ${\tt NEW\_LEADER}$ message. Hence,
$\mathit{prep\_view}_{i}[k] \ge v > 0$ and $\max\{\mathit{prep\_view}_{j'}[k] \mid p_{j'} \in Q\} \ge v$.
Then from~(\ref{pbft:hyp3}) we get
\begin{equation}\label{pbft:concl1}
\forall p_j \in Q.\, \mathit{prep\_view}_j[k] = \max\{\mathit{prep\_view}_{j'}[k] \mid p_{j'} \in Q\} {\implies}
\mathit{log}_j[k] = x.
\end{equation}
Assume now that $x \not= {\tt nop}$, but $\mathit{log}'[k] = {\tt nop}$ due to
line~\ref{alg:castro:newview-end}. Then
$$
\exists k'.\, k' \not= k \wedge \mathit{log}'[k'] = x \wedge \exists p_j \in Q.\,
\forall p_{j'} \in Q.\, \mathit{prep\_view}_j[k'] > \mathit{prep\_view}_{j'}[k]
$$
and $v' > \mathit{prep\_view}_j[k'] > \mathit{prep\_view}_{i}[k] \ge v$. Since
${\sf ValidNewState}(m)$, for some $C''$ we have
${\sf prepared}(C'', \mathit{prep\_view}_j[k'], k', {\sf hash}(x))$ and ${\sf wf}(C'')$. Then
by~(\ref{pbft:hyp4}) we have $k = k'$, which yields a contradiction. This
together with~(\ref{pbft:concl1}) and ${\sf ValidNewState}(m)$ implies
$\mathit{log}'[k] = x$, as required.
Assume now $x \not= {\tt nop}$, ${\sf prepared}(C', v', k', {\sf hash}(x))$ and
${\sf wf}(C')$. Then a correct process that sent the corresponding ${\tt PREPARE}$ message
must have received a message $m = {\tt NEW\_STATE}(v', \mathit{log}', M)$ from the leader of
$v'$ satisfying ${\sf ValidNewState}(m)$. As before, we can show $\mathit{log}'[k] =
x$. By Lemma~\ref{lemma:pbft:nodupl}, the process starts the view $v'$ with a
log without duplications (except ${\tt nop}$s), and does not add duplicate entries
due to the check at line~\ref{alg:castro:safety-check}. Hence, we must have
$k' = k$, as required. \qed
\begin{corollary}\label{thm:pbft:agreement}
PBFT-light\xspace satisfies Ordering.
\end{corollary}
{\em Proof.}
By contradiction, assume that Ordering is violated. Then for some $k$, two
correct processes execute the handler in line~\ref{alg:castro:deliver} for
${\sf last\_delivered} = k-1$ so that ${\sf commit\_log}[k] = x$ at one process and
${\sf commit\_log}[k] = x'$ at the other, where $x \not= x'$. Then
$\ensuremath{{\sf committed}}(C, v, k, {\sf hash}(x))$ and $\ensuremath{{\sf committed}}(C', v', k, {\sf hash}(x'))$ for
some well-formed $C$ and $C'$. By
Proposition~\ref{lemma:pbft:committed-prepared} we have
${\sf prepared}(C_0, v, k, {\sf hash}(x))$ and ${\sf prepared}(C'_0, v', k, {\sf hash}(x'))$
for some well-formed $C_0$ and $C'_0$. Without loss of generality assume
$v \le v'$. If $v = v'$, then $x = x'$ by
Proposition~\ref{lemma:pbft:singlecmd}. If $v < v'$, then $x = x'$ by
Lemma~\ref{lemma:pbft:main}. In either case we get a contradiction.\qed
\begin{corollary}\label{thm:pbft-integrity}
PBFT-light\xspace satisfies Integrity.
\end{corollary}
{\em Proof.}
By contradiction, assume that Integrity is violated. Then for some $k$, $k'$
such that $k\not=k' $and $x \not= {\tt nop}$, a correct process executes the
handler in line~\ref{alg:castro:deliver} first in a view $v$ for
${\sf last\_delivered} = k-1$ and ${\sf commit\_log}[k] = x$ and then in a view $v'$ for
${\sf last\_delivered} = k'-1$ and ${\sf commit\_log}[k'] = x$. We must have
$\ensuremath{{\sf committed}}(C, v, k, {\sf hash}(x))$ and $\ensuremath{{\sf committed}}(C', v', k', {\sf hash}(x'))$
for some well-formed $C$ and $C'$. By
Proposition~\ref{lemma:pbft:committed-prepared} we have
${\sf prepared}(C_0, v, k, {\sf hash}(x))$ and ${\sf prepared}(C'_0, v', k', {\sf hash}(x'))$
for some well-formed $C_0$ and $C'_0$. Without loss of generality assume
$v \le v'$. If $v = v'$, then we get a contradiction by
Corollary~\ref{cor:pbft:nodupl}. If $v < v'$, then we get a contradiction by
Lemma~\ref{lemma:pbft:main}.\qed
\section{Constructing a Consensus Synchronizer from an SMR Synchronizer}
\label{sec:single-shot}
\begin{figure}[h]
\begin{algorithm*}[H]
\setcounter{AlgoLine}{0}
\SubAlgo{\Fun $\texttt{start}$()}{\label{line2:start}
{\tt advance}();
}
\smallskip
\SubAlgo{{\bf upon} ${\tt new\_view}(v)$}{\label{line2:newview}
$\ensuremath{{\tt stop\_timer}}({\sf timer\_view})$\; \label{line2:timer-stop}
$\ensuremath{{\tt start\_timer}}({\sf timer\_view}, \ensuremath{F}(v))$\; \label{line2:start-timer}
\Trigger ${\tt new\_consensus\_view}(v)$\;
}
\smallskip
\SubAlgo{\textbf{when {\sf timer\_view}\ expires}}{\label{line2:timer-exp1}
{\tt advance}();
}
\end{algorithm*}
\caption{A consensus synchronizer from an SMR synchronizer.}
\label{fig:single-shot}
\end{figure}
\begin{figure}[h]
\center
\setlength{\leftmargini}{20pt}
\renewcommand{\theenumi}{\Roman{enumi}}
\renewcommand{\labelenumi}{\theenumi.}
\begin{enumerate}
\item
\label{prop:local-order} $\forall i, v, v'.\, {\sse{i}{v}\mathpunct{\downarrow}} \wedge
{\sse{i}{v'}\mathpunct{\downarrow}} {\implies} (v < v' {\iff} \sse{i}{v} < \sse{i}{v'})$
\item
\label{prop:after-t} $\ssm{\mathcal{V}} \ge {\sf GST}$
\item
\label{prop:no-skip-sync:1}
$\forall i.\, \forall v\ge \mathcal{V}.\, p_i \in \mathcal{C} {\implies} {\sse{i}{v}\mathpunct{\downarrow}}$
\item
\label{prop:no-skip-sync:2}
$\forall v \ge \mathcal{V}.\, \ssl{v} \le \ssm{v}+d$
\item
\label{prop:no-skip-sync:3}
$\forall v \ge \mathcal{V}.\, \ssm{v+1} > \ssm{v}+\ensuremath{F}(v)$
\end{enumerate}
\caption{Consensus synchronizer specification~\cite{bftlive}, holding for some $\mathcal{V} \in {\sf View}$.}
\label{fig:sync-properties}
\end{figure}
A {\em consensus synchronizer} produces a stream of notifications
${\tt new\_consensus\_view}(v)$ at each correct process, telling it to {\em enter} a view
$v$. A process can ensure that the synchronizer has started operating by calling
a special ${\tt start}()$ function. We assume that each correct process
eventually calls ${\tt start}()$, unless it gets a ${\tt new\_consensus\_view}$ notification
first. For a consensus protocol to terminate, its processes need to stay in the
same view for long enough to complete the message exchange leading to a
decision. Since the message delay $\delta$ after ${\sf GST}$ is unknown to the
protocol, we need to increase the view duration until it is long enough for the
protocol to terminate. To this end, the synchronizer is parameterized by a
function defining this duration -- $\ensuremath{F} : {\sf View} \cup \{0\} \to {\sf Time}$,
which is monotone, satisfies $\ensuremath{F}(0) = 0$, and increases unboundedly:
\begin{equation}
\label{prop:increasing}
\forall \theta.\,\exists v.\,\forall v'.\, v'\ge v \implies F(v')>\theta.
\end{equation}
Figure~\ref{fig:single-shot} shows how we can construct a consensus synchronizer
from an SMR synchronizer. Upon a ${\tt start}()$ call, the consensus
synchronizer just tells the underlying SMR synchronizer to advance
(line~\ref{line2:start}). When the SMR synchronizer tells the process to enter
a view $v$ (line~\ref{line2:newview}), the consensus synchronizer produces the
corresponding ${\tt new\_consensus\_view}(v)$ notification. It also sets a timer ${\sf timer\_view}$
for the duration $F(v)$. When the timer expires (line~\ref{line2:timer-exp1}),
the consensus synchronizer tells the SMR synchronizer to advance.
Figure~\ref{fig:sync-properties} presents the specification of a consensus
synchronizer proposed in~\cite{bftlive}. This relies on the following notation,
analogous to the one used for SMR synchronizers. Given a view $v$ for which a
correct process $p_i$ received a ${\tt new\_consensus\_view}(v)$ notification, we denote by
$\sse{i}{v}$ the time when this happens; we let $\ssm{v}$ and $\ssl{v}$ denote
respectively the earliest and the latest time when some correct process receives
a ${\tt new\_consensus\_view}(v)$ notification. Like an SMR synchronizer, a consensus
synchronizer must guarantee that views only increase at a given process
(Property~\ref{prop:local-order}). A consensus synchronizer ensures view
synchronization only starting from some view $\mathcal{V}$, entered after ${\sf GST}$
(Property~\ref{prop:after-t}). Starting from $\mathcal{V}$, correct processes do not skip
any views (Property~\ref{prop:no-skip-sync:1}), enter each view $v \ge \mathcal{V}$
within at most $d$ of each other (Property~\ref{prop:no-skip-sync:2}) and stay
there for a determined amount of time: until $\ensuremath{F}(v)$ after the first
process enters $v$ (Property~\ref{prop:no-skip-sync:3}). We next prove the
following theorem, showing that the consensus synchronizer in
Figure~\ref{fig:single-shot} satisfies these properties.
\begin{theorem}
The consensus synchronizer in Figure~\ref{fig:single-shot} satisfies
Properties~\ref{prop:local-order}-\ref{prop:no-skip-sync:3} in
Figure~\ref{fig:sync-properties}, provided the SMR synchronizer it uses
satisfies the properties in Figure~\ref{fig:multi-sync-properties}.
\label{th:main-app}
\end{theorem}
The implementation in Figure~\ref{fig:single-shot} ensures the following
proposition, which we tacitly use in our proof.
\begin{proposition}
$\forall i, v.\, \sse{i}{v} = \te{i}{v}$.
\end{proposition}
\begin{proposition}
$\forall v.\, \exists v'.\, v'>v \wedge {\ssm{v'}\mathpunct{\downarrow}}$.
\label{lem:live}
\end{proposition}
{\em Proof.} Analogous to Proposition~\ref{lem:live-toy}.\qed
\begin{lemma}
If a correct process enters a view $v>0$ and $\tm{v} \ge {\sf GST}$,
then for all $v' > v$, no correct process attempts to advance from $v'-1$ before
$\tm{v} + \ensuremath{F}(v)$.
\label{lem:i-wont-try}
\end{lemma}
{\em Proof.}
Suppose by contradiction that there exists a time
$t' < \tm{v} + \ensuremath{F}(v)$ and a correct process $p_i$
such that $p_i$ attempts to advance from $v'-1 > v-1$ at $t'$.
Since $v' \ge v + 1 > 1$, at $t'$ the process $p_i$ executes
the handler at line~\ref{line2:timer-exp1} and
the last view it entered is $v' - 1$.
Since $p_i.{\sf timer\_view}$ is not enabled at $t'$, $p_i$ must have
entered $v' - 1$ at least $\ensuremath{F}(v)$ before $t'$ according
to its local clock. Since
$v' - 1 \ge v$, by Proposition~\ref{sync:noskip},
we have $\tm{v' - 1} \ge \tm{v} \ge {\sf GST}$. Therefore,
given that the clocks of all correct processes progress
at the same rate as real time after ${\sf GST}$, we get
$$
\tm{v} \le \tm{v' - 1} \le t' - \ensuremath{F}(v' - 1).
$$
Hence,
$$
t' \ge \tm{v} + \ensuremath{F}(v' - 1).
$$
Since $\ensuremath{F}$ is non-decreasing and $v' - 1 \ge v$,
we have $\ensuremath{F}(v' - 1) \ge \ensuremath{F}(v)$, so that
$$
t' \ge \tm{v} + \ensuremath{F}(v),
$$
which contradicts our assumption that $t' < \tm{v} + \ensuremath{F}(v)$.
This contradiction shows the required.
\qed
\paragraph{\rm\it Proof of Theorem~\ref{th:main-app}.}
Property~\ref{prop:local-order} follows from Monotonicity\xspace of
the SMR synchronizer. Let $\mathcal{V}$ be the view from Bounded Entry\xspace and
let $\mathcal{V}'$ be the minimal view such that $\mathcal{V}' \ge \mathcal{V}$, $\tm{\mathcal{V}'} \ge {\sf GST}$ and
$\ensuremath{F}(\mathcal{V}') \ge 2\delta$. Such a view exists by~(\ref{prop:increasing}) and
Proposition~\ref{lem:live}. Then Property~\ref{prop:after-t} holds for
$\mathcal{V} = \mathcal{V}'$. By Propositions~\ref{sync:noskip} and~\ref{lem:live}, a correct
process enters every view $v \ge \mathcal{V}'$. By Proposition~\ref{sync:noskip},
$v \ge \mathcal{V}'$ implies
\begin{equation}
\tm{v} \ge \tm{\mathcal{V}'} \ge {\sf GST}.
\label{eq:v-after-gst}
\end{equation}
Since $\ensuremath{F}$ is a non-decreasing function, $\ensuremath{F}(v) \ge 2\delta$. Thus, by
Lemma~\ref{lem:i-wont-try} and Bounded Entry\xspace, all correct processes
enter $v$, and $\tl{v} \le \tm{v} + 2\delta$, which validates
Properties~\ref{prop:no-skip-sync:1} and~\ref{prop:no-skip-sync:2} for
$\mathcal{V} = \mathcal{V}'$. To prove Property~\ref{prop:no-skip-sync:3}, fix a view $v\ge \mathcal{V}'$.
Since a correct process enters view $v+1$, by Validity\xspace,
there exist a time $t < \tm{v+1}$ at which some correct process attempts to
advance from $v$. By~(\ref{eq:v-after-gst}), $\tm{v} \ge {\sf GST}$. Then by
Lemma~\ref{lem:i-wont-try} we get $t \ge \tm{v} + \ensuremath{F}(v)$, so that
$\tm{v+1} > t \ge \tm{v} + \ensuremath{F}(v)$, as required.\qed
\subsection{Proof of the Synchronizer Performance Properties}
The following lemma bounds the latency of entering
$v$ as a function of the time by which all correct processes have sent such
${\tt WISH}$es.
\begin{lemma}
For all views $v>0$ and times $s$, if all correct processes $p_i$
send ${\tt WISH}(v_i)$ with $v_i \ge v$ no later than at $s$, and
some correct process enters $v$, then $\tl{v} \le \max(s, \ensuremath{\overline{{\sf GST}}}) + \delta$.
\label{lem:simple-bound-generic}
\end{lemma}
{\em Proof.}
Fix an arbitrary correct process $p_i$ that sends
${\tt WISH}(v_i)$ with $v_i \ge v$
to all processes at time $t_i \le s \le \max(s, \ensuremath{\overline{{\sf GST}}})$.
Since $\max(s, \ensuremath{\overline{{\sf GST}}}) \ge \ensuremath{\overline{{\sf GST}}}$, by Lemma~\ref{lem:postgst}
there exists a time $t_i'$ such that ${\sf GST} \le t_i' \le \max(s, \ensuremath{\overline{{\sf GST}}})$ and at $t_i'$,
$p_i$ sends ${\tt WISH}(v_i')$ with $v_i' \ge v_i \ge v$
to all processes. Since $t_i' \ge {\sf GST}$, all correct processes
receive ${\tt WISH}(v_i')$ from $p_i$ no later than at
$t_i' + \delta \le \max(s, \ensuremath{\overline{{\sf GST}}}) + \delta$.
Consider an arbitrary correct process $p_j$ and let
$t_j \le \max(s, \ensuremath{\overline{{\sf GST}}}) + \delta$ be the earliest time by which
$p_j$ receives ${\tt WISH}(v_i')$ with with $v_i' \ge v$
from each correct processes $p_i$.
Thus, at $t_j$, the entries of all correct processes
in $p_j.{\sf max\_views}$ are occupied by views $\ge v$.
Since at least $2f+1$ entries in $p_j.{\sf max\_views}$ belong to correct processes,
the $(2f+1)$th highest entry is $\ge v$. Thus,
$p_j.{\sf view}(t_j) \ge v$. Since $p_j.{\sf view}$ is non-decreasing,
there exists a time $t_j' \le t_j$ at which $p_j.{\sf view}$ first became
$\ge v$. If $p_j.{\sf view}(t_j') = p_j.{\sf view}^+(t_j') = v$, then
$p_j$ enters $v$ at $t_j'$. Otherwise, either
$p_j.{\sf view}(t_j') > v$ or $p_j.{\sf view}^+(t_j') > v$.
Since both $p_j.{\sf view}$ and $p_j.{\sf view}^+$ are non-decreasing,
$p_j$ will never enter $v$ after $t_j'$. Thus, a correct process cannot
enter $v$ after $\max(s, \ensuremath{\overline{{\sf GST}}}) + \delta$. Since
by the lemma's premise, some correct process does enter $v$,
$\tl{v} \le \max(s, \ensuremath{\overline{{\sf GST}}}) + \delta$, as needed.\qed
\smallskip
\smallskip
The next lemma gives an upper bound on the duration of time a correct process
may spend in a view before sending a ${\tt WISH}$ for a higher view.
\begin{lemma}
Let $p_k$ be a correct process that enters a view $v$.
Then $p_k$ sends ${\tt WISH}(v_k)$ with $v_k \ge v+1$
no later than at $\taelast{v}$.
\label{lem:one-proc-after-tl}
\end{lemma}
{\em Proof.}
Suppose that $p_k$ enters a view $v > 0$ at time ${\sf GST} \le s_k \le \tl{v}$. Then
$$
p_k.{\sf view}(s_k) = p_k.{\sf view}^+(s_k) = v.
$$
By the definition of $\taelast{v}$, there exists a time $s_k'$ such that
$$
s_k \le s_k' \le \taelast{v},
$$
and at $s_k'$, $p_k$ either attempts to advance from $v$ or enters
a view $v' > v$.
If $p_k$ attempts to advance from $v$ at $s_k'$, then
$p_k$ sends ${\tt WISH}(v_k)$ with
$v_k = \max(p_k.{\sf view}(s_k')+1, p_k.{\sf view}^+(s_k'))$.
Since both $p_k.{\sf view}$ and $p_k.{\sf view}^+$ are non-decreasing,
we have $p_k.{\sf view}(s_k') \ge v$ and $p_k.{\sf view}^+(s_k') \ge v$.
Thus, $v_k \ge v + 1$, as required.
On the other hand, if $p_k$ enters a view $v' > v$
at $s_k'$, then $v' = p_k.{\sf view}(s_k') > p_k.{\sf view}(s_k) = v$
and therefore, $p_k.{\sf view}^+(s_k') \ge p_k.{\sf view}(s_k') \ge v+1$.
Since $p_k.{\sf view}^+$ is non-decreasing and $p_k.{\sf view}^+(s_k)=v$,
$p_k.{\sf view}^+$ must have changed its value from $v$ to
$v_k'' \ge v+1$ at some time $s_k''$ such that $s_k < s_k'' \le s_k'$. Thus, the condition
in line~\ref{line:cond-send5} holds at $s_k''$, which means
that $p_k$ sends ${\tt WISH}(v_k)$ with $v_k \ge v+1$ at $s_k''$.
Thus, in all cases,
$p_k$ sends ${\tt WISH}(v_k)$ with $v_k \ge v+1$ no later than at
$\max(\tl{v}, {\sf GST}) + \ensuremath{F}(v)$, as required.\qed
\smallskip
\smallskip
The next lemma bounds the time by which every correct process
either enters a view $v > 0$, or sends a ${\tt WISH}$ messages with
a view $> v$.
\begin{lemma}
Consider a view $v > 0$ such that some correct process enters $v$.
Then, for all times $t$, if $t \ge \max(\tm{v}, \ensuremath{\overline{{\sf GST}}})$, then
$\tl{v} \le t+2\delta$ and for all correct processes $p_k$,
if $p_k$ never enters $v$, then, by $\tl{v}$,
$p_k$ sends ${\tt WISH}(v_k)$ with $v_k \ge v+1$ to all processes.
\label{lem:all-send-wish1-generic:aux}
\end{lemma}
{\em Proof.}
Since $v>0$, $\tm{v}\mathpunct{\downarrow}$, and $t \ge \tm{v}$,
there exists a correct process $p_l$ such
that $p_l$ entered $v$ and $\te{l}{v} \le t$. By the view entry
condition, $p_l.{\sf view}(\te{l}{v}) = v$, and therefore
$p_l.{\sf max\_views}(\te{l}{v})$ includes $2f+1$ entries
$\ge v$. Since $f+1$ of these entries belong to correct processes,
there exists a set $C$ of $f+1$ correct processes $p_i$, each of which sent
${\tt WISH}(v_i)$ with $v_i\ge v$ to all processes before
$\te{l}{v} \le t$.
Since $t \ge \ensuremath{\overline{{\sf GST}}}$, by Lemma~\ref{lem:postgst},
$p_i$ sends ${\tt WISH}(v_i')$ with $v_i' \ge v_i \ge v$ sometime
between ${\sf GST}$ and $t$.
Since after ${\sf GST}$ every message sent by a correct process is received
by all correct processes within $\delta$ of its transmission,
the above implies that by $t + \delta$ every correct process receives a
${\tt WISH}(v_i')$ with $v_i' \ge v$ from each process $p_i \in C$.
Consider an arbitrary correct process $p_j$ and let $t_j \le t + \delta$ be the
earliest time by which $p_j$ receives ${\tt WISH}(v_i)$ with
$v_i \ge v$ from each process $p_i \in C$.
Thus, for all processes $p_i\in C$,
$p_j.{\sf max\_views}[i](t_j) \ge v$.
Since $|C|=f+1$, the $(f+1)$th highest entry in $p_j.{\sf max\_views}[i](t_j)$
is $\ge v$, and therefore, $p_j.{\sf view}^+(t_j) \ge v$.
Then each correct process $p_j$ sends ${\tt WISH}(v_j)$ with $v_j \ge v$ to all
correct processes no later than $t_j \le t + \delta$. Since
$t+\delta > t \ge \ensuremath{\overline{{\sf GST}}}$ and, and
some correct process entered $v$, by Lemma~\ref{lem:simple-bound-generic},
\begin{equation}\label{simple-bound-generic-app}
\tl{v} \le t + 2\delta.
\end{equation}
In addition, by Lemma~\ref{lem:postgst}, there exists a time
$t_j'$ such that ${\sf GST} \le t_j' \le t+\delta$ and $p_j$ sends ${\tt WISH}(v_j')$
with $v_j' \ge v_j \ge v$ at $t_j'$. Since a message sent by a correct
process after ${\sf GST}$ is received by all correct processes within $\delta$
of its transmission, all correct processes must have
received ${\tt WISH}(v_j')$ with $v_j' \ge v$ from each correct process
$p_j$ in-between ${\sf GST}$ and $t + 2\delta$.
Suppose that $p_k$ never enters $v$, and let $t_k$ be
the earliest time $\ge {\sf GST}$ by which $p_k$ receives ${\tt WISH}(v_j')$
from each correct process $p_j$; we have $t_k \le t+2\delta$.
Since $v_j' \ge v$, and there are $2f+1$ correct processes,
$p_k.{\sf max\_views}(t_k)$ includes at least $2f+1$ entries $\ge v$.
Thus, $p_k.{\sf view}(t_k) \ge v$. Since $p_k$ never enters $v$,
we have either $p_k.{\sf view}^+(t_k) \ge p_k.{\sf view}(t_k) \ge v+1$
or $p_k.{\sf view}(t_k) = v \wedge p_k.{\sf view}^+(t_k) \ge v+1$.
Thus, $p_k.{\sf view}^+(t_k) \ge v + 1$ and
therefore, $p_k$ sends ${\tt WISH}(v_k)$ with $v_k\ge v+1$
by $t_k \le t+2\delta$, which combined with~(\ref{simple-bound-generic-app})
validates the lemma\qed
\smallskip
\smallskip
We are now ready to prove the SMR synchronizer performance
bounds.
\begin{theorem}
The SMR synchronizer in Figure~\ref{fig:sync} satisfies
Property~\ref{eq:gen-bounded-entry:main}.
\label{thm:gen-bounded-entry:main}
\end{theorem}
{\em Proof.}
Consider a view $v$ such that $\tm{v}\mathpunct{\downarrow}$, and let $t =
\max(\tm{v}, \ensuremath{\overline{{\sf GST}}})$. Since $\tam{0} < {\sf GST}$, by the definition of $\ensuremath{\overline{{\sf GST}}}$,
$\ensuremath{\overline{{\sf GST}}} = {\sf GST} + \rho$. Thus, $t = \max(\tm{v}, {\sf GST} + \rho)$. By
Lemma~\ref{lem:all-send-wish1-generic:aux}, $\tl{v} \le t + 2\delta =
\max(\tm{v}, {\sf GST} + \rho) + 2\delta$, as needed.\qed
\begin{theorem}
The SMR synchronizer in Figure~\ref{fig:sync} satisfies
Property~\ref{eq:lat-bound1:main}.
\label{thm:lat-bound1:main}
\end{theorem}
{\em Proof.}
Consider a view $v\ge 0$ such that $\tm{v+1}\mathpunct{\downarrow}$.
If $v=0$, then since we assume for all
correct processes $p_i$, $\tae{i}{0}\mathpunct{\downarrow}$, by Lemma~\ref{lem:one-proc-after-tl},
all correct processes send ${\tt WISH}(v')$ with $v' \ge 0$ to all processes
no later than at $\taelast{0}$. Thus, by Lemma~\ref{lem:simple-bound-generic},
$\tl{1} \le \max(\taelast{0}, \ensuremath{\overline{{\sf GST}}}) + \delta$.
If $\tam{0} < {\sf GST}$, then $\ensuremath{\overline{{\sf GST}}} = {\sf GST} + \rho$, and therefore,
$\tl{1} \le \max(\taelast{0}, {\sf GST} + \rho) + \delta$. Otherwise,
$\ensuremath{\overline{{\sf GST}}} = \tam{0} \le \taelast{0}$, so that
$\tl{1} \le \taelast{0} + \delta$. Thus, the theorem holds
for $v=0$.
Suppose that $v>0$.
Since some correct process enters $v+1$,
by Proposition~\ref{sync:noskip}, some correct process
enters view $v$ as well.
Consider a correct process $p_k$. If $p_k$ enters $v$,
then by Lemma~\ref{lem:all-send-wish1-generic:aux},
$\te{k}{v} \le \max(\tm{v}, \ensuremath{\overline{{\sf GST}}})+2\delta$, and therefore,
by Lemma~\ref{lem:one-proc-after-tl}, $p_k$ sends
${\tt WISH}(v_k)$ with $v_k \ge v+1$ no later than at
\begin{equation}
\taelast{v} > \max(\tm{v}, \ensuremath{\overline{{\sf GST}}})+2\delta.
\label{eq:taelast-max}
\end{equation}
On the other hand, if $p_k$ never enters $v$, then
by Lemma~\ref{lem:all-send-wish1-generic:aux}, $p_k$
sends ${\tt WISH}(v_k)$ with $v_k \ge v+1$ than
at $\max(\tm{v}, \ensuremath{\overline{{\sf GST}}})+2\delta$. Thus, every correct process $p_k$
sends ${\tt WISH}(v_k)$ with $v_k \ge v+1$ no later than
$$
\max(\taelast{v}, \max(\tm{v}, \ensuremath{\overline{{\sf GST}}})+2\delta),
$$
which by~(\ref{eq:taelast-max}), implies that all correct
processes send a ${\tt WISH}$ message with a view $\ge v+1$
no later than $\taelast{v}$. Thus,
by Lemma~\ref{lem:simple-bound-generic}, we have
\begin{equation}
\tl{v+1} \le \max(\taelast{v}, \ensuremath{\overline{{\sf GST}}}) + \delta.
\label{eq:vplus1}
\end{equation}
If $\tam{0} < {\sf GST}$, then $\ensuremath{\overline{{\sf GST}}} = {\sf GST} + \rho$, and
therefore,~(\ref{eq:vplus1}) implies that
$\tl{v+1} \le \max(\taelast{v}, {\sf GST} + \rho) + \delta$, as required.
Otherwise, $\ensuremath{\overline{{\sf GST}}} = \tam{v} \le \taelast{v}$, which
by~(\ref{eq:vplus1}) implies that $\tl{v+1} \le \taelast{v} + \delta$,
validating the theorem.\qed
\smallskip
\smallskip
\paragraph{\rm\it Proof of Theorem~\ref{thm:smr-sync-correct}.}
Follows from Theorems~\ref{thm:smr-sync-correct2},~\ref{thm:gen-bounded-entry:main},
and~\ref{thm:lat-bound1:main}.\qed
\section{SMR Synchronizer Specification and Implementation}
\label{sec:sync}
We consider a synchronizer interface defined in~\cite{lumiere,NK20}, which here
we call an {\em SMR synchronizer}. Let ${\sf View} = \{1, 2, \ldots\}$ be the set of
{\em views}, ranged over by $v$; we use $0$ to denote an invalid initial view.
The synchronizer produces notifications ${\tt new\_view}(v)$ at a process, telling it
to {\em enter} view $v$. To trigger these, %
the synchronizer allows a process to call a function ${\tt advance}()$, which
signals that the process wishes to {\em advance} to a higher view. For
simplicity, we assume that a correct process does not call ${\tt advance}$ twice
without an intervening ${\tt new\_view}$ notification.
Our first contribution is the SMR synchronizer specification in
Figure~\ref{fig:multi-sync-properties}, which is simpler and more general than
prior proposals~\cite{lumiere,NK20} (see \S\ref{sec:related} for a
discussion). The specification relies on the following notation. Given a view
$v$ entered by a correct process $p_i$, we denote by $\te{i}{v}$ the time when
this happens; we let $\tm{v}$ and $\tl{v}$ denote respectively the earliest and
the latest time when some correct process enters $v$. %
We denote by $\ta{i}{v}$ the time when a correct process $p_i$ calls ${\tt advance}$
while in %
$v$, and let $\tam{v}$ and $\talast{v}$ denote respectively the earliest and the
latest time when this happens.
Given a partial function $f$, we write $f(x)\mathpunct{\downarrow}$ if $f(x)$ is defined, and
$f(x)\mathpunct{\uparrow}$ if $f(x)$ is undefined. Thus, $\tm{v}\mathpunct{\downarrow}$ means that some
correct process enters %
$v$, and $\tm{v}\mathpunct{\uparrow}$ that no correct process enters $v$.
The Monotonicity\xspace property in Figure~\ref{fig:multi-sync-properties} ensures
that views can only increase at a given process. Validity\xspace ensures that a
process may only enter a view $v+1$ if some correct process has called
${\tt advance}$ in $v$. This prevents faulty processes from disrupting the system by
forcing view changes. As a corollary of Validity\xspace we can prove that, if a
view $v'$ is entered by some correct process, then so are all the views $v$
preceding $v'$.
\vspace{1pt}
\begin{proposition}\label{sync:noskip}
$\forall v, v'.\, 0 < v < v' \wedge {\tm{v'}\mathpunct{\downarrow}} {\implies} {\tm{v}\mathpunct{\downarrow}}
\wedge \tm{v} < \tm{v'}$.
\end{proposition}
\vspace{1pt}
{\em Proof.}
Fix $v' \ge 2$ and assume that a correct process enters $v'$, so that
$\tm{v'}\mathpunct{\downarrow}$. We prove by induction on $k$ that
$\forall k=0..(v'-1).\, {\tm{v'-k}\mathpunct{\downarrow}} \wedge \tm{v'-k} \le \tm{v'}$. The base
case of $k=0$ is trivial. For the inductive step, assume that the required holds
for some $k$. Then by Validity\xspace there exists a time
$t < \tm{v'-k}$ at which some correct process $p_j$ attempts to advance from
$v'-k-1$. But then $p_j$'s view at $t$ is $v'-k-1$. Hence, $p_j$ enters $v'-k-1$
before $t$, so that $\tm{v'-k-1} < t < \tm{v'-k} \le \tm{v'}$, as required.\qed
\smallskip
Bounded Entry\xspace ensures that if some process enters view $v$, then
all correct processes will do so within at most $d$ units of time of each other
($d = 2\delta$ for our %
implementation). This only holds if
within $d$ no process attempts to advance to a higher view, as this
may make some processes skip $v$ and enter a higher view directly.
Bounded Entry\xspace also holds only starting from some view $\mathcal{V}$, since
a synchronizer may not be able to guarantee it for views entered before ${\sf GST}$.
\begin{figure}[t]
\setlength{\leftmargini}{10pt}
\renewcommand{\labelenumi}{\theenumi.}
\begin{enumerate}
\item\label{sync:local-order}
{\bf Monotonicity.} A process enters increasing views:
$\forall i, v, v'.\, {\te{i}{v}\mathpunct{\downarrow}} \,\wedge\,
{\te{i}{v'}\mathpunct{\downarrow}} \,{\implies}\, (v < v' \,{\iff}\, \te{i}{v} < \te{i}{v'})$
\vspace{2pt}
\item\label{sync:enter-attempt}
{\bf Validity.} A process may only enter a view $v+1$ if some correct process
has attempted to advance from $v$:\\[1pt]
$\forall i, v.\, {\te{i}{v+1}\mathpunct{\downarrow}} \,{\implies}\, {\tam{v}\mathpunct{\downarrow}} \,\wedge\,
\tam{v} < \te{i}{v+1}$
\vspace{2pt}
\item\label{sync:2delta} {\bf Bounded Entry.} For some $\mathcal{V}$ and
$d$, %
if a process enters a view $v\ge\mathcal{V}$ and no process attempts to advance to a
higher view within time $d$,
then all correct processes will enter $v$ within $d$:\\[1pt]
$\exists \mathcal{V}, d.\, \forall v \ge \mathcal{V}.\, {\tm{v}\mathpunct{\downarrow}} \,\wedge\, \neg(\tam{v} <
\tm{v} + d) \,{\implies} (\forall p_i \in \mathcal{C}.\, {\te{i}{v}\mathpunct{\downarrow}})
\,\wedge\, (\tl{v} \le \tm{v}+d)$
\vspace{2pt}
\item\label{sync:enter1}
{\bf Startup.} Some correct process will enter view $1$ if $f+1$ processes call ${\tt advance}$:\\[1pt]
$(\exists P \subseteq \mathcal{C}.\, |P| = f+1 \,\wedge\, (\forall p_i \in P.\,
{\ta{i}{0}\mathpunct{\downarrow}})) \,{\implies}\, {\tm{1}\mathpunct{\downarrow}}$
\vspace{2pt}
\item\label{sync:liveness} {\bf Progress.} If a correct process enters a view
$v$ and, for some set $P$ of $f+1$ correct processes, any process in $P$ that
enters $v$ eventually calls ${\tt advance}$, then some correct process will
enter view $v+1$:\\[1pt]
$\forall v.\, {\tm{v}\mathpunct{\downarrow}} \,\wedge\, (\exists P \subseteq \mathcal{C}.\, |P| =
f+1 \,\wedge\, (\forall p_i \in P.\, {\te{i}{v}\mathpunct{\downarrow}} \,{\implies}\,
{\ta{i}{v}\mathpunct{\downarrow}})) \,{\implies}\, {\tm{v+1}\mathpunct{\downarrow}}$
\end{enumerate}
\vspace{-7pt}
\caption{SMR synchronizer specification.}
\label{fig:multi-sync-properties}
\end{figure}
\begin{wrapfigure}[9]{l}{.28\textwidth}
\vspace{-16pt}
\begin{algorithm*}[H]
\setcounter{AlgoLine}{0}
\SubAlgo{\textbf{when the process starts or {\sf timer}\ expires}}{\label{line3:timer-exp1}
{\tt advance}();
}
\smallskip
\SubAlgo{{\bf upon} ${\tt new\_view}(v)$}{
$\ensuremath{{\tt stop\_timer}}({\sf timer})$\; \label{line3:timer-stop}
$\ensuremath{{\tt start\_timer}}({\sf timer}, \tau)$;\!\!\!\!\!\!\!\!\!\! \label{line3:start-timer}
}
\end{algorithm*}
\vspace{-9pt}
\caption{A simple client of\\ an SMR synchronizer.}
\label{fig:toy}
\end{wrapfigure}
Startup\xspace ensures that some correct process enters view $1$ if $f+1$ processes
call ${\tt advance}$. Given a view $v$ entered by a correct process, Progress\xspace
determines conditions under which some correct process will enter the next view
$v+1$. This will happen if for some set $P$ of $f+1$ correct processes, any
process in $P$ entering $v$ eventually calls ${\tt advance}$. Note that even a
single ${\tt advance}$ call at a correct process {\em may} lead to a view switch
(reflecting the fact that in implementations faulty processes may help this
correct process). Startup\xspace and Progress\xspace ensure that the synchronizer {\em must}
switch if at least $f+1$ correct processes ask for this. We now illustrate a
typical pattern of their use, which we later apply to PBFT
(\S\ref{sec:liveness}). To this end, we consider a simple client in
Figure~\ref{fig:toy}, where in each view a process sets a timer for a fixed
duration $\tau$ and calls ${\tt advance}$ when the timer expires. Using Startup\xspace and
Progress\xspace we prove that this client keeps switching views forever as follows.
\begin{proposition}
In any execution of the client in Figure~\ref{fig:toy}:
$\forall v.\, \exists v'.\, v'>v \wedge {\tm{v'}\mathpunct{\downarrow}}$.
\label{lem:live-toy}
\end{proposition}
{\em Proof.} Since all correct processes initially call ${\tt advance}$, by
Startup\xspace some correct process eventually enters view $1$. Assume now that the
proposition is false, so that there is a maximal view $v$ entered by any correct
process. Let $P$ be any set of $f+1$ correct processes and consider an arbitrary
process $p_i \in P$ that enters $v$. When this happens, $p_i$ sets the ${\sf timer}$
for the duration $\tau$. The process then either calls ${\tt advance}$ when ${\sf timer}$
expires, or enters a new view $v'$ before this. In the latter case $v' > v$ by
Monotonicity\xspace, which is impossible. Hence, $p_i$ eventually calls
${\tt advance}$ while in $v$. Since $p_i$ was chosen arbitrarily,
$\forall p_i \in P.\, {\te{i}{v}\mathpunct{\downarrow}} {\implies} {\ta{i}{v}\mathpunct{\downarrow}}$. Then by
Progress\xspace we get $\tm{v+1}\mathpunct{\downarrow}$, yielding a contradiction.\qed
\smallskip
\smallskip
Similarly to Figure~\ref{fig:toy}, we can use an SMR synchronizer satisfying the
properties in Figure~\ref{fig:multi-sync-properties} to implement a {\em
consensus synchronizer}~\cite{bftlive,NK20} without extra overhead. This lacks
an ${\tt advance}$ call and provides only the ${\tt new\_view}$ notification, which it
keeps invoking at increasing intervals so that eventually the there is a view
long enough for the consensus protocol running on top to decide. We obtain a
consensus synchronizer if in Figure~\ref{fig:toy} we propagate the ${\tt new\_view}$
notification to the consensus protocol and set the ${\sf timer}$ to an unboundedly
increasing function of views instead of a constant $\tau$. In
\tr{\ref{sec:single-shot}}{A} we show that the resulting consensus
synchronizer satisfies the specification proposed in~\cite{bftlive}.
\subsection{A Bounded-Space SMR Synchronizer}
\label{sec:sync-impl}
We now present a bounded-space algorithm that implements the %
specification in Figure~\ref{fig:multi-sync-properties} under partial synchrony
for $d=2\delta$.
Our implementation reuses algorithmic techniques from a consensus synchronizer
of Bravo et al.~\cite{bftlive}. However, it supports a more general abstraction,
and thus requires a more intricate correctness proof and latency analysis
(\S\ref{sec:sync-bounds}).
\begin{figure}[t]
\vspace{3pt}
\begin{tabular}{@{\ }l@{\ }|@{\quad\ }l@{}}
\scalebox{0.96}{%
\begin{minipage}[t]{7cm}
\let\@latex@error\@gobble
\vspace*{-10pt}
\begin{algorithm*}[H]
\setcounter{AlgoLine}{0}
\SubAlgo{\Fun{} {\tt advance}()}{\label{line:timer-exp1}
\Send ${\tt WISH}(\max({\sf view}+1, {\sf view}^+))$ \KwTo \ {\bf all}\;\label{line:send2}
${\sf advanced} \leftarrow \text{\sc true}$\; \label{line:advance-true}
}
\smallskip
\smallskip
\smallskip
\smallskip
\SubAlgo{\textbf{periodically}}{\label{line:retransmit-start}
\uIf{${\sf advanced}$}{\label{line:start-guard}
\Send ${\tt WISH}(\max({\sf view}+1, {\sf view}^+))$ \KwTo \ {\bf all}\;\label{line:send4}
}
\ElseIf{${\sf view}^+ > 0$}{
\Send ${\tt WISH}({\sf view}^+)$ \KwTo \ {\bf all}\;\label{line:send3}
}
}
\end{algorithm*}
\vspace*{-4pt}
\end{minipage}}
&
\scalebox{0.95}{%
\begin{minipage}[t]{9cm}
\let\@latex@error\@gobble
\vspace*{-11pt}
\begin{algorithm*}[H]
\SubAlgo{\WhenReceived ${\tt WISH}(v)$ {\bf from $p_j$}}{
$\textit{prev\_v}, \textit{prev\_v}^+ \leftarrow {\sf view}, {\sf view}^+$\;
\lIf{$v > {\sf max\_views}[j]$}{${\sf max\_views}[j] \leftarrow v$\label{line:update-maxviews}}
${\sf view} \ \ \leftarrow \max\{v \mid \exists k.\, {\sf max\_views}[k] = v \wedge{}$\label{line:update-view}\\
\renewcommand{\nl}{\let\nl\oldnl}\hspace{2.4cm}$|\{j \mid {\sf max\_views}[j] \ge v\}| \ge 2f+1\}$\;
${\sf view}^+ \leftarrow \max\{v \mid \exists k.\, {\sf max\_views}[k] = v \wedge {}$\label{line:update-viewp}\\
\renewcommand{\nl}{\let\nl\oldnl}\hspace{2.4cm}$|\{j \mid {\sf max\_views}[j] \ge v\}| \ge f+1\}$\;
\If{${\sf view}^+ = {\sf view} \wedge {\sf view} > \textit{prev\_v}$}{\label{line:enter-condition}
\Trigger ${\tt new\_view}({\sf view})$;\ \ \label{line:trigger-newview}
${\sf advanced} \leftarrow \text{\sc false}$\; \label{line:advance-false}
}
\lIf{${\sf view}^+ > \textit{prev\_v}^+$\label{line:cond-send5}}
{\Send ${\tt WISH}({\sf view}^+)$ \KwTo \ {\bf all}\label{line:send5}}
}
\end{algorithm*}
\vspace*{-4pt}
\end{minipage}}
\end{tabular}
\vspace*{-5pt}
\caption{A bounded-space SMR synchronizer. The periodic handler fires every
$\rho$ units of time. All counters are initially $0$.}
\label{fig:sync}
\end{figure}
When a process calls ${\tt advance}$ (line~\ref{line:timer-exp1}), the synchronizer
does not immediately move to the next view $v'$, but disseminates a ${\tt WISH}(v')$
message announcing its intention. A process enters a new view once it
accumulates a sufficient number of ${\tt WISH}$ messages supporting this. A naive
synchronizer design could follow %
Bracha broadcast~\cite{random-bracha}: enter a view $v'$ upon receiving $2f+1$
${\tt WISH}(v')$ messages, and echo ${\tt WISH}(v')$ upon receiving $f+1$ copies thereof;
the latter is needed to combat equivocation by Byzantine processes. However, in
this case the process would have to track all newly proposed views for which
$< 2f+1$ ${\tt WISH}$es have been received.
Since messages sent before ${\sf GST}$ can be lost or delayed, this would require
unbounded space. To reduce the space complexity, in our algorithm a process only
remembers the highest view received from each process, kept in an array
${\sf max\_views} : \{1,\ldots, n\} \rightarrow {\sf View} \cup \{0\}$
(line~\ref{line:update-maxviews}). This array is then used to compute variables
${\sf view}$ and ${\sf view}^+$, which respectively hold the $(2f\,{+}\,1)$st highest and
the $(f\,{+}\,1)$st highest views in ${\sf max\_views}$
(lines~\ref{line:update-view}-\ref{line:update-viewp}).
These variables never decrease and always satisfy ${\sf view} \le {\sf view}^+$.
The process enters the view stored in the ${\sf view}$ variable when this variable
increases (lines~\ref{line:enter-condition}-\ref{line:trigger-newview}).
A process thus enters a view $v$ only if it receives $2f+1$ ${\tt WISH}$es for views
$\ge v$,
and a process may be forced to switch views even if it did not call ${\tt advance}$;
the latter helps lagging processes to catch up.
The variable ${\sf view}^+$ increases when the process receives $f+1$ ${\tt WISH}$es for
views $\ge{\sf view}^+$, and thus some correct process wishes to enter a new view
$\ge{\sf view}^+$. In this case the process echoes ${\sf view}^+$ (line~\ref{line:send5}),
to help processes switch views and satisfy Bounded Entry and Progress.
The guard ${\sf view}^+ = {\sf view}$ in line~\ref{line:enter-condition} ensures that a
process does not enter a ``stale'' view such that another correct process
already wishes to enter a higher one. Similarly, when the process calls
${\tt advance}$, it sends a ${\tt WISH}$ for the maximum of ${\sf view}+1$ and ${\sf view}^+$
(line~\ref{line:send2}). Thus, if ${\sf view} = {\sf view}^+$, so that the values of the
two variables have not changed since the process entered the current view, then
the process sends a ${\tt WISH}$ for the next view (${\sf view}+1$). Otherwise,
${\sf view} < {\sf view}^+$, and the process sends a ${\tt WISH}$ for the higher view ${\sf view}^+$.
Finally, to deal with message loss before ${\sf GST}$, a process retransmits the
highest ${\tt WISH}$ it sent every $\rho$ units of time, according to its local clock
(line~\ref{line:retransmit-start}). Depending on whether the process has called
${\tt advance}$ in the current view (tracked by the {\sf advanced}{} flag), the ${\tt WISH}$
is computed as in lines~\ref{line:send5} or~\ref{line:send2}.
Our SMR synchronizer requires only $O(n)$ variables for storing
views. Proposition~\ref{sync:noskip} also ensures that views entered by correct
processes %
do not skip values. Thus, although the individual view values stored by the
synchronizer are unbounded, Proposition~\ref{sync:noskip} limits the power of
the adversary to exhaust their allocated space, similarly to~\cite{BazziD04}.
\subsection{SMR Synchronizer Correctness and Latency Bounds}
\label{sec:sync-bounds}
The following theorem (proved in \tr{\ref{sec:proof-sync}}{B})
states the correctness of our synchronizer as well as and its performance
properties. In \S\ref{sec:latency} we apply the latter to bound the latency of
Byzantine SMR protocols.
Given a view $v$ that was entered by a correct process $p_i$, we let
$\tae{i}{v}$ denote the time at which $p_i$ either attempts to advance from $v$
or enters a view $>v$; we let $\taelast{v}$ denote the latest time when a
correct process does so.
We assume that every correct process eventually attempts to advance
from view $0$ unless it enters a view $>0$, i.e.,
$\forall p_i \in \mathcal{C}.\, \tae{i}{0}\mathpunct{\downarrow}$.
\begin{theorem}
\label{thm:bounds}
Consider an execution with an eventual message delay $\delta$. In this
execution, the algorithm in Figure~\ref{fig:sync} satisfies the properties in
Figure~\ref{fig:multi-sync-properties} for $d=2\delta$ and
$\mathcal{V} = \max\{v \mid ({\tm{v}\mathpunct{\downarrow}} \,\wedge\, \tm{v} < {\sf GST} + \rho) \vee v=0\} + 1$
if $\tam{0} < {\sf GST}$, and $\mathcal{V} = 1$, otherwise.
Furthermore, the algorithm also satisfies the following:
{\renewcommand{\theenumi}{\Alph{enumi}}
\renewcommand{\labelenumi}{\theenumi.}
\begin{enumerate}
\item \label{eq:gen-bounded-entry:main}
$\forall v.\, {\tm{v}\mathpunct{\downarrow}} \,\wedge\, \tam{0} < {\sf GST} \,{\implies}\,
\tl{v} \le \max(\tm{v}, {\sf GST}+\rho) + 2\delta$.
\vspace{4pt}
\item \label{eq:lat-bound1:main}
$\forall v.\, {\tm{v+1}\mathpunct{\downarrow}} \,{\implies}\,
\tl{v+1} \le
\begin{cases}
\max(\taelast{v}, {\sf GST} + \rho) + \delta,& \text{if } \tam{0} < {\sf GST};\\[-1pt]
\taelast{v} + \delta,& \text{otherwise.}
\end{cases}
$
\end{enumerate}
}
\label{thm:smr-sync-correct}
\end{theorem}
The theorem gives a witness for $\mathcal{V}$ in Bounded Entry\xspace: it is the
next view after the highest one entered by a correct process at or before
${\sf GST}+\rho$ (or $1$ if no view was entered).
Property~\ref{eq:gen-bounded-entry:main} bounds the latest time any correct
process can enter a view that has been previously entered by a correct
process. It is similar to Bounded Entry\xspace, but also handles views $< \mathcal{V}$.
Property~\ref{eq:lat-bound1:main} refines Progress\xspace: while the latter guarantees
that the synchronizer will enter $v+1$ if enough processes ask for this, the
former bounds the time by which this will happen. We explain the use of these
properties in \S\ref{sec:latency}.
\section{Additional Case Studies}
\label{sec:xbft}
To demonstrate the generality of the SMR synchronizer abstraction, we have also
used it to ensure the liveness of two other protocols. First, we handle a
variant of PBFT that periodically forces a leader change, as is common in modern
Byzantine SMR~\cite{aardvark,spinning,mirbft}. In this protocol a process calls
${\tt advance}$ not only when it suspects the current leader to be faulty, but also
when it delivers $B$ values proposed by this leader (for a fixed $B$). This
changes the censorship-resistance mechanism, which can now exploit the fact that
the protocol will keep encountering correct leaders.
Second, we have applied the SMR synchronizer %
to a variant of the above protocol that follows the approach of
HotStuff~\cite{hotstuff}. The resulting protocol adds an extra communication
step to the normal path of PBFT in exchange for reducing the communication
complexity of leader change. Due to space constraints, we defer the details
about these two protocols to \tr{\ref{sec:pbft-rotation}}{D} and
\tr{\ref{sec:hotstuff}}{\npbfthotstuff}. Their liveness proofs follow the
methodology we proposed for PBFT-light\xspace, establishing analogs of
Lemmas~\ref{thm:castro:completeness}-\ref{thm:castro:timers}.
For PBFT with periodic leader rotation we have also established latency bounds
when using the synchronizer in Figure~\ref{fig:sync} (see
\tr{\ref{sec:pbft-rotation}}{D}). The most interesting one, stated
informally below, demonstrates the benefit of PBFT's mechanism for adapting
timeouts to an unknown $\delta$: recall that in PBFT a process only increases
its timeouts when a timer expires, which means that the current view does not
operate normally (\S\ref{sec:pbft}). The bound assumes that the protocol
executes during a synchronous period, all views up to $v$ operate normally, and
the leader of $v$ is faulty (for simplicity, just crashed). The bound then
quantifies how quickly the protocol switches to the next view $v+1$. Since in
PBFT processes do not increase timeouts in good views, they pay a minimal
latency penalty once they encounter a bad leader -- the initial value of
${\sf dur\_recovery}$. This contrasts with the simplistic way of adapting the
timeouts to an unknown $\delta$ by increasing them in every view: in this case,
as the protocol keeps changing views, the timeouts would eventually increase up
to the maximum (determined by $\Delta$), and the protocol would have to wait
that much to recover from a faulty leader.
\begin{theorem}[\it informal]
Assume that all correct processes start executing PBFT with leader rotation
after ${\sf GST}$, and consider a view $v$ such that ${\sf leader}(v)$ is initially
crashed. Suppose that in each view $v' < v$ all correct processes deliver $B$
values proposed by the leader of this view. Then
$\tl{v+1} \le \tl{v} + R + \delta$, where $R$ is the initial value of
${\sf dur\_recovery}$.
\label{thm:pbftr-latency2-informal}
\end{theorem}
|
{'timestamp': '2022-02-15T02:43:38', 'yymm': '2202', 'arxiv_id': '2202.06679', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06679'}
|
arxiv
|
\section{Introduction}
\label{sec:intro}
\vspace{-2mm}
Human activity recognition (HAR) has been a popular field of interest among the research community. Due to its relatively accurate performance and high utility, HAR has found its way into several consumer products for noncritical use cases. These products, equipped with inertial motion unit (IMU) sensors, include mobile devices and wearable devices such as smart watches and wristbands. The devices use a combination of in-device processing and cloud services to produce information about the physical activity of the user, providing them with different context-adaptive services.
Developing robust classifiers for detecting multiple activities is a challenging task that requires large amounts of labelled training data. The typical setup for obtaining this data is based on recording the IMU signals and labelling them in (semi) controlled sessions from multiple subjects, an approach that can be extremely laborious and presents serious limitations. On the other hand, video sharing platforms, such as YouTube, contain huge amounts of videos from various kinds of human physical activities, and they are usually easier to label based on their metadata or by simple visual inspection. Transforming this video information into a representation that could be directly used as a training material for IMU based classifers would enable access to enormous amounts of annotated training data, potentially improving the robustness of IMU-based HAR.
To directly use this video material for IMU-based activity classifiers, it must be transformed into IMU-like signals. In this paper, we show how extracting human movement from activity videos using pose estimation approaches produces signals that can be transformed into a representation that is directly usable by IMU-based classifiers. Our approach is based on a neural network model that uses a simple architecture to transform a sequence of 2D pose estimates from videos into realistic features equivalent to those obtained solely with IMU-signals. In addition, we show how the same neural network architecture could be used to extract the raw IMU-like signals themselves, by changing only the last layer. In this work, we concentrate solely on the acceleration signal, since it is the one predominantly used in HAR, but the method presented can be easily extended to other components of the IMU such as the magnetometer and gyroscope signals.
\vspace{-2mm}
\section{Related work}
\vspace{-2mm}
Although it is becoming relatively usual in visual computing \cite{augmentingVisualComputing} and computer vision tasks \cite{augmentingComputerVision} (including pose estimation \cite{augmentingPoseEstimation}), using augmented, synthetic or generated data in IMU-based HAR has not yet been fully explored. A few small attempts at creating generated training data have been made. They include simulating different sensor positions and orientations using signal rotations \cite{augmentingSensorOrientation}, augmenting spectral data in the feature space \cite{augmentingHAR} or generating extra data by extrapolating time series \cite{augmentingTimeSeries}. All these approaches have presented mixed success and applicability, since the original labelled material used to derive the augmentations was still very limited \cite{limitedSensorData}.
In our work we aim at generating virtual sensor signals and features using only video sequences of human activities, a type of data that is abundant and easy to label. The closest work to ours is the one presented by Rey \textit{et al.} \cite{similarRey}. They experimented with the generation of sensor readings from monocular videos. Their approach is based on a regression model that predicts the total acceleration signal by using a sequence of pose estimates as an input of a typical residual convolutional network. The quality of their resulting signals is evaluated in a relatively simple activity recognition dataset using a classifier based on temporal convolutional blocks (TCN). Our approach aims instead at creating full training sets by generating sensor data directly from activity videos. We propose a U-net topology \cite{ronneberger2015u} to predict both individual feature values that could be directly used by an activity classifier, and 3-axis raw acceleration signals that can be directly compared to the original ones.
\vspace{-4mm}
\section{Experimental setup}
\vspace{-2mm}
To evaluate our approach, we performed our experimental analysis on the VTT-ConIoT dataset \cite{Zenodo}\cite{VTT-ConIot}. This dataset recorded video data for 13 persons performing 15 different construction work-related activities for one minute. The subjects were wearing three IMU-sensors at 100Hz. (located on the hip and near the left shoulder) 100 Hz sampling rate. The dataset provides synchronized IMU and video signals.
In this work, we concentrate on the original dataset protocol described as the \textit{simple baseline}. This protocol defines six classes representing typical tasks in the construction setup: Cleaning, Climbing, Floor Work, Painting, Walking and working with Hands Up. Figure \ref{fig:activities} depicts and example frame of each of the tasks. In this setup, each 1-minute signal is segmented into sliding 2-second windows that are used as "activity samples" in both training and test sets. The performance is evaluated by constructing a model based on 7 different features (average, median, variance, mean, max, min, upper quartile and lower quartile) which are roughly based on the prior knowledge of their usability in the human activity. The features are calculated over 4 different signals obtained from the IMU placed on the hip (3-axis accelerometer, \textit{x,y,z} , and the total acceleration \textit{tot}), for a total of 28 features per sample. The cross-validation setup is Leave-one-subject-out (LOSO).
\begin{figure}[h]
\centering{\includegraphics[width=90mm]{activities.png}}
\vspace{-5mm}
\caption{Example of the 6-activity setup from the VTT-ConIot dataset. From left to right: Cleaning, Climbing, Floor Work, Painting, Walking and Hands Up}
\label{fig:activities}
\vspace{-5mm}
\end{figure}
\section{Acceleration extraction from monocular videos}
\vspace{-2mm}
Processing videos to obtain a sequence of poses could provide some of the required positional information to estimate the acceleration of a human articulation or joint. Available open source pose estimation models include OpenPose \cite{openpose}, DeepPose \cite{deeppose} and Detectron2 \cite{detectron2}. Human pose information from monocular videos is essentially two-dimensional and expressed in absolute terms depending on the camera position, acquired at rates from 15 to 60 fps. On the other hand, IMU-based acceleration signals are three-dimensional (\textit{x,y,z}) and related to the position of the sensor itself, and they are recorded at much higher rates (50-150 Hz.). This calls for a preprocessing stage that allows us to match both signals.
The video preprocessing starts by extracting the human poses from each individual frame using a state-of-the-art human pose detector (Detectron2 \cite{detectron2}), which provides us with poses composed of 17 keypoints that represent articulations in the human body, in a usual format \cite{COCO}.
We estimate the body center by interpolating between two keypoints located on both sides of the hip, the closest point to the IMU-sensor location (lower back center). This body position was selected as a reference point used in the experiments. To obtain a third spatial dimension of the point, we estimate the Z-coordinate using the size of the projected pose, since poses closer to the camera will look larger and poses far from the camera will look smaller. This distance was estimated by using the maximum and minimum size values of the dataset for each individual while standing (respectively, closer and farther distances to the camera), which allowed us to estimate the height of the subject and normalize the size according to it.
These coordinates represent the spatial displacements of the subjects while performing activities. We computed 3-axis accelerations of the reference point by calculating the second derivative of the coordinates across frames. This resulted in acceleration signals in the video coordinate space. This signal was then further processed with a low-pass filtering with a cut-off frequency of 12 Hz, to eliminate the high-frequency noise introduced by the pose estimation jittering and human detection errors.
Similarly, to match the characteristics of the acceleration signal obtained from the videos, the acceleration signals obtained from the real IMU-sensors were downsampled to 25 Hz (to match the video frame rate) and then low-pass filtered at 12Hz. This bandwidth reduction has shown to not affect the HAR classification process, since human activities do not present frequencies over 20 Hz, while most discriminative components are well below 6Hz \cite{frequencyHAR}\cite{frequency2HAR}.
\section{Transformation model}
\vspace{-2mm}
The model used in the transformation between the pose estimation and IMU-like signals and features is based on the U-net topology \cite{ronneberger2015u} and consists of an encoder, decoder and skip-connections between layers that have feature maps of similar size. U-net has been previously used successfully in e.g., image segmentation tasks. The structure of the model used in the experiments is presented in Figure \ref{fig:model}. First, three convolutional blocks of the model (encoder) perform down-sampling on the data (on the left hand side of figure) while the next three blocks perform up-sampling (decoder). The down- and up-sampling blocks are connected with lateral skip connections that provide additional information for the convolutional/upsampling blocks. All our transformation models use the same architecture, with the exception of the output layer. This layer of the model is set as a 1-dimensional convolution layer for the generation of raw signals and as a fully connected layer for the generation of individual features. The selected optimizer is based on Adadelta's default parameters in \textit{keras.io}, using mean-absolute-error as the loss function. Each model was trained for 250 epochs with an early stopping configuration.
\begin{figure}[ht]
\centering{\includegraphics[width=60mm]{model3.png}}
\vspace{-2mm}
\caption{Structure of the model used in the transformation. Output layers: 1-D convolutional filter for raw signals, fully connected layer for ndividual features.}
\label{fig:model}
\vspace{-2mm}
\end{figure}
\section{Generation of virtual sensor signals}
\vspace{-2mm}
As a first step to use the generated data into HAR classifiers, we experiment with the generation of raw signals from the components obtained from video data. In this context, we generate a set of 2-second segments with 1-second overlap of the raw signals corresponding to (\textit{x,y,z}) axes and the total acceleration in an independent manner, constructing one transformation model per signal that follows the description detailed in the previous section.
To evaluate the correctness of these generated signals, we simply compare each segment belonging to the real and the generated ones, by computing the errors measured sample by sample along the segment. The errors are then expressed in terms of Mean Squared Error (MSE). The errors of the signal generation in comparison with the real IMU-based ones are depicted in Table \ref{tab:signals}.
\begin{table}[h]
\small
\centering
\vspace{-1mm}
\caption{Average MSE for each window and activity }
\label{tab:signals}
\begin{tabular}{|l|c|c|c|c|c|c|c|}
\hline
Signal & \tiny Cleaning & \tiny Climbing & \tiny FloorWork & \tiny Painting & \tiny Walking & \tiny HandsUp & Mean \\ \hline
$x_{(t)}$ & 0.16 & 0.28 & 0.20 & 0.09 & 0.27 & 0.09 & 0.18 \\\hline
$y_{(t)}$ & 0.16 & 0.16 & 0.20 & 0.11 & 0.19 & 0.08 & 0.15 \\\hline
$z_{(t)}$ & 0.57 & 0.44 & 0.95 & 0.49 & 0.48 & 0.47 & 0.56 \\\hline
$tot_{(t)}$ & 0.13 & 0.26 & 0.07 & 0.07 & 0.29 & 0.07 & 0.15 \\\hline
\end{tabular}
\end{table}
The results show that we are able to generate reasonably accurate signals for each axis and for the total acceleration without clear differences among different activities. However, we can note that z-axis present a significantly larger error than the other signals. We hypothesize that this is due to the changes in the gravity direction, which for the typical sensor setup and a standing person, corresponds exactly to that axis. This can be defended by, for example observing that the activity \textit{FloorWork} shows the larger error, and it is the activity where the gravity direction has more distinct and constant change, since the subjects are crouched in an inclined position and do not stand up during the whole activity.
\section{Generation of virtual sensor features}
\vspace{-2mm}
The next step was to create models that are able to predict specific statistical features calculated from the IMU signal by using information obtained only from video data. These statistical features can then be directly used for HAR classification, without the need of creating accurate signals.
In this context, analogously to signal generation, we create a set of models whose output is a single value that corresponds to each IMU-feature as it is used by the classifiers. We output this value by changing in our architecture the last 1x1 convolutional layer to a fully connected layer that provides a single value per sample. The set of features is selected to correspond to the simple baseline of the VTT-ConIot dataset classification task~\cite{VTT-ConIot}. The set of models estimates seven statistical features: average \textit{(avg)}, median \textit{(med)}, variance \textit{(var)}, 25th percentile \textit{(lq)}, 75th percentile \textit{(uq)}, minimum \textit{(min)} and maximum \textit{(max)}. Each feature is computed in four different axes (\textit{x, y, z} and total acceleration \textit{(tot)} computed as the L2 norm of the axes). Each feature is estimated using 2-second segments, and the features were generated using leave-one-subject-out (LOSO) validation.
This process produced a vector with 28 feature values for each two second time widow. The mean-squared-errors of each generated feature in comparison to the real IMU feature values are shown in Table \ref{tab:mses}. \hfill\break
\begin{table}[h]
\small
\centering
\vspace{-2mm}
\caption{Average MSE for each feature and activity}
\begin{tabular}{|@{\hskip3pt}l@{\hskip3pt}|@{\hskip3pt}c|@{\hskip3pt}c|@{\hskip3pt}c|@{\hskip3pt}c|@{\hskip3pt}c|@{\hskip3pt}c|@{\hskip3pt}c|}
\hline
Feat & \tiny Cleaning & \tiny Climbing & \tiny FloorWork & \tiny Painting & \tiny Walking & \tiny HandsUp & Mean \\ \hline
$x_{avg}$ & 0.023 & 0.007 & 0.155 & 0.008 & 0.016 & 0.021 & 0.038 \\ \hline
$x_{med}$ & 0.026 & 0.008 & 0.144 & 0.008 & 0.016 & 0.024 & 0.038 \\ \hline
$x_{var}$ & 0.049 & 0.092 & 0.051 & 0.024 & 0.043 & 0.033 & 0.049 \\ \hline
$x_{lq}$ & 0.059 & 0.041 & 0.141 & 0.018 & 0.041 & 0.042 & 0.057 \\ \hline
$x_{uq}$ & 0.025 & 0.025 & 0.157 & 0.010 & 0.047 & 0.029 & 0.049 \\ \hline
$x_{min}$ & 0.226 & 0.607 & 0.261 & 0.105 & 0.197 & 0.137 & 0.256 \\ \hline
$x_{max}$ & 0.285 & 0.670 & 0.289 & 0.129 & 0.437 & 0.196 & 0.334 \\ \hline
$y_{avg}$ & 0.037 & 0.029 & 0.185 & 0.038 & 0.044 & 0.048 & 0.064 \\ \hline
$y_{med}$ & 0.043 & 0.027 & 0.183 & 0.041 & 0.037 & 0.047 & 0.063 \\ \hline
$y_{var}$ & 0.006 & 0.007 & 0.002 & 0.002 & 0.007 & 0.002 & 0.004 \\ \hline
$y_{lq}$ & 0.056 & 0.036 & 0.220 & 0.045 & 0.043 & 0.058 & 0.076 \\ \hline
$y_{uq}$ & 0.044 & 0.039 & 0.143 & 0.044 & 0.045 & 0.042 & 0.060 \\ \hline
$y_{min}$ & 0.200 & 0.378 & 0.345 & 0.090 & 0.331 & 0.145 & 0.248 \\ \hline
$y_{max}$ & 0.192 & 0.427 & 0.123 & 0.091 & 0.204 & 0.082 & 0.187 \\ \hline
$z_{avg}$ & 0.313 & 0.178 & 0.850 & 0.269 & 0.173 & 0.301 & 0.347 \\ \hline
$z_{med}$ & 0.307 & 0.168 & 0.829 & 0.298 & 0.127 & 0.286 & 0.336 \\ \hline
$z_{var}$ & 0.009 & 0.010 & 0.004 & 0.002 & 0.013 & 0.004 & 0.007 \\ \hline
$z_{lq}$ & 0.332 & 0.188 & 0.979 & 0.275 & 0.236 & 0.293 & 0.384 \\ \hline
$z_{uq}$ & 0.287 & 0.162 & 0.801 & 0.258 & 0.125 & 0.311 & 0.324 \\ \hline
$z_{min}$ & 0.428 & 0.586 & 1.229 & 0.313 & 0.614 & 0.361 & 0.589 \\ \hline
$z_{max}$ & 0.376 & 0.458 & 0.839 & 0.278 & 0.361 & 0.464 & 0.463 \\ \hline
$tot_{avg}$ & 0.008 & 0.008 & 0.004 & 0.003 & 0.027 & 0.007 & 0.010 \\ \hline
$tot_{med}$ & 0.006 & 0.007 & 0.004 & 0.003 & 0.022 & 0.008 & 0.008 \\ \hline
$tot_{var}$ & 0.028 & 0.074 & 0.014 & 0.011 & 0.045 & 0.018 & 0.032 \\ \hline
$tot_{lq}$ & 0.019 & 0.029 & 0.007 & 0.008 & 0.043 & 0.015 & 0.020 \\ \hline
$tot_{uq}$ & 0.025 & 0.030 & 0.010 & 0.012 & 0.075 & 0.015 & 0.028 \\\hline
$tot_{min}$ & 0.104 & 0.276 & 0.055 & 0.041 & 0.152 & 0.062 & 0.115 \\ \hline
$tot_{max}$ & 0.386 & 0.910 & 0.168 & 0.137 & 0.547 & 0.190 & 0.390 \\ \hline
Mean & 0.139 & 0.196 & 0.293 & 0.091 & 0.145 & 0.116 & 0.163 \\ \hline
\end{tabular}\vspace{-3mm}
\label{tab:mses}
\end{table}
The results show again that we are able to generate individual features with reasonable accuracy across different activities, without clear differences. Again, it can be observed that the generation of features in the z-axis is more challenging, especially for features that measure average or median values, while the variance error is similar to the one obtained for the other axes. We argue that our model is able to infer the energy and variations of the individual signals while obtaining its average values (that depend on the sensor orientation) is more difficult. These are to be expected since the input values obtained from the videos and poses do not provide any information on the gravity components or directions.
\vspace{-2mm}
\section{Classification of human activities}
\vspace{-2mm}
Finally, we evaluate the usability of the models and their generated features by using classifiers. For a fair comparison, we train three different classifiers using three different types of input data. The first classifier (IMU input) is trained using only real IMU data obtained from real sensors. According to the protocol described before, 28 features were calculated and standardized (by subtracting the mean and dividing with standard deviation) from the real IMU signals. These features are used to train a random forest classifier to classify six activities. A second classifier (Generated input) is trained by using the features generated from our previously described generation model that produced already standardized features. This classifier is trained on videos that do not include the subject in the testing. Finally, for comparative purposes, a third naive classifier (Video input) is trained by using the same type of standardized features that are directly computed from the accelerations corresponding to the poses in the videos, without an intermediate generation model.
We run inference on all three classifiers in the same way. For testing, we used only real IMU data from unseen subjects, and we strictly followed a leave-one-subject-out protocol where none of the trained models (both for generation and classification) had access to the test subject.The classifiers, trained with different data types (real, generated, and naive-video) are evaluated in terms of mean classification accuracy. Results for all three classifiers are shown in Table \ref{tab:loo}.
\begin{table}[ht]
\small
\centering
\vspace{-4mm}
\caption{LOSO validation results of different IMU classifiers.}
\begin{tabular}{|c|c|c|c|}
\hline
& Accuracy & Accuracy & Accuracy \\
Subject & IMU input & Generated input & Video input \\ \hline
S1 & 0.495 & 0.489 & 0.290 \\ \hline
S2 & 0.461 & 0.395 & 0.207 \\ \hline
S3 & 0.415 & 0.375 & 0.254 \\ \hline
S4 & 0.466 & 0.379 & 0.328 \\ \hline
S5 & 0.493 & 0.518 & 0.217 \\ \hline
S6 & 0.518 & 0.453 & 0.341 \\ \hline
S7 & 0.623 & 0.622 & 0.209 \\ \hline
S8 & 0.567 & 0.525 & 0.262 \\ \hline
S9 & 0.392 & 0.304 & 0.206 \\ \hline
S10 & 0.589 & 0.547 & 0.231 \\ \hline
S11 & 0.560 & 0.547 & 0.244 \\ \hline
S12 & 0.582 & 0.554 & 0.302 \\ \hline
S13 & 0.621 & 0.547 & 0.303 \\ \hline
\textbf{Mean} & \textbf{0.521} & \textbf{0.481} & \textbf{0.261} \\ \hline
\end{tabular}
\label{tab:loo}
\end{table}
The results clearly show the usefulness of the intermediate generation model. The classifier trained on only real IMU data, following the simple baseline of the dataset, obtains an accuracy of about 52\%, while the naive classifier trained directly from video pose coordinates and tested on real IMU-data achieves about half (26\%). However, the model trained with the intermediate feature generation model achieves a 48\% accuracy, a performance comparable to the classifier trained on real IMU data. We believe that these results show that our Video2IMU generation models are able to add IMU-like characteristics to the acceleration signal extracted from pose estimation coordinates, in a way that can generalize to unseen individuals.
\vspace{-2mm}
\section{Discussion}
\vspace{-2mm}
We have shown that a relatively simple transformation model to generate IMU-like signals and features from activity videos can be directly utilized to train HAR classifiers that can perform inference on real sensor data with reasonable accuracy.
Our selected setup uses a simple baseline where the short window size, reduced number of features, and a single sensor location (placed in the hip) presents a classification accuracy that is relatively low, even for the IMU-based classifier that uses real sensor data. We believe that this is not the optimal setup for recognizing certain activities where movement mostly occurs on the hands. Future work will focus on studying alternative sensor locations and the limits for the generalization of our generation method to unseen activities.
\bibliographystyle{IEEEbib}
|
{'timestamp': '2022-02-15T02:38:35', 'yymm': '2202', 'arxiv_id': '2202.06547', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06547'}
|
arxiv
|
\section{Introduction}
Virtual screening (VS) is a computational field that has emerged in the past two decades as an aid to conventional experimental drug discovery by using statistics to estimate unknown bio-interaction between compounds and biological targets, usually proteins\cite{wang_pairwise_2014}. VS is a search for compounds with a defined biological activity using a computation model. Molecular compounds are filtered through a progressive series of tests which determine their phyisio-chemical properties, bioactivity, effectiveness and toxicity for later stages of drug discovery process.
“With the emergence of supercomputers, we can analyze in more depth the natural laws of life on Earth, including the metabolic processes of complex diseases like cancer. We can analyze data obtained from high-throughput genomic and proteomic tools, solve systems with millions of linear equations, and analyze graphs that represent thousands of genes and proteins”\cite{tomic_evaluation_2018}.
There are numerous examples where drug discovery systems can be seen as complex adaptive systems with nonlinear emergent behaviour that is hard to predict\cite{schneider_novo_2016} due to its sensitivity to small structural modifications having hugely different effect (“activity cliff”) or unknown interdependencies and gene expression influences. This is inherently also a limitation and challenge for virtual screening methods, along with others that will be mentioned in this review.
Methods of virtual screening use structural models of compounds and target proteins, their physio-chemical properties, bioactivity and experimentally verified bio-interaction data to leverage predictive behavior.
Although the drug production process still remains expensive and time-consuming due to a high proportion of failures in clinical trials\cite{mullard_2020_2021} (in 2020. FDA didn’t approve 42\% of drugs for rare diseases and 58\% for substantial improvements for serious diseases) some impressive technological leaps were seen during the past few years. Mostly powered by artificial intelligence(AI) and ever-growing omics databases, new computational methods for early phase drug discovery that are developed will be presented in this article. One of key challenges in comparing different AI methods is lack of universal benchmarking datasets by which the scientific community can more precisely compare performance results. Another limitation of deep learning models is that most training/validation sets are still based on handcrafted features or predefined descriptors which makes structural information extraction more difficult from raw inputs. Besides that, most deep model architectures are not initially suited for molecular data representation so researchers have to transform data into more appropriate forms\cite{wan_deep_2016} or develop novel architectures for more accurate molecular representation(e.g. graph neural network\cite{Lau2017BrendanADC}). Deep learning methods have improved different aspects of drug discovery like molecular design, chemical synthesis planning, macromolecular target identification or protein structure prediction\cite{pcm_recent_2017}.
\begin{figure}[htp]
\centering
\includegraphics[width=0.8\linewidth]{Drug_lead_like}
\caption{Computational prediction of biological activity is still a very challenging task with high rates of false positives and negatives. Some compounds that can be developed into drugs are never identified as drug-like or lead-like compounds. On the other hand, some compounds that have very strong biological activity do not possess drug-like properties, for example they are toxic for humans.}
\end{figure}
Molecules or new chemical entities (NCEs) with low or medium affinity are referred to as “hit” compounds and compounds with sub-optimal target binding affinity are “lead” compounds. Lead compounds are just first iterations of a molecule that is going to be further researched and possibly approved as a drug. To be chosen for further development a lead compound show have following properties: (i) relatively simple chemical features (e.g. suitable for combinatorial/medicinal chemistry optimization, no or few chiral centres), (ii) well-established structure-activity relationship (property where similar compounds or chemical groups share similar biological activity), (iii) favourable absorption, distribution, metabolism, excretion, and toxicity (ADME)\cite{adme_predicting_2002} properties and favourable patent situation for commercialization of discover compounds\cite{sheridan_chemical_2007}.
\section{Virtual screening}
During the hit discovery phase of drug development there are two main approaches: identification of novel bioactive compounds for a target protein and identification of new targets for known bioactive compounds, which are mostly drugs but not exclusively\cite{10.1093/bib/bby061}. Identification and validation of disease-causing genes that are viable as drug targets are key challenges of drug discovery\cite{patel_objective_2013}. On the other side is development of novel compounds that are targeting disease-related protein or repurposing currently approved drugs for treatment of different diseases.
In the drug discovery pipeline, virtual screening comes before an experimental screening procedure, reducing a set of researched chemicals to only potentially active and drug-like combinations. This is where VS has great potential to reduce the time and cost required for high-throughput screening\cite{schierz_virtual_2009}.
It is a knowledge based method for which prior knowledge about data is necessary.
Based on used input features VS methods can be grouped into three categories: structure-based, ligand-based and proteochemometric modeling (PCM) \cite{pcm_recent_2017} which just recently advanced so much it can be considered a standalone category. Structure based VS methods use 3D structure of targets and compounds to model target-compound interactions while ligand-based VS methods use molecular properties of compounds, which are mostly non-structural descriptors\cite{10.1093/bib/bby061}. Ligand-based VS is based on the hypothesis that structurally similar compounds have similar biological activities\cite{johnson_concepts_1990}, usually expressed as quantitative structure-activity relationship(QSAR). Its approach consists of finding a compound that is active against some target and using similarity-based techniques to find similar compounds from a library of compounds or by searching chemical space\cite{chemical_space} in case of \textit{de-novo} drug design to identify candidates for further screening process. On the other hand, PCM approach models the interaction by combining non-structural descriptors of both compounds and targets at the input level.
\begin{figure}[htp]
\centering
\includegraphics[width=0.5\linewidth]{Drug_discovery_process}
\caption{Virtual screening is part of the first step in the drug development process. It is a method for low resolution research of vast amounts of compounds from chemical space for “lead” and “hit” chemicals with desired properties. Goal of the drug discovery process can be finding novel drugs (\textit{de-novo}) or repurposing existing drugs for treatments other than currently approved by FDA.}
\end{figure}
\section{Descriptors and features}
Each VS method uses different biological, topological and physio-chemical properties of compounds and targets combined with the experimentally validated bioactivity data to predict biological activities\cite{10.1093/bib/bby061}. For the task of VS it is important to vectorize compounds and targets to get their appropriate computational representation. For quantum mechanical and biophysical datasets, the use of physics-aware featurizations can be more important than the choice of a particular machine learning algorithm\cite{wu_moleculenet:_2018}.
A well defined descriptor should faithfully represent intrinsic physical and chemical properties of the corresponding molecule. This kind of representation enables statistical models and neural networks to learn and generalize the shared properties among the molecules that lead to the interaction between compounds and targets\cite{10.1093/bib/bby061}. Molecular descriptors are numerical vectors representing compound’s features which are generated by algorithms based on geometrical, structural and physio-chemical properties of those molecules.
Descriptors are categorized based on the dimensionality of information describing the molecule, which can get very large as there are more than a thousand different types of molecular descriptors in literature\cite{todeschini_molecular_2009}.
These extremely high dimensional vectors can be very challenging to work with, creating computational overhead and reducing prediction accuracy. It is known that adding features can improve prediction performance up to a certain point after which it only decreases performance as more features are added to the model. This is known as a \textit{curse of dimensionality} \cite{powell_approximate_2011}. In order to cope with that drawback usually various dimensionality reduction techniques are employed.
3D structure models of proteins and compounds carry important information for determining their bioactivity and function. Currently there is only a small fraction of experimentally known 3D structures of compounds(small molecules) and human proteins, some structures partially and some completely known or predicted. One of the most complete and publicly available databases of such structures is RCSB Protein Data Bank (PDB) \cite{rcsb-pdb}. Most protein structures are predicted from their amino acid sequence with certain accuracy, and some popular methods for protein structure prediction are SWISS-MODEL\cite{waterhouse_swiss-model:_2018} and I-TASSER\cite{yang_i-tasser_2015}. Recently Google’s company DeepMind has released their neural network AlphaFold 2 for which they state that it solves the structure prediction component of the ‘protein folding problem’\cite{dill_protein_2008}. They show that AlphaFold 2 can predict protein structures with atomic accuracy even when there are no known similar structures\cite{jumper_highly_2021}. They have built AlphaFold Protein Structure Database where they provide open access to protein structure prediction of human proteome and some other usually studied oranzims. Currently this is the most complete database of predicted 3D structures of human proteins, containing almost the entire human proteome (98.5\% of proteins found in humans)\cite{tunyasuvunakool_highly_2021}.
Another project RoseTTAFold inspired by DeepMinds network architecture incorporated a three-track neural network of (i) the 1D sequence level, (ii) the 2D distance map level and (iii) 3D coordinate level information\cite{RoseTTAFold}. RoseTTAFold can also generate accurate protein-protein complex models from sequence information alone, without the need for a traditional docking of two proteins.
Compound structures are much easier to obtain and most of them are available in public databases like DrugBank\cite{wishart_drugbank:_2006} while the rest is in private databases usually held by pharmaceutical companies.
Often researchers use already developed tools for other purposes to solve a drug-target interaction (DTI) prediction problem or use a different representation of their input data. For example, using natural language processing (NLP) methods\cite{ozturk_exploring_2020} to represent molecular descriptors like DeepCPI \cite{wan_deepcpi:_2019} where they exploit latent features from large-scale unlabeled compound and protein data by combining feature embedding and deep learning methods. NLP techniques were used to extract useful features of compounds and proteins by representing compounds as “documents” and their basic structures as “words”, whereas protein sequences are represented as “sentences” and all possible three non-overlapping amino acid residues are “words”. After preparing compounds and proteins as language constructs they feed it to multimodal DNN classifiers to make DTI predictions.
\begin{figure}[htp]
\centering
\includegraphics[width=\linewidth]{chemical_space}
\caption{Drug-like space is approximated to contain between $10^{23}$ and $10^{60}$. One of the biggest known enumerated chemical libraries GDB-17 contains more than 166 billion compounds. These molecules made of up to 17 atoms are organized in multidimensional space in a way that neighbouring compounds share similar properties, according to 42 characteristics.}
\end{figure}
\section{Drug discovery and design}
\subsection{De-novo drug design}
Method of creating new chemicals with desired drug-like properties with the assistance of computational methods and artificial intelligence. Process of \textit{de-novo} drug design can be formulated as data mining of chemical space, which is a descriptor space of all possible compounds. This process usually starts with a molecular fragment of low molecular weight that is screened against macromolecular targets, which are usually proteins. Molecular fragments can bind at one or more sites on the target protein and that is determined with the help of docking tools like AutoDock Vina\cite{eberhardt_autodock_2021}. Depending on their binding affinity these fragments can be a starting point for development of “lead” compounds. Molecular fragments which are chosen as “lead” compounds usually possess favourable physical, pharmacokinetics and toxicity (ADMET—absorption, distribution, metabolism, excretion, and toxicity) properties.
While developing a molecular fragment into a production-ready drug, or fragment-to-lead optimization, fragment-based methods\cite{de_souza_neto_silico_2020} use strategies like hot spot analysis, druggability prediction, structure-activity relationship (SAR) and applications of various machine learning methods for synthesising new compounds from drug-like fragments.
Largest \textit{in silico} ligand–receptor docking run through the chemical library has recently been performed in 2019. for 170 million virtual compounds assembled from 130 chemical reactions\cite{lyu_ultra-large_2019}. Just to put that in perspective, the estimated cardinality of a chemical space is in the order of $10^{18}$ - $10^{200}$ molecules\cite{drew_size_2012}, depending on the set of constraints, and drug-like space is estimated between $10^{23}$ and $10^{60}$ molecules\cite{walters_virtual_2019}. Largest publicly available chemical library is ZINC containing ~2 billion compounds\cite{irwin_zinc20free_2020}. There are many proprietary and commercial databases with compound cardinality up to $10^{20}$ and $10^{9}$ respectively. Those libraries mostly contain distinct molecules because intellectual property laws imply that only newly-found molecules can be under commercial ownership. Data-handling on libraries this size is very challenging even in a cloud or HPC parallel environment as memory requirements and search times are increasing with the number of molecules in a library. For example, disk size required to save $10^{20}$ molecules as SMILES is ~200 000 TB in compressed format\cite{van_hilten_virtual_2019}. Techniques aimed at optimizing data-handling in large libraries are beyond the scope of this article and an interested reader can find more information about it from Merck’s Accessible Inventory (MASSIV)\cite{molecules24173096} which is currently one of the largest virtual molecule pools known to the public.
\subsection{Drug repurposing}
Beside discovering new drug candidates, another application of VS is repurposing current drugs for different treatments. Main advantage of screening approved compounds for potential target proteins is that their drug-likeness, bioactivity and non-toxicity are clinically confirmed\cite{ashburn_drug_2004}. Recent approaches to drug repurposing besides conventional chemical similarity and molecular docking use novel approaches in the spirit of systems biology. This means incorporating genomic, proteomic and transcriptomic data in construction of datasets and workflows. Researches now use disease networks which scrape data from various sources to create multilayer networks of known disease interactions (KEGG pathways, text mining)\cite{li_pathway-based_2009}, create Connectivity Map gene expression signatures from mRNA expressions\cite{sirota_discovery_2011} and transcriptomic data\cite{le_transcriptomics-based_2021}.
\section{Machine learning approaches}
Most machine learning approaches can on a high level be described through four steps: data cleaning and preprocessing, feature extraction, model fitting and evaluation of results \cite{angermueller_deep_2016}. Some of those steps are more complex than the others, depending on the approach and problem that is trying to be solved. For example, feature extraction is very challenging in computational biology and chemistry because chemical reactions and atomic structures are hard to describe using numerical vectors. More on features and their numerical encoding can be found in chapter Features and descriptors.
Authors in \cite{todeschini_molecular_2009} have divided VS methods based on the methodological utilization of the input properties in two groups: similarity-based methods and feature-based methods. Although there are multiple methods in the literature that are using both methodologies this still represents a valid description of general directions for machine learning approaches in VS.
Similarity-based methods rely on the assumption that biologically, topologically and chemically similar molecules probably have similar bioactivity and biological functions, therefore, they have similar target molecules\cite{ding_similarity-based_2014}.
This assumption is only partially correct and should be regarded as such because sometimes very small structural changes can have a large effect on bioactivity and properties of those compounds.
Similarity between two compounds is calculated by searching shared molecular substructures and isomorphism. Compound molecules are usually represented as SMILES\cite{smiles_1988} strings and targets are represented as genome sequences where alignment methods are used to calculate similarity. These methods are used to generate similarity matrices which are then used for machine learning models. Similarity methods are especially useful for clustering compounds with similar structure and biological properties. Similarity-based methods are suitable when problems involve heterogeneous data since they can combine different similarity matrices in the same model (e.g. similarity fusion). They are relatively simple to model but require a high number of similarity calculations so they are not computationally always feasible, especially on large datasets. Also, most existing similarity-based methods need to be retrained each time new drugs are approved and they can’t be directly used for novel drug discovery or when adding new targets. There are some novel methods like Weighted k-Nearest Neighbor with Interaction Recovery (WkNNIR)\cite{liu_drug-target_2021} that aim to solve those problems by using ensemble of DTI methods with different sampling strategies and interaction recovery to perform prediction upon a completed interaction matrix without the necessity of retraining and ability to detect previous false negatives.
Feature-based VS methods are based on numerical vector representation of compounds where each compound is mapped to a high dimensional vector which represents different physico-chemical and molecular properties of that compound. Typical workflow of feature-based VS consists of several steps: determining researched targets, finding appropriate compounds from databases of known interactions, generating feature vectors for targets and compounds and finally feeding those vectors to machine learning models to train it for prediction of target interactions. Generated feature vector of unknown compound is used as an input to ML model and output is either active or inactive against targets this predictive model was trained on\cite{westen_proteochemometric_2011}. Feature-based methods are more interpretable than similarity-based methods as they can reveal intrinsic properties of targets and compounds leading, making it easier to identify which features play critical roles in DTIs\cite{10.1093/bib/bby061}. Problem specific features can also be determined (computationally or heuristically) and selected for prediction models to get more accurate results.
It should be noted that the downside of feature-based methods, and generally most machine learning methods in DTI prediction, is the very difficult construction of a negative training set with negative samples. Databases mentioned in this article contain experimentally validated DTIs which are interacting and they are substantially more numerous than non-interacting pairs. This can lead to a class imbalance problem which results in a bias towards class with most training samples, so DTI prediction models often suffer from a high number of false positive(FP) predictions\cite{10.1093/bib/bby061}.
Researchers very often create negative training sets by randomly selecting pairs from sets excluding interacting pairs. It is obvious that this method is inherently problematic as some of those pairs can be interacting but their interaction is not yet known. There are some datasets in literature \cite{park_revisiting_2011} of negative example sets for protein-protein interactions where they build two different subsets: (i) unbiased subset for cross-validated testing and predictive performance estimation which should generalize population level and (ii) subset for training predictive algorithms which is constructed to gain best predictive performance of algorithm, even if that subset is biased.
Most ML methods in literature use supervised learning methods and combination of similarity-based and feature-based approaches for constructing predictive models. Such a method \cite{sawada_target-based_repurposing_2015} was employed for drug repurposing by integrating data from multiple sources like ChEMBL database\cite{gaulton_chembl_2017} for compound structures, chemical-protein interactome data and three molecular descriptors: KEGG Chemical Function and Structure (KCF-S) \cite{kotera_kcf-s_2013}, CDK (Daylight-type fingerprints) \cite{steinbeck_cdk_2003} and ECFP4 \cite{rogers_extended-connectivity_2010}. Molecular descriptors were used to construct feature vectors named ‘chemical profile’ and ‘phenotypic profile’ of researched compounds created from manually curated databases like KEGG DISEASE database \cite{kegg_2000}. This is usually the case when researchers are creating databases for training predictive models, they have to merge knowledge from programirably accessible databases containing huge amounts of data with data available in literature.
\subsection{Network-based methods}
Another highly studied topic regarding methodological approaches used in modeling target-compound pairs are network based drug-target interaction prediction methods. Those methods are also referred to as graph based DTI methods because they represent target-compound pairs as graph nodes with edges connecting them. This approach borrows various tools and methods from graph theory, social networks, and biological systems which are employed for link prediction tasks. Main advantage of the network-based approach is the low number of necessary examples for training, which is especially useful in drug design where example space is often very sparse.
\begin{figure}[htp]
\centering
\includegraphics[width=\linewidth]{Thyroid_cancer_pathway}
\caption{Example of KEGG signaling pathway for thyroid cancer in humans. This signaling pathway is a network representation of important elements (e.g. proteins, enzymes, molecular interactions and reactions) for thyroid cancer curated from the literature. Boxes represent ortholog groups, circles are other molecules, usually chemical compounds, and lines represent reactions in metabolic maps.}
\end{figure}
Network-based approaches are also very useful for integrating heterogeneous biological data from different sources for drug-target interaction prediction. Yamanishi et al. \cite{yamanishi_drug-target_2010} have joined chemical space\cite{chemical_space}, pharmacological space\cite{pharmacological_space} and topology of drug-target interaction networks in a unified prediction framework. They showed that DTIs are more correlated with pharmacological effect similarity than with chemical structure similarity. This was the first method to be able to predict potential pharmacological similarity for any drug candidate in a unified way by integrating chemical, genomic and pharmacological data and combining it with known DTIs.
Another example of research that is utilizing biological networks for DTI is an \textit{in silico} model of cancer called VINI. Tomić et al. \cite{vini} have developed a virtual screening framework which transforms the metabolic pathways of cancer from Kyoto Encyclopedia of Genes and Genomes\cite{kegg_2000} into the binding energy matrices. VINI is able to search libraries containing 3D structures and FASTA drug sequences of small molecules and protein-based drugs, to identify those with the highest binding energy to target molecules. The VINI model uses Autodock Vina software in the process of calculating binding free energy ($\Delta$G) between receptors and small molecules, and molecular dynamics tools to calculate $\Delta$G between receptors and protein-based drugs. By definition, $\Delta$G has always negative values expressed in kcal/mol units, or zero value in case there is no binding between receptor and ligand. The lower are these negative values, the greater the inhibition of the receptor by ligand is. Although receptors can be any kind of chemical compounds, most common receptors in KEGG pathways are proteins. Unlike receptors, most researched drug candidates are usually small molecules composed of several to several dozen atoms with low molecular weight. In literature only a few protein drugs (1000-2000 atoms) were screened against KEGG pathways due to the extremely high computational resources demand of molecular dynamic tools (e.g. GROMACS \cite{gromacs_2015}) needed to perform \textit{in silico} protein-protein docking and calculation of their binding free energies and high complexity of producing drugs of such complicated molecular configuration.
Another example is the computational method DDR \cite{DDR:graph_mining} where authors use a heterogeneous graph containing known DTIs with multiple similarities between drugs and between target proteins. They integrate a heuristic optimization process to obtain the best subset of similarity combinations for a nonlinear similarity fusion method. Similarity fusion is a process of combining selected similarity measures into one final composite similarity that contains information from its components.
As already stated, network-based models are very suitable for integrating heterogeneous data from different network models, sequencing data and various proteomic analysis into a single model capable of significantly improving personalized and precision medicine\cite{zhou_network-based_2020}. Those models are able to more faithfully represent a single patient's biological environment and predict drug efficiency for that patient with significantly improved accuracy. There is an increasing gap between what is technically possible and what is allowed by privacy laws\cite{price_privacy_2019}. Labeled medical data of patients is subject to very strict privacy legislation so prediction systems should include confidentiality by design. One example of such a system is Swarm Learning\cite{swarm_2021} where authors are uniting decentralized machine-learning, edge computing and blockchain-based-peer-to-peer networking for detection of heterogeneous illness while maintaining confidentiality with the need for a central coordinator.
\subsection{Protein-to-protein binding affinity prediction}
Central element of almost all cellular processes are protein-to-protein interactions(PPI), so knowledge of the structure of protein-protein complexes and predicting their binding affinity is of major importance to understand PPI and its impact on the virtual screening process \cite{computational_prediction_ppi_2020}. Protein-to-protein docking and binding affinity prediction are substantially more complex and computationally demanding than those for protein-to-small-molecule (which most target-compound pairs in literature usually are). There are some novel rigid body protein-protein docking methods that provide less accurate, yet acceptable models for more complexes than flexible docking methods. Authors in \cite{ppi_docking_performance_2020} are archiving protein-protein docking by fast Fourier transform algorithm used for sampling billions of complex conformations.
There are multiple available scoring schemes and conformational sampling for protein-protein complex structure prediction, while binding affinity approaches can be grouped into structural and sequence based approaches\cite{GROMIHA201731}. There are several software tools\cite{amino_acid_ppi}\cite{ofran_isis:_2007}\cite{vangone_contacts-based_2015} for protein interactions and structure geometry analysis of protein-protein complexes like PSAIA\cite{PSAIA} which uses random forests or web server HDOCK\cite{yan_hdock:_2017} for DNA/RNA docking based on a hybrid model of template-based modeling and free docking. Authors of web based service PSOPIA\cite{murakami_homology-based_2014} for homology-based PPI prediction use combination of three sequence based features: sequence similarities to a known interacting protein pair, statistical propensities of observed interacting protein pairs and sum of edge weights along the shortest path between homologous proteins in a PPI network. There are also studies that focus specifically on some subgroups of proteins to gain better prediction accuracy, like InterPep\cite{protein_peptide_predicting_2019} which is a tool for predicting protein-peptide interactions.
\section{Deep learning methods}
Deep learning (DL) is a computational model composed of multiple processing layers capable of learning data representations with multiple levels of abstraction. Term “deep” defines a subset of machine learning methods that use multiple hidden neural network layers in their architecture layers\cite{Wen20171401}. DL models can detect intricate relationships and structure in large datasets by using the backpropagation algorithm\cite{10.1093/bib/bby061}. Deep neural networks (DNNs) is an artificial computational architecture inspired by networks of neurons formed in the brain, a multilayer network that is represented as a graph with nodes representing neurons and edges representing neural connections.
Basic example of feedforward DNN is multilayer perceptron - MLP but there are many other implementations and variations in literature. For example, deep convolutional nets and deep recurrent nets are improving state-of-the-art in speech and visual objects recognition, text analysis and also biological domains like drug discovery and genomics \cite{lecun_deep_2015}.
Most commonly used machine learning techniques for DTI prediction in literature past few years were variations of DNNs with multiple hidden layers \cite{ma_deep_2015} because of their ability to make better prospective predictions than random forest (RF)\cite{random_forest_bias_2007} or support vector machine (SVM)\cite{svm_cancer} which were commonly used methods in the early 2000s. This is actually a revival of neural networks because they wever superseded by RF and SVM as more robust back at that time.
Each layer of DNN captures specific features from multidimensional, often heterogeneous, data. They are capable of detecting higher-level abstractions from complex sets of features and identifying unknown structures and relationships from raw data in a hierarchical manner.
Convolutional neural networks (CNNs) have gone a long way in image classification\cite{mask_r_cnn} so they are often used in VS when input data can be represented as an image or object with image-like features. In the next chapters of this review, deep learning models are categorized by the neural network architecture they implement.
\subsection{Feedforward deep neural networks}
Feedforward deep neural networks (FF-DNNs) are the first and simplest type of neural networks. Their nodes never form a cycle so information moves in only one direction, forward from input nodes, through hidden layer(s) to output nodes. Architectures like a single or multi layer perceptron are most common although there are architectures implementing a directed acyclic graph which means some input can skip hidden layers.
Authors in \cite{stokes_deep_2020} have used feedforward DNN to discover a molecule from the Drug Repurposing Hub\cite{corsello_drug_2017} that is structurally as different as possible from conventional antibiotics while keeping the same biological activity so it can be used against a wide spectrum of resistant bacteria. Variation of FF-DNN called message passing neural network (MPNN)\cite{yang_analyzing_2019} was used to predict quantum properties of organic molecules which are otherwise computationally expensive to calculate because of a density functional theory (DFT)\cite{becke_densityfunctional_1993} modeling. Three different optimizations were used on MPNN architecture: adding additional molecule-level features from RDKit for large molecules, ensembling with different initial weights and hyperparameter optimization. This speed-up allowed authors to screen multiple chemical libraries in search for structurally distant molecules from known antibiotics.
\subsection{Pairwise input neural networks}
Pairwise input neural networks (PINNs) are a variation of neural networks where the input vector is a combination of both target and compound description vectors. There are some PINNs where a combination of input vectors is processed by the same connected neurons while others use separate groups of neurons for processing target and compound input vectors before they are merged together in a fully connected layer. Pairwise representation is inherently convenient for prediction of pairwise relations like DTI\cite{10.1093/bib/bby061}. Authors in \cite{wan_deep_2016} used unsupervised learning to extract low-dimensional representation of input features which they embedded to a fixed low dimensional space. Amino acid triplets in proteins and compounds molecular structure were represented as word-embeddings so natural language processing (NLP) techniques could be applied to extract hidden structures and relationships.
\subsection{Convolutional neural networks}
Convolutional neural network (CNN) is a neural network modelling approach inspired by neuroscience to imitate images within the visual cortex. In the visual cortex neurons respond to stimuli in their receptive fields, with some neurons overlapping their parts of their receptive fields. CNN architecture is especially adapted to multidimensional input obtained from image pixels, where each hidden layer is recognizing certain critical features such as lines or objects. CNNs ability to to exploit spatial or temporal correlation in data makes CNN techniques very suitable for usage in computer vision and voice recognition\cite{khan_survey_2020}. Facebook’s Mask R-CNN has outperformed all single-model entries on every task in image instance segmentation, bounding-box object detection and person keypoint detection\cite{mask_r_cnn}. Several studies have employed already developed image recognition CNN models for the purpose of virtual screening, biology activity or toxicity predictions, representing input data as images. Authors in \cite{goh_how_2018} represented each compound as an 80x80 pixel image based on their 2D drawing from chemical databases. These images coupled with their biological properties were fed as input to CNN for classification. Model was used for prediction of toxicity, biological activity and solvation free energy. In other research, authors represented drug molecules as 2D graphs with atom features and fed it to CNN to learn molecular features from molecular graphs. These molecular features were used as a dataset for training other prediction models\cite{Altae-Tran2017283}. Their motivation was to significantly lower the amount of data required to make meaningful predictions in drug discovery applications. It was implemented as one-shot learning architecture combining iterative refinement long short-term memory and graph convolutional neural network, which is described in more detail in a separate section. Besides the need for large amounts of training data CNN’s main drawback is its inability to model potential relationships between distant atoms in a raw molecule sequence. Authors in \cite{BECK2020784} have used a combination of CNN and self-attention mechanism\cite{shin_self-attention_2019} (concept initially developed for natural language representation learning) to overcome short backs of CNN for prediction of commercially available antiviral drugs that could act on SARS-CoV-2 virus.
In another example, authors used atom and amino acid embeddings in creating vector representation of protein-ligand complexes further processed by CNN\cite{pereira_boosting_2016}. Here they are using CNN to boost the docking process for virtual screening, which is usually performed by docking software like AutoDock Vina or Dock.
\subsection{Recurrent neural networks}
Recurrent neural networks (RNN) is a type of deep learning architecture designed specifically to handle sequenced data which has achieved great success in fields like NLP and voice recognition. Main difference between FF-DNNs and RNN is that in deep learning methods that follow feedforward architecture there is no connection between nodes in the same hidden layer, only between nodes of different adjacent layers. In RNN architectures there is also a connection between nodes in the same hidden layer which enables them to process sequential information by affiliating adjacent hidden nodes with each other and capturing the calculated information from previous time slices and storing it for the subsequent processing.
Authors in \cite{gupta_generative_2018} used RNN containing long short-term memory (LSTM) cells for de novo drug design. It captured SMILES string molecular representation and learned probability patterns that were used for generation of new SMILES strings. By employing transfer learning this RNN architecture can be fine-tuned for specific molecular targets. In transfer learning the model is keeping information from the previous target while tasked to solve a different but related and yet unseen target. Authors in \cite{olivecrona_molecular_2017} are using RNN to generate novel molecules with some desirable properties, fine-tuning it through augmented episodic likelihood. NN was tested through three step assignment: (i) generating sulfur-free molecules, (ii) generating analogues of the drug Celecoxib and finally (iii) generating novel compounds against an assigned target with 95\% of them predicted to be active.
\subsection{Restricted Boltzmann machine (RBM)/Deep belief networks (DBN)}
Restricted Boltzmann machine is a variation of the single-layer model Boltzmann machine\cite{bengio_learning_2009} in which neurons from visible and hidden layers must form a bipartite graph. “Restricted” implies that they have symmetric connection between them but there are no connections between nodes inside the same layer which allows usage of more efficient training algorithms like gradient-based contrastive divergence algorithm or likelihood gradient \cite{montavon_practical_2012}. By “stacking” RBMs into a deep belief network(DBN) they can be used in deep learning, where usually gradient descent and backpropagation are used for fine-tuning the results.
Authors in \cite{wang_predicting_2013} trained individual RMB for each target and integrated them together into a final model. Main goal of this architecture was to incorporate a heterogeneous set of compounds and targets with different DTIs into a single multidimensional prediction model. They divided interactions as direct and indirect, where physical binding of a compound molecule to a protein is considered direct interaction and all other interactions are considered indirect, for example changing expression levels of genes responsible for encoding target proteins.
On the other hand, authors in \cite{Wen20171401} grouped all target proteins in the same group to train a single predictive model. They only later after training decoupled their model to test the ability of DBN in abstracting of the input data and generating more informative representation in each succeeding hidden layer. They used each layer’s representation to train a simple logistics regression model to predict DTIs. Accuracy of the logistic regression model was getting higher as the hidden layer used for training was deeper in DBNs architecture. This indicated that each hidden layer in DBN was generating more informative and meaningful representation of input data.
\subsection{Graph convolutional neural network}
Graph convolutional networks (GCN) achieved remarkable success during the past 10 years in various domains of bioinformatics. They were developed through efforts to generalize a convolution operator on non-Euclidean structured data, which are in this case graphs. Authors in \cite{sun_graph_2020} point out that graph-based representation of molecules has several advantages over descriptor-based molecule representations: it extracts features with respect to structure of the data and it can automatically extract features from raw input instead of hand picking features and thus potentially leaving out important information or creating bias.
GCN found their applications in molecular property and activity prediction, interaction prediction, synthesis prediction and \textit{de-novo} drug design\cite{wang_pairwise_2014}. Two main approaches to building GCN for virtual drug screening are distincted by their definition of convolution: spatial and spectral GCN. Spatial GCN formulates convolution in spatial domain by summing up all features vectors of neighborhood nodes in a graph, while spectral defines convolution in the graph spectral domain\cite{Defferrard20163844}. Spatial convolution constructs convolution explicitly in the vertex domain. Representation of a single node is updated by recursively aggregating information from its neighborhood nodes. Spectral convolution takes variation of Fourier transformation as the basis for signals defined on a graph, typically focusing on the properties of the graph Laplacian matrix.
Authors in \cite{YingkaiGao20183371},\cite{Duvenaud20152224} used GCNs to overcome common challenges of traditional machine learning used for DTI prediction which are: (i) extensively large chemical space on which search for drug-like compounds is performed, (ii) interaction prediction is usually defined as binary classification problem (e.g. compound is either active or inactive for a single target) making it ineffective for screening against new targets and (iii) lack of biological interpretation.
\subsection{Generative deep neural networks}
Besides processing labeled data in supervised learning, DNNs can be used for analyzing non labeled data in an unsupervised learning process. This is usually achieved with two NNs (e.g. DBN) which act like encoder and decoder, where former maximizes its classification accuracy and latter is maximizing its discrimination accuracy.
Most often seen generative neural networks in literature are variational autoencoder (VAE) and adversarial autoencoder (AAE). Main difference between these two approaches is in the way they compute loss in latent representations. VAE relies on Kullback–Leibler divergence\cite{kullback_information_1951} between distribution obtained from the encoder and prior distribution of input data - we would like to get latent distribution as close to gaussian prior as possible. On the other hand, adversarial AE uses a different approach for getting the term minimized adversarially. AAE achieves the same result by sending samples from latent (“fake”) distribution and samples from a gaussian distribution (“real” samples) to a discriminator which should learn to produce samples similar to prior gaussian distribution.
Authors in \cite{kadurin_drugan:_2017} have used deep generative adversarial network (GAN)\cite{creswell_generative_2018} called druGAN to demonstrate a proof-of-concept for adversarial autoencoder (AAE) used to identify new molecular fingerprints with predefined anticancer and drug-like properties. They show improvement over variational autoencoder (VAE) in terms of adjustability and capacity of processing large molecular sets. Autoencoders have been commonly used for molecular feature extraction purposes while building prediction models for DTI. Various types of autoencoders have capabilities of extracting important features from high dimensional feature space describing targets and compounds, allowing researchers to get better results with sparse datasets\cite{Alain2013RegularizedAE}. There are many examples in recent literature\cite{polykovskiy_entangled_2018}\cite{kadurin_cornucopia_2017} of researchers using autoencoders to extract favourable features from molecular descriptors which they later use for synthesis of novel compounds with the same features through generative adversarial networks.
Authors in \cite{Kadurin201710883} used generative adversarial autoencoders (AAE) for generating novel molecular fingerprints with a defined set of parameters. NCI-60 cell line was used to train AAE with input and output defined as a combination of binary fingerprint vector and log concentration of the molecule. Additional neuron was added to control growth inhibition (GI) percentage which indicates reduction in the number of tumor cells if its value is negative. AEE was trained on MCF-7 cell line assay data for 6252 compounds based on their log concentration, molecular fingerprint and GI data. AEE and decoder were used to generate 32 descriptor vectors containing molecular fingerprint, GI value and concentration. This set of vectors was later screened against 72 million compounds from Pubchem\cite{pubchem} where top 10 hits with maximum likelihood function were filtered. Pubchem BioAssay database \cite{pubchem_bioassay} was used to identify compounds with biological and medical relevance and it was discovered that trained AEE generated some very similar compounds to those that are known to have anticancer activities, mostly similar to anthracyclines.
\subsection{Explainable AI in drug discovery}
DNNs are often limited in their usability due to their black-box nature so different model interpretations were developed for better understanding of the inner-process of training NN and their prediction results\cite{10.1093/bib/bbaa177}.
Explainable, or sometimes referred to as interpretable, artificial intelligence is a collection of methods developed to gain better insight in the training and prediction process of deep learning algorithms. There are several properties of explainable artificial intelligence that are favourable in drug discovery process: (i) transparency (knowing how certain result was reached, e.g. which features play major role), (ii) justification (reasoning why that answer was provided by the model), (iii) informativeness (ability to provide additional, previously unknown, information for human operators) and (iv) uncertainty estimation (quantified measure of how reliable is models prediction)\cite{Lipton2018}. There are many domain-specific challenges in building explainable AI for drug discovery - first of all, drug discovery has inherently problematic modeling of raw data. Unlike image recognition or natural language processing, molecules don’t have complete and raw data representation. It is still not clear which is the best molecule representation and often it is very dependent on the domain of application. This choice of molecular representation becomes a limiting factor in performance and explainability of the model. Molecular representation determines which properties can be explained and which chemical information can be retained (for example, if we represent a molecule with its physicochemical properties then the model can only be interpretable in a regard to those specific properties)\cite{jimenez-luna_drug_2020}.
\section{Conclusion and future challenges}
Appeal of applying artificial intelligence in the drug discovery process is in its potential to build data-driven models from vast datasets generated from high throughput screening(where hit rates are only 0-0-1\%) and to prioritize alternative variations. In the beginning this implies synergy of machine and human intelligence in a specific domain where machines augment capabilities of medicinal chemists in early phases of drug design and selection. Ultimately, the goal is to develop a model capable of autonomously generating new chemical entities (NCEs) of desired properties without the need for human intervention and expensive high throughput screenings. From Schneiders et al.\cite{schneider_rethinking_2020} perspective AI-aided drug design should provide questions to five ‘grand challenges’ in order to be successful in its mission. Those grand challenges are: “obtaining appropriate datasets, generating new hypotheses, optimizing in a multi-objective manner, reducing cycle times and changing the research culture and creating appropriate mindset”. Authors point out that input dataset are key factors when evaluating predictive models and whether those dataset were collected with the final goal in mind. In most cases the relationship between \textit{in vitro} and \textit{in vivo} tests for animal and human patients is not clearly established so models built on surrogate data have inherent limitations. This extends to designing high-throughput screening datasets, protein structure prediction and appropriate meta-data and annotations in databases. There is a lot of work ahead for researchers, with high necessity for interdisciplinary collaboration in order to harvest the full potential of new predictive methods in drug discovery.
\bibliographystyle{ieeetr}
\section{Introduction}
Virtual screening (VS) is a computational field that has emerged in the past two decades as an aid to conventional experimental drug discovery by using statistics to estimate unknown bio-interaction between compounds and biological targets, usually proteins\cite{wang_pairwise_2014}. VS is a search for compounds with a defined biological activity using a computation model. Molecular compounds are filtered through a progressive series of tests which determine their phyisio-chemical properties, bioactivity, effectiveness and toxicity for later stages of drug discovery process.
“With the emergence of supercomputers, we can analyze in more depth the natural laws of life on Earth, including the metabolic processes of complex diseases like cancer. We can analyze data obtained from high-throughput genomic and proteomic tools, solve systems with millions of linear equations, and analyze graphs that represent thousands of genes and proteins”\cite{tomic_evaluation_2018}.
There are numerous examples where drug discovery systems can be seen as complex adaptive systems with nonlinear emergent behaviour that is hard to predict\cite{schneider_novo_2016} due to its sensitivity to small structural modifications having hugely different effect (“activity cliff”) or unknown interdependencies and gene expression influences. This is inherently also a limitation and challenge for virtual screening methods, along with others that will be mentioned in this review.
Methods of virtual screening use structural models of compounds and target proteins, their physio-chemical properties, bioactivity and experimentally verified bio-interaction data to leverage predictive behavior.
Although the drug production process still remains expensive and time-consuming due to a high proportion of failures in clinical trials\cite{mullard_2020_2021} (in 2020. FDA didn’t approve 42\% of drugs for rare diseases and 58\% for substantial improvements for serious diseases) some impressive technological leaps were seen during the past few years. Mostly powered by artificial intelligence(AI) and ever-growing omics databases, new computational methods for early phase drug discovery that are developed will be presented in this article. One of key challenges in comparing different AI methods is lack of universal benchmarking datasets by which the scientific community can more precisely compare performance results. Another limitation of deep learning models is that most training/validation sets are still based on handcrafted features or predefined descriptors which makes structural information extraction more difficult from raw inputs. Besides that, most deep model architectures are not initially suited for molecular data representation so researchers have to transform data into more appropriate forms\cite{wan_deep_2016} or develop novel architectures for more accurate molecular representation(e.g. graph neural network\cite{Lau2017BrendanADC}). Deep learning methods have improved different aspects of drug discovery like molecular design, chemical synthesis planning, macromolecular target identification or protein structure prediction\cite{pcm_recent_2017}.
\begin{figure}[htp]
\centering
\includegraphics[width=0.8\linewidth]{Drug_lead_like}
\caption{Computational prediction of biological activity is still a very challenging task with high rates of false positives and negatives. Some compounds that can be developed into drugs are never identified as drug-like or lead-like compounds. On the other hand, some compounds that have very strong biological activity do not possess drug-like properties, for example they are toxic for humans.}
\end{figure}
Molecules or new chemical entities (NCEs) with low or medium affinity are referred to as “hit” compounds and compounds with sub-optimal target binding affinity are “lead” compounds. Lead compounds are just first iterations of a molecule that is going to be further researched and possibly approved as a drug. To be chosen for further development a lead compound show have following properties: (i) relatively simple chemical features (e.g. suitable for combinatorial/medicinal chemistry optimization, no or few chiral centres), (ii) well-established structure-activity relationship (property where similar compounds or chemical groups share similar biological activity), (iii) favourable absorption, distribution, metabolism, excretion, and toxicity (ADME)\cite{adme_predicting_2002} properties and favourable patent situation for commercialization of discover compounds\cite{sheridan_chemical_2007}.
\section{Virtual screening}
During the hit discovery phase of drug development there are two main approaches: identification of novel bioactive compounds for a target protein and identification of new targets for known bioactive compounds, which are mostly drugs but not exclusively\cite{10.1093/bib/bby061}. Identification and validation of disease-causing genes that are viable as drug targets are key challenges of drug discovery\cite{patel_objective_2013}. On the other side is development of novel compounds that are targeting disease-related protein or repurposing currently approved drugs for treatment of different diseases.
In the drug discovery pipeline, virtual screening comes before an experimental screening procedure, reducing a set of researched chemicals to only potentially active and drug-like combinations. This is where VS has great potential to reduce the time and cost required for high-throughput screening\cite{schierz_virtual_2009}.
It is a knowledge based method for which prior knowledge about data is necessary.
Based on used input features VS methods can be grouped into three categories: structure-based, ligand-based and proteochemometric modeling (PCM) \cite{pcm_recent_2017} which just recently advanced so much it can be considered a standalone category. Structure based VS methods use 3D structure of targets and compounds to model target-compound interactions while ligand-based VS methods use molecular properties of compounds, which are mostly non-structural descriptors\cite{10.1093/bib/bby061}. Ligand-based VS is based on the hypothesis that structurally similar compounds have similar biological activities\cite{johnson_concepts_1990}, usually expressed as quantitative structure-activity relationship(QSAR). Its approach consists of finding a compound that is active against some target and using similarity-based techniques to find similar compounds from a library of compounds or by searching chemical space\cite{chemical_space} in case of \textit{de-novo} drug design to identify candidates for further screening process. On the other hand, PCM approach models the interaction by combining non-structural descriptors of both compounds and targets at the input level.
\begin{figure}[htp]
\centering
\includegraphics[width=0.5\linewidth]{Drug_discovery_process}
\caption{Virtual screening is part of the first step in the drug development process. It is a method for low resolution research of vast amounts of compounds from chemical space for “lead” and “hit” chemicals with desired properties. Goal of the drug discovery process can be finding novel drugs (\textit{de-novo}) or repurposing existing drugs for treatments other than currently approved by FDA.}
\end{figure}
\section{Descriptors and features}
Each VS method uses different biological, topological and physio-chemical properties of compounds and targets combined with the experimentally validated bioactivity data to predict biological activities\cite{10.1093/bib/bby061}. For the task of VS it is important to vectorize compounds and targets to get their appropriate computational representation. For quantum mechanical and biophysical datasets, the use of physics-aware featurizations can be more important than the choice of a particular machine learning algorithm\cite{wu_moleculenet:_2018}.
A well defined descriptor should faithfully represent intrinsic physical and chemical properties of the corresponding molecule. This kind of representation enables statistical models and neural networks to learn and generalize the shared properties among the molecules that lead to the interaction between compounds and targets\cite{10.1093/bib/bby061}. Molecular descriptors are numerical vectors representing compound’s features which are generated by algorithms based on geometrical, structural and physio-chemical properties of those molecules.
Descriptors are categorized based on the dimensionality of information describing the molecule, which can get very large as there are more than a thousand different types of molecular descriptors in literature\cite{todeschini_molecular_2009}.
These extremely high dimensional vectors can be very challenging to work with, creating computational overhead and reducing prediction accuracy. It is known that adding features can improve prediction performance up to a certain point after which it only decreases performance as more features are added to the model. This is known as a \textit{curse of dimensionality} \cite{powell_approximate_2011}. In order to cope with that drawback usually various dimensionality reduction techniques are employed.
3D structure models of proteins and compounds carry important information for determining their bioactivity and function. Currently there is only a small fraction of experimentally known 3D structures of compounds(small molecules) and human proteins, some structures partially and some completely known or predicted. One of the most complete and publicly available databases of such structures is RCSB Protein Data Bank (PDB) \cite{rcsb-pdb}. Most protein structures are predicted from their amino acid sequence with certain accuracy, and some popular methods for protein structure prediction are SWISS-MODEL\cite{waterhouse_swiss-model:_2018} and I-TASSER\cite{yang_i-tasser_2015}. Recently Google’s company DeepMind has released their neural network AlphaFold 2 for which they state that it solves the structure prediction component of the ‘protein folding problem’\cite{dill_protein_2008}. They show that AlphaFold 2 can predict protein structures with atomic accuracy even when there are no known similar structures\cite{jumper_highly_2021}. They have built AlphaFold Protein Structure Database where they provide open access to protein structure prediction of human proteome and some other usually studied oranzims. Currently this is the most complete database of predicted 3D structures of human proteins, containing almost the entire human proteome (98.5\% of proteins found in humans)\cite{tunyasuvunakool_highly_2021}.
Another project RoseTTAFold inspired by DeepMinds network architecture incorporated a three-track neural network of (i) the 1D sequence level, (ii) the 2D distance map level and (iii) 3D coordinate level information\cite{RoseTTAFold}. RoseTTAFold can also generate accurate protein-protein complex models from sequence information alone, without the need for a traditional docking of two proteins.
Compound structures are much easier to obtain and most of them are available in public databases like DrugBank\cite{wishart_drugbank:_2006} while the rest is in private databases usually held by pharmaceutical companies.
Often researchers use already developed tools for other purposes to solve a drug-target interaction (DTI) prediction problem or use a different representation of their input data. For example, using natural language processing (NLP) methods\cite{ozturk_exploring_2020} to represent molecular descriptors like DeepCPI \cite{wan_deepcpi:_2019} where they exploit latent features from large-scale unlabeled compound and protein data by combining feature embedding and deep learning methods. NLP techniques were used to extract useful features of compounds and proteins by representing compounds as “documents” and their basic structures as “words”, whereas protein sequences are represented as “sentences” and all possible three non-overlapping amino acid residues are “words”. After preparing compounds and proteins as language constructs they feed it to multimodal DNN classifiers to make DTI predictions.
\begin{figure}[htp]
\centering
\includegraphics[width=\linewidth]{chemical_space}
\caption{Drug-like space is approximated to contain between $10^{23}$ and $10^{60}$. One of the biggest known enumerated chemical libraries GDB-17 contains more than 166 billion compounds. These molecules made of up to 17 atoms are organized in multidimensional space in a way that neighbouring compounds share similar properties, according to 42 characteristics.}
\end{figure}
\section{Drug discovery and design}
\subsection{De-novo drug design}
Method of creating new chemicals with desired drug-like properties with the assistance of computational methods and artificial intelligence. Process of \textit{de-novo} drug design can be formulated as data mining of chemical space, which is a descriptor space of all possible compounds. This process usually starts with a molecular fragment of low molecular weight that is screened against macromolecular targets, which are usually proteins. Molecular fragments can bind at one or more sites on the target protein and that is determined with the help of docking tools like AutoDock Vina\cite{eberhardt_autodock_2021}. Depending on their binding affinity these fragments can be a starting point for development of “lead” compounds. Molecular fragments which are chosen as “lead” compounds usually possess favourable physical, pharmacokinetics and toxicity (ADMET—absorption, distribution, metabolism, excretion, and toxicity) properties.
While developing a molecular fragment into a production-ready drug, or fragment-to-lead optimization, fragment-based methods\cite{de_souza_neto_silico_2020} use strategies like hot spot analysis, druggability prediction, structure-activity relationship (SAR) and applications of various machine learning methods for synthesising new compounds from drug-like fragments.
Largest \textit{in silico} ligand–receptor docking run through the chemical library has recently been performed in 2019. for 170 million virtual compounds assembled from 130 chemical reactions\cite{lyu_ultra-large_2019}. Just to put that in perspective, the estimated cardinality of a chemical space is in the order of $10^{18}$ - $10^{200}$ molecules\cite{drew_size_2012}, depending on the set of constraints, and drug-like space is estimated between $10^{23}$ and $10^{60}$ molecules\cite{walters_virtual_2019}. Largest publicly available chemical library is ZINC containing ~2 billion compounds\cite{irwin_zinc20free_2020}. There are many proprietary and commercial databases with compound cardinality up to $10^{20}$ and $10^{9}$ respectively. Those libraries mostly contain distinct molecules because intellectual property laws imply that only newly-found molecules can be under commercial ownership. Data-handling on libraries this size is very challenging even in a cloud or HPC parallel environment as memory requirements and search times are increasing with the number of molecules in a library. For example, disk size required to save $10^{20}$ molecules as SMILES is ~200 000 TB in compressed format\cite{van_hilten_virtual_2019}. Techniques aimed at optimizing data-handling in large libraries are beyond the scope of this article and an interested reader can find more information about it from Merck’s Accessible Inventory (MASSIV)\cite{molecules24173096} which is currently one of the largest virtual molecule pools known to the public.
\subsection{Drug repurposing}
Beside discovering new drug candidates, another application of VS is repurposing current drugs for different treatments. Main advantage of screening approved compounds for potential target proteins is that their drug-likeness, bioactivity and non-toxicity are clinically confirmed\cite{ashburn_drug_2004}. Recent approaches to drug repurposing besides conventional chemical similarity and molecular docking use novel approaches in the spirit of systems biology. This means incorporating genomic, proteomic and transcriptomic data in construction of datasets and workflows. Researches now use disease networks which scrape data from various sources to create multilayer networks of known disease interactions (KEGG pathways, text mining)\cite{li_pathway-based_2009}, create Connectivity Map gene expression signatures from mRNA expressions\cite{sirota_discovery_2011} and transcriptomic data\cite{le_transcriptomics-based_2021}.
\section{Machine learning approaches}
Most machine learning approaches can on a high level be described through four steps: data cleaning and preprocessing, feature extraction, model fitting and evaluation of results \cite{angermueller_deep_2016}. Some of those steps are more complex than the others, depending on the approach and problem that is trying to be solved. For example, feature extraction is very challenging in computational biology and chemistry because chemical reactions and atomic structures are hard to describe using numerical vectors. More on features and their numerical encoding can be found in chapter Features and descriptors.
Authors in \cite{todeschini_molecular_2009} have divided VS methods based on the methodological utilization of the input properties in two groups: similarity-based methods and feature-based methods. Although there are multiple methods in the literature that are using both methodologies this still represents a valid description of general directions for machine learning approaches in VS.
Similarity-based methods rely on the assumption that biologically, topologically and chemically similar molecules probably have similar bioactivity and biological functions, therefore, they have similar target molecules\cite{ding_similarity-based_2014}.
This assumption is only partially correct and should be regarded as such because sometimes very small structural changes can have a large effect on bioactivity and properties of those compounds.
Similarity between two compounds is calculated by searching shared molecular substructures and isomorphism. Compound molecules are usually represented as SMILES\cite{smiles_1988} strings and targets are represented as genome sequences where alignment methods are used to calculate similarity. These methods are used to generate similarity matrices which are then used for machine learning models. Similarity methods are especially useful for clustering compounds with similar structure and biological properties. Similarity-based methods are suitable when problems involve heterogeneous data since they can combine different similarity matrices in the same model (e.g. similarity fusion). They are relatively simple to model but require a high number of similarity calculations so they are not computationally always feasible, especially on large datasets. Also, most existing similarity-based methods need to be retrained each time new drugs are approved and they can’t be directly used for novel drug discovery or when adding new targets. There are some novel methods like Weighted k-Nearest Neighbor with Interaction Recovery (WkNNIR)\cite{liu_drug-target_2021} that aim to solve those problems by using ensemble of DTI methods with different sampling strategies and interaction recovery to perform prediction upon a completed interaction matrix without the necessity of retraining and ability to detect previous false negatives.
Feature-based VS methods are based on numerical vector representation of compounds where each compound is mapped to a high dimensional vector which represents different physico-chemical and molecular properties of that compound. Typical workflow of feature-based VS consists of several steps: determining researched targets, finding appropriate compounds from databases of known interactions, generating feature vectors for targets and compounds and finally feeding those vectors to machine learning models to train it for prediction of target interactions. Generated feature vector of unknown compound is used as an input to ML model and output is either active or inactive against targets this predictive model was trained on\cite{westen_proteochemometric_2011}. Feature-based methods are more interpretable than similarity-based methods as they can reveal intrinsic properties of targets and compounds leading, making it easier to identify which features play critical roles in DTIs\cite{10.1093/bib/bby061}. Problem specific features can also be determined (computationally or heuristically) and selected for prediction models to get more accurate results.
It should be noted that the downside of feature-based methods, and generally most machine learning methods in DTI prediction, is the very difficult construction of a negative training set with negative samples. Databases mentioned in this article contain experimentally validated DTIs which are interacting and they are substantially more numerous than non-interacting pairs. This can lead to a class imbalance problem which results in a bias towards class with most training samples, so DTI prediction models often suffer from a high number of false positive(FP) predictions\cite{10.1093/bib/bby061}.
Researchers very often create negative training sets by randomly selecting pairs from sets excluding interacting pairs. It is obvious that this method is inherently problematic as some of those pairs can be interacting but their interaction is not yet known. There are some datasets in literature \cite{park_revisiting_2011} of negative example sets for protein-protein interactions where they build two different subsets: (i) unbiased subset for cross-validated testing and predictive performance estimation which should generalize population level and (ii) subset for training predictive algorithms which is constructed to gain best predictive performance of algorithm, even if that subset is biased.
Most ML methods in literature use supervised learning methods and combination of similarity-based and feature-based approaches for constructing predictive models. Such a method \cite{sawada_target-based_repurposing_2015} was employed for drug repurposing by integrating data from multiple sources like ChEMBL database\cite{gaulton_chembl_2017} for compound structures, chemical-protein interactome data and three molecular descriptors: KEGG Chemical Function and Structure (KCF-S) \cite{kotera_kcf-s_2013}, CDK (Daylight-type fingerprints) \cite{steinbeck_cdk_2003} and ECFP4 \cite{rogers_extended-connectivity_2010}. Molecular descriptors were used to construct feature vectors named ‘chemical profile’ and ‘phenotypic profile’ of researched compounds created from manually curated databases like KEGG DISEASE database \cite{kegg_2000}. This is usually the case when researchers are creating databases for training predictive models, they have to merge knowledge from programirably accessible databases containing huge amounts of data with data available in literature.
\subsection{Network-based methods}
Another highly studied topic regarding methodological approaches used in modeling target-compound pairs are network based drug-target interaction prediction methods. Those methods are also referred to as graph based DTI methods because they represent target-compound pairs as graph nodes with edges connecting them. This approach borrows various tools and methods from graph theory, social networks, and biological systems which are employed for link prediction tasks. Main advantage of the network-based approach is the low number of necessary examples for training, which is especially useful in drug design where example space is often very sparse.
\begin{figure}[htp]
\centering
\includegraphics[width=\linewidth]{Thyroid_cancer_pathway}
\caption{Example of KEGG signaling pathway for thyroid cancer in humans. This signaling pathway is a network representation of important elements (e.g. proteins, enzymes, molecular interactions and reactions) for thyroid cancer curated from the literature. Boxes represent ortholog groups, circles are other molecules, usually chemical compounds, and lines represent reactions in metabolic maps.}
\end{figure}
Network-based approaches are also very useful for integrating heterogeneous biological data from different sources for drug-target interaction prediction. Yamanishi et al. \cite{yamanishi_drug-target_2010} have joined chemical space\cite{chemical_space}, pharmacological space\cite{pharmacological_space} and topology of drug-target interaction networks in a unified prediction framework. They showed that DTIs are more correlated with pharmacological effect similarity than with chemical structure similarity. This was the first method to be able to predict potential pharmacological similarity for any drug candidate in a unified way by integrating chemical, genomic and pharmacological data and combining it with known DTIs.
Another example of research that is utilizing biological networks for DTI is an \textit{in silico} model of cancer called VINI. Tomić et al. \cite{vini} have developed a virtual screening framework which transforms the metabolic pathways of cancer from Kyoto Encyclopedia of Genes and Genomes\cite{kegg_2000} into the binding energy matrices. VINI is able to search libraries containing 3D structures and FASTA drug sequences of small molecules and protein-based drugs, to identify those with the highest binding energy to target molecules. The VINI model uses Autodock Vina software in the process of calculating binding free energy ($\Delta$G) between receptors and small molecules, and molecular dynamics tools to calculate $\Delta$G between receptors and protein-based drugs. By definition, $\Delta$G has always negative values expressed in kcal/mol units, or zero value in case there is no binding between receptor and ligand. The lower are these negative values, the greater the inhibition of the receptor by ligand is. Although receptors can be any kind of chemical compounds, most common receptors in KEGG pathways are proteins. Unlike receptors, most researched drug candidates are usually small molecules composed of several to several dozen atoms with low molecular weight. In literature only a few protein drugs (1000-2000 atoms) were screened against KEGG pathways due to the extremely high computational resources demand of molecular dynamic tools (e.g. GROMACS \cite{gromacs_2015}) needed to perform \textit{in silico} protein-protein docking and calculation of their binding free energies and high complexity of producing drugs of such complicated molecular configuration.
Another example is the computational method DDR \cite{DDR:graph_mining} where authors use a heterogeneous graph containing known DTIs with multiple similarities between drugs and between target proteins. They integrate a heuristic optimization process to obtain the best subset of similarity combinations for a nonlinear similarity fusion method. Similarity fusion is a process of combining selected similarity measures into one final composite similarity that contains information from its components.
As already stated, network-based models are very suitable for integrating heterogeneous data from different network models, sequencing data and various proteomic analysis into a single model capable of significantly improving personalized and precision medicine\cite{zhou_network-based_2020}. Those models are able to more faithfully represent a single patient's biological environment and predict drug efficiency for that patient with significantly improved accuracy. There is an increasing gap between what is technically possible and what is allowed by privacy laws\cite{price_privacy_2019}. Labeled medical data of patients is subject to very strict privacy legislation so prediction systems should include confidentiality by design. One example of such a system is Swarm Learning\cite{swarm_2021} where authors are uniting decentralized machine-learning, edge computing and blockchain-based-peer-to-peer networking for detection of heterogeneous illness while maintaining confidentiality with the need for a central coordinator.
\subsection{Protein-to-protein binding affinity prediction}
Central element of almost all cellular processes are protein-to-protein interactions(PPI), so knowledge of the structure of protein-protein complexes and predicting their binding affinity is of major importance to understand PPI and its impact on the virtual screening process \cite{computational_prediction_ppi_2020}. Protein-to-protein docking and binding affinity prediction are substantially more complex and computationally demanding than those for protein-to-small-molecule (which most target-compound pairs in literature usually are). There are some novel rigid body protein-protein docking methods that provide less accurate, yet acceptable models for more complexes than flexible docking methods. Authors in \cite{ppi_docking_performance_2020} are archiving protein-protein docking by fast Fourier transform algorithm used for sampling billions of complex conformations.
There are multiple available scoring schemes and conformational sampling for protein-protein complex structure prediction, while binding affinity approaches can be grouped into structural and sequence based approaches\cite{GROMIHA201731}. There are several software tools\cite{amino_acid_ppi}\cite{ofran_isis:_2007}\cite{vangone_contacts-based_2015} for protein interactions and structure geometry analysis of protein-protein complexes like PSAIA\cite{PSAIA} which uses random forests or web server HDOCK\cite{yan_hdock:_2017} for DNA/RNA docking based on a hybrid model of template-based modeling and free docking. Authors of web based service PSOPIA\cite{murakami_homology-based_2014} for homology-based PPI prediction use combination of three sequence based features: sequence similarities to a known interacting protein pair, statistical propensities of observed interacting protein pairs and sum of edge weights along the shortest path between homologous proteins in a PPI network. There are also studies that focus specifically on some subgroups of proteins to gain better prediction accuracy, like InterPep\cite{protein_peptide_predicting_2019} which is a tool for predicting protein-peptide interactions.
\section{Deep learning methods}
Deep learning (DL) is a computational model composed of multiple processing layers capable of learning data representations with multiple levels of abstraction. Term “deep” defines a subset of machine learning methods that use multiple hidden neural network layers in their architecture layers\cite{Wen20171401}. DL models can detect intricate relationships and structure in large datasets by using the backpropagation algorithm\cite{10.1093/bib/bby061}. Deep neural networks (DNNs) is an artificial computational architecture inspired by networks of neurons formed in the brain, a multilayer network that is represented as a graph with nodes representing neurons and edges representing neural connections.
Basic example of feedforward DNN is multilayer perceptron - MLP but there are many other implementations and variations in literature. For example, deep convolutional nets and deep recurrent nets are improving state-of-the-art in speech and visual objects recognition, text analysis and also biological domains like drug discovery and genomics \cite{lecun_deep_2015}.
Most commonly used machine learning techniques for DTI prediction in literature past few years were variations of DNNs with multiple hidden layers \cite{ma_deep_2015} because of their ability to make better prospective predictions than random forest (RF)\cite{random_forest_bias_2007} or support vector machine (SVM)\cite{svm_cancer} which were commonly used methods in the early 2000s. This is actually a revival of neural networks because they wever superseded by RF and SVM as more robust back at that time.
Each layer of DNN captures specific features from multidimensional, often heterogeneous, data. They are capable of detecting higher-level abstractions from complex sets of features and identifying unknown structures and relationships from raw data in a hierarchical manner.
Convolutional neural networks (CNNs) have gone a long way in image classification\cite{mask_r_cnn} so they are often used in VS when input data can be represented as an image or object with image-like features. In the next chapters of this review, deep learning models are categorized by the neural network architecture they implement.
\subsection{Feedforward deep neural networks}
Feedforward deep neural networks (FF-DNNs) are the first and simplest type of neural networks. Their nodes never form a cycle so information moves in only one direction, forward from input nodes, through hidden layer(s) to output nodes. Architectures like a single or multi layer perceptron are most common although there are architectures implementing a directed acyclic graph which means some input can skip hidden layers.
Authors in \cite{stokes_deep_2020} have used feedforward DNN to discover a molecule from the Drug Repurposing Hub\cite{corsello_drug_2017} that is structurally as different as possible from conventional antibiotics while keeping the same biological activity so it can be used against a wide spectrum of resistant bacteria. Variation of FF-DNN called message passing neural network (MPNN)\cite{yang_analyzing_2019} was used to predict quantum properties of organic molecules which are otherwise computationally expensive to calculate because of a density functional theory (DFT)\cite{becke_densityfunctional_1993} modeling. Three different optimizations were used on MPNN architecture: adding additional molecule-level features from RDKit for large molecules, ensembling with different initial weights and hyperparameter optimization. This speed-up allowed authors to screen multiple chemical libraries in search for structurally distant molecules from known antibiotics.
\subsection{Pairwise input neural networks}
Pairwise input neural networks (PINNs) are a variation of neural networks where the input vector is a combination of both target and compound description vectors. There are some PINNs where a combination of input vectors is processed by the same connected neurons while others use separate groups of neurons for processing target and compound input vectors before they are merged together in a fully connected layer. Pairwise representation is inherently convenient for prediction of pairwise relations like DTI\cite{10.1093/bib/bby061}. Authors in \cite{wan_deep_2016} used unsupervised learning to extract low-dimensional representation of input features which they embedded to a fixed low dimensional space. Amino acid triplets in proteins and compounds molecular structure were represented as word-embeddings so natural language processing (NLP) techniques could be applied to extract hidden structures and relationships.
\subsection{Convolutional neural networks}
Convolutional neural network (CNN) is a neural network modelling approach inspired by neuroscience to imitate images within the visual cortex. In the visual cortex neurons respond to stimuli in their receptive fields, with some neurons overlapping their parts of their receptive fields. CNN architecture is especially adapted to multidimensional input obtained from image pixels, where each hidden layer is recognizing certain critical features such as lines or objects. CNNs ability to to exploit spatial or temporal correlation in data makes CNN techniques very suitable for usage in computer vision and voice recognition\cite{khan_survey_2020}. Facebook’s Mask R-CNN has outperformed all single-model entries on every task in image instance segmentation, bounding-box object detection and person keypoint detection\cite{mask_r_cnn}. Several studies have employed already developed image recognition CNN models for the purpose of virtual screening, biology activity or toxicity predictions, representing input data as images. Authors in \cite{goh_how_2018} represented each compound as an 80x80 pixel image based on their 2D drawing from chemical databases. These images coupled with their biological properties were fed as input to CNN for classification. Model was used for prediction of toxicity, biological activity and solvation free energy. In other research, authors represented drug molecules as 2D graphs with atom features and fed it to CNN to learn molecular features from molecular graphs. These molecular features were used as a dataset for training other prediction models\cite{Altae-Tran2017283}. Their motivation was to significantly lower the amount of data required to make meaningful predictions in drug discovery applications. It was implemented as one-shot learning architecture combining iterative refinement long short-term memory and graph convolutional neural network, which is described in more detail in a separate section. Besides the need for large amounts of training data CNN’s main drawback is its inability to model potential relationships between distant atoms in a raw molecule sequence. Authors in \cite{BECK2020784} have used a combination of CNN and self-attention mechanism\cite{shin_self-attention_2019} (concept initially developed for natural language representation learning) to overcome short backs of CNN for prediction of commercially available antiviral drugs that could act on SARS-CoV-2 virus.
In another example, authors used atom and amino acid embeddings in creating vector representation of protein-ligand complexes further processed by CNN\cite{pereira_boosting_2016}. Here they are using CNN to boost the docking process for virtual screening, which is usually performed by docking software like AutoDock Vina or Dock.
\subsection{Recurrent neural networks}
Recurrent neural networks (RNN) is a type of deep learning architecture designed specifically to handle sequenced data which has achieved great success in fields like NLP and voice recognition. Main difference between FF-DNNs and RNN is that in deep learning methods that follow feedforward architecture there is no connection between nodes in the same hidden layer, only between nodes of different adjacent layers. In RNN architectures there is also a connection between nodes in the same hidden layer which enables them to process sequential information by affiliating adjacent hidden nodes with each other and capturing the calculated information from previous time slices and storing it for the subsequent processing.
Authors in \cite{gupta_generative_2018} used RNN containing long short-term memory (LSTM) cells for de novo drug design. It captured SMILES string molecular representation and learned probability patterns that were used for generation of new SMILES strings. By employing transfer learning this RNN architecture can be fine-tuned for specific molecular targets. In transfer learning the model is keeping information from the previous target while tasked to solve a different but related and yet unseen target. Authors in \cite{olivecrona_molecular_2017} are using RNN to generate novel molecules with some desirable properties, fine-tuning it through augmented episodic likelihood. NN was tested through three step assignment: (i) generating sulfur-free molecules, (ii) generating analogues of the drug Celecoxib and finally (iii) generating novel compounds against an assigned target with 95\% of them predicted to be active.
\subsection{Restricted Boltzmann machine (RBM)/Deep belief networks (DBN)}
Restricted Boltzmann machine is a variation of the single-layer model Boltzmann machine\cite{bengio_learning_2009} in which neurons from visible and hidden layers must form a bipartite graph. “Restricted” implies that they have symmetric connection between them but there are no connections between nodes inside the same layer which allows usage of more efficient training algorithms like gradient-based contrastive divergence algorithm or likelihood gradient \cite{montavon_practical_2012}. By “stacking” RBMs into a deep belief network(DBN) they can be used in deep learning, where usually gradient descent and backpropagation are used for fine-tuning the results.
Authors in \cite{wang_predicting_2013} trained individual RMB for each target and integrated them together into a final model. Main goal of this architecture was to incorporate a heterogeneous set of compounds and targets with different DTIs into a single multidimensional prediction model. They divided interactions as direct and indirect, where physical binding of a compound molecule to a protein is considered direct interaction and all other interactions are considered indirect, for example changing expression levels of genes responsible for encoding target proteins.
On the other hand, authors in \cite{Wen20171401} grouped all target proteins in the same group to train a single predictive model. They only later after training decoupled their model to test the ability of DBN in abstracting of the input data and generating more informative representation in each succeeding hidden layer. They used each layer’s representation to train a simple logistics regression model to predict DTIs. Accuracy of the logistic regression model was getting higher as the hidden layer used for training was deeper in DBNs architecture. This indicated that each hidden layer in DBN was generating more informative and meaningful representation of input data.
\subsection{Graph convolutional neural network}
Graph convolutional networks (GCN) achieved remarkable success during the past 10 years in various domains of bioinformatics. They were developed through efforts to generalize a convolution operator on non-Euclidean structured data, which are in this case graphs. Authors in \cite{sun_graph_2020} point out that graph-based representation of molecules has several advantages over descriptor-based molecule representations: it extracts features with respect to structure of the data and it can automatically extract features from raw input instead of hand picking features and thus potentially leaving out important information or creating bias.
GCN found their applications in molecular property and activity prediction, interaction prediction, synthesis prediction and \textit{de-novo} drug design\cite{wang_pairwise_2014}. Two main approaches to building GCN for virtual drug screening are distincted by their definition of convolution: spatial and spectral GCN. Spatial GCN formulates convolution in spatial domain by summing up all features vectors of neighborhood nodes in a graph, while spectral defines convolution in the graph spectral domain\cite{Defferrard20163844}. Spatial convolution constructs convolution explicitly in the vertex domain. Representation of a single node is updated by recursively aggregating information from its neighborhood nodes. Spectral convolution takes variation of Fourier transformation as the basis for signals defined on a graph, typically focusing on the properties of the graph Laplacian matrix.
Authors in \cite{YingkaiGao20183371},\cite{Duvenaud20152224} used GCNs to overcome common challenges of traditional machine learning used for DTI prediction which are: (i) extensively large chemical space on which search for drug-like compounds is performed, (ii) interaction prediction is usually defined as binary classification problem (e.g. compound is either active or inactive for a single target) making it ineffective for screening against new targets and (iii) lack of biological interpretation.
\subsection{Generative deep neural networks}
Besides processing labeled data in supervised learning, DNNs can be used for analyzing non labeled data in an unsupervised learning process. This is usually achieved with two NNs (e.g. DBN) which act like encoder and decoder, where former maximizes its classification accuracy and latter is maximizing its discrimination accuracy.
Most often seen generative neural networks in literature are variational autoencoder (VAE) and adversarial autoencoder (AAE). Main difference between these two approaches is in the way they compute loss in latent representations. VAE relies on Kullback–Leibler divergence\cite{kullback_information_1951} between distribution obtained from the encoder and prior distribution of input data - we would like to get latent distribution as close to gaussian prior as possible. On the other hand, adversarial AE uses a different approach for getting the term minimized adversarially. AAE achieves the same result by sending samples from latent (“fake”) distribution and samples from a gaussian distribution (“real” samples) to a discriminator which should learn to produce samples similar to prior gaussian distribution.
Authors in \cite{kadurin_drugan:_2017} have used deep generative adversarial network (GAN)\cite{creswell_generative_2018} called druGAN to demonstrate a proof-of-concept for adversarial autoencoder (AAE) used to identify new molecular fingerprints with predefined anticancer and drug-like properties. They show improvement over variational autoencoder (VAE) in terms of adjustability and capacity of processing large molecular sets. Autoencoders have been commonly used for molecular feature extraction purposes while building prediction models for DTI. Various types of autoencoders have capabilities of extracting important features from high dimensional feature space describing targets and compounds, allowing researchers to get better results with sparse datasets\cite{Alain2013RegularizedAE}. There are many examples in recent literature\cite{polykovskiy_entangled_2018}\cite{kadurin_cornucopia_2017} of researchers using autoencoders to extract favourable features from molecular descriptors which they later use for synthesis of novel compounds with the same features through generative adversarial networks.
Authors in \cite{Kadurin201710883} used generative adversarial autoencoders (AAE) for generating novel molecular fingerprints with a defined set of parameters. NCI-60 cell line was used to train AAE with input and output defined as a combination of binary fingerprint vector and log concentration of the molecule. Additional neuron was added to control growth inhibition (GI) percentage which indicates reduction in the number of tumor cells if its value is negative. AEE was trained on MCF-7 cell line assay data for 6252 compounds based on their log concentration, molecular fingerprint and GI data. AEE and decoder were used to generate 32 descriptor vectors containing molecular fingerprint, GI value and concentration. This set of vectors was later screened against 72 million compounds from Pubchem\cite{pubchem} where top 10 hits with maximum likelihood function were filtered. Pubchem BioAssay database \cite{pubchem_bioassay} was used to identify compounds with biological and medical relevance and it was discovered that trained AEE generated some very similar compounds to those that are known to have anticancer activities, mostly similar to anthracyclines.
\subsection{Explainable AI in drug discovery}
DNNs are often limited in their usability due to their black-box nature so different model interpretations were developed for better understanding of the inner-process of training NN and their prediction results\cite{10.1093/bib/bbaa177}.
Explainable, or sometimes referred to as interpretable, artificial intelligence is a collection of methods developed to gain better insight in the training and prediction process of deep learning algorithms. There are several properties of explainable artificial intelligence that are favourable in drug discovery process: (i) transparency (knowing how certain result was reached, e.g. which features play major role), (ii) justification (reasoning why that answer was provided by the model), (iii) informativeness (ability to provide additional, previously unknown, information for human operators) and (iv) uncertainty estimation (quantified measure of how reliable is models prediction)\cite{Lipton2018}. There are many domain-specific challenges in building explainable AI for drug discovery - first of all, drug discovery has inherently problematic modeling of raw data. Unlike image recognition or natural language processing, molecules don’t have complete and raw data representation. It is still not clear which is the best molecule representation and often it is very dependent on the domain of application. This choice of molecular representation becomes a limiting factor in performance and explainability of the model. Molecular representation determines which properties can be explained and which chemical information can be retained (for example, if we represent a molecule with its physicochemical properties then the model can only be interpretable in a regard to those specific properties)\cite{jimenez-luna_drug_2020}.
\section{Conclusion and future challenges}
Appeal of applying artificial intelligence in the drug discovery process is in its potential to build data-driven models from vast datasets generated from high throughput screening(where hit rates are only 0-0-1\%) and to prioritize alternative variations. In the beginning this implies synergy of machine and human intelligence in a specific domain where machines augment capabilities of medicinal chemists in early phases of drug design and selection. Ultimately, the goal is to develop a model capable of autonomously generating new chemical entities (NCEs) of desired properties without the need for human intervention and expensive high throughput screenings. From Schneiders et al.\cite{schneider_rethinking_2020} perspective AI-aided drug design should provide questions to five ‘grand challenges’ in order to be successful in its mission. Those grand challenges are: “obtaining appropriate datasets, generating new hypotheses, optimizing in a multi-objective manner, reducing cycle times and changing the research culture and creating appropriate mindset”. Authors point out that input dataset are key factors when evaluating predictive models and whether those dataset were collected with the final goal in mind. In most cases the relationship between \textit{in vitro} and \textit{in vivo} tests for animal and human patients is not clearly established so models built on surrogate data have inherent limitations. This extends to designing high-throughput screening datasets, protein structure prediction and appropriate meta-data and annotations in databases. There is a lot of work ahead for researchers, with high necessity for interdisciplinary collaboration in order to harvest the full potential of new predictive methods in drug discovery.
\bibliographystyle{ieeetr}
|
{'timestamp': '2022-02-15T02:41:59', 'yymm': '2202', 'arxiv_id': '2202.06635', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06635'}
|
arxiv
|
\section{Introduction}
\label{s:intro}
Recurrent event data are common in clinical studies when participants are followed up longitudinally. Typically, each event occurrence can be subject to right censoring as well as a competing terminal event, such as death. In large pragmatic clinical trials, the event processes are often observed across a heterogeneous population, along with an informative competing event process as well as between-participant clustering. These features bring new challenges for the analysis of clustered recurrent events, due to the need to simultaneously characterize the recurrent event process, non-terminal as well as terminal event survival process as a function of covariates.
Our work is motivated by the Strategies to Reduce Injuries and Develop Confidence in Elders \citep[STRIDE;][]{stride_introduction} study, which is a pragmatic, cluster-randomized trial designed to assess the effectiveness of a patient-centered intervention on fall injury prevention for older adults. More than 6,000 community-dwelling adults from 86 primary care practices were recruited,
with 43 practices randomized to intervention and the remaining to usual care. Participants were followed up every four months via tele-interview; all reported fall injuries were recorded, and a blinded adjudication committee confirmed serious fall injures via medical and claim records from the participating healthcare systems and Centers for Medicare and Medicaid Services data \citep{Ganz2019}.
During the study, 89\% of participants did not experience an adjudicated serious fall injury.
As a simple illustration, we randomly select one practice from both the intervention and usual care group, and present in Figure \ref{stride} the time trajectories for recurrent adjudicated serious fall injuries and an observed death event or censoring for each participant. Irrespective of the intervention, there was an excessive number of participants without events, which signals potential zero-inflation for the recurrent event process.
\begin{figure}
\centering
\includegraphics[width=0.9\textwidth]{survival.pdf}
\caption{An illustration of (right-continuous) time trajectories for serious fall injury occurrence and terminal death event among participants from a randomly selected practice from both the intervention and control group, where `$\circ$' represents censoring, `$\bullet$' represents an occurrence of fall injury, and `$+$' represents the occurrence of death. }\label{stride}
\end{figure}
There is growing literature on the analysis of recurrent events in the presence of a terminal event; see, for example, the estimating equations based approaches under the frequentist paradigm \citep{kalbfleisch2013estimating} and the parametric or semi-parametric models under the Bayesian paradigm \citep{lin2017bayesian,li2019bayesian,li2020time}. A key feature of these methods is the characterization of the dependence between the non-terminal and terminal events under a semi-competing risks perspective \citep{fine2001semi}, as ignoring this dependence can lead to biased inference. To do so, one common strategy is to formulate a joint model with a shared participant-level frailty in the recurrent event and terminal event submodels, where the submodels can either be based on the intensity functions of the event processes \citep{liu2004shared,lee_2019} or the hazard rate of the gap time between two events \citep{zhangsheng2011joint,paulon2020joint}. Despite this growing literature, few existing methods have simultaneously addressed the complications of cluster correlated data as seen in the STRIDE study, whereas failure to account for clustering can result in invalid inference \citep{lee_2016}.
\revise{\cite{jung2019joint} developed an approach that accounted for between-participant clustering in the presence of recurrent and terminal events. A similar joint model was also formulated in \cite{rondeau2015joint} and implemented in the \texttt{R} package \texttt{frailtypack}. However, these existing approaches require strong parametric assumptions on the between-participant clustering effect
and have not accounted for population heterogeneity with respect to event susceptibility.}
The contributions of our work is several-fold. First, we propose a joint model to analyze the recurrent event and survival processes in the presence of between-participant clustering and a competing terminal event. We introduce random effects at the participant level and the practice level, both of which contribute to connecting the recurrent event and survival processes. Second, we address potential zero-inflation within our modeling framework by including a point mass at zero for the recurrent event intensity function. Using a latent indicator to define the status of unsusceptibility for each participant, we are able to directly inform population heterogeneity by separating the unobserved unsusceptible sub-population from the whole study population \citep{liu2016joint,kim2021joint}. \revise{Third, we consider separate nonparametric Dirichlet process priors \citep{ferguson1973bayesian} for the residual in the survival process as well as for the cluster-specific random effect, which, compared with parametric formulations, alleviates potential bias due to model misspecification.}
Finally, we apply the proposed Bayesian semi-parametric approach to analyze data from the STRIDE trial and generate new insights.
The rest of the article is organized as follows. In Sections \ref{s:model} and \ref{sec:BA}, we introduce our Bayesian semi-parametric model including specifications of all submodels, choice of priors, and posterior inference. We evaluate the model performance by comparing with other competing approaches using simulations in Section \ref{sec:simu}, and by analyzing the STRIDE study in Section \ref{sec:data}. We conclude with a discussion in Section \ref{s:discuss}.
\section{Modeling Clustered Recurrent Events in the Presence of a Terminal Event}\label{s:model}
We consider a clustered data structure
with recurrent events that are subject to a terminal event, such as death. We assume $J$ clusters (primary care practices) are recruited, with $N_j$ participants in cluster $j$ and $N=\sum N_j$ participants in total.
Define $Q_{ij}(t)$ as the number of recurrent events prior to or at time $t$ for participant $i$ ($i=1,\ldots,N_j$) within cluster $j$ ($j=1,\ldots,J$). In our motivating STRIDE study, adjudicated serious fall injuries for patients are considered as recurrent events, subject to the risk of death as a terminal event. After a terminal event, recurrent events are no longer observable. In this case, we define time to the terminal event for each participant as $R_{ij}$ and the usual right censoring time (such as administrative censoring) as $C_{ij}$. The observed follow-up time is $\widetilde{R}_{ij}=R_{ij}\wedge C_{ij}$ with a censoring indicator $\Delta_{ij}=1$ if the terminal event is observed and 0 if censored. Equivalently, we observe a total of $Q_{ij}(\widetilde{R}_{ij})$ recurrent events for participant $i$ in cluster $j$. We also write $T_{ijk}\leq \widetilde{R}_{ij}$ as the time when the $k$th ($1\leq k\leq Q_{ij}(\widetilde{R}_{ij})$) recurrent event is observed. For notation purposes, we define the collection of recurrent event times for each participant with at least one event as $\mathbf{T}_{ij}=\{T_{ij1},\ldots,T_{ij,Q_{ij}(\widetilde{R}_{ij})}\}$, and for those with zero events as $\mathbf{T}_{ij}=\emptyset$.
As shown in Figure \ref{stride}, a substantial proportion of participants have not experienced recurrent events, suggesting that some patients may be structurally unsusceptible to fall injuries during the study period, and could have distinctive characteristics from the remaining population. This requires us to separately consider this subgroup for plausibly uncovering the actual event mechanisms.
\revise{To model zero-inflation, we introduce a latent indicator $D_{ij}$ with $D_{ij}=1$ if participant $i$ in cluster $j$ belongs to the subgroup that is unsusceptible to recurrent event during the study period and 0 otherwise}. We consider a point mass mixture of non-homogeneous Poisson process (NHPP) to model the recurrent event hazard (or intensity) function for each participant as
\begin{equation}\label{eq:point}
\lambda_{ij}(t) =
\begin{cases}
\gamma_{ij}\lambda_0(t)\exp{\left(\boldsymbol \beta^T\mathbf X_{ij}+\mu_j\right)} & \text{if $D_{ij}=0$;}\\
0 & \text{if $D_{ij}=1$,}
\end{cases}
\end{equation}
In the hazard function \eqref{eq:point}, $\mathbf X_{ij}$ represent the covariates including the treatment arm and additional baseline characteristics potentially related to the recurrent process, $\boldsymbol \beta$ are the coefficients representing the relationship between $\mathbf X_{ij}$ and recurrent event process among the susceptible subgroup with $D_{ij}=0$, and $\lambda_0(t)$ is the associated baseline hazard. \revise{By definition, a participant belongs to the susceptible subgroup if $Q_{ij}(\widetilde{R}_{ij})>0$; otherwise the participant can belong to either the susceptible or unsusceptible subgroup.} In addition, $\gamma_{ij}$ is the subject-specific frailty accounting for the correlation between recurrent events for the same participant, and $\mu_j$ is the cluster-specific random effect that captures between-participant correlation within the same practice.
There are different options to specify $\lambda_0(t)$ under a Bayesian paradigm. For instance, we could assume a power law model \citep{lee_2019} with $\lambda_0(t)=\psi t^{\psi-1}$, which corresponds to a Weibull baseline hazard with scale parameter 1 and shape parameter $\psi$ controlling the rate of event occurrences. In this case, the survival function for the non-terminal events is parametrically specified as $S_{ij}(t)= \exp\left\{-\gamma_{ij}t^{\psi}\exp\left(\boldsymbol \beta^T\mathbf X_{ij}+\mu_j\right)\right\}$ for the susceptible subgroup, and 1 otherwise. Alternatively, we could also consider a nonparametric specification for $\lambda_0(t)$ with a piecewise constant function \citep{mckeague2000bayesian,jung2019joint} as
\begin{equation}\label{eq:point2}
\lambda_0(t)= \sum_{g=1}^G \mathbf I[ s_{g-1} < t \leq s_{g}] \cdot\lambda_{0g},
\end{equation}
where $\mathbf I[\cdot]$ is the indicator function, $s_{0}=0$, $s_{G}$ represent the largest recurrent event time, and $\{s_{1},\ldots, s_{G-1}\}$ are $G-1$ grid points that partition the time interval such that baseline hazard is a constant $\lambda_{0g}$ over $(s_{g-1}, s_{g}]$. While the power law model assumes a monotone baseline hazard, the piecewise constant model can be more flexible and more robust to model assumptions.
In what follows, we will primarily focus on the piecewise constant model \eqref{eq:point2}; discussions and numerical results under the power law baseline hazard are provided in the supplementary materials.
\iffalse
Furthermore, we assume a power law model \citep{lee_2019} for the baseline hazard, i.e.
$\lambda_0(t)=\psi t^{\psi-1}$, which can also be viewed as a Weibull hazard with scale parameter 1 and shape parameter $\psi$ controlling the rate of event occurrences.
Accordingly, the survival function for the non-terminal events is written as
\begin{equation}\label{eq:point2}
S_{ij}(t) =
\begin{cases}
\exp\{-\gamma_{ij}t^{\psi}\exp\left(\boldsymbol \beta^T\mathbf X_{ij}+\mu_j\right)\} & \text{if $D_{ij}=0$;}\\
1 & \text{if $D_{ij}=1$.}
\end{cases}
\end{equation}
Of note, there are other options to specify $\lambda_0(t)$, such as nonparametric piecewise constant functions \citep{mckeague2000bayesian}. Given the computational advantage of the parametric baseline hazard formulations, and the flexibility that we will gain from our subsequent nonparametric random effects terms, we choose to implement the above parametric baseline hazard in our illustration and numerical studies.
\fi
\revise{For survival process of the terminal event, we consider an accelerated failure time (AFT) model incorporating the hierarchical random effects shared with the recurrent event model
\begin{equation}\label{eq:aft}
\log(R_{ij})=\alpha_0+\boldsymbol \alpha^T\mathbf Z_{ij}+\xi_1\log(\gamma_{ij})+\xi_2\mu_j+\kappa_{ij}^{-1}\epsilon_{ij},
\end{equation}
where $\kappa_{ij}^{-1}$ is the participant-specific shape parameter and $\epsilon_{ij}$ is the independent and
identically distributed residual error for the log survival time. In \eqref{eq:aft}, $\alpha_0$ is the intercept that captures the common factor across subjects, $\mathbf Z_{ij}$ is the set of covariates associated with the terminal event time with coefficients $\boldsymbol \alpha$ and can differ from $\mathbf X_{ij}$ in the recurrent event model \eqref{eq:point}, and coefficients $\xi_1$ and $\xi_2$ control the degree of unobserved associations between the recurrent and terminal event processes at the participant level and cluster level, respectively.} This above model representation indicates that the participant-level frailty $\gamma_{ij}$ and the cluster-level random effect $\mu_j$ jointly affect the relative change in survival time for the terminal event to account for the variation beyond that captured by the observed covariates. Meanwhile, model \eqref{eq:aft} and the recurrent event intensity model \eqref{eq:point} share the hierarchical random effects to induce an informative terminal event process. To interpret this in the STRIDE study, an elderly participant who is more susceptible to repeated occurrences of falls may be either more likely or unlikely to survive until the end of the study, as captured by the participant-level frailty $\gamma_{ij}$ and its coefficient $\xi_1$. Similar interpretation also applies to the practice-level frailty $\mu_j$ and its coefficient $\xi_2$ in the terminal process submodel.
\revise{For AFT model \eqref{eq:aft}, a canonical parametric specification is to assume that residual error $\epsilon_{ij}$ follows a standard extreme value distribution and $\kappa_{ij}=\kappa$ $\forall~i,j$. Under this parameterization, the AFT model implies a Weibull hazard function for the terminal event time with $h_{ij}(t\mid \kappa_{ij}=\kappa)=\gamma_{ij}^{-\kappa\xi_1} t^{\kappa-1}\kappa\exp\left\{-\kappa\left(\alpha_0+\boldsymbol \alpha^T\mathbf Z_{ij}+\xi_2\mu_j\right)\right\}$. Accordingly, the survival function becomes $H_{ij}(t\mid \kappa_{ij}=\kappa)=\exp\left[-\gamma_{ij}^{-\kappa\xi_1}t^{\kappa}\exp\big\{-\kappa\left(\alpha_0+\boldsymbol \alpha^T\mathbf Z_{ij}+\xi_2\mu_j\right)\big\}\right]$. The AFT model with the homogeneous error distribution, though easy to implement, may be less robust to between-participant heterogeneity in their baseline risk to the terminal event. To enhance model robustness, we consider a nonparametric Dirichlet process ($\mathcal{DP}$) model to model the error distribution. Specifically, we assume the participant-specific shape parameter
\begin{equation}\label{eq:DP0}
\kappa_{ij}\ \mid F \overset{\text{i.i.d}}{\sim} F,~~j=1,\dots, J; i=1,\dots, N_j; \qquad F\sim \mathcal{DP}(\phi_0, F_0).
\end{equation}
Here, $F_0$ is called a base measure that defines the expectation of the random probability $F\in \mathbb{R}$ from which $\kappa_{ij}$ is sampled from, and $\phi_0$ is the scale parameter describing the overall sampling concentration or the variance of the random probability measure. We specify $F_0$ as a Gamma distribution $\mathcal{G}(a_{\kappa}, b_{\kappa})$, and assign a non-informative Gamma distribution for scale parameter $\phi_0\sim \mathcal{G}(1, 1)$ to ensure adequate flexibility. Essentially, model \eqref{eq:DP0} induces a nonparametric realization for the shape parameters, which then corresponds to a more flexible form of the hazard and survival functions. To elaborate on this point, we can represent the $\mathcal{DP}$ model in \eqref{eq:DP0} by an infinite mixtures of point masses \citep{sethuraman1994constructive}
\begin{eqnarray}
F&=&\sum_{k=1}^\infty \pi_k\mu_{\theta_k}, \qquad \text{with} \quad \pi_k=\pi'_k\prod_{h=1}^{k-1}(1-\pi'_h),\label{DP3}
\end{eqnarray}
where $\mu_\theta$ is a probability measure concentrated at $\theta$, and the
two sets of independent and identically distributed random variables $\{\pi'_k\}_{k=1}^{\infty}$ and $\{\theta_k\}_{k=1}^{\infty}$ follow
\begin{eqnarray}\label{DP2}
\pi'_k\mid G_0,\phi \sim \text{Beta}(1, \phi_0); \qquad \theta_k\mid F_0,\phi\sim F_0;\qquad k=1,\dots,\infty.
\end{eqnarray}
Here, $\{\theta_k\}_{k=1}^\infty$ is a sequence of independent draws from the base measure $F_0$, and $\{\pi_k\}_{k=1}^\infty$ are the weight parameters constructed via a stick-breaking representation. With probability one, $F$ is a discrete distribution as a combination of infinite number of point masses. Under weights $\{\pi_k\}_{k=1}^\infty$, realization of each $\kappa_{ij}$ will be obtained directly from $F$ consisting of components $\{\theta_k\}_{k=1}^\infty$. The induced survival function for participant $i$ in cluster $j$ then becomes an infinite mixture of Weibull survival functions given by
\begin{equation*}
\sum_{k=1}^\infty \pi_k H_{ij}(t\mid \kappa_{ij}=\theta_k)=\sum_{k=1}^\infty \pi_k \exp\left[-\gamma_{ij}^{-\theta_k\xi_1}t^{\theta_k}\exp\big\{-\theta_k\left(\alpha_0+\boldsymbol \alpha^T\mathbf Z_{ij}+\xi_2\mu_j\right)\big\}\right],
\end{equation*}
and the associated hazard function corresponds to a similar infinite mixture of Weibull hazards
\begin{align*}
\sum_{k=1}^\infty \left\{\frac{\pi_k H_{ij}(t\mid \kappa_{ij}=\theta_k)}{\sum_{l=1}^\infty \pi_l H_{ij}(t\mid \kappa_{ij}=\theta_l)}\right\}
\gamma_{ij}^{-\theta_k\xi_1} t^{\theta_k-1}\theta_k\exp\left\{-\theta_k\left(\alpha_0+\boldsymbol \alpha^T\mathbf Z_{ij}+\xi_2\mu_j\right)\right\},
\end{align*}
both of which are arguably much more flexible than their canonical, fully parametric counterparts. Meanwhile, as shown in \eqref{DP3}, with $k$ increased, $\pi_k$ decreases exponentially and concentrates the sampling on a number of initial components. This allows the residual error distributions to group based on their identical shape parameter values, and in turn, induces a clustering effect to dissect subgroup of individuals sharing a similar shape of the survival function. Finally, the canonical AFT specification can be considered as a special case of \eqref{DP3} with a degenerate Dirac measure.
}
\iffalse
To model the survival process for the terminal event, we consider a Weibull regression incorporating the hierarchical random effects shared with the recurrent event model \eqref{eq:point}.
Specifically, we assume the hazard for the terminal event among those with $D_{ij}=0$ as
\begin{align}
\begin{split}
\label{eq:sur}
h_{ij}(t)&=\kappa t^{\kappa-1}\exp\big\{-\kappa\left(\alpha_0+\boldsymbol \alpha^T\mathbf Z_{ij}+\xi_1\log(\gamma_{ij})+\xi_2\mu_j\right)\big\}\\
&=\gamma_{ij}^{-\kappa\xi_1} t^{\kappa-1}\kappa\exp\big\{-\kappa\left(\alpha_0+\boldsymbol \alpha^T\mathbf Z_{ij}+\xi_2\mu_j\right)\big\},
\end{split}
\end{align}
with shape parameter $\kappa$. In model \eqref{eq:sur}, $\alpha_0$ is the intercept that captures the common factor across subjects; $\mathbf Z_{ij}$ is the set of covariates associated with the terminal event process with coefficients $\boldsymbol \alpha$, and can differ from $\mathbf X_{ij}$ in model \eqref{eq:point}. The coefficients, $\xi_1$ and $\xi_2$, control the degree of unobserved associations between the recurrent and terminal event processes at the participant level and cluster level, respectively; and we can also view $\gamma_{ij}^{-\kappa\xi_1}$ as the subject-specific adjustment for the survival hazard compared to $\gamma_{ij}$ on the recurrent event hazard for the susceptible subgroup.
Under this parameterization, the survival function for the terminal event becomes $$H_{ij}(t)=\exp\left[-\gamma_{ij}^{-\kappa\xi_1}t^{\kappa}\exp\big\{-\kappa\left(\alpha_0+\boldsymbol \alpha^T\mathbf Z_{ij}+\xi_2\mu_j\right)\big\}\right].$$
Alternatively, model \eqref{eq:sur} itself can be reformulated as an accelerated failure time (AFT) model, since we can write the log survival time as
\begin{equation}\label{eq:aft}
\log(R_{ij})=\alpha_0+\boldsymbol \alpha^T\mathbf Z_{ij}+\xi_1\log(\gamma_{ij})+\xi_2\mu_j+\kappa^{-1}\epsilon_{ij},
\end{equation}
where the residuals, $\epsilon_{ij}$'s, are independent and identically distributed according to an extreme value distribution. The AFT model representation indicates that the participant-level frailty $\gamma_{ij}$ and the cluster-level random effect $\mu_j$ jointly affect the relative change in survival time for the terminal event to account for the variation beyond that captured by the observed covariates. Meanwhile, model \eqref{eq:aft} and the recurrent event intensity model, equation \eqref{eq:point}, share the hierarchical random effects to induce an informative terminal event process. To interpret this in the STRIDE study, an elderly participant who is more susceptible to repeated occurrences of falls may be either more likely or unlikely to survive until the end of the study, as captured by the participant-level frailty $\gamma_{ij}$ and its coefficient $\xi_1$. Similar interpretation also applies to the practice-level frailty $\mu_j$ and its coefficient $\xi_2$ in the terminal process submodel.
\fi
\section{Bayesian Inference}\label{sec:BA}
\subsection{Prior Specification}\label{sec:prior}
To jointly characterize the zero-inflated recurrent events and terminal event process, the proposed joint modeling framework involves the following unknown parameters:
regression coefficients $\boldsymbol \beta$, $\boldsymbol \alpha$, $\xi_1$, and $\xi_2$, participant-level and cluster-level random effects $\boldsymbol \gamma=\{\gamma_{ij}\}$ and $\boldsymbol\mu=\{\mu_j\}$, latent indicator $\mathbf D=\{D_{ij}\}$, \revise{shape parameter $\boldsymbol \kappa=\{\kappa_{ij}\}$ for the terminal event submodel, grid points $\mathbf s$, and piecewise constants $\boldsymbol\lambda=(\lambda_{01},\dots,\lambda_{0G})$ for the recurrent event submodel. }
The hierarchical random effects play an important role in connecting the recurrent and survival processes, since they represent shared unmeasured factors in addition to those captured by the baseline covariates.
The frailty $\boldsymbol \gamma$ is directly grouped by different practices the participants belong to and provides quantification of between-participant heterogeneity, while the practice-specific random effects $\boldsymbol\mu$ account for between-practice heterogeneity. We assume independence between elements of $\boldsymbol \gamma$ and assign $\gamma_{ij}\sim \mathcal{LN}(0,\tau_j^2)$, where $\mathcal{LN}$ represents, a log-normal distribution and $\tau^2_j$ represents a practice-specific variance parameter; and we adopt an Inverse Gamma ($\mathcal{IG}$) hyper-prior such that $\tau_j^2\sim \mathcal{IG}(a_0,b_0)$. For $\boldsymbol\mu$, instead of using parametric conjugate priors, we consider again a nonparametric $\mathcal{DP}$ prior by assuming
\begin{equation}\label{eq:DP}
\mu_j\ \mid G \overset{\text{i.i.d}}{\sim} G,~~j=1,\dots, J; \qquad G\sim \mathcal{DP}(\phi, G_0).
\end{equation}
We specify base measure $G_0$ as the mean zero normal distribution, $\mathcal{N}(0, \sigma^2)$, and assign $\phi\sim \mathcal{G}(1, 1)$ to ensure adequate flexibility. Prior \eqref{eq:DP} induces a nonparametric representation for the random effects over practices. Since the inference of model parameters may be sensitive to parametric assumptions of the practice-level random effects \citep{gasparini2019impact}, this nonparametric prior can induce more robust characterization of the quality of care in each practice. \revise{To facilitate posterior inference under \eqref{eq:DP}, following \eqref{DP3} and \eqref{DP2}, we also resort to an infinite mixtures of point masses representation under the point mass random set $\{\eta_{l}\}_{l=1}^{\infty}$ where each $\mu_j$ sampled from under the weights $\{\tilde{\pi}_{l}\}_{l=1}^{\infty}$. This will also group the realization of each element within $\boldsymbol\mu$ together by their identical values}, indicating, for example, similar quality of care across the included practices.
In STRIDE, the primary care practices are nested within different health care systems, which could induce inter-practice similarity. Although we do not directly account for heterogeneity across health systems beyond that across practices,
the implicit clustering effect due to the $\mathcal{DP}$ prior automatically identifies more similar practices according to values of $\mu_j$, either within or across different health systems, and provides additional flexibility beyond a single random effect at the health system level.
Alternatively, in the absence of a clear grouping pattern between practices in terms of quality of care, we can still rely on \eqref{eq:DP} to potentially reduce the number of unknown practice-level random effects.
\iffalse
In our model formulation, it is theoretically possible to further replace the $\mathcal{LN}$ prior with a $\mathcal{DP}$ prior for the participant-level frailty $\gamma_{ij}$, which, for example, has been adopted previously in \cite{lee_2019} in the absence of between-participant correlation.
However, for the analysis of STRIDE, there are naturally more participants than practices, and we choose to prioritize flexible prior specification for the practice-level random effects and consider parametric prior specification for the participant-level frailty for better identifiability and improved computational efficiency.
\fi
We further assume the latent indicator $D_{ij}$ follows
$D_{ij}\sim \text{Bern}(p_{ij})$, $i=1,\dots,N_j$, $j=1,\dots,J$, with $p_{ij}$ being the participant-specific probability to be classified into the unsusceptible subgroup. In practice, when there is prior knowledge on potential risk factors that are associated with an individual's susceptibility status for recurrent events, we can adopt a logistic model
\begin{eqnarray}\label{eq:logit}
\text{logit}(p_{ij})=\boldsymbol \zeta^T\mathbf U_{ij},
\end{eqnarray}
where $\mathbf U_{ij}$ includes an intercept as well as risk factors for susceptibility and $\boldsymbol \zeta$ represents the regression coefficients. In other cases without strong prior information on such covariates, we could instead assume that $p_{ij}$ takes a constant value, say $0.5$, which leads to a non-informative prior for the latent indicator $D_{ij}$. This non-informative prior specification can be regarded as a special case of \eqref{eq:logit} by removing the non-intercept terms in $\mathbf U_{ij}$ and specifying a fixed intercept parameter.
For generality, we will discuss posterior inference under a general logistic formulation \eqref{eq:logit}.
\revise{In terms of the baseline hazard in the recurrent event process, following \cite{jung2019joint}, we pre-specify $\mathbf s$ as quantiles based on the minimum to the maximum recurrent event time, and adopt a uniform prior $(0, \infty)$ for each element within $\boldsymbol\lambda$.}
To complete prior specification, we assign priors for the remaining model parameters such that $\boldsymbol \beta\sim \mathcal{N}(\boldsymbol 0,\sigma^2_\beta\mathbf{I})$, $\boldsymbol \alpha\sim \mathcal{N}(\boldsymbol 0,\sigma^2_\alpha\mathbf{I})$, $\boldsymbol \zeta\sim \mathcal{N}(\boldsymbol 0,\sigma^2_\zeta\mathbf{I})$, $\xi_1\sim \mathcal{N}(0,\sigma^2_{\xi_1})$, $\xi_2\sim \mathcal{N}(0,\sigma^2_{\xi_2})$; and further assign conjugate $\mathcal{IG}$ hyper-priors for $\sigma_{\beta}^2$ and $\sigma_{\alpha}^2$ and pre-specify the remaining hyper-parameters with reasonable values without strong prior impact on the posterior inference. For an overview of our method, Figure \ref{fig:demo} provides a graphical illustration of the data structure along with the modeling assumptions.
\begin{figure}
\centering
\includegraphics[width=0.9\textwidth]{demo.pdf}
\caption{A graphical demonstration of the multi-level data structure and our proposed Bayesian joint model for the zero-inflated recurrent events and semi-competing survival process. }
\label{fig:demo}
\end{figure}
\subsection{Likelihood and Posterior Inference}\label{sec:posterior}
Given the observed data $\mathcal{O}_{ij}=\left\{\widetilde{R}_{ij}, \Delta_{ij}, \mathbf{T}_{ij}, Q_{ij}(\widetilde{R}_{ij}), \mathbf X_{ij}, \mathbf Z_{ij}, \mathbf U_{ij}\right\}$ for each subject $i~ (i=1,\dots, N_j)$ within practice $j~ (j=1,\dots,J)$, we need to carefully distinguish between different events and survival states, as well as the subgroup each subject belongs to, in order to carry out inference for all model parameters. \revise{For example, while each participant may be may not be susceptible to recurrent events, all participants are susceptible to the terminal events in the STRIDE application.}
With the unknown parameters $\boldsymbol \Theta=\left\{\boldsymbol \beta,\boldsymbol \alpha,\boldsymbol \zeta,\boldsymbol \gamma,\boldsymbol\mu,\mathbf D,\xi_1,\xi_2,\boldsymbol \kappa; \phi \text{ or } \boldsymbol\lambda \right\}$, the observed data likelihood involves a combination of probabilities for structural zeros among the unsusceptible subgroup, recurrent events, and terminal events, and is given by
\revise{\begin{eqnarray*}\label{eq:likelihood}
\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)&=& \prod^J_{j=1}\prod_{i=1}^{N_j}\left\{D_{ij}+(1-D_{ij})(1-\Delta_{ij})S_{ij}(\widetilde{R}_{ij})H_{ij}(\widetilde{R}_{ij})+(1-D_{ij})\Delta_{ij}S_{ij}(\widetilde{R}_{ij})\right.\\
&&\left.\times f_{ij}(\widetilde{R}_{ij})\right\}^{I\left[Q_{ij}(\widetilde{R}_{ij})=0\right]}\times
\left\{\Delta_{ij}\prod_{k=1}^{Q_{ij}(\widetilde{R}_{ij})}\lambda_{ij}(T_{ijk})S_{ij}(\widetilde{R}_{ij})f_{ij}(\widetilde{R}_{ij})\right.\\
&&\left.+(1-\Delta_{ij})\prod_{k=1}^{Q_{ij}(\widetilde{R}_{ij})}\lambda_{ij}(T_{ijk})S_{ij}(\widetilde{R}_{ij})H_{ij}(\widetilde{R}_{ij})\right\}^{I\left[Q_{ij}(\widetilde{R}_{ij})>0\right]},
\end{eqnarray*}}where $f_{ij}(\widetilde{R}_{ij})=h_{ij}(\widetilde{R}_{ij})H_{ij}(\widetilde{R}_{ij})$ is the density function for the terminal event process of participant $i$ in practice $j$ evaluated at the observed survival time $\widetilde{R}_{ij}$, and the indicator function $I[\cdot]$ separating the likelihood for those with and without recurrent events. By combining the observed data likelihood with our prior specification, we obtain the joint posterior distribution of $\boldsymbol \Theta$, from which we perform estimation and inference for each of the unknown parameters.
For posterior inference, we develop a Markov Chain Monte Carlo (MCMC) algorithm based on a combination of Gibbs sampler and Metropolis-Hastings (MH) updates. Specifically, we randomly initialize the model parameters and then cycle through the following steps:
\begin{itemize}
\setlength\itemsep{0.2em}
\item Sample each element of $\mathbf D$ from its posterior Bernoulli distribution.
\item For the recurrent event submodel, update each element of $\boldsymbol \beta$ via its MH step; \revise{and update each element of $\boldsymbol\lambda$ in the baseline hazard from its MH step.}
\item For the terminal event submodel, update $\alpha_0$ and each element of $\boldsymbol \alpha$ via the corresponding MH steps. \revise{For the individual shape parameter $\boldsymbol \kappa$, we implement an approximate sampling procedure under the truncated stick-breaking process \citep{ishwaran2001gibbs,li2015spatial}, where a conservative upper bound $K$ larger than the possible number of latent groups for the mixture of $\kappa_{ij}$'s is assigned.
By introducing a mapping indicator set $\mathbf v=(v_{11},\dots,v_{N_J,J})$ with $v_{ij}\in\{1,\dots,K\}$ following a Multinomial distribution with probabilities $\{\pi_1,\dots,\pi_K\}$, we align each $\kappa_{ij}$ to its latent membership label $v_{ij}$. Within the same group membership label, the $\kappa_{ij}$'s are considered identical. Therefore, we update each $v_{ij}$ from the posterior Multinomial distribution, sample $\kappa_{ij}$ within each of the $K$ clusters via a MH step, and update $\pi_k=\pi'_k\prod_{h<k}(1-\pi'_h)$ with $\pi'_h$ sampled from the Beta distribution.}
\item For the participant-specific frailty, update each $\gamma_{ij}$ via the MH step and sample the frailty variance $\tau_j^2$ from its posterior $\mathcal{IG}$ distribution for $i=1,\dots, N_j, j=1,\ldots,J$.
\item For the practice-specific random effect $\boldsymbol\mu$, we implement a similar sampling procedure as that for $\boldsymbol \kappa$ by assigning a conservative upper bound $L$ and
introducing a mapping indicator set $\mathbf{m}=(m_1,\dots,m_J)$ with each element following a Multinomial distribution with probabilities $\{\tilde{\pi}_1,\dots,\tilde{\pi}_L\}$. The update for each $\mu_j$, $m_j$ and $\tilde{\pi}_l$ follow a similar procedure as before.
\item For the shared random effects in the terminal event submodel, update $\xi_1$ and $\xi_2$ via the corresponding MH steps.
\item For the logistic model, update each element of $\boldsymbol \zeta$ via the corresponding MH step.
\end{itemize}
The full computational details are provided in the supplementary materials. We implement this MCMC algorithm with different initial values and check the posterior convergence by both trace plots and the Gelman-Rubin method \citep{gelman1992inference}. Based on the posterior samples (after burn-in), we can directly obtain the point and credible interval estimators for each parameter using the posterior mean and associated quantiles.
\section{Simulation Studies} \label{sec:simu}
We carry out simulation studies to assess the finite-sample performance of the proposed Bayesian semi-parametric joint model and compare with alternative modeling approaches.
Although our motivating STRIDE study recruited 86 practices, we simulate 60, 40, 20 practices, representing more challenging scenarios with fewer clusters. We assume equal numbers of participants per practice and consider $N=1,800$, $N=1,200$ and $N=600$ as three levels of total sample sizes.
For each participant,
we specify the covariates $\mathbf Z_{ij}$ for the terminal event as a three-dimensional vector with each element generated from $\mathcal{N}(0,0.1^2)$ and set $\boldsymbol \alpha=(0.2, 0.3, 0.4)^T$.
We then generate the frailty $\gamma_{ij}\sim \mathcal{LN}(0, 0.3)$ with a common variance component across all practices,
and we consider a five-component mixture of normals to simulate the practice-level random effect,
$$\mu_{j} \stackrel{\text{ind}}{\sim}0.2\mathcal{N}(-0.4,0.1^2)+0.2\mathcal{N}(-0.2,0.1^2)+0.2\mathcal{N}(0,0.1^2)+0.2\mathcal{N}(0.2,0.1^2)+0.2\mathcal{N}(0.4,0.1^2).$$
\revise{We simulate the survival time $R_{ij}$ with the shape parameter $\kappa$ drawing randomly from the discrete value set $\{0.7, 2.2, 5.2, 8.2\}$} and $\alpha_0=0.15$, $\xi_1=0.1$, $\xi_2=-0.5$. To determine censoring status, we generate independently from $\Delta_{ij}{\sim}\text{Bern}(0.5)$. When $\Delta_{ij}=0$, we generate the observed survival time $\widetilde{R}_{ij}$ from a Uniform distribution under $(0, R_{ij})$; when $\Delta_{ij}=1$, we directly equate $\widetilde{R}_{ij}=R_{ij}$.
For the recurrent process, we first specify the covariates $\mathbf X_{ij}$ for the recurrent events including the first two elements of $\mathbf Z_{ij}$ and a third element generated from $\mathcal{N}(0,0.1^2)$,
then let $\mathbf U_{ij}$ for the susceptibility status be the union of $\mathbf X_{ij}$ and $\mathbf Z_{ij}$. We set $\boldsymbol \zeta=(1,1,1,1)^T$ to simulate the latent indicator $D_{ij}$ with probability $p_{ij}$ and $\boldsymbol \beta=(0.4, 0.3, 0.2)^T$. \revise{To generate the recurrent event process $Q_{ij}(t)$, we consider a piecewise constant baseline hazard specified by quintile grids and $(\lambda_{01},\lambda_{02},\lambda_{03},\lambda_{04},\lambda_{05})^T=(2,2.3,2.1,2.4,1.7)^T$
and censor the recurrent events at time $\widetilde{R}_{ij}$. For the unsusceptible subgroup, we set $Q_{ij}(\widetilde{R}_{ij})=0$ but without impacting the terminal event time}.
We also consider different sample sizes
and \revise{simulate $250$ data replicates for each setting.}
\revise{To implement our method, we set $\sigma^2_{\zeta}=\sigma^2_{\xi_1}=\sigma^2_{\xi_2}=10$ to give non-informative normal priors, $a_{\kappa}=b_{\kappa}=1$ for the Gamma base measure, $\sigma^2=1$ for the normal base measure, and $\mathcal{IG}(1/2, 1/2)$ for the conjugate priors of $\sigma^2_{\beta}$ and $\sigma^2_{\alpha}$. We also consider $G=5$ to specify the quantile grids in $\mathbf s$.
In each implementation, multiple chains with randomly generated initial values are run for 10,000 iterations
with the first 5,000 as burn-in. Our results show that the posterior inference is insensitive to the
initial values with a proper mixing for each parameter. In addition to implementing our proposed model (abbreviated as BMZ-$\mathcal{DP}$ for the Bayesian multi-level zero-inflated $\mathcal{DP}$ model),
we also consider three variations of BMZ-$\mathcal{DP}$ by simplifying certain model components: (1) BM-$\mathcal{DP}$, which ignores the structural zeros by modeling recurrent event hazard with a single mode Poisson process; (2) BZ-$\mathcal{DP}$, which ignores the multi-level data structure by omitting the practice-level random effects; (3) BMZ, which replaces the nonparametric $\mathcal{DP}$ prior for $\mu_j$ with a fully parametric normal prior, as well as (4) the joint frailty model under a frequentist paradigm implemented in the {\tt{R}} package {\tt{frailtypack}} \citep{rondeau2012frailtypack,rondeau2015joint}, which accounts for the multi-level data structure but ignores structural zeros.} Of note, BZ-$\mathcal{DP}$ is a variation of the approach developed in \cite{lee_2019} with the addition of the susceptible subgroup, and BMZ is a pure Bayesian parametric implementation.
The priors and hyper-parameters for the three Bayesian model variations largely follow those for BMZ-$\mathcal{DP}$; and \revise{for the frequentist joint frailty model (denoted as frailty), we use the ``frailtyPenal'' function which is designed to fit a joint frailty model for clustered data and closest to our setting (with gamma-distributed participant-level frailty and practice-level frailty). }For each method, we summarize the mean or posterior mean, percentage bias (\%) relative to the true value, and the 95\% confidence or credible intervals (CIs) for the primary parameters of interest, $\boldsymbol \beta=(\beta_1,\beta_2,\beta_3)^T$ and $\boldsymbol \alpha=(\alpha_1,\alpha_2,\alpha_3)^T$ in Table \ref{table:result}.
\begin{table}
\centering
\caption{Simulation results under sample sizes 600, 1200, 1800 for all the methods summarized by mean or posterior mean (Mean), percentage bias (Bias (\%)) and coverage probability of the 95\% credible interval (Coverage (\%)).}\label{table:result}
\resizebox{0.75\textwidth}{!}{
\begin{tabular}{cccrrrrrrr}
\toprule
& & & \multicolumn{3}{c}{Recurrent Process} & & \multicolumn{3}{c}{Survival Process} \\
\cmidrule(lr){4-6}\cmidrule(lr){7-10}
\multirow{3}{*}{} $N$ & & Method & $\beta_{1}$ & $\beta_{2}$ & $\beta_3$ & & $\alpha_1$ & $\alpha_2$ & $\alpha_3$ \\
\hline \hline
& & BMZ-$\mathcal{DP}$ & 0.41 & 0.31 & 0.25 & & 0.20 & 0.32 & 0.40 \\
& & BM-$\mathcal{DP}$ & -0.04 & -0.15 & -0.22 & & 0.21 & 0.31 & 0.41 \\
\multirow{3}{*}{} & Mean & BZ-$\mathcal{DP}$ & 0.52 & 0.45 & 0.37 & & 0.21 & 0.32 & 0.40 \\
& & BMZ & 0.43 & 0.35 & 0.29 & & 0.22 & 0.33 & 0.42 \\
& & Frailty & -0.08 & -0.16 & -0.28 & & 0.02 & 0.06 & -0.05 \\
\cmidrule(lr){4-6}\cmidrule(lr){7-10}
& & BMZ-$\mathcal{DP}$ & 2.20 & 2.93 & 26.22 & & 2.21 & 6.25 & 0.67 \\
& & BM-$\mathcal{DP}$ & -111.15 & -148.38 & -210.02 & & 4.63 & 2.85 & 2.57 \\
600 & Bias (\%) & BZ-$\mathcal{DP}$ & 29.03 & 48.87 & 84.75 & & 6.92 & 8.15 & 0.58 \\
& & BMZ & 9.40 & 17.41 & 44.09 & & 10.72 & 9.69 & 3.83 \\
& & Frailty & -118.88 & -153.00 & -237.96 & & -90.21 & -80.77 & -113.39 \\
\cmidrule(lr){4-6}\cmidrule(lr){7-10}
& & BMZ-$\mathcal{DP}$ & 88.59 & 84.56 & 79.19 & & 95.91 & 92.87 & 96.95 \\
& & BM-$\mathcal{DP}$ & 1.49 & 1.33 & 1.33 & & 93.81 & 90.90 & 75.36 \\
& Coverage (\%) & BZ-$\mathcal{DP}$ & 66.32 & 54.63 & 50.98 & & 93.87 & 89.79 & 95.91 \\
& & BMZ & 82.31 & 79.02 & 70.95 & & 91.83 & 85.37 & 89.79 \\
& & Frailty & 1.49 & 1.49 & 0.00 & & 79.66 & 74.58 & 62.71 \\
\hline
& & BMZ-$\mathcal{DP}$ & 0.38 & 0.31 & 0.23 & & 0.20 & 0.31 & 0.40 \\
& & BM-$\mathcal{DP}$ & -0.05 & -0.13 & -0.24 & & 0.21 & 0.31 & 0.43 \\
& Mean & BZ-$\mathcal{DP}$ & 0.50 & 0.44 & 0.37 & & 0.21 & 0.32 & 0.41 \\
& & BMZ & 0.42 & 0.35 & 0.27 & & 0.21 & 0.33 & 0.41 \\
& & Frailty & -0.08 & -0.17 & -0.28 & & 0.05 & -0.03 & -0.05 \\
\cmidrule(lr){4-6}\cmidrule(lr){7-10}
& & BMZ-$\mathcal{DP}$ & -4.66 & 2.93 & 16.37 & & 0.27 & 3.52 & 0.96 \\
& & BM-$\mathcal{DP}$ & -111.81 & -144.49 & -220.16 & & 4.59 & 3.43 & 6.38 \\
1200 & Bias (\%) & BZ-$\mathcal{DP}$ & 25.30 & 46.01 & 84.45 & & 4.03 & 6.89 & 1.77 \\
& & BMZ & -121.00 & 16.70 & 36.13 & & 2.64 & 8.34 & 3.57 \\
& & Frailty & 6.18 & -158.67 & -238.52 & & -77.35 & -108.81 & -113.37 \\
\cmidrule(lr){4-6}\cmidrule(lr){7-10}
& & BMZ-$\mathcal{DP}$ & 84.85 & 84.52 & 83.46 & & 94.87 & 90.34 & 94.92 \\
& & BM-$\mathcal{DP}$ & 1.12 & 1.12 & 0.03 & & 84.39 & 90.88 & 52.32 \\
& Coverage (\%) & BZ-$\mathcal{DP}$ & 58.86 & 40.56 & 25.34 & & 86.77 & 85.13 & 95.46 \\
& & BMZ & 80.92 & 72.34 & 71.76 & & 82.54 & 85.37 & 85.47 \\
& & Frailty & 1.33 & 1.33 & 1.33 & & 71.19 & 62.71 & 55.93 \\
\hline
& & BMZ-$\mathcal{DP}$ & 0.37 & 0.31 & 0.22 & & 0.20 & 0.30 & 0.40 \\
& & BM-$\mathcal{DP}$ & -0.05 & -0.13 & -0.24 & & 0.21 & 0.31 & 0.42 \\
& Mean & BZ-$\mathcal{DP}$ & 0.51 & 0.44 & 0.35 & & 0.22 & 0.32 & 0.40 \\
& & BMZ & 0.43 & 0.37 & 0.27 & & 0.21 & 0.32 & 0.42 \\
& & Frailty & -0.07 & -0.16 & -0.27 & & 0.05 & -0.01 & -0.04 \\
\cmidrule(lr){4-6}\cmidrule(lr){7-10}
& & BMZ-$\mathcal{DP}$ & -7.87 & 4.98 & 13.44 & & 1.35 & 1.60 & 1.38 \\
& & BM-$\mathcal{DP}$ & -114.50 & -142.90 & -220.50 & & 4.04 & 2.47 & 6.03 \\
1800 & Bias (\%) & BZ-$\mathcal{DP}$ & 26.98 & 46.85 & 76.99 & & 9.16 & 5.54 & 1.15 \\
& & BMZ & 6.14 & 21.86 & 34.30 & & 3.56 & 7.52 & 4.66 \\
& & Frailty & -117.34 & -154.61 & -237.30 & & -77.21 & -101.53 & -110.87 \\
\cmidrule(lr){4-6}\cmidrule(lr){7-10}
& & BMZ-$\mathcal{DP}$ & 79.38 & 85.58 & 81.44 & & 94.84 & 93.81 & 96.91 \\
& & BM-$\mathcal{DP}$ & 1.69 & 1.12 & 1.12 & & 85.13 & 79.73 & 28.38 \\
& Coverage (\%) & BZ-$\mathcal{DP}$ & 49.48 & 30.93 & 21.64 & & 82.47 & 86.59 & 94.84 \\
& & BMZ & 76.28 & 68.04 & 60.82 & & 79.38 & 86.59 & 84.54 \\
& & Frailty & 1.69 & 1.69 & 1.69 & & 84.75 & 72.88 & 40.68 \\
\bottomrule
\end{tabular}}
\end{table}
Based on the results in Table \ref{table:result}, the proposed BMZ-$\mathcal{DP}$ model achieves the overall best performance under all different sample sizes, with the smallest or among the smallest percentage bias and closest to 95\% coverage for all parameters. \revise{Specifically, under the proposed BMZ-$\mathcal{DP}$ model, the coverage probabilities for the survival process parameters are generally at the nominal level, whereas the coverage probabilities for the recurrent event parameters are slightly lower than nominal (though still the closet to nominal among all competing methods). With this level of sample size, the under-coverage for recurrent event model parameters is anticipated, due to the complicated event structure in the recurrent process including zero-inflation as well as nested random effects. In addition, BMZ-$\mathcal{DP}$ outperforms BM-$\mathcal{DP}$ particularly in uncovering the recurrent process by precisely tracking zero-inflation among the population. Meanwhile, we also observe substantial estimation bias from both BZ-$\mathcal{DP}$ and BMZ, as they either ignore the between-participant clustering or assume a fully parametric specification of the practice-level random effect. Finally, the performance of the frequentist joint frailty model is unsatisfactory in estimating both recurrent and survival related parameters, which is anticipated due to its omission for heterogeneity and misspecification of the distributions of the practice-level random effect and residual error of the survival process.}
Overall, the difference in the performance of our method and the competing approaches helps reinforce the necessity of the key components of our proposed model.
BM-$\mathcal{DP}$ and the frequentist joint frailty model carry the largest estimation bias and lowest coverage for the recurrent process parameters, indicating that accurate inference for recurrent event processes depends critically on adjusting for population heterogeneity.
Similarly, BZ-$\mathcal{DP}$ also suffers with large bias with low coverage, suggesting the necessity for explicitly accounting for the multi-level data structure with our complex survival outcomes.
Finally, the performance of BMZ demonstrates that it is critical to consider a flexible nonparametric prior for the practice-level random effect, as the estimation of model parameters can otherwise be subject to bias. \revise{Of note, we have also conducted a similar set of simulations when the baseline hazard for the recurrent process is generated from a Weibull distribution and the conclusions are qualitatively similar. The details of the simulation setting, model implementation and results are provided in the supplementary materials. }
\section{Application to the STRIDE study}\label{sec:data}
We implement our Bayesian semi-parametric joint model and the competing approaches described in Section \ref{sec:simu} to analyze data from the STRIDE study and investigate how the intervention and clinical covariates are associated with serious fall injuries and death among the elderly participants who are 70 years of age or older. As described in Section \ref{s:intro}, STRIDE is a pragmatic trial conducted with 86 primary care practices randomized either to the intervention (multifactorial fall intervention delivered by nurses) or usual care in a one-to-one ratio.
A total of 5,419 participants are included in our final analysis, and several baseline covariates with descriptive statistics are presented in the supplementary materials. The participants were followed for
a maximum of 44 months, at which point the survival outcomes were right censored. During follow-up, each occurrence of fall injury and its severity level were ascertained from interviews in conjunction with data obtained from the trial site as well as the claims database from the Centers for Medicare and Medicaid Services and electronic health records. Meanwhile, adverse events including hospitalization and death were also recorded periodically.
In these analyses, we are interested in recurrent adjudicated serious fall injuries (falls resulting in a fracture, joint dislocation, cut requiring closure, or overnight hospitalization, reported by participants and confirmed by medical records or claims data) and deaths. Besides the intervention, we adjust for several risk factors, including age, sex, race, and number of chronic coexisting conditions (NCD), to study their effect on fall prevention and survival. We implement the proposed BMZ-$\mathcal{DP}$ model and \revise{the competing approaches, i.e. BZ-$\mathcal{DP}$, BM-$\mathcal{DP}$ and BMZ}, assuming all the risk factors can potentially impact the recurrent events and survival. The hyper-parameter specifications for all the methods closely follow those in Section \ref{sec:simu} except for the hyper-prior for $p_{ij}$, which we assign $p_{ij}=0.5$ without prior knowledge on the effect of susceptibility status from any of the observed covariates.
Under random initials, we run MCMC for 20,000 iterations with the first 10,000 as burn-in. The posterior inference for each method is summarized in Table \ref{table:realdata} and the trace plots showing posterior convergence are provided in the supplementary materials. \revise{We do not further consider the joint frailty model under a frequentist paradigm (in \texttt{frailtypack}) because the model did not converge after running for $48$ hours.}
\begin{table}
\begin{center}
\caption{Posterior inference for parameters in the recurrent and survival processes under different methods for the analysis of the STRIDE study.} \label{table:realdata}
\resizebox{\textwidth}{!}{
\begin{tabular}{lcccc}
\hline
& BMZ-$\mathcal{DP}$ & BM-$\mathcal{DP}$ & BZ-$\mathcal{DP}$& BMZ \\
\hline
\multicolumn{5}{c}{Recurrent Process}\\
\hline
Intervention & -0.06 (-0.32,0.28) & -0.25 (-0.48,0.01) & -0.08 (-0.30,0.13)& -0.68(-1.09, -0.30) \\
Number of Chronic Coexisting Conditions & 0.16 (0.11,0.22) & 0.14 (0.08,0.18)& 0.16 (0.10,0.22)& 0.15(0.09,0.21))\\
Age & -0.05 (-0.06,-0.04) & -0.05 (-0.06,-0.04) & 0.01 (-0.01,0.01)& -0.07(-0.08,-0.06)\\
Sex (Female vs. Male) & 0.02 (-0.18,0.21) & 0.03 (-0.12,0.20) & 0.13 (-0.06,0.32)& -0.04(-0.24,0.13)\\
Race (White vs. Others) & 0.10(-0.34,0.44) & 0.17 (-0.13,0.44) & 0.61 (0.38,0.90)& -0.07 (-0.32, 0.20)\\
\hline
\multicolumn{5}{c}{Survival Process}\\
\hline
Intervention & -0.06 (-0.41,0.28) & -0.05 (-0.20,0.11) & -0.05(-0.39,0.28)& 0.33(-0.22,0.90)\\
Number of Chronic Coexisting Conditions & -0.18 (-0.26,-0.10) & -0.15 (-0.21,-0.12) & -0.19 (-0.28,-0.10)& -0.23(-0.35,-0.11)\\
Age & -0.03 (-0.05,-0.01) & -0.04 (-0.05,-0.03) & -0.05 (-0.06,-0.03) &-0.04(-0.06, -0.02)\\
Sex (Female) & 0.55 (0.24,0.87) & 0.45 (0.32,0.61) & 0.57 (0.27,0.90)& 0.71 (0.33, 1.14)\\
Race (White vs. Others) & 0.05(-0.5,0.48) & 0.09 (-0.08,0.30) & -0.04 (-0.58,0.46) & 0.18 (-0.30,0.72)\\
\hline
{LPML} & -2439.84 & -3585.48 & -2516.90& -2498.87\\
\hline
\hline
\end{tabular}}
\end{center}
\end{table}
\begin{figure}
\centering
\includegraphics[width=0.8\textwidth]{priorplot_new2.pdf}
\caption{Analysis results on structural zero probabilities and cluster-specific random effects for STRIDE: panel (a) displays the marginal posterior inclusion probability of $D_{ij}=1$ ordered from smallest to largest; panel (b) summarizes the distribution of marginal posterior inclusion probability of $D_{ij}=1$ within different practices; panel (c) provides the posterior inference of $\mu_j$ ordered by posterior mean. }\label{realdataresult}
\end{figure}
We first investigate the impact of the intervention and risk factors on recurrent fall injuries. Under the BMZ-$\mathcal{DP}$ model, NCD and age appear to be associated with fall injury intensity, and their corresponding 95\% CIs exclude zero. Exponentiating
the posterior means of the model parameters, we interpret that one additional chronic condition multiplies the serious fall rate by 0.16 (0.11, 0.22) and a one year increase in age reduces injury intensity by around 5\%.
The latter result provides new evidence since it was originally believed that older age increases the risk for
fall injury.
However, because the population recruited in our study are 70 years of age or older, it is also likely that a further increase in age could start to prevent them from potential triggers for serious fall such as exercise or intensive movement.
For death,
both NCD and age remain significant predictors, with their 95\% posterior CIs excluding zero, and an increase in NCD or age leads to an increased hazard of death, as expected.
We also see a strong association between sex and survival, with the survival time ratio between females and male is 1.73. Consistent with the previous analysis \citep{stride_introduction}, the intervention does reduce the rate of recurrent falls as well as benefit survival experiences, but the CIs of the intervention effect parameter include zero.
Although results from the models without zero-inflation (BM-$\mathcal{DP}$), multi-level data structure (BZ-$\mathcal{DP}$) and both (BMZ) are generally consistent with those from BMZ-$\mathcal{DP}$, we do notice differences in the effect estimates and CIs. Specifically, the major conclusions based on BM-$\mathcal{DP}$ align with those from BMZ-$\mathcal{DP}$, but failure to account for the structural zeros tends to under-estimate the effect of NCD for the serious fall intensity and the survival.
The results from BZ-$\mathcal{DP}$ identify NCD as a significant predictor but fail to dissect the effect of age on both recurrent and survival process. Those from BMZ, though successfully capturing the effects from age and NCD, over-estimates their effects during the recurrent process and brings a false positive conclusion for the intervention upon the recurrent process, which is inconsistent from the previous conclusion \citep{stride_introduction}.
To further evaluate model fit, we calculate the log pseudo marginal likelihood (LPML) based on leave-one-out-cross-validation as
$\text{LPML}=\sum_{i=1}^{n} \log(\text{CPO}_{i})$,
where $\text{CPO}_i$ is the conditional predictive ordinate used for detecting surprising observations over subjects \citep{cpo_introduction_2}. This is a commonly used metric in Bayesian survival analyses to assess model performance, with a larger value suggesting a better fit of the data. As shown in Table \ref{table:realdata}, our method clearly demonstrates the best performance in terms of LPML.
Finally, we examine the structural zero probabilities and cluster-specific random effects, as these are two key aspects of STRIDE our method is well-suited to identify. We summarize the marginal posterior inclusion probability for $D_{ij}=1$ over subjects who may be considered naturally unsusceptible for the recurrent fall events in panel (a) of Figure \ref{realdataresult}. With a 0.5 cutoff
\citep{barbieri2004optimal}, we conclude there could be a substantial fraction of participants who may not be susceptible to serious fall injuries during the study period. We present the distribution of those inclusion probabilities within different practices in panel (b) of Figure \ref{realdataresult}. Almost all practices include a large amount of patients from the unsusceptible subgroup, and the inclusion probability varies both within and between practices. This visualization can help identify practices with substantially more unsusceptible patients for falls, although the exact
scientific mechanism for unsusceptibility remains to be further studied. Finally, we provide the posterior mean along with the 95\% CI obtained from the inference of each $\mu_j$ in panel (c) of Figure \ref{realdataresult}, where the practices are ordered by their point estimates. Clearly, the cluster-level frailties show substantial heterogeneity across practices,
are all negative, and are all significantly different from zero, so failure to account for this between-practice heterogeneity will likely result in bias in the association estimates.
\section{Discussion}\label{s:discuss}
In this paper, we propose a new Bayesian semi-parametric joint model framework to simultaneously characterize the recurrent event process and survival in the presence of clustering and potential zero-inflations. \revise{To accommodate the between-participant clustering commonly seen in pragmatic clinical trials, we introduce hierarchical random effects at the participant and practice levels, both of which bridge the recurrent and survival processes. To further relax the parametric assumptions, we specify separate nonparametric realizations for the baseline hazard, practice-level random effect and terminal event survival function, which are naturally incorporated into our unified Bayesian paradigm and enhance the model robustness compared with the existing alternative modeling strategies. We also demonstrate the necessity of each analytical component within our integrative joint modeling framework
and develop MCMC algorithms to enable posterior inference for all model parameters.} Through extensive simulations and our application to a recent pragmatic cluster-randomized trial STRIDE, we demonstrate the advantage of our method by providing more reliable estimation and inference while \revise{maintaining robustness to violations of certain parametric assumptions.}
To account for zero-inflation, we define the structural zeros as those contributed by participants who are unsusceptible to the recurrent event during the study period, and we impose a two-component mixture to represent the recurrent event hazard.
\revise{This definition is similar to the existing cure model literature \citep{yu2004joint,rondeau2013cure} with straightforward interpretation of unsusceptibility.} When recurrent events are subject to a terminal event, alternative definitions of unsusceptibility exist. For example, one can either define the unsusceptibility status based on the unsusceptibility status of recurrent events
or further differentiate the structural zero from the random zero based on the terminal event. \revise{The former definition has been adopted in \cite{xu2018joint} and \cite{han2020variable} as well as our current model specification, given study participants should always be susceptible to typical terminal events such as death, particularly in studies with an elderly population and a longer follow-up. }
\cite{liu2016joint} also provided a brief explanation on the difference of these two definitions of unsusceptibility driven by a specific application. In any case, our modeling framework can be easily adapted under an alternative definition of unsusceptibility incorporating the terminal event.
One potential limitation of our modeling strategy is that we have
not distinguished the survival hazard between subjects who experience recurrent event(s) and those who directly move to the terminal event. The impact upon the survival function from the previous recurrent event occurrence is primarily controlled by the shared hierarchical frailty terms, $\gamma_{ij}$ and $\mu_j$, from the two hazards. An alternative modeling strategy can be based on the multi-state model \citep{lee_2016,li2022comparison}, where one can more explicitly split the event occurrence paths into 1) recurrent events only, 2) recurrent events followed by the terminal event, and 3) terminal event only, and characterize state-specific hazard functions for each of them in conjunction with different random effects. Under multi-state modeling, we may be able to capture the influence from both fixed and random effects on different hazard functions, potentially allowing for richer information extraction.
However, a practical issue of multi-state modeling in our case comes from the growing number of unknown parameters, since we would need an additional set of coefficients as well as more random effects. This could induce computational and inferential challenges,
especially with a small sample size, and merits additional investigation.
\iffalse
In our analysis of STRIDE, we have only considered a small number of risk factors that were anticipated to be associated with survival based on expert knowledge, and variable selection techniques may be required if we have access to a high-dimensional covariate vector.
Incorporating a variable selection procedure for semi-competing risk models has been explored in the presence of a high-dimensional set of covariates \citep{han2020variable}.
To incorporate a valid variable selection procedure, frequentist models rely on penalty functions which often require us to deal with a non-smooth likelihood function, under which post-selection inference may be challenging. Within our Bayesian semi-parametric model, we plan to carry out future work that imposes spike-and-slab priors on the survival model parameters to select variables using the median probability model through posterior inference, to achieve parsimonious inference in the presence of a rich set of baseline covariates.
\fi
\section*{Supplementary Materials}
Detailed MCMC algorithms and additional results are available as supplementary materials. Sample code to implement the proposed Bayesian model is available at \url{https://github.com/xt83/Bayesian_semi_parametric_inference_for_clustered_recurrent_event}.
\bibliographystyle{asa}
\baselineskip=10pt
\section*{S1. MCMC Algorithm}
\subsection*{S1.1. MCMC Algorithm-with piecewise constant hazard function for the recurrent event process}
We provide here the details of the MCMC algorithm for posterior inference under BMZ-$\mathcal{DP}$ with piecewise constant hazard function for the recurrent event process. The algorithm is implemented by a combination of Gibbs sampler and MH updates. The update for each parameter follows
\begin{itemize}
\item Update $\boldsymbol \beta$ by sampling a proposal $\boldsymbol \beta^{p} \sim \text{N}(\boldsymbol \beta, \rho^2_{\beta})$ and setting $\boldsymbol \beta = \boldsymbol \beta^{p}$ with probability $\min\{1, R_{\boldsymbol \beta}\}$, where
$$R_{\boldsymbol \beta} = \frac{\pi(\boldsymbol \beta^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol\mu, \boldsymbol \gamma, \lambda,\sigma^2_{\beta})}{\pi(\boldsymbol \beta \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol\mu, \boldsymbol \gamma, \lambda,\sigma^2_{\beta})},$$
with $\pi(\boldsymbol \beta \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol\mu, \boldsymbol \gamma, \lambda,\sigma^2_{\beta})\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)\exp(-\frac{\boldsymbol \beta^T\boldsymbol \beta}{2\sigma^2_{\beta}})$ the full conditional.
\item Update $\boldsymbol \alpha$ by sampling a proposal $\boldsymbol \alpha^{p} \sim \text{N}(\boldsymbol \alpha, \rho^2_{\alpha})$ and setting $\boldsymbol \alpha = \boldsymbol \alpha^{p}$ with probability $\min\{1, R_{\boldsymbol \alpha}\}$, where
$$R_{\boldsymbol \alpha} = \frac{\pi(\boldsymbol \alpha^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\xi_1,\xi_2,\sigma^2_{\alpha})}{\pi(\boldsymbol \alpha \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\xi_1,\xi_2,\sigma^2_{\alpha})},$$
with $\pi(\boldsymbol \alpha \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\xi_1,\xi_2,\sigma^2_{\alpha})\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)\exp(-\frac{\boldsymbol \alpha^T\boldsymbol \alpha}{2\sigma^2_{\alpha}})$ the full conditional.
\item Update $\alpha_0$ by sampling a proposal $\alpha_0^{p} \sim \text{N}(\alpha, \rho^2_{\alpha_0})$ and setting $\alpha_0 = \alpha_0^{p}$ with probability $\min\{1, R_{\alpha_0}\}$, where
$$R_{\alpha_0} = \frac{\pi(\alpha^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \alpha, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\xi_1,\xi_2)}{\pi(\alpha_0 \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \alpha, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\xi_1,\xi_2)},$$
with $\pi(\alpha_0 \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \alpha, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\xi_1,\xi_2)\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)$ the full conditional.
\item Update $\tau_{j}^2$ by sampling
$\tau_{j}^2\mid \boldsymbol \gamma \sim \mathcal{IG}(a_{0}+\frac{N_j}{2},b_{0}+\frac{\sum_{i=1}^{N_j} (\log \gamma_{ij})^2}{2}), j=1,...,J.$
\item Update $\gamma_{ij},i=1,...,N_j, j=1,...,J$ by sampling a proposal $\gamma_{ij}^{p} \sim \text{N}(\gamma_{ij}, \rho^2_{\gamma})$ and setting $\gamma_{ij} = \gamma_{ij}^{p}$ with probability $\min\{1, R_{\gamma}\}I\{\gamma_{ij}^{p}>0\}$, where
$$R_{\gamma} = \frac{\pi(\gamma_{ij}^{p} \mid \mathcal{O}_{ij}, D_{ij}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \lambda, \kappa,\xi_1,\xi_2,\tau_{j})}{\pi(\gamma_{ij} \mid \mathcal{O}_{ij}, D_{ij}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \lambda, \kappa,\xi_1,\xi_2,\tau_{j})},$$
with $\pi(\gamma_{ij} \mid \mathcal{O}_{ij}, D_{ij}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \lambda, \kappa,\xi_1,\xi_2,\tau_{j})\propto\mathcal{L}(\mathcal{O}_{ij}\mid \boldsymbol \Theta)\exp(-\frac{\gamma^2_{ij}}{2\tau_j^2})$ the full conditional.
\revise{\item Update $m_j, j=1,\dots,J$ from Multinominal distribution with
$$p(m_j=l\mid\{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \lambda, \kappa,\xi_1,\xi_2)=\frac{\pi_l\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta_l)}{\sum_{l=1}^L\pi_l\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta_l)}, l=1,\dots,L,$$
with $\boldsymbol \Theta_l$ denoting all the unknown parameters with $\mu_j$ setting to $\eta_l$.
\item Set $\tilde{\pi}'_L=1$, and sample $\tilde{\pi}'_l\sim \mbox{Beta}(1+\sum_j I\{m_j=l\}, \phi+\sum_j I\{m_j>l\}), l=1,\dots,L-1$. Then we have $\tilde{\pi}_l=\tlide{\pi}'_l\sum_{t<l}(1-\tilde{\pi}'_t).$
\item Based on mapping vector m, we transfer the update of $\mu_j, j=1\dots,J$ to the update of $\eta_1,\dots,\eta_L$. Update each $\eta_l$ by sampling a proposal $\eta_{l}^{p} \sim \text{N}(\eta_{l}, \rho^2_{\eta})$ and setting $\eta_{l} = \eta_{l}^{p}$ with probability $\min\{1, R_{\eta}\}$, where
$$R_{\eta} = \frac{\pi(\eta_{l}^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \lambda, \kappa,\xi_1,\xi_2,\sigma^2)}{\pi(\eta_{l} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \lambda, \kappa,\xi_1,\xi_2,\sigma^2)},$$
with $\pi(\eta_{l}^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \lambda, \kappa,\xi_1,\xi_2,\sigma^2)\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)\exp(-\frac{\eta_{k}}{2\sigma^2})$ the full conditional.}
\item Update $D_{ij}$ by sampling from $\mbox{Bern}(\frac{l_1}{l_1+l_0})$ with $l_a=\pi(D_{ij}=a\mid \mathcal{O}_{ij}, D_{ij}, \boldsymbol \beta, \boldsymbol \alpha,\mu_j, \gamma_{ij}, \lambda, \kappa_{ij},\xi_1,\xi_2,\tau_{j})$ for $a=0, 1$; with $i=1,...,N_j, j=1,...,J$.
\revise{\item Update $\lambda_{0g}$ by sampling a proposal $\lambda^{p}_{0g} \sim \text{N}(\lambda_{0g}, \rho^2_{\lamba_{0g}})$ and setting $\lambda_{0g}= \lambda_{0g}^{p}$ with probability $\min\{1, R_{\lambda_{0g}}\}*I(\lambda_{0g}^p>0)$, where
$$R_{\lambda_{0g}} = \frac{\pi(\lambda_{0g}^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol\mu, \boldsymbol \gamma, \boldsymbol \beta)}{\pi(\lambda_{0g} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol\mu, \boldsymbol \gamma, \boldsymbol \beta)},$$
with $\pi(\lambda_{0g}^p \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol\mu, \boldsymbol \gamma, \boldsymbol \beta)\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)$ the full conditional.}
\revise{\item Update $v_{ij}, i=1,\dots, N_J, j=1,\dots,J$ from Multinominal distribution with
$$p(v_{ij}=k\mid\{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \kappa,\xi_1,\xi_2)=\frac{\pi_l\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta_l)}{\sum_{l=1}^L\pi_l\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta_l)}, k=1,\dots,K,$$
with $\boldsymbol \Theta_l$ denoting all the unknown parameters with $\kappa_{ij}$ setting to $\theta_k$.
\item Set $\pi'_K=1$, and sample $\pi'_K\sim \mbox{Beta}(1+\sum_j I\{v_{ij}=k\}, \phi+\sum_j I\{v_{ij}>k\}), k=1,\dots,K-1$. Then we have $\pi_k=\pi'_k\sum_{t<k}(1-\pi'_t).$
\item Based on mapping vector $\mathbf v$, we transfer the update of $\kappa_{ij}, i=1,\dots, N_J, j=1,\dots,J$ to the update of $\theta_1,\dots,\theta_K$. Update each $\theta_k$ by sampling a proposal $\theta_{k}^{p} \sim \text{N}(\theta_{k}, \rho^2_{\theta})$ and setting $\theta_{k} = \theta_{k}^{p}$ with probability $\min\{1, R_{\theta}\}$, where
$$R_{\theta} = \frac{\pi(\theta_{k}^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\},\boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \kappa,\xi_1,\xi_2,\sigma^2)}{\pi(\theta_{k} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \kappa,\xi_1,\xi_2,\sigma^2)},$$
with $\pi(\theta_{k}^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \kappa,\xi_1,\xi_2,\sigma^2)\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)$ the full conditional.}
\item Update $\xi_1$ by sampling a proposal $\xi_1^{p} \sim \text{N}(\xi_1, \rho^2_{\xi_1})$ and setting $\xi_1 = \xi_1^{p}$ with probability $\min\{1, R_{\xi_1}\}$, where
$$R_{\xi_1} = \frac{\pi(\xi_1^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\boldsymbol \alpha,\xi_2,\sigma^2_{\alpha})}{\pi(\xi_1 \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\boldsymbol \alpha,\xi_2,\sigma^2_{\alpha})},$$
with $\pi(\pi(\xi_1 \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\boldsymbol \alpha,\xi_2,\sigma^2_{\alpha}))\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)$ the full conditional.
\item Update $\xi_2$ by sampling a proposal $\xi_2^{p} \sim \text{N}(\xi_2, \rho^2_{\xi_2})$ and setting $\xi_2 = \xi_2^{p}$ with probability $\min\{1, R_{\xi_2}\}$, where
$$R_{\xi_2} = \frac{\pi(\xi_2^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\boldsymbol \alpha,\xi_1,\sigma^2_{\alpha})}{\pi(\xi_2 \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\boldsymbol \alpha,\xi_1,\sigma^2_{\alpha})},$$
with $\pi(\pi(\xi_2 \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\boldsymbol \alpha,\xi_1,\sigma^2_{\alpha}))\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)$ the full conditional.
\item Update $\boldsymbol \zeta$ by sampling a proposal $\boldsymbol \zeta^{p} \sim \text{N}(\boldsymbol \zeta, \rho^2_{\zeta})$ and setting $\boldsymbol \zeta = \boldsymbol \zeta^{p}$ with probability $\min\{1, R_{\zeta}\}$, where
$$R_{\zeta} = \frac{\pi(\boldsymbol \zeta^{p} \mid \mathcal{O}_{ij}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \lambda, \kappa,\xi_1,\xi_2)}{\pi(\boldsymbol \zeta \mid \mathcal{O}_{ij}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \lambda, \kappa,\xi_1,\xi_2)},$$
with $\pi(\boldsymbol \zeta \mid \mathcal{O}_{ij}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \lambda, \kappa,\xi_1,\xi_2)\propto\mathcal{L}(\mathcal{O}_{ij}\mid \boldsymbol \Theta)\exp(-\frac{\boldsymbol \zeta^T\boldsymbol \zeta}{2\sigma^2_{\zeta}})$ the full conditional. Then we calculate $p_{ij}=\frac{\exp(\boldsymbol \zeta^T\mathbf U_{ij})}{1+\exp(\boldsymbol \zeta^T\mathbf U_{ij})}.$
\end{itemize}
\revise{\subsection*{S1.2. MCMC Algorithm-with Weibull baseline hazard function for the recurrent event process}
We provide here the details of the MCMC algorithm for posterior inference under BMZ-$\mathcal{DP}$ with Weibull baseline hazard function for the recurrent event process. The algorithm is implemented by a combination of Gibbs sampler and MH updates. The update for each parameter follows
\begin{itemize}
\item Update $\boldsymbol \beta$ by sampling a proposal $\boldsymbol \beta^{p} \sim \text{N}(\boldsymbol \beta, \rho^2_{\beta})$ and setting $\boldsymbol \beta = \boldsymbol \beta^{p}$ with probability $\min\{1, R_{\boldsymbol \beta}\}$, where
$$R_{\boldsymbol \beta} = \frac{\pi(\boldsymbol \beta^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol\mu, \boldsymbol \gamma, \psi,\sigma^2_{\beta})}{\pi(\boldsymbol \beta \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol\mu, \boldsymbol \gamma, \psi,\sigma^2_{\beta})},$$
with $\pi(\boldsymbol \beta \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol\mu, \boldsymbol \gamma, \psi,\sigma^2_{\beta})\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)\exp(-\frac{\boldsymbol \beta^T\boldsymbol \beta}{2\sigma^2_{\beta}})$ the full conditional.
\item Update $\boldsymbol \alpha$ by sampling a proposal $\boldsymbol \alpha^{p} \sim \text{N}(\boldsymbol \alpha, \rho^2_{\alpha})$ and setting $\boldsymbol \alpha = \boldsymbol \alpha^{p}$ with probability $\min\{1, R_{\boldsymbol \alpha}\}$, where
$$R_{\boldsymbol \alpha} = \frac{\pi(\boldsymbol \alpha^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\xi_1,\xi_2,\sigma^2_{\alpha})}{\pi(\boldsymbol \alpha \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\xi_1,\xi_2,\sigma^2_{\alpha})},$$
with $\pi(\boldsymbol \alpha \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\xi_1,\xi_2,\sigma^2_{\alpha})\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)\exp(-\frac{\boldsymbol \alpha^T\boldsymbol \alpha}{2\sigma^2_{\alpha}})$ the full conditional.
\item Update $\alpha_0$ by sampling a proposal $\alpha_0^{p} \sim \text{N}(\alpha, \rho^2_{\alpha_0})$ and setting $\alpha_0 = \alpha_0^{p}$ with probability $\min\{1, R_{\alpha_0}\}$, where
$$R_{\alpha_0} = \frac{\pi(\alpha^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \alpha, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\xi_1,\xi_2)}{\pi(\alpha_0 \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \alpha, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\xi_1,\xi_2)},$$
with $\pi(\alpha_0 \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \alpha, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\xi_1,\xi_2)\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)$ the full conditional.
\item Update $\tau_{j}^2$ by sampling
$\tau_{j}^2\mid \boldsymbol \gamma \sim \mathcal{IG}(a_{0}+\frac{N_j}{2},b_{0}+\frac{\sum_{i=1}^{N_j} (\log \gamma_{ij})^2}{2}), j=1,...,J.$
\item Update $\gamma_{ij},i=1,...,N_j, j=1,...,J$ by sampling a proposal $\gamma_{ij}^{p} \sim \text{N}(\gamma_{ij}, \rho^2_{\gamma})$ and setting $\gamma_{ij} = \gamma_{ij}^{p}$ with probability $\min\{1, R_{\gamma}\}I\{\gamma_{ij}^{p}>0\}$, where
$$R_{\gamma} = \frac{\pi(\gamma_{ij}^{p} \mid \mathcal{O}_{ij}, D_{ij}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \psi, \kappa,\xi_1,\xi_2,\tau_{j})}{\pi(\gamma_{ij} \mid \mathcal{O}_{ij}, D_{ij}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \psi, \kappa,\xi_1,\xi_2,\tau_{j})},$$
with $\pi(\gamma_{ij} \mid \mathcal{O}_{ij}, D_{ij}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \psi, \kappa,\xi_1,\xi_2,\tau_{j})\propto\mathcal{L}(\mathcal{O}_{ij}\mid \boldsymbol \Theta)\exp(-\frac{\gamma^2_{ij}}{2\tau_j^2})$ the full conditional.
\item Update $m_j, j=1,\dots,J$ from Multinominal distribution with
$$p(m_j=l\mid\{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \lambda, \kappa,\xi_1,\xi_2)=\frac{\pi_l\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta_l)}{\sum_{l=1}^L\pi_l\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta_l)}, l=1,\dots,L,$$
with $\boldsymbol \Theta_l$ denoting all the unknown parameters with $\mu_j$ setting to $\eta_l$.
\item Set $\tilde{\pi}'_L=1$, and sample $\tilde{\pi}'_l\sim \mbox{Beta}(1+\sum_j I\{m_j=l\}, \phi+\sum_j I\{m_j>l\}), l=1,\dots,L-1$. Then we have $\tilde{\pi}_l=\tlide{\pi}'_l\sum_{t<l}(1-\tilde{\pi}'_t).$
\item Based on mapping vector m, we transfer the update of $\mu_j, j=1\dots,J$ to the update of $\eta_1,\dots,\eta_L$. Update each $\eta_l$ by sampling a proposal $\eta_{l}^{p} \sim \text{N}(\eta_{l}, \rho^2_{\eta})$ and setting $\eta_{l} = \eta_{l}^{p}$ with probability $\min\{1, R_{\eta}\}$, where
$$R_{\eta} = \frac{\pi(\eta_{l}^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \lambda, \kappa,\xi_1,\xi_2,\sigma^2)}{\pi(\eta_{l} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \lambda, \kappa,\xi_1,\xi_2,\sigma^2)},$$
with $\pi(\eta_{l}^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \lambda, \kappa,\xi_1,\xi_2,\sigma^2)\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)\exp(-\frac{\eta_{k}}{2\sigma^2})$ the full conditional.
\item Update $D_{ij}$ by sampling from $\mbox{Bern}(\frac{l_1}{l_1+l_0})$ with $l_a=\pi(D_{ij}=a\mid \mathcal{O}_{ij}, D_{ij}, \boldsymbol \beta, \boldsymbol \alpha,\mu_j, \gamma_{ij}, \psi, \kappa_{ij},\xi_1,\xi_2,\tau_{j})$ for $a=0, 1$; with $i=1,...,N_j, j=1,...,J$.
\item Update $\psi$ by sampling a proposal $\psi^{p} \sim \text{N}(\psi, \rho^2_{\psi})$ and setting $\psi= \psi^{p}$ with probability $\min\{1, R_{\psi}\}$, where
$$R_{\psi} = \frac{\pi(\psi^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol\mu, \boldsymbol \gamma, \boldsymbol \beta)}{\pi(\psi \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol\mu, \boldsymbol \gamma, \boldsymbol \beta)},$$
with $\pi(\psi \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol\mu, \boldsymbol \gamma, \boldsymbol \beta)\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)$ the full conditional.
\item Update $v_{ij}, i=1,\dots, N_J, j=1,\dots,J$ from Multinominal distribution with
$$p(v_{ij}=k\mid\{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \kappa,\xi_1,\xi_2)=\frac{\pi_l\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta_l)}{\sum_{l=1}^L\pi_l\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta_l)}, k=1,\dots,K,$$
with $\boldsymbol \Theta_l$ denoting all the unknown parameters with $\kappa_{ij}$ setting to $\theta_k$.
\item Set $\pi'_K=1$, and sample $\pi'_K\sim \mbox{Beta}(1+\sum_j I\{v_{ij}=k\}, \phi+\sum_j I\{v_{ij}>k\}), k=1,\dots,K-1$. Then we have $\pi_k=\pi'_k\sum_{t<k}(1-\pi'_t).$
\item Based on mapping vector $\mathbf v$, we transfer the update of $\kappa_{ij}, i=1,\dots, N_J, j=1,\dots,J$ to the update of $\theta_1,\dots,\theta_K$. Update each $\theta_k$ by sampling a proposal $\theta_{k}^{p} \sim \text{N}(\theta_{k}, \rho^2_{\theta})$ and setting $\theta_{k} = \theta_{k}^{p}$ with probability $\min\{1, R_{\theta}\}$, where
$$R_{\theta} = \frac{\pi(\theta_{k}^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \kappa,\xi_1,\xi_2,\sigma^2)}{\pi(\theta_{k} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \kappa,\xi_1,\xi_2,\sigma^2)},$$
with $\pi(\theta_{k}^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \kappa,\xi_1,\xi_2,\sigma^2)\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)$ the full conditional.
\item Update $\xi_1$ by sampling a proposal $\xi_1^{p} \sim \text{N}(\xi_1, \rho^2_{\xi_1})$ and setting $\xi_1 = \xi_1^{p}$ with probability $\min\{1, R_{\xi_1}\}$, where
$$R_{\xi_1} = \frac{\pi(\xi_1^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\boldsymbol \alpha,\xi_2,\sigma^2_{\alpha})}{\pi(\xi_1 \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\boldsymbol \alpha,\xi_2,\sigma^2_{\alpha})},$$
with $\pi(\pi(\xi_1 \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\boldsymbol \alpha,\xi_2,\sigma^2_{\alpha}))\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)$ the full conditional.
\item Update $\xi_2$ by sampling a proposal $\xi_2^{p} \sim \text{N}(\xi_2, \rho^2_{\xi_2})$ and setting $\xi_2 = \xi_2^{p}$ with probability $\min\{1, R_{\xi_2}\}$, where
$$R_{\xi_2} = \frac{\pi(\xi_2^{p} \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\boldsymbol \alpha,\xi_1,\sigma^2_{\alpha})}{\pi(\xi_2 \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\boldsymbol \alpha,\xi_1,\sigma^2_{\alpha})},$$
with $\pi(\pi(\xi_2 \mid \{\mathcal{O}_{ij}\}, \{D_{ij}\}, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \kappa,\boldsymbol \alpha,\xi_1,\sigma^2_{\alpha}))\propto\mathcal{L}(\{\mathcal{O}_{ij}\}\mid \boldsymbol \Theta)$ the full conditional.
\item Update $\boldsymbol \zeta$ by sampling a proposal $\boldsymbol \zeta^{p} \sim \text{N}(\boldsymbol \zeta, \rho^2_{\zeta})$ and setting $\boldsymbol \zeta = \boldsymbol \zeta^{p}$ with probability $\min\{1, R_{\zeta}\}$, where
$$R_{\zeta} = \frac{\pi(\boldsymbol \zeta^{p} \mid \mathcal{O}_{ij}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \psi, \kappa,\xi_1,\xi_2)}{\pi(\boldsymbol \zeta \mid \mathcal{O}_{ij}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \psi, \kappa,\xi_1,\xi_2)},$$
with $\pi(\boldsymbol \zeta \mid \mathcal{O}_{ij}, \boldsymbol \beta, \boldsymbol \alpha, \alpha_0, \boldsymbol\mu, \boldsymbol \gamma, \psi, \kappa,\xi_1,\xi_2)\propto\mathcal{L}(\mathcal{O}_{ij}\mid \boldsymbol \Theta)\exp(-\frac{\boldsymbol \zeta^T\boldsymbol \zeta}{2\sigma^2_{\zeta}})$ the full conditional. Then we calculate $p_{ij}=\frac{\exp(\boldsymbol \zeta^T\mathbf U_{ij})}{1+\exp(\boldsymbol \zeta^T\mathbf U_{ij})}.$
\end{itemize}}
\revise{\section*{S2. Additional results for the simulation}}
\revise{We also conduct an additional set of simulation to assess the model performance under a Weibull baseline hazard for the recurrent process. The recurrent and survival process generation procedures follow those in the primary simulation in the paper except that we simulate the baseline hazard for the recurrent process from a Weibull distribution with scale parameter 1 and shape parameter 1.5 instead of the piecewise constant function. In the model implementation, we assume the prior for the shape parameter $\psi\sim \mathcal{G}(a_{\psi}, b_{\psi})$ with $a_{\psi}=b_{\psi}=1$ for BMZ-$\mathcal{DP}$ and its three variations. The rest of the model implementation stays the same as that in the paper. Eventually, we summarize this set of simulation results for all the methods in Table \ref{table:result2} under different sample sizes. As we can see from the table, BMZ-$\mathcal{DP}$ maintains its superior performance compared with the competing methods; and all the observations from the primary simulation under a piecewise constant hazard function are displayed in the current simulation. }
\begin{table}
\centering
\caption{Additional simulation results with Weibull baseline hazard for the recurrent process under sample sizes 600, 1200, 1800 for all the methods summarized by mean or posterior mean (Mean), percentage bias (Bias (\%)) and coverage probability (Coverage (\%)).}\label{table:result2}
\resizebox{0.75\textwidth}{!}{
\begin{tabular}{cccrrrrrrr}
\toprule
& & & \multicolumn{3}{c}{Recurrent Process} & & \multicolumn{3}{c}{Survival Process} \\
\cmidrule(lr){4-6}\cmidrule(lr){7-10}
\multirow{3}{*}{} $N$ & & Method & $\beta_{1}$ & $\beta_{2}$ & $\beta_3$ & & $\alpha_1$ & $\alpha_2$ & $\alpha_3$ \\
\hline \hline
& & BMZ-$\mathcal{DP}$ & 0.36 & 0.32 & 0.26 & & 0.20 & 0.31 & 0.41 \\
& & BM-$\mathcal{DP}$ & -0.09 & -0.21 & -0.28 & & 0.20 & 0.31 & 0.42 \\
\multirow{3}{*}{} & Mean & BZ-$\mathcal{DP}$ & 2.20 & 2.40 & 2.01 & & -0.27 & -0.15 & 0.31 \\
& & BMZ & 0.82 & 0.77 & 0.57 & & 0.14 & 0.24 & 0.41 \\
& & Frailty & -0.11 & -0.18 & -0.30 & & -0.02 & -0.08 & 0.04 \\
\cmidrule(lr){4-6}\cmidrule(lr){7-10}
& & BMZ-$\mathcal{DP}$ & -9.04 & 7.51 & 31.50 & & -0.62 & 4.47 & 3.15 \\
& & BM-$\mathcal{DP}$ & -123.09 & -169.39 & -238.00 & & 1.30 & 2.28 & 5.08 \\
600 & Bias (\%) & BZ-$\mathcal{DP}$ & 404.47 & 700.81 & 900.49 & & -234.66 & -149.90 & -22.17 \\
& & BMZ & 104.30 & 155.73 & 189.13 & & -28.97 & -18.57 & 2.54 \\
& & Frailty & -126.51 & -160.12 & -248.35 & & -108.81 & -126.74 & -89.10 \\
\cmidrule(lr){4-6}\cmidrule(lr){7-10}
& & BMZ-$\mathcal{DP}$ & 85.41 & 91.67 & 81.25 & & 97.91 & 94.79 & 90.63 \\
& & BM-$\mathcal{DP}$ & 1.12 & 1.12 & 1.12 & & 91.16 & 93.43 & 61.84 \\
& Coverage (\%) & BZ-$\mathcal{DP}$ & 31.67 & 3.67 & 6.33 & & 48.67 & 52.33 & 65.00 \\
& & BMZ & 35.34 & 45.27 & 41.84 & & 77.69 & 76.31 & 82.15 \\
& & Frailty & 0.00 & 1.33 & 0.00 & & 71.19 & 64.41 & 64.41 \\
\hline
& & BMZ-$\mathcal{DP}$ & 0.36 & 0.31 & 0.25 & & 0.20 & 0.31 & 0.41 \\
& & BM-$\mathcal{DP}$ & -0.09 & -0.17 & -0.27 & & 0.21 & 0.31 & 0.42 \\
& Mean & BZ-$\mathcal{DP}$ & 2.21 & 2.16 & 1.82 & & -0.20 & -0.05 & 0.31 \\
& & BMZ & 0.61 & 0.50 & 0.40 & & 0.14 & 0.26 & 0.38 \\
& & Frailty & -0.14 & -0.21 & -0.32 & & 0.02 & 0.01 & -0.04 \\
\cmidrule(lr){4-6}\cmidrule(lr){7-10}
& & BMZ-$\mathcal{DP}$ & -9.27 & 4.92 & 25.89 & & 1.72 & 3.80 & 2.72 \\
& & BM-$\mathcal{DP}$ & -123.06 & -156.06 & -232.71 & & 2.67 & 2.80 & 5.57 \\
1200 & Bias (\%) & BZ-$\mathcal{DP}$ & 453.31 & 619.50 & 810.30 & & -200.24 & -116.14 & -21.47 \\
& & BMZ & 53.53 & 68.27 & 99.46 & & -28.95 & -11.91 & -4.03 \\
& & Frailty & -135.35 & -170.86 & -257.70 & & -92.87 & -97.49 & -110.44 \\
\cmidrule(lr){4-6}\cmidrule(lr){7-10}
& & BMZ-$\mathcal{DP}$ & 81.43 & 89.22 & 80.24 & & 92.81 & 92.21 & 90.42 \\
& & BM-$\mathcal{DP}$ & 0.00 & 0.00 & 0.00 & & 86.25 & 91.25 & 32.50 \\
& Coverage (\%) & BZ-$\mathcal{DP}$ & 20.83 & 2.08 & 4.17 & & 55.21 & 54.17 & 68.75 \\
& & BMZ & 34.38 & 43.75 & 47.92 & & 69.69 & 73.95 & 84.38 \\
& & Frailty& 1.69 & 0.00 & 0.00 & & 71.18 & 61.00 & 49.15 \\
\hline
& & BMZ-$\mathcal{DP}$ & 0.37 & 0.31 & 0.24 & & 0.20 & 0.31 & 0.41 \\
& & BM-$\mathcal{DP}$ & -0.10 & -0.16 & -0.27 & & 0.21 & 0.31 & 0.42 \\
& Mean & BZ-$\mathcal{DP}$ & 2.19 & 2.12 & 1.72 & & -0.12 & 0.06 & 0.33 \\
& & BMZ & 0.57 & 0.48 & 0.35 & & 0.14 & 0.25 & 0.36 \\
& & Frailty & -0.12 & -0.19 & -0.32 & & 0.07 & -0.01 & -0.01 \\
\cmidrule(lr){4-6}\cmidrule(lr){7-10}
& & BMZ-$\mathcal{DP}$ & -8.01 & 2.88 & 22.79 & & 2.06 & 2.58 & 3.06 \\
& & BM-$\mathcal{DP}$ & -125.45 & -154.56 & -232.59 & & 3.31 & 2.65 & 6.02 \\
1800 & Bias (\%) & BZ-$\mathcal{DP}$ & 447.86 & 607.95 & 761.94 & & -234.66 & -149.90 & -22.17 \\
& & BMZ & 43.05 & 58.63 & 73.62 & & -30.90 & -17.52 & -8.78 \\
& & Frailty & 129.78 & -164.82 & -259.50 & & -63.46 & -103.52 & -100.85 \\
\cmidrule(lr){4-6}\cmidrule(lr){7-10}
& & BMZ-$\mathcal{DP}$ & 94.03 & 85.07 & 76.12 & & 94.03 & 89.55 & 91.04 \\
& & BM-$\mathcal{DP}$ & 0.00 & 0.00 & 0.00 & & 79.68 & 87.50 & 35.94 \\
& Coverage (\%) & BZ-$\mathcal{DP}$ & 17.98 & 1.12 & 2.25 & & 57.30 & 56.18 & 69.77 \\
& & BMZ & 42.70 & 42.70 & 56.18 & & 59.55 & 68.54 & 74.16 \\
& & Frailty & 1.69 & 1.69 & 1.69 & & 72.88 & 59.32 & 45.76 \\
\bottomrule
\end{tabular}}
\end{table}
\vspace{0.4cm}
\section*{S3. Additional results for the data application}
\subsection*{S3.1. Descriptive statistics}
We present the descriptive statistics to summarize the number of recurrent adjudicated serious fall injuries, observed death, race, gender, number of chronic diseases under both the intervention and control group in Table \ref{table:sum}. This provides a general idea of the STRIDE data and the zero-inflation situation in the recurrent event.
\begin{table}
\caption{Descriptive statistics for variables in STRIDE used in our analysis.}\label{table:sum}
\centering
\begin{threeparttable}
\begin{tabular}{llrrrrrr}
\hline
& Intervention & Control \\
& ($N=2787$) & ($N=2631$)\\
Characteristic & {No. (\%)} & {No. (\%)}\\
\hline
Number of recurrent adjudicated serious fall injuries \\
\hspace{1em} 0 & \makecell[c]{2497 (89.59)} & \makecell[c]{2331 (88.60)} \\
\hspace{1em} 1 & \makecell[c]{258 (9.26)} & \makecell[c]{273 (10.38)} \\
\hspace{1em} 2 & \makecell[c]{27 (0.97)} & \makecell[c]{20 (0.76)} \\
\hspace{1em} 3 & \makecell[c]{3 (0.11)} & \makecell[c]{6 (0.23)} \\
\hspace{1em} 4 & \makecell[c]{2 (0.07)} & \makecell[c]{1 (0.04)} \\
Observed death & \makecell[c]{122 (4.38)} & \makecell[c]{108 (4.10)}\\
White & \makecell[c]{2571 (92.25)} & \makecell[c]{2394 (90.99)}\\
Female & \makecell[c]{1747 (62.68)} & \makecell[c]{1619 (61.54)}\\
Number of chronic diseases \\
\hspace{1em} 0 & \makecell[c]{280 (10.05)} & \makecell[c]{211 (8.02)}\\
\hspace{1em} 1 & \makecell[c]{725 (26.01)} & \makecell[c]{672 (25.54)}\\
\hspace{1em} 2 & \makecell[c]{847 (30.39)} &\makecell[c]{825 (31.36)} \\
\hspace{1em} 3 & \makecell[c]{534 (19.16)} & \makecell[c]{542 (20.60)}\\
\hspace{1em} 4 & \makecell[c]{278 (9.97)} & \makecell[c]{256 (9.73)}\\
\hspace{1em} 5 & \makecell[c]{83 (2.98)} & \makecell[c]{97 (3.69)}\\
\hspace{1em} 6 & \makecell[c]{27 (0.97)} & \makecell[c]{22 (0.84)}\\
\hspace{1em} 7 & \makecell[c]{10 (0.36)} & \makecell[c]{6 (0.23)}\\
\hspace{1em} 8 & \makecell[c]{2 (0.07)} & \makecell[c]{-----}\\
\hspace{1em} 9 & \makecell[c]{1 (0.04)} & \makecell[c]{-----}\\
\hline
\end{tabular}
\end{threeparttable}
\end{table}
\subsection*{S3.2. Posterior convergence}
We show the posterior convergence by the trace plots corresponding to the posterior samples obtained from selected parameters within $\boldsymbol \beta$, $\boldsymbol \alpha$, $\boldsymbol\mu$ and $\boldsymbol \gamma$. \revise{Under random initials, we run MCMC for 20,000 iterations with the first 10,000 as burn-in; and we plot the post burn-in posterior samples, i.e. iteration 10,001 to 20,000 in Figure \ref{fig:trace}. } Based on these trace plots, we conclude there is no trends in any of the plots after burn-in, indicating the convergence of posterior computation. \revise{We also conduct convergence diagnostics using the Gelman-Rubin method \citep{Gelman&Rubin:1992}. The potential scale reduction factors (PSRF) for the log-likelihood with multiple runs started from random initials are smaller than 1.2, confirming convergence.}
\begin{figure}
\centering
\includegraphics[width=0.9\textwidth]{trace.pdf}
\caption{The trace plots for a few selected parameters to showcase the posterior convergence.}
\label{fig:trace}
\end{figure}
\iffalse
We also show in Figure \ref{fig:cumu} the inferred baseline functions for the recurrent and survival processes under our proposed BMZ-$\mathcal{DP}$, and the competing BM-$\mathcal{DP}$ and BZ-$\mathcal{DP}$. The solid line represent the cumulative baseline function under posterior mean, and the dashed lines are those under the 2.5\% and 97.5\% quantiles.
\begin{figure}
\centering
\includegraphics[width=0.9\textwidth]{cumulative.pdf}
\caption{The inferred baseline functions for the recurrent and survival processes under different methods}
\label{fig:cumu}
\end{figure}
\fi
\bibliographystyle{biorefs}
|
{'timestamp': '2022-02-15T02:42:02', 'yymm': '2202', 'arxiv_id': '2202.06636', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06636'}
|
arxiv
|
\section{Introduction}
\paragraph{Hybrid Networks} Real networks often employ multiple communication modes. For instance, mobile devices combine high-bandwidth, short-range wireless communication with relatively low-bandwidth cellular communication (c.f., 5G \cite{Asadi2016}). Other examples are hybrid data centers, which combine wireless and wired communication \cite{Han2015} or optical circuit switching and electrical packet switching \cite{Wang2010}, or software defined networking \cite{Vissicchio2014}.
In this article we utilize the theoretical abstraction of such hybrid communication networks provided by \cite{Augustine2020} which became known as \textit{hybrid model} and was designed to reflect a high-bandwidth local communication mode and a low-bandwidth global communication mode, capturing one of the main aspects of real hybrid networks.
Fundamentally, the hybrid model builds on the concept of \textit{synchronous message passing}, a classic model to investigate communication complexity in distributed systems.
\begin{definition}[Synchronous Message Passing, c.f., \cite{Lynch1996}]
\label{def:sync_msg_passing}
Let $V$ be a set of $n$ nodes with unique identifiers $ID)(\cdot):V \to [n]$.\footnote{$[k] := \{1, \ldots , k\}$ for $k \in \mathbb{N}$.} Time is slotted into discrete rounds consisting of the following steps. First, all nodes receive the set of messages addressed to them in the last round. Second, nodes conduct computations based on their current state and the set of received messages to compute their new state (randomized algorithms also include the result of some random function). Third, based on the new state the next set of messages is sent.
\end{definition}
Synchronous message passing has a clear focus on investigating communication complexity, i.e., the number of communication rounds required to solve a problem with an input distributed over all nodes (usually a graph problem). For this purpose, nodes are usually assumed to be computationally unbounded.\footnote{Occasionally this model is ``overexploited'', e.g., nodes are supposed solve $\mathcal{NP}$-complete problems on their local data. We will refrain from that.} The hybrid model then places additional restrictions on the messages size and which pairs of nodes can exchange them.
\begin{definition}[Hybrid model \cite{Augustine2020}]
\label{def:hybrid_model}
The \hybridpar{\lambda}{\gamma} model is a synchronous message passing model (Def.\ \ref{def:sync_msg_passing}), subject to the following restrictions. \emph{Local mode:} nodes may send one message per round of maximum size $\lambda$ bits to each of their neighbors in a graph. \emph{Global mode:} nodes can send and receive messages of total size at most $\gamma$ bits per round to/from any other node(s) in the network. If the restrictions are not adhered to then a strong adversary\footnote{The strong adversary knows the states of all nodes, their source codes and even the outcome of all random functions.} selects the messages that are delivered.
\end{definition}
Note that the parameter spectrum of the \hybridpar{\lambda}{\gamma} model covers the standard models \ensuremath{\mathsf{LOCAL}}\xspace, \ensuremath{\mathsf{CONGEST}}\xspace, \ensuremath{\mathsf{CLIQUE}}\xspace (aka ``Congested Clique'') and \ensuremath{\mathsf{NCC}}\xspace (``Node Capacitated Clique'') as marginal cases.\footnote{\ensuremath{\mathsf{LOCAL}}\xspace: $\lambda \!=\! \infty, \gamma \!=\! 0$, \ensuremath{\mathsf{CONGEST}}\xspace: $\lambda \!=\! \smash{\ensuremath{O}}(\log n), \gamma \!=\! 0$, \ensuremath{\mathsf{CLIQUE}}\xspace (+ Lenzen's Routing scheme \cite{Lenzen2013}): $\lambda \!=\! 0, \gamma \!=\! n \log n$, \ensuremath{\mathsf{NCC}}\xspace: $\lambda \!=\! 0, \gamma \!=\! \smash{\ensuremath{O}}(\log^2 n)$.} Given the ramifications of investigating \hybridpar{\lambda}{\gamma} in its entirety, we narrow our scope (for our upper bounds) to a particular parametrization that pushes both communication modes to one extreme end of the spectrum. Following the argumentation of \cite{Augustine2020} we leave the size of local messages unrestricted (modeling high local bandwidth) and allow only $\polylog n$ bits of global communication per node per round (modeling severely restricted global bandwidth). Formally, we define the ``standard'' hybrid model as combination of the standard \ensuremath{\mathsf{LOCAL}}\xspace and \ensuremath{\mathsf{NCC}}\xspace \cite{Augustine2019} models: $\ensuremath{\mathsf{HYBRID}}\xspace := \hybridparbig{\infty}{\smash{\ensuremath{O}}(\log^2 n)}$.\footnote{Choosing $\gamma = \smash{\ensuremath{O}}(\log^2 n)$ is due to convenience. It allows nodes to exchange $\smash{\ensuremath{O}}(\log n)$ global messages of size $\smash{\ensuremath{O}}(\log n)$ bits, which often makes randomized algorithms more concise. The slight arbitrariness of this choice is one reason to resort to the $\smash{\ensuremath{\widetilde{O}}}$ notation for analyzing the round complexity.} Note that our lower bounds are parametrized for the more general $\hybridpar{\infty}{\gamma}$ model (which also yields lower bounds for the weaker \ensuremath{\mathsf{HYBRID}}\xspace model).
\paragraph{Routing Schemes \& Distance Oracles} A fundamental aspect of the Internet Protocol is packet forwarding, where every node has to compute a routing function, which -- when combined with target-specific information stored in the packet header -- must indicate the neighbor which the packet has to be forwarded to such that it reaches its intended destination. A correct \textit{routing scheme} consists of these routing functions and a unique \textit{label} per node, such that the packet forwarding procedure induces a path in the network from \textit{any} source node to \textit{any} destination node specified by the corresponding label attached to the packet.
Typically, a distinction is made between \textit{stateful} and \textit{stateless} routing schemes. In the former, routing can be based on additional information accumulated in the packet header as the packet is forwarded, whereas in the latter routing decisions are completely oblivious to the previous routing path. A related problem is the computation of distance oracles, which has some similarities to the all pairs shortest paths problem. Each node must compute an oracle function that provides the distance (or an estimate) to any other node when provided with the corresponding label. Formal definitions are given in Section \ref{sec:preliminaries} (Def.\ \ref{def:distance_oracles}, \ref{def:stateless_routing} and \ref{def:stateful_routing}).
Our first goal is to gather the necessary information for labels, routing and oracle functions with as few communication rounds as possible. This is particularly important for dynamic or unreliable networks where changes in distances or topology necessitates (frequent) re-computation. In this work we allow that node labels\footnote{Allowing relabeling is also called a labeling scheme.} may contain information that help with distance estimation and routing decisions, which gives rise to our second goal; keeping node labels small.\footnote{Usually the amount of information stored at nodes for routing and distance estimation is also considered. Since the nodes in our model are computationally unbounded we do not focus on that. Our lower bounds have also no restriction on the local information.}
The third goal is to speed up the actual packet forwarding process to minimize latency and alleviate congestion. Given a graph with edge weights corresponding to (e.g.) link-latencies, we want to minimize the largest detour any packet takes in relation to the corresponding shortest path. This is also known as \textit{stretch}. Analogously, for distance oracles we want to minimize the worst estimation error relative to the true distance.
\paragraph{Routing Schemes \& Distance Oracles in Distributed Networks} In this work we are interested solving the above problems in a distributed setting (c.f., Definition \ref{def:sync_msg_passing}). This has particular importance given the distributed nature of many real networks where routing problems are relevant (most prominently, the Internet) and where providing a centralized view of the whole network is prohibitively expensive. Note that we are interested in computing routing schemes and distance oracles for the {local communication network}, which is motivated by the fact that typically lots of packets are routed during an ongoing session and due bandwidth and cost constraints of the global mode. However, the global mode can be used to send the (relatively small) destination label to the source of a packet quickly, which can then be stored at that node for the duration of a session.
From an algorithmic standpoint, computing routing schemes and distance oracles is an inherently \textit{global} problem. That is, allowing only local communication (i.e., the \ensuremath{\mathsf{LOCAL}}\xspace model) it takes $\Omega(n)$ rounds to accomplish this (we provide a proof of this in Lemma \ref{lem:lower_bound_local}).\footnote{Any graph problem can be solved in $\smash{\ensuremath{O}}(n)$ rounds in \ensuremath{\mathsf{LOCAL}}\xspace by collecting the graph and solving the problem locally at some node. This makes global problems uninteresting for the \ensuremath{\mathsf{LOCAL}}\xspace model, unless communication restrictions are increased (c.f., \ensuremath{\mathsf{CONGEST}}\xspace) or decreased (c.f., \ensuremath{\mathsf{HYBRID}}\xspace).} A similar observation can be made for the global communication mode (\ensuremath{\mathsf{NCC}}\xspace model). If we are only allowed to use global communication and each node initially only knows its incident edges in the local network, it takes $\smash{\ensuremath{\widetilde{\Omega}}}(n)$\footnote{The $\smash{\ensuremath{\widetilde{O}}}(\cdot)$ notation suppresses multiplicative terms that are polylogarithmic in $n$.} rounds to compute routing schemes and distance oracles (we show that in Lemma \ref{lem:lower_bound_ncc}).\footnote{Computing routing schemes in \ensuremath{\mathsf{NCC}}\xspace is somewhat artificial, as the need for routing schemes for a local network suggests that it exists and can be used.}
This article addresses the question whether the combination of the two communication modes in the \ensuremath{\mathsf{HYBRID}}\xspace model can overcome the $\smash{\ensuremath{\widetilde{\Omega}}}(n)$ lower bound of the individual modes \ensuremath{\mathsf{LOCAL}}\xspace and \ensuremath{\mathsf{NCC}}\xspace.
Our answer to this is two-pronged. First we show that indeed, we can compute routing schemes and distance oracles significantly faster, for instance, we show $\smash{\ensuremath{\widetilde{O}}}(n^{1/3})$ rounds and labels of size $\Theta(n^{2/3})$ suffice (c.f., Theorem \ref{thm:exact_algo}). Second, we show that the \ensuremath{\mathsf{HYBRID}}\xspace model is not arbitrarily powerful by giving polynomial lower bounds for these problems (depending on the stretch) that hold even for relatively large labels and unbounded local memory. For instance, we show that it takes $\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/3})$ rounds to solve either problem exact, even for unweighted graphs and labels of size $\smash{\ensuremath{O}}(n^{2/3})$ (c.f., Theorem \ref{thm:lower_bound_unweighted}).
We provide numerous, more nuanced results, depending on stretch and the type of problem, summarized in the following.
\subsection{Contributions and Overview}
Our contributions and results are summarized in Table \ref{tbl:results}, which gives a simplified overview of our complexity results for the various forms of routing scheme and distance oracle problems.
Here we also want to give some intuition into how our techniques work and highlight how some of the results are generalized in the main part.
\begin{table}[ht]
\begin{center}
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{@{}p{13mm}>{\centering\arraybackslash}cccc@{}}
\toprule
problem & stretch & complexity & label-size & reference\\
\midrule
\multirow{2}{*}{\shortstack[l]{distance\\ oracles}} & $3\!-\!\varepsilon$ & $\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/3})$ & $\smash{\ensuremath{O}}(n^{2/3})^\dagger$ & Thm.\ \ref{thm:lower_bound_distance_oracle_small_stretch}\\
& $\ell$ & $\smash{\ensuremath{\widetilde{\Omega}}}\big(n^{1/f(\ell)}\big)^\ddagger$ & $\smash{\ensuremath{O}}\big(n^{2/f(\ell)}\big)^\ddagger$ & Thm.\ \ref{thm:lower_bound_distance_oracle_small_stretch}, \ref{thm:lower_bound_distance_oracle_large_stretch} \\
\midrule
\multirow{3}{*}{\shortstack[l]{\textit{stateless}\\ routing\\ schemes}} & $\sqrt{3}\!-\!\varepsilon$ & $\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/3})$ & $\smash{\ensuremath{O}}(n^{2/3})^\dagger$ & Thm.\ \ref{thm:lower_bound_stateless_routing}\\
& $\sqrt{5}\!-\!\varepsilon$ & $\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/5})$ & $\smash{\ensuremath{O}}(n^{2/5})^\dagger$ & Thm.\ \ref{thm:lower_bound_stateless_routing}\\
& $1\!+\!\sqrt{2}\!-\!\varepsilon$ & $\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/7})$ & $\smash{\ensuremath{O}}(n^{2/7})^\dagger$ & Thm.\ \ref{thm:lower_bound_stateless_routing}\\
\midrule
\multirow{4}{*}{\shortstack[l]{\textit{stateful}\\ routing\\ schemes}} & $\sqrt{2}\!-\!\varepsilon$ & $\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/3})$ & $\smash{\ensuremath{O}}(n^{2/3})^\dagger$ & Thm.\ \ref{thm:lower_bound_stateful_routing}\\
& $\frac{5}{3}\!-\!\varepsilon$ & $\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/5})$ & $\smash{\ensuremath{O}}(n^{2/5})^\dagger$ & Thm.\ \ref{thm:lower_bound_stateful_routing}\\
& $\frac{7}{4}\!-\!\varepsilon$ & $\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/7})$ & $\smash{\ensuremath{O}}(n^{2/7})^\dagger$ & Thm.\ \ref{thm:lower_bound_stateful_routing}\\
& $\approx 1.78$ & $\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/11})$ & $\smash{\ensuremath{O}}(n^{2/11})$ & Thm.\ \ref{thm:lower_bound_stateful_routing}\\
\midrule
\multirow{2}{*}{\shortstack[l]{all on\\ \textit{unw.\ graphs}}} & exact & $\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/3})$ & $\smash{\ensuremath{O}}(n^{2/3})^\dagger$ & Thm.\ \ref{thm:lower_bound_unweighted}\\
& $1\!+\!\varepsilon$ & $\smash{\ensuremath{\widetilde{O}}}(n^{1/3}/\varepsilon)$ & $\Theta(\log n)$ & Thm.\ \ref{thm:approx_algo}\\
\midrule
\multirow{2}{*}{\shortstack[l]{all on \textit{weigh.}\\ \textit{graphs}}} & exact & $\smash{\ensuremath{\widetilde{O}}}(n^{1/3})$ & $\Theta(n^{2/3})$ & Thm.\ \ref{thm:exact_algo}\\
& 3 & $\smash{\ensuremath{\widetilde{O}}}(n^{1/3})$ & $\Theta(\log n)$ & Thm.\ \ref{thm:approx_algo}\\
\bottomrule
\end{tabular}
\shrt{\begin{minipage}[c]{0.58\linewidth}}
\begin{tablenotes}
\footnotesize
\item $\dagger$ The lower bound on round complexity holds any node labeling of at most that size.
\item $\ddagger$ For some function $f(\ell)$ that is linear in $\ell$.
\end{tablenotes}
\shrt{\end{minipage}}
\end{center}
\caption{Selected and simplified contributions of this paper.}
\label{tbl:results}
\end{table}
\paragraph{Lower Bounds Summary} Our main contribution revolves around computational lower bounds for computing distance oracles and stateless and stateful routing schemes in the \ensuremath{\mathsf{HYBRID}}\xspace model. Lower bounds for approximations are summarized in the first three groups of Table \ref{tbl:results}. We also provide a lower bound on unweighted graphs, given in the first row of the fourth group of Table \ref{tbl:results}. Note that all lower bounds hold regardless of the allowed local memory. Moreover, our lower bounds hold for randomized algorithms with constant success probability.
In the main part, our results are formulated for the more general \hybridpar{\infty}{\gamma} model, that is $\gamma$ appears as a parameter. For instance, our lower bound on unweighted graphs is in fact \smash{$\Omega(n^{1/3}/\gamma^{1/3})$} rounds for labels of size up to \smash{$c \cdot n^{2/3} \cdot \gamma^{1/3}$} for some $c > 0$ (c.f., Theorem \ref{thm:lower_bound_unweighted}), that is, we get a polynomial lower bound for the \hybridpar{\infty}{\gamma} model for any $\gamma \in \tilde o(n)$. For easier readability we plug in the ``standard'' \ensuremath{\mathsf{HYBRID}}\xspace model with $\gamma = \smash{\ensuremath{\widetilde{O}}}(1)$, which lets us hide $\gamma$ by using the $\smash{\ensuremath{\widetilde{\Omega}}}$ notation.
\paragraph{Lower Bounds Overview} The general proof idea is based on information theory and plays out roughly as follows. We start out with a two party communication problem, where Alice is given the state of some random variable $X$ and needs to communicate it to Bob (c.f., Definition \ref{def:party_comm_problem}). Any communication protocol that achieves this needs to communicate $H(X)$ (Shannon entropy of $X$ \cite{Shannon1948}) bits in expectation (c.f., Corollary \ref{cor:lower_bound_two_party}), which is a consequence of the source coding theorem (replicated in Lemma \ref{lem:source_coding_theorem}).
In Section \ref{sec:node_communication_problem} we translate this to the \ensuremath{\mathsf{HYBRID}}\xspace setting into what we call the \textit{node communication problem}. There, we have two sets of nodes $A$ and $B$, where nodes in $A$ ``collectively know'' the state of some random variable $X$ and need to communicate it to $B$ (for more precise information see Definition \ref{def:node_comm_problem}). We show a reduction (via a simulation argument) where a \ensuremath{\mathsf{HYBRID}}\xspace algorithm that solves the node communication problem on sets $A$ and $B$ that are at sufficiently large distance in the local graph, can be used to derive a protocol for the two party communication problem (c.f., Lemma \ref{lem:reduce_comm_problems}). We conclude that for sets $A,B$ with distance at least $h$ it takes $\smash{\ensuremath{\widetilde{\Omega}}}\big(\min(H(X)/n,h)\big)$ rounds to solve this problem (Theorem \ref{thm:lower_bound_node_communication}).
In Section \ref{sec:lower_bounds_unweighted} we give a reduction from the node communication problem to distance oracle and routing scheme computation. The goal is to encode some random variable $X$ with large entropy (super-linear in $n$) into some randomized part of our local communication graph such that some node set $A$ knows $X$ by vicinity. We construct such a graph $\Gamma$ (see Figure \ref{fig:lower_bound_basic}) from the complete bipartite graph $G_{k,k} = (A,E)$ and a (i.i.d.) random $k^2$-bit-string \smash{$X = (x_e)_{e \in E}$} with \smash{$H(X)=\Theta(k^2)$}. Then an edge $e \in E$ of $G_{k,k}$ is present in $\Gamma$ iff $x_e = 1$.
The nodes in $A$ collectively know $X$ since they are incident to the edges sampled from $G_{k,k}$. We designate $k$ nodes of $A$ (one side of the bipartition in $G_{k,k}$) as the ``target nodes''. Then we connect each target with a path of length $h$ to one of $k$ ``source nodes'' which will take the role of $B$ (see Figure \ref{fig:lower_bound_basic}). We show that if the nodes in $B$ learn the distances to the source nodes they also learn about the (non-)existence of the edges sampled from $G_{k,k}$ and can conclude the state of $X$ and thus have solved the node communication problem. Choosing the trade-off between $k$ and $h$ appropriately (roughly $n^{2/3}$ and $n^{1/3}$) we conclude \smash{$\smash{\ensuremath{\widetilde{\Omega}}}\big(\min(H(X)/n,h)\big) = \smash{\ensuremath{\widetilde{\Omega}}}(n^{1/3})$} rounds of communication must have taken place to solve the (exact) distance oracle problem (Theorem \ref{thm:lower_bound_unweighted}).
One caveat is that in the distance oracle problem the nodes are only supposed to give a distance to a target when also provided with the target-label. So we choose the labels sufficiently small such that the ``free information'', given in form of the labels of all targets, is negligible. We can allow labels of size $\smash{\ensuremath{O}}(n^{2/3})$ without changing the above narrative, see Theorem \ref{thm:lower_bound_unweighted}.
For routing schemes we have to adapt the graph $\Gamma$ a bit. We add a slightly longer alternative route from sources to targets (Figure \ref{fig:lower_bound_basic}, left side) and show that the existence of edges and thus the state of $X$ can be concluded from the first routing decision the sources have to make
So far we got lower bounds only for exact solutions with the advantage that they hold on unweighted graphs. In Section \ref{sec:lower_bounds_approx} we show how to use graph weights to get lower bounds for approximation algorithms. For this we replace $G_{k,k}$ with a balanced, bipartite graph $G = (A,E)$ with $k$ nodes and girth $\ell$ (length of the shortest cycle in $G$). As before, the existence of an edge $e \in E$ in $\Gamma$ is determined by to a random bit string $X = (x_e)_{e \in E}$, c.f., Figure \ref{fig:lower_bound_enhanced}. If some edge $e \in E$ is not in $\Gamma$, then the detour in $\Gamma$ between the endpoints of $e$ is at least $\ell\!-\!1$ edges (otherwise $e$ closes a loop of less than $\ell$ edges). By assigning large weights to edges sampled from $G$, we can transform this into multiplicative detour of almost $\ell\!-\!1$. Similar to the idea in the unweighted case, any algorithm for distance oracles that has stretch \textit{slightly} smaller than $\ell\!-\!1$ can be used to solve the node communication problem, which takes \smash{$\smash{\ensuremath{\widetilde{\Omega}}}\big(\min(H(X)/n,h)\big)$} rounds.
To optimize the lower bound we need to maximize the entropy $H(X)$ of \smash{$X = (x_e)_{e \in E}$}, i.e., the density of $G$.
However, it is well known that girth and density of a graph are opposing goals: a graph with girth $2g+1$ can have at most \smash{$\smash{\ensuremath{O}}\big(n^{1+1/g}\big)$} edges (c.f., \cite{Alon2001}, simplified in Lemma \ref{lem:girth_edges_bound}). This inherently limits the amount of information we can encode in $\Gamma$ and we show in Lemma \ref{lem:approx_lower_bound_groundwork} how graph density affects lower bounds for the node communication problem.
The good news is, that for some girth values, graphs that achieve their theoretical density limit actually exist and have been constructed (c.f., \citealp{Benson1966, Singleton1966}, simplified form given in Lemma \ref{lem:low_girth_graph_density}). For higher girth values, graphs that come close to that limit are known (c.f., \cite{Lazebnik1997}, simplified form in Lemma \ref{lem:high_girth_graph_density}).\footnote{There is a long standing conjecture that for each girth $2g\!+\!1$ there exists a graph that reaches the theoretical limit of \smash{$\smash{\ensuremath{O}}\big(n^{1+1/g}\big)$} edges (\cite{Erdoes1982}, c.f., Conjecture \ref{con:erdoes_girth}). Our tools can be used to generate new lower bounds in case new such graphs are found.}
Utilizing these graphs we achieve polynomial lower bounds for the \textit{distance oracle} problem for some small stretch values (c.f., Theorem \ref{thm:lower_bound_distance_oracle_small_stretch}) and for arbitrary constant stretch (c.f., Theorem \ref{thm:lower_bound_distance_oracle_large_stretch}). Theorem \ref{thm:lower_bound_distance_oracle_large_stretch} is heavily parametrized, but to sum it up in a simpler way: for any constant stretch $\ell$ we attain a polynomial lower bound of \smash{$\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/f(\ell)})$}, that is, $f(\ell)$ is constant as well (roughly \smash{$f(\ell) \approx \frac{3}{2}\ell$}).
For approximate \textit{routing schemes} we have to be more careful and also make a distinction between the stateless and stateful variant (c.f., Definitions \ref{def:stateless_routing}, \ref{def:stateful_routing}).
The idea is the same as in the exact, unweighted case, however, since a wrong routing decision at the source can still be completed into a routing path of relatively good quality, the best stretch that can be achieved for lower bounds is limited (even more so for stateful routing, where a packet may ``backtrack''). In particular, allowing too much stretch can open up unwanted routing paths that mislead the sources in their conclusions about $X$. We forbid these unwanted routing paths using inequalities parametrized by the stretch and graph weights. Maximizing the stretch subject to these conditions we obtain the lower bounds for stretch values that are given in the second and third group of Table \ref{tbl:results} with details in Theorems \ref{thm:lower_bound_stateless_routing} and \ref{thm:lower_bound_stateful_routing}.
\paragraph{Upper Bounds Summary \& Overview} Our computational upper bounds (Given in Appendix \ref{sec:upper_bounds}) can be expressed more concisely due to the existence of efficient randomized algorithms for shortest path problems in the \ensuremath{\mathsf{HYBRID}}\xspace model. In particular we draw on fast solutions for the so called \textit{random sources shortest paths problem} (RSSP) \cite{CensorHillel2021}, where all nodes must learn their distance to a set of i.i.d. randomly sampled nodes, say $S$. After solving RSSP, our strategy is to use the distance between a node $u$ and the nodes in $S$ as its label $\lambda(u)$.
Roughly speaking, provided that $u$ is sufficiently ``far away'', a node $v$ can combine $\lambda(u)$ with its own distances to $S$ to compute its distance (estimate) to $u$. If $u$ is ``close'' then we can use the local network to compute the distance directly. While this gives us only distance oracles, it is relatively straight forward to also derive routing schemes. Simply speaking, we can always send a packet to a neighbor that has the best distance (estimate) to $u$ (some care must be taken for approximations). Note that this process is oblivious to previous routing decisions so the obtained routing scheme is stateless (c.f., Definition \ref{def:stateless_routing}).
A trade-off arises from the local exploration around nodes and the global computation depending on the size of $S$ (since we solve RSSP on $S$), which balances out to a round complexity of \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{1/3})$} with \smash{$|S| \in \smash{\ensuremath{\widetilde{O}}}(n^{2/3})$} (similar trade-offs were observed for shortest paths problems in \cite{Augustine2020, Kuhn2020, CensorHillel2021}). For exact algorithms (distance oracles and routing schemes) we require labels of size \smash{$\Theta(n^{2/3})$} (however we can decrease the label size to \smash{$\Theta(n^{2/3-\zeta})$} at a cost of \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{1/3+\zeta})$} rounds, c.f., Theorem \ref{thm:exact_algo}). This is tight up to $\polylog n$ factors as is shown by the corresponding lower bound in Table \ref{tbl:results} group 4 line 1 (which holds even on unweighted graphs).
For smaller labels we show that restricting $\lambda(u)$ to $u$'s closest node in $S$ gives good approximations. We obtain a 3-approximation on weighted graphs and a $(1\!+\!\varepsilon)$ approximation on unweighted graphs in $\smash{\ensuremath{\widetilde{O}}}(n^{1/3})$ rounds (assuming $\varepsilon>0$ is constant) with labels of size $\smash{\ensuremath{O}}(\log n)$ (c.f., Theorem \ref{thm:approx_algo}). Compare this to our lower bounds: even much larger labels of size $\Theta(n^{2/3})$ do \textit{not} help to improve the runtime or the stretch by much, as this still takes $\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/3})$ rounds for stretch of $3\!-\!\varepsilon$ for distance oracles on weighted graphs, and stretch $1$ on unweighted graphs (see Table \ref{tbl:results}).
\subsection{Related Work}
There was an early effort to approach hybrid networks from a theoretic angle \cite{Afek1990}, with a conceptually different model.\footnote{Essentially \cite{Afek1990} combines \ensuremath{\mathsf{LOCAL}}\xspace with a global channel where in each round \textit{one} node may broadcast a message, making it much weaker than the \ensuremath{\mathsf{HYBRID}}\xspace model.}
Research on the current take of the \ensuremath{\mathsf{HYBRID}}\xspace model was initiated by \cite{Augustine2020} in the context of shortest paths problems, which most of the research has focused on so far. As shortest paths problems problems are closely related, we give a brief account of the recent developments.
\paragraph{Shortest Paths in the Hybrid Model} \cite{Augustine2020} introduced an information dissemination scheme to efficiently broadcast small messages to all nodes in the network. Using this protocol, they derive various solutions for shortest paths problems. For instance, for SSSP:\footnote{In the $k$ sources shortest paths problem ($k$-SSP) all nodes must learn their distance to $k$ dedicated source nodes. Then SSSP \smash{$\stackrel{\text{def}}{=}$} $1$-SSP, APSP \smash{$\stackrel{\text{def}}{=}$} $n$-SSP.} a $(1\!+\!\varepsilon)$ stretch, \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{1/3})$}-round algorithm and a $(1/\varepsilon)^{\smash{\ensuremath{O}}(1/\varepsilon)}$-stretch, \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{\varepsilon})$}-round algorithm.\footnote{\cite{Augustine2020} also gives an exact, \smash{$\smash{\ensuremath{\widetilde{O}}}\big(\!\sqrt{\text{SPD}}\big)$}-round SSSP algorithm depending on the shortest path diameter SPD, using a completely different approach.} Further, an approximation of APSP with stretch 3 in \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{1/2})$} rounds, which closely matches their corresponding \smash{$\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/2})$} lower bound (which holds for much larger stretch).
Subsequently, \cite{Kuhn2020} introduced a protocol for efficient routing of small messages between dedicated source-target pairs in the \ensuremath{\mathsf{HYBRID}}\xspace model (not to be confused with routing schemes), which they use to solve APSP and SSSP {exactly} in \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{1/2})$} and \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{2/5})$} rounds, respectively. For computing the diameter they provide algorithms (e.g., a $3/2\!+\!\varepsilon$ approximation in \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{1/3})$} rounds) and a \smash{$\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/3})$} lower bound.
\cite{CensorHillel2021} combines the techniques of \cite{Kuhn2020} with a densitiy sensitive approach, to solve $n^{1/3}$-SSP (thus SSSP) exactly and compute a $(1\!+\!\varepsilon)$-approximation of the diameter in \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{1/3})$} rounds.\footnote{As we reuse some techniques of \cite{Augustine2020, Kuhn2020, CensorHillel2021}, we explain them in a bit more detail in Section \ref{sec:upper_bounds}).} \cite{CensorHillel2021a} uses density awareness in a different way to improve SSSP to \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{5/17})$} rounds for a small stretch of $(1\!+\!\varepsilon)$.
\cite{Anagnostides2021} derandomized the dissemination protocol of \cite{Augustine2020} to obtain a deterministic APSP-algorithm with stretch \smash{$\frac{\log n}{\log\log n}$} in \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{1/2})$} rounds.
For classes of sparse graphs (e.g., cactus graphs) \cite{Feldmann2020} demonstrates that $\polylog n$ solutions are possible even in the harsher hybrid combination \ensuremath{\mathsf{CONGEST}}\xspace and \ensuremath{\mathsf{NCC}}\xspace.
\paragraph{Routing Schemes in Distributed Models} Routing schemes in a hybrid network model have been pioneered in \cite{Coy2021}. Their work can be contrasted to this article in three main ways: First, they consider specific types of local graphs, namely ``hole-free'' grid graphs and unit disc graphs (UDGs) (which have practical relevance in the context of wireless local networks), whereas this work focuses on general graphs. Second, \cite{Coy2021} provides upper bounds based on a routing scheme on a grid-graph abstraction of UDGs, whereas the main technical contribution of this work are lower bounds. Third, we consider hybrid networks with unlimited \ensuremath{\mathsf{LOCAL}}\xspace edges (which strengthens our lower bounds), whereas \cite{Coy2021} gives a $\smash{\ensuremath{O}}(\log n)$ round algorithm with labels and local tables of size $\smash{\ensuremath{O}}(\log n)$ and stretch 1 and constant stretch on certain grid-graphs and UDGs, respectively, which holds even for the stricter combination of \ensuremath{\mathsf{CONGEST}}\xspace and \ensuremath{\mathsf{NCC}}\xspace. Note that our lower bounds supplement the work of \cite{Coy2021} in that it shows the necessity to narrow the scope (for instance to particular graph classes) in order to achieve $\smash{\ensuremath{O}}(\log n)$ round algorithms with small labels and stretch.
A related line of work investigates the round complexity of implementing routing schemes and distance oracles in the \ensuremath{\mathsf{CONGEST}}\xspace model, where the challenge is that only small local messages can be used. Here, a \smash{$\smash{\ensuremath{\widetilde{\Omega}}}(n^{1/2} \!+\! D_G)$} lower bound for computing routing schemes is implied by \cite{Sarma2012} (even for polynomial labels, whereas $D_G$ is the diameter of $G$). For distance oracles in \ensuremath{\mathsf{CONGEST}}\xspace, \cite{Izumi2014} gives a lower bound of \smash{$\Omega(n^{\frac{1}{2}+\frac{1}{5k}})$} with stretch $2k$ for graphs with small diameter assuming Erd\H{o}s' girth conjecture (c.f., Conjecture \ref{con:erdoes_girth}). Their bound holds for small labels without this assumption.
A line of papers narrows the gap to these lower bounds \cite{Lenzen2013a, Lenzen2015, Elkin2016}. For instance \cite{Elkin2016} achieves a routing scheme with stretch $\smash{\ensuremath{O}}(k)$, routing tables of size $\smash{\ensuremath{\widetilde{O}}}(n^{1/k})$, labels of size $\smash{\ensuremath{\widetilde{O}}}(k)$ in $\smash{\ensuremath{O}}\big(n^{1/2 + 1/k} \!+\! D_G\big) \cdot n^{o(1)}$ rounds.
\paragraph{Routing Schemes as Distributed Data Structure} In this branch of research the goal is often to optimize the trade-off between stretch and the size of the local routing tables. It is well established that $\smash{\ensuremath{\widetilde{O}}}(n)$ bit of memory per node always suffices for routing schemes\footnote{As $\smash{\ensuremath{\widetilde{O}}}(n)$ bit of memory allows each node to store the next node for every destination.} \cite{Peleg1989}. For routing schemes on general graphs with small stretch ($<\!3$) $\Omega(n)$ bit are required \cite{Peleg1989, Thorup2001}.\footnote{With $o(n)$ local memory a $\Omega(n)$-degree node has to ``forget'' neighbors, necessarily generating a detour when routing to the neighbors that have been forgotten. This lower bound is part of the reason why we do not analyze local memory in this work.} More generally, for a stretch smaller than $2k\!+\!1$ it is known that local tables of size $\Omega({n^{1/k}})$ bit are required for small values $k \in \{1,2,3,5\}$, see \cite{Thorup2001}. This is true for all parameters of $k$ if one believes Erd\H{o}s' girth conjecture (see Conjecture \ref{con:erdoes_girth}) \cite{Thorup2001}. The reliance on this conjecture can be dropped for weaker \textit{name-independent} routing schemes, where nodes can \textit{not} be re-labeled and \cite{Abraham2006} shows that this requires \smash{$\Omega({(n\log n)^{1/k}})$} memory for any stretch smaller than $2k\!+\!1$.
On the positive side, \cite{Thorup2001} shows that a stretch of $\smash{\ensuremath{O}}(k)$ with \smash{$\smash{\ensuremath{\widetilde{O}}}({kn^{1/k}})$} memory can be achieved. The concrete stretch is $4k\!-\!5$ or even $2k\!-\!1$ (i.e., almost optimal) if \textit{handshaking} is allowed (an initial exchange of a message between source and destination before a packet is routed). The lower bound for name independent routing has been contrasted with a scheme that achieves $O(k)$ stretch with memory size \smash{$\smash{\ensuremath{\widetilde{O}}}(k^2n^{1/k})$} \cite{Abraham2006a}.
\subsection{Preliminaries}
\label{sec:preliminaries}
\paragraph{General Definitions} The scope of this paper is solving graph problems, typically in the undirected communication graph. Let $G = (V,E)$ be undirected. Edges have {weights} $w: E \to [W]$, where $W$ is at most polynomial in $n$, thus the weight of an edge and of a simple path fits into a $\smash{\ensuremath{O}}(\log n)$ bit message.\footnote{In this article, $\log$ functions are always to the base of 2.} A graph is considered {unweighted} if $W=1$. Let $w(P) = \sum_{e \in P}w(e)$ denote the length of a path $P \subseteq E$. Then the \emph{distance} between two nodes $u,v \in V$ is
\lng{\[
d_G(u,v) := \!\min_{\text{$u$-$v$-path } P} w(P).
\]}
\shrt{$d_G(u,v) := \!\min_{\text{$u$-$v$-path } P} w(P).$}
A path with smallest length between two nodes is called a \emph{shortest path}.
Let $|P|$ be the number of edges (or \emph{hops}) of a path $P$.
The \emph{hop-distance} between two nodes $u$ and $v$ is defined as:
\lng{\[
\hop_G(u,v) := \!\min_{\text{$u$-$v$-path } P} |P|.
\vspace*{-1mm}
\] }
\shrt{$\hop_G(u,v) := \!\min_{\text{$u$-$v$-path } P} |P|.$}
We generalize this for sets $U,W \subseteq V$ (whereas $\hop_G(v,v) := 0$):
\lng{\[
\hop_G(U,W) := \!\min_{u \in U, w \in W} \hop_G(u,w).
\vspace*{-1mm}
\] }
\shrt{$\hop_G(U,W) := \!\min_{u \in U, w \in W} \hop_G(u,w).$}
The \emph{diameter} of $G$ is defined as:
\lng{\[
D_G:= \max_{u,v \in V} \hop_G(u,v).
\]}
\shrt{$D_G:= \max_{u,v \in V} \hop_G(u,v).$}
Let the \emph{$h$-hop distance} from $u$ to $v$ be:
\lng{\[
d_{G,h}(u,v) := \!\!\min_{{\text{$u$-$v$-path } P, |P| \leq h }}\, w(P).
\]}
\shrt{$d_{G,h}(u,v) := \!\!\min_{{\text{$u$-$v$-path } P, |P| \leq h }}\, w(P).$}
If there is no $u$-$v$ path $P$ with $|P|\leq h$ we define $d_{h}(u,v) := \infty$. We drop the subscript $G$, when $G$ is clear from the context. In this paper we consider the following problem types:
\begin{definition}[Distance Oracles]
\label{def:distance_oracles}
Every node $v \in V$ of a graph $G= (V,E)$ needs to compute a \textit{label} $\lambda(v)$ and an \textit{oracle function} $o_v : \lambda(V) \to \mathbb{N}$, such that $o_v(\lambda(u)) \geq d(u,v)$ for all $u \in V$.
An oracle function $o_v$ is an $(\alpha, \beta)$-approximation if $o_v(\lambda(u)) \leq \alpha \cdot d(u,v) + \beta$ for all $u,v \in V$, that is, $\alpha, \beta$ are the \textit{multiplicative} and \textit{additive} approximation error, respectively. We speak of a \textit{stretch} of $\alpha$ in case of an $(\alpha, 0)$-approximation. If the stretch is one, we call $o_v$ \textit{exact}.
\end{definition}
\begin{definition}[Stateless Routing Scheme]
\label{def:stateless_routing}
Every node $v \in V$ of a graph $G= (V,E)$ needs to learn a \textit{label} $\lambda(v)$ and a \textit{routing function} (sometimes called ``table'') $\rho_v : \lambda(V) \to N(v)\cup \{v\}$ where $N(v)$ are adjacent nodes of $v$ in $G$ (whereas we formally set $\rho_v(\lambda(v)) := v$). The functions $\rho_v$ must fulfill the following correctness condition.
Let $v_0 := v$ and recursively define \smash{$v_i := \rho_{v_{i-1}}(\lambda(u))$}.
Then the routing functions $\rho_v, v \in V$ must satisfy $v_h = u$ for some $h \in \mathbb{N}$.
Let $P_\rho(u,v)$ be the path induced by the visited nodes $v_0, \dots, v_h$. We call $\rho$ an $(\alpha, \beta)$-approximation if $w(P_\rho(u,v)) \leq \alpha d(u,v) + \beta$ for all $u,v \in V$.
\end{definition}
\begin{definition}[Stateful Routing Scheme]
\label{def:stateful_routing}
This is mostly defined as in the stateless case, with the difference that the routing function $\rho_v$ can additionally depend on the information gathered along the path that has already been visited by a packet (which would be stored in its header). Note that in this means that the routing path defined by such a function $\rho$ is not necessarily simple (i.e., might have loops).
\end{definition}
\begin{definition}[Randomized Graph Algorithms]
\label{def:rand_algo}
We say that an algorithm has success probability $p$, if it succeeds with probability at least $p$ on every possible input graph (however, some of our results are restricted to unweighted graphs as input). Specifically, for our upper bounds we aim for success \textit{with high probability} (w.h.p.), which means with success probability at least $1-\frac{1}{n^c}$ for any constant $c>0$.
\end{definition}
\lng{\input{sec/upper_bounds.tex}}
\section{Node Communication Problem}
\label{sec:node_communication_problem}
\lng{In the remaining sections of this paper we will completely focus on computational lower bounds.} This section is dedicated to creating an ``information bottleneck'' in the \ensuremath{\mathsf{HYBRID}}\xspace model between two (distant) parts of the local communication graph. We do this for the more general $\hybridpar{\infty}{\gamma}$ model, where we have a global communication bandwidth of $\gamma$ bits per node per round. Besides the advantage of having a more general lower bound, this avoids logarithmic terms and $\smash{\ensuremath{O}}$-notation as long as possible (recall that $\ensuremath{\mathsf{HYBRID}}\xspace = \hybridparbig{\infty}{\smash{\ensuremath{O}}(\log^2 n)}$).
We start with some intuition. Let $G=(V,E)$ be a graph. Assume that information, formalized as the state of some random variable $X$, is collectively known by nodes $A \subset V$ and must be learned by some set $B \subset V$ disjoint from $A$. This information either has to travel the hop distance $h := hop(A,B)$ from $A$ to $B$ along the unrestricted local network, which takes $h$ rounds. If we want to be faster than that, each bit traveling from $A$ to $B$ has to use a global edge eventually. Thus the number of rounds is at least the ``total amount'' of information (given by the entropy $H(X)$\footnote{The Shannon entropy of random variable $X\!:\! \Omega \!\to\! S$ is defined as $H(X) := - \!\sum_{x \in S} \mathbb{P}(X \!=\! x) \log \big(\mathbb{P}(X \!=\! x) \big)$ \cite{Shannon1948}.}), divided by the overall global communication capacity of at most $n \cdot \gamma$ bits in the $\hybridpar{\infty}{\gamma}$ model
To prove this formally and in a more general form, we first introduce some definitions. We say that the nodes from some set $A \subseteq V$ \textit{collectively know} the state of a random variable $X$, if its state can be derived from the information that the nodes $A$ have. Or, in terms of information theory, given the state or input $S_A$ of all nodes $A$ (interpreted as a random variable), then the conditional entropy $H(X|S_A)$ also known as the amount of new information of $X$ provided that $S_A$ is already known, is zero.
Similarly, we say that the state of $X$ is \textit{unknown} to $B \subseteq V$, if the initial information of the nodes $B$ does not induce any knowledge on the outcome of $X$. Or formally, that for the state $S_B$ of the nodes $B$ we have that $H(X|S_B) = H(X)$, meaning that all information in $X$ is new even if $S_B$ is known. Another way of expressing this is that $S_B$ and $X$ are stochastically independent.
\begin{definition}[Node Communication Problem]
\label{def:node_comm_problem}
Let $G=(V,E)$ be some graph. Let $A,B \subset V$ be disjoint sets of nodes and $h := hop(A,B)$. Furthermore, let $X$ be a random variable whose state is collectively known by the nodes $A$ but unknown to any set of nodes disjoint from $A$. An algorithm $\mathcal A$ solves the \emph{node communication problem} if the nodes in $B$ collectively know the state of $X$ after $\mathcal A$ terminates. We say $\mathcal{A}$ has success probability $p$ if $\mathcal{A}$ solves the problem with probability at least $p$ for \emph{any} state $X$ can take.\footnote{In line with our Definition \ref{def:rand_algo} of success probability for graph algorithms.}
\end{definition}
The goal of Lemma \ref{lem:reduce_comm_problems} is to reduce a more basic communication problem, for which we can provide lower bounds using basic information theory (c.f., Appendix \ref{sec:information_theory}) {to} the node communication problem. Analogously to node sets, we define that Alice knows some random variable $X$, which is unknown to Bob as follows. Given that $S_{\text{Alice}}$ and $S_{\text{Bob}}$ are their respective inputs then we have $H(X|S_{\text{Alice}}) = 0$ and $H(X|S_{\text{Bob}}) = H(X)$.
\begin{definition}[Two Party Communication Problem]
\label{def:party_comm_problem}
Given two computationally unbounded parties, Alice and Bob, where initially Alice knows the state of some random variable $X$ which is unknown to Bob. A communication protocol $\mathcal P$ is said to solve the problem if after the execution of $\mathcal P$ Bob can derive the state of $X$ from the transcript of all exchanged messages. Performance is measured in the length of the transcript in bits. We say $\mathcal P$ has success probability $p$ if $\mathcal P$ solves the problem with probability at least $p$ for \emph{any} state $X$ can take.
\end{definition}
The reduction from the 2-party communication problem to the node communication problem uses a simulation argument similar to the one in \cite{Kuhn2020}. We show that Alice and Bob can together simulate a \hybridpar{\infty}{\gamma} model algorithm for the node communication problem and use it solve the 2-party communication problem. \shrt{The proof is deferred to Appendix \ref{sec:node_communication_problem_proofs}.}
\begin{lemma}
\label{lem:reduce_comm_problems}
Any algorithm $\mathcal A$ that solves the \emph{node communication problem} (Def.\ \ref{def:node_comm_problem}) in the \hybridpar{\infty}{\gamma} model on some local graph $G = (V,E)$ with $n = |V|$ and $A,B \subset V$ in $T < h = hop(A,B)$ rounds with success probability $p$ can be used to obtain a protocol $\mathcal P$ that solves the \textit{two party communication problem} (Def.\ \ref{def:party_comm_problem}) with the same success probability $p$ and transcript length at most $T \cdot n \cdot \gamma$.
\end{lemma}
\lng{\begin{proof}
We will derive a protocol $\mathcal P$ that uses (i.e., simulates) algorithm $\mathcal A$ in order to solve the two-party communication problem. First we make a few assumptions about the initial knowledge of both parties in particular about the graph $G$ from the node communication problem, you can think of this information as hard coded into the instructions of $\mathcal P$. The important observation is that none of these assumptions will give Bob any knowledge about $X$.
Specifically, we assume that Alice is given complete knowledge of the topology $G$ and inputs of all nodes in $G$ (in particular the state of $X$ and the source codes of all nodes specified by $\mathcal{A}$). Bob is given the same for the subgraph induced by $V \setminus A$, which means that the state of $X$ remains unknown to Bob (c.f., Def.\ \ref{def:node_comm_problem}). To accommodate randomization of $\mathcal A$, both are given the same copy of a string of random bits (determined randomly and independently from $X$) that is sufficiently long to cover all ``coin flips'' used by any node in the execution of $\mathcal A$.
Alice and Bob simulate the following nodes during the simulated execution of algorithm $\mathcal A$. For $i \in [h\!-\!1]$ let $V_i := \{v \in V \mid \hop(v,A) \leq i \}$ be the set of nodes at hop distance at most $i$ from $A$. Note that $A \subseteq V_i$ for all $i$. In round 0 of algorithm $\mathcal A$, Alice simulates all nodes in $A$ and Bob simulates all nodes in $V \setminus A$. However, in subsequent rounds $i > 0$, Alice simulates the larger set $A \cup V_i$ and Bob simulates the smaller set $B \cup V \setminus V_i$.
Figuratively speaking, in round $i$ Bob will relinquish control of all nodes that are at hop distance $i$ from set $A$, to Alice. This means, in each round, every node is simulated \textit{either} by Alice \textit{or} by Bob.
We show that each party can simulate their nodes correctly with an induction on $i$. Initially ($i=0$), this is true as each party gets the necessary inputs of the nodes they simulate. Say we are at the beginning of round $i > 0$ and the simulation was correct so far. It suffices to show that both parties obtain all messages that are sent (in the \hybridpar{\infty}{\gamma} model) to the nodes they currently simulate.
The communication taking place during execution of $\mathcal A$ in the \hybridpar{\infty}{\gamma} model is simulated as follows. If two nodes that are currently simulated by the \emph{same} party, say Alice, want to communicate, then this can be taken care as part of the internal simulation by Alice. If a node that is currently simulated (w.l.o.g.) by Bob wants to send a message over the \emph{global} network to some node that Alice simulates, then Bob sends that message directly to Alice as part of $\mathcal P$, and that message becomes part of the transcript.
Now consider the case where a \textit{local} message is exchanged between some node $u$ simulated by Alice and some node $v$ simulated by Bob. Then in the subsequent round Alice will \textit{always} take control of $v$, as part of our simulation regime. Thus Alice can continue simulating $v$ correctly as she has all information to simulate all nodes all the time anyway (Alice is initially given all inputs of all nodes). Therefore it is \textit{not} required to exchange {any} \textit{local} messages across parties for the correct simulation.
After $T$ simulated rounds, Bob, who simulates the set $B$ until the very end (as $T < h$), can derive the state of $X$ from the local information of $B$ with success probability at least $p$ (same as algorithm $\mathcal A$). Hence, using the global messages that were exchanged between Alice and Bob during the simulation of algorithm $\mathcal A$ we obtain a protocol $\mathcal P$ that solves the two party communication problem with probability $p$. Since total global communication is restricted by $n \cdot \gamma$ bits per round in the \hybridpar{\infty}{\gamma} model, Alice sends Bob at most $T \cdot n \cdot \gamma$ bits during the whole simulation.
\end{proof}}
Next we plug in the lower bound for the 2-party communication problem (c.f.\ Lemma \ref{lem:lower_bound_two_party} in Appendix \ref{sec:information_theory}) to derive a lower bound for the node communication problem. Note that this theorem only depends on the hop distance $h$ between $A,B$ and the entropy of $X$ and is otherwise agnostic to the local graph. Note that a lower bound that holds in expectation is also a worst case lower bound.\footnote{A worst case lower bound means there exists one outcome of $X$ where the algorithm takes at least that many rounds. A lower bound that holds in expectation clearly implies the same in the worst case.}
\begin{theorem}
\label{thm:lower_bound_node_communication}
Any algorithm that solves the {node communication problem} (Def.\ \ref{def:node_comm_problem}) on some $n$-node graph in the \hybridpar{\infty}{\gamma} model with success probability at least $p$, takes at least \smash{$\min\!\big(\frac{pH(X) -1}{n \cdot \gamma}, h\big)$} rounds in expectation, where $H(X)$ denotes the entropy of $X$.
\end{theorem}
\begin{proof}
We have to show that a randomized, \hybridpar{\infty}{\gamma} algorithm $\mathcal A$ that solves the node communication problem in \textit{less} than $h$ rounds with success probability $p$ takes at least \smash{$\frac{p H(X)-1}{n \cdot \gamma}$} rounds.
Presume, for a contradiction, that $\mathcal A$ has an expected running time $T<h$ \textit{and} \smash{$T < \frac{p H(X)-1}{n \cdot \gamma}$}. This implies \smash{$T \cdot n \cdot \gamma < p\cdot H(X)-1$}.
Invoking Lemma \ref{lem:reduce_comm_problems} gives us a protocol $\mathcal P$ with the same success probability $p$ and with a transcript of length at most $T \cdot n \cdot \gamma$.
With the inequality above, this means in the protocol $\mathcal P$, Alice sends \textit{less} than $p\cdot H(X)-1$ bits to Bob in expectation. This contradicts the fact that $p \cdot H(X) -1$ is a lower bound for this due to Appendix \ref{sec:information_theory} Lemma \ref{lem:lower_bound_two_party}
\end{proof}
We have to accommodate the fact that in the routing problem or distance oracle problem, the nodes have to give a distance estimation or next routing neighbor only when provided with the label of the target node. Therefore we have to slightly amend Theorem \ref{thm:lower_bound_node_communication}, which will later allow us to argue that even if we assume that nodes have advance knowledge of a selection of sufficiently small labels, the lower bound will not change asymptotically. \shrt{The proof is deferred to Appendix \ref{sec:node_communication_problem_proofs}.}
\begin{corollary}
\label{cor:lower_bound_general_amended}
If $A$ is allowed to communicate $y$ bits to $B$ for free, then any algorithm that solves the {node communication problem} on some $n$-node graph (Def.\ \ref{def:node_comm_problem}) in the \hybridpar{\infty}{\gamma} model with success probability at least $p$, takes at least \smash{$\min\!\big(\frac{pH(X) -1-y}{n \cdot \gamma}, h\big)$} rounds in expectation (i.e., also in the worst case).
\end{corollary}
\lng{\begin{proof}
As above, the node communication problem reduces to the communication problem between Alice and Bob, where Alice is now allowed to send $y$ bits to Bob in advance. Note that this still requires Alice to send $p \cdot H(X)-1-y$ remaining bits in expectation, as per Lemma \ref{lem:lower_bound_two_party}.
The same contradiction as in Theorem \ref{thm:lower_bound_node_communication} can be derived as follows. Fewer rounds than stated in this lemma would imply that the transcript of global messages from Alice to Bob, would be shorter than $p \cdot H(X)-1-y$ bits (essentially by substituting $p \cdot H(X)-1$ for $p \cdot H(X)-1-y$ in the previous proof). Thus the transcript would be less than $p \cdot H(X)-1$ bits even when we add the $y$ ``free'' bits to the transcript.
\end{proof}}
\section{Lower Bounds For Unweighted Graphs}
\label{sec:lower_bounds_unweighted}
In this and the following section we aim to reduce from the node communication problem in the \hybridpar{\infty}{\gamma} model given in Definition \ref{def:node_comm_problem}, to the problem of computing routing tables or distance oracles, which works as follows.
We define a graph $\Gamma = (V_\Gamma, E_\Gamma)$ such that, first, the solution of the routing or distance oracle problems informs a subset $B \subset V_\Gamma$ about the exact state of some random variable $X$ that is encoded by the subgraph induced by $A \subset V_\Gamma$. Second, $X$ has a large entropy (we aim for super-linear in $n$). And third, the distance $hop(A,B)$ between both sets is sufficiently large.
\begin{definition}
\label{def:unweighted_construction}
Let \smash{$X = (x_{ij})_{i,j\in[k]} \in \{0,1\}^{k^2}$} be a bit sequence of length \smash{$k^2$}. Let $\Gamma = (V_\Gamma, E_\Gamma)$ (shown in Figure \ref{fig:lower_bound_basic}) be an unweighted graph with source nodes $s_1, \dots, s_k \in V_\Gamma$, transit nodes $u_1, \dots, u_k \in V_\Gamma$ and target nodes $t_1, \dots, t_k \in V_\Gamma$.
Each source $s_i$ has a path of length $h$ hops to the transit nodes $u_i$. We have an edge between $u_i$ and $t_j$ if and only if $x_{ij} = 1$.
Additionally, there are two nodes $v,v'\in V_\Gamma$ connected by a path of $h$ hops. The nodes $v$ and $v'$ have an edge to each source $s_i$ or target $t_i$, respectively (Figure \ref{fig:lower_bound_basic}).
\end{definition}
This construction has the following properties.
\begin{enumerate}[(1)]
\item The distance from source $s_i$ to $t_j$ is larger for $x_{ij} = 0$ than for $x_{ij} = 1$ (as shown by the subsequent Lemma \ref{lem:source_target_distance_unweighted}).
\item For all $i,j \in [k]$, independently set $x_{ij} = 1$ with probability $\frac{1}{2}$, else $x_{ij} = 0$. This maximizes \smash{$H(X) = -k^2 \cdot \frac{\log(1/2)}{2} = \frac{k^2}{2}$}.
\item Let $A \!=\!\{u_1, ... \,, u_k,t_1, ... \,, t_k\}$, $B \!=\! \{s_1, ... \,, s_k\}$, i.e., $hop(A,B) \!=\! h$.
\end{enumerate}
\lng{\begin{figure}[h]
\centering
\includegraphics[scale=0.7]{img/lower_bound.pdf}
\caption{\lng{\boldmath} Graph $\Gamma = (V_\Gamma,E_\Gamma)$. Bit string $X = (x_{ij})$ determines red edges. E.g., $\{u_1, t_2\} \!\notin\! E_\Gamma$ and $\{u_1, t_3\} \!\in\! E_\Gamma$ means $x_{12} = 0$ and $x_{13} = 1$, respectively.}
\label{fig:lower_bound_basic}
\end{figure}}
\shrt{\begin{figure}[h]
\centering
\begin{subfigure}{0.48\textwidth}
\includegraphics[scale=0.73]{img/lower_bound.pdf}
\caption{\lng{\boldmath} Graph $\Gamma = (V_\Gamma,E_\Gamma)$. Bit string $X = (x_{ij})$ determines red edges. E.g., $\{u_1, t_2\} \!\notin\! E_\Gamma$ and $\{u_1, t_3\} \!\in\! E_\Gamma$ means $x_{12} = 0$ and $x_{13} = 1$, respectively.}
\label{fig:lower_bound_basic}
\end{subfigure}
\hfill
\begin{subfigure}{0.48\textwidth}
\includegraphics[scale=0.73, page = 2]{img/lower_bound.pdf}
\caption{\lng{\boldmath} Graph $\Gamma$ constructed around $G = (A,E) \in \mathcal G_{k,\ell}$ with $m := |E|$ edges (in red) and from the bit string $X = (x_e)_{e \in E} \in \{0,1\}^m$. An edge $e \in E$ is part of $\Gamma$ iff $x_e = 1$.
}
\label{fig:lower_bound_enhanced}
\end{subfigure}
\vspace*{-2mm}
\caption{Lower bound graphs. Unweighted (left) and weighted (right).}
\end{figure}}
\vspace*{-2mm}
\lng{Property (1) is shown by the following lemma.}
\begin{lemma}
\label{lem:source_target_distance_unweighted}
{If $x_{ij}\!=\!1$ then $d(s_i,t_j) = h\!+\!1$ and the shortest $s_i$-$t_j$-path contains $v$, else $d(s_i,t_j) = h\!+\!2$ and it does not contain $v$.}\footnote{In the following, distances without subscript will refer to distances in $\Gamma$, i.e., $d(u,v) := d_\Gamma(u,v)$.}
\end{lemma}
\begin{proof}
Any path from $s_i$ to $t_j$ has to cross the vertex cut $U := \{u_1, \dots ,u_k,v'\}$ (c.f., Figure \ref{fig:lower_bound_basic}). Such a path has to include a path of length $h$ to reach a node of $U$, as well as an additional edge connecting $U$ to $t_j$ and therefore $d(s_i,t_j) \geq h+1$. However, we also have $d(s_i,t_j) \leq h+2$, due to the path along the nodes $s_i, v, \ldots, v',t_j$ (c.f., Figure \ref{fig:lower_bound_basic}) that has length $h+2$.
If $x_{ij} = 1$, i.e., $\{u_i, t_j\} \in E$, then the path along the nodes $s_i, \ldots, u_i,t_j$ has length $h+1$. Note that all nodes in $U \setminus \{u_i,v'\}$ are at distance at least $h+2$ from $s_i$ (c.f., Figure \ref{fig:lower_bound_basic}), so every path via one of the nodes $U \setminus \{u_i,v'\}$ has distance at least $h+3$. In the case $x_{ij} = 0$, i.e., $\{u_i, t_j\} \notin E_\Gamma$, this is also true for the path via $u_i$ and the only path with distance $h+2$ is the one via $v'$.
\end{proof}
The idea to prove the next theorem is that if the nodes in $B$ learn the distance to the nodes in $t_1, \dots, t_k$, then their combined knowledge can be used to infer the state of the random string $X$ that is collectively known by the nodes in $A$.
\begin{theorem}
\label{thm:lower_bound_unweighted}
Even on \emph{unweighted graphs}, any randomized algorithm that computes exact ({stateless} or stateful) routing schemes or distance oracles in the \hybridpar{\infty}{\gamma} model with constant success probability takes \smash{$\Omega(n^{1/3}/\gamma^{1/3})$} rounds. This holds for labels of size up to \smash{$c \cdot n^{2/3} \cdot \gamma^{1/3}$} (for a fixed constant $c > 0$).
\end{theorem}
\begin{proof}
Consider an algorithm $\mathcal A$ that computes exact routing schemes or distance oracles for $\Gamma$ with constant probability at least $p$.
Assuming that the nodes in $B$ are given the distance labels for the nodes $\{t_1, \dots ,t_k\}$ in advance then after algorithm $\mathcal A$ has terminated, every node $s_i \in B$ either knows its distance $d(s_i,t_j)$ for every $t_j$ (distance oracles) or it knows if the next node on the corresponding shortest path is $v$ or not (routing schemes).
Then, by Lemma \ref{lem:source_target_distance_unweighted}, every node $s_i$ can infer for every $t_j$ if $x_{ij} = 0$ or $x_{ij} = 1$, which means that the nodes in $B$ collectively know the state of $X$. Note that this corresponds to the node communication problem of Definition \ref{def:node_comm_problem}, with the caveat that we assumed nodes in $B$ have advance knowledge of the labels $\lambda(t_1), \dots , \lambda(t_k)$.
The combination of these labels can contain information at most \smash{$y := \sum_{i =1}^k |\lambda(t_i)|$} bits, which we allow $A$ to communicate to $B$ ``for free''. By Corollary \ref{cor:lower_bound_general_amended}, algorithm $\mathcal A$ takes at least \smash{$\min\!\big(\frac{pH(X)-1-y}{n \cdot \gamma}, h\big)$} rounds.
The total number of nodes of $\Gamma$ is $n \in \Theta(h\cdot k)$, which leaves one degree of freedom for $k$ and $h$. We choose \smash{$k \in \Theta(n^{2/3}\gamma^{1/3})$} and \smash{$h \in \Theta(n^{1/3}/\gamma^{1/3})$}. This implies \smash{$H(X)\in \Theta(n^{4/3}\gamma^{2/3})$} by property (2) (see further above). For labels of size \smash{$c \cdot n^{2/3} \gamma^{1/3}$}, we have \smash{$y = c \cdot \Theta(n^{4/3}\gamma^{2/3})$}. We simply choose the constant $c > 0$ small enough so that \smash{$c n^{4/3}\gamma^{2/3} \leq \frac{pH(X)-1}{2}$} (i.e., $y$ will not change the lower bound asymptotically). Plugging all of the above into the lower bound of \smash{$\min\!\big(\frac{pH(X)-1-y}{n \cdot \gamma}, h\big)$} rounds, yields the desired bound of \smash{$\Omega(n^{1/3}/\gamma^{1/3})$} rounds.
\end{proof}
\section{Lower Bounds for Approximations}
\label{sec:lower_bounds_approx}
Our next construction relies on the existence of families of graphs that have high girth and maintain relatively high density.
We modify the basic construction above, essentially by replacing the upper part of $\Gamma$ with a random selection of edges from a graph of that family (and also making $\Gamma$ weighted). Besides high density we require the following.
\begin{definition}
\label{def:graph_family}
$\mathcal G_{k,\ell}$ is a graph family, s.t. for all $G \!=\! (A,E) \!\in\! \mathcal G_{k,\ell}$
\begin{enumerate}[(i)]
\item $|A| = 2k$
\item $G$ has (even) girth at least $\ell$
\item $G$ is balanced and bipartite
\end{enumerate}
\end{definition}
\subsection{Weighted Construction}
Removing an edge from $G \in \mathcal G_{k,\ell}$ incurs a large detour of at least $\ell\!-\!1$ hops between the endpoints of that edge, since otherwise there would be a cycle shorter than $\ell$ in $G$. This observation is often used to prove certain bounds for low stretch subgraphs\footnote{One prominent example is the lower bound on the size of low stretch spanners.} and can be exploited to introduce a stretch into our lower bound construction. We construct this formally as follows (however, first consulting Figure \ref{fig:lower_bound_enhanced} will presumably be more helpful to the reader).
\lng{\begin{figure}[h]
\centering
\includegraphics[scale=0.7, page = 2]{img/lower_bound.pdf}
\caption{\lng{\boldmath} Graph $\Gamma$ constructed around $G = (A,E) \in \mathcal G_{k,\ell}$ with $m := |E|$ edges (in red) and from the bit string $X = (x_e)_{e \in E} \in \{0,1\}^m$. An edge $e \in E$ is part of $\Gamma$ iff $x_e = 1$. For instance $\{u_2,t_3\} \in E$ but $x_{\{u_2,t_3\}} = 0$, so $\{u_2,t_3\} \notin E_\Gamma$. Edge weights $ \textcolor{blue}{w_0},\textcolor{red}{w_1}, \textcolor{orange}{w_2}$ are indicated with colored edges, all others have weight 1.}
\label{fig:lower_bound_enhanced}
\end{figure}}
\begin{definition}
\label{def:weighted_construction}
Let $G = (A,E) \in \mathcal G_{k,\ell}$ with $m := |E|$ edges and let $\{u_1, \dots, u_k\} \cup \{t_1, \dots, t_k\} = A$ be the bipartition of $G$. Graph $\Gamma = (V_\Gamma,E_\Gamma)$ (shown in Figure \ref{fig:lower_bound_enhanced}) has a similar structure as the unweighted construction (Def.\ \ref{def:unweighted_construction}), where the main difference is the way how the nodes $\{u_1, \dots, u_k\} \cup \{t_1, \dots, t_k\}$ are connected by edges in $\Gamma$.
Let $X = (x_{e})_{e\in E} \in \{0,1\}^{m}$ be a bit string of length $m = |E|$, i.e., each bit $x_e$ corresponds to an edge $e$ of $G$. For each $u_i,t_j$ we have $\{u_i,t_j\} \in E_\Gamma$, if and only if $\{u_i,t_j\} \in E$ \textit{and} $x_{\{u_i,t_j\}} = 1$. In a slight change from the previous construction, we make the path from $v$ to $v'$ of hop length $h\!-\!1$. The weights of $\Gamma$ are assigned as follows. Edges between the node $v'$ and some $t_j$ have weight $w_0$. Edges between nodes $u_i,t_j$ have weight $w_1$. Edges incident to some $s_i$ have weight $w_2$.
\end{definition}
We have the following properties.
\begin{enumerate}[(1)]
\item Let $e \!=\! \{u_i,t_j\} \!\in\! E$. $w_0,w_1,w_1$ can be chosen s.t.\ $d(s_i,t_j)$ is much longer for $x_e = 0$ than for $x_e = 1$ (c.f., Lemma \ref{lem:source_target_distance_weighted}).
\item For each edge $e \in E$ of $G$, set $x_{e} = 1$ i.i.d.\ with probability $\frac{1}{2}$, else $x_{e} = 0$. This maximizes the entropy $H(X) = \frac{m}{2}$.
\item For nodes $A$ of $G$ and $B := \{s_1, \dots, s_k\}$ we have $\hop(A,B) = h$.
\end{enumerate}
We analyze distances $d(s_i,t_j)$ between nodes $s_i,t_j$ with $e = \{u_i, t_j\} \in E$ for the two cases that $e$ is part of $\Gamma$ ($x_e = 1$), or not ($x_{e} = 0$). Conceptually, we choose weights $w_1 \ll w_0$, such that we can observe a large difference in $d(s_i,t_j)$ depending on $x_e$. \shrt{The proof is deferred to Appendix \ref{sec:lower_bounds_approx_proofs}.}
\begin{lemma}
\label{lem:source_target_distance_weighted}
Consider $\Gamma$ (Def.\ \ref{def:weighted_construction}), constructed from $G = (A,E) \in \mathcal G_{k,\ell}$ and $X$. Let $w_1 < w_0 < (\ell-1) w_1$. Let $e = \{u_i,t_j\} \in E$. Then we have:
\begin{enumerate}[(i)]
\item The shortest $s_i$-$t_j$-path contains $v$ if and only if $x_e = 0$.
\item If $x_{e}=1$ then $d(s_i,t_j) = w_2 + w_1 + h - 1$.\\ If $x_{e}=0$, then $d(s_i,t_j) = w_2 + w_0 + h - 1$.
\end{enumerate}
\end{lemma}
\lng{\begin{proof}
Let $U := \{u_1, \dots ,u_k,v\}$ be the vertex cut that separates any $s_i$ from any $t_j$. The shortest \textit{simple} $s_i$-$t_j$-path that crosses $U$ via $v$ has length $w_2 + w_0 + h - 1$ \textit{independently} from $x_e$ (simple implies that a path can not ``turn around'' and go via $u_i$).
Consider the shortest $s_i$-$t_j$-path that does \textit{not} contain $v$. In the case $x_e=1$, i.e., $e = \{u_i,t_j\}$ exists in $\Gamma$, this $s_i$-$t_j$-path is forced to cross $U$ via $u_i$ and then goes directly to $t_j$ via $e$, and thus has length $w_2 + w_1 + h - 1$.
Let us analyze the length of the $s_i$-$t_j$-path that does \textit{not} contain $v$ for the case $x_e=0$ (i.e., $e \notin E_\Gamma$). Let $G'$ be the subgraph that corresponds to $G$ after removing each edge $e' \in E$ with $x_{e'}=0$. Then that $s_i$-$t_j$-path has to traverse $G'$ to reach $t_j$.
The sub-path from $u_i$ to $t_j$ in $G'$ has to use at least $(\ell\!-\!1)$ edges, because otherwise $e = \{u_i,t_j\}$ would close a loop of less than $\ell$ edges in $G'$ (and thus also in $G$), contradicting the premise that $G$ has girth $\ell$. Thus, for $e \notin E_\Gamma$ any $s_i$-$t_j$-path that does not contain $v$ has length \textit{at least} $w_2+(\ell\!-\!1)w_1+h-1$.
We sum up the cases. If $x_e = 1$, then the $s_i$-$t_j$-path \textit{not} containing $v$ of length $w_2 + w_1 + h - 1$ is shorter than the one via $v$ of length $w_2 + w_0 + h - 1$, since $w_1 < w_0$. If $x_e = 0$, then the $s_i$-$t_j$-path via $v$ of length $w_2 + w_0 + h - 1$ is shorter than the one not containing $v$ of length at least $w_2 + (\ell-1)w_1 + h - 1$ due to $w_0 < (\ell\!-\!1) w_1$.
\end{proof}}
For the reduction from the node communication problem to our concrete routing and distance oracle problems, we start with a technical lemma that analyzes the running time of any algorithm $\mathcal A$ that solves the node communication problem in $\Gamma$ for the dedicated node sets $A,B$ and the random variable $X$ from which $\Gamma$ is constructed.
In particular, we express the lower bound from Theorem \ref{thm:lower_bound_node_communication} as function of $n := |V_\Gamma|$, the density of $G \in \mathcal G_{k,\ell}$ given by a parameter $\delta$ and the global communication capacity $\gamma$.
The lemma is the result of balancing a trade off between the distance $h = \hop(A,B)$ and the number of nodes $\Theta(k)$ of $G$ (which governs the entropy $H(X)=\Theta(k^{1+\delta})$ when the density of $G$ is fixed).\footnote{Naturally, the number of edges $\Theta\big(k^{1+\delta}\big)$ of $G \in \mathcal G_{k,\ell}$ is also bounded through $\delta < \frac{\ell-1}{2}$, c.f., Lemma \ref{lem:girth_edges_bound} in Appendix \ref{sec:girth_density}.} \shrt{The proof is deferred to Appendix \ref{sec:lower_bounds_approx_proofs}.}
\begin{lemma}
\label{lem:approx_lower_bound_groundwork}
Consider $\Gamma$ constructed from random variable $X$ and $G = (A,E) \in \mathcal G_{k,\ell}$ (Def.\ \ref{def:weighted_construction}) with \smash{$|E| = \Theta\big(k^{1+\delta}\big)$} edges (for $\delta > 0$ and $k$ of our choosing).
Let $\mathcal A$ be an algorithm that solves the node communication problem on $\Gamma$ with $X$, node sets $A,B \subset V_\Gamma$ and $h = hop(A,B)$ in the \hybridpar{\infty}{\gamma} model (all parameters as in Def.\ \ref{def:weighted_construction}). We can choose $k=\Theta\big(\frac{n}{h}\big)$ such that $\mathcal A$ takes \smash{$\Omega\big((\tfrac{n^\delta}{\gamma})^{\frac{1}{2+\delta}}\big)$} rounds. There exists a constant $c>0$ such that this holds even when we allow exchanging \smash{$c \cdot k^{1+\delta}$} bits from $A$ to $B$ for free.
\end{lemma}
\lng{\begin{proof}
As $\mathcal A$ solves the node communication problem (Def.\ \ref{def:node_comm_problem}) it takes at least \smash{$\min\!\big(\frac{pH(X)-1-y}{n \cdot \gamma}, h\big)$} rounds by Corollary \ref{cor:lower_bound_general_amended}, where $H(X) \in \Theta (k^{1+\delta})$ (see property (2), further above), $p$ is the constant success probability and $y$ describes the ``free'' communication.
The arguments of \smash{$\min\!\big(\frac{pH(X)-1-y}{n \cdot \gamma}, h\big)$} behave inversely, since increasing the distance $h = hop(A,B)$ leaves only \smash{$k \in \Theta\big(\frac{n}{h}\big)$} nodes for the graph $G$, which decreases $H(X) \in \Theta (k^{1+\delta})$. So in order to maximize the number of rounds given by the min function, we solve the equation \smash{$\frac{pH(X)-1-y}{n \cdot \gamma} = h$} subject to $k \cdot h = \Theta(n)$. Slashing constants and neglecting $y$ for now, this simplifies as follows
\[
\Theta \big( \tfrac{k^{1+\delta}}{n\cdot \gamma} \big) = \Theta (h), \quad \text{subject to} \quad k \cdot h = \Theta(n).
\]
The solution is \smash{$k = \Theta\big(n^{\frac{2}{2+\delta}}\cdot \gamma^{\frac{1}{2+\delta}}\big)$} and \smash{$h = \Theta\big(n^{\frac{\delta}{2+\delta}}/ \gamma^{\frac{1}{2+\delta}}\big)$} (which the willing reader may verify by inserting), resulting in a lower bound of \smash{$\Omega(n^{\frac{\delta}{2+\delta}} / \gamma^{\frac{1}{2+\delta}}) = \Omega\big((\tfrac{n^\delta}{\gamma})^{\frac{1}{2+\delta}}\big)$} rounds.
When we factor the free communication of $y = c \cdot k^{1+\delta}$ bits back into the equation \smash{$\frac{pH(X)-1-y}{n \cdot \gamma} = h$}, then there are no asymptotic changes to the outcome of our calculations as long as we choose the constant $c$ such that \smash{$c \cdot k^{1+\delta} \leq \frac{pH(X)-1}{2}$} (for all $n$ bigger than some constant $n_0$).
\end{proof}}
\subsection{Distance Oracles}
The first lower bound with stretch is for the distance oracle problem.
The idea is as follows. In case there is a direct edge $e = \{u_i, t_j\}$ (i.e., $x_e = 1$), the distance from $s_i$ to $t_j$ is almost $\ell\!-\!1$ times shorter, than if that is not the case. Hence, by learning an approximation of $d(s_i,t_j)$ with a stretch slightly lower than $\ell\!-\!1$, the node $s_i$ can conclude if $e$ exists or not, i.e., if $x_e = 1$ or $x_e = 0$. Hence the nodes $B = \{s_1, \dots, s_k\}$ collectively learn the random variable $X$ and thus solve the node communication problem.\footnote{Note that for the distance oracles lower bound, the path from $v$ to $v'$ could be removed from $\Gamma$, since $s_i$ learns $x_e = x_{\{s_i,t_j\}}$ from the distance estimate to $t_j$ and not from the next routing node. Since it does not hurt either, we keep $\Gamma$ uniform for all our lower bounds.}
This lemma is kept general such that we can later plug in any graph with a given density parameter $\delta$ and girth $\ell$. Note that the girth $\ell$ fundamentally limits the density parameter $\delta$; the correspondence between the two is roughly $\delta \in \smash{\ensuremath{O}}\big(\frac{1}{\ell}\big)$ as shown in Appendix \ref{sec:girth_density}. For a more intuitive understanding we suggest plugging in the complete bipartite graph $G_{k,k}$ which has girth $\ell=4$ and $\Theta(k^2)$ edges (i.e., density parameter $\delta=1$). \shrt{The proof is deferred to Appendix \ref{sec:lower_bounds_approx_proofs}.}
\begin{lemma}
\label{lem:lower_bound_distance_oracle}
Consider $\Gamma$ constructed from $G = (A,E) \in \mathcal G_{k,\ell}$ with $|E| = \Theta\big(k^{1+\delta}\big)$ edges for some $\delta > 0$.
Any algorithm that solves the \emph{distance oracle problem} on $\Gamma$ with stretch $\alpha_\ell = \ell\!-\!1\!-\!\varepsilon$ (for any const.\ $\varepsilon > 0$) and constant success probability in the \hybridpar{\infty}{\gamma} model takes \smash{$\Omega\big((\tfrac{n^\delta}{\gamma})^{\frac{1}{2+\delta}}\big)$} rounds, for labels up to size
\smash{$c \cdot n^{\frac{2\delta}{2+\delta}}\cdot \gamma^{\frac{\delta}{2+\delta}}$} (for a fixed const.\ $c > 0$).
\end{lemma}
\lng{\begin{proof}[Proof of Lemma \ref{lem:lower_bound_distance_oracle}]
Set $w_2 = 1$ (this weight is only needed later for stateful routing scheme lower bounds). To make the idea described above work, we have to make the unweighted edges of $\Gamma$ (the $h$-hop $s_i$-$u_i$-paths) insignificant for the approximation ratio by scaling the weights $w_1,w_0$ by a large factor $t$.
For that purpose we introduce the parameter $t>0$, which is specified later.
We choose $w_1 = t$ and $w_0 =(\ell\!-\!1\!-\!\frac{\varepsilon}{2})\cdot t$. In particular, this means $w_1 < w_0 < (\ell-1) w_1$ (the precondition of Lemma \ref{lem:source_target_distance_weighted}).
Let $e = \{u_i,t_j\} \in E$. Let $d_1 = d(s_i,t_j)$ for the case $x_e = 1$ and $d_0 = d(s_i,t_j)$ for the case $x_e = 0$. By Lemma \ref{lem:source_target_distance_weighted}, we know that $d_1 = t \!+\! h$ and \smash{$d_0 = (\ell\!-\!1\!-\!\frac{\varepsilon}{2})\cdot t + h$}.
Let $\mathcal A$ be an approximation algorithm for the distance oracle problem with stretch $\alpha_\ell = \ell\!-\!1\!-\!\varepsilon$.
For the cases $x_e = 1$ and $x_e = 0$, respectively, let $\tilde d_1$ and $\tilde d_0$ be distance approximations of $d(s_i,t_j)$ with stretch $\alpha_\ell$ that $s_i$ determines with its local table and the label of $t_j$ (which we computed with $\mathcal A$).
Note that our claims about $\tilde d_0, \tilde d_1$ will only depend on $x_e$ and are independent from $x_{e'}$ of other edges $e'\in E \setminus \{e\}$ (even though the \textit{exact} value of $\tilde d_0, \tilde d_1$ might depend on the $x_{e'}$).
The goal is to show
$\tilde d_1 < d \leq \tilde d_0$ for some constant $d > 0$, which enables $s_i$ to distinguish $x_e=1$ from $x_e=0$ from its approximation of $d(s_i,t_j)$.
We know that $\tilde d_1 \leq \alpha_\ell \cdot d_1 = (\ell\!-\!1\!-\!\varepsilon)(t \!+\! h)$. We also have $\tilde d_0 \geq d_0$ since our approximations are supposed to be one-sided.
Then
\begin{align*}
\tilde d_1 & \leq (\ell\!-\!1\!-\!\varepsilon)(t \!+\! h)\\
& = (\ell\!-\!1\!-\!\tfrac{\varepsilon}{2})\cdot t + h + (\ell\!-\!2\!-\!\varepsilon) \cdot h -\tfrac{\varepsilon}{2}\cdot t \tag*{\small\text{\textit{expand}}}\\
& < (\ell\!-\!1\!-\!\tfrac{\varepsilon}{2})\cdot t + h \tag*{\small\text{\textit{for large enough} $t$}}\\
& = d_0 \leq \tilde d_0.
\end{align*}
The strict inequality is obtained by choosing $t > \frac{2(\ell-2-\varepsilon)}{\varepsilon} \cdot h \in \Theta(\frac{\ell h}{\varepsilon})$. Note that edge weights remain polynomial in $n$ with this choice of $t$ since $\ell, h \in O(n)$ and $\varepsilon$ is constant.
So we get $\tilde d_1 < d_0 \leq \tilde d_0$, which implies the following. Let \smash{$\tilde d(s_i,t_j)$} be the distance estimate that $s_i$ actually outputs. Then it is $x_e=0$ if \smash{$\tilde d(s_i,t_j) < d_0$}, else it is $x_e=1$. Hence the nodes $B := \{s_1, \dots, s_k\}$ collectively learn $X$ and thus solve the node communication problem, which takes \smash{$\Omega\big((\tfrac{n^\delta}{\gamma})^{\frac{1}{2+\delta}}\big)$} rounds by Lemma \ref{lem:approx_lower_bound_groundwork}.
Two things remain to be mentioned. First, we can assume that each $s_i$ also has advance knowledge of $d_0$, as this does not carry any information about $X$ to the nodes $B = \{s_1, \dots, s_k\}$ and therefore does not make the node communication problem easier.
Second, the nodes $s_i$ can only produce the distance estimations \smash{$\tilde d(s_i,t_j)$} when they are also provided with the labels $\lambda(t_1), \dots, \lambda(t_k)$.
Here we assume that the nodes $s_i$ get these labels in advance as part of the contingent of ``free'' communication that we budgeted for in Lemma \ref{lem:approx_lower_bound_groundwork} and which does not make the node communication problem asymptotically easier.
In particular let $c_1>0$ be the constant from Lemma \ref{lem:approx_lower_bound_groundwork}, such that we are allowed \smash{$y = c_1 k^{1+\delta}$} bits of free communication in total. This leaves \smash{$c_1 k^{\delta}$} bits for each of the $k$ labels $\lambda(t_1), \dots, \lambda(t_k)$. In the proof of Lemma \ref{lem:approx_lower_bound_groundwork} we chose \smash{$k = c_2 \cdot n^{\frac{2}{2+\delta}}\cdot \gamma^{\frac{1}{2+\delta}}$} (for some constant $c_2 > 0$), resulting in a label size of at most \smash{$c_1 c_2 \cdot n^{\frac{2\delta}{2+\delta}}\cdot \gamma^{\frac{\delta}{2+\delta}}$}.
\end{proof}}
It remains to insert graphs $G \in \mathcal{G}_{k,\ell}$ into Lemma \ref{lem:lower_bound_distance_oracle}. We aim for graphs $G = (V,E) \in \mathcal{G}_{k,\ell}$ with $|E| \in \Theta\big(k^{1+\delta}\big)$ that maximize both girth $\ell$ and density parameter $\delta$. As outlined in Appendix \ref{sec:girth_density}, these are opposing objectives, and for even girth $\ell \geq 4$ we know that $\delta \in \smash{\ensuremath{O}}\big(\frac{2}{\ell-2}\big)$ (from applying Lemma \ref{lem:girth_edges_bound} on uneven girth $\ell-1$). Bipartite graphs of girth $\ell$ that reach $\delta \in \Theta\big(\frac{2}{\ell-2}\big)$ can be constructed for small girth $\ell$ (summarized in Lemma \ref{lem:low_even_girth_graph_density}) from which we obtain Theorem \ref{thm:lower_bound_distance_oracle_small_stretch}. But for higher girth we have to settle for $\delta$ below this threshold (see Lemma \ref{lem:high_even_girth_graph_density}), this is reflected in Theorem \ref{thm:lower_bound_distance_oracle_large_stretch}.
\begin{theorem}
\label{thm:lower_bound_distance_oracle_small_stretch}
Any algorithm that solves the \emph{distance oracle problem} in the \hybridpar{\infty}{\gamma} model with constant success probability with
\begin{itemize}
\item stretch $3\!-\!\varepsilon$ takes \smash{$\Omega\big((\tfrac{n}{\gamma})^{\frac{1}{3}}\big)$} rounds for label size \smash{$\leq c \cdot (n^2 \gamma)^{\frac{1}{3}}$}
\item stretch $5\!-\!\varepsilon$ takes \smash{$\Omega\big(\tfrac{n^{1/5}}{\gamma^{2/5}}\big)$}
rounds for label size \smash{$\leq c \cdot (n^2 \gamma)^{\frac{1}{5}}$}
\item stretch $7\!-\!\varepsilon$ takes
\smash{$\Omega\big(\tfrac{n^{1/7}}{\gamma^{3/7}}\big)$}
rounds for label size \smash{$\leq c \cdot (n^2 \gamma)^{\frac{1}{7}}$}
\item stretch $11\!-\!\varepsilon$ takes
\smash{$\Omega\big(\tfrac{n^{1/11}}{\gamma^{5/11}}\big)$}
rounds for label size \smash{$\leq c \cdot (n^2 \gamma)^{\frac{1}{11}}$}
\end{itemize}
for any const.\ $\varepsilon > 0$ and a fixed const.\ $c > 0$.
\end{theorem}
\begin{proof}
By Lemma \ref{lem:low_even_girth_graph_density} there are bipartite, balanced graphs with girth $\ell \in \{4,6,8,12\}$ and \smash{$\Theta(n^{1+\frac{2}{\ell-2}})$} edges, thus $\delta(\ell) = \frac{2}{\ell-2}$. In particular, we have \smash{$\delta(4) = 1, \delta(6) = \frac{1}{2}, \delta(8) = \frac{1}{3}, \delta(12) = \frac{1}{5}$}, which yield the desired results when plugged into Lemma \ref{lem:lower_bound_distance_oracle}.
\end{proof}
Applying Lemma \ref{lem:lower_bound_distance_oracle} on the densest known graphs with larger girth (see Lemma \ref{lem:high_even_girth_graph_density}), we obtain the subsequent theorem. The parametrization is complex due to a case distinction in Lemma \ref{lem:high_even_girth_graph_density}, the upshot is that for any constant stretch and sufficiently small $\gamma$ we get lower bounds polynomial in $n$ for label up to sizes that are also polynomial.
\begin{theorem}
\label{thm:lower_bound_distance_oracle_large_stretch}
Any algorithm that solves the \emph{distance oracle problem} in the \hybridpar{\infty}{\gamma} model with constant success probability with
\begin{itemize}
\item stretch $\ell \!-\! 1 \!-\!\varepsilon$ for $\ell \geq 14$ with $\ell \equiv 2 \!\!\mod 4$ takes
\smash{$\Omega\Big(n^{\tfrac{2}{3\ell - 8}}/\gamma^{\tfrac{3\ell -10}{6\ell - 6}}\Big)$} rounds for label size \smash{$\leq c \cdot n^{{4}/(3\ell - 8)} \cdot \gamma^{{2}/(3\ell - 8)}$}
\item stretch $\ell \!-\! 1 \!-\!\varepsilon$ for $\ell \geq 16$ with $\ell \equiv 0 \!\!\mod 4$ takes
\smash{$\Omega\Big(n^{\tfrac{2}{3\ell - 10}}/\gamma^{\tfrac{3\ell -12}{6\ell - 8}}\Big)$} rounds for label size \smash{$\leq c \cdot n^{{4}/(3\ell - 10)} \cdot \gamma^{{2}/(3\ell - 10)}$}
\end{itemize}
for any const.\ $\varepsilon > 0$ and a fixed const.\ $c > 0$.
\end{theorem}
\begin{proof}
By Lemma \ref{lem:high_even_girth_graph_density} there are bipartite, balanced graphs with even girth $\ell \geq 14$ that have (i) \smash{$\Theta(n^{1+\frac{4}{3\ell-10}})$} edges if $\ell \equiv 2 \!\!\mod 4$, or (ii) \smash{$\Theta(n^{1+\frac{4}{3\ell-12}})$} edges if $\ell \equiv 0 \!\!\mod 4$. Thus in case (i) we have \smash{$\delta(\ell) = \frac{4}{3\ell-10}$} and in case (ii) \smash{$\delta(\ell) = \frac{4}{3\ell-12}$}. Plugging $\delta(\ell)$ into Lemma \ref{lem:lower_bound_distance_oracle} gives the desired result.
\end{proof}
\subsection{Stateless Routing Scheme}
For lower bounds of routing schemes we exploit the observation that for an edge $e = \{s_i,t_j\} \in E$ the node $s_i$ learns about the existence of $e$ in $\Gamma$, i.e., whether $x_e = 0$ or $x_e = 1$, from the decision to send a packet with destination $t_j$ first to $v$ or not. More precisely, our goal is to show that $x_e = 0$ if and only if $v$ is the first routing neighbor for the packet with destination $t_j$.
However, we have to decrease the stretch of our lower bound in order that this works. The main obstacle is that the decision of $s_i$ to send a packet with target $t_j$ directly towards $u_i$ instead of node $v$ (left path) does not impact the distance of the routing path that one can still obtain by that much.
In particular, in the case of \textit{stateless} routing, a packet that travels from $s_i$ to $u_i$ and finds that the direct edge $\{u_i,t_j\}$ does \textit{not} exist, could still use any other edge $\{u_i,t_p\}$ and then the two edges $\{t_p, v'\}, \{v', t_j\}$ to get to $t_j$ (e.g., in Figure \ref{fig:lower_bound_enhanced} from $s_2$ to $t_3$). This would mislead $s_i$ as the first routing node was \textit{not} $v$, yet $x_e = 0$.
The target is to prohibit this and some other troublesome routing options by making them exceed the stretch guarantee. However, this gives us additional restrictions that dominate the resulting system of inequalities for higher girth $\ell$ of $G$, in particular we gain no improvement in the stretch for $\ell \geq 8$. \shrt{The proof is deferred to Appendix \ref{sec:lower_bounds_approx_proofs}.}
\begin{lemma}
\label{lem:lower_bound_stateless_routing}
Consider $\Gamma$ constructed from $G = (A,E) \in \mathcal G_{k,\ell}$ with $|E| = \Theta\big(k^{1+\delta}\big)$ edges for some $\delta > 0$. For any constant $\varepsilon > 0$ let \smash{$\alpha_\ell = \sqrt{\ell\!-\!1} \!-\! \varepsilon$} for $\ell \leq 6$ and \smash{$\alpha_\ell = 1 \!+\! \sqrt{2} \!-\! \varepsilon$} for $\ell \geq 8$.
Any algorithm that computes a \emph{stateless routing scheme} on $\Gamma$ with stretch $\alpha_\ell$ and constant success probability in the \hybridpar{\infty}{\gamma} model takes \smash{$\Omega\big((\tfrac{n^\delta}{\gamma})^{\frac{1}{2+\delta}}\big)$} rounds. This holds for labels of size
\smash{$c \cdot n^{\frac{2\delta}{2+\delta}} \gamma^{\frac{\delta}{2+\delta}}$} and fixed constant $c>0$.
\end{lemma}
\lng{\begin{proof}
We set $w_2 = 1$ (this weight only plays a role later \textit{stateful} routing lower bound) and $w_1 < w_0 < (\ell \!- \! 1)w_1$ (more precise values are determined further below). Let $s_i, t_j$ be a source-target pair of $\Gamma$ where $e := \{s_i,t_j\} \in E$ is part of $G$ (but not necessarily $\Gamma$). For the case $x_e = 1$ we define $d_1 := d(s_i,t_j) = w_1\!+\!h$ and $d_0 := d(s_i,t_j) = w_0\!+\!h$ for the case $x_e = 0$ (c.f., Lemma \ref{lem:source_target_distance_weighted}).
Let $\mathcal A$ be an algorithm solving the \textit{stateless} routing problem with the claimed approximation ratio (with const.\ probability). Let $P$ be the \textit{simple} $s_i$-$t_j$-path induced by the \textit{stateless} routing scheme computed by $\mathcal A$. Recall that $P$ must be simple as otherwise a packet that is oblivious to the prior routing decisions would be trapped in a loop. Our aim is that $s_i$ can decide whether $x_e =0$ or $x_e =1$ from the next routing node on $P$. That is, we want that $P$ contains $v$ if and only if $x_e = 0$. However, there are a few options to obtain the $s_i$-$t_j$-path $P$ that do, in certain cases, not abide by this requirement. We enumerate these in the following.
Assume $P$ does not contain $e$. Then option (1) is to go the left ``lane'' via $v$ and then use the direct blue edge $\{v', t_j\}$ to get to $t_j$, i.e., the path of length $d_0$. If $P$ goes from $s_i$ directly to $u_i$, then $P$ can be completed into a path to $t_j$ by (2) using only edges that are also part of $G$ (but not $e$), i.e., only red edges in Figure \ref{fig:lower_bound_enhanced}. Note that option (2) must include at least $\ell \! - \! 1$ red edges due to the girth $\ell$ of $G$. Option (3) is where $P$ goes to $u_i$ first uses any red edge $\{u_i,t_p\}$ ($p \neq j$) and then the two blue edges $\{t_p, v'\}, \{v', t_j\}$ to reach $t_j$. Note that for the case $x_e = 0$ all other $s_i$-$t_j$-paths are either strictly longer than option (1),(2),(3) or not simple.
The distances of the three paths (1),(2),(3) are at least (recall $w_2 = 1$):
\begin{align*}
d^{(1)} & := w_0 + h \;(= d_0)\\%\tag{1}\\
d^{(2)} & := (\ell \! - \! 1)w_1 + h\\%\tag{2}\\
d^{(3)} & := w_1 + 2w_0 +
\end{align*}
To enforce $v \notin P$ in case $x_e = 1$, we require that path (1) is unfeasible, i.e., exceeds the allowed distance $\alpha_\ell d_1$. Furthermore, to enforce $v \in P$ in case $x_e = 0$, we require that the paths (2) and (3) exceed the allowed distance $\alpha_\ell d_0$. From this we obtain the following conditions.
\begin{align*}
\alpha_{\ell} \cdot d_1 & \stackrel{!}{<} d^{(1)} = w_0 + h\tag{1}\\
\alpha_{\ell} \cdot d_0 & \stackrel{!}{<} d^{(2)} = (\ell \! - \! 1)w_1 + h \tag{2} \\
\alpha_{\ell} \cdot d_0 & \stackrel{!}{<} d^{(3)} = w_1 + 2w_0 + h \tag{3}
\end{align*}
The remaining part of the proof is merely technical, we need to maximize $\alpha_\ell$ under the above constraints. (Afterwards, the rest follows from having solved the node communication problem as in the proof of Lemma \ref{lem:lower_bound_distance_oracle}). Set $w_1 := t < w_0$ for some yet unspecified variable $t > 0$. Further, we set $\alpha := \frac{w_0}{t} - \varepsilon$ and show that this fulfills Equation (1):
\[
\alpha_{\ell} \cdot d_1 = \big(\tfrac{w_0}{t} - \varepsilon\big)(t+h) = w_0 + \tfrac{h w_0}{t} - \varepsilon(t+h) < w_0 + h.
\]
For Equation (2) we obtain:
\begin{align*}
& \alpha_{\ell} \cdot d_0 = \big(\tfrac{w_0}{t} \!-\! \varepsilon\big)(w_0\!+\!h) < (\ell \! - \! 1)t + h\\
\Longleftrightarrow \quad & \tfrac{w_0^2}{t} + \tfrac{w_0}{t}(h-\varepsilon t)-\varepsilon h - h < (\ell \! - \! 1)t\\
\Longleftrightarrow \quad & w_0^2 + \underbrace{w_0(h-\varepsilon t)}_{<0, \text{ for } t > h/\varepsilon} \underbrace{-\varepsilon ht - ht}_{<0} < (\ell \! - \! 1)t^2\\
{\Longleftarrow} \quad & w_0^2 \leq (\ell \! - \! 1)t^2\\
{\Longleftrightarrow} \quad & w_0 \leq t \cdot \sqrt{\ell \! - \! 1}.
\end{align*}
Now let us turn to Equation (3)
\begin{align*}
& \alpha_{\ell} \cdot d_0 = \big(\tfrac{w_0}{t} \!-\! \varepsilon\big)(w_0\!+\!h) < t + 2w_0 + h\\
\Longleftrightarrow \quad & \tfrac{w_0^2}{t} + \tfrac{w_0}{t}(h-\varepsilon t)-\varepsilon h < t + 2w_0 + h\\
\Longleftrightarrow \quad & w_0^2 + w_0(\underbrace{h-\varepsilon t}_{<0}-2t) \underbrace{-\varepsilon ht - ht}_{<0} - t^2 < 0\\
\Longleftarrow \quad & w_0^2 -2tw_0 - t^2\leq 0 \\
\Longleftarrow \quad & w_0 \leq t \cdot (1\!+\!\sqrt 2).
\end{align*}
Therefore, Equations (2),(3) are fulfilled if $w_0 \leq t \cdot \sqrt{\ell \! - \! 1}$ and $w_0 \leq t \cdot (1\!+\!\sqrt 2)$ (and \smash{$t > \frac{h}{\varepsilon}$}, which can be chosen freely). This implies that the stretch $\alpha_\ell = \frac{w_0}{t} - \varepsilon$ must satisfy $\alpha_\ell\leq \sqrt{\ell \! - \! 1} - \varepsilon$ and $\alpha_\ell \leq 1\!+\!\sqrt 2 \!-\! \varepsilon$, whereas the former condition for $\alpha_\ell$ dominates the latter if and only if $\ell \leq 8$.
With this choice of $w_0, \alpha_\ell$, the first node that a packet from $s_i$ with destination $t_j$ is routed to is the node $v$ if and only if $x_e = 0$. Hence, the nodes in $B$ collectively learn $X$ from the information provided by algorithm $\mathcal{A}$ and the labels of the nodes $t_j$, which therefore solves the node communication problem. The runtime and size of the labels then follows the same way as in the proof of Lemma \ref{lem:lower_bound_distance_oracle}.
\end{proof} }
We plug graphs $G \in \mathcal{G}_{k,\ell}$ into Lemma \ref{lem:lower_bound_stateless_routing}. Since in this case we get no improvements in the stretch for girth $\ell\geq 8$ it suffices to apply Lemma \ref{lem:low_even_girth_graph_density}. Beside the changed values for the stretch, the proof is the same as that of Theorem \ref{thm:lower_bound_distance_oracle_small_stretch}, we just have to use the corresponding values of $\delta$ from Lemma \ref{lem:low_even_girth_graph_density} for $\ell = 4,6,8$.
\begin{theorem}
\label{thm:lower_bound_stateless_routing}
Any algorithm that solves the \emph{stateless routing problem} in the \hybridpar{\infty}{\gamma} model with constant success probability with
\begin{itemize}
\item stretch $\sqrt{3}\!-\!\varepsilon$ takes \smash{$\Omega\big((\tfrac{n}{\gamma})^{\frac{1}{3}}\big)$} rounds for label size \smash{$\leq c \cdot (n^2 \gamma)^{\frac{1}{3}}$}
\item stretch $\sqrt{5}\!-\!\varepsilon$ takes \smash{$\Omega\big(\tfrac{n^{1/5}}{\gamma^{2/5}}\big)$}
rounds for label size \smash{$\leq c \cdot (n^2 \gamma)^{\frac{1}{5}}$}
\item stretch $1\!+\!\sqrt{2}\!-\!\varepsilon$ takes
\smash{$\Omega\big(\tfrac{n^{1/7}}{\gamma^{3/7}}\big)$}
rounds for label size \smash{$\leq c \cdot (n^2 \gamma)^{\frac{1}{7}}$}
\end{itemize}
for any const.\ $\varepsilon > 0$ and a fixed const.\ $c > 0$.
\end{theorem}
\subsection{Stateful Routing Scheme}
We obtain similar lower bound results for the approximate \textit{stateful} routing problem, however with even smaller stretch. Recall that in the stateful version the problem is relaxed in the sense that a routing decision may also depend on the information a packet has gathered along the previous routing path.
Since this permits loops in the routing path, it opens up additional options for routing a packet from $s_i$ to $t_j$ that we need to prohibit. For instance, a packet could first travel to $u_i$, then check if the direct edge $\{u_i,t_j\}$ is present, and if not travel back to $s_i$ to take the shorter route via $v$ instead. Note that this path has the same number of red and blue edges as the shortest path directly to $v$ and then to $t_j$ (c.f. Figure \ref{fig:lower_bound_enhanced}).
The trick is to make the weight $w_2$ (orange edges) of all incident edges of $s_i$ more expensive, such that revisiting $s_i$ breaks the approximation guarantee. This again forces the source $s_i$ to make the correct decision with the first node it routes the packet to, which renders the ability to travel in loops and learn along the way useless. \shrt{The proof of the following lemma is in Appendix \ref{sec:lower_bounds_approx_proofs}.}
\begin{lemma}
\label{lem:lower_bound_stateful_routing}
Consider $\Gamma$ constructed from $G = (A,E) \in \mathcal G_{k,\ell}$ with $|E| = \Theta\big(k^{1+\delta}\big)$ edges for some $\delta > 0$. For any constant $\varepsilon > 0$ let \smash{$\alpha_4 = \sqrt 2 - \varepsilon$}, \smash{$\alpha_6 = \tfrac{5}{3} - \varepsilon$}, \smash{$\alpha_8 = \tfrac{7}{4} - \varepsilon$}. For $\ell \geq 10$ let \smash{$\alpha_\ell = \frac{3+\sqrt{17}}{4} - \varepsilon \approx 1.78$}.
Any algorithm that computes a \emph{stateful routing scheme} on $\Gamma$ with stretch $\alpha_\ell$ and constant success probability in the \hybridpar{\infty}{\gamma} model takes \smash{$\Omega\big((\tfrac{n^\delta}{\gamma})^{\frac{1}{2+\delta}}\big)$} rounds. This holds for labels of size
\smash{$c \!\cdot\! n^{\frac{2\delta}{2+\delta}} \!\cdot\! \gamma^{\frac{\delta}{2+\delta}}$} and fixed constant $c>0$.
\end{lemma}
\lng{\begin{proof}
The beginning of the proof is similar to the one of Lemma \ref{lem:lower_bound_stateless_routing}.
Consider algorithm $\mathcal A$ that solves the \textit{stateful} routing problem with the claimed approximation ratio and constant probability. Let $s_i, t_j \in V_\Gamma$ with $e := \{s_i,t_j\} \in E$ and define $d_1 := d(s_i,t_j) = w_1\!+\!w_2\!+\!h\!-\!1$ and $d_0 := d(s_i,t_j) = w_0\!+\!w_2\!+\!h\!-\!1$ for the cases $x_e = 1$, $x_e = 0$ respectively (we will ensure $w_1 < w_0 < (\ell\!-\!1)w_1$ so that Lemma \ref{lem:source_target_distance_weighted} applies).
Let $P$ be the $s_i$-$t_j$-path induced by the \textit{stateful} routing scheme computed by $\mathcal A$. Similar to before, our goal is to show that the first node on $P$ is $v$ if and only if $x_e = 0$, so that $s_i$ learns $x_e$ from its routing decision. As before, we aim to prohibit all routing options (i.e., make them break the stretch guarantee) that do not abide by this requirement. We will extend our list of options for $P$ which are in some cases undesirable from the previous proof.
We have the loop-less routing options (1),(2),(3) from before (c.f., proof of Lemma \ref{lem:lower_bound_stateless_routing}), whose lengths change by an additive term $w_2-1$ due to the introduction of weight $w_2$ (orange edges in Figure \ref{fig:lower_bound_enhanced}). Note that any path (possibly with loops) that contains $s_i$ just once is at least as long as one of the options (1)-(3) (in their respective cases) so prohibiting the latter prohibits the former.
The problem that arises is from visiting $s_i$ at least twice is that it can mislead $s_i$ by first going to $v$ even though $x_e = 1$ or vice versa.
Assume the case that $e$ is not in $\Gamma$ ($x_e = 0$), then we need to prohibit routing option (4) that visits the first node on the path towards $u_i$, returns to $s_i$, travels directly to $v'$ and uses the blue edge to $t_j$.
Conversely, assuming the case that $e$ is present in $\Gamma$ ($x_e = 1$), $P$ we need to prohibit option (5), which visits $v$ first but then returns to $s_i$, travels to $u_i$ and uses $e$ to reach $t_j$. Note that all paths that contain $s_i$ at least twice, are at least as long as one of the paths (4),(5) (in their respective cases). The described routing paths (1)-(5) have the following respective lengths:
\begin{align*}
d^{(1)} & := w_0 + w_2 + h -1\\
d^{(2)} & := (\ell \! - \! 1)w_1 + w_2 + h -1\\
d^{(3)} & := 2w_0 + w_1 + w_2 + h -1\\
d^{(4)} & := w_0 + 3w_2 + h -1\\
d^{(5)} & := w_1 + 3w_2 + h -1
\end{align*}
We obtain inequalities similar as before. For the reasoning of inequalities (1)-(3) consider the proof of Lemma \ref{lem:lower_bound_stateless_routing}. Observe that if $P$ would follow path options (4),(5) it could make $s_i$ believe $x_e = 1$ or $x_e = 0$ respectively, even though the opposite is true. We require that path options (4) and (5) exceed the stretch $\alpha_\ell$ in the cases in which they are undesirable, that is, $x_e = 0$ and $x_e = 1$, respectively.
\begin{align*}
\alpha_{\ell} \cdot d_1 & \stackrel{!}{<} d^{(1)} = w_0 + w_2 + h -1\tag{1}\\
\alpha_{\ell} \cdot d_0 & \stackrel{!}{<} d^{(2)} = (\ell \! - \! 1)w_1 + w_2 + h -1 \tag{2} \\
\alpha_{\ell} \cdot d_0 & \stackrel{!}{<} d^{(3)} = 2w_0 + w_1 + w_2 + h -1 \tag{3} \\
\alpha_{\ell} \cdot d_0 & \stackrel{!}{<} d^{(4)} = w_0 + 3w_2 + h -1 \tag{4} \\
\alpha_{\ell} \cdot d_1 & \stackrel{!}{<} d^{(5)} = w_1 + 3w_2 + h -1 \tag{5}
\end{align*}
This leaves us with an optimization problem where $\alpha_{\ell}$ is to be maximized in the domain $1 \leq w_1 \leq w_0,w_2$, subject to conditions (1)-(5). This is admittedly a bit tedious, in particular since the optimization problem has a different result for girth $\ell \in \{4,6,8,10\}$ (we gain no improvement for larger $\ell$). We do not reproduce all necessary calculations of the optimization in detail, instead we give some explanations to make our results (given in Table \ref{tbl:lower_bounds_stateful_opt_values}) reproducible.
One obstacle is the presence of edges with weight 1 in $\Gamma$ forming the path of length $h-1$, which is not yet fixed and therefore prohibits solving the optimization problem directly. Our strategy is to first relax our problem to a simplified one with zero-weight edges. That is, we set all edges, except those with weight $w_0,w_1,w_2$, to zero and adapt the distances $d_0, d_1, d^{(1)}, \dots, d^{(5)}$ accordingly (essentially slashing $h\!-\!1$ in those distances). We also set $w_1 = 1$. This eliminates $w_1,h$ from conditions (1)-(5) and the resulting maximization problem(s) can be solved directly.
From the results of the simplified optimization problems (for girths $\ell \in \{4,6,8,10\}$), we obtain almost optimal solutions for the general optimization problem with non-zero weights as follows. We multiply the values of $w_0,w_1,w_2$ with a (sufficiently large) parameter $t \geq 1$ and subtract an $\varepsilon>0$ from $\alpha_\ell$ to accommodate a (small) slack that is required in the general inequalities. The value of $t$ depends on the slack $\varepsilon$ in $\alpha_\ell$ that is given but is generally polynomial in $n$ as long as $\varepsilon$ is constant.
The results obtained using this procedure are given in Table \ref{tbl:lower_bounds_stateful_opt_values}.
\begin{table}
\centering
\begin{tabular}{p{5mm}>{\centering\arraybackslash}p{14mm}>{\centering\arraybackslash}p{14mm}>{\centering\arraybackslash}p{6mm}>{\centering\arraybackslash}p{14mm}}
\toprule
$\ell$ & $\alpha_\ell$ & $w_0$ & $w_1$ & $w_2$\\
\midrule
4 & $\sqrt 2 - \varepsilon$ & $2t\sqrt 2 \!-\!t$ & $t$ & $t$\\[1.5mm]
6 & $\frac{5}{3} - \varepsilon$ & $\frac{5t}{2}$ & $t$ & $\frac{5t}{4}$ \\[1.5mm]
8 & $\tfrac{7}{4} - \varepsilon$ & $\frac{35t}{11}$ & $t$ & $\frac{21t}{11}$ \\[1.5mm]
10 & $\frac{3+\sqrt{17}}{4} - \varepsilon$ & $\frac{3+\sqrt{17}}{2}t$ & $t$ & $\frac{5+\sqrt{17}}{4}t$\\
\bottomrule
\end{tabular}
\caption{\lng{\boldmath} Results of maximizing $\alpha_\ell$, s.t., conditions (1)-(5) for $\ell \in \{4,6,8,10\}$ (and scaling with $t$ and introducing slack $\varepsilon$).}
\label{tbl:lower_bounds_stateful_opt_values}
\end{table}
The most relevant parameter in Table \ref{tbl:lower_bounds_stateful_opt_values} are certainly the values for $\alpha_\ell$ for $\ell \in \{4,6,8,10\}$, whereas we also provide the weights $w_0,w_1,w_2$ for reproducibility. Showing that the given parameters do in fact satisfy conditions (1)-(5) for any constant $\varepsilon > 0$ and some choice of $t$, is a repetitive task. We show this once for $\ell=10$ and condition (1) (which is almost tight in this case), the other cases can be repeated analogously.
\begin{align*}
\alpha_{\ell} \cdot d_1 & = \big(\tfrac{3+\sqrt{17}}{4} \big)d_1 - \varepsilon d_1\\
& = \big(\tfrac{3+\sqrt{17}}{4} \big)(w_1 + w_2 + h -1) - \varepsilon d_1\\
& = \big(\tfrac{3+\sqrt{17}}{4} \big)(w_1 + w_2) + h \!-\!1 + \smash{\underbrace{\big(\tfrac{\sqrt{17}-1}{4} \big)(h\!-\!1) - \varepsilon d_1 }_{<0,\text{ for large }t}}\\
& < \big(\tfrac{3+\sqrt{17}}{4} \big)\big(\tfrac{9+\sqrt{17}}{4}\cdot t\big) + h \!-\!1\\
& = \big(\tfrac{11+3\sqrt{17}}{4}\big) \cdot t + h \!-\!1\\
& = \big(\tfrac{3+\sqrt{17}}{2} + \tfrac{5+\sqrt{17}}{4}\big) \cdot t + h \!-\!1\\
& = w_0 + w_2 + h \!-\!1 = \smash{d^{(1)}}.
\end{align*}
Note that, since $d_1$ grows linear in $t$ the inequality in the fourth line holds for \smash{$t > \big(\tfrac{\sqrt{17}-1}{4\varepsilon} \big)(h\!-\!1) \in \smash{\ensuremath{O}}(n)$}.
Finally, by enforcing conditions (1)-(5) with the appropriate parameters given in Table \ref{tbl:lower_bounds_stateful_opt_values}, we can guarantee that the first node that a packet from $s_i$ to $t_j$ is first routed to $v$ if and only if $x_e = 0$. From this the nodes in $B$ collectively learn $X = (x_e)_{e \in E}$ thus solving the node communication problem. The runtime and size of the labels follows as in the proof of Lemma \ref{lem:lower_bound_distance_oracle}.
\end{proof}}
Again, our actual lower bounds come from inserting graphs $G \in \mathcal{G}_{k,\ell}$ into Lemma \ref{lem:lower_bound_stateless_routing}. Our best stretch is obtained for $\ell = 10$, but unfortunately we have a gap for that value in Lemma \ref{lem:low_even_girth_graph_density}. Therefore, for the largest stretch value we use a graph $G \in \mathcal{G}_{k,12} \subseteq \mathcal{G}_{k,10}$, which has the drawback of not being as dense. Aside from different stretch values, the proof follows that of Theorem \ref{thm:lower_bound_distance_oracle_small_stretch}, by inserting the values of $\delta$ from Lemma \ref{lem:low_even_girth_graph_density} for $\ell = 4,6,8,12$.
\begin{theorem}
\label{thm:lower_bound_stateful_routing}
Any algorithm that solves the \emph{stateful routing problem} in the \hybridpar{\infty}{\gamma} model with constant success probability with
\begin{itemize}
\item stretch $\sqrt{2}\!-\!\varepsilon$ takes \smash{$\Omega\big((\tfrac{n}{\gamma})^{\frac{1}{3}}\big)$} rounds for label size \smash{$\leq c \cdot (n^2 \gamma)^{\frac{1}{3}}$}
\item stretch $\frac{5}{3}\!-\!\varepsilon$ takes \smash{$\Omega\big(\tfrac{n^{1/5}}{\gamma^{2/5}}\big)$}
rounds for label size \smash{$\leq c \cdot (n^2 \gamma)^{\frac{1}{5}}$}
\item stretch $\frac{7}{4}\!-\!\varepsilon$ takes
\smash{$\Omega\big(\tfrac{n^{1/7}}{\gamma^{3/7}}\big)$}
rounds for label size \smash{$\leq c \cdot (n^2 \gamma)^{\frac{1}{7}}$}
\item stretch \smash{$\frac{3+\sqrt{17}}{4}\!-\!\varepsilon$} takes
\smash{$\Omega\big(\tfrac{n^{1/11}}{\gamma^{5/11}}\big)$}
rounds for label size \smash{$\leq c \cdot (n^2 \gamma)^{\frac{1}{11}}$}
\end{itemize}
for any const.\ $\varepsilon > 0$ and a fixed const.\ $c > 0$.
\end{theorem}
\shrt{\newpage}
\section{Deferred Proof of Section \ref{sec:upper_bounds}}
\section{Deferred Proof of Section \ref{sec:node_communication_problem}}
\label{sec:node_communication_problem_proofs}
\begin{proof}[Proof of Lemma \ref{lem:reduce_comm_problems}]
We will derive a protocol $\mathcal P$ that uses (i.e., simulates) algorithm $\mathcal A$ in order to solve the two-party communication problem. First we make a few assumptions about the initial knowledge of both parties in particular about the graph $G$ from the node communication problem, you can think of this information as hard coded into the instructions of $\mathcal P$. The important observation is that none of these assumptions will give Bob any knowledge about $X$.
Specifically, we assume that Alice is given complete knowledge of the topology $G$ and inputs of all nodes in $G$ (in particular the state of $X$ and the source codes of all nodes specified by $\mathcal{A}$). Bob is given the same for the subgraph induced by $V \setminus A$, which means that the state of $X$ remains unknown to Bob (c.f., Def.\ \ref{def:node_comm_problem}). To accommodate randomization of $\mathcal A$, both are given the same copy of a string of random bits (determined randomly and independently from $X$) that is sufficiently long to cover all ``coin flips'' used by any node in the execution of $\mathcal A$.
Alice and Bob simulate the following nodes during the simulated execution of algorithm $\mathcal A$. For $i \in [h\!-\!1]$ let $V_i := \{v \in V \mid \hop(v,A) \leq i \}$ be the set of nodes at hop distance at most $i$ from $A$. Note that $A \subseteq V_i$ for all $i$. In round 0 of algorithm $\mathcal A$, Alice simulates all nodes in $A$ and Bob simulates all nodes in $V \setminus A$. However, in subsequent rounds $i > 0$, Alice simulates the larger set $A \cup V_i$ and Bob simulates the smaller set $B \cup V \setminus V_i$.
Figuratively speaking, in round $i$ Bob will relinquish control of all nodes that are at hop distance $i$ from set $A$, to Alice. This means, in each round, every node is simulated \textit{either} by Alice \textit{or} by Bob.
We show that each party can simulate their nodes correctly with an induction on $i$. Initially ($i=0$), this is true as each party gets the necessary inputs of the nodes they simulate. Say we are at the beginning of round $i > 0$ and the simulation was correct so far. It suffices to show that both parties obtain all messages that are sent (in the \hybridpar{\infty}{\gamma} model) to the nodes they currently simulate.
The communication taking place during execution of $\mathcal A$ in the \hybridpar{\infty}{\gamma} model is simulated as follows. If two nodes that are currently simulated by the \emph{same} party, say Alice, want to communicate, then this can be taken care as part of the internal simulation by Alice. If a node that is currently simulated (w.l.o.g.) by Bob wants to send a message over the \emph{global} network to some node that Alice simulates, then Bob sends that message directly to Alice as part of $\mathcal P$, and that message becomes part of the transcript.
Now consider the case where a \textit{local} message is exchanged between some node $u$ simulated by Alice and some node $v$ simulated by Bob. Then in the subsequent round Alice will \textit{always} take control of $v$, as part of our simulation regime. Thus Alice can continue simulating $v$ correctly as she has all information to simulate all nodes all the time anyway (Alice is initially given all inputs of all nodes). Therefore it is \textit{not} required to exchange {any} \textit{local} messages across parties for the correct simulation.
After $T$ simulated rounds, Bob, who simulates the set $B$ until the very end (as $T < h$), can derive the state of $X$ from the local information of $B$ with success probability at least $p$ (same as algorithm $\mathcal A$). Hence, using the global messages that were exchanged between Alice and Bob during the simulation of algorithm $\mathcal A$ we obtain a protocol $\mathcal P$ that solves the two party communication problem with probability $p$. Since total global communication is restricted by $n \cdot \gamma$ bits per round in the \hybridpar{\infty}{\gamma} model, Alice sends Bob at most $T \cdot n \cdot \gamma$ bits during the whole simulation.
\end{proof}
\begin{proof}[Proof of Corollary \ref{cor:lower_bound_general_amended}]
As above, the node communication problem reduces to the communication problem between Alice and Bob, where Alice is now allowed to send $y$ bits to Bob in advance. Note that this still requires Alice to send $p \cdot H(X)-1-y$ remaining bits in expectation, as per Lemma \ref{lem:lower_bound_two_party}.
The same contradiction as in Theorem \ref{thm:lower_bound_node_communication} can be derived as follows. Fewer rounds than stated in this lemma would imply that the transcript of global messages from Alice to Bob, would be shorter than $p \cdot H(X)-1-y$ bits (essentially by substituting $p \cdot H(X)-1$ for $p \cdot H(X)-1-y$ in the previous proof). Thus the transcript would be less than $p \cdot H(X)-1$ bits even when we add the $y$ ``free'' bits to the transcript.
\end{proof}
\section{Deferred Proofs of Section \ref{sec:lower_bounds_approx}}
\label{sec:lower_bounds_approx_proofs}
\begin{proof}[Proof of Lemma \ref{lem:source_target_distance_weighted}]
Let $U := \{u_1, \dots ,u_k,v\}$ be the vertex cut that separates any $s_i$ from any $t_j$. The shortest \textit{simple} $s_i$-$t_j$-path that crosses $U$ via $v$ has length $w_2 + w_0 + h - 1$ \textit{independently} from $x_e$ (simple implies that a path can not ``turn around'' and go via $u_i$).
Consider the shortest $s_i$-$t_j$-path that does \textit{not} contain $v$. In the case $x_e=1$, i.e., $e = \{u_i,t_j\}$ exists in $\Gamma$, this $s_i$-$t_j$-path is forced to cross $U$ via $u_i$ and then goes directly to $t_j$ via $e$, and thus has length $w_2 + w_1 + h - 1$.
Let us analyze the length of the $s_i$-$t_j$-path that does \textit{not} contain $v$ for the case $x_e=0$ (i.e., $e \notin E_\Gamma$). Let $G'$ be the subgraph that corresponds to $G$ after removing each edge $e' \in E$ with $x_{e'}=0$. Then that $s_i$-$t_j$-path has to traverse $G'$ to reach $t_j$.
The sub-path from $u_i$ to $t_j$ in $G'$ has to use at least $(\ell\!-\!1)$ edges, because otherwise $e = \{u_i,t_j\}$ would close a loop of less than $\ell$ edges in $G'$ (and thus also in $G$), contradicting the premise that $G$ has girth $\ell$. Thus, for $e \notin E_\Gamma$ any $s_i$-$t_j$-path that does not contain $v$ has length \textit{at least} $w_2+(\ell\!-\!1)w_1+h-1$.
We sum up the cases. If $x_e = 1$, then the $s_i$-$t_j$-path \textit{not} containing $v$ of length $w_2 + w_1 + h - 1$ is shorter than the one via $v$ of length $w_2 + w_0 + h - 1$, since $w_1 < w_0$. If $x_e = 0$, then the $s_i$-$t_j$-path via $v$ of length $w_2 + w_0 + h - 1$ is shorter than the one not containing $v$ of length at least $w_2 + (\ell-1)w_1 + h - 1$ due to $w_0 < (\ell\!-\!1) w_1$.
\end{proof}
\begin{proof}[Proof of Lemma \ref{lem:approx_lower_bound_groundwork}]
As $\mathcal A$ solves the node communication problem (Def.\ \ref{def:node_comm_problem}) it takes at least \smash{$\min\!\big(\frac{pH(X)-1-y}{n \cdot \gamma}, h\big)$} rounds by Corollary \ref{cor:lower_bound_general_amended}, where $H(X) \in \Theta (k^{1+\delta})$ (see property (2), further above), $p$ is the constant success probability and $y$ describes the ``free'' communication.
The arguments of \smash{$\min\!\big(\frac{pH(X)-1-y}{n \cdot \gamma}, h\big)$} behave inversely, since increasing the distance $h = hop(A,B)$ leaves only \smash{$k \in \Theta\big(\frac{n}{h}\big)$} nodes for the graph $G$, which decreases $H(X) \in \Theta (k^{1+\delta})$. So in order to maximize the number of rounds given by the min function, we solve the equation \smash{$\frac{pH(X)-1-y}{n \cdot \gamma} = h$} subject to $k \cdot h = \Theta(n)$. Slashing constants and neglecting $y$ for now, this simplifies as follows
\[
\Theta \big( \tfrac{k^{1+\delta}}{n\cdot \gamma} \big) = \Theta (h), \quad \text{subject to} \quad k \cdot h = \Theta(n).
\]
The solution is \smash{$k = \Theta\big(n^{\frac{2}{2+\delta}}\cdot \gamma^{\frac{1}{2+\delta}}\big)$} and \smash{$h = \Theta\big(n^{\frac{\delta}{2+\delta}}/ \gamma^{\frac{1}{2+\delta}}\big)$} (which the willing reader may verify by inserting), resulting in a lower bound of \smash{$\Omega(n^{\frac{\delta}{2+\delta}} / \gamma^{\frac{1}{2+\delta}}) = \Omega\big((\tfrac{n^\delta}{\gamma})^{\frac{1}{2+\delta}}\big)$} rounds.
When we factor the free communication of $y = c \cdot k^{1+\delta}$ bits back into the equation \smash{$\frac{pH(X)-1-y}{n \cdot \gamma} = h$}, then there are no asymptotic changes to the outcome of our calculations as long as we choose the constant $c$ such that \smash{$c \cdot k^{1+\delta} \leq \frac{pH(X)-1}{2}$} (for all $n$ bigger than some constant $n_0$).
\end{proof}
\begin{proof}[Proof of Lemma \ref{lem:lower_bound_distance_oracle}]
Set $w_2 = 1$ (this weight is only needed later for stateful routing scheme lower bounds). To make the idea described above work, we have to make the unweighted edges of $\Gamma$ (the $h$-hop $s_i$-$u_i$-paths) insignificant for the approximation ratio by scaling the weights $w_1,w_0$ by a large factor $t$.
For that purpose we introduce the parameter $t>0$, which is specified later.
We choose $w_1 = t$ and $w_0 =(\ell\!-\!1\!-\!\frac{\varepsilon}{2})\cdot t$. In particular, this means $w_1 < w_0 < (\ell-1) w_1$ (the precondition of Lemma \ref{lem:source_target_distance_weighted}).
Let $e = \{u_i,t_j\} \in E$. Let $d_1 = d(s_i,t_j)$ for the case $x_e = 1$ and $d_0 = d(s_i,t_j)$ for the case $x_e = 0$. By Lemma \ref{lem:source_target_distance_weighted}, we know that $d_1 = t \!+\! h$ and \smash{$d_0 = (\ell\!-\!1\!-\!\frac{\varepsilon}{2})\cdot t + h$}.
Let $\mathcal A$ be an approximation algorithm for the distance oracle problem with stretch $\alpha_\ell = \ell\!-\!1\!-\!\varepsilon$.
For the cases $x_e = 1$ and $x_e = 0$, respectively, let $\tilde d_1$ and $\tilde d_0$ be distance approximations of $d(s_i,t_j)$ with stretch $\alpha_\ell$ that $s_i$ determines with its local table and the label of $t_j$ (which we computed with $\mathcal A$).
Note that our claims about $\tilde d_0, \tilde d_1$ will only depend on $x_e$ and are independent from $x_{e'}$ of other edges $e'\in E \setminus \{e\}$ (even though the \textit{exact} value of $\tilde d_0, \tilde d_1$ might depend on the $x_{e'}$).
The goal is to show
$\tilde d_1 < d \leq \tilde d_0$ for some constant $d > 0$, which enables $s_i$ to distinguish $x_e=1$ from $x_e=0$ from its approximation of $d(s_i,t_j)$.
We know that $\tilde d_1 \leq \alpha_\ell \cdot d_1 = (\ell\!-\!1\!-\!\varepsilon)(t \!+\! h)$. We also have $\tilde d_0 \geq d_0$ since our approximations are supposed to be one-sided.
Then
\begin{align*}
\tilde d_1 & \leq (\ell\!-\!1\!-\!\varepsilon)(t \!+\! h)\\
& = (\ell\!-\!1\!-\!\tfrac{\varepsilon}{2})\cdot t + h + (\ell\!-\!2\!-\!\varepsilon) \cdot h -\tfrac{\varepsilon}{2}\cdot t \tag*{\small\text{\textit{expand}}}\\
& < (\ell\!-\!1\!-\!\tfrac{\varepsilon}{2})\cdot t + h \tag*{\small\text{\textit{for large enough} $t$}}\\
& = d_0 \leq \tilde d_0.
\end{align*}
The strict inequality is obtained by choosing $t > \frac{2(\ell-2-\varepsilon)}{\varepsilon} \cdot h \in \Theta(\frac{\ell h}{\varepsilon})$. Note that edge weights remain polynomial in $n$ with this choice of $t$ since $\ell, h \in O(n)$ and $\varepsilon$ is constant.
So we get $\tilde d_1 < d_0 \leq \tilde d_0$, which implies the following. Let \smash{$\tilde d(s_i,t_j)$} be the distance estimate that $s_i$ actually outputs. Then it is $x_e=0$ if \smash{$\tilde d(s_i,t_j) < d_0$}, else it is $x_e=1$. Hence the nodes $B := \{s_1, \dots, s_k\}$ collectively learn $X$ and thus solve the node communication problem, which takes \smash{$\Omega\big((\tfrac{n^\delta}{\gamma})^{\frac{1}{2+\delta}}\big)$} rounds by Lemma \ref{lem:approx_lower_bound_groundwork}.
Two things remain to be mentioned. First, we can assume that each $s_i$ also has advance knowledge of $d_0$, as this does not carry any information about $X$ to the nodes $B = \{s_1, \dots, s_k\}$ and therefore does not make the node communication problem easier.
Second, the nodes $s_i$ can only produce the distance estimations \smash{$\tilde d(s_i,t_j)$} when they are also provided with the labels $\lambda(t_1), \dots, \lambda(t_k)$.
Here we assume that the nodes $s_i$ get these labels in advance as part of the contingent of ``free'' communication that we budgeted for in Lemma \ref{lem:approx_lower_bound_groundwork} and which does not make the node communication problem asymptotically easier.
In particular let $c_1>0$ be the constant from Lemma \ref{lem:approx_lower_bound_groundwork}, such that we are allowed \smash{$y = c_1 k^{1+\delta}$} bits of free communication in total. This leaves \smash{$c_1 k^{\delta}$} bits for each of the $k$ labels $\lambda(t_1), \dots, \lambda(t_k)$. In the proof of Lemma \ref{lem:approx_lower_bound_groundwork} we chose \smash{$k = c_2 \cdot n^{\frac{2}{2+\delta}}\cdot \gamma^{\frac{1}{2+\delta}}$} (for some constant $c_2 > 0$), resulting in a label size of at most \smash{$c_1 c_2 \cdot n^{\frac{2\delta}{2+\delta}}\cdot \gamma^{\frac{\delta}{2+\delta}}$}.
\end{proof}
\begin{proof}[Proof of Lemma \ref{lem:lower_bound_stateless_routing}]
We set $w_2 = 1$ (this weight only plays a role later \textit{stateful} routing lower bound) and $w_1 < w_0 < (\ell \!- \! 1)w_1$ (more precise values are determined further below). Let $s_i, t_j$ be a source-target pair of $\Gamma$ where $e := \{s_i,t_j\} \in E$ is part of $G$ (but not necessarily $\Gamma$). For the case $x_e = 1$ we define $d_1 := d(s_i,t_j) = w_1\!+\!h$ and $d_0 := d(s_i,t_j) = w_0\!+\!h$ for the case $x_e = 0$ (c.f., Lemma \ref{lem:source_target_distance_weighted}).
Let $\mathcal A$ be an algorithm solving the \textit{stateless} routing problem with the claimed approximation ratio (with const.\ probability). Let $P$ be the \textit{simple} $s_i$-$t_j$-path induced by the \textit{stateless} routing scheme computed by $\mathcal A$. Recall that $P$ must be simple as otherwise a packet that is oblivious to the prior routing decisions would be trapped in a loop. Our aim is that $s_i$ can decide whether $x_e =0$ or $x_e =1$ from the next routing node on $P$. That is, we want that $P$ contains $v$ if and only if $x_e = 0$. However, there are a few options to obtain the $s_i$-$t_j$-path $P$ that do, in certain cases, not abide by this requirement. We enumerate these in the following.
Assume $P$ does not contain $e$. Then option (1) is to go the left ``lane'' via $v$ and then use the direct blue edge $\{v', t_j\}$ to get to $t_j$, i.e., the path of length $d_0$. If $P$ goes from $s_i$ directly to $u_i$, then $P$ can be completed into a path to $t_j$ by (2) using only edges that are also part of $G$ (but not $e$), i.e., only red edges in Figure \ref{fig:lower_bound_enhanced}. Note that option (2) must include at least $\ell \! - \! 1$ red edges due to the girth $\ell$ of $G$. Option (3) is where $P$ goes to $u_i$ first uses any red edge $\{u_i,t_p\}$ ($p \neq j$) and then the two blue edges $\{t_p, v'\}, \{v', t_j\}$ to reach $t_j$. Note that for the case $x_e = 0$ all other $s_i$-$t_j$-paths are either strictly longer than option (1),(2),(3) or not simple.
The distances of the three paths (1),(2),(3) are at least (recall $w_2 = 1$):
\begin{align*}
d^{(1)} & := w_0 + h \;(= d_0)\\%\tag{1}\\
d^{(2)} & := (\ell \! - \! 1)w_1 + h\\%\tag{2}\\
d^{(3)} & := w_1 + 2w_0 +
\end{align*}
To enforce $v \notin P$ in case $x_e = 1$, we require that path (1) is unfeasible, i.e., exceeds the allowed distance $\alpha_\ell d_1$. Furthermore, to enforce $v \in P$ in case $x_e = 0$, we require that the paths (2) and (3) exceed the allowed distance $\alpha_\ell d_0$. From this we obtain the following conditions.
\begin{align*}
\alpha_{\ell} \cdot d_1 & \stackrel{!}{<} d^{(1)} = w_0 + h\tag{1}\\
\alpha_{\ell} \cdot d_0 & \stackrel{!}{<} d^{(2)} = (\ell \! - \! 1)w_1 + h \tag{2} \\
\alpha_{\ell} \cdot d_0 & \stackrel{!}{<} d^{(3)} = w_1 + 2w_0 + h \tag{3}
\end{align*}
The remaining part of the proof is merely technical, we need to maximize $\alpha_\ell$ under the above constraints. (Afterwards, the rest follows from having solved the node communication problem as in the proof of Lemma \ref{lem:lower_bound_distance_oracle}). Set $w_1 := t < w_0$ for some yet unspecified variable $t > 0$. Further, we set $\alpha := \frac{w_0}{t} - \varepsilon$ and show that this fulfills Equation (1):
\[
\alpha_{\ell} \cdot d_1 = \big(\tfrac{w_0}{t} - \varepsilon\big)(t+h) = w_0 + \tfrac{h w_0}{t} - \varepsilon(t+h) < w_0 + h.
\]
For Equation (2) we obtain:
\begin{align*}
& \alpha_{\ell} \cdot d_0 = \big(\tfrac{w_0}{t} \!-\! \varepsilon\big)(w_0\!+\!h) < (\ell \! - \! 1)t + h\\
\Longleftrightarrow \quad & \tfrac{w_0^2}{t} + \tfrac{w_0}{t}(h-\varepsilon t)-\varepsilon h - h < (\ell \! - \! 1)t\\
\Longleftrightarrow \quad & w_0^2 + \underbrace{w_0(h-\varepsilon t)}_{<0, \text{ for } t > h/\varepsilon} \underbrace{-\varepsilon ht - ht}_{<0} < (\ell \! - \! 1)t^2\\
{\Longleftarrow} \quad & w_0^2 \leq (\ell \! - \! 1)t^2\\
{\Longleftrightarrow} \quad & w_0 \leq t \cdot \sqrt{\ell \! - \! 1}.
\end{align*}
Now let us turn to Equation (3)
\begin{align*}
& \alpha_{\ell} \cdot d_0 = \big(\tfrac{w_0}{t} \!-\! \varepsilon\big)(w_0\!+\!h) < t + 2w_0 + h\\
\Longleftrightarrow \quad & \tfrac{w_0^2}{t} + \tfrac{w_0}{t}(h-\varepsilon t)-\varepsilon h < t + 2w_0 + h\\
\Longleftrightarrow \quad & w_0^2 + w_0(\underbrace{h-\varepsilon t}_{<0}-2t) \underbrace{-\varepsilon ht - ht}_{<0} - t^2 < 0\\
\Longleftarrow \quad & w_0^2 -2tw_0 - t^2\leq 0 \\
\Longleftarrow \quad & w_0 \leq t \cdot (1\!+\!\sqrt 2).
\end{align*}
Therefore, Equations (2),(3) are fulfilled if $w_0 \leq t \cdot \sqrt{\ell \! - \! 1}$ and $w_0 \leq t \cdot (1\!+\!\sqrt 2)$ (and \smash{$t > \frac{h}{\varepsilon}$}, which can be chosen freely). This implies that the stretch $\alpha_\ell = \frac{w_0}{t} - \varepsilon$ must satisfy $\alpha_\ell\leq \sqrt{\ell \! - \! 1} - \varepsilon$ and $\alpha_\ell \leq 1\!+\!\sqrt 2 \!-\! \varepsilon$, whereas the former condition for $\alpha_\ell$ dominates the latter if and only if $\ell \leq 8$.
With this choice of $w_0, \alpha_\ell$, the first node that a packet from $s_i$ with destination $t_j$ is routed to is the node $v$ if and only if $x_e = 0$. Hence, the nodes in $B$ collectively learn $X$ from the information provided by algorithm $\mathcal{A}$ and the labels of the nodes $t_j$, which therefore solves the node communication problem. The runtime and size of the labels then follows the same way as in the proof of Lemma \ref{lem:lower_bound_distance_oracle}.
\end{proof}
\begin{proof}[Proof of Lemma \ref{lem:lower_bound_stateful_routing}]
The beginning of the proof is similar to the one of Lemma \ref{lem:lower_bound_stateless_routing}.
Consider algorithm $\mathcal A$ that solves the \textit{stateful} routing problem with the claimed approximation ratio and constant probability. Let $s_i, t_j \in V_\Gamma$ with $e := \{s_i,t_j\} \in E$ and define $d_1 := d(s_i,t_j) = w_1\!+\!w_2\!+\!h\!-\!1$ and $d_0 := d(s_i,t_j) = w_0\!+\!w_2\!+\!h\!-\!1$ for the cases $x_e = 1$, $x_e = 0$ respectively (we will ensure $w_1 < w_0 < (\ell\!-\!1)w_1$ so that Lemma \ref{lem:source_target_distance_weighted} applies).
Let $P$ be the $s_i$-$t_j$-path induced by the \textit{stateful} routing scheme computed by $\mathcal A$. Similar to before, our goal is to show that the first node on $P$ is $v$ if and only if $x_e = 0$, so that $s_i$ learns $x_e$ from its routing decision. As before, we aim to prohibit all routing options (i.e., make them break the stretch guarantee) that do not abide by this requirement. We will extend our list of options for $P$ which are in some cases undesirable from the previous proof.
We have the loop-less routing options (1),(2),(3) from before (c.f., proof of Lemma \ref{lem:lower_bound_stateless_routing}), whose lengths change by an additive term $w_2-1$ due to the introduction of weight $w_2$ (orange edges in Figure \ref{fig:lower_bound_enhanced}). Note that any path (possibly with loops) that contains $s_i$ just once is at least as long as one of the options (1)-(3) (in their respective cases) so prohibiting the latter prohibits the former.
The problem that arises is from visiting $s_i$ at least twice is that it can mislead $s_i$ by first going to $v$ even though $x_e = 1$ or vice versa.
Assume the case that $e$ is not in $\Gamma$ ($x_e = 0$), then we need to prohibit routing option (4) that visits the first node on the path towards $u_i$, returns to $s_i$, travels directly to $v'$ and uses the blue edge to $t_j$.
Conversely, assuming the case that $e$ is present in $\Gamma$ ($x_e = 1$), $P$ we need to prohibit option (5), which visits $v$ first but then returns to $s_i$, travels to $u_i$ and uses $e$ to reach $t_j$. Note that all paths that contain $s_i$ at least twice, are at least as long as one of the paths (4),(5) (in their respective cases). The described routing paths (1)-(5) have the following respective lengths:
\begin{align*}
d^{(1)} & := w_0 + w_2 + h -1\\
d^{(2)} & := (\ell \! - \! 1)w_1 + w_2 + h -1\\
d^{(3)} & := 2w_0 + w_1 + w_2 + h -1\\
d^{(4)} & := w_0 + 3w_2 + h -1\\
d^{(5)} & := w_1 + 3w_2 + h -1
\end{align*}
We obtain inequalities similar as before. For the reasoning of inequalities (1)-(3) consider the proof of Lemma \ref{lem:lower_bound_stateless_routing}. Observe that if $P$ would follow path options (4),(5) it could make $s_i$ believe $x_e = 1$ or $x_e = 0$ respectively, even though the opposite is true. We require that path options (4) and (5) exceed the stretch $\alpha_\ell$ in the cases in which they are undesirable, that is, $x_e = 0$ and $x_e = 1$, respectively.
\begin{align*}
\alpha_{\ell} \cdot d_1 & \stackrel{!}{<} d^{(1)} = w_0 + w_2 + h -1\tag{1}\\
\alpha_{\ell} \cdot d_0 & \stackrel{!}{<} d^{(2)} = (\ell \! - \! 1)w_1 + w_2 + h -1 \tag{2} \\
\alpha_{\ell} \cdot d_0 & \stackrel{!}{<} d^{(3)} = 2w_0 + w_1 + w_2 + h -1 \tag{3} \\
\alpha_{\ell} \cdot d_0 & \stackrel{!}{<} d^{(4)} = w_0 + 3w_2 + h -1 \tag{4} \\
\alpha_{\ell} \cdot d_1 & \stackrel{!}{<} d^{(5)} = w_1 + 3w_2 + h -1 \tag{5}
\end{align*}
This leaves us with an optimization problem where $\alpha_{\ell}$ is to be maximized in the domain $1 \leq w_1 \leq w_0,w_2$, subject to conditions (1)-(5). This is admittedly a bit tedious, in particular since the optimization problem has a different result for girth $\ell \in \{4,6,8,10\}$ (we gain no improvement for larger $\ell$). We do not reproduce all necessary calculations of the optimization in detail, instead we give some explanations to make our results (given in Table \ref{tbl:lower_bounds_stateful_opt_values}) reproducible.
One obstacle is the presence of edges with weight 1 in $\Gamma$ forming the path of length $h-1$, which is not yet fixed and therefore prohibits solving the optimization problem directly. Our strategy is to first relax our problem to a simplified one with zero-weight edges. That is, we set all edges, except those with weight $w_0,w_1,w_2$, to zero and adapt the distances $d_0, d_1, d^{(1)}, \dots, d^{(5)}$ accordingly (essentially slashing $h\!-\!1$ in those distances). We also set $w_1 = 1$. This eliminates $w_1,h$ from conditions (1)-(5) and the resulting maximization problem(s) can be solved directly.
From the results of the simplified optimization problems (for girths $\ell \in \{4,6,8,10\}$), we obtain almost optimal solutions for the general optimization problem with non-zero weights as follows. We multiply the values of $w_0,w_1,w_2$ with a (sufficiently large) parameter $t \geq 1$ and subtract an $\varepsilon>0$ from $\alpha_\ell$ to accommodate a (small) slack that is required in the general inequalities. The value of $t$ depends on the slack $\varepsilon$ in $\alpha_\ell$ that is given but is generally polynomial in $n$ as long as $\varepsilon$ is constant.
The results obtained using this procedure are given in Table \ref{tbl:lower_bounds_stateful_opt_values}.
\begin{table}[h]
\begin{center}
\begin{tabular}{p{5mm}>{\centering\arraybackslash}p{14mm}>{\centering\arraybackslash}p{14mm}>{\centering\arraybackslash}p{6mm}>{\centering\arraybackslash}p{14mm}}
\toprule
$\ell$ & $\alpha_\ell$ & $w_0$ & $w_1$ & $w_2$\\
\midrule
4 & $\sqrt 2 - \varepsilon$ & $2t\sqrt 2 \!-\!t$ & $t$ & $t$\\[1.5mm]
6 & $\frac{5}{3} - \varepsilon$ & $\frac{5t}{2}$ & $t$ & $\frac{5t}{4}$ \\[1.5mm]
8 & $\tfrac{7}{4} - \varepsilon$ & $\frac{35t}{11}$ & $t$ & $\frac{21t}{11}$ \\[1.5mm]
10 & $\frac{3+\sqrt{17}}{4} - \varepsilon$ & $\frac{3+\sqrt{17}}{2}t$ & $t$ & $\frac{5+\sqrt{17}}{4}t$\\
\bottomrule
\end{tabular}
\end{center}
\caption{\lng{\boldmath} Results of maximizing $\alpha_\ell$, s.t., conditions (1)-(5) for $\ell \in \{4,6,8,10\}$ (and scaling with $t$ and introducing slack $\varepsilon$).}
\label{tbl:lower_bounds_stateful_opt_values}
\end{table}
The most relevant parameter in Table \ref{tbl:lower_bounds_stateful_opt_values} are certainly the values for $\alpha_\ell$ for $\ell \in \{4,6,8,10\}$, whereas we also provide the weights $w_0,w_1,w_2$ for reproducibility. Showing that the given parameters do in fact satisfy conditions (1)-(5) for any constant $\varepsilon > 0$ and some choice of $t$, is a repetitive task. We show this once for $\ell=10$ and condition (1) (which is almost tight in this case), the other cases can be repeated analogously.
\begin{align*}
\alpha_{\ell} \cdot d_1 & = \big(\tfrac{3+\sqrt{17}}{4} \big)d_1 - \varepsilon d_1\\
& = \big(\tfrac{3+\sqrt{17}}{4} \big)(w_1 + w_2 + h -1) - \varepsilon d_1\\
& = \big(\tfrac{3+\sqrt{17}}{4} \big)(w_1 + w_2) + h \!-\!1 + \smash{\underbrace{\big(\tfrac{\sqrt{17}-1}{4} \big)(h\!-\!1) - \varepsilon d_1 }_{<0,\text{ for large }t}}\\
& < \big(\tfrac{3+\sqrt{17}}{4} \big)\big(\tfrac{9+\sqrt{17}}{4}\cdot t\big) + h \!-\!1\\
& = \big(\tfrac{11+3\sqrt{17}}{4}\big) \cdot t + h \!-\!1\\
& = \big(\tfrac{3+\sqrt{17}}{2} + \tfrac{5+\sqrt{17}}{4}\big) \cdot t + h \!-\!1\\
& = w_0 + w_2 + h \!-\!1 = \smash{d^{(1)}}.
\end{align*}
Note that, since $d_1$ grows linear in $t$ the inequality in the fourth line holds for \smash{$t > \big(\tfrac{\sqrt{17}-1}{4\varepsilon} \big)(h\!-\!1) \in \smash{\ensuremath{O}}(n)$}.
Finally, by enforcing conditions (1)-(5) with the appropriate parameters given in Table \ref{tbl:lower_bounds_stateful_opt_values}, we can guarantee that the first node that a packet from $s_i$ to $t_j$ is first routed to $v$ if and only if $x_e = 0$. From this the nodes in $B$ collectively learn $X = (x_e)_{e \in E}$ thus solving the node communication problem. The runtime and size of the labels follows as in the proof of Lemma \ref{lem:lower_bound_distance_oracle}.
\end{proof}
\section{Upper Bounds}
\label{sec:upper_bounds}
\lng{The first part of this paper is to} \shrt{In this part of the paper we} derive algorithms that compute routing schemes and distance oracles in the \ensuremath{\mathsf{HYBRID}}\xspace model\lng{, which we consider as a warm-up and complementary to the subsequent section on lower bounds}.
We can draw on the techniques and fast algorithms for shortest paths problems from \cite{Augustine2020, Kuhn2020, CensorHillel2021} (where most of the heavy lifting occurs) and show how to leverage these to obtain distance oracles and routing schemes efficiently in the \ensuremath{\mathsf{HYBRID}}\xspace model. We start with a quick introduction to the techniques we use.
{\subsection{Techniques}
Skeleton graphs were first used by \cite{Ullman1991} and became one of the main tools used in the context of shortest path algorithms in the \ensuremath{\mathsf{HYBRID}}\xspace model (c.f., \cite{Augustine2020,Kuhn2020,CensorHillel2021}). Simply speaking, a skeleton is a minor of a graph $G$ consisting of a (usually relatively small) set of nodes sampled with some probability $\frac{1}{x}$ and virtual edges formed between sampled nodes at most $\smash{\ensuremath{\widetilde{O}}}(x)$ hops apart with weights such that distances in the skeleton graph correspond to those in $G$ w.h.p.
The usual approach is to solve a given shortest path problem on an appropriately sized skeleton graph by leveraging the global communication provided by the \ensuremath{\mathsf{HYBRID}}\xspace model and then extend that solution to the whole graph using local communication. While at this point it is not necessary to fully characterize skeleton graphs anymore (we use existing algorithms out of the box), we still have to use the subsequent property for a random sampling of nodes (from which all required properties of a skeleton graph are derived).
Assume each node joins some set $S \subseteq V$ independently and identically distributed (i.i.d.) with probability $1/x$ for some $x > 1$. The expected number of nodes joining $S$ is $\mathbb E(|S|) = n/x$, and we also have $|S| \in \Theta(n/x)$ w.h.p.\ if $\mathbb E(|S|)$ is sufficiently large (which a simple application of the Chernoff bound given in Lemma \ref{lem:chernoffbound} shows).
Furthermore, there exists some $h \in \smash{\ensuremath{\widetilde{O}}}(x)$ such that for any $u,v \in V$ there will be a sampled node on some shortest $u$-$v$-path $P$ at least every $h$ hops for any $u,v \in V$ w.h.p. This is formalized as follows (the proof can be found at the end of Appendix \ref{apx:generalnotations}).
\begin{lemma}[c.f., \cite{Kuhn2020}, \cite{Augustine2020}]
\label{lem:node_sampling}
Let $G=(V,E)$. Let each node join some set $S\subseteq V$ i.i.d.\ with probability $\frac{1}{x}$. Then there is a constant $\xi \!>\! 0$, such that for any $u,v \!\in\! V$ with $hop(u,v) \!\geq\! h := \xi x \ln n$, there is at least one shortest path $P$ from $u$ to $v$, such that any sub-path $Q$ of $P$ with at least $h$ nodes contains a node in $S$ w.h.p.
\end{lemma}
We are interested in the distances to the sampled nodes, which can be formalize as follows.
\begin{definition}[Random Sources Shortest Paths (RSSP)]
Given a subset of nodes (sources) that were sampled i.i.d.\ with probability $1/x$ for some $x \geq 1$ from an undirected, weighted graph $G$. The RSSP problem is solved when every node in the network has learned its distance to each of the random source nodes.
\end{definition}
We provide a rough overview how RSSP was solved (simplified for \smash{$x = n^{1/3}$}) for readers unfamiliar with the topic. First, a skeleton graph of $G$ is constructed on the \smash{$\Theta(n^{2/3})$} sampled nodes as in \cite{Augustine2020}. Note that edges of that skeleton are at most \smash{$\smash{\ensuremath{\widetilde{\Theta}}}(n^{1/3})$} hops apart, which means that one round of the \ensuremath{\mathsf{LOCAL}}\xspace model can be simulated on that skeleton graph in \smash{$\smash{\ensuremath{\widetilde{\Theta}}}(n^{1/3})$} real rounds.
Second, \cite{Kuhn2020} showed that a round of the \ensuremath{\mathsf{CLIQUE}}\xspace model\footnote{In the \ensuremath{\mathsf{CLIQUE}}\xspace model, in each round each node is allowed to send a (different) $\smash{\ensuremath{O}}(\log n)$ message to every node.} can also be simulated in \smash{$\smash{\ensuremath{\widetilde{\Theta}}}(n^{1/3})$} rounds on the skeleton graph using a routing protocol tailored to the \ensuremath{\mathsf{HYBRID}}\xspace model to efficiently communicate $\smash{\ensuremath{O}}(\log n)$ bit messages between pairs of senders and receivers.
Third, \cite{CensorHillel2021} observed that skeleton nodes with a high degree in the skeleton graph can learn a lot of information by relying on the bandwidth of their neighbors in the skeleton. With this observation they use \smash{$\smash{\ensuremath{\widetilde{O}}}(1)$} simulated \ensuremath{\mathsf{LOCAL}}\xspace and \ensuremath{\mathsf{CLIQUE}}\xspace rounds (of \smash{$\smash{\ensuremath{\widetilde{\Theta}}}(n^{1/3})$} real rounds each) to compute ``tiered oracles'' (not to be confused with distance oracles in this paper) meaning that each node with a degree in a certain ``tier'' (exponential degree class \smash{$\{2^{i-1}\!\!\!, \dots, 2^{i}\!-\!1\}$ with $i \in [\lceil\log n\rceil]$}) learns the subgraph of the skeleton graph induced by nodes of degree in its own tier or below.
Iteratively, one can solve the all pairs shortest paths problem on the skeleton. Initially, the nodes of the highest tier know the whole skeleton graph and can send their distance to every node in one \ensuremath{\mathsf{CLIQUE}}\xspace round. This information enables the nodes in the next lower tier to compute their distance to every node in the skeleton. Then the process repeats (for each of the $\smash{\ensuremath{\widetilde{O}}}(1)$ tiers) until eventually all pairs shortest paths is solved on the skeleton. All other nodes in $G$ can learn their distance to each skeleton node from those within $\smash{\ensuremath{\widetilde{O}}}(n^{1/3})$ hops. The following lemma summarizes this.
\begin{lemma}[c.f., \cite{CensorHillel2021}\footnote{For our applications, it is convenient to rephrase the result of \cite{CensorHillel2021}, which considers sampling probabilities $n^{y-1}$ for $0<y<1$ with running time \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{1/3}+n^{2y-1})$}. This corresponds to the variant given here via the substitution \smash{$y = 1-\frac{\log x}{\log n}$}.}]
\label{lem:rssp}
There is an algorithm that solves the random sources shortest path problem for sampling probability $1/x$ for some $x \geq 1$ exactly and w.h.p.\ in \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{1/3}+n/x^2)$} rounds.
\end{lemma}
This result is almost tight (up to $\polylog(n)$ factors) for $x = n^{1/3}$ (i.e., there are $|S| = \Theta(n^{2/3})$ sources) due to a corresponding lower bound by \cite{CensorHillel2021} which was slightly adapted for random sources from the $\smash{\ensuremath{\widetilde{\Omega}}}(\!\sqrt{k})$ lower bound for the $k$-sources shortest path problem given in \cite{Kuhn2020}.}
\subsection{Base Algorithm}
{We combine the previous two techniques to compute exact distance oracles and routing schemes in the \ensuremath{\mathsf{HYBRID}}\xspace model.} We will presume a subroutine \code{explore($h$)} that floods all graph information for $h$ hops such that afterwards each node $u \in V$ knows $\mathcal{B}_{u,h}$ defined as the subgraph induced by the nodes within $h$ hops around $u$. Furthermore we presume a subroutine \code{solve-rssp} that solves RSSP on the sampled nodes in accordance with Lemma \ref{lem:rssp}.
Algorithm \ref{alg:base_algo} gives an overview. The parameters $x$ and $h$ are tuning parameters which will be specified for the task at hand. Algorithm \ref{alg:base_algo} consists of two parts: first all nodes collect the information required to compute distance oracles and routing schemes. Second, in the last three lines, the computation of the label $\lambda(v)$, oracle function $o_v$ and routing function $\rho_v$ takes place (c.f., Definitions \ref{def:distance_oracles}, \ref{def:stateful_routing}). We will override these sub-procedures to adapt the algorithm for exact and approximate results and for the special case of unweighted graphs. The steps are described on a node-level.
\begin{algorithm}[H]
\caption{\code{base-algorithm($x,h$)}\Comment{\textit{$h$ not smaller as in Lem.\ \ref{lem:node_sampling}}}}
\label{alg:base_algo}
\begin{algorithmic}
\State $v$ joins $S$ with probability $\frac{1}{x}$
\State \code{explore($h$)} \Comment{\textit{$v$ learns $\mathcal{B}_{v,h}$}}
\State \code{solve-rssp} \Comment{\textit{with source nodes $S$}}
\State \code{create-label} \Comment{\textit{computation of $v$'s problem-specific label}}
\State \code{create-oracle-function} \Comment{\textit{output $o_v$ as in Def.\ \ref{def:distance_oracles}}}
\State \code{create-routing-function} \Comment{\textit{output $\rho_v$ as in Def.\ \ref{def:stateless_routing}}}
\end{algorithmic}
\end{algorithm}
\begin{lemma}
\label{lem:base_algo_runtime}
Given that the last three lines have constant running time, Algorithm \ref{alg:base_algo} takes $\smash{\ensuremath{\widetilde{O}}}(n^{1/3}+n/x^2 + h)$ rounds.
\end{lemma}
\begin{proof}
The time consuming steps are \code{explore($h$)}, i.e., the flooding of the graph for $h \in \smash{\ensuremath{\widetilde{\Omega}}}(x)$ rounds and solving the RSSP with $\smash{\ensuremath{\widetilde{O}}}(n^{1/3}+n/x^2)$ (c.f., Lemma \ref{lem:rssp}).
\end{proof}
\subsection{Exact Distance Oracles \& Routing Schemes}
First, \code{create-label} computes $v$'s label $\lambda(v):=\big\{\big(\text{ID}(s),d(s,v)\big)\mid s \in S\big\}$ corresponding to the identifiers of all nodes in $S$ and the associated distances that are known from solving the RSSP problem.
Second, for a given label $\lambda(u)$ of some destination $u \in V$ \code{create-oracle-function} outputs the following function
\begin{equation}
\label{eq:exact_oracle_function}
o_v(\lambda(u)) = \min\Big(d_h(v,u), \,\min_{s\in S} d(v,s) + d(s,u)\Big)
\end{equation}
Note that in the above equation we set $d(v,v)=0$ and $d_h(v,u) = \infty$ for $u \notin \mathcal{B}_{v,h}$. The $h$-hop distances $d_h(v,u)$ are known since $v$ knowns $\mathcal{B}_{v,h}$, the distances $d(v,s), s \in S$ are known from solving the RSSP problem on $S$ and the distances between pairs $d(s,u), u \in S$ are part of the label $\lambda(u)$, thus $o_v(\lambda(u))$ can be computed by $v$.
Exchanging the computed distance oracles between neighbors problem gives us sufficient information to solve the routing problem. Roughly speaking, the next node on a shortest path is given by a neighbor that minimizes the distance to the destination of the packet (a little bit of care has to be taken for proving this, though).
More precisely, the subroutine \code{create-routing-function} will first do a single round of communication so that each node $v$ learns the oracle function $o_w$ of each of its neighbors $w$ in the local network. Then we use this knowledge to pass the packet only to a neighbor whose distance oracle to the target decreases by the weight of that edge (pick an arbitrary one if there is more than one).
\begin{align}
\label{eq:exact_routing_function}
& \rho_v(\lambda(u)) \in \big\{z \in N(v) \mid o_z(\lambda(u)) = o_v(\lambda(u)) - w(v,z) \big\}
\end{align}
Note that additional knowledge of $o_z(\lambda(u))$ for $z \in N(v)$ is sufficient to compute $\rho_v(\lambda(u))$.
It remains to analyze the resulting algorithm and give the remaining correctness arguments, which we do in the proof of the following theorem. Note that here we obtain a trade off between label size and the running time, which we formalize with a parameter $\zeta$.
\begin{theorem}
\label{thm:exact_algo}
For any $\zeta \geq 0$ \emph{exact} distance oracles and \emph{stateless} routing schemes with labels of size \smash{$\smash{\ensuremath{O}}(n^{\frac{2}{3}-\zeta})$} bits can be computed in \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{\frac{1}{3}+\zeta})$} rounds in the \ensuremath{\mathsf{HYBRID}}\xspace model w.h.p
\end{theorem}
\begin{proof}
Note that for $\zeta \geq 2/3$ the problem becomes trivial (any graph problem can be solved in $n$ rounds in \ensuremath{\mathsf{HYBRID}}\xspace), so we assume $\zeta < 2/3$. We choose \smash{$x = n^{\frac{1}{3}+\zeta}$} and $h = \smash{\ensuremath{\widetilde{\Theta}}}(x)$ as in Lemma \ref{lem:node_sampling}, then the runtime follows from Lemma \ref{lem:base_algo_runtime}. The number of sampled nodes is \smash{$|S| \in \Theta(n^{\frac{2}{3}-\zeta})$} (a simple application of Lemma \ref{lem:chernoffbound}). As the label $\lambda(v)$ contains information of size $\smash{\ensuremath{O}}(\log n)$ bits for each node $s \in S$ (recall that distances are polynomial in $n$), $\lambda(v)$ requires \smash{$\smash{\ensuremath{O}}(n^{\frac{2}{3}-\zeta}\log n)$} bits. We can shift the $\log n$ factor from the label size into the runtime (where it is absorbed by the $\smash{\ensuremath{\widetilde{O}}}$ notation) with a substitution \smash{$\zeta= \zeta' + \frac{\log\log n}{\log n}$}.
We already established in the algorithm description that the required information to compute $\lambda(v)$, $o_v$ and $\rho_v$ is present at the node $v$ from executing \code{explore($h$)} and \code{solve-rssp}.
It remains to show that $o_v(\lambda(u)) = d(v,u)$. If there is a shortest $v$-$u$-path with at most $h$ hops, then the first argument of the outer $\min$ function in Equation \eqref{eq:exact_oracle_function} corresponds to $d(v,u)$. If all shortest $v$-$u$-paths have more than $h$ hops then there must be a node $s \in S$ on one such path by Lemma \ref{lem:node_sampling}, which means that the second argument of the outer $\min$ function in Equation \eqref{eq:exact_oracle_function} corresponds to $d(v,u)$.
Regarding the routing function, we observe that $z \in N(v)$ is the next node on \emph{some} shortest path from $v$ to $u$ if and only if $d(v,u) = w(v,z) + d(z,u)$, which is equivalent to $o_z(u) = o_v(u) - w(v,z)$ as $o_v,o_z$ are exact distance oracles. Since $G$ is connected, there is always a neighbor of $v$ on some shortest path to $u$ so the set in Equation \eqref{eq:exact_routing_function} is not empty.
By always choosing the next node on \emph{some} shortest path from the current node to $u$ (c.f., Equation \eqref{eq:exact_routing_function}), we will naturally obtain a shortest $v$-$u$-path overall. Note that the obtained routing scheme is oblivious to previous routing decisions.
\end{proof}
\subsection{Approximate Solutions}
\label{sec:upper_bounds_approx}
Note that if we do not want to compromise on the running time the label size in Theorem \ref{thm:exact_algo} is $\smash{\ensuremath{\widetilde{\Omega}}}(n^{2/3})$. However, we can compromise on the stretch in order to significantly decrease the label size as we show in the following.
Subroutine \code{create-label} of $v$ computes the much smaller label $\lambda(v):=\big(\text{ID}(s_v),d(s_v,v)\big)$, where $s_v := \argmin_{s \in S} d(s,v)$ corresponds to the identifier and distance of the \textit{closest} node in $S$.
Given some label $\lambda(u):=\big(\text{ID}(s_u) ,d(s_u,v)\big)$ then node $v$ outputs the following function in subroutine \code{create-oracle-function}, which is the shorter of the $h$-hop distance to $u$ and the shortest $v$-$u$-path that transits $s_u$.
\begin{equation}
\label{eq:approx_oracle_function}
o_v(\lambda(u)) = \min\big(d_{h}(v,u), \,d(v,s_u) + d(s_u,u)\big).
\end{equation}
We start by showing that the oracle function $o_v$ from above gives a decent approximation (with proofs similar to those for approximations for the single source shortest paths problem in \cite{Augustine2020}).
\begin{lemma}
\label{lem:algo-approx-weighted}
For $u,v \in V$ it is $o_v(u) \leq 3d(v,u)$ w.h.p. (for $o_v$ from Eq.\ \eqref{eq:approx_oracle_function}).
\end{lemma}
\begin{proof}
If there is a shortest $v$-$u$-path with at most $h$ hops, then we actually have $o_v(\lambda(u)) = d_{h}(v,u) = d(v,u)$ (c.f., first argument of Equation \eqref{eq:approx_oracle_function}) analogous to the proof of Theorem \ref{thm:exact_algo}.
Else, all shortest $v$-$u$-paths have more than $h$ hops. Then by Lemma \ref{lem:node_sampling} w.h.p.\ there must be a node $\hat s \in \mathcal{B}_{u,h}$ such that
\[
d(v,u) = d(v,\hat s) + d(\hat s,u).\tag*{(i)}
\]
Let $s_u := \argmin_{s \in S} d(s,v)$ from the label $\lambda(u)$. Then
\[
d(s_u,u) \stackrel{\text{Def.\ of } s_u}{\leq} d(\hat s,u) \stackrel{\text{(i)}}{=} d(v,u) - d(v,\hat s) \leq d(v,u).\tag*{(ii)}
\]
Then, for the second argument of Equation \eqref{eq:approx_oracle_function} we get
\begin{align*}
o_v(\lambda(u)) & \leq d(v,s_u) + d(s_u,u)\tag*{\textit{c.f., Equation \eqref{eq:approx_oracle_function}}}\\
& \leq d(v,u) + d(u,s_u) + d(s_u,u) \tag*{\textit{triangle ineq.}}\\
& = d(v,u) + 2 d(u,s_u) \leq 3d(v,u).\tag*{\textit{by ineq.} {(ii)}}
\end{align*}
\end{proof}
We can also express the approximation as additive error depending on largest weight $W'$ on some $v$-$u$-path and the hop distance $h'$ between sampled nodes on that shortest path.
\begin{lemma}
\label{lem:algo-approx-unweighted}
For $u,v \in V$ let $W'$ be the largest weight on \emph{some} shortest $v$-$u$-path. Then $o_v(\lambda(u)) \leq d(v,u) +2h' W'$ w.h.p.\ (for $o_v$ from Eq.\ \eqref{eq:approx_oracle_function}) where $h'\in \smash{\ensuremath{\widetilde{O}}}(x)$ denotes the value from Lemma \ref{lem:node_sampling}.
\end{lemma}
\begin{proof}
Fix a shortest $v$-$u$-path $P$. Let $W'$ be the largest weight on $P$. By Lemma \ref{lem:node_sampling} there is a sampled node $\hat s \in S$ on $P$ with $\hop(\hat s,u) \leq h'$ w.h.p.\footnote{Note for the union bound to work, Lemma \ref{lem:node_sampling} is phrased such that for each pair $u,v \in V$ there is just \textit{one} shortest $v$-$u$-path (out of possibly exponentially many) which has a sampled node at last every $h'$ hops. In fact in the proof we can fix one specific such path for each pair ourselves and the union bound still works.} This implies $d(\hat s,u) \leq h'W'$. Let $s_u := \argmin_{s' \in S} d(s',v)$ (from the label $\lambda(u)$). By definition of $s$ we have $d(s_u,u) \leq d(\hat s,u) \leq h'W'$. Then we get
\begin{align*}
o_v(\lambda(u)) & \leq d(v,s_u) + d(s_u,u)\tag*{\textit{c.f., Equation \eqref{eq:approx_oracle_function}}}\\
& \leq d(v,u) + d(u,s_u) + d(s_u,u) \tag*{\textit{triangle ineq.}}\\
& \leq d(v,u) + 2 h'W'.\tag*{\qedhere}
\end{align*}
\end{proof}
Similar to Equation \eqref{eq:exact_routing_function}, we define $\rho_v(\lambda(u))$ as a node $z$ that is adjacent to $v$ such that the oracle function $o_z(\lambda(u))$ decreases by \textit{at least} the weight of the corresponding edge, i.e., $o_z(\lambda(u)) \leq o_v(\lambda(u)) - w(v,z)$ (we will show that there is always a neighbor of $v$ that fulfills these criteria and if several do, we choose one arbitrarily). Then subroutine \code{create-routing-function} outputs
\begin{align}
\label{eq:approx_routing_function}
& \rho_v(\lambda(u)) \in \big\{z \in N(v) \mid o_z(\lambda(u)) \leq o_v(\lambda(u)) - w(v,z) \big\}
\end{align}
\begin{lemma}
\label{lem:stretch-routing}
For any $u,v \in V$ the routing functions in Equation \eqref{eq:approx_routing_function} induce a $v$-$u$-path $P$ with $w(P) \leq o_v(\lambda(u))$ w.h.p.
\end{lemma}
\begin{proof}
Assume a packet is forwarded along a path $P$ containing the nodes $v =: v_1, \dots , v_k := u$ with $o_{{i+1}} \leq o_{i} - w(v_i,v_{i+1})$ (whereas we abbreviate $o_i := o_{v_{i}}(\lambda(u))$ and we have $o_k = o_{u}(\lambda(u)) = 0$) then we can upper bound $w(P)$ with a telescoping sum
\[
w(P) = \! \sum_{i=1}^{k-1} \! w(v_i,v_{i+1})
\leq \! \sum_{i=1}^{k-1} \! \big( o_i - o_{i+1} \big)
= o_1 - \underbrace{\smash{o_k}}_{=0} = o_{v}(\lambda(u)).
\]
It remains to prove the existence of $P$. For that we show that each node $v$ has a neighbor $z$ that fulfills the requirement $o_z(\lambda(u)) \leq o_v(\lambda(u)) - w(v,z)$. We have to unwrap the definition of $o_v(\lambda(u))$ to make this argument.
\textit{Case 1:} if $o_v(\lambda(u)) = d_{h}(v,u)$ (first argument of the $\min$ function in Equation \eqref{eq:approx_oracle_function}), then this means there is a $h$-hop path $Q$ from $v$ to $u$ that fulfills $w(Q) = o_v(\lambda(u))$.
Clearly, the next $z \in N(v)$ on $Q$ is one hop closer to $u$ and also sees the sub-path $Q_{z,u} \subseteq Q$ within its ball $\mathcal{B}_{z,h}$ so by Equation \eqref{eq:approx_oracle_function} $z$'s distance estimate must be at least as good: $o_z(u) \leq w(Q_{z,u}) = o_v(\lambda(u)) - w(v,z)$.
\textit{Case 2:} if $o_v(\lambda(u)) = d(v,s_u) + d(s_u,u)$, then this means our distance estimation via $s_u$ is at least as good as the $h$-hop distance to $u$ (c.f., second argument of $\min$ in Equation \eqref{eq:approx_oracle_function}). Let $Q$ be a path concatenated from two shortest paths $Q_{v,s_u} \cup Q_{s_u,u}$ from $v$ to $s_u$ and from $s_u$ to $u$, respectively.
Note that $\hop(s_u,u) \leq h$, as otherwise there would be a node $s_u' \in S$, $s_u'\neq s_u$ on $Q_{s_u,u}$ by Lemma \ref{lem:node_sampling}, which would be closer to $u$ thus contradicting the definition $s_u := \argmin_{s \in S} d(s,u)$ in the label $\lambda(u)$. This means that we can assume $v \neq s_u$ since otherwise we can apply case 1.
Let $z \in N(v)$ be the next node on $Q_{v,s_u}$ (which contains at least the 2 nodes $v$ and $s_u$, but $z = s_u$ is possible). Then
\begin{align*}
& d(v,s_u) + d(s_u,u) = w(v,z) + d(z,s_u) + d(s_u,u)\\
\Longrightarrow \quad & o_v(\lambda(u)) - w(v,z) = d(z,s_u) + d(s_u,u) \geq o_z(\lambda(u)).\hfill\qedhere
\end{align*}
\end{proof}
The following Theorem gives a summary of the obtained approximation algorithms for which we utilize the previous lemmas.
\begin{theorem}
\label{thm:approx_algo}
Distance oracles and \emph{stateless} routing schemes with label-size $\smash{\ensuremath{O}}(\log n)$ can be computed in \ensuremath{\mathsf{HYBRID}}\xspace w.h.p.\ and
\begin{itemize}
\item stretch 3 in \smash{$\smash{\ensuremath{\widetilde{O}}}(n^{1/3})$} rounds on weighted graphs,
\item stretch $1\!+\!\varepsilon$ for $0 \!<\! \varepsilon \!\leq\! 1$ in \smash{$\smash{\ensuremath{\widetilde{O}}}\big(\frac{n^{1/3}}{\varepsilon}\big)$} rounds on unweighted graphs.
\end{itemize}
\end{theorem}
\begin{proof}
The label $\lambda(v)$ contains only the distance to the closest sampled node in $S$ which is $\smash{\ensuremath{O}}(\log n)$ bits. For the first result on weighted graphs we invoke Algorithm \ref{alg:base_algo} with $x = n^{1/3}$ and $h \in \smash{\ensuremath{\widetilde{\Theta}}}(x)$ as in Lemma \ref{lem:node_sampling}, then the runtime follows from Lemma \ref{lem:base_algo_runtime} and the stretch for the resulting distance oracles follows from Lemma \ref{lem:algo-approx-weighted}. Note that by Lemma \ref{lem:stretch-routing} the same stretch holds for the resulting stateless routing scheme.
For the second result we invoke Algorithm \ref{alg:base_algo} with $x = n^{1/3}$ with a wider local exploration (by a factor $1/\varepsilon$) to distance $h = h'/\varepsilon$ whereas $h' \in \smash{\ensuremath{\widetilde{\Theta}}}(x)$ is the usual value from Lemma \ref{lem:node_sampling}. Again, the runtime follows from Lemma \ref{lem:base_algo_runtime}.
The idea is that a wider local search allows us to compute shortest paths with at most $h$ hops exactly which allows us to disregard those for proving the stretch. By Lemma \ref{lem:algo-approx-unweighted} the additive error scales only in $h'$ which is by a factor $1/\varepsilon$ smaller than $h$ and therefore has a relatively small impact on the stretch of paths longer than $h$ hops.
More precisely, if $d_{h}(v,u) = d(v,u)$ then we obtain an exact distance estimation from Equation \eqref{eq:approx_oracle_function}.
Now let $d_{h}(v,u) > d(v,u)$ meaning that all $v$-$u$-paths with at most $h$ hops are longer than $d(v,u)$ or there exists none such path. Then, due to the minimum edge weight of 1, we have $d(v,u) \geq h$.
Then by Lemma \ref{lem:algo-approx-unweighted} we have
\begin{align*}
o_v(\lambda(u)) & \leq d(v,u)\!+\!2h' W' = d(v,u)\!+\!2\varepsilon h W' \\
& \leq d(v,u)\!+\!2\varepsilon d(v,u) = d(v,u)(1\!+\!2\varepsilon)
\end{align*}
The final result is obtained with a substitution $\varepsilon':= 2\varepsilon$.
\end{proof}
|
{'timestamp': '2022-02-15T02:41:22', 'yymm': '2202', 'arxiv_id': '2202.06624', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06624'}
|
arxiv
|
\section{Introduction}
The millimeter wave (mmWave) communication over 30-300 GHz spectrum is a key technology in 5G and beyond wireless networks to provide high data-rate transmission \cite{6732923,6824746,niu2015survey}. Compared with sub-6 GHz, the high directivity at high frequency bands makes mmWave communication much more sensitive to signal blockage. One promising and cost-effective solution to overcome the blockage issue is to deploy Reconfigurable Intelligent Surfaces (RISs). An RIS is an artificial meta-surface consisting of a large number of passive reflection elements that can be programmed to electronically control the phase of the incident electromagnetic waves \cite{book,8910627}. With the help of a smart controller, RISs can be controlled to enhance the desirable signals via coherent combining, or to suppress the undesirable interference via destructive combining. RISs are spectrum- and energy-efficient since they do not require radio frequency (RF) components or dedicated energy supply. Furthermore, from the implementation perspective, RISs have appealing advantages such as low profile, light-weight, and conformal geometry. Recently, RISs have emerged as a promising technique to enhance the performance of wireless communication systems, especially in mmWave bands \cite{8796365,9122596,9086766}.
As RISs bring a new degree-of-freedom to the optimization
of beamforming design, a key issue of interest in RIS-aided wireless communication systems is to jointly design the active beamforming at the multi-antenna base stations (BSs) and the passive reflection coefficients at the RIS. There have been several prior studies investigating this problem under different system setups and assumptions \cite{ wu2019intelligent,9226616,9246254, 8741198, li2019joint, guo2020weighted}. Specifically, the work \cite{wu2019intelligent} studies the power minimization problem under the signal-to-interference-plus-noise ratio (SINR) constraints and proposes a semidefinite relaxation (SDR) based algorithm for the joint active and passive beamforming design. The work \cite{9226616} extends \cite{wu2019intelligent} to the scenario with multiple RISs and a near-optimal analytical solution is derived. The work \cite{9246254} aims to maximize the minimum weighted SINR at the users and proposes a low-complexity inexact-alternating-optimization approach. The work \cite{8741198} focuses on the energy efficiency problem under individual quality-of-service (QoS) requirements as well as maximum power constraints. Under the maximum transmit power constraints, the work \cite{li2019joint} aims to maximize the minimum SINR, and the work \cite{guo2020weighted} aims to maximize the weighted-sum-rate (WSR) of all users.
Moreover, RISs have also been studied under other communication setups, such as secure communication \cite{8723525, 9198898}, unmanned aerial vehicle (UAV) communication \cite{8959174, 9124704}, and simultaneous wireless information and power transfer (SWIPT) systems \cite{8941080, wu2020joint}.
Note that in all these works on joint active-passive beamforming design, the active beamforming at the BS is fully digital as in most of the multiple-input-multiple-output (MIMO) beamforming literature, which requires each antenna to be connected to one RF chain, and hence has a high hardware cost.
{Unlike the fully digital beamforming structure, hybrid analog and digital (A/D) beamforming at the BS is more practical in mmWave systems since it employs a reduced number of RF chains \cite{8030501,7389996}. It is therefore desirable to consider hybrid beamforming in RIS-aided mmWave communications as a cost-effective alternative. There are very few works along this line of research except \cite{ying2020gmdbased, xiu2020reconfigurable, 9234098}. In specific, the work \cite{ying2020gmdbased} considers the individual design of the digital beamformer, the analog beamformer, and the RIS phase shifts to achieve low error rate in a wideband system. The work \cite{xiu2020reconfigurable} investigates the WSR maximization in a nonorthogonal multiple access (NOMA) system by jointly designing the power allocation, the RIS phase shifts and the hybrid beamforming vector. Therein, the manifold optimization method is adopted for the design of the phase shifts at both the RIS and the analog beamformer, while the digital beamforming is obtained by the successive convex approximation (SCA) based algorithm. The work \cite{9234098} focuses on maximizing the spectral efficiency in a single-user mmWave MIMO system by jointly optimizing the RIS reflection coefficients and the hybrid beamforming vector at the BS. The manifold optimization is adopted to handle the RIS reflection coefficients, and then the digital beamforming is obtained through the singular value decomposition (SVD) of the cascaded channel.}
In this work, we consider an RIS-aided multi-user downlink mmWave system, and investigate the joint design of hybrid beamforming at the BS and reflection coefficients at the RIS. Unlike the previous works \cite{ying2020gmdbased, xiu2020reconfigurable, 9234098} which all employ the fully-connected hybrid architecture at the BS with each RF chain connected to all antenna elements, we employ the sub-connected hybrid architecture with each RF chain only connected to a disjoint subset of antenna elements. The sub-connected architecture is more appealing for its further reduced hardware cost and power consumption.
The main contributions and results of this paper are listed as follows.
\begin{itemize}
\item {We first formulate the so-called QoS problem for minimizing the total transmit power at the BS subject to individual SINR constraints at all users. The problem is highly non-convex due to the deeply coupled variables and the unit-modulus phase shifts constraints. To tackle this problem, we propose a two-layer penalty-based algorithm where the block coordinate descent (BCD) method is adopted in the inner layer to solve a penalized problem and the penalty factor is updated in the outer layer until convergence. The penalty method can decouple the optimization variables and make the problem much easier to handle. In the BCD method, considering the same unit-modulus constraints on both the BS analog beamformer and the RIS response matrix, they can be updated simultaneously by using the manifold optimization method.}
\item {In order to reduce the complexity, we propose a sequential optimization method where the RIS coefficients are obtained by maximizing the channel gain of the user with the worst channel state; the analog beamforming is obtained by minimizing the Euclidean distance between the fully digital beamforming and the hybrid beamforming; and the digital beamforming is optimally obtained by the second-order cone program (SOCP) method.}
\item {We discuss a closely related problem of the QoS problem, which is the max-min fairness (MMF) problem. The MMF problem is more difficult to solve than the QoS problem due to its non-smooth objective function. However, we can solve the MMF problem by solving a series of QoS problems.}
\end{itemize}
{Finally, we conduct comprehensive simulations to validate the performance of the proposed algorithms. It is shown that the proposed penalty-based algorithm outperforms the traditional SDR-based optimization algorithm. Results also demonstrate that the proposed hybrid beamforming at the BS can perform closely to a fully digital beamforming system. In addition, the transmit power at the BS can be greatly reduced by employing a large number of RIS elements on the BS side or the user side. Furthermore, it is sufficient for practical use when both the RIS and the analog beamformer have 3-bit quantizers.}
The rest of the paper is organized as follows. Section \ref{sec_model} introduces the RIS-aided mmWave MIMO system model, and formulates the power minimization problem. A two-layer penalty-based algorithm is proposed to solve the power minimization problem in Section \ref{sec_qos}. A low-complexity sequential optimization method is proposed in Section \ref{individual}. The relationship between the QoS problem and the MMF problem is studied in Section \ref{discussion}. Simulation results are provided in Section \ref{sec_simulation}. Finally, Section \ref{sec_conclusion} concludes this paper.
\emph{Notations}: The imaginary unit is denoted by $j=\sqrt{-1}$. Vectors and matrices are denoted by bold-face lower-case and upper-case letters, respectively.
The conjugate, transpose, conjugate transpose and pseudo-inverse of the vector $\bf x$ are denoted by $ \bf x^*$, $\mathbf{x}^T$, $\mathbf x^H$ and $\bf x^\dagger$, respectively. Further, we use $\bf I$ and $\mathbf{O}$ to denote an identity matrix and all-zero matrix of appropriate dimensions, respectively; we use $\mathbb{C}^{x\times y}$ to denote the space of $x\times y$ complex-valued matrices. The notations $\arg(\cdot)$ and $\operatorname{Re}(\cdot)$ denote the argument and real part of a complex number, respectively. The notations $\mathbb{E}(\cdot)$ and $\operatorname{Tr}(\cdot)$ denote the expectation and trace operation, respectively; $\odot$ represents the Hadamard product; $\|\cdot\|$ represents the Frobenius norm. For a vector $\mathbf{x}$, $\operatorname{diag}(\mathbf{x})$ denotes a diagonal matrix with each diagonal element being the corresponding element in $\mathbf{x}$. For a vector $\mathbf{x}$, $\nabla f(\mathbf{x}_i)$ denotes the gradient vector of function $f(\mathbf{x})$ at the point $\mathbf{x}_i$. Finally, The distribution of a circularly symmetric complex Gaussian (CSCG) random vector with mean vector $x$ and covariance matrix $\Sigma$ is denoted by $\mathcal{C}\mathcal{N}(x,\Sigma)$; and $\sim$ stands for ``distributed as''.
\section{System Model And Problem Formulation}
\label{sec_model}
\subsection{System Model}
\begin{figure}[t]
\begin{centering}
\vspace{-0.1cm}
\includegraphics[width=0.45\textwidth]{systemmodel2_2.eps}
\caption{\small{An RIS-aided downlink mmWave communication system.}}\label{fig_systemmodel}
\end{centering}
\end{figure}
As shown in Fig.~\ref{fig_systemmodel}, we consider an RIS-aided downlink mmWave communication system where one BS, equipped with $M$ antennas, communicates with $K$ single-antenna users via the help of one RIS equipped with $F$ unit cells. The BS employs the sub-connected hybrid A/D beamforming structure with $N$ RF chains, each connected to a disjoint subset of $D=M/N$ antennas. Let $s_k$ denote the information signal intended to user $k$, for $k\in \mathcal{K} \triangleq \{1, 2, \ldots,K\}$. The signals are assumed to be independent of each other and satisfy $\mathbb{E}(|s_k|^2)=1$. Each of these signals is first weighted by a digital beamforming vector, denoted as $\mathbf{w}_k\in\mathbb{C}^{N\times{1}}$. These weighted signal vectors are summed together and each entry is sent to an RF chain, then multiplied by an analog beamforming vector, denoted as $\mathbf{v}_n\in \mathbb{C}^{D\times{1}}$, for $n\in \mathcal{N}\triangleq \{1,2,\ldots,N\}$. Each entry of $\mathbf{v}_n$, denoted as ${v}_{n,d}, \forall d\in \mathcal{D}\triangleq\{1,2,\ldots,D\}$ is a phase shifter. Discrete phase shifts are considered. Denote $\mathcal{S}_a$ as the set of all possible phase shifts for the analog beamformer, given by
\begin{equation}
\mathcal{S}_{a} \triangleq \left\{e^{j\theta} \; \bigg| \; \theta \in \left\{0,\frac{2\pi}{2^{Q_1}}, \ldots, \frac{2\pi(2^{Q_1}-1)}{2^{Q_1}}\right\} \right\},
\end{equation}
where $Q_1$ is the number of control bits for each analog phase shifter. In the special case when $Q_1 = \infty$, it becomes continuous phase shifts. The overall analog beamforming matrix can be represented as
\begin{equation}
\mathbf{V}=\left[\begin{array}{cccc}
\mathbf{v}_{1} & \mathbf{0} & \cdots & \mathbf{0} \\
\mathbf{0} & \mathbf{v}_{2} & \cdots & \mathbf{0} \\
\mathbf{0} & \mathbf{0} & \ddots & \mathbf{0} \\
\mathbf{0} & \mathbf{0} & \cdots & \mathbf{v}_{N}
\end{array}\right].
\end{equation}
The total transmit power of the BS is given by
\begin{equation}
P_\text{transmit}=\sum\limits_{k=1}^{K}\Arrowvert{\mathbf{V}\mathbf{w}_k}\Arrowvert^2
=D \sum\limits_{k=1}^K \Arrowvert{\mathbf{w}_k}\Arrowvert^2.
\end{equation}
The RIS is connected to the BS through an RIS control link for transmission and information exchange. Let $\mathcal{F} \triangleq \{1,2,\ldots,F\}$ denote the set of all RIS unit cells, and define the response matrix at the RIS as
\begin{equation}
\mathbf{\Theta}= \text{diag} {(b_1,b_2,\ldots,b_F)},
\end{equation}
where $b_f=\beta_f e^{j\theta_f}, \beta_f \in [0,1]$ and $\theta_f\in{[0,2\pi)}$ are the amplitude reflection coefficient and the phase shift of the $f$-th unit cell, respectively. In this paper, we assume $\beta_f=1, \forall f \in \mathcal{F}$ to maximize the signal reflection. Denote $\mathcal{S}_{r}$ as the set of all possible phase shifts for the RIS reflection coefficients, given by
\begin{equation}
\mathcal{S}_{r} \triangleq \left\{e^{j\theta} \; \bigg| \; \theta \in \left\{0,\frac{2\pi}{2^{Q_2}}, \ldots, \frac{2\pi(2^{Q_2}-1)}{2^{Q_2}}\right\} \right\},
\end{equation}
where $Q_2$ is the number of control bits for each RIS element. Again the special case of $Q_2 = \infty$ corresponds to the continuous phase shifts.
We assume that the BS-user direct link is blocked, and thus the direct path can be ignored. {The signal power reflected two or more times is much lower than that reflected just once due to the high free-space path loss. Thus, we ignore the power of the signals that are reflected by the RIS more than once.} In addition, we assume that the channel state information (CSI) of all links involved is perfectly known at the BS and all the channels experience quasi-static flat-fading. How to obtain accurate CSI is an important and challenging issue in the RIS-aided communication system. {The CSI can be obtained through uplink pilots due to the channel reciprocity} and some early attempts can be found in \cite{chen2019channel,9103231, 9127834,9374451,9398559}. Suppose that $\mathbf{G}\in \mathbb{C}^{F \times M}$ is the channel matrix from the BS to the RIS, $\mathbf{h}_{k}^{H} \in\mathbb{C}^{1\times{F}}$ is the channel vector from the RIS to user $k$. Then the received signal of user $k$ can be represented as
\begin{equation}
y_k=\mathbf{h}_{k}^{H}\mathbf{\Theta}\mathbf{G}\mathbf{V}\sum\limits_{j=1}^{K}{\mathbf{w}_js_j}+n_k, \forall{k}\in\mathcal{K},
\end{equation}
where $n_k\thicksim\mathcal{C}\mathcal{N}{(0, \sigma_k^2)}$ is the additive white Gaussian noise at the receiver of user $k$ with zero mean and variance $\sigma^2_k$. The received SINR of user $k$ can be expressed as
\begin{equation}
\text{SINR}_k=\frac{\arrowvert{\mathbf{h}_{k}^H\mathbf{\Theta}\mathbf{G}\mathbf{V}\mathbf{w}_k} \arrowvert^2}{\sum\limits_{j\not=k}\arrowvert{\mathbf{h}_{k}^H\mathbf{\Theta}\mathbf{G} \mathbf{V}\mathbf{w}_j}\arrowvert^2+\sigma_k^2}, \forall{k}\in\mathcal{K}.
\end{equation}
\subsection{mmWave Channel Model}
We adopt the widely used narrowband clustered channel model \cite{6717211} for mmWave communications. Specifically, the channel matrix between the BS and the RIS can be written as
\begin{equation}
\mathbf{G}={\sqrt{\frac{MF}{{N_\text{cl}}_1{N_\text{ray}}_1}} \sum \limits_{i=1}^{{N_\text{cl}}_1} \sum\limits_{l=1}^{{N_\text{ray}}_1} \alpha_{il}\mathbf{a}_R(\phi_{il}^{Rr}, \delta_{il}^{Rr})\mathbf{a}_B(\phi_{il}^{B}, \delta_{il}^{B})^H}.
\end{equation}
Here, ${N_\text{cl}}_1$ denotes the number of scattering clusters, ${N_\text{ray}}_1$ denotes the number of rays in each cluster, and $\alpha_{il}$ denotes the channel coefficient of the $l$-th ray in the $i$-th propagation cluster. Moreover, $\mathbf{a}_R(\phi_{il}^{Rr},\delta_{il}^{Rr})$ and $\mathbf{a}_B(\phi_{il}^B,\delta_{il}^B)$ represent the receive array response vectors of the RIS and the transmit array response vectors of the BS respectively, where $\phi_{il}^{Rr}(\phi_{il}^{B})$ and $\delta_{il}^{Rr}(\delta_{il}^B)$ represent azimuth and elevation angles of arrival at the RIS (or departing from the BS).
The channel vector between the RIS and the $k$-th user can be represented as
\begin{equation}
\mathbf{h}_{k}=\sqrt{\frac{F}{{N_\text{cl}}_2{N_\text{ray}}_2}} \sum \limits_{i=1}^{{N_\text{cl}}_2} \sum\limits_{l=1}^{{N_\text{ray}}_2} \beta_{il}\mathbf{a}_R(\phi_{il}^{Rt},\delta_{il}^{Rt}).
\end{equation}
Here, ${N_\text{cl}}_2$, ${N_\text{ray}}_2$, $\beta_{il}$, $\phi_{il}^{Rt}$ and $\delta_{il}^{Rt}$ are defined in the same way as above.
In this paper, we consider the uniform planar array (UPA) structure at both BS and RIS. Consequently, the array response vector can be denoted as
\begin{equation}
\begin{aligned}
\label{upa}
\mathbf{a}_{{z}}\left(\phi, \delta\right)= & \frac{1}{\sqrt{A_1 A_2}}\left[1, \ldots, e^{j \frac{2 \pi}{\lambda} d_1 \left(o \sin \phi \sin \delta+p \cos \delta\right)}\right.\\
& \left.\ldots, e^{j \frac{2 \pi}{\lambda} d_1 \left((A_1-1) \sin \phi \sin \delta)+(A_2-1) \cos \delta\right)}\right]^{T},
\end{aligned}
\end{equation}
where ${z} \in \{R,B\}$, $\lambda$ is the signal wavelength, $d$ is the antenna or unit cell spacing which is assumed to be half wavelength distance, $0\leq{o}<A_1$ and $0\leq{p}<A_2$, $A_1$ and $A_2$ represent the number of rows and columns of the UPA in the 2D plane, respectively.
\subsection{Problem Formulation}
\label{pro_formulation}
We consider the QoS problem which aims to minimize the transmit power at the BS by jointly optimizing the digital beamforming matrix $\mathbf{W}=\left[\mathbf{w}_1, \mathbf{w}_2,\ldots,\mathbf{w}_K \right]\in \mathbb{C}^{N\times K}$ and the analog beamforming matrix $\mathbf{V}$ at the BS, as well as the overall response matrix $\mathbf{\Theta}$ at the RIS, subject to QoS constraints for all users. The problem can be formulated as
\begin{subequations}\label{prob_original}
\begin{align}
{\mathcal{P}_0: \quad \min \limits_{\{\mathbf{V},\mathbf{W},\mathbf{\Theta}\}}} \quad & {D\sum \limits_{k=1}^{K}\left\| \mathbf{w}_{k}\right\|^{2}} \\
{\text { s.t. }}\quad\quad & {\text{SINR}_{k} \geq \gamma_{k}, \forall k\in\mathcal{K}}, \label{const1}\\
{}&{{v}_{n,d} \in \mathcal{S}_{a}, \forall n \in \mathcal{N}, \forall d \in \mathcal{D}}, \label{const2}\\
{}&{ b_f \in \mathcal{S}_{r}, \forall f \in \mathcal{F}}, \label{const3}
\end{align}
\end{subequations}
where $\gamma_k>0$ is the minimum SINR requirement of user $k$.
The problem $\mathcal{P}_0$ is highly non-convex due to the non-convex SINR constraints \eqref{const1} and the unit-modulus phase shifts constraints \eqref{const2}, \eqref{const3}, and thus difficult to be optimally solved. A commonly used approach to solve such problem approximately is to apply the BCD technique in conjunction with the SDR method as in \cite{wu2019intelligent,9148827}. The BCD technique updates just one block of variables while fixing all the others at a time. In particular, at each iteration, the digital beamforming matrix can be solved via SOCP, while both the analog beamforming matrix and the RIS response matrix can be solved via SDR. Note that SDR cannot guarantee the feasibility due to the rank-one constraint and thus an additional randomization procedure is generally needed. Its complexity is high for the large RIS size. In addition, when the number of users is close to the number of RF chains, the above approach may become invalid because the randomization procedure may fail to find a feasible solution even after a large number of randomization. In this work, we propose a two-layer penalty-based algorithm to solve the problem $\mathcal{P}_0$ as detailed in the next section.
\section{Penalty-based Joint Optimization Algorithm}
\label{sec_qos}
In this section, we propose a two-layer penalty-based method by exploiting the penalty method, where the BCD method is adopted in the inner layer to solve a penalized problem and the penalty factor is updated in the outer layer until convergence. Specifically, we firstly introduce auxiliary variables $\{t_{k,j}\}$ to represent $ \mathbf{h}_{k}^{H} \mathbf{\Theta} \mathbf{G} \mathbf{V} \mathbf{w}_j$ such that the variables $\mathbf{W}$, $\mathbf{V}$ and $\mathbf{\Theta}$ can be decoupled. Then, the non-convex constraints \eqref{const1} can be equivalently written as
\begin{subequations}
\begin{align}
{\frac{ \left| t_{k,k} \right|^{2}} {\sum_{j \neq k}^{K}\left| t_{k,j} \right|^{2}+\sigma_{k}^{2}} \geq \gamma_{k}, \forall k \in \mathcal{K},}\label{penalty_ori_const1}\\
{t_{k,j}= \mathbf{h}_{k}^{H} \mathbf{\Theta} \mathbf{G} \mathbf{V} \mathbf{w}_j}, \forall k,j \in \mathcal{K}. \label{penalty_ori_const2}
\end{align}
\end{subequations}
Then, the equality constraints \eqref{penalty_ori_const2} can be relaxed and added to the objective function as a penalty term. Thereby, the original problem $\mathcal{P}_0$ can be converted to the following penalized problem
\begin{subequations} \label{penalty_prob}
\begin{align}
{\mathcal{P}_1(\rho):} {\min \limits_{\small{\mathbf{V}, \mathbf{W}, \mathbf{\Theta},\{t_{k,j}\}}}} \quad & D \sum \limits_{k=1}^{K}\left\| \mathbf{w}_{k}\right\|^{2} \notag \\
&+ \frac{\rho}{2} \sum \limits_{j=1}^K \sum \limits_{k=1}^K \left| \mathbf{h}_{k}^{H} \mathbf{\Theta} \mathbf{G} \mathbf{V} \mathbf{w}_j-t_{k,j} \right|^2 \\
{\text { s.t. }}\quad\qquad & {\eqref{penalty_ori_const1},\eqref{const2},\eqref{const3} },
\end{align}
\end{subequations}
where $\rho>0$ is the penalty factor.
Generally, the choice of $\rho$ is crucial to balance the original objective function and the equality constraints. It is seen that the objective function in $\mathcal{P}_1(\rho)$ is dominated by the penalty term when $\rho$ is large enough and consequently the equality constraints \eqref{penalty_ori_const2} can be well met by the solution. Therefore, we can start with a small value of $\rho$ to get a good starting point, and then by gradually increasing $\rho$, a high precision solution can be obtained.
{There are mainly two different methods to handle the discrete phase shifts. First, the optimal solution can be found by the exhaustive search method \cite{8930608}. However, its complexity is too high to be practical. The second method is to relax the discrete phases to continuous ones and then apply projection \cite{9226616,9133142}. As such, in the rest of the paper, we adopt the projection method. Specifically, we first relax the discrete phase shifts of analog beamforming and RIS coefficients to continuous ones, then solve the relaxed problem with the proposed algorithms, finally project the obtained continuous solution back to the discrete set.}
\subsection{Inner Layer: BCD Algorithm for Solving Problem $\mathcal{P}_1(\rho)$}
\label{sec3a}
For any given $\rho$, though the problem $\mathcal{P}_1(\rho)$ is still non-convex, all the optimization variables $\{\mathbf{W}, \{\mathbf{\Theta}, \mathbf{V}\}, \{t_{k,j}\}\}$ are decoupled in the constraints. We therefore adopt the BCD method to optimize each of them alternately.
\subsubsection{Optimize $\mathbf{W}$}
When $\mathbf{V}$, $\mathbf{\Theta}$ and $\{t_{k,j}\}$ are fixed, problem $\mathcal{P}_1(\rho)$ becomes an unconstrained convex problem. Consequently, the optimal $\mathbf{W}$ can be obtained by the first-order optimality condition, i.e.,
\begin{equation}\label{penalty_optimw}
\mathbf{w}_k=\rho \mathbf{A}_1^{-1} \sum \limits_{j=1}^K \tilde{\mathbf{h}}_j^H t_{j,k}, \forall k \in \mathcal{K},
\end{equation}
where $ \tilde{\mathbf{h}}_j=\mathbf{h}_{ j}^{H} \mathbf{\Theta} \mathbf{G} \mathbf{V}$ and $\mathbf{A}_1=2D \mathbf{I}_N + \rho \sum \limits_{j=1}^K \tilde{\mathbf{h}}_j^H \tilde{\mathbf{h}}_j$.
\subsubsection{{Optimize $\{\mathbf{\Theta},\mathbf{V}\}$}}
\label{manifold_b}
Let $\mathbf{b}\triangleq[b_1,b_2,\ldots,b_F]^{H}$,
$
\mathbf{x} \triangleq\left[\mathbf{v}_{1}^{T}, \mathbf{v}_{2}^{T}, \ldots, \mathbf{v}_{N}^{T}\right]^{T} \in \mathbb{C}^{M\times 1},
$
and
$
\mathbf{Y}_j \triangleq \text{diag}\{{w}_{ j,1}\mathbf{I}_D, \ldots, {w}_{ j,N}\mathbf{I}_D \} \in \mathbb{C}^{M\times M},
$
where $\left|{x}_m\right| = 1, \forall m\in \mathcal{M}\triangleq \{1,2,\ldots,M\}$ and ${w}_{j,n}$ denotes the $n$-th entry of $\mathbf{w}_j$. Then, we can rewrite $\mathbf{V} \mathbf{w}_j=\mathbf{Y}_j \mathbf{x} \in \mathbb{C}^{M\times 1}$ so that the optimization problem is formulated in term of $(\mathbf{b},\mathbf{x})$.
When the digital beamforming matrix $\mathbf{W}$ and the auxiliary variables $\{t_{k,j}\}$ are fixed, the problem $\mathcal{P}_1(\rho)$ is reduced to (with constant terms ignored)
\begin{subequations}\label{optimy1}
\begin{align}
{\min \limits_{\mathbf{b},\mathbf{x} }} &\quad {f(\mathbf{b},\mathbf{x}) =\sum \limits_{j=1}^{K} \sum \limits_{k=1}^{K}\left|\mathbf{b}^{H} \mathbf{c}_{k, j}\mathbf{x}-t_{k, j}\right|^{2}} \\
{\text { s.t. }} &\quad {|b(f)|=1, \forall f \in \mathcal{F}},\label{opty_const1}\\
& \quad{|x(m)|=1, \forall m \in \mathcal{M}},
\end{align}
\end{subequations}
where $\mathbf{c}_{k,j}=\text{diag} (\mathbf{h}_{k}^H) \mathbf{G} \mathbf{Y}_j \in \mathbb{C}^{F\times M}$. In the following, we would like to adopt three different methods to tackle the problem \eqref{optimy1}.
\textbf{\emph{Method One: Alternating Optimization}}
The first idea is to alternately optimize one of the variables $\mathbf{b}$ and $\mathbf{x}$ while keeping the other fixed. When $\mathbf{x}$ is fixed, the main obstacles of the problem \eqref{optimy1} lie in the unit-modulus phase shifts constraints \eqref{opty_const1}. Note that they form a complex circle manifold $\mathcal{M}= \{\mathbf{b}\in \mathbb{C}^F: |b_1|=\cdots=|b_F|=1\}$ \cite{absil2009optimization}. Therefore, the problem \eqref{optimy1} can be efficiently solved by the manifold optimization technique. In specific, we adopt the Riemannian conjugate gradient (RCG) algorithm. The RCG algorithm is widely applied in hybrid beamforming design \cite{yu2016alternating} and recently applied in RIS-aided systems as well \cite{yu2019miso},\cite{guo2020weighted}. In the following we briefly review the general procedure of the RCG algorithm.
Each iteration of the RCG algorithm involves four key steps, namely, to compute the Riemannian gradient, to do the transport, to find the search direction and to do the retraction.
Denote ${f(\mathbf{b}) =\sum \limits_{j=1}^{K} \sum \limits_{k=1}^{K}\left|\mathbf{b}^{H} \mathbf{c}_{k, j}\mathbf{x}-t_{k, j}\right|^{2}}$. For any given point $\mathbf{b}_i$, the Riemannian gradient $\operatorname{grad} f(\mathbf{b}_i)$ is defined as the orthogonal projection of the Euclidean gradient $\nabla f(\mathbf{b}_i)$ onto the tangent space ${T}_{\mathbf{b}_i} \mathcal{M}$ of the manifold $\mathcal{M}$ at point $\mathbf{b}_i$, which can be expressed as
\begin{equation}
T_{\mathbf{b}_i} \mathcal{M}=\left\{\mathbf{b} \in \mathbb{C}^{F}: \operatorname{Re}\left\{\mathbf{b} \odot \mathbf{b}_i^{*}\right\}=\mathbf{0}_{F}\right\}.
\end{equation}
The Euclidean gradient at the point $\mathbf{b}_i$ is given by
\begin{equation}
\nabla f(\mathbf{b}_i) = 2\sum \limits_{j=1}^K \sum \limits_{k=1}^K \mathbf{c}_{k,j} \mathbf{x} (\mathbf{x}^H \mathbf{c}_{k,j}^H \mathbf{b} - t_{k,j}^H).
\end{equation}
Then, the Riemannian gradient at the point $\mathbf{b}_i$ is given by
\begin{equation} \label{grad}
\operatorname{grad} f(\mathbf{b}_i)=\nabla f(\mathbf{b}_i) -\operatorname{Re}\left\{\nabla f(\mathbf{b}_i) \odot \mathbf{b}_i^*\right\} \odot \mathbf{b}_i.
\end{equation}
With the Riemannian gradient, the optimization technique in the Euclidean space can be extended to the manifold space. Here, we adopt the conjugate gradient method, where the search direction can be updated by
\begin{equation} \label{direction}
\boldsymbol{\eta}_{i+1}=-\operatorname{grad} f(\mathbf{b}_{i+1})+\lambda_1 \mathcal{T}_{\mathbf{b}_{i} \rightarrow \mathbf{b}_{i+1}}\left(\boldsymbol{\eta}_{i}\right),
\end{equation}
where $\boldsymbol{\eta}_i$ is the search direction at $\mathbf{b}_i$, $\lambda_1$ is the update parameter chosen as the Polak-Ribiere parameter \cite{absil2009optimization}, and $\mathcal{T}_{\mathbf{b}_{i} \rightarrow \mathbf{b}_{i+1}}\left(\boldsymbol{\eta}_{i}\right)$ is the transport operation. Note that $\boldsymbol{\eta}_i$ and $\boldsymbol{\eta}_{i+1}$ lie in different tangent spaces and they cannot be conducted directly. Therefore, the transport operation $\mathcal{T}_{\mathbf{b}_{i} \rightarrow \mathbf{b}_{i+1}}\left(\boldsymbol{\eta}_{i}\right)$ is needed to map the previous search direction from its original tangent space to the current tangent space at the current point $\mathbf{b}_{i+1}$. The transport operation is given by
\begin{equation} \label{transport}
\begin{aligned}
\mathcal{T}_{\mathbf{b}_{i} \rightarrow \mathbf{b}_{i+1}}\left(\boldsymbol{\eta}_{i}\right) : T_{\mathbf{b}_{i}} \mathcal{M} & \mapsto T_{\mathbf{b}_{i+1}} \mathcal{M}: \\
\boldsymbol{\eta}_{i} & \mapsto \boldsymbol{\eta}_{i}-\operatorname{Re}\left\{\boldsymbol{\eta}_{i} \odot \mathbf{b}_{i+1}^{*}\right\} \odot \mathbf{b}_{i+1}.
\end{aligned}
\end{equation}
Since the updated point may leave the previous manifold space, a retraction operation $\operatorname{Retr}_{\mathbf{b}}(\lambda_2 \boldsymbol{\eta}_i)$ is needed to project the point back to the manifold:
\begin{equation} \label{retraction}
\begin{aligned}
\operatorname{Retr}_{\mathbf{b}_i}(\lambda_2 \boldsymbol{\eta}_i) : T_{\mathbf{b}_{i}} \mathcal{M} & \mapsto \mathcal{M}: \\
\lambda_2 \boldsymbol{\eta}_{i} & \mapsto \frac{\left(\mathbf{b}_i+\lambda_{2} \boldsymbol{\eta}_{i}\right)_{j}}{\left|\left(\mathbf{b}_i+\lambda_{2} \boldsymbol{\eta}_{i}\right)_{j}\right|},
\end{aligned}
\end{equation}
where $\lambda_2$ is the Armijo backtracking line search step size, and $(\mathbf{b}_i+\lambda_{2} \boldsymbol{\eta}_{i})_j$ denotes the $j$-th entry of $\mathbf{b}_i+\lambda_{2} \boldsymbol{\eta}_{i}$.
The key steps are introduced above, and the consequent algorithm for solving the problem \eqref{optimy1} with fixed $\mathbf{x}$ is summarized in \textit{Algorithm} \ref{rcg}. \textit{Algorithm} \ref{rcg} is guaranteed to converge to a stationary point \cite{absil2009optimization}.
When $\mathbf{b}$ is fixed, $\mathbf{x}$ can be also updated similarly by the RCG algorithm.
\begin{algorithm}[t]
\caption{RCG Algorithm for solving problem \eqref{optimy1} with fixed $\mathbf{x}$}
\label{rcg}
\hspace*{0.02in} {\bf Input:} $\{\mathbf{c}_{k,j}\}$, $\mathbf{x}$, $\mathbf{b}_0 \in \mathcal{M}$
\begin{algorithmic}[1]
\State Calculate $\boldsymbol{\eta}_0= -\operatorname{grad} f(\mathbf{b}_0)$ according to \eqref{grad} and set $i=0$;
\Repeat
\State Choose the Armijo backtracking line search step size $\lambda_2$;
\State Find the next point $\mathbf{b}_{i+1}$ using retraction according to \eqref{retraction};
\State Calculate the Riemannian gradient $\operatorname{grad} f(\mathbf{b}_{i+1})$ according to \eqref{grad};
\State Calculate the transport $\mathcal{T}_{\mathbf{b}_{i} \rightarrow \mathbf{b}_{i+1}} \left(\boldsymbol{\eta}_{i}\right)$ according to \eqref{transport};
\State Choose the Polak-Ribiere parameter $\lambda_1$;
\State Calculate the conjugate direction $\boldsymbol{\eta}_{i+1}$ according to \eqref{direction};
\State $i \leftarrow i+1$;
\Until $\|\operatorname{grad} f(\mathbf{b}_i)\|_2 \leq \epsilon_1$.
\end{algorithmic}
\end{algorithm}
\textbf{\emph{Method Two: RCG-based Joint Optimization}}
Note that both $\mathbf{b}$ and $\mathbf{x}$ of the problem \eqref{optimy1} are subject to unit-modulus constraints. Thus we can concatenate them and treat as a higher-dimensional vector subject to the same unit-modulus constraints. Specifically, let $\mathbf{z}=\left[\mathbf{b}^H, \mathbf{x}^H\right]^H \in \mathbb{C}^ {(F+M)\times 1}$, and we can rewrite the problem \eqref{optimy1} as follows
\begin{subequations} \label{penalty_optimb}
\begin{align}
{\min \limits_{\mathbf{z}}} \quad & { f(\mathbf{z})=\sum \limits_{j=1}^{K} \sum \limits_{k=1}^{K}\left| \mathbf{z}^H \mathbf{d}_{k,j} \mathbf{z}-t_{k,j} \right|^2} \label{penalty_obtimb_obj}\\
{\text { s.t. }} \quad & { |z(i)|=1, \forall i \in \mathcal{Z}}\label{unitm},
\end{align}
\end{subequations}
where $\mathbf{d}_{k,j}=\left[\begin{array}{l}
\mathbf{I}_{F \times F} \\
\mathbf{O}_{M \times F}
\end{array}\right] \mathbf{c}_{k, j}\left[\mathbf{O}_{M \times F}\quad \mathbf{I}_{M \times M}\right] \in \mathbb{C}^{(M+F)\times (M+F)}$ and $\mathcal{Z}\triangleq \{1,2, \ldots, F+M\}$.
{The Euclidean gradient of the function $f(\mathbf{z})$ is given by}
\begin{equation}
\nabla f(\mathbf{z})=\left[\begin{array}{c}
2 \sum \limits_{j=1}^{K} \sum_{k=1}^{K} \mathbf{c}_{k, j} \mathbf{x}\left(\mathbf{x}^{H} \mathbf{c}_{k, j}^{H} \mathbf{b}-t_{k, j}^{H}\right) \\
2 \sum \limits_{j=1}^{K} \sum_{k=1}^{K} \mathbf{c}_{k,j}^{H} \mathbf{b}\left(\mathbf{b}^{H} \mathbf{c}_{k, j} \mathbf{x}-t_{k,j}\right)
\end{array}\right].
\end{equation}
Therefore, the problem \eqref{penalty_optimb} can be effectively solved by the RCG algorithm.
Note that the objective function of the problem \eqref{optimy1} is convex over $\mathbf{b}$ or $\mathbf{x}$. In the alternating optimization, the subproblem is reduced to an unconstrained convex problem in the manifold space. Therefore, the optimal solution can be obtained for each subproblem by the RCG algorithm. However, the function $f(\mathbf{z})$ is not jointly convex in $\mathbf{b}$ and $\mathbf{x}$. Thus, in the RCG-based joint optimization, only the sub-optimal solution can be obtained.
\textbf{\emph{Method Three: SCA-based Joint Optimization}}
The RCG algorithm requires multiple projections. If we directly optimize the phase shifts, the projection procedure is no longer needed. Then the problem \eqref{penalty_optimb} becomes an unconstraint non-convex problem, i.e.,
\begin{equation} \label{ques2}
\begin{array}{cc}
{\min \limits_{\bs\phi}} & {f(\bs\phi)=\sum \limits_{j=1}^K \sum \limits_{k=1}^K \left| (e^{j\bs\phi})^H\mathbf{d}_{k,j} e^{j\bs\phi}
- t_{k,j} \right|^2},
\end{array}
\end{equation}
where $\bs{\phi}=\angle{\mathbf{z}}$. Though the above problem is still difficult to solve optimally, we only need to solve its surrogate problem by exploiting the SCA technique, and the BCD method will converge to a stationary solution \cite{razaviyayn2013unified}. Specifically, denote the surrogate function for $f(\bs\phi)$ by $g(\bs \phi, \bar{\bs\phi})$. Then, $\bs\phi$ can be updated by solving the following surrogate problem
\begin{equation}
\bs\phi=\arg \min \limits_{\bs\phi \in \mathbb{R}^{F+M}} g(\bs \phi, \bar{\bs\phi}).
\end{equation}
The surrogate function $g(\bs \phi, \bar{\bs\phi})$ needs to satisfy following the two constraints \cite[Proposition 1]{razaviyayn2013unified}:
\begin{subequations}
\begin{align}
g(\bar{\bs\phi}, \bar{\bs\phi})=f(\bar{\bs \phi}), \\
g(\bs \phi, \bar{\bs \phi}) \geq f (\bs \phi). \label{surrogate2}
\end{align}
\end{subequations}
We can construct the surrogate function by the second order Taylor expansion:
\begin{equation}
g(\bs\phi, \bar{\bs\phi})=f (\bar{\bs\phi})+\nabla f (\bar{\bs\phi})^{T} (\bs\phi-\bar{\bs\phi})+\frac{1}{2\kappa}\|\bs\phi-\bar{\bs\phi}\|^{2},
\end{equation}
where $\nabla f (\bar{\bs\phi})$ is the gradient, and $\kappa$ is chosen to satisfy \eqref{surrogate2} locally within a bounded feasible set. Then, $\bs \phi$ is updated by
\begin{equation}
\bs \phi = \bar{\bs\phi}- \kappa \nabla f(\bar{\bs\phi}).
\end{equation}
In practice, the parameter $\kappa$ can be determined by the Armijo rule:
\begin{equation}\label{bu}
f(\bar{\bs\phi})- f(\bs\phi) \geq \zeta\kappa \|\nabla f(\bar{ \bs\phi}) \|^2,
\end{equation}
where $0<\zeta<0.5$, $\kappa$ is the largest element in $\{\beta\kappa_0^i\}_{i=0,1,\ldots}$ that makes \eqref{bu} satisfied, $\beta>0$ and $0<\kappa_0<1$.
\subsubsection{Optimize $\{t_{k,j}\}$}
With other variables fixed, problem $\mathcal{P}_1(\rho)$ can be reduced to
\begin{subequations} \label{penalty_t}
\begin{align}
{\min \limits_{\{t_{k,j}\}}} \quad & { \sum \limits_{j=1}^K \sum \limits_{k=1}^K \left| \mathbf{h}_{k}^{H} \mathbf{\Theta} \mathbf{G} \mathbf{V} \mathbf{w}_j-t_{k,j} \right|^2} \\
{\text { s.t. }} \quad & {\frac{ \left| t_{k,k} \right|^{2}} {\sum_{j \neq k}^{K}\left| t_{k,j} \right|^{2}+\sigma_{k}^{2}} \geq \gamma_{k}, \forall k \in \mathcal{K}}\label{22}.
\end{align}
\end{subequations}
The objective function is convex over $\{t_{k,j}\}$. Although the constraints \eqref{22} are non-convex, they can be translated to the form of second-order cones as follows,
\begin{equation}
\sqrt{1+\frac{1}{\gamma_k}}t_{k,j} \geq \left\|\begin{array}{c}
\mathbf{A}_2^{H} \mathbf{e}_{k} \\
\sigma_{k}
\end{array}\right\|_{2}, \forall k \in \mathcal{K},
\end{equation}
where $\mathbf{A}_2\in \mathbb{C}^{K \times K}$ denotes a matrix with the entry in its $k$-th row and $j$-the column being $t_{k,j}$, i.e., $\mathbf{A}_2[k,j]=t_{k,j}$, and $\mathbf{e}_k\in \mathbb{C}^{K\times 1}$ denotes a vector with the $k$-th entry being one and others being zeros. Then, the problem \eqref{penalty_t} can be effectively and optimally solved by the SOCP method \cite{1561584}.
\subsection{Outer Layer: Update Penalty Factor}
The penalty factor $\rho$ is initialized to be a small number to find a good starting point, then gradually increased to tighten the penalty. Specifically,
\begin{equation}\label{penalty_rho}
\rho:=\frac{\rho}{c}, 0 <c <1,
\end{equation}
where $c$ is a constant scaling parameter. A larger $c$ may lead to a more precise solution with a longer running time.
\subsection{Algorithm}
\begin{algorithm}[t]
\caption{Penalty-based Optimization Algorithm}
\label{alg_penalty}
\begin{algorithmic}[1]
\State Initialize $\mathbf{V}$, $\mathbf{\Theta}$, $\rho$ and $\{t_{k,j}\},\forall k,j \in \mathcal{K}$.
\Repeat
\Repeat
\State Update $\mathbf{W}$ by \eqref{penalty_optimw};
\State Update $\mathbf{\Theta}$ and $\mathbf{V}$ by solving problem \eqref{optimy1};
\State Update $\{t_{k,j}\}$ by solving problem \eqref{penalty_t};
\Until The decrease of the objective value of problem $\mathcal{P}_1(\rho)$ is below threshold $\epsilon_2>0$.
\State Update $\rho$ by \eqref{penalty_rho}.
\Until The stopping indicator $\xi$ in \eqref{stop_criteria} is below threshold $\epsilon_3>0$.
\State Project $\mathbf{\Theta}$ and $\mathbf{V}$ onto the discrete sets $\mathcal{S}_{r}$ and $\mathcal{S}_{a}$, respectively;
\State Update $\mathbf{W}$ by solving problem \eqref{inde_w} with the projected $\mathbf{\Theta}$ and $\mathbf{V}$.
\end{algorithmic}
\end{algorithm}
The overall penalty-based optimization algorithm is summarized in \textit{Algorithm} \ref{alg_penalty}. Define the stopping indicator $\xi$ as follows,
\begin{equation}\label{stop_criteria}
\xi \triangleq \max \left\{ | \mathbf{h}_{k}^{H} \mathbf{\Theta} \mathbf{G} \mathbf{V} \mathbf{w}_j-t_{k,j} |^2, \forall k,j \in \mathcal{K} \right\}.
\end{equation}
When $\xi$ is below a pre-defined threshold $\epsilon_3>0$, the equality constraints \eqref{penalty_ori_const2} are considered to be satisfied and the proposed algorithm is terminated. Since we start with a small penalty and gradually increase its value, the objective value of problem $\mathcal{P}_1(\rho)$ is finally determined by the penalty part and the equality constraints are guaranteed to be satisfied. {Note that, for any given penalty factor $\rho$, the objective value of the problem $\mathcal{P}_1(\rho)$ solved through the BCD method is non-increasing over iterations in the inner layer. And the optimal value of the problem $\mathcal{P}_1(\rho)$ is bounded by the SINR constraints. Thereby, based on the \textit{Theorem 4.1} of the work \cite{7558213}, the proposed \textit{Algorithm} \ref{alg_penalty} is guaranteed to converge.}
{Let us consider the complexity of the proposed algorithm. Let us first compare the complexities of the three different methods, which are dominated by computing the Euclidean gradient. Thus, the complexity of Alternating Opt is $\mathcal{O}(I_\mathbf{b} K^2 F+ I_\mathbf{x} K^2 M)$, where $I_\mathbf{b}$ and $I_\mathbf{x}$ denote the required iteration times of the RCG algorithm to update $\mathbf{b}$ and $\mathbf{x}$, respectively. The complexity of RCG-based Joint Opt is $\mathcal{O}(I_\mathbf{z} K^2 (F+M))$, where $I_\mathbf{z}$ denotes the required iteration times of the RCG algorithm to update $\mathbf{z}$. The complexity of SCA-based Joint Opt is $\mathcal{O}(I_a K^2 (F+M))$, where $I_a$ denotes the iteration number of the Armijo search. As will be shown in Section \ref{simulation_methods}, the RCG-based joint optimization method outperforms the other two methods. Thus, we adopt the RCG-based joint optimization method and analyze its complexity. It can be shown that the complexity of computing $\mathbf{W}$ in \eqref{penalty_optimw} is $\mathcal{O}(N^3+KN^2 +K^2N)$. Besides, the complexity of solving problem \eqref{penalty_t} is $\mathcal{O}(K^{3.5})$. Thereby, the overall complexity of \textit{Algorithm} \ref{alg_penalty} is $\mathcal{O}(I_{out}I_{in}(N^3+KN^2 +K^2N +I_{\mathbf{z}}K^2 (F+M) +K^{3.5}))$ where $I_{out}$ and $I_{in}$ denote the outer and inner iteration times required for convergence, respectively.}
\section{Sequential Optimization}
\label{individual}
{To reduce the complexity of solving the problem $\mathcal{P}_0$, we develop a sequential optimization approach in this section. Specifically, we first optimize the RIS response matrix $\mathbf{\Theta}$, then optimize the analog beamformer $\mathbf{V}$, and finally optimize the digital beamformer $\mathbf{W}$ without iteration.}
\subsection{RIS Design}
\label{ris_design}
Looking at the SINR constraints \eqref{const1}, and we can get
\begin{equation}\label{ris1}
|\mathbf{h}_k^H \mathbf{\Theta} \mathbf{G}\mathbf{V}\mathbf{w}_k| - \gamma_k \sum _{j\not=k} |\mathbf{h}_{k}^H \mathbf{\Theta} \mathbf{G} \mathbf{V}\mathbf{w}_j| \geq 0, \forall k \in \mathcal{K}.
\end{equation}
For simplicity, let the transmit beamforming vectors at the BS be set based on the maximum-ratio transmission (MRT) principle, i.e., $\mathbf{V}\mathbf{w}_k= (\mathbf{h}_k^H \mathbf{\Theta} \mathbf{G})^H$. {Note that the transmit beamforming vectors here are only used to extract the optimization of the RIS response matrix. The actually adopted transmit beamforming vectors are designed later.} Then, the problem \eqref{ris1} is translated to
\begin{equation}\label{ris2}
\|\mathbf{h}_k^H \mathbf{\Theta} \mathbf{G}\|^2 - \gamma_k \sum _{j\not=k} \|\mathbf{h}_{k}^H \mathbf{\Theta} \mathbf{G} \mathbf{G}^H \mathbf{\Theta}^H \mathbf{h}_j\| \geq 0, \forall k \in \mathcal{K}.
\end{equation}
{The inequality \eqref{ris2} should be satisfied for all users. Therefore, in order to ensure the receive signal quality of each user, we maximize the worst case of the left-hand side of \eqref{ris2} among all users, i.e.,}
\begin{subequations}\label{max_min_ris}
\begin{align}
{\max \limits_{\mathbf{\Theta}}}\quad &{\min \limits_{k\in \mathcal{K}} \ \|\mathbf{h}_k^H \mathbf{\Theta} \mathbf{G}\|^2 - \gamma_k \sum _{j\not=k} \|\mathbf{h}_{k}^H \mathbf{\Theta} \mathbf{G} \mathbf{G}^H \mathbf{\Theta}^H \mathbf{h}_j\|} \\
{\text { s.t. }}\quad & {b_f \in \mathcal{S}_{r}, \forall f \in \mathcal{F}}.
\end{align}
\end{subequations}
The SDR technique can be adopted to solve the above problem. Specifically, let us introduce an auxiliary variable $\varpi$, and let $\mathbf{B}=\mathbf{b}\mathbf{b}^H$. After dropping the rank-one constraint, the problem \eqref{max_min_ris} can be relaxed into
\begin{subequations}\label{max_min_ris2}
\begin{align}
{\max \limits_{\mathbf{B}, \varpi}}\quad &{\varpi} \\
{\text { s.t. }} \quad& { \text{Tr}(\mathbf{\eta}_k \eta_k^H \mathbf{B}) \geq \varpi + \gamma_k \sum \limits_{j\not=k} \|\text{Tr}(\zeta_{k,j} \mathbf{B})\|, \forall k \in \mathcal{K}, }\\
{}&{\mathbf{B}_{f,f}=1, \forall f \in \mathcal{F}},\\
{}&{\mathbf{B} \succeq 0, }
\end{align}
\end{subequations}
where $\eta_k=\text{diag}(\mathbf{h}_k^H)\mathbf{G}\in \mathbb{C}^{F\times M}$ and $\zeta_{k,j}=\text{diag}(\mathbf{h}_k^H) \mathbf{G} \mathbf{G}^H \text{diag}(\mathbf{h}_j) \in \mathbb{C}^{F\times F}$. The problem \eqref{max_min_ris2} is convex and can be optimally solved by a standard convex solver such as CVX\cite{grant2014cvx}. After solving the problem \eqref{max_min_ris2}, the optimal $\mathbf{B}$ can be obtained. Then, we need to obtain the value of $\mathbf{b}$, which has the direct relationship to $\mathbf{B}$. Generally, there is no guarantee that the relaxed problem \eqref{max_min_ris2} has a rank-one optimal solution. If $\text{rank}(\mathbf{B}) = 1$, then we can obtain the optimal $\mathbf{b}$ by taking the eigenvalue decomposition of $\mathbf{B}$. Otherwise, if $\text{rank}(\mathbf{B}) > 1$, an additional Gaussian randomization procedure is needed to produce a rank-one solution \cite{5447068,wu2019intelligent}. Specifically, suppose that the eigenvalue decomposition of $\mathbf{B}$ is $\mathbf{B} = \mathbf{U}\Sigma\mathbf{U}^H$. Then, let $\overline{\mathbf{b}} = \mathbf{U}\Sigma^{1/2}\mathbf{r}$, where $\mathbf{r} \sim \mathcal{C} \mathcal{N}\left(0, \boldsymbol{I}_{F}\right)$. Finally, project $\overline{\mathbf{b}}$ to the pre-defined set $\mathcal{S}_r$, i.e.,
\begin{equation}
b_f=e^{j\angle b_f},
\end{equation}
where $\angle b_f =\arg \min \limits_{\angle b_f \in \mathcal{S}_{r}} |\angle b_f -\angle \overline{b}_f|$. With many independently generated $\mathbf{r}$, the one that makes $\varpi$ maximum is taken as the solution.
\subsection{Analog Beamforming Design}
{We then optimize the analog beamforming after the RIS has been configured.} The orthogonal match pursuit (OMP) method is widely adopted to design the analog beamformer\cite{6717211}. If the BS adopts the fully digital beamforming structure, the optimal digital beamforming $\mathbf{W}_{\text {opt}}$ can be obtained by solving the following problem
\begin{subequations} \label{ind_wopt}
\begin{align}
{\min \limits_{\mathbf{W}}}\quad &{D\sum \limits_{k=1}^{K}\left\| \mathbf{w}_{k}\right\|^{2}} \\
{\text { s.t. }} \quad& { \frac{ |\mathbf{h}_{k}^H \mathbf{\Theta} \mathbf{G} \mathbf{w}_k|^2}{\sum \limits_{j\not= k} |\mathbf{h}_{k}^H \mathbf{\Theta} \mathbf{G} \mathbf{w}_j|^2 + \sigma^2_k} \geq \gamma_k, \forall k \in \mathcal{K}}.
\end{align}
\end{subequations}
{Note} that the above problem can be optimally solved by the SOCP method. {We adopt an overlapping codebook $\mathbf{A}$ with an overlapping coefficient $\mu$ to improve the spatial resolution due to the limited resolution of the conventional DFT codebook \cite{8362957}. A larger $\mu$ represents higher resolution of the codebook.} The codebook can be represented as $\mathbf{A}=[\mathbf{a}_B (\psi_1, \phi_1), \ldots, \mathbf{a}_B (\psi_1, \phi_{\mu N_z}), \ldots, \newline \mathbf{a}_B (\psi_{\mu N_y}, \phi_{\mu N_z})]$, where $N_y$ and $N_z$ denote the horizontal and vertical lengths, $\psi_i= \frac{2 \pi(i-1)}{\mu N_{y}}, i=1,2,\ldots,\mu N_y$ and
$\phi_j =\frac{2 \pi(j-1)}{\mu N_{z}}, j=1,2,\ldots,\mu N_z$, respectively.
Then, we can use a selection matrix $\mathbf{T}\in \mathbb{R}^{\mu^2 N_y N_z \times N}$ to select proper columns. Specifically, the analog beamforming problem can be formulated as
\begin{subequations} \label{analog_codebook}
\begin{align}
{\mathbf{T}^*=\underset{\mathbf{T}, \mathbf{F}_{BB}}{\arg \min } } \quad & { \left\|\mathbf{W}_{\text {opt}}- \mathbf{A}_t \mathbf{T} \mathbf{F}_{BB} \right\|_{F} }\\
{\text{ s.t. }}\quad & {\left\|\operatorname{diag}\left(\mathbf{T} \mathbf{T}^{H}\right)\right\|_{0}= N, }
\end{align}
\end{subequations}
{where $\mathbf{A}_t= \mathbf{e}_{t} \odot \mathbf{A}, t\in \mathcal{N}$, and $\mathbf{e}_t$ is an $M\times1$ zero-vector with the entry from $(t-1)D+1$ to $tD$ being one.} Since the structure of analog beamforming is sub-connected, we use $\mathbf{e}_t$ to modify the codebook. Then, the OMP method can be applied to obtain the selection matrix $\mathbf{T}^*$. The analog beamforming can be recovered, i.e., $\mathbf{V}=\mathbf{A}_t \mathbf{T}^*$. Finally, the discrete analog beamforming can be obtained by mapping $\mathbf{V}$ to the nearest discrete value in $\mathcal{S}_{a}$.
\subsection{Digital Beamforming Design}
After obtaining the RIS phase shifts and the analog beamforming vector, we need to obtain the optimal digital beamforming matrix. The digital beamforming can be obtained by solving following problem
\begin{subequations} \label{inde_w}
\begin{align}
{\min \limits_{\mathbf{W}}}\quad &{D\sum \limits_{k=1}^{K}\left\| \mathbf{w}_{k}\right\|^{2}} \\
{\text { s.t. }} \quad& { \frac{ |\mathbf{h}_{k}^H \mathbf{\Theta} \mathbf{G} \mathbf{V} \mathbf{w}_k|^2}{\sum \limits_{j\not= k} |\mathbf{h}_{k}^H \mathbf{\Theta} \mathbf{G} \mathbf{V} \mathbf{w}_j|^2 + \sigma^2_k} \geq \gamma_k, \forall k \in \mathcal{K}}.
\end{align}
\end{subequations}
{Note that the digital beamforming $\mathbf{W}_{\text {opt}}$ obtained by solving the problem \eqref{ind_wopt} is only used for the analog beamforming design. }The problem \eqref{inde_w} is the conventional power minimization problem in the multiple-input-single-output (MISO) system, which can be effectively and optimally solved by the SOCP method \cite{1561584}.
{Here, we consider the complexity of the sequential optimization. The complexity of the RIS design is dominated by the SDR technique, which is $\mathcal{O}(F^6)$ \cite{ben2001lectures}. The complexity of the analog beamforming is dominated by the OMP technique, which is $\mathcal{O}(\mu^2 MFN^3)$. The complexity of the digital beamforming design is $\mathcal{O}(N^{3.5} K^{3.5})$ \cite{7961152}. Thus, the overall computational complexity of the Sequential Optimization is $\mathcal{O}(F^6+\mu^2 MFN^3+N^{3.5} K^{3.5})$. The advantage of this algorithm is that it does not need to perform iterative operations.}
\section{Extension to the Max-Min Fairness Problem}
\label{discussion}
A closely related problem of the QoS problem $\mathcal{P}_0$ is the MMF problem, which aims to maximize the performance of the worse-case user under a fixed total transmit power budget. In this section, we discuss the relationship between the QoS problem and the MMF problem, and the extension of the proposed algorithm to solve the MMF problem. In specific, the MMF problem is to maximize the weighted minimum SINR under a total power budget $P_T$, which can be formulated as
\begin{subequations}\label{prob_original2}
\begin{align}
{\mathcal{Q}_0: \max \limits_{\{\mathbf{V},\mathbf{W},\mathbf{\Theta}\}} \min \limits_{k\in \mathcal{K}}} \quad & { \frac{1}{\gamma_k}\frac{\arrowvert{\mathbf{h}_{k}^H\mathbf{\Theta}\mathbf{G}\mathbf{V}\mathbf{w}_k} \arrowvert^2}{\sum\limits_{j\not=k}\arrowvert{\mathbf{h}_{k}^H\mathbf{\Theta}\mathbf{G} \mathbf{V}\mathbf{w}_j}\arrowvert^2+\sigma_k^2} } \\
{\text { s.t. }}\quad\quad & {D\sum \limits_{k=1}^K \|\mathbf{w}_k\|^2 \leq P_T }, \label{prob_f_cons1}\\
{}&{\eqref{const2},\eqref{const3}}
\end{align}
\end{subequations}
where $\gamma_k>0$ denotes the weight parameter of user $k$. A larger value of $\gamma_k$ indicates that user $k$ has a higher priority in transmission.
Let us compare the problem $\mathcal{P}_0$ and the problem $\mathcal{Q}_0$. Let $\bs{\gamma}\triangleq[\gamma_1, \gamma_2,\ldots, \gamma_K]^T$. For a given set of channels and noise powers, $\mathcal{P}_0$ is parameterized by $\bs{\gamma}$. We use the notation $\mathcal{P}_0 (\bs{\gamma})$ to account for this, and $P_T=\mathcal{P}_0 (\bs{\gamma})$ to denote the associated minimum power. Similarly, $\mathcal{Q}_0$ is parameterized by $\bs{\gamma}$ and $P_T$. Then, $\mathcal{Q}_0 (\bs{\gamma}, P_T)$ and $\xi=\mathcal{Q}_0 (\bs{\gamma}, P_T)$ are used to represent the dependence and the associated maximum worst-case weighted SINR, respectively. Similar to \cite{1634819,4443878}, we have the following proposition.
\begin{proposition}\label{remark}
The QoS problem $\mathcal{P}_0$ and the MMF problem $\mathcal{Q}_0$ have the following relationship:
\begin{subequations}
\begin{align}
\xi=\mathcal{Q}_0(\bs{\gamma},\mathcal{P}_0(\xi\bs{\gamma})),\label{relation1}\\
P_T=\mathcal{P}_0(\mathcal{Q}_0(\bs{\gamma},P_T)\bs{\gamma}).\label{relation2}
\end{align}
\end{subequations}
\end{proposition}
\begin{proof}
Contradiction argument is used to prove \eqref{relation1}. For the problem $\mathcal{P}_0(\xi\bs{\gamma})$, denote the optimal solution and the associated optimal value as $\{\mathbf{W}^{\mathcal{P}_0}, \mathbf{\Theta}^{\mathcal{P}_0}, \mathbf{V}^{\mathcal{P}_0} \}$ and $P_T^{\mathcal{P}_0}$, respectively. It is observed that the set $\{\mathbf{W}^{\mathcal{P}_0}, \mathbf{\Theta}^{\mathcal{P}_0}, \mathbf{V}^{\mathcal{P}_0} \}$ is also a feasible solution with the objective value $\xi$ to the problem $\mathcal{Q}_0(\bs{\gamma}, P_T^{\mathcal{P}_0})$. Since $\mathbf{\Theta}$ and $\mathbf{V}$ have unit-modulus constraints, we can only scale $\mathbf{W}$. Assume there is another solution $\{\mathbf{W}^{\mathcal{Q}_0}, \mathbf{\Theta}^{\mathcal{P}_0}, \mathbf{V}^{\mathcal{P}_0} \}$ with bigger objective value $\xi^{\mathcal{Q}_0}>\xi$. Then, we can appropriately scale down the digital beamforming with the SINR constraints of the problem $\mathcal{P}_0(\xi\bs{\gamma})$ still satisfied. The resulting solution $\{c\mathbf{W}^{\mathcal{Q}_0}, \mathbf{\Theta}^{\mathcal{P}_0}, \mathbf{V}^{\mathcal{P}_0} \}(0<c<1)$ has a smaller transmit power than $P_T^{\mathcal{P}_0}$, which contradicts the optimality of $\{\mathbf{W}^{\mathcal{P}_0}, \mathbf{\Theta}^{\mathcal{P}_0}, \mathbf{V}^{\mathcal{P}_0} \}$. \eqref{relation2} can be proved in the similar way and the details are omitted.
\end{proof}
Generally, the MMF problem $\mathcal{Q}_0$ is more difficult to solve than the QoS problem $\mathcal{P}_0$ due to {the non-smooth} objective function. Based on Proposition \ref{remark}, we can solve the MMF problem by solving a series of QoS problems. Specifically, let us consider the following problem $\mathcal{P}_2 (\varsigma)$, i.e.,
\begin{subequations}
\begin{align}
{\mathcal{P}_2 (\varsigma): \min \limits_{\{\mathbf{V},\mathbf{W},\mathbf{\Theta}\}}} \quad & {D\sum \limits_{k=1}^{K}\left\| \mathbf{w}_{k}\right\|^{2}} \\
{\text { s.t. }}\quad\quad & {\text{SINR}_{k} \geq \varsigma \gamma_{k}, \forall k\in\mathcal{K}}, \\
{}&{\eqref{const2}, \eqref{const3}}.
\end{align}
\end{subequations}
For a given set of channels, noise powers and $\bs{\gamma}$, $\mathcal{P}_2$ is parameterized by $\varsigma$. Note that the problem $\mathcal{P}_2 (\varsigma)$ is a linear function over $\varsigma$. A larger $\varsigma$ leads to a larger objective value of $\mathcal{P}_2$. Thus, in order to solve the problem $\mathcal{Q}_0$, we can do a bisection search over $\varsigma$ of the problem $\mathcal{P}_2 $ until its objective value is $P_T$. Then, the corresponding result is the solution to $\mathcal{Q}_0$ with the total power budget being $P_T$.
\section{Simulation Results}
\label{sec_simulation}
\begin{figure}[t]
\begin{centering}
\vspace{-0.5cm}
\includegraphics[width=0.45\textwidth]{simulation_setup2.eps}
\caption{The simulated RIS-aided communication scenario.}\label{simulation_setup}
\end{centering}
\vspace{-0.3cm}
\end{figure}
In this section, we evaluate the performance of our proposed algorithms. {We consider an RIS-aided multiuser mmWave communication system which operates at 28 GHz with bandwidth 251.1886 MHz. Thus, the noise power is $\sigma_k^2=-174+10 \log _{10} B=-90$ dBm.} We consider a $6\times 6$ UPA structure at the BS with $N=6$ RF chains and a total of $M=36$ antennas located at (0 m, 0 m) as shown in Fig.~\ref{simulation_setup}. The RIS is located at ($d_{RIS}$ m, 10 m) and equipped with $F_1 \times F_2$ unit cells where $F_1=6$ and $F_2$ can vary. Users are uniformly and randomly distributed in a circle centered at (100 m, 0 m) with radius 5 m. As for the mmWave channel, we set ${N_{\text{cl}}}_1={N_\text{cl}}_2=5$ clusters, ${N_\text{ray}}_1={N_\text{ray}}_2=10$ rays per cluster; the azimuth and elevation angles of arrival and departure follow the Lapacian distribution with an angle spread of 10 degrees; the complex gain $\alpha_{il}$ and $\beta_{il}$ follow the complex Gaussian distribution $\mathcal{CN}(0,10^{-0.1PL(d)})$, and $PL(d)$ can be modeled as\cite{akdeniz2014millimeter}:
\begin{equation}
PL(d)=\varphi_a + 10 \varphi_b \log_{10} (d) + \varphi_c (\text{dB}),
\end{equation}
where $\varphi_c \sim \mathcal{N}\left(0, \sigma^{2}\right)$, $\varphi_a=72.0,\varphi_b=2.92$ and $\sigma=8.7$dB. The auxiliary variables $\{t_{k,j}\}$ are initialized following $\mathcal{C}\mathcal{N}(0,1)$. The penalty factor is initialized as $\rho=10^{-3}$. Other system parameters are set as follows unless specified otherwise later: $K=3, F_2=6, d_{RIS}=50, c=0.9, \epsilon_1=\epsilon_3=10^{-7}, \epsilon_2=10^{-4}, \gamma_k=10$dB, $\forall k \in \mathcal{K}$. All simulation curves are averaged over $100$ independent channel realizations. {The simulations are carried out on a computer with Intel i7-7700 CPU at 3.60 GHz and with 16.0 GB RAM.}
\begin{figure}[t]
\begin{centering}
\vspace{-0.1cm}
\includegraphics[width=0.45\textwidth]{convcrit.eps}
\caption{\small{Stopping indicator of the penalty-based algorithm.}}\label{fig_conv_penalty1}
\end{centering}
\vspace{-0.4cm}
\end{figure}
\begin{figure}[t]
\begin{centering}
\includegraphics[width=.45\textwidth]{convpower.eps}
\caption{\small{Convergence of the penalty-based algorithm.}}\label{fig_conv_penalty2}
\end{centering}
\vspace{-0.2cm}
\end{figure}
\subsection{Convergence Performance of the Penalty-based Algorithm}
First, let us look at the convergence performance of the penalty-based algorithm. We show the stopping indicator \eqref{stop_criteria} of the penalty-based algorithm in Fig.~\ref{fig_conv_penalty1} and the average convergence of the penalty-based algorithm in Fig.~\ref{fig_conv_penalty2} in the case of continuous phase shifts of analog beamformer and RIS coefficients. These curves are plotted with the average plus and minus the standard deviation. {Note that the transmit power increases as the total number of iterations increases. This is because that a larger $\rho$ corresponding to a larger penalty for violating the equality restrictions, necessitating a higher transmit power to reduce the penalty term.} It is observed that the stopping indicator can always meet the predefined accuracy $10^{-7}$ after about 110 outer layer iterations in Fig.~\ref{fig_conv_penalty1}. Thus, the solutions obtained by \textit{Algorithm} \ref{alg_penalty} satisfy all SINR constraints. Fig.~\ref{fig_conv_penalty2} shows that the proposed algorithm converges after about 200 total iterations, which means that the inner layer runs averagely 2 times.
\subsection{Performance and Computational Comparison of Solving Problem \eqref{optimy1} by Different Methods}
\label{simulation_methods}
\begin{figure}[t]
\begin{centering}
\includegraphics[width=.45\textwidth]{conv_p1.eps}
\caption{{Convergence comparison with fixed penalty $\rho=1$ when solving problem \eqref{optimy1} by different methods.}}\label{conv1}
\end{centering}
\end{figure}
\begin{figure}[t]
\begin{centering}
\includegraphics[width=.45\textwidth]{comp_sinr.eps}
\caption{{Transmit power versus SINR targets when solving problem \eqref{optimy1} by different methods.}}\label{conv2}
\end{centering}
\vspace{-0.2cm}
\end{figure}
{We first compare the performance of different methods of solving problem \eqref{optimy1} as described in Section \ref{manifold_b}. Fig.~\ref{conv1} illustrates the objective value of $\mathcal{P}_1$ versus the iteration number when the penalty factor $\rho$ is fixed to one. Fig.~\ref{conv2} illustrates the transmit power versus SINR targets.
Though the optimal solution can be obtained for each subproblem in alternating optimization, it converges to a worse local optimum compared with the RCG-based joint optimization as shown in Fig.~\ref{conv1} and Fig.~\ref{conv2}. Though the SCA-based joint optimization does not require projection, it performs worse than the RCG-based joint optimization as shown in Fig.~\ref{conv1} and Fig.~\ref{conv2}. It is also seen from Fig.~\ref{conv2} that the gap between the SCA-based method and the RCG-based method decreases as the SINR targets increase. However, we have tested the results when the SINR target is 20dB, the RCG-based method still outperforms the SCA-based method. }
{We further compare the computational time with fixed penalty $\rho=1$ when solving problem (15) by different methods in Table \ref{compu_comp2}. Here, we set the RIS $F_1 \times F_2$ unit cells where $F_1=5$ and $F_2$ can vary. It is found that the SCA-based Joint Opt runs the fastest, while the Alternating Opt runs the slowest.}
{Overall, the RCG-based Joint Opt converges to the best point, and the time consumed is somewhere in the middle. Therefore, the RCG-based Joint Opt is a good choice among the three methods. In the following, we adopt the RCG-based joint optimization method.}
\begin{table}
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline \multirow{2}{*} {} & \multicolumn{4}{|c|} {\text { Running time (s) }} \\
\cline { 2 - 5 } & F=10 & F=20 & F=40 & F=80 \\
\hline \text { Alternating Opt } & 142.9865 & 152.4747 & 157.7086 & 163.2711 \\
\hline \text { RCG-based Joint Opt } & 134.5921 & 142.8421 & 143.1132 & 148.7838 \\
\hline \text { SCA-based Joint Opt } & 103.1461 & 104.0654 & 105.5587 & 110.4485 \\
\hline
\end{tabular}
\caption{Computational Time Comparison.} \label{compu_comp2}
\end{table}
\subsection{Influence of Discrete Phase Shifts}
\begin{figure}[t]
\begin{centering}
\includegraphics[width=.45\textwidth]{original.eps}
\caption{Influence of discrete phase shifts.}\label{fig_discrete1}
\end{centering}
\vspace{-0.5cm}
\end{figure}
We consider that the number of control bits at the analog beamformer and at the RIS, i.e., $Q_1$ and $Q_2$, can be designed separately, and each can take values from $\{1, 2, 3, \infty\}$, where $\infty$ corresponds to continuous phase shifts. Fig.~\ref{fig_discrete1} shows that when there is only one control bit for both analog beamformer and RIS, i.e. $Q_1 = Q_2 = 1$, the power gap to the ideal case with continuous phase shifts is up to 7 dB; when $Q_1 = Q_2 = 2$ and $Q_1 = Q_2 = 3$, the gap reduces quickly to 1.5 dB and 0.4dB, respectively. This suggests that having 3 bits for the discrete phase shifts is enough in practice. It is also seen from Fig.~\ref{fig_discrete1} that the BS is more robust to the discrete phase shifts than the RIS. In specific, the performance at $Q_1=1, Q_2 = \infty$ is about 2 dB better than that at $Q_1 = \infty, Q_2= 1$.
{We believe that the analog beamforming at the BS has a larger dimension of regulation than the RIS. Specifically, the analog beamforming contains many RF chains and each RF chain can serve one user, while all users are served by the same RIS. Therefore, the BS is more robust to the discrete phase shifts than the RIS.
}
\subsection{Performance Comparison with Other Schemes}
To demonstrate the efficiency of the proposed algorithms and to reveal some design insights, we compare the performance of the following algorithms when $Q_{1}=3$ and $Q_2=3$.
\begin{itemize}
\item Penalty-Manifold joint design with hybrid beamforming structure (Penalty-Manifold HB): This is the proposed \textit{Algorithm} \ref{alg_penalty} for joint design of hybrid beamforming and RIS phase shifts.
\item Penalty-Manifold joint design with fully digital beamforming structure (Penalty-Manifold FD): This is the proposed \textit{Algorithm} \ref{alg_penalty} but changing the hybrid beamforming to the fully digital beamforming at the BS. This is done by setting $D=1$.
\item Penalty-Manifold joint design with random $\mathbf{\Theta}$ (Random $\mathbf{\Theta}$): The phase shifts at the RIS are randomly selected to be feasible values. Then the hybrid beamforming matrices $\{\mathbf{W},\mathbf{V}\}$ at the BS are obtained by using the penalty-manifold joint algorithm as in \textit{Algorithm} \ref{alg_penalty}, where the update of $\mathbf{\Theta}$ is skipped. This is to find out the significance of optimizing the phase shifts at the RIS.
\item Penalty-Manifold joint design with SDR $\mathbf{\Theta}$ (SDR $\mathbf{\Theta}$): The phase shifts at the RIS are designed by using the SDR approach as stated in Section \ref{ris_design}. Then the hybrid beamforming matrices $\{\mathbf{W}, \mathbf{V}\}$ at the BS are obtained by using the penalty-manifold joint algorithm as in \textit{Algorithm} \ref{alg_penalty}, where the udpate of $\mathbf{\Theta}$ is skipped. This is again to find out the significance of optimizing the phase shifts at the RIS.
\item BCD-SDR joint design (BCD-SDR): The conventional BCD method in conjunction with the SDR method, as mentioned in Section \ref{pro_formulation}.
\item Sequential design: the proposed sequential design where RIS phase shifts, analog beamforming, and digital beamforming are optimized sequentially in Section \ref{individual}. {In order to make the sequential optimization method be more effective, we try different overlapping coefficients $\mu$ from 1 to 4 and let the best result be the final solution.}
\end{itemize}
\begin{figure}[t]
\begin{centering}
\includegraphics[width=.45\textwidth]{dsinr.eps}
\caption{\small{Transmit power versus SINR targets.}}\label{fig_multi_sinr}
\end{centering}
\end{figure}
\begin{figure}[t]
\begin{centering}
\includegraphics[width=.45\textwidth]{dele.eps}
\caption{\small{Transmit power versus the number of the elements of RIS.}} \label{fig_ele}
\end{centering}
\end{figure}
\begin{figure}[t]
\begin{centering}
\includegraphics[width=.45\textwidth]{ddis.eps}
\caption{\small{Transmit power versus the horizontal distance of RIS.}}\label{fig_distance}
\end{centering}
\end{figure}
\begin{table}[t]
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline \multirow{2}{*} {} & \multicolumn{4}{|c|} {\text { Running time (s) }} \\
\cline { 2 - 5 } & F=10 & F=20 & F=40 & F=80 \\
\hline \text { SDR-BCD } & 54.2175 & 61.1350 & 169.0588 & 461.3819 \\
\hline \text { Penalty-Manifold FD } & 96.0028 & 101.2406 & 115.0541 & 116.8831 \\
\hline \text { Sequential Design } & 15.3721 & 17.9422 & 20.1504 & 37.0946 \\
\hline
\end{tabular}
\caption{Computational Time Comparison.} \label{compu_comp}
\end{table}
Fig.~\ref{fig_multi_sinr} illustrates the transmit power versus SINR targets. We first observe that the Penalty-Manifold joint design outperforms the start-of-the-art BCD-SDR joint design, which verifies the effectiveness of the proposed algorithm. Second, it is seen that the Penalty-Manifold joint design with random $\mathbf{\Theta}$ performs the worst among all the considered schemes. By simply changing the random $\mathbf{\Theta}$ to the SDR $\mathbf{\Theta}$ (while keeping the joint design of $\{\mathbf{W},\mathbf{V}\}$ unchanged), the transmit power consumption can be reduced by 4 dB. If $\mathbf{\Theta}$ is involved in the Penalty-Manifold joint design, another about 5 dB power reduction can be obtained. These observations indicate that the design of RIS phase shifts plays the crucial role for performance optimization.
Third, we observe that the sequential design is about 1dB worse than the joint design with SDR $\mathbf{\Theta}$. This suggests that, when the RIS response matrix is designed sequentially, further optimizing the hybrid beamforming at the BS can only bring marginal improvement.
Last but not least, we observe that the power consumed by Penalty-Manifold beamforming is about 2dB higher than the power consumed by Penalty-Manifold FD. Note that the hybrid beamforming has a much lower hardware cost since it only employs $N=6$ RF chains at the BS, while the fully digital beamforming has $M=36$ RF chains. This means that the proposed hybrid beamforming is effective.
The influence of the RIS element number is considered in Fig.~\ref{fig_ele}. When the RIS element number increases from 12 to 60, the transmit power decreases about 15dB. Thus, we conclude that the RIS can greatly reduce the transmit power by installing a large number of elements.
Fig.~\ref{fig_distance} illustrates the transmit power versus the RIS horizontal distance. It is seen that as the RIS horizontal distance $d_{RIS}$ increases, the transmit power increases firstly, and reaches the peak at 50 m, then decreases. This can be explained that the received power through the reflection of the RIS in the far field is proportional to $d_1^{-2} d_2^{-2}$, where $d_1$ and $d_2$ denote the distances between the BS-RIS and RIS-user, respectively. It is found that the RIS can be located near the BS or users to save energy.
{We further compare in Table \ref{compu_comp} the running time for various values of $F$. Here, $\mu$ is set to be 3. We set the RIS $F_1 \times F_2$ unit cells where $F_1=5$ and $F_2$ can vary. It is observed that the time consumed by the SDR-BCD method increases greatly as $F$ increases. It is interesting that the computational time of Penalty-Manifold FD is insensitive to $F$. And the time consumed by the Sequential Design is the least among the algorithms, which means that it has the lowest complexity.}
\section{Conclusion}
\label{sec_conclusion}
{In this paper, we investigate an RIS-aied downlink MIMO system, with the objective of minimizing the transmit power at the BS by jointly optimizing the hybrid A/D beamforming at the BS, as well as the overall response-coefficient at the RIS, subject to individual minimum SINR constraints. The non-convex problem is first solved by the penalty-based algorithm with manifold optimization, followed by a low-complexity sequential optimization. {In particular, we propose three different methods for optimizing the BS analog beamforming and the RIS response matrix in the penalty-based algorithm. The RCG-based joint optimization is found to outperform the other two methods but it has a slightly higher complexity.} Extensive simulation results demonstrate that the proposed algorithm outperforms the state-of-art BCD-SDR algorithm. Our simulation results provide useful insights into the corresponding wireless system design. In particular, the simulation results show that utilizing a large number of RIS units could help reduce the transmit power at the BS greatly. Moreover, 3-bit quantizers of both the RIS and the analog beamformer could approach the performance of continuous phase shifters.}
\bibliographystyle{IEEEtran}
|
{'timestamp': '2022-02-15T02:38:12', 'yymm': '2202', 'arxiv_id': '2202.06532', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06532'}
|
arxiv
|
\section{Introduction}
Consider a parametric process $X^\theta_t \in \mathbb{R}^d$ which satisfies the stochastic differential equation (SDE):
\begin{equation}\begin{aligned}
\label{ergodic process}
dX_t^\theta &= \mu(X_t^\theta, \theta) dt + \sigma(X_t^\theta, \theta) dW_t, \\
X_0^\theta &= x,
\end{aligned}\end{equation}
where $\theta \in \mathbb{R}^\ell$. Suppose $X_t^\theta$ is ergodic with the stationary distribution $\pi_\theta$.\footnote{ Sufficient conditions (\cite{pardoux2003poisson}) for the existence and uniqueness of $\pi_\theta$ are: (1) both coefficients $\mu$ and $\sigma$ are assumed to be bounded and $\sigma$ is uniformly continuous with respect to $x$ variable, (2) $ \displaystyle \lim _{|x| \to \infty} \sup _{\theta} \mu(x, \theta) x = -\infty$, and (3) there exist two constants $0<\lambda<\Lambda<\infty$ such that
$ \lambda I_d \leq \sigma \sigma^{\top}(x, \theta) \leq \Lambda I_d $ where $I_d$ is the $d\times d$ identity matrix.}
Let $p_t(x,x', \theta)$ and $p_\infty(x',\theta)$ denote its transition and invariant density, respectively. Our goal is to select the parameters $\theta$ which minimize the objective function
\begin{equation}
\label{objective function}
J(\theta) = \sum\limits_{n=1}^N \bigg{(} {\bf E}_{\pi_\theta} \big{[} f_n(Y) \big{]} - \beta_n \bigg{)}^2,
\end{equation}
where $f_n$ are known functions and $\beta_n$ are the target quantities.
Thus, we are interested in optimizing the parameterized SDEs (\ref{ergodic process}) such that their stationary distribution matches, as closely as possible, the target statistics $\beta_n$. In practice, the target statistics may be data from real-world observations which are then used to calibrate the SDE model (\ref{ergodic process}).
\subsection{Existing methods to optimize over the stationary distribution of SDEs} \label{ExistingMethods}
The stationary distribution $\pi_{\theta}$ is typically unknown and therefore it is challenging to optimize over $J(\theta)$. The quantity ${\bf E}_{\pi_\theta} \big{[} f_n(Y) \big{]}$ as well as its gradient $\nabla_{\theta} {\bf E}_{\pi_\theta} \big{[} f_n(Y) \big{]}$ must be estimated in order to minimize $J(\theta)$. ${\bf E}_{\pi_\theta} \big{[} f_n(Y) \big{]}$ can be evaluated using the forward Kolmogorov equation
\begin{eqnarray}
\mathcal{L}^{\theta, *}_{x} p_\infty(x, \theta) = 0,
\label{ForwardKolmogorov}
\end{eqnarray}
where $\mathcal{L}^{\theta}_x$ is the infinitesimal generator of the process $X_t^{\theta}$ and $\mathcal{L}^{\theta, *}_x$ is the adjoint operator of $\mathcal{L}^{\theta}_x$. $\nabla_{\theta} {\bf E}_{\pi_\theta} \big{[} f_n(Y) \big{]}$ can be calculated using an appropriate adjoint partial differential equation (PDE) for (\ref{ForwardKolmogorov}). However, if the dimension of $d$ for $X_t^{\theta}$ is large, solving the forward Kolmogorov equation and its adjoint PDE become extremely computationally expensive. In the special case where the drift function $\mu$ is the gradient of a scalar function and the volatility function $\sigma$ is constant, there exists a closed-form formula for the stationary distribution \cite{Pavliotis}.
Alternatively, ${\bf E}_{\pi_\theta} \big{[} f_n(Y) \big{]}$ can be approximated by simulating (\ref{ergodic process}) over a long time $[0,T]$. The gradient descent algorithm would be:
\begin{itemize}
\item Simulate $X^{\theta_k}_t$ for $ t \in [0,T]$.
\item Evaluate the gradient of $J_T(\theta^k) := \displaystyle \sum_{n=1}^N \left( \frac1T \int_0^T f_n(X^{\theta_k}_t) dt - \beta_n \right)^2$ .
\item Update the parameter as $\theta^{k+1} = \theta^k - \alpha_k \nabla_\theta J_T(\theta^k)$,
\end{itemize}
where $\alpha_k$ is the learning rate. This gradient descent algorithm will be slow; a long simulation time $T$ will be required for each optimization iteration. A second disadvantage is that $J_T(\theta)$ is an approximation to $J(\theta)$ and therefore error is introduced into the algorithm, i.e. $\nabla_{\theta} J_T(\theta) \neq \nabla_{\theta} J(\theta)$.
\subsection{An Online Optimization Algorithm}
We propose a new continuous-time stochastic gradient descent algorithm which allows for computationally efficient optimization of \eqref{objective function}. For notational convenience (and without loss of generality), we will set $N = 1$ and $\beta_1 = \beta$. The online algorithm for optimizing \eqref{objective function} is:
\begin{equation}\begin{aligned}
\label{nonlinear update}
\frac{d\theta_t}{dt} &= -2\alpha_t \left(f(\bar X_t) - \beta \right) \tilde X_t^{\top} \nabla_x f(X_t), \\
d \tilde X_t &= \left( \mu_x( X_t, \theta_t )\tilde X_t +\mu_\theta(X_t, \theta_t) \right) dt + \left( \sigma_x(X_t,\theta_t)\tilde X_t + \sigma_\theta(X_t, \theta_t) \right) dW_t, \\
dX_t &= \mu(X_t, \theta_t) dt + \sigma(X_t, \theta_t) dW_t, \\
d\bar X_t &= \mu( \bar X_t, \theta_t ) dt + \sigma(\bar X_t, \theta_t) d \bar W_t,
\end{aligned}\end{equation}
where $W_t$ and $\bar W_t$ are independent Brownian motions and $\alpha_t$ is the learning rate. $\mu_x = \frac{\partial \mu}{\partial x}, \mu_{\theta} = \frac{\partial \mu}{\partial \theta}, \sigma_x = \frac{\partial \sigma}{\partial x},$ and $\sigma_{\theta} = \frac{\partial \sigma}{\partial \theta}$. The learning rate must be chosen such that $\int_0^{\infty} \alpha_s ds = \infty$ and $\int_0^{\infty} \alpha_s^2 ds < \infty$. (An example is $\alpha_t = \frac{C}{1 + t}$.)
$\tilde X_t$ estimates the derivative of $X_t$ with respect to $\theta_t$. The parameter $\theta_t$ is continuously updated using $\left(f(\bar X_t) - \beta \right) \tilde X_t^{\top} \nabla_x f(X_t)$ as a stochastic estimate for $\nabla_{\theta} J(\theta_t)$.
To better understand the algorithm (\ref{nonlinear update}), let us first re-write the gradient of the objective function using the ergodicity of $X_t^{\theta}$:
\begin{eqnarray}
\label{gradient}
\nabla_\theta J(\theta) &=& 2 \left( {\bf E}_{\pi_\theta} f(Y) - \beta \right) \nabla_\theta {\bf E}_{\pi_\theta} f(Y) \notag \\
&\overset{a.s.}=& 2\left( \lim_{T \to \infty}\frac{1}{T} \int_0^T f(X^{\theta}_t) dt- \beta \right) \times \nabla_\theta \left( \lim_{T \to \infty}\frac1T \int_0^T f(X^\theta_t)dt \right).
\end{eqnarray}
If the derivative and the limit can be interchanged, the gradient can be expressed as
\begin{eqnarray}
\nabla_\theta J(\theta)= 2\left(\lim_{T \to \infty}\frac{1}{T} \int_0^T f(X^{\theta}_t) dt - \beta \right) \times \lim_{T \to \infty} \frac1T \int_0^T ( \nabla_\theta X_t^\theta )^{\top} \nabla_x f(X^\theta_t) dt.
\end{eqnarray}
Define $\tilde X_t^{\theta} = \nabla_\theta X_t^\theta$. $\tilde X_t^{\theta}$ will satisfy
\begin{eqnarray}
d \tilde X_t^{\theta} &= \left( \mu_x( X_t^{\theta}, \theta ) \tilde X_t^{\theta} +\mu_\theta(X_t^{\theta}, \theta) \right) dt + \left( \sigma_x(X_t^{\theta},\theta) \tilde X_t^{\theta} + \sigma_\theta(X_t^{\theta}, \theta) \right) dW_t.
\end{eqnarray}
$\tilde X_t$ and $\tilde X_t^{\theta}$ satisfy the same equations, except $\theta$ is a fixed constant for $\tilde X_t^{\theta}$ while $\theta_t$ is updated continuously in time for $\tilde X_t$. Then, we have that
\begin{eqnarray}
\nabla_\theta J(\theta)= 2\left( \lim_{T \to \infty}\frac{1}{T} \int_0^T f(X^{\theta}_t ) dt - \beta \right) \times \lim_{T \to \infty} \frac1T \int_0^T ( \tilde X_t^{\theta} )^{\top} \nabla_x f(X^\theta_t) dt.
\label{IntroJ00}
\end{eqnarray}
The formula (\ref{IntroJ00}) can be used to evaluate $\nabla_{\theta} J(\theta)$ and thus allows for optimization via a gradient descent algorithm. However, as highlighted in Section \ref{ExistingMethods}, $X_t^{\theta}$ must be simulated for a large time period $[0,T]$ for each optimization iteration, which is computationally costly.
A natural alternative is to develop a \emph{continuous-time} stochastic gradient descent algorithm which updates $\theta$ using a stochastic estimate $G(\theta_t)$ for $\nabla_\theta J(\theta_t)$, where $G(\theta_t)$ asymptotically converges to an unbiased estimate for the direction of steepest descent $\nabla_{\theta} J(\theta_t)$. (The random variable $G(\theta_t)$ is an unbiased estimate for $\nabla_{\theta} J(\theta_t)$ if ${\bf E}[ G(\theta_t) | \theta_t ] = \nabla_{\theta} J(\theta_t)$.) The online algorithm (\ref{nonlinear update}) does exactly this using $G(\theta_t) = 2 \left(f(\bar X_t) - \beta \right) \tilde X_t^{\top} \nabla_x f(X_t)$ as a stochastic estimate for $\nabla_{\theta} J(\theta_t)$.
For large $t$, we expect that ${\bf E}\left[ f(\bar X_t) - \beta \right] \approx {\bf E}_{\pi_{\theta_t}}\left[ f(Y) - \beta \right]$ and ${\bf E} \left[\tilde X_t^{\top} \nabla_x f(X_t) \right] \approx \nabla_\theta \left( {\bf E}_{\pi_{\theta_t}}\left[ f(X) - \beta \right] \right)$ since $\theta_t$ is changing very slowly as $t$ becomes large due to $\displaystyle \lim_{t \rightarrow \infty} \alpha_t = 0$. Furthermore, since $\bar X_t$ and $X_t$ are driven by independent Brownian motions, we expect that ${\bf E} \left[ 2 \left(f(\bar X_t) - \beta \right) \tilde X_t^{\top} \nabla_x f(X_t) \right ] \approx \nabla_{\theta} J(\theta_t)$ for large $t$ due to $\bar X_t$ and $(X_t, \tilde X_t)$ being close to conditionally independent since $\theta_t$ will be changing very slowly for large $t$.
Thus, we expect that for large $t$, the stochastic sample $G(\theta_t) = 2 \left(f(\bar X_t) - \beta \right) \tilde X_t^{\top} \nabla_x f(X_t)$ will provide an unbiased estimate for the direction of steepest descent $\nabla_{\theta} J(\theta_t)$ and $\theta_t$ will converge to a local minimum of the objective function $J(\theta)$.
\subsection{Contributions of this Paper}
We rigorously prove the convergence of the algorithm (\ref{nonlinear update}) when $\mu(\cdot)$ is linear and for constant $\sigma$. Even in the linear case, the distribution of $(X_t, \bar X_t, \tilde X_t, \theta_t)$ will be non-Gaussian and convergence analysis is non-trivial. Unlike in the traditional stochastic gradient descent algorithm, the data is not i.i.d. (i.e., $X_t$ is correlated with $X_s$ for $s \neq t$) and, for a finite time $t$, the stochastic update direction $G(\theta_t)$ is not an unbiased estimate of $\nabla_{\theta} J(\theta_t)$. One must show that asymptotically $G(\theta_t)$ becomes an unbiased estimate of the direction of steepest descent $\nabla_{\theta} J(\theta_t)$. Furthermore, it must be proven that the stochastic fluctuations of $G(\theta_t)$ around the direction of steepest descent vanish in an appropriate way as $t \rightarrow \infty$.
The proof therefore requires analysis of the fluctuations of the stochastic update direction $G(\theta_t)$ around $\nabla_{\theta} J(\theta_t)$. Bounds on the fluctuations are challenging to obtain due to the online nature of the algorithm. The stationary distribution $\pi_{\theta_t}$ will continuously change as the parameters $\theta_t$ evolve. We prove bounds on a new class of Poisson partial differential equations, which are then used to analyze the parameter fluctuations in the algorithm. The fluctuations are re-written in terms of the solution to the Poisson PDE using Ito's Lemma, the PDE solution bounds are subsequently applied, and then we can show asymptotically that the fluctuations vanish. Our main theorem proves for the linear case that:
\begin{eqnarray}
\lim_{t \rightarrow \infty} \left| \nabla_{\theta} J(\theta_t) \right| \overset{a.s.} = 0.
\end{eqnarray}
In the numerical section of this paper, we evaluate the performance of our online algorithm (\ref{nonlinear update}) for a variety of linear and nonlinear examples. In these examples, we show that the algorithm can also perform well in practice for nonlinear SDEs. We also demonstrate that the online algorithm can optimize over path-dependent SDEs and pathwise statistics of SDEs such as the auto-covariance.
\subsection{Literature Review}
\hspace{1.4em} In this paper we show that, if $\alpha_{t}$ is appropriately chosen, then $\nabla J(\theta_t) \rightarrow 0$ as $t \rightarrow \infty$ with probability 1. Similar results have been previously proven for stochastic gradient descent (SGD) in discrete time. \cite{bertsekas2000gradient} proves the convergence of SGD with i.i.d. data samples. \cite{benveniste2012adaptive} proves the convergence of SGD in discrete time with the correlated data samples under stronger conditions than \cite{bertsekas2000gradient}. We refer readers to \cite{benveniste2012adaptive, bertsekas2000gradient, bottou2018optimization, goodfellow2016deep, kushner2003stochastic} for a thorough review of the very large literature on SGD and similar stochastic optimization algorithms (e.g., SGD with momentum, Adagrad, ADAM, and RMSprop). However, these articles do not study stochastic gradient descent methods for optimizing over the stationary distribution of stochastic models, which is the focus of our paper.
Recent articles such as \cite{bhudisaksang2021online, sharrock2020two, sirignano2017stochastic, sirignano2020stochastic, surace2018online} have studied continuous-time stochastic gradient descent. \cite{sirignano2017stochastic} proposed a ``stochastic gradient descent in continuous time" (SGDCT) algorithm for estimating parameters $\theta$ in an SDE $X_t^{\theta}$ from continuous observations of $X_t^{\theta^{\ast}}$ where $\theta^{\ast}$ is the true parameter. \cite{sirignano2017stochastic} proves convergence of the algorithm to a stationary point. \cite{bhudisaksang2021online} extended SGDCT to estimate the drift parameter of a continuous-time jump-diffusion process. \cite{sirignano2020stochastic} analyzed proved a central limit theorem for the SGDCT algorithm and a convergence rate for strongly convex objective functions. \cite{sharrock2020two} established the almost sure convergence of two-timescale stochastic gradient descent algorithms in continuous time. \cite{surace2018online} designed an online learning algorithm for estimating the parameters
of a partially observed diffusion process and studied its convergence. \cite{sharrock2021parameter} proposes an online estimator for the parameters of
the McKean-Vlasov SDE and proves that this estimator converges in $L_1$ to the stationary points of the asymptotic log-likelihood.
Our paper has several important differences as compared to \cite{bhudisaksang2021online, sharrock2020two, sharrock2021parameter, sirignano2017stochastic, sirignano2020stochastic, surace2018online}. These previous papers estimate the parameter $\theta$ for the SDE $X_t^{\theta}$ from observations of $X_t^{\theta^{\ast}}$ where $\theta^{\ast}$ is the true parameter. In this paper, our goal is to select $\theta$ such that the stationary distribution of $X_t^{\theta}$ matches certain target statistics. Therefore, unlike the previous papers, we are directly optimizing over the stationary distribution of $X_t^{\theta}$. The presence of the $X$ process in SGDCT makes the mathematical analysis challenging as the $X$ term introduces correlation across times, and this correlation does not disappear as time tends to infinity. In order to prove convergence, \cite{sirignano2017stochastic, sirignano2020stochastic} use an appropriate Poisson PDE \cite{gilbarg2015elliptic, pardoux2001poisson, pardoux2003poisson} associated with $X$ to describe the evolution of the parameters for large times and analyze the fluctuations of the parameter around the direction of steepest descent. However, the theoretical results from \cite{pardoux2001poisson, pardoux2003poisson} do not apply to the PDE considered in this paper since the diffusion term in our PDE is not uniformly elliptic. This is a direct result of the process $\tilde X_t$ in (\ref{nonlinear update}), which shares the same Brownian motion with the process $X_t$. In the case of constant $\sigma$, the PDE operator will not be uniformly elliptic and, furthermore, the coefficient for derivatives such as $\frac{\partial^2 }{\partial \tilde x^2}$ is zero. Consequently, we must analyze a new class of Poisson PDEs which is different than the class of Poisson PDEs studied in \cite{pardoux2001poisson, pardoux2003poisson}. We prove there exists a solution to this new class of Poisson PDEs which satisfies polynomial bounds. The polynomial bounds are crucial for analyzing the fluctuations of the parameter evolution in the algorithm (\ref{nonlinear update}).
\subsection{Organization of Paper}
The paper is organized into three main sections. In Section \ref{main result}, we present the assumptions and the main theorem. Section \ref{detail proof} rigorously proves the convergence of our algorithm for multi-dimensional linear SDEs. Section \ref{numerical experiment} studies the numerical performance of our algorithm for a variety of linear and nonlinear SDEs, including McKean-Vlasov and path-dependent SDEs.
\section{Main Results}\label{main result}
\hspace{1.4em} In this section, we rigorously prove convergence of the algorithm \eqref{nonlinear update} for linear SDEs. Consider the multi-dimensional Ornstein–Uhlenbeck (OU) process
\begin{equation}\begin{aligned}
\label{process}
dX^\theta_t &= ( g(\theta) - h(\theta) X^\theta_t )dt + \sigma dW_t, \\
X_0^\theta &= x,
\end{aligned}\end{equation}
where $\theta \in \mathbb{R}^\ell$, $g(\theta) \in \mathbb{R}^d$, $h(\theta) \in \mathbb{R}^{d \times d}_+$, $W_t \in \mathbb{R}^d$, $X^\theta_t \in \mathbb{R}^d$, and $\sigma$ is a scalar constant. If $h(\theta)$ is invertible, the solution to the SDE (\ref{process}) is
\begin{equation}
\label{solution}
X^\theta_t = e^{-h(\theta) t} x + \left(h(\theta)\right)^{-1}\left(I_d- e^{-h(\theta)t}\right)g(\theta) + e^{-h(\theta)t} \int_0^t e^{h(\theta)s} \sigma dW_s,
\end{equation}
where $I_d$ is the $d\times d$ identity matrix. Recall that $\tilde X^\theta_t = \nabla_\theta X^\theta_t = \left( \frac{\partial X_t^{\theta,i}}{\partial \theta_j}\right)_{i,j} \in \mathbb{R}^{d \times \ell}$.\footnote{In this paper's notation, the Jacobian matrix of a vector value function $f: x \in \mathbb{R}^n \to \mathbb{R}^m $ is an $m \times n$ matrix and the gradient of a scalar value function is a column vector.} Then,
\begin{equation}
\label{tilde theta}
\frac{d \tilde X^\theta_t}{dt} = \nabla_\theta g(\theta) - \nabla_\theta h(\theta) X_t^\theta - h(\theta) \tilde X^\theta_t,
\end{equation}
where $\nabla_\theta h(\theta)$ is a tensor. The ODE \eqref{tilde theta} can be written explicitly as
\begin{equation}
\frac{d}{dt} \frac{\partial X_t^{\theta,i}}{\partial \theta_j} = \frac{\partial g_i(\theta)}{\partial \theta_j} - \sum\limits_{k=1}^d \frac{\partial h_{ik}(\theta) }{\partial \theta_j} X_t^{\theta, k} - \sum\limits_{k=1}^d h_{ik}(\theta) \frac{\partial X_t^{\theta,k}}{\partial \theta_j}
\end{equation}
for $i \in \{1,2,\cdots, d\}$ and $j \in \{1,2,\cdots, \ell\}$. Thus, we know the solution of \eqref{tilde theta} with initial point $\tilde x$ is
\begin{equation}
\label{tilde}
\tilde X^\theta_t = e^{-h(\theta)t} \tilde x + e^{-h(\theta)t} \int_0^t e^{h(\theta)s} \left( \nabla_\theta g(\theta) - \nabla_\theta h(\theta) X_s^\theta \right)ds.
\end{equation}
As in \eqref{nonlinear update}, we define another independent process
\begin{equation}\begin{aligned}
\label{independent process}
d\bar X^\theta_t &= ( g(\theta) - h(\theta) \bar X^\theta_t )dt + \sigma d\bar W_t,\\
\bar X_0^\theta &= \bar x,
\end{aligned}\end{equation}
where $\bar W_t$ is another Brownian motion independent of $W_t$.
Let $\pi_\theta$ be the stationary distribution of $X_t^\theta$. Our goal is to solve the optimization problem
\begin{equation}
\label{object}
\min\limits_{\theta} J(\theta) = \min\limits_{\theta} \left( {\bf E}_{\pi_\theta}f(Y) - \beta \right)^2,
\end{equation}
where $\beta$ is a constant. For the linear case, our online algorithm \eqref{nonlinear update} becomes:
\begin{equation}\begin{aligned}
\label{update}
\frac{d\theta_t}{dt} &= -2\alpha_t \left(f(\bar X_t) - \beta \right) \tilde X_t^\top \nabla_x f(X_t),\\
dX_t &= ( g(\theta_t) - h(\theta_t) X_t ) dt + \sigma d W_t, \\
\frac{d \tilde X_t}{dt} &= \nabla_\theta g(\theta_t) - \nabla_\theta h(\theta_t) X_t - h(\theta_t) \tilde X_t,\\
d\bar X_t &= ( g(\theta_t) - h(\theta_t) \bar X_t ) dt + \sigma d \bar W_t.
\end{aligned}\end{equation}
For the rest of this article, we will use $c, C,$ and $C_k$ to denote generic constants. Our convergence theorem will require the following assumptions.
\begin{assumption}
\label{condition}
\begin{itemize}
\item[(1)] $g(\theta)$, $\nabla^i_\theta g(\theta)$, $h(\theta)$ and $\nabla^i_\theta h(\theta)$ are uniformly bounded functions for $i=1,2$.
\item[(2)] $h$ is symmetric and uniformly positive definite, i.e. there exists a constant $c>0$ such that
$$
\min\left\{ x^\top h(\theta) x \right\} \ge c|x|^2, \quad \forall \theta \in \mathbb{R}^\ell, x\in \mathbb{R}^d, k,j \in \{ 1,2, \cdots, \ell \}.
$$
\item[(3)] $f, \nabla^i f, i=1,2,3$ are polynomially bounded\footnote{$|\cdot|$ denotes the Euclidean norm. Sometimes for a square matrix $x$, $|x|$ will be used to denote its spectral norm which is equivalent to the Euclidean norm.}:
\begin{equation}
\label{poly}
|f(x)| + \sum\limits_{i=1}^3|\nabla^i_x f(x)| \le C(1+|x|^m),\quad \forall x\in \mathbb{R}^d
\end{equation}
for some constant $C, m>0$.
\item[(4)] The learning rate $\alpha_t$ satisfies $\int_{0}^{\infty} \alpha_{t} d t=\infty$, $\int_{0}^{\infty} \alpha_{t}^{2} d t<\infty$, $\int_{0}^{\infty}\left|\alpha_{s}^{\prime}\right| d s<\infty$, and there is a $p>0$ such that $\displaystyle \lim _{t \rightarrow \infty} \alpha_{t}^{2} t^{\frac12 + 2 p}=0$.
\end{itemize}
\end{assumption}
Under these assumptions, we are able to prove the following convergence result.
\begin{theorem}
\label{conv f}
Under Assumption \ref{condition} and for the linear case \eqref{update},
\begin{equation}
\lim_{t \rightarrow \infty} \left| \nabla_\theta J(\theta_t) \right| \overset{a.s.} = 0.
\end{equation}
\end{theorem}
\section{Proof of Theorem \ref{conv f}}\label{detail proof}
\hspace{1.4em} In this section, we present the proof of Theorem \ref{conv f}. We begin by decomposing the evolution of $\theta_t$ in \eqref{update} into several terms:
\begin{eqnarray}
\label{gradient with error}
\frac{d\theta_t}{dt} &=& -2\alpha_t ( f(\bar X_t) - \beta ) \tilde X_t^\top \nabla_x f(X_t) \notag \\
&=& -2\alpha_t ({\bf E}_{\pi_{\theta_t}}f(Y) - \beta) \tilde X_t^\top \nabla_x f(X_t) - 2\alpha_t \left( f(\bar X_t) - {\bf E}_{\pi_{\theta_t}}f(Y) \right) \tilde X_t^\top \nabla_x f(X_t) \notag \\
&=& \underbrace{-\alpha_t \nabla_\theta J(\theta_t)}_{\textrm{Direction of Steepest Descent}} - \underbrace{ 2\alpha_t ({\bf E}_{\pi_{\theta_t}}f(Y)-\beta) \left( \tilde X_t^\top \nabla_x f(X_t) - \nabla_\theta {\bf E}_{Y \sim \pi_{\theta_t}}f(Y) \right) }_{\textrm{Fluctuation term $Z_t^1$}} \notag \\
&-& \underbrace{2\alpha_t \left( f(\bar X_t) - {\bf E}_{\pi_{\theta_t}}f(Y) \right) \tilde X_t^\top \nabla_x f(X_t)}_{\textrm{Fluctuation term $Z_t^2$}}.
\end{eqnarray}
Define the error terms
\begin{equation}\begin{aligned}
\label{error}
Z_t^1 &= ({\bf E}_{\pi_{\theta_t}}f(Y)-\beta) \left( \tilde X_t^\top \nabla_x f(X_t) - \nabla_\theta {\bf E}_{\pi_{\theta_t}}f(Y) \right), \\
Z_t^2 &= \left( f(\bar X_t) - {\bf E}_{\pi_{\theta_t}}f(Y)) \right) \tilde X_t^\top \nabla_x f(X_t).
\end{aligned}\end{equation}
We have therefore decomposed the evolution of $\theta_t$ into the direction of steepest descent $-\alpha_t \nabla_\theta J(\theta_t)$ and the two fluctuation terms $\alpha_t Z_t^1$ and $\alpha_t Z_t^2$.
As in \cite{sirignano2017stochastic}, we study a cycle of stopping times to control the time periods where $|\nabla_\theta J(\theta_t)|$ is close to zero and away from zero. Let us select an arbitrary constant $\kappa>0$ and also define $\mu=\mu(\kappa)>0$ (to be chosen later). Then set $\sigma_{0}=0$ and define the cycles of random times
$$
0=\sigma_{0} \leq \tau_{1} \leq \sigma_{1} \leq \tau_{2} \leq \sigma_{2} \leq \ldots,
$$
where for $k=1,2, \ldots$
\begin{equation}\begin{aligned}
\label{cycle of time}
&\tau_{k}=\inf \left\{t>\sigma_{k-1}:\left|\nabla_\theta J\left(\theta_{t}\right)\right| \geq \kappa\right\} \\
&\sigma_{k}=\sup \left\{t>\tau_{k}: \frac{\left|\nabla_\theta J\left(\theta_{\tau_{k}}\right)\right|}{2} \leq\left|\nabla _\theta J\left(\theta_{s}\right)\right| \leq 2\left|\nabla_\theta J\left(\theta_{\tau_{k}}\right)\right| \text { for all } s \in\left[\tau_{k}, t\right] \text { and } \int_{\tau_{k}}^{t} \alpha_{s} d s \leq \mu \right\}.
\end{aligned}\end{equation}
We define the random time intervals $J_{k}=\left[\sigma_{k-1}, \tau_{k}\right)$ and $I_{k}=\left[\tau_{k}, \sigma_{k}\right)$. We introduce $\eta > 0$ which will be chosen to be sufficiently small later.
We first seek to control
\begin{equation}
\label{error integral}
\Delta^i_{\tau_k,\sigma_k + \eta} := \int_{\tau_k}^{\sigma_k + \eta} \alpha_s Z^i_s ds, \quad i =1,2
\end{equation}
and, as in \cite{sirignano2017stochastic}, we will use a Poisson equation to bound the online fluctuation terms $\Delta^{i}_{\tau_k,\sigma_k + \eta}$. For this, we first prove some ergodic properties for the multi-dimensional OU process \eqref{process}.
\begin{proposition}
\label{ergodic estimation}
Let $p_t(x,x',\theta)$ and $p_\infty(x', \theta)$ denote the transition probability and invariant density of the multi-dimensional OU process \eqref{process}. Under Assumption \ref{condition}, we have the following ergodic result:
\begin{itemize}
\item[(\romannumeral1)] For any $m>0$, there exists a constant $C=C(m)$ such that
\begin{equation}
\label{invariant density}
\left|\nabla_\theta^i p_{\infty}\left(x^{\prime}, \theta\right)\right| \leq \frac{C}{1+\left|x^{\prime}\right|^m}, \quad i = 0, 1, 2.
\end{equation}
\item[(\romannumeral2)] For any $m', k$ there exist constants $C,m$ such that for any $t>1$
\begin{equation}
\label{x prime decay}
\left| \nabla_\theta^i p_{t}\left(x, x^{\prime}, \theta\right) - \nabla_\theta^i p_{\infty}\left(x^{\prime}, \theta\right)\right| \leq \frac{C\left(1+|x|^{m}\right)}{\left(1+\left|x^{\prime}\right|^{m^{\prime}}\right)(1+t)^{k}}, \quad i=0,1,2.
\end{equation}
\item[(\romannumeral3)] For any $m^{\prime}, k$ there exists constants $C, m$ such that for any $t>1$
\begin{equation}
\label{x decay}
\left|\nabla_{x}^{j} \nabla_\theta^i p_{t}\left(x, x^{\prime}, \theta\right)\right| \leq \frac{C\left(1+|x|^{m}\right)}{\left(1+\left|x^{\prime}\right|^{m^{\prime}}\right)(1+t)^{k}}, \quad i = 0, 1, \quad j = 1,2.
\end{equation}
\begin{comment}{\item[(\romannumeral4)]
And when $t \in (0,1]$ we have
\begin{equation}
\label{x theta finite time}
\left|\nabla_{x}^{j} \nabla_\theta^i p_{t}\left(x, x^{\prime}, \theta\right)\right| \leq C t^{-\frac{d+j}{2}} \exp \left(-c\frac{\left|x-x^{\prime}\right|^{2}}{t}\right), \quad i = 0, 1, 2, \quad j = 0, 1.
\end{equation}
\end{comment}
\item[(\romannumeral4)] For any $m>0$, there exists a constant $C=C(m)$ such that for any $t\ge 0$
\begin{equation}
\label{normal bound}
{\bf E}_x \left| X_t^\theta \right|^m \le C(1+|x|^m), \quad {\bf E}_{x, \tilde x} \left| \tilde X_t^\theta \right|^m \le C(1+|x|^m+|\tilde x|^m),
\end{equation}
where ${\bf E}_{x}, {\bf E}_{x, \tilde x}$ denotes that $X_0 = x, \tilde X_0 = \tilde x$.
\item[(\romannumeral5)] For any polynomially bounded function $f$ satisties \eqref{poly}, there exists constant $C, m$ such that when $t\in[0, 1]$
\begin{equation}
\label{expectation bound}
\left| \nabla^j_x \nabla^i_\theta {\bf E}_x f(X_t^\theta) \right| \le C(1+|x|^m), \quad i = 0,1, \quad j=0,1,2.
\end{equation}
\end{itemize}
\end{proposition}
\begin{remark}
Proposition \ref{ergodic estimation} is similar to Theorem $1$ in \cite{pardoux2003poisson}. However, the assumption of uniform boundedness in \cite{pardoux2001poisson} does not hold for the multi-dimensional OU process \eqref{process}. Thus we give a brief proof by direct calculations in Section \ref{ergodic appendix}.
\end{remark}
We must analyze the fluctuation terms $Z_t^1$ and $Z_t^2$. In order to do this, we prove a polynomially-bounded solution exists to a new class of Poisson PDEs. The polynomial bound is in the spatial coordinates and, importantly, the bound is uniform in the parameter $\theta$. A Poisson PDE was also used in \cite{sirignano2017stochastic}. However, several key innovations are required for the online optimization algorithm \eqref{update} that we consider in this paper. Unlike in \cite{sirignano2017stochastic}, $\tilde X_t^\theta$ in \eqref{tilde theta} does not have a diffusion term, which means $(X^\theta_t, \tilde X_t^\theta)$ is a degenerate diffusion process and its generator $\mathcal{L}_{x,\tilde x}^\theta$ is not a uniformly elliptic operator. Thus we cannot use the results from \cite{pardoux2001poisson, pardoux2003poisson}. Instead, we must prove existence and bounds for this new class of Poisson PDEs.
\begin{lemma}
\label{poisson eq}
Define the error function
\begin{equation}
\label{function}
G^1(x,\tilde x, \theta) = ({\bf E}_{\pi_\theta} f(Y)-\beta) \left(\tilde x^\top \nabla_x f(x) - \nabla_\theta {\bf E}_{\pi_\theta}f(Y) \right)
\end{equation}
and the function
\begin{equation}
\label{representation}
v^1(x, \tilde x, \theta) = -\int_0^\infty {\bf E}_{x,\tilde x} G^1(X_t^\theta,\tilde X_t^\theta, \theta) dt,
\end{equation}
where ${\bf E}_{x,\tilde x}$ is the conditional expectation given that $X_0 = x$ and $\tilde X_0 = \tilde x$. Then, under Assumption \ref{condition}, $v^1(x,\tilde x, \theta)$ is the classical solution of the Poisson equation
\begin{equation}
\label{PDE}
\mathcal{L}_{x,\tilde x}^\theta u(x,\tilde x, \theta) = G^1(x,\tilde x, \theta),
\end{equation}
where $u = (u_1, \ldots, u_\ell)^\top \in \mathbb{R}^\ell$ is a vector, $\mathcal{L}_{x,\tilde x}^\theta u(x,\tilde x, \theta) = (\mathcal{L}_{x,\tilde x}^\theta u_1(x,\tilde x, \theta), \ldots, \mathcal{L}_{x,\tilde x}^\theta u_{\ell}(x,\tilde x, \theta))^\top$, and $\mathcal{L}^\theta_{x,\tilde x}$ is the infinitesimal generator of the process $(X_\cdot^\theta, \tilde X_\cdot^\theta)$, i.e. for any test function $\varphi$
\begin{equation}
\mathcal{L}^\theta_{x,\tilde x} \varphi(x,\tilde x) = \mathcal{L}_x^\theta \varphi(x, \tilde x) + \text{tr}\left( \nabla_{\tilde x}\varphi(x, \tilde x)^\top \left( \nabla_\theta g(\theta) - \nabla_\theta h(\theta) x - h(\theta) \tilde x \right) \right) .
\end{equation}
Furthermore, the solution $v^1$ satisfies the bound
\begin{equation}\begin{aligned}
\label{control v1}
\left| v^1(x, \tilde x, \theta)\right| + \left|\nabla_\theta v^1(x, \tilde x, \theta)\right|+\left|\nabla_x v^1(x, \tilde x, \theta)\right| + \left|\nabla_{\tilde x} v^1(x, \tilde x, \theta)\right| \le C\left(1+ |x|^{m'} + |\tilde x|^{m^{\prime}}\right),
\end{aligned}\end{equation}
where $C$ is a constant which does not depend upon $(x,\tilde x, \theta)$.
\end{lemma}
\begin{proof}
We begin by proving that the integral \eqref{representation} is finite. We divide \eqref{representation} into two terms:
\begin{eqnarray}
v^1(x,\tilde x, \theta) &=& ( {\bf E}_{\pi_\theta} f(Y) - \beta) \int_0^\infty \left( \nabla_\theta {\bf E}_{\pi_\theta}f(Y) - {\bf E}_{x,\tilde x} (\tilde X_t^\theta)^\top \nabla_xf(X_t^\theta) \right) dt \notag \\
&=& ({\bf E}_{\pi_\theta} f(Y) - \beta) \left[ \int_0^\infty \left( \nabla_\theta {\bf E}_{\pi_\theta}f(Y) - \nabla_\theta {\bf E}_{x} f(X_t^\theta) \right) dt + \int_0^\infty \left( \nabla_\theta {\bf E}_{x} f(X_t^\theta) - {\bf E}_{x,\tilde x} (\tilde X_t^\theta)^\top \nabla_xf(X_t^\theta) \right) dt \right] \notag \\
&=:& v^{1,1}(x, \theta) + v^{1,2}(x, \tilde x, \theta).
\end{eqnarray}
By Assumption \ref{condition} and \eqref{invariant density},
\begin{equation}
\left|\int_{\mathbb{R}^d} f(x') \nabla^i_\theta p_\infty(x',\theta) dx' \right| \le C\int \frac{ 1 + |x'|^m }{1 + |x'|^{m'} } dx' \overset{(a)}{\le} C, \quad i = 0, 1, 2,
\end{equation}
where step $(a)$ is by choosing $m'>m+d$. Thus by dominated convergence theorem (DCT):
\begin{equation}
\label{theta bound}
\left| \nabla^i_\theta {\bf E}_{\pi_\theta} f(Y) \right| = \left|\int_{\mathbb{R}^d} f(x') \nabla^i_\theta p_\infty(x',\theta) dx' \right| \le C, \quad i =0,1,2.
\end{equation}
Similarly, we can bound $v^{1,1}$ as follows:
\begin{equation}\begin{aligned}
\label{control v11}
\left| v^{1,1}(x,\theta) \right| &\overset{(a)}{\le} C \int_0^1 \left( 1 + \left| \nabla_\theta {\bf E}_{x} f(X_t^\theta) \right| \right)dt + C \int_1^\infty \int_R \left( 1 + |x'|^m \right) \left| \nabla_\theta p_\infty(x',\theta) - \nabla_\theta p_t(x, x', \theta) \right|dx'dt \\
&\overset{(b)}{\le} C + C \int_0^\infty \int_R \left( 1 + |x'|^m \right) \frac{1+|x|^{m'}}{(1+|x'|^{m''})(1+t)^2} dx'dt \\
&\overset{(c)}{\le} C \left( 1 + |x|^{m'} \right),
\end{aligned}\end{equation}
where steps $(a)$ is by Assumption \ref{condition} and \eqref{theta bound}, step $(b)$ by \eqref{x prime decay} and \eqref{expectation bound}, and step $(c)$ follows from selecting $m'' > m+d$. For $v^{1,2}$, by Assumption \ref{condition} and \eqref{normal bound} we have
\begin{equation}
\label{pre DCT}
\left| {\bf E}_{x, 0} (\tilde X_t^\theta)^\top \nabla f(X_t^\theta) \right| \le {\bf E}_0 \left|\tilde X_t^\theta\right|^2 + {\bf E}_x \left|\nabla f(X_t^\theta)\right|^2 \le C < \infty.
\end{equation}
Thus by DCT we have
\begin{equation}
\label{change order gradient theta}
\nabla_\theta {\bf E}_{x} f(X_t^\theta) = {\bf E}_{x} \nabla_\theta f(X_t^\theta) = {\bf E}_{x, 0} (\tilde X_t^\theta)^\top \nabla f(X_t^\theta),
\end{equation}
which together with \eqref{tilde} derives
\begin{eqnarray}
\label{tilde x cal}
\nabla_\theta {\bf E}_{x} f(X_t^\theta) - {\bf E}_{x,\tilde x} (\tilde X_t^\theta)^\top \nabla f(X_t^\theta) &=& {\bf E}_{x, 0} (\tilde X_t^\theta)^\top \nabla f(X_t^\theta) - {\bf E}_{x,\tilde x} (\tilde X_t^\theta)^\top \nabla f(X_t^\theta) \notag \\
&=& -(e^{-h(\theta)t} \tilde x)^\top {\bf E}_{x} \nabla f\left(X_t^\theta\right).
\end{eqnarray}
Thus, $v^{1,2}$ satisfies the bound
\begin{equation}\begin{aligned}
\label{control v12}
\left| v^{1,2}(x, \tilde x, \theta) \right| &= \left| ({\bf E}_{\pi_\theta} f(Y) -\beta) \int_0^\infty (e^{-h(\theta)t} \tilde x)^\top {\bf E}_{x} \nabla f\left(X_t^\theta\right) dt \right| \\
&\overset{(a)}{\le} C \int_0^\infty \left( 1 + {\bf E}_{x} \left|X_t^\theta\right|^m \right) e^{-ct} dt \cdot \left| \tilde x \right| \\
&\overset{(b)}{\le} C \int_0^\infty \left( 1 + |x|^{m'} \right) e^{-ct} dt \cdot \left| \tilde x \right| \\
&\le C \left(1 + |x|^{m'} + |x'|^{m'} \right),
\end{aligned}\end{equation}
where step $(a)$ is by Assumption \ref{condition}, \eqref{theta bound} and $\lambda_{\max} \left( e^{-h(\theta)t} \right) \le e^{-ct}$. Step $(b)$ is by \eqref{normal bound}.
Next we show $v^1(x,\tilde x, \theta)$ is differentiable with respect to $x, \tilde x,$ and $\theta$. We can prove this using a version of the dominated convergence theorem (see Theorem 2.27 in \cite{folland1999real}), where it suffices to show that the derivative of the integrand is bounded by an integrable function. Using the same analysis as in \eqref{control v12}, we can show that
\begin{equation}
\label{control vxtilde}
\left| \int_0^\infty e^{-h(\theta)t} {\bf E}_{x} \nabla f(X_t^\theta) dt \right| \le C \int_0^\infty \left( 1 + {\bf E}_{x} \left|X_t^\theta\right|^m \right) e^{-ct} dt \le C \left(1 + |x|^{m'} \right).
\end{equation}
Therefore, by the dominated convergence theorem, we know $v^1$ is differentiable with respect to $\tilde x$. Furthermore, we can change the order of $\nabla_{\tilde x}$ and the integral in $v^1$ and obtain
\begin{equation}
\left| \nabla_{\tilde x} v^1(x, \tilde x, \theta) \right| = \left| ({\bf E}_{\pi_\theta} f(Y) -\beta) \int_0^\infty e^{-h(\theta)t} {\bf E}_{x} \nabla f\left(X_t^\theta\right) dt \right| \overset{(a)}{\le} C \left(1 + |x|^{m'} \right),
\end{equation}
where step $(a)$ is by \eqref{theta bound} and \eqref{control vxtilde}.
By \eqref{x prime decay}, \eqref{theta bound}, and the same approach as in \eqref{control v11}, we have
\begin{equation}
\begin{aligned}
\label{cal 1}
&\left| \nabla_\theta {\bf E}_{\pi_\theta} f(Y) \int_1^\infty \left( \nabla_\theta {\bf E}_{\pi_\theta}f(Y) - \nabla_\theta {\bf E}_{x} f(X_t^\theta) \right) dt + \left( {\bf E}_{\pi_\theta} f(Y) - \beta \right) \int_1^\infty \left( \nabla^2_\theta {\bf E}_{\pi_\theta}f(Y) - \nabla^2_\theta {\bf E}_{x} f(X_t^\theta) \right) dt \right| \\
\le& C \int_1^\infty \int_{\mathbb{R}^d} \left| f(x') \nabla_\theta \left[ p_\infty(x',\theta) - p_t(x, x', \theta) \right] \right| dx'dt + C \int_1^\infty \int_{\mathbb{R}^d} \left| f(x') \nabla_\theta^2 \left[ p_\infty(x',\theta) - p_t(x, x', \theta) \right] \right| dx' dt \\
\le& C \left( 1 + |x|^{m'} \right).
\end{aligned}
\end{equation}
By \eqref{expectation bound} and \eqref{theta bound},
\begin{equation}
\label{cal 2}
\left| \nabla_\theta {\bf E}_{\pi_\theta} f(Y) \int_0^1 \nabla_\theta {\bf E}_{\pi_\theta}f(Y) - \nabla_\theta {\bf E}_{x} f(X_t^\theta) dt + \left( {\bf E}_{\pi_\theta} f(Y) - \beta \right) \int_0^1 \nabla^2_\theta {\bf E}_{\pi_\theta}f(Y) - \nabla^2_\theta {\bf E}_{x} f(X_t^\theta) dt \right| \le C \left( 1 + |x|^{m'}\right).
\end{equation}
By \eqref{cal 1}, \eqref{cal 2}, and DCT we know $v^{1,1}$ is differentiable with respect to $\theta$ and
\begin{equation}
\label{control v11 theta}
\left| \nabla_\theta v^{1,1}(x,\theta) \right|
\le C \left( 1 + |x|^{m'}\right) .
\end{equation}
For $\nabla_\theta v^{1,2}$, by \eqref{tilde x cal} we have for any $i \in \{1,2,\cdots, \ell \}$
\begin{equation}\begin{aligned}
\label{change order v12}
&\left| \int_0^\infty \frac{\partial}{\partial \theta_i} \left( \nabla_\theta {\bf E}_{x} f(X_t^\theta) - {\bf E}_{x,\tilde x} (\tilde X_t^\theta)^T \nabla_xf(X_t^\theta) \right) dt \right| \\
=& \left| \int_0^\infty \left( \frac{\partial}{\partial \theta_i} e^{-h(\theta)t} \tilde x\right)^\top {\bf E}_{x} \nabla f\left(X_t^\theta\right) dt + \int_0^\infty \left( e^{-h(\theta)t} \tilde x\right)^\top \frac{\partial}{\partial \theta_i} {\bf E}_{x} \nabla f\left(X_t^\theta\right) dt \right| \\
\overset{(a)}{\le}& \left|\tilde x\right| \cdot \int_0^\infty \left|\frac{\partial}{\partial \theta_i} e^{-h(\theta)t}\right| \cdot \left|{\bf E}_x \nabla_x f(X_t^\theta)\right| dt + \left|\tilde x\right| \cdot \int_0^\infty \left|e^{-h(\theta)t}\right| \cdot \left|{\bf E}_x \frac{\partial}{\partial \theta_i} \nabla_x f(X_t^\theta)\right| dt\\
=&: I_4 + I_5.
\end{aligned}\end{equation}
where in step $(a)$ we use
\begin{equation}
\frac{\partial}{\partial \theta_i} {\bf E}_{x} \nabla f\left(X_t^\theta\right) = {\bf E}_x \frac{\partial}{\partial \theta_i} \nabla_x f(X_t^\theta),
\end{equation}
which is due to \eqref{pre DCT} and \eqref{change order gradient theta}.
By \eqref{norm},
\begin{equation}\begin{aligned}
\label{I4}
& I_4 \le C\left| \tilde x\right| \left( \left| \int_0^1 {\bf E}_x \nabla_x f(X_t^\theta) e^{-ct} t dt \right| + \left| \int_1^\infty {\bf E}_x \nabla_x f(X_t^\theta) e^{-ct} t dt \right| \right) \\
\overset{(a)}{\le}& C |\tilde x| \left( 1 + \int_1^\infty e^{-ct}t \int_{\mathbb{R}^d} \left( 1 + |x'|^{m} \right)\left| p_t(x, x', \theta) - p_\infty(x',\theta) \right| dx'dt + \int_1^\infty e^{-ct}t \int_{\mathbb{R}^d} \left( 1 + |x'|^{m} \right) \left| p_\infty(x',\theta) \right| dx'dt \right) \\
\overset{(b)}{\le}& C \left( 1 + |x|^{m'} + |\tilde x|^{m'} \right),
\end{aligned}\end{equation}
where in step (a) we used \eqref{expectation bound} and step $(b)$ is by \eqref{invariant density}, \eqref{x prime decay}, and the same analysis as in \eqref{theta bound} and \eqref{control v11}. Similarly,
\begin{equation}\begin{aligned}
\label{I5}
I_5 \le& C\left| \tilde x\right| \left( \int_0^1 \left|{\bf E}_x \frac{\partial}{\partial \theta_i} \nabla_x f(X_t^\theta)\right| e^{-ct} dt + \int_1^\infty \left|{\bf E}_x \frac{\partial}{\partial \theta_i} \nabla_x f(X_t^\theta)\right| e^{-ct} dt \right) \\
\le& C |\tilde x| + C |\tilde x| \cdot \int_1^\infty e^{-ct} \int_{\mathbb{R}^d} \left( 1 + |x'|^{m} \right)\left| \frac{\partial}{ \partial \theta_i} p_t(x, x', \theta) - \frac{\partial}{ \partial \theta_i} p_\infty(x',\theta) \right| dx'dt \\
+& C |\tilde x| \cdot \int_1^\infty e^{-ct} \int_{\mathbb{R}^d} \left( 1 + |x'|^{m} \right) \left| \frac{\partial}{ \partial \theta_i} p_\infty(x',\theta) \right| dx'dt \\
\le& C \left( 1 + |x|^{m'} + |\tilde x|^{m'} \right).
\end{aligned}\end{equation}
Combining \eqref{control v12}, \eqref{change order v12}, \eqref{I4}, \eqref{I5}, and DCT, we know
$v^{1,2}$ is differentiable with respect to $\theta$ and for any $i \in \{1,2,\cdots, \ell\}$
\begin{equation}
\label{control v12 theta}
\left|\frac{\partial v^{1,2}}{\partial \theta_i}(x, \tilde x, \theta)\right| \le \left| \frac{\partial}{\partial \theta_i} {\bf E}_{\pi_\theta} f(Y) \int_0^\infty (e^{-h(\theta)t} \tilde x)^\top {\bf E}_{x} \nabla_x f\left(X_t^\theta\right) dt\right|
+ \left|{\bf E}_{\pi_\theta} f(Y) -\beta \right| \cdot (I_4 + I_5) \le C\left(1+ |x|^{m'} + |\tilde x|^{m^{\prime}}\right),
\end{equation}
which together with \eqref{control v11 theta} yields
\begin{equation}
\left|\nabla_\theta v^1(x, \tilde x, \theta)\right| \le C\left(1+ |x|^{m'} + |\tilde x|^{m^{\prime}}\right).
\end{equation}
Similarly, by \eqref{x decay}, \eqref{normal bound}, and \eqref{expectation bound},
$$
\begin{aligned}
&\left| \int_0^\infty \nabla_x \left( \nabla_\theta {\bf E}_{\pi_\theta}f(Y) - \nabla_\theta {\bf E}_{x} f(X_t^\theta) \right) dt \right| \\
=& \left| \int_0^1 \nabla_x \nabla_\theta {\bf E}_{x} f(X_t^\theta) dx'dt \right| + \left| \int_1^{+\infty} \int_{\mathbb{R}} f(x') \nabla_x \nabla_\theta p_t(x,x',\theta) dx'dt \right| \\
\le& C \left( 1 + |x|^{m'} \right)
\end{aligned}
$$
and
$$
\left| \int_0^\infty \nabla_x\left( \nabla_\theta {\bf E}_{x} f(X_t^\theta) - {\bf E}_{x,\tilde x} (\tilde X_t^\theta)^\top \nabla_xf(X_t^\theta) \right) dt \right| = \left|\int_0^\infty (e^{-h(\theta)t} \tilde x)^\top \nabla_x \left( {\bf E}_{x} \nabla_x f\left(X_t^\theta\right) \right) dt \right| \le C \left(1 + |x|^{m'} + |\tilde x|^{m'} \right).
$$
By DCT and \eqref{theta bound},
\begin{equation}\begin{aligned}
\label{control v1 x}
\left| \nabla_x v^{1,1}(x, \theta) \right| &= \left| \left( {\bf E}_{\pi_\theta} f(Y) - \beta \right) \int_0^\infty \int_{\mathbb{R}^d} f(x') \nabla_x \nabla_ \theta p_t(x, x', \theta) dx'dt \right| \le C \left( 1 + |x|^{m'} \right), \\
\left| \nabla_x v^{1,2}(x, \tilde x, \theta) \right| &= \left| ({\bf E}_{\pi_\theta} f(Y) -\beta) \int_0^\infty (e^{-h(\theta)t} \tilde x)^\top \nabla_x \left( {\bf E}_{x} \nabla_x f\left(X_t^\theta\right) \right) dt \right| \le C \left(1 + |x|^{m'} + |\tilde x|^{m'} \right).
\end{aligned}\end{equation}
Then, for $\nabla_x^2 v^1(x,\tilde x, \theta)$, we have
$$
\begin{aligned}
&\left| \int_0^\infty \nabla^2_x \left( \nabla_\theta {\bf E}_{\pi_\theta}f(Y) - \nabla_\theta {\bf E}_{x} f(X_t^\theta) \right) dt \right| \\
=& \left| \int_0^1 \nabla^2_x \nabla_\theta {\bf E}_{x} f(X_t^\theta) dx'dt \right| + \left|\int_0^\infty \int_{\mathbb{R}^d} f(x') \nabla^2_x \nabla_ \theta p_t(x, x', \theta) dx'dt \right| \\
\le& C \left( 1 + |x|^{m'} \right),\\
\end{aligned}
$$
and
$$
\begin{aligned}
\left| \int_0^\infty \nabla^2_x\left( \nabla_\theta {\bf E}_{x} f(X_t^\theta) - {\bf E}_{x,\tilde x} (\tilde X_t^\theta)^\top \nabla_x f(X_t^\theta) \right) dt \right| &= \left| \int_0^\infty (e^{-h(\theta)t} \tilde x)^\top \nabla^2_x \left( {\bf E}_{x} \nabla_x f\left(X_t^\theta\right) \right) dt \right| \le C \left(1 + |x|^{m'} + |\tilde x|^{m'} \right).
\end{aligned}
$$
By DCT and \eqref{theta bound},
\begin{equation}\begin{aligned}
\label{control v1 xx}
\left| \nabla_x^2 v^{1,1}(x, \theta) \right| &=\left| \left( {\bf E}_{\pi_\theta} f(Y) - \beta \right) \int_0^\infty \int_{\mathbb{R}^d} f(x') \nabla^2_x \nabla_ \theta p_t(x, x', \theta) dx'dt \right| \le C \left( 1 + |x|^{m'} \right), \\
\left| \nabla_x^2 v^{1,2}(x, \tilde x, \theta) \right| &=\left| ({\bf E}_{\pi_\theta} f(Y) -\beta) \int_0^\infty (e^{-h(\theta)t} \tilde x)^\top \nabla^2_x \left( {\bf E}_{x} \nabla_x f\left(X_t^\theta\right) \right) dt \right| \le C \left(1 + |x|^{m'} + |\tilde x|^{m'} \right).
\end{aligned}\end{equation}
Finally, we verify that $v^1$ is a solution to the PDE \eqref{PDE}. Note that
\begin{equation}
\label{fubini 1}
\int_0^\infty {\bf E}_{x,\tilde x} {\bf E}_{X^\theta_s,\tilde X_s^\theta} \left| G^1(X_t^\theta,\tilde X_t^\theta, \theta) \right| dt \overset{(a)}{=} \int_0^\infty {\bf E}_{x,\tilde x} \left| G^1(X_{t+s}^\theta,\tilde X_{t+s}^\theta, \theta) \right| dt \overset{(b)}{=} \int_s^\infty {\bf E}_{x,\tilde x} \left| G^1(X_{t}^\theta,\tilde X_{t}^\theta, \theta) \right| dt \overset{(c)}{<} \infty,
\end{equation}
where step $(a)$ is by the Markov property of the process $(X_\cdot^\theta, \tilde X_\cdot^\theta)$, step $(b)$ by change of variables and step $(c)$ is by
the convergence of $v^1$. By Fubini's theorem,
\begin{equation}
\label{fubini 2}
{\bf E}_{x,\tilde x} v^1(X_s^\theta, \tilde X_s^\theta, \theta) = {\bf E}_{x,\tilde x} \int_0^\infty {\bf E}_{X^\theta_s,\tilde X_s^\theta} G^1(X_t^\theta,\tilde X_t^\theta, \theta) dt = \int_0^\infty {\bf E}_{x,\tilde x} {\bf E}_{X^\theta_s,\tilde X_s^\theta} G^1(X_t^\theta,\tilde X_t^\theta, \theta) dt.
\end{equation}
Combining \eqref{fubini 1} and \eqref{fubini 2}, we have that
\begin{equation}\begin{aligned}
\label{weak solution}
\frac{1}{s} \left[ {\bf E}_{x,\tilde x} v^1(X_s^\theta, \tilde X_s^\theta, \theta) - v^1(x, \tilde x, \theta) \right] &= \frac{1}{s} \left[ - \int_0^\infty {\bf E}_{x,\tilde x} {\bf E}_{X^\theta_s,\tilde X_s^\theta} G^1(X_t^\theta,\tilde X_t^\theta, \theta) dt + \int_0^\infty {\bf E}_{x,\tilde x} G^1(X_t^\theta,\tilde X_t^\theta, \theta) dt \right]\\
&= \frac{1}{s} \left[ - \int_0^\infty {\bf E}_{x,\tilde x} G^1(X_{t+s}^\theta,\tilde X_{t+s}^\theta, \theta) dt + \int_0^\infty {\bf E}_{x,\tilde x} G^1(X_t^\theta,\tilde X_t^\theta, \theta) dt \right]\\
&= \frac{1}{s} \left[ - \int_s^\infty {\bf E}_{x,\tilde x} G^1(X_{t}^\theta,\tilde X_{t}^\theta, \theta) dt + \int_0^\infty {\bf E}_{x,\tilde x} G^1(X_t^\theta,\tilde X_t^\theta, \theta) dt \right]\\
&= \frac{1}{s} \int_0^s{\bf E}_{x,\tilde x} G^1(X_t^\theta,\tilde X_t^\theta, \theta) dt,
\end{aligned}\end{equation}
Let $s \to 0^+$. By the definition of the infinitesimal generator and since $v^1(x,\tilde x, \theta)$ is twice differentiable with respect to $x$ and once differentiable with respect to $\tilde x$, $v^1(x,\tilde x,\theta)$ is the classical solution of the Poisson PDE \eqref{PDE}.
\end{proof}
We will need bounds on the moments of $X_t$ and $\tilde X_t$ in order to analyze the error term $\Delta^i_{\tau_k, \sigma_k + \eta}$.
\begin{lemma}
\label{moment}
For any $p>0$, there exists a constant $C_p$ that only depends on $p$ such that the processes $X_t, \tilde X_t$ from \eqref{update} satisfy
\begin{equation}
\label{moment bound}
{\bf E}_x |X_t|^p \le C_p\left( 1 + |x|^p \right), \quad {\bf E}_{x,\tilde x} |\tilde X_t|^p \le C_p\left( 1 + |x|^p + |\tilde x|^p \right).
\end{equation}
Furthermore, we have the bounds
\begin{equation}\begin{aligned}
\label{uniform moment bound}
{\bf E}_x \left( \sup\limits_{0 \le t' \le t} |X_{t'}|^p \right) &= O(\sqrt t) \quad \text{as}\ t \to \infty,\\
{\bf E}_{x, \tilde x} \left( \sup\limits_{0 \le t' \le t} |\tilde X_{t'}|^p \right) &= O(\sqrt t) \quad \text{as}\ t \to \infty.\\
\end{aligned}\end{equation}
\end{lemma}
\begin{proof}
By adapting the method in \cite{fang2017adaptive}, we first prove \eqref{moment bound} for $p \geq 2$ and then the result for $0<p<2$ follows from Hölder's inequality. Let $p = 2m$ and applying Itô's formula to $e^{m \alpha t}\left|X_{t}\right|^{2m}$, we have for any $t \ge 0$,
\begin{equation}\begin{aligned}
\label{p order}
e^{p \alpha t / 2}\left|X_t\right|^{p}-\left|X_{0}\right|^{p} &\leq \int_{0}^{t} p\left(\frac{\alpha}{2}\left|X_{t}\right|^{2}+ \langle X_{s}, g(\theta_s) - h(\theta_s) X_{s} \rangle \right) e^{p \alpha s / 2}\left|X_{s}\right|^{p-2} ds \\
&+\int_{0}^{t} \frac{p(p-1)d}{2} e^{p \alpha s / 2}\left|X_{s}\right|^{p-2} ds + \int_{0}^{t} p e^{p \alpha s / 2}\left|X_{s}\right|^{p-2} \langle X_s, \ dW_{s} \rangle,
\end{aligned}\end{equation}
where $\langle a,\ b\rangle := a^T b$. By Assumption \ref{condition}, we know there exists constants $\alpha>0, \beta>d$ such that for any $\theta$
\begin{equation}
\label{ergodic}
\langle x, g(\theta) - h(\theta) x \rangle \le -\alpha |x|^2 + \beta.
\end{equation}
Thus by taking expectations on both sides of \eqref{p order} and using \eqref{ergodic}, we obtain
$$
{\bf E}_x \left[ e^{p \alpha t / 2}\left|X_{t}\right|^{p}\right]- \left|x\right|^{p} \leq \int_{0}^{t} -\frac{p \alpha}{2} {\bf E}_x \left[ e^{p \alpha s / 2}\left|X_{s}\right|^{p}\right] ds +\int_{0}^{t} {\bf E}_x \left[\frac{p(p+1) \beta}{2} e^{p \alpha s / 2}\left|X_{s}\right|^{p-2}\right] ds.
$$
Young's inequality implies that
$$
\frac{p(p+1) \beta}{2} \mathrm{e}^{p \alpha s / 2}\left|X_{s}\right|^{p-2} \leq \frac{p \alpha}{2} e^{p \alpha s / 2}\left|X_{s}\right|^{p}+c_{p}e^{p \alpha s / 2}
$$
where $c_{p}=\left(\frac{p-2}{p \alpha}\right)^{p / 2-1}(\beta(p+1))^{p / 2}$. Therefore, we obtain
$$
{\bf E}_x \left[ e^{p \alpha t / 2}\left|X_{t}\right|^{p}\right]- \left|x\right|^{p} \leq \int_{0}^{t} c_{p} \mathrm{e}^{p \alpha s / 2} ds
$$
and
$$
{\bf E}_x \left|X_{t}\right|^{p} \leq \frac{2 c_{p}}{p \alpha} + e^{-p \alpha t / 2} \left|x\right|^{p} \leq C_{p}\left( 1 + |x|^p \right).
$$
Using the moment bound for $X_t$, we can derive the moment bound for $\tilde X_t$. From \eqref{tilde} and \eqref{update} we know
\begin{equation}
\label{tilde x}
\tilde X_t = e^{-\int_0^th(\theta_u)du}\tilde X_0 + \int_0^t e^{-\int_s^t h(\theta_u)du} \left( \nabla_\theta g(\theta_s) - \nabla_\theta h(\theta_s)X_s \right) ds
\end{equation}
and thus
\begin{equation}\begin{aligned}
\label{tilde bound}
{\bf E}_{x,\tilde x}|\tilde X_t|^p &\le 2|\tilde x|^p + 2{\bf E}_{x, \tilde x}\left| \int_0^t \left| e^{-\int_s^t h(\theta_u)du}\right| \cdot \left| \nabla_\theta g(\theta_s) - \nabla_\theta h(\theta_s)X_s \right| ds \right|^p\\
&\overset{(a)}{\le} 2|\tilde x|^p + C_p {\bf E}_{x, \tilde x}\left| \int_0^t e^{-c(t-s)} \left( 1 + |X_s| \right) ds \right|^p\\
&\le 2|\tilde x|^p + C_p {\bf E}_{x}\left| \int_0^t \frac{e^{cs}}{e^{ct} - 1} \left( 1 + |X_s| \right) ds \right|^p e^{-cp t}\left( e^{ct} - 1 \right)^p \\
&\overset{(b)}{\le} 2|\tilde x|^p + C_p {\bf E}_x\left| \int_0^t \frac{e^{cs}}{e^{ct} - 1} \left( 1 + |X_s| \right)^p ds \right|\\
&\le C_p \left( 1 + |x|^p + |\tilde x|^p \right),
\end{aligned}\end{equation}
where step $(a)$ is by Assumption \ref{condition} and the fact
\begin{equation}
\lambda_{\max} \left( e^{-\int_s^{t'} h(\theta_u)du} \right) = e^{ -\lambda_{\min}\left( \int_s^{t'} h(\theta_u)du \right)} \le e^{-c(t'-s)}
\end{equation}
and step (b) is by Jensen's inequality.
To prove \eqref{uniform moment bound}, we use a similar method as in \cite{pardoux2001poisson}. By Itô's formula, we have for $p \ge 1$
\begin{equation}\begin{aligned}
\left|X_{t}\right|^{2p}-\left|X
_{0}\right|^{2p} &\leq \int_{0}^{t} 2p \left| X_s \right|^{2p-1} \left( g(\theta_s) - h(\theta_s) X_{s} \right) ds + \int_{0}^{t} pd(2p-1) \left|X_{s}\right|^{2p-2} ds + 2p \int_{0}^{t} \left|X_{s}\right|^{2p-2} \langle X_s, \ dW_{s} \rangle\\
&\le C_p \int_{0}^{t} \left|X_{s}\right|^{2p-2} ds + 2p \int_{0}^{t} \left|X_{s}\right|^{2p-2} \langle X_s, \ dW_{s} \rangle.
\end{aligned}\end{equation}
Using the Burkholder-Davis-Gundy inequality, there exists a constant $C$ such that
\begin{equation}
\label{uniform}
{\bf E}_{x}\left(\sup _{t^{\prime} \leq t}\left|X_{t^{\prime}}\right|^{2 p}\right) \leq |x|^{2 p} + C_p \left({\bf E}_{x} \int_{0}^{t}\left|X_{s}\right|^{4 p-2} d s\right)^{1 / 2} + C_p {\bf E}_{x} \int_{0}^{t}\left|X_{s}\right|^{2 p-2} ds,
\end{equation}
which together with estimate \eqref{moment bound} can be used to derive the bound
\begin{equation}
{\bf E}_{x}\left(\sup _{t' \leq t}\left|X_{t'}\right|^{2 p}\right) \leq |x|^{2p} + C_p \left(t+t^{1 / 2}\right)\left(1+|x|^{2 p-1}\right).
\end{equation}
Furthermore, for $t \geq 1$,
\begin{equation}
\label{p}
{\bf E}_{x}\left(\sup _{t^{\prime} \le t}\left|X_{t^{\prime}}\right|^{p}\right) \overset{(a)}{\leq} \left( {\bf E}_{x} \sup _{t^{\prime} \leq t}\left|X_{t^{\prime}}\right|^{2p}\right)^{\frac12}
\le \left( |x|^{2p} + C_p \left(t+t^{1 / 2}\right)\left(1+|x|^{2 p-1}\right) \right)^{\frac12}
\le |x|^{p} + C_p \left(1+|x|^{p - \frac12}\right) \sqrt{t},
\end{equation}
where step (a) is by H\"{o}lder inequality. Similarly, we have for any $p^{\prime}<p$ and $t \geq 1$ that
\begin{equation}
\label{p'}
{\bf E}_{x}\left(\sup_{t^{\prime} \leq t}\left|X_{t^{\prime}}\right|^{p^{\prime}}\right) \leq C|x|^{p^{\prime}}+C\left(1+|x|^{p-\frac12}\right) t^{\frac{p'}{2p}},
\end{equation}
and thus the result for $X_t$ in \eqref{uniform moment bound} follows. Finally, similarly as in \eqref{tilde bound},
\begin{equation}\begin{aligned}
\label{relation}
{\bf E}_{x, \tilde x} \sup_{t' \le t} |\tilde X_{t'}|^p &\le 2|\tilde x|^p + 2{\bf E}_{x, \tilde x}\sup_{t' \le t}\left| \int_0^{t'} \left| e^{-\int_s^{t'} h(\theta_u)du} \right| \cdot \left| \nabla_\theta g(\theta_s) - \nabla_\theta h(\theta_s)X_s \right| ds \right|^p\\
&\le 2|\tilde x|^p + C_p {\bf E}_x \sup_{t' \le t} \left| \int_0^{t'} e^{-c(t'-s)} \left( 1 + |X_s| \right) ds \right|^p\\
&\le 2|\tilde x|^p + C_p {\bf E}_x \sup_{t' \le t} \left( 1 + |X_{t'}|^p \right).
\end{aligned}\end{equation}
Combining \eqref{p}, \eqref{p'}, and \eqref{relation}, we can prove the bound for $\tilde X_t$ in \eqref{uniform moment bound}.
\end{proof}
Using the estimates in Lemma \ref{poisson eq} and Lemma \ref{moment}, we can now bound the first fluctuation term $\Delta^1_{\tau_k, \sigma_k + \eta}$ in \eqref{error integral}.
\begin{lemma}
\label{fluctuation 1}
Under Assumption \ref{condition}, for any fixed $\eta>0$
\begin{equation}
\label{errors conv}
\left|\Delta^1_{\tau_k, \sigma_k + \eta}\right| \rightarrow 0 \text { as } k \rightarrow \infty, \quad \text{a.s.}
\end{equation}
\end{lemma}
\begin{proof}
The idea is to use the Poisson equation in Lemma \ref{poisson eq} to derive an equivalent expression for the term $\Delta^i_{\tau_k, \sigma_k + \eta}$ which we can appropriately control as $k$ becomes large. Consider the function
$$
G^1(x,\tilde x, \theta) = ({\bf E}_{\pi_\theta} f(Y)- \beta) \left( \tilde x^\top \nabla f(x) - \nabla_\theta {\bf E}_{\pi_\theta}f(Y) \right).
$$
By Lemma \ref{poisson eq}, the Poisson equation $ \mathcal{L}^\theta_{x\tilde x} u(x,\tilde x, \theta) = G^1(x, \tilde x, \theta) $ will have a unique smooth solution $v^1(x, \tilde x, \theta)$ that grows at most polynomially in $(x, \tilde x)$. Let us apply Itô's formula to the function
$$
u^1(t, x, \tilde x, \theta) := \alpha_{t} v^1(x, \tilde x, \theta) \in \mathbb{R}^\ell,
$$
evaluated on the stochastic process $(X_t, \tilde X_t, \theta_t)$. Recall that $u_i$ denotes the $i$-th element of $u$ for $i \in \{1,2,\cdots, \ell\}$. Then,
\begin{equation}\begin{aligned}
u^1_i\left(\sigma, X_{\sigma}, \tilde X_\sigma, \theta_{\sigma}\right) =& u^1_i\left(\tau, X_{\tau}, \tilde X_\tau, \theta_{\tau}\right) + \int_{\tau}^{\sigma} \partial_{s} u^1_i\left(s, X_{s}, \tilde X_s, \theta_{s}\right) ds + \int_{\tau}^{\sigma} \mathcal{L}^{\theta_s}_{x\tilde x} u^1_i\left(s, X_{s}, \tilde X_s, \theta_{s}\right) ds \\
+& \int_{\tau}^{\sigma} \left \langle \nabla_\theta u^1_i\left(s, X_{s}, \tilde X_s, \theta_{s}\right), \ d\theta_s \right \rangle + \int_{\tau}^{\sigma} \left\langle \nabla_{x} u^1_i\left(s, X_{s}, \tilde X_s, \theta_{s}\right), \ dW_{s} \right\rangle.
\end{aligned}\end{equation}
Rearranging the previous equation, we obtset the representation
\begin{equation}\begin{aligned}
\label{representation 1}
\Delta^1_{\tau_k,\sigma_k + \eta} =& \int_{\tau_{k}}^{\sigma_{k}+ \eta} \alpha_{s} G^1(X_s, \tilde X_s, \theta_s) ds = \int_{\tau_{k}}^{\sigma_{k}+\eta} \mathcal{L}^{\theta_s}_{x\tilde x} u^1\left(s, X_{s}, \tilde X_s, \theta_{s}\right) ds \\
=& \alpha_{\sigma_{k}+ \eta} v^1\left(X_{\sigma_{k}+\eta}, \tilde X_{\sigma_{k}+\eta}, \theta_{\sigma_{k}+\eta}\right)-\alpha_{\tau_{k}} v^1\left(X_{\tau_{k}}, \tilde X_{\tau_{k}}, \theta_{\tau_{k}}\right)-\int_{\tau_{k}}^{\sigma_{k}+\eta} \alpha'_{s} v^1\left(X_{s}, \tilde X_s, \theta_{s}\right) ds \\
+&\int_{\tau_{k}}^{\sigma_{k}+\eta} 2\alpha^2_{s} \nabla_\theta v^1\left(X_{s}, \tilde X_s, \theta_{s}\right) (f(\bar X_s) - \beta) \tilde X_s^\top \nabla f(X_s) ds - \int_{\tau_{k}}^{\sigma_{k}+\eta} \alpha_s \nabla_{x} v^1\left(X_{s}, \tilde X_s, \theta_{s}\right) dW_{s}.
\end{aligned}\end{equation}
The next step is to treat each term on the right hand side of \eqref{representation 1} separately. For this purpose, let us first set
\begin{equation}
J_{t}^{1,1}=\alpha_{t} \sup _{s \in[0, t]}\left|v^1\left(X_{s}, \tilde X_s, \theta_{s}\right)\right|.
\end{equation}
By \eqref{control v1} and \eqref{uniform moment bound}, there exists a constant $C$ that only depends on $m'$ such that
\begin{equation}\begin{aligned}
{\bf E} \left|J_{t}^{1,1}\right|^{2} &\leq C \alpha_{t}^{2} {\bf E} \left[1 + \sup _{s \in[0, t]}\left|X_{s}\right|^{m'} + \sup _{s \in[0, t]}\left|\tilde X_{s}\right|^{m'} \right]\\
&= C \alpha_{t}^{2}\left[1+\sqrt{t} \frac{{\bf E} \sup _{s \in[0, t]}\left|X_{s}\right|^{m'} + {\bf E} \sup _{s \in[0, t]}\left|\tilde X_{s}\right|^{m'} }{\sqrt{t}} \right] \\
&\leq C \alpha_{t}^{2} \sqrt{t}.
\end{aligned}\end{equation}
Let $p>0$ be the constant in Assumption \ref{condition} such that $\lim _{t \rightarrow \infty} \alpha_{t}^{2} t^{1 / 2+2 p}=0$ and for any $\delta \in(0, p)$ define the event $A_{t, \delta}=\left\{J_{t}^{1,1} \geq t^{\delta-p}\right\} .$ Then we have for $t$ large enough such that $\alpha_{t}^{2} t^{1 / 2+2 p} \leq 1$
$$
{\bf P} \left(A_{t, \delta}\right) \leq \frac{{\bf E}\left|J_{t}^{1,1}\right|^{2}}{t^{2(\delta-p)}} \leq C \frac{\alpha_{t}^{2} t^{1 / 2+2 p}}{t^{2 \delta}} \leq C \frac{1}{t^{2 \delta}}.
$$
The latter implies that
$$
\sum_{n \in \mathbb{N}} {\bf P} \left(A_{2^{n}, \delta}\right)<\infty.
$$
Therefore, by the Borel-Cantelli lemma we have that for every $\delta \in(0, p)$ there is a finite positive random variable $d(\omega)$ and some $n_{0}<\infty$ such that for every $n \geq n_{0}$ one has
$$
J_{2^{n}}^{1, 1} \leq \frac{d(\omega)}{2^{n(p-\delta)}}.
$$
Thus, for $t \in\left[2^{n}, 2^{n+1}\right)$ and $n \geq n_{0}$ one has for some finite constant $C<\infty$
$$
J_{t}^{1, 1} \leq C \alpha_{2^{n+1}} \sup _{s \in\left(0,2^{n+1}\right]}\left| v^1\left(X_{s}, \tilde X_s, \theta_{s}\right) \right| \leq C \frac{d(\omega)}{2^{(n+1)(p-\delta)}} \leq C \frac{d(\omega)}{t^{p-\delta}},
$$
which proves that for $t \geq 2^{n_{0}}$ with probability one
\begin{equation}
\label{conv 1}
J_{t}^{1, 1} \leq C \frac{d(\omega)}{t^{p-\delta}} \rightarrow 0, \text { as } t \rightarrow \infty.
\end{equation}
Next we consider the term
$$
J_{t, 0}^{1,2} = \int_{0}^{t}\left|\alpha_{s}^{\prime} v^1\left(X_{s}, \tilde X_s, \theta_{s}\right) - 2\alpha^2_{s} \nabla_\theta v^1\left(X_{s}, \tilde X_s, \theta_{s}\right) (f(\bar X_s) - \beta) \tilde X_s^T \nabla f(X_s) \right| ds.
$$
There exists a constant $0<C<\infty$ (that may change from line to line ) and $0< m' <\infty$ such that
$$
\begin{aligned}
\sup _{t>0} {\bf E} \left|J_{t, 0}^{1,2}\right| & \overset{(a)}{\le} K \int_{0}^{\infty}\left(\left|\alpha_{s}^{\prime}\right|+\alpha_{s}^{2}\right)\left(1+{\bf E}\left|X_{s}\right|^{m'} + {\bf E}|\tilde X_t|^{m'}\right) ds \\
& \overset{(b)}{\le} C \int_{0}^{\infty}\left(\left|\alpha_{s}^{\prime}\right|+\alpha_{s}^{2}\right) d s \\
& \leq C,
\end{aligned}
$$
where step $(a)$ is by Assumption \ref{condition} and \eqref{control v1} and in step $(b)$ we use \eqref{moment bound}. Thus there is a finite random variable $J_{\infty, 0}^{1, 2}$ such that
\begin{equation}
\label{conv 2}
J_{t, 0}^{1, 2} \rightarrow J_{\infty, 0}^{1, 2}, \text{as} \ t \rightarrow \infty \ \text{with probability one}.
\end{equation}
The last term we need to consider is the martingale term
$$
J_{t, 0}^{1, 3}=\int_{0}^{t} \alpha_s \nabla_{x} v^1\left(X_{s}, \tilde X_s, \theta_{s}\right) d W_{s}.
$$
By Doob's inequality, Assumption \ref{condition}, \eqref{control v1}, \eqref{moment bound}, and using calculations similar to the ones for the term $J_{t, 0}^{1, 2}$, we can show that for some finite constant $C<\infty$,
$$
\sup _{t>0} {\bf E} \left|J_{t, 0}^{1, 3} \right|^{2} \le C \int_{0}^{\infty} \alpha_{s}^{2} d s<\infty
$$
Thus, by Doob's martingale convergence theorem there is a square integrable random variable $J_{\infty, 0}^{1,3}$ such that
\begin{equation}
\label{conv 3}
J_{t, 0}^{1, 3} \to J_{\infty, 0}^{1, 3},\quad \text{as} \ t \to \infty \ \text{ both almost surely and in $L^{2}$}.
\end{equation}
Let us now return to \eqref{representation 1}. Using the terms $J_{t}^{1,1}, J_{t, 0}^{1,2}$, and $J_{t, 0}^{1,3}$ we can write
$$
\left|\Delta^1_{\tau_k, \sigma_k+ \eta}\right| \leq J_{\sigma_{k}+\eta}^{1,1}+J_{\tau_{k}}^{1,1}+\left|J_{\sigma_{k}+\eta, \tau_{k}}^{1,2}\right| + \left|J_{\sigma_{k}+\eta, \tau_{k}}^{1,3}\right|,
$$
which together with \eqref{conv 1}, \eqref{conv 2}, and \eqref{conv 3} prove the statement of the Lemma.
\end{proof}
Now we prove a similar convergence result for $\Delta^2_{\tau_k, \sigma_k + \eta}$. We first prove an extension of Lemma \ref{poisson eq} for the Poisson equation.
\begin{lemma}
\label{poisson eq 2}
Define the error function
\begin{equation}
\label{function 2}
G^2(x,\tilde x, \bar x, \theta) = [ f(\bar x) - {\bf E}_{\pi_{\theta}}f(Y) ] \tilde x^\top \nabla f(x).
\end{equation}
Under Assumption \ref{condition}, the function
\begin{equation}
\label{representation2}
v^2(x, \tilde x, \bar x, \theta) = -\int_0^\infty {\bf E}_{x,\tilde x,\bar x} G^2(X_t^\theta,\tilde X_t^\theta, \bar X_t^\theta, \theta) dt
\end{equation}
is the classical solution of the Poisson equation
\begin{equation}
\label{PDE 2}
\mathcal{L}^\theta_{x, \tilde x, \bar x} u(x, \tilde x, \bar x, \theta) = G^2(x, \tilde x, \bar x, \theta),
\end{equation}
where $\mathcal{L}^\theta_{x,\tilde x,\bar x}$ is generator of the process $(X_\cdot^\theta, \tilde X_\cdot^\theta, \bar X_\cdot^\theta)$, i.e. for any test function $\varphi$
\begin{equation}
\mathcal{L}^\theta_{x,\tilde x,\bar x} \varphi(x,\tilde x, \bar x) = \mathcal{L}_{x,\tilde x}^\theta \varphi(x, \tilde x, \bar x) + \mathcal{L}_{\bar x}^\theta \varphi(x, \tilde x, \bar x).
\end{equation}
Furthermore, this solution satisfies the bound
\begin{equation}\begin{aligned}
\label{control v2}
\left| v^2(x, \tilde x, \bar x, \theta)\right|+\left| \nabla_{\bar x} v^2(x, \tilde x, \bar x, \theta)\right| + \left|\nabla_\theta v^2(x, \tilde x, \bar x, \theta)\right| + \left| \nabla_x v^2(x, \tilde x, \bar x, \theta)\right| \le C\left(1+ |x|^{m'} + |\tilde x|^{m'} + |\bar x|^{m^{\prime}}\right),
\end{aligned}\end{equation}
where $C$ is a constant independent of $(x,\tilde x, \bar x, \theta)$.
\end{lemma}
\begin{proof}
The proof is exactly the same as in Lemma \ref{poisson eq} except for the presence of the dimension $\bar x$ and $\mathcal{L}_{\bar x}$. We first show that the integral in \eqref{representation2} converges. Note that
\begin{eqnarray}
v^2(x,\tilde x, \bar x, \theta) &=& \int_0^\infty
{\bf E}_{x,\tilde x, \bar x}[ {\bf E}_{\pi_{\theta}}f(Y) - f(\bar X_t^\theta) ] \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle dt \notag \\
&\overset{(a)}{=}& \int_0^\infty \left[ {\bf E}_{\pi_{\theta}}f(Y) - {\bf E}_{\bar x}f(\bar X_t^\theta) \right] \cdot {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle dt,
\end{eqnarray}
where step $(a)$ is by the independence of $\bar X^\theta_\cdot$ and $(X^\theta_\cdot, \tilde X^\theta_\cdot)$.
We now prove a uniform bound for $ {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle$ and then by the ergodicity of $\bar X^\theta_\cdot$ in Lemma \ref{ergodic estimation} we can show that the integrals converge.
\begin{equation}\begin{aligned}
\left| {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle \right| &= \left| {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle - \nabla_\theta {\bf E}_x f(X_t^\theta) + \nabla_\theta {\bf E}_x f(X_t^\theta) \right|\\
&\overset{(a)}{\le} \left| \tilde x^T e^{-h(\theta)t} {\bf E}_{x} \nabla f(X_t^\theta) \right| + \left| \nabla_\theta {\bf E}_x f(X_t^\theta) \right|,
\end{aligned}\end{equation}
where step $(a)$ is by \eqref{tilde x cal}. Therefore, if $t\in[0,1]$, we can conclude
\begin{equation}
\label{control v2 half 1}
\left| \tilde x^T e^{-h(\theta)t} {\bf E}_{x} \nabla f(X_t^\theta) \right| + \left| \nabla_\theta {\bf E}_x f(X_t^\theta) \right| \le C \left(1 + \left| x \right|^{m'} + \left| \tilde x \right|^{m'} \right),
\end{equation}
where we have used Assumption \ref{condition} and equation \eqref{expectation bound}. For $t>1$, we have
\begin{equation}
\begin{aligned}
\label{control v2 half 2}
&\left| \tilde x^T e^{-h(\theta)t} {\bf E}_{x} \nabla f(X_t^\theta) \right| + \left| \nabla_\theta {\bf E}_x f(X_t^\theta) \right|\\
\overset{(a)}{\le}& C \left(1 + {\bf E}_x \left|X_t^\theta\right|^m \right) \cdot \left| \tilde x \right| + C \int_{\mathbb{R}^d} \left( 1 + |x'|^m \right) \left| \nabla_\theta p_t(x, x', \theta) - \nabla_\theta p_\infty(x', \theta) \right| dx' + C \int_{\mathbb{R}^d} \left( 1 + |x'|^m \right) \left| \nabla_\theta p_\infty(x', \theta) \right| dx' \\
\overset{(b)}{\le}& C \left(1 + \left| x \right|^{m'} + \left| \tilde x \right|^{m'} \right),
\end{aligned}
\end{equation}
where step $(a)$ uses Assumption \ref{condition} and step $(b)$ uses Proposition \ref{ergodic estimation} and the same calculations as in \eqref{theta bound} and \eqref{control v11}. Combining \eqref{control v2 half 1} and \eqref{control v2 half 2}, we have for any $t\ge0$
\begin{equation}
\label{control v2 half}
\left| {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle \right| \le C \left(1 + \left| x \right|^{m'} + \left| \tilde x \right|^{m'} \right).
\end{equation}
Thus, by \eqref{control v2 half} and the same derivation as in \eqref{control v11}, we have
\begin{eqnarray}
\left| v^2(x,\tilde x, \bar x, \theta) \right| &\le& C \left(1 + \left| x \right|^{m'} + \left| \tilde x \right|^{m'} \right) \cdot \int_0^\infty \left| {\bf E}_{\bar x} f(\bar X_t^\theta) - {\bf E}_{\pi_{\theta}}f(Y) \right| dt \notag \\
&\le& C\left(1+ |x|^{m'} + |\tilde x|^{m'} + |\bar x|^{m^{\prime}}\right).
\end{eqnarray}
We next show that $v^2(x,\tilde x, \bar x, \theta)$ is differentiable with respect to $x, \tilde x, \bar x, \theta$. Similar to Lemma \ref{poisson eq}, we first change the order of differentiation and integration and show the corresponding integral exists. Then, we apply DCT to prove that the differentiation and integration can be interchanged. For the ergodic process $\bar X_\cdot^\theta$, by \eqref{control v2 half}, \eqref{x decay}, and \eqref{expectation bound}, we have the bounds
\begin{equation}\begin{aligned}
\int_0^\infty \int_{\mathbb{R}^d} \left| f(\bar x') \nabla_{\bar x} p_t(\bar x, \bar x', \theta) \right| d\bar x' \cdot \left| {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle \right|dt &\le C\left(1+ |x|^{m'} + |\tilde x|^{m'} + |\bar x|^{m^{\prime}}\right), \\
\int_0^\infty \int_{\mathbb{R}^d} \left| f(\bar x') \nabla^2_{\bar x} p_t(\bar x, \bar x', \theta) \right| d\bar x' \cdot \left| {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle \right| dt &\le C\left(1+ |x|^{m'} + |\tilde x|^{m'} + |\bar x|^{m^{\prime}}\right),
\end{aligned}\end{equation}
and thus by the DCT
\begin{equation}
\sum_{i=1}^2 \left| \nabla^i_{\bar x} v^2(x,\tilde x, \bar x, \theta) \right| \le C\left(1+ |x|^{m'} + |\tilde x|^{m'} + |\bar x|^{m^{\prime}}\right).
\end{equation}
To address $\nabla_x v^2, \nabla_x^2 v^2$, we first note that for any $i,j \in \{1,2,\cdots, d\}$
\begin{equation}\begin{aligned}
\left| \nabla_x {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta,\ \nabla f(X_t^\theta) \rangle \right| &\le \left| \tilde x^T e^{-h(\theta)t} \nabla_x {\bf E}_{x} \nabla f(X_t^\theta) \right| + \left| \nabla_x \nabla_\theta {\bf E}_x f(X_t^\theta) \right| \overset{(a)}{\le} C \left(1 + \left| x \right|^{m'} + \left| \tilde x \right|^{m'} \right),\\
\left| \frac{\partial^2 }{\partial x_i \partial x_j} {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle \right| &\le \left| \tilde x^T e^{-h(\theta)t} \frac{\partial^2 }{\partial x_i \partial x_j} {\bf E}_{x} \nabla f(X_t^\theta) \right| + \left| \frac{\partial^2 }{\partial x_i \partial x_j} \nabla_\theta {\bf E}_x f(X_t^\theta) \right| \overset{(a)}{\le} C \left(1 + \left| x \right|^{m'} + \left| \tilde x \right|^{m'} \right),
\end{aligned}\end{equation}
where in step $(a)$ we use \eqref{x decay} when $t>1$ and \eqref{expectation bound} for $t\in[0,1]$. Thus we have $ \forall i,j \in \{1,2,\cdots, d\}$
\begin{equation}\begin{aligned}
\int_0^\infty \left| \left[ {\bf E}_{\pi_{\theta}}f(Y) - {\bf E}_{\bar x}f(\bar X_t^\theta) \right] \right| \cdot \left| \nabla_x {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle \right| dt &\le C\left(1+ |x|^{m'} + |\tilde x|^{m'} + |\bar x|^{m^{\prime}}\right),\\
\int_0^\infty \left| \left[ {\bf E}_{\pi_{\theta}}f(Y) - {\bf E}_{\bar x}f(\bar X_t^\theta) \right] \right| \cdot \left| \frac{\partial^2}{\partial x_i \partial x_j} {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle \right| dt &\le C\left(1+ |x|^{m'} + |\tilde x|^{m'} + |\bar x|^{m^{\prime}}\right).
\end{aligned}\end{equation}
Then by DCT,
\begin{equation}
\sum_{i=1}^2 \left| \nabla^i_x v^2(x,\tilde x,\bar x, \theta) \right| \le C\left(1+ |x|^{m'} + |\tilde x|^{m'} + |\bar x|^{m^{\prime}}\right).
\end{equation}
Then for $\nabla_\theta v^2$, first we have for any $i \in \{1,2,\cdots, \ell\}$
\begin{equation}\begin{aligned}
\left| \frac{\partial}{\partial \theta_i} {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta,\ \nabla f(X_t^\theta) \rangle \right| &\le \left| \tilde x^\top \left(\frac{\partial }{\partial \theta}_i e^{-h(\theta)t}\right) {\bf E}_{x} \nabla f(X_t^\theta) \right| + \left| \tilde x^\top e^{-h(\theta)t} \frac{\partial }{\partial \theta}_i {\bf E}_{x} \nabla f(X_t^\theta) \right| + \left| \frac{\partial}{\partial \theta_i} \nabla_\theta {\bf E}_x f(X_t^\theta) \right| \\
&\overset{(a)}{\le} C \left(1 + \left| x \right|^{m'} + \left| \tilde x \right|^{m'} \right),
\end{aligned}\end{equation}
where in step $(a)$ we use \eqref{norm} and the same analysis as in \eqref{I5}. Thus
\begin{equation}
\begin{aligned}
&\left| \int_0^\infty \frac{\partial}{\partial \theta_i} \left( \left[ {\bf E}_{\pi_{\theta}}f(Y) - {\bf E}_{\bar x}f(\bar X_t^\theta) \right] \cdot {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle \right) dt \right| \\
\le& \int_0^\infty \int_{\mathbb{R}^d} \left| f(x') \frac{\partial}{\partial \theta_i} \left( p_\infty(\bar x', \theta) - p_t(\bar x, \bar x', \theta) \right) \right| d\bar x' \cdot \left| {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle \right| dt\\
+& \int_0^\infty \int_{\mathbb{R}^d} \left| f(x') \left( p_\infty(\bar x', \theta) - p_t(\bar x, \bar x', \theta) \right) \right| d\bar x' \cdot \left| \frac{\partial }{\partial \theta_i}{\bf E}_{x,\tilde x} \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle \right| dt\\
\le& C\left(1+ |x|^{m'} + |\tilde x|^{m'} + |\bar x|^{m^{\prime}}\right),
\end{aligned}
\end{equation}
which together with the DCT derives
\begin{equation}
\left| \nabla_\theta v^2(x,\tilde x,\bar x, \theta) \right| \le C\left(1+ |x|^{m'} + |\tilde x|^{m'} + |\bar x|^{m^{\prime}}\right).
\end{equation}
Finally, note that
\begin{equation}\begin{aligned}
&\left| \int_0^\infty \nabla_{\tilde x} \left( \left[ {\bf E}_{\pi_{\theta}}f(Y) - {\bf E}_{\bar x}f(\bar X_t^\theta) \right] \cdot {\bf E}_{x,\tilde x} \langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle \right) dt \right| \\
\le& \int_0^\infty \left| \left[ {\bf E}_{\pi_{\theta}}f(Y) - {\bf E}_{\bar x} f(\bar X_t^\theta) \right] \right| \cdot \left| \nabla_{\tilde x} {\bf E}_{x,\tilde x,}\langle \tilde X_t^\theta, \ \nabla f(X_t^\theta) \rangle \right| dt \\
\le& C\int_0^\infty \left| \left[ {\bf E}_{\pi_{\theta}}f(Y) - {\bf E}_{\bar x}f(\bar X_t^\theta) \right] \right| \cdot \left| {\bf E}_{x} e^{-h(\theta)t} \nabla f(X_t^\theta) \right| dt \\
\le& C\left(1+ |x|^{m'} + |\bar x|^{m^{\prime}}\right)
\end{aligned}\end{equation}
and then by DCT
\begin{equation}
\left| \nabla_{\tilde x}v^2(x,\tilde x, \bar x, \theta) \right| \le C\left(1+ |x|^{m'} + |\bar x|^{m^{\prime}}\right).
\end{equation}
By the same calculations as in \eqref{weak solution}, we know $v^2$ is the classical solution of PDE \eqref{PDE 2} and the bound \eqref{control v2} holds.
\end{proof}
\begin{lemma}
\label{fluctuation 2}
Under Assumption \ref{condition}, for any fixed $\eta>0$, we have
\begin{equation}
\label{errors conv 2}
\left|\Delta^2_{\tau_k, \sigma_k + \eta}\right| \rightarrow 0, \text { as } k \rightarrow \infty, \quad \text{a.s.}.
\end{equation}
\end{lemma}
\begin{proof}
Consider the function
\begin{equation}
G^2(x,\tilde x, \bar x, \theta) = \left[ f(\bar x) - {\bf E}_{\pi_{\theta}}f(Y)\right] \tilde x^\top \nabla f(x).
\end{equation}
Let $v^2$ be the solution of \eqref{PDE 2} in Lemma \ref{poisson eq 2}. We apply Itô formula to the function $u^2(t, x, \tilde x, \bar x, \theta)=\alpha_{t} v^2(x, \tilde x, \bar x, \theta)$
evaluated on the stochastic process $(X_t, \tilde X_t, \bar X_t, \theta_t)$ and get for any $i \in \{1,2,\cdots, \ell\}$
\begin{equation}\begin{aligned}
&u^2_i\left(\sigma, X_{\sigma}, \tilde X_{\sigma}, \bar X_\sigma,\theta_{\sigma}\right)-u^2_i\left(\tau, X_{\tau}, \tilde X_\tau, \bar X_\tau, \theta_{\tau}\right) \\
=& \int_{\tau}^{\sigma} \partial_{s} u^2_i\left(s, X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right) ds + \int_{\tau}^{\sigma} \mathcal{L}^{\theta_s}_{x,\tilde x} u^2_i\left(s, X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right) ds + \int_{\tau}^{\sigma} \mathcal{L}^{\theta_s}_{\bar x} u^2_i\left(s, X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right) ds\\
+& \int_{\tau}^{\sigma} \langle \nabla_{\theta} u^2_i\left(s, X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right), \ d\theta_s \rangle + \int_{\tau}^{\sigma} \langle \nabla_{x} u_i^2\left(s, X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right), \ dW_{s} \rangle + \int_{\tau}^{\sigma} \langle \nabla_{\bar x} u^2_i\left(s, X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right), \ d\bar W_{s} \rangle.
\end{aligned}\end{equation}
Rearranging the previous equation, we obtain the representation
\begin{equation}\begin{aligned}
\label{representation 2}
&\Delta^2_{\tau_k,\sigma_k + \eta} = \int_{\tau_{k}}^{\sigma_{k}+ \eta} \alpha_{s} G^2( X_s, \tilde X_s, \bar X_s, \theta_s) ds = \int_{\tau_{k}}^{\sigma_{k}+\eta} \mathcal{L}^{\theta_s}_{x, \tilde x, \bar x} u^2\left(s, X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right) ds \\
=& \alpha_{\sigma_{k}+ \eta} v^2\left( X_{\sigma_{k}+\eta}, \tilde X_{\sigma_k+ \eta}, \bar X_{\sigma_k+ \eta}, \theta_{\sigma_{k}+\eta}\right)-\alpha_{\tau_{k}} v^2\left(X_{\tau_{k}}, \tilde X_{\tau_{k}}, \bar X_{\tau_k}, \theta_{\tau_{k}}\right)-\int_{\tau_{k}}^{\sigma_{k}+\eta} \alpha'_{s} v^2\left(X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right) ds \\
-& \int_{\tau_{k}}^{\sigma_{k}+\eta} \alpha_s \nabla_{\bar x} v^2\left(X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right) d\bar W_{s} + \int_{\tau_{k}}^{\sigma_{k}+\eta} 2\alpha^2_{s} \nabla_\theta v^2\left(X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right) \left(f(\bar X_s) - \beta\right) \tilde X_s^\top \nabla f(X_s) ds \\
-& \int_{\tau_{k}}^{\sigma_{k}+\eta} \alpha_s \nabla_{x} v^2\left(X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right) dW_s.
\end{aligned}\end{equation}
The next step is to treat each term on the right hand side of \eqref{representation 2} separately.
For this purpose, let us first set
\begin{equation}
J_{t}^{2,1}=\alpha_{t} \sup _{s \in[0, t]}\left|v^1\left(X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right)\right|.
\end{equation}
Using the same approach as for $X_t$ in Lemma \ref{moment}, we can show that for any $p>0$ there exists a constant $C_p$ that only depends on $p$ such that
\begin{equation}
\label{moment bar}
{\bf E}_{\bar x} |\bar X_t|^p \le C_p\left( 1 + |\bar x|^p \right), \quad {\bf E}_{\bar x} \left( \sup\limits_{0 \le t' \le t} |\bar X_{t'}|^p \right) = O(\sqrt t) \quad \text{as}\ t \to \infty.
\end{equation}
Combining Lemma \ref{moment}, \eqref{control v2}, and \eqref{moment bar}, we know that there exists a constant $C$ such that
\begin{equation}\begin{aligned}
{\bf E} \left|J_{t}^{2,1}\right|^{2} &\leq C \alpha_{t}^{2} {\bf E}\left[1 + \sup _{s \in[0, t]}\left|X_{s}\right|^{m'} + \sup _{s \in[0, t]}\left|\tilde X_{s}\right|^{m'} + \sup _{s \in[0, t]}\left|\bar X_{s}\right|^{m'} \right]\\
&= C \alpha_{t}^{2}\left[1+\sqrt{t} \frac{{\bf E} \sup _{s \in[0, t]}\left|X_{s}\right|^{m'} + {\bf E} \sup _{s \in[0, t]}\left|\tilde X_{s}\right|^{m'} + {\bf E} \sup _{s \in[0, t]}\left|\bar X_{s}\right|^{m'}}{\sqrt{t}} \right] \\
&\leq C \alpha_{t}^{2} \sqrt{t}.
\end{aligned}\end{equation}
Let $p>0$ be the constant in Assumption \ref{condition} such that $\displaystyle \lim _{t \rightarrow \infty} \alpha_{t}^{2} t^{1 / 2+2 p}=0$ and for any $\delta \in(0, p)$ define the event $A_{t, \delta}=\left\{J_{t}^{2,1} \geq t^{\delta-p}\right\} .$ Then we have for $t$ large enough such that $\alpha_{t}^{2} t^{1 / 2+2 p} \leq 1$ and
$$
{\bf P} \left(A_{t, \delta}\right) \leq \frac{{\bf E}\left|J_{t}^{2,1}\right|^{2}}{t^{2(\delta-p)}} \leq C \frac{\alpha_{t}^{2} t^{1 / 2+2 p}}{t^{2 \delta}} \leq C \frac{1}{t^{2 \delta}}.
$$
The latter implies that
$$
\sum_{n \in \mathbb{N}} {\bf P}\left(A_{2^{n}, \delta}\right)<\infty.
$$
Therefore, by the Borel-Cantelli lemma we have that for every $\delta \in(0, p)$ there is a finite positive random variable $d(\omega)$ and some $n_{0}<\infty$ such that for every $n \geq n_{0}$ one has
$$
J_{2^{n}}^{2,1} \leq \frac{d(\omega)}{2^{n(p-\delta)}}.
$$
Thus for $t \in\left[2^{n}, 2^{n+1}\right)$ and $n \geq n_{0}$ one has for some finite constant $C<\infty$
$$
J_{t}^{2,1} \leq C \alpha_{2^{n+1}} \sup _{s \in\left(0,2^{n+1}\right]}\left| v^1\left(X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right) \right| \leq C \frac{d(\omega)}{2^{(n+1)(p-\delta)}} \leq C \frac{d(\omega)}{t^{p-\delta}},
$$
which derives that for $t \geq 2^{n_{0}}$ we have with probability one
\begin{equation}
\label{conv 1 2}
J_{t}^{2,1} \leq C \frac{d(\omega)}{t^{p-\delta}} \rightarrow 0, \text { as } t \rightarrow \infty.
\end{equation}
Next we consider the term
$$
J_{t, 0}^{2,2}=\int_{0}^{t}\left|\alpha_{s}^{\prime} v^2\left(X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right) - 2\alpha^2_{s} \nabla_\theta v^2\left(X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right) \left(f(\bar X_s) - \beta\right) \tilde X_s^\top \nabla f(X_s) \right| ds
$$
and thus we see that there exists a constant $0<C<\infty$ such that
$$
\begin{aligned}
\sup_{t>0} {\bf E} \left|J_{t, 0}^{2,2}\right| & \overset{(a)}{\le} C \int_{0}^{\infty}\left(\left|\alpha_{s}^{\prime}\right|+\alpha_{s}^{2}\right)\left(1+{\bf E}\left|X_{s}\right|^{m'}+ {\bf E}\left|X_{s}\right|^{m'} + {\bf E}\left|\bar X_{s}\right|^{m'}\right) ds \\
& \overset{(b)}{\le} C \int_{0}^{\infty}\left(\left|\alpha_{s}^{\prime}\right|+\alpha_{s}^{2}\right) d s \\
& \leq C,
\end{aligned}
$$
where in step $(a)$ we use \eqref{control v2} and in step $(b)$ we use Lemma \ref{moment} and \eqref{moment bar}. Thus we know there is a finite random variable $J_{\infty, 0}^{2,2}$ such that
\begin{equation}
\label{conv 2 2}
J_{t, 0}^{2,2} \rightarrow J_{\infty, 0}^{2,2}, \ \text{as} \ t \rightarrow \infty \ \text{with probability one}.
\end{equation}
The last term we need to consider is the martingale term
$$
J_{t, 0}^{2,3}=\int_{0}^{t} \alpha_s \nabla_{x} v^2\left(X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right) dW_{s} + \int_{0}^{t} \alpha_s \nabla_{\bar x} v^2\left(X_{s}, \tilde X_s, \bar X_s, \theta_{s}\right) d\bar W_{s}.
$$
Notice that Doob's inequality and the bounds of \eqref{control v2} (using calculations similar to the ones for the term $J_{t, 0}^{2,2}$ ) give us that for some finite constant $K<\infty$, we have
$$
\sup _{t>0} {\bf E}\left|J_{t, 0}^{2,3}\right|^{2} \leq K \int_{0}^{\infty} \alpha_{s}^{2} d s<\infty.
$$
Thus, by Doob's martingale convergence theorem there is a square integrable random variable $J_{\infty, 0}^{(3)}$ such that
\begin{equation}
\label{conv 3 2}
J_{t, 0}^{2,3} \to J_{\infty, 0}^{2,3}, \quad
\text{as}\ t \to \infty \ \text{both almost surely and in $L^{2}$}.
\end{equation}
Let us now go back to \eqref{representation 2}. Using the terms $J_{t}^{2,1}, J_{t, 0}^{2,2}$ and $J_{t, 0}^{2,3}$ we can write
$$
\left|\Delta^2_{\tau_k, \sigma_k + \eta}\right| \leq J_{\sigma_{k}+\eta}^{2,1}+J_{\tau_{k}}^{2,1}+J_{\sigma_{k}+\eta, \tau_{k}}^{2,2}+\left|J_{\sigma_{k}+\eta, \tau_{k}}^{2,3}\right|,
$$
which together with \eqref{conv 1 2}, \eqref{conv 2 2} and \eqref{conv 3 2} prove the statement of the Lemma.
\end{proof}
By \eqref{theta bound}, we know that
\begin{equation}
\left| \nabla_\theta J(\theta) \right| = 2 \left| {\bf E}_{\pi_\theta} f(Y) - \beta \right| \cdot \left| \nabla_\theta {\bf E}_{\pi_\theta} f(Y) \right| \le C
\end{equation}
and therefore the objective function $J(\theta)$ is Lipschitz continuous with respect to $\theta$.
\begin{lemma}
\label{estimation f}
Under Assumption \ref{condition}, choose $\mu>0$ in \eqref{cycle of time} such that for the given $\kappa>0$, one has $3 \mu + \frac{\mu}{8 \kappa}=\frac{1}{2L_{\nabla J}}$, where $L_{\nabla J}$ is the Lipschitz constant of $J$ in \eqref{object}. Then for $k$ large enough and $\eta>0$ small enough (potentially random depending on $k$), one has $\int_{\tau_{k}}^{\sigma_k + \eta} \alpha_{s} d s>\mu$. In addition we also have $\frac{\mu}{2} \leq \int_{\tau_{k}}^{\sigma_{k}} \alpha_{s} d s \leq \mu$ with probability one.
\end{lemma}
\begin{proof}
We use a ``proof by contradiction". Assume that $\int_{\tau_k}^{\sigma_k+\eta} \alpha_s ds \le \mu $ and let $\delta>0$ be such that $\delta<\mu/8$. Without loss of generality, we assume that for any $k$, $\eta$ is small enough such that for any $s \in [ \tau_k, \sigma_k + \eta ]$ one has $| \nabla J(\theta_s) | \le 3 | \nabla J(\theta_{\tau_k})|$.
Combining \eqref{gradient with error} and \eqref{error}, we know
\begin{equation}
\frac{d\theta_t}{dt} = -\alpha_t \nabla J(\theta_t) - 2\alpha_t Z_t^1 - 2\alpha_t Z_t^2
\end{equation}
and thus
\begin{equation}\begin{aligned}
\label{control}
\left| \theta_{\sigma_k + \eta} - \theta_{\tau_k} \right| &\le \int_{\tau_k}^{\sigma_k+\eta} \alpha_t \left| \nabla J(\theta_t) \right| dt + 2\left|\int_{\tau_k}^{\sigma_k+\eta} \alpha_t Z_t^1dt \right| + 2 \left| \int_{\tau_k}^{\sigma_k+\eta} \alpha_t Z_t^2 dt \right| \\
&\le 3 \left| \nabla J(\theta_{\tau_k})\right| \mu + I_1 + I_2.
\end{aligned}\end{equation}
By Lemmas \ref{fluctuation 1} and \ref{fluctuation 2}, we have that for $k$ large enough,
\begin{equation}\begin{aligned}
\label{control online}
I_1 &\le 2| \Delta^1_{\tau_k, \sigma_k+\eta} | \le \delta < \mu/16\\
I_2 &\le 2| \Delta^2_{\tau_k, \sigma_k+\eta} | \le \delta < \mu/16.
\end{aligned}\end{equation}
In addition, we also have by definition that
$\frac{\kappa}{\left|\nabla J\left(\theta\left(\tau_{k}\right)\right)\right|} \le 1$. Combining \eqref{control} and \eqref{control online} yields
$$
\left|\theta_{\sigma_{k}+\eta} -\theta_{\tau_{k}} \right| \le \left|\nabla J\left(\theta_{\tau_{k}}\right)\right| \left(3 \mu+\frac{\mu}{8 \kappa}\right) = \frac{1}{2L_{\nabla J}} \left|\nabla J\left(\theta_{\tau_{k}}\right)\right|.
$$
This means that
$$
\left|\nabla J\left(\theta_{\sigma_{k}+\eta} \right)-\nabla J\left(\theta_{\tau_{k}}\right)\right| \le L_{\nabla J} \left|\theta_{\sigma_{k}+\eta} - \theta_{\tau_{k}} \right| \le \frac{1}{2}\left|\nabla J\left(\theta_{\tau_{k}} \right)\right|,
$$
and thus
$$
\frac{1}{2}\left|\nabla J\left(\theta_{\tau_{k}} \right)\right| \le \left|\nabla J\left(\theta_{\sigma_{k}+\eta} \right)\right|\le 2\left|\nabla J\left(\theta_{\tau_{k}}\right)\right|.
$$
However, this produces a contradiction since it implies $\int_{\tau_{k}}^{\sigma_{k}+\eta} \alpha_s ds > \mu$; otherwise, from the definition of $\sigma_k$ in \eqref{cycle of time}, we will have $\sigma_{k}+\eta \in$ $\left[\tau_{k}, \sigma_{k}\right]$. This concludes the proof of the first part of the lemma.
The proof of the second part of the lemma is straightforward. By its definition in \eqref{cycle of time}, we have that $\int_{\tau_{k}}^{\sigma_{k}} \alpha_s ds \le \mu$. It remains to show that $\int_{\tau_{k}}^{\sigma_{k}} \alpha_s ds \ge \frac{\mu}{2}$. We have shown that $\int_{\tau_{k}}^{\sigma_{k}+\eta} \alpha_s ds>\mu$. For $k$ large enough and $\eta$ small enough we can choose that $\int_{\sigma_{k}}^{\sigma_{k}+\eta} \alpha_s ds \le \frac{\mu}{2}$. The conclusion then follows.
\end{proof}
\begin{lemma}
\label{decreasing f}
Under Assumption \ref{condition}, suppose that there exists an infinite number of intervals $I_k = [\tau_k, \sigma_k)$. Then there is a fixed constant $ \gamma_1 = \gamma_1(\kappa) > 0$ such that for k large enough,
\begin{equation}
J(\theta_{\sigma_k}) - J( \theta_{\tau_k}) \le -\gamma_1.
\end{equation}
\end{lemma}
\begin{proof}
By chain rule, we have
\begin{equation}\begin{aligned}
J(\theta_{\sigma_k}) - J(\theta_{\tau_k}) &= - \int_{\tau_k}^{\sigma_k} \alpha_\rho \left|\nabla J(\theta_\rho)\right|^2 d\rho + \int_{\tau_k}^{\sigma_k} \alpha_\rho \langle \nabla J(\theta_\rho),\ Z^1_\rho \rangle d\rho + \int_{\tau_k}^{\sigma_k} \alpha_\rho \langle \nabla J(\theta_\rho),\ Z^2_\rho \rangle d\rho \\
&=: M_{1,k} + M_{2,k} + M_{3,k}.
\end{aligned}\end{equation}
For $M_{1, k}$, note that for $\rho \in\left[\tau_{k}, \sigma_{k}\right]$ we have $\frac{\left|\nabla J\left(\theta_{\tau_{k}} \right)\right|}{2} \le
|\nabla J(\theta_{\rho})| \le 2\left|\nabla J\left(\theta_{\tau_{k}}\right)\right|$. Thus for sufficiently large $k$, we have by Lemma \ref{estimation f}
$$
M_{1, k} \le -\frac{\left|\nabla J\left(\theta_{\tau_{k}} \right)\right|^{2}}{4} \int_{\tau_{k}}^{\sigma_{k}} \alpha_\rho d\rho \le -\frac{\left|\nabla J\left(\theta_{\tau_{k}} \right)\right|^{2}}{8} \mu.
$$
For $M_{2, k}$ and $M_{3,k}$, we can use the same method of Poisson equations as in Lemmas \ref{fluctuation 1} and \ref{fluctuation 2}. Define
\begin{equation}\begin{aligned}
\label{object error}
G^1(x,\tilde x, \theta) &= \langle \nabla_\theta J(\theta),\ ({\bf E}_{\pi_{\theta}}f(Y)-\beta) \left( \tilde x^\top \nabla f(x) - \nabla_\theta {\bf E}_{\pi_{\theta}}f(Y) \right) \rangle \\
G^2(x,\tilde x, \bar x, \theta) &= \langle \nabla_\theta J(\theta),\ \left( f(\bar x) - {\bf E}_{\pi_{\theta}}f(Y)) \right) \tilde x^\top \nabla f(x) \rangle,
\end{aligned}\end{equation}
and use the solution of the corresponding Poisson equations
\begin{eqnarray}
\mathcal{L}^\theta_{x, \tilde x} v^1(x, \tilde x, \theta) &=& G^1(x, \tilde x, \theta), \notag \\
\mathcal{L}^\theta_{x, \tilde x, \bar x} v^2(x, \tilde x, \bar x, \theta) &=& G^2(x, \tilde x, \bar x, \theta),
\end{eqnarray}
as in Lemmas \ref{fluctuation 1} and \ref{fluctuation 2} to prove $M_{2,k}, M_{3,k}\to 0$ as $k \to \infty$ almost surely.
Combining the above results, we obtain that for $k$ large enough such that $\left|M_{2, k}\right| + \left|M_{3, k}\right| \le \delta<\frac{\mu}{16} \kappa^{2}$
\begin{eqnarray}
J\left(\theta_{\sigma_{k}}\right)-J\left(\theta_{\tau_{k}} \right) &\le& -\frac{\left|\nabla J\left(\theta_{\tau_{k}} \right)\right|^{2}}{8} \mu+\delta \notag \\
&\le& -\frac{\mu}{8} \kappa^{2}+\frac{\mu}{16} \kappa^{2} \notag \\
&=& -\frac{\mu}{16} \kappa^{2}.
\end{eqnarray}
Let $\gamma_1=\frac{\mu}{16} \kappa^{2}$, which concludes the proof of the lemma.
\end{proof}
\begin{lemma}
\label{increasing f}
Under Assumption \ref{condition}, suppose that there exists an infinite number of intervals $ I_k = [\tau_k, \sigma_k)$. Then, there is a fixed constant $\gamma_2 < \gamma_1$ such that for $k$ large enough,
\begin{equation}
J(\theta_{\tau_k}) - J(\theta_{\sigma_{k-1}}) \le \gamma_2.
\end{equation}
\end{lemma}
\begin{proof}
By chain rule, we have
\begin{equation}\begin{aligned}
J(\theta_{\tau_k}) - J(\theta_{\sigma_{k-1}}) &= - \int_{\sigma_{k-1}}^{\tau_k} \alpha_\rho \left|\nabla J(\theta_\rho)\right|^2 d\rho + \int_{\sigma_{k-1}}^{\tau_k} \alpha_\rho \langle \nabla J(\theta_\rho),\ Z^1_\rho \rangle d\rho + \int_{\sigma_{k-1}}^{\tau_k} \alpha_\rho \langle \nabla J(\theta_\rho),\ Z^2_\rho \rangle d\rho \\
&\le \int_{\sigma_{k-1}}^{\tau_k} \alpha_\rho \langle \nabla J(\theta_\rho),\ Z^1_\rho \rangle d\rho + \int_{\sigma_{k-1}}^{\tau_k} \alpha_\rho \langle \nabla J(\theta_\rho),\ Z^2_\rho \rangle d\rho.
\end{aligned}\end{equation}
As in the proof of Lemma \ref{decreasing f} we get that for $k$ large enough, the right hand side of the last display can be arbitrarily small, which concludes the proof of the lemma.
\end{proof}
\begin{proof}[Proof of Theorem \ref{conv f}:]
Recalling \eqref{cycle of time}, we know $\tau_k$ is the first time $|\nabla_\theta J(\theta_t)|> \kappa$ when $t > \sigma_{k-1}$. Thus, for any fixed $\kappa>0$, if there are only finitely number of $\tau_{k}$, then there is a finite $T^{*}$ such that $\left|\nabla_\theta J(\theta_t)\right| \le \kappa$ for $t \ge T^{*}$. We now use a ``proof by contradiction". Suppose that there are infinitely many instances of $\tau_{k}$. By Lemmas \ref{decreasing f} and \ref{increasing f}, we have for sufficiently large $k$ that
$$
\begin{aligned}
&J\left(\theta_{\sigma_{k}}\right)-J\left(\theta_{\tau_{k}}\right) \le-\gamma_{1} \\
&J\left(\theta_{\tau_{k}}\right)-J\left(\theta_{\sigma_{k-1}}\right) \le \gamma_{2}
\end{aligned}
$$
with $0<\gamma_{2}<\gamma_{1}$. Choose $N$ large enough so that the above relations hold simultaneously for $k \geq N$. Then,
\begin{eqnarray}
J\left(\theta_{\tau_{n+1}}\right) - J\left(\theta_{\tau_{N}}\right) &=& \sum_{k=N}^{n}\left[J\left(\theta_{\sigma_{k}}\right) - J\left(\theta_{\tau_{k}}\right) + J\left(\theta_{\tau_{k+1}}\right) - J\left(\theta_{\sigma_{k}}\right)\right] \notag \\
&\le& \sum_{k=N}^{n}\left(-\gamma_{1}+\gamma_{2}\right) \notag \\
&<& (n - N) \times \left(-\gamma_{1}+\gamma_{2}\right).
\end{eqnarray}
Letting $n \rightarrow \infty$, we observe that $J\left(\theta_{\tau_{n}}\right) \rightarrow -\infty$, which is a contradiction, since by definition $J(\theta_t) \ge 0$. Thus, there can be at most finitely many $\tau_{k}$. Thus, there exists a finite time $T$ such that almost surely $|\nabla_\theta J(\theta)| < \kappa$ for $t \ge T$. Since $\kappa$ is arbitrarily chosen, we have proven that $|\nabla_\theta J(\theta)| \to 0$ as $t \to \infty$ almost surely.
\end{proof}
\section{Numerical Performance of the Online Algorithm}{\label{numerical experiment}}
\hspace{1.4em} In this section, we will implement the continuous-time stochastic gradient descent algorithm \eqref{nonlinear update} and evaluate its numerical performance. The algorithm is implemented for a variety of linear and nonlinear models. The algorithm is also implemented for the simultaneous optimization of both the drift and volatility functions, optimizing over a path-dependent SDE, and optimizing over the auto-covariance of an SDE. In our numerical experiments, we found that the performance of the algorithm can depend upon carefully selecting hyperparameters such as the learning rate and mini-batch size. A larger mini-batch size reduces the noise in the estimation of the gradient descent direction. The learning rate must decay as $t \rightarrow \infty$, but it should not be decreased too rapidly and the initial magnitude should be large enough so that the algorithm converges quickly.
\subsection{One-Dimensional Ornstein–Uhlenbeck Process}
\hspace{1.4em} We start with a simple case of a one-dimensional Ornstein–Uhlenbeck process $X_t^\theta \in \mathbb{R}$:
\begin{equation}
dX_t^\theta = (\theta - X_t^\theta) dt + dW_t.
\end{equation}
We will use the algorithm \eqref{nonlinear update} to learn the minimizer for
\begin{equation}
\label{linear object}
J(\theta) = ({\bf E}_{\pi_\theta} Y - 2)^2.
\end{equation}
Note that in this case we have the closed-form solution $\pi_\theta \sim N\left(\theta, \frac12\right)$ and thus the global minimizer is $\theta^* = 2$. In Figure \ref{ou mean}, the trained parameter from the online algorithm converges to the global minimizer ($\theta^* = 2$). Several different sample paths of the online algorithm are plotted.
Similarly, we use the algorithm \eqref{nonlinear update} to learn the minimizer for
\begin{equation}
\label{linear object 2}
J(\theta) = ({\bf E}_{\pi_\theta} Y^2 - 2)^2.
\end{equation}
In this case, the global minimizer is $\theta^* = \pm \sqrt{1.5}$. In Figure \ref{ou mean 2}, the parameter trained by the online algorithm converges to the global minimizer.
\begin{figure}[htbp]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{OU.eps}
\caption{ Online Algorithm for the objective function \eqref{linear object}. }
\label{ou mean}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{OU_2.eps}
\caption{ Online Algorithm for the objective function \eqref{linear object 2}. }
\label{ou mean 2}
\end{minipage}
\end{figure}
We now consider a more general Ornstein–Uhlenbeck process with parameters $\theta = (\theta^1, \theta^2)$:
\begin{equation}
\label{1 dim ou}
dX_t^\theta = (\theta^1 - \theta^2X_t^\theta ) dt + dW_t,
\end{equation}
The online algorithm \eqref{nonlinear update} is used to learn the minimizer for the objective function $ J(\theta) = ({\bf E}_{\pi_\theta} Y^2 - 2)^2 $.
A mini-batch version of the algorithm \eqref{nonlinear update} will be used:
\begin{equation}\begin{aligned}
\label{ou}
\frac{d\theta^1_t}{dt} &= -4 \alpha_t \left(\frac1N \sum\limits_{i=1}^{N} (\bar X^i_t)^2 - 2\right) \times \left( \frac1N \sum\limits_{i=1}^{N} X^i_t \tilde X^{1,i}_t \right), \\
\frac{d\theta^2_t}{dt} &= -4 \alpha_t \left(\frac1N \sum\limits_{i=1}^{N} (\bar X^i_t)^2 - 2\right) \times \left( \frac1N \sum\limits_{i=1}^{N} X^i_t \tilde X^{2,i}_t \right), \\
dX^i_t &= ( \theta^1_t - \theta_t^2 X^i_t )dt + dW^i_t, \quad i = 1,2,\cdots, N \\
d\tilde X^{1,i}_t &= (1- \theta^2_t \tilde X^{1,i}_t ) dt, \quad i = 1,2,\cdots, N \\
d\tilde X^{2,i}_t &= (- X^i_t - \theta^2_t \tilde X^{2,i}_t ) dt, \quad i = 1,2,\cdots, N \\
d\bar X^i_t &= ( \theta^1_t - \theta_t^2 \bar X^i_t )dt + d\bar W^i_t, \quad i = 1,2,\cdots, N.
\end{aligned}\end{equation}
A mini-batch size of $N = 20$ is used. $100$ experiments are run and all of the parameter training paths converge (see Figure \ref{ou 2p}). All of the paths of the objective function converge to zero (see Figure \ref{ou 2p object}).
\begin{figure}[htbp]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{double_OU.eps}
\caption{ $\theta^1, \theta^2$ evolution for the online algorithm \eqref{ou}.}
\label{ou 2p}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{double_OU_object.eps}
\caption{Objective function for the online algorithm \eqref{ou}.}
\label{ou 2p object}
\end{minipage}
\end{figure}
\subsection{One-Dimensional Nonlinear Process}
\hspace{1.4em} We now use the online algorithm to optimize over the stationary distribution of a one-dimensional nonlinear process
\begin{equation}
\label{non process}
dX_t^\theta = (\theta - X_t^\theta - (X_t^\theta)^3 ) dt + dW_t.
\end{equation}
We use the algorithm \eqref{nonlinear update} to learn the minimizer of $J(\theta) = ({\bf E}_{\pi_\theta} Y^2 - 2)^2$. The mini-batch version of the algorithm with mini-batch size $N = 100$ is used:
\begin{equation}\begin{aligned}
\label{nonlinear mini batch}
\frac{d\theta_t}{dt} &= -4\alpha_t \left( \frac1N \sum\limits_{i=1}^N (\bar X_t^i)^2 - 2 \right) \times \left( \frac1N \sum\limits_{i=1}^N X^i_t \tilde X^i_t \right), \\
dX^i_t &= \left( \theta_t - X_t^i - (X^i_t)^3 \right)dt + dW^i_t, \quad i = 1,2, \cdots, N \\
d\tilde X_t &= \left( 1- \tilde X_t^i -3 (X^i_t)^2 \tilde X_t \right) dt, \quad i = 1,2, \cdots, N\\
d\bar X_t &= \left( \theta_t - \bar X_t^i - ( \bar X^2_t)^3 \right)dt + d\bar W^i_t, \quad i = 1,2, \cdots, N.
\end{aligned}\end{equation}
We run $100$ experiments and all of the parameter training paths converge (see Figure \ref{nonlinear}). As we cannot calculate a closed-form formula for the stationary distribution $\pi_\theta$, we approximate the objective function $J(\theta)$ using a time-average since, due to the ergodic theorem, we expect that
\begin{equation}
\label{ergodic thm}
\lim\limits_{t\to \infty} \frac1t \int_0^t f(X_s^\theta) ds = {\bf E}_{\pi_\theta} f(Y) \quad \text{a.s.}
\end{equation}
For each $\theta_t$ path during the training, we can compute the approximate value of $J(\theta_t)$ along that path. In Figure \ref{nonlinear object}, the objective function decays to zero (the global minimum) very quickly.
\begin{figure}[htbp]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{nonlinear.eps}
\caption{ Parameter evolution for the online algorithm \eqref{nonlinear mini batch}.}
\label{nonlinear}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{nonlinear_object.eps}
\caption{ Objective function for the online algorithm \eqref{nonlinear mini batch}.}
\label{nonlinear object}
\end{minipage}
\end{figure}
\subsection{Optimizing over the Volatility Coefficient}
\hspace{1.4em} We now optimize over the drift and volatility functions of the process
\begin{equation}
dX_t^\theta = ( \mu - X_t^\theta) dt + \sigma dW_t
\end{equation}
with parameters $\theta = (\mu, \sigma)$.
The online algorithm \eqref{nonlinear update} is used to learn the minimizer of $J(\theta) = ({\bf E}_{\pi_\theta} Y^2 - 20)^2$. The mini-batch version of the algorithm with mini-batch size $N = 100$ is used:
\begin{equation}\begin{aligned}
\label{linear vol batch}
d\mu_t &= -4\alpha_t \left( \frac1N \sum_{i=1}^N (\bar X^i_t)^2 - 20 \right) \times \left( \frac1N \sum_{i=1}^N X^i_t \tilde X^{1,i}_t \right) dt, \\
d\sigma_t &= -4\alpha_t \left( \frac1N \sum_{i=1}^N (\bar X^i_t)^2 - 20 \right) \times \left( \frac1N \sum_{i=1}^N X^i_t \tilde X^{2,i}_t \right) dt, \\
dX^i_t &= ( \mu_t - X^i_t )dt + \sigma_t dW^i_t, \quad i=1,2, \cdots, N\\
d\tilde X^{1,i}_t &= (1- \tilde X^{1,i}_t) dt, \quad i=1,2, \cdots, N \\
d\tilde X^{2,i}_t &= - \tilde X^{2,i}_t dt + dW^i_t, \quad i=1,2, \cdots, N \\
d\bar X^i_t &= ( \mu_t - \bar X^i_t )dt + \sigma_t d\bar W^i_t, \quad i=1,2, \cdots, N.
\end{aligned}\end{equation}
In Figure \ref{linear vol}, the trained parameters $\mu_t, \sigma_t$ converge and in Figure \ref{linear vol object} the objective function $J(\theta_t) \to 0 $ very quickly.
\begin{figure}[htbp]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{linear_volatility.eps}
\caption{ $\mu, \sigma$ evolution for the online algorithm \eqref{linear vol batch}.}
\label{linear vol}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{linear_volatility_object.eps}
\caption{Objective function for the online algorithm \eqref{linear vol batch}.}
\label{linear vol object}
\end{minipage}
\end{figure}
We also implement the online algorithm for the nonlinear process
\begin{equation}
dX_t^\theta = (\mu - (X_t^\theta)^3 ) dt + \sigma X_t^\theta dW_t,
\end{equation}
where $\theta= ( \mu, \sigma)$ are the parameters and the objective function is $J(\theta) = ({\bf E}_{\pi_\theta} Y^2 - 10)^2$. The mini-batch algorithm becomes:
\begin{equation}\begin{aligned}
\label{nonlinear vol batch}
d\mu_t &= -4\alpha_t \left( \frac1N \sum_{i=1}^N (\bar X^i_t)^2 - 2 \right) \times \left( \frac1N \sum_{i=1}^N X^i_t \tilde X^{1,i}_t \right) dt, \\
d\sigma_t &= -4\alpha_t \left( \frac1N \sum_{i=1}^N (\bar X^i_t)^2 - 2 \right) \times \left( \frac1N \sum_{i=1}^N X^i_t \tilde X^{2,i}_t \right) dt, \\
dX^i_t &= ( \mu_t - (X^i_t)^3 ) dt + \sigma_t X_t^i dW^i_t, \quad i=1,2,\cdots, N\\
d\tilde X^{1,i}_t &= \left( 1 - 3 (X_t^i)^2 \tilde X^{1,i}_t \right) dt + \sigma_t \tilde X_t^{1,i} dW_t^i, \quad i=1,2, \cdots, N \\
d\tilde X^{2,i}_t &= - 3 (X_t^i)^2 \tilde X^{2,i}_t dt + \left[ X_t^i + \sigma_t \tilde X_t^{2,i} \right] dW^i_t, \quad i=1,2, \cdots, N \\
d\bar X^i_t &= ( \mu_t - (\bar X^i_t)^3 )dt + \sigma_t \bar X_t^i d\bar W^i_t, \quad i=1,2, \cdots, N.
\end{aligned}\end{equation}
In Figure \ref{nonlinear vol}, the trained parameters $\mu_t, \sigma_t$ converge and in Figure \ref{nonlinear vol object} the objective function $J(\theta_t) \to 0 $ very quickly.
\begin{figure}[htbp]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{nonlinear_volatility.eps}
\caption{ $\mu, \sigma$ evolution for \eqref{nonlinear vol batch} }
\label{nonlinear vol}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{nonlinear_volatility_object.eps}
\caption{ Objective function for \eqref{nonlinear vol batch} }
\label{nonlinear vol object}
\end{minipage}
\end{figure}
\subsection{Multi-Dimensional Independent Ornstein–Uhlenbeck Process}
\hspace{1.4em} We next consider a simple multi-dimensional Ornstein–Uhlenbeck process which consists of $m$ independent copies of \eqref{1 dim ou}. For the parameter $\theta = (\theta^1, \theta^2) \in R^{2m}$, let the m-dimensional Ornstein–Uhlenbeck process to be
\begin{eqnarray}
dX_t^\theta = (\theta^1 - \theta^2 \odot X_t^\theta ) dt + dW_t,
\end{eqnarray}
where $X_t^\theta \in R^m$, $W_t \in R^m$, and $\odot$ is an element-wise product.
The objective function is
\begin{equation}
\label{multi ou object}
J(\theta) := ( \sum_{k=1}^m E_{\pi_\theta} |Y_k|^2 - 20)^2.
\end{equation}
The online algorithm is
\begin{equation}\begin{aligned}
\label{multi ou update}
d\theta^{1}_t &= -4\alpha_t \left(|\bar X_t|^2 - 2\right) X_t \odot \tilde X^{1}_t dt, \\
d\theta^{2}_t &= -4\alpha_t \left(|\bar X_t|^2 - 2\right) X_t \odot \tilde X^{2}_t dt, \\
dX_t &= \left( \theta^{1}_t - \theta_t^{2} \odot X_t \right)dt + dW^i_t, \\
d\tilde X^{1}_t &= \left(1- \theta^{2}_t \odot \tilde X^{1}_t \right) dt, \\
d\tilde X^{2}_t &= \left(- X_t - \theta^{2}_t \odot \tilde X^{2}_t \right) dt, \\
d\bar X_t &= \left( \theta^{1}_t - \theta^{2}_t \odot \bar X_t \right)dt + d\bar W^i_t.
\end{aligned}\end{equation}
We implement the algorithm for $m =3$ and $m =10$. In Figures \ref{multi_ou_object1} and \ref{multi_ou_object2}, the objective functions $J(\theta_t) \to 0$ as $t$ becomes large.
\begin{figure}[htbp]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{multi_ou_object1.eps}
\caption{ Objective function for the online algorithm \eqref{multi ou update} when $m=3$.}
\label{multi_ou_object1}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{multi_ou_object2.eps}
\caption{Objective function for the online algorithm \eqref{multi ou update} when $m=10$.}
\label{multi_ou_object2}
\end{minipage}
\end{figure}
\subsection{Multi-Dimensional Correlated Ornstein–Uhlenbeck Process}
\hspace{1.4em} For the parameters $ \theta = (\mu, b) \in \mathbb{R}^{2m}$, let the $m$-dimensional process $X_t^{\theta}$ satisfy
\begin{equation}
\label{multi correlated process}
dX_t^\theta = \mu - (bb^T + \lambda I_m) X_t^\theta dt + dW_t,
\end{equation}
where $W_t \in \mathbb{R}^m$, $\lambda$ a positive constant, and $I_m$ is the $m \times m$ identity matrix. Define $\tilde X_t^\mu $ and $\tilde X_t^b$ as the Jacobian matrices of $X_t^\theta$ with respect to $\mu$ and $b$:
\begin{eqnarray}
\tilde X_t^\mu &=& \nabla_\mu X_t^\theta \in \mathbb{R}^{m\times m}, \notag \\
\tilde X_t^b &=& \nabla_b X_t^\theta \in \mathbb{R}^{m\times m}.
\end{eqnarray}
Then,
\begin{equation}\begin{aligned}
\frac{ d\tilde X_t^{\mu} }{dt} &= I_m - (bb^T + \lambda I_m) \tilde X_t^{\mu}, \\
\frac{ d\tilde X_t^{b, i} }{dt} &= -
\frac{\partial bb^T}{\partial b^i} X_t^\theta - (bb^T + \lambda I_m) \tilde X_t^{b, i}, \quad i = 1,2,\cdots, m
\end{aligned}\end{equation}
where $\tilde X^{b, i}_t$ is the $i$-th column of $\tilde X_t^b$.
We will use the online algorithm to minimize the objective function
$$
J(\theta) = ( E_{\pi_\theta} |Y|^2 - 20)^2.
$$
The online algorithm is
\begin{equation}\begin{aligned}
\label{multi correlated}
d\mu_t &= -4\alpha_t (|\bar X_t|^2 - 2) (\tilde X_t^{1})^T X_t dt, \\
db_t &= -4\alpha_t (|\bar X_t|^2 - 2) (\tilde X_t^{2})^T X_t dt,\\
dX_t &= \mu_t - (b_tb_t^T + \lambda I_m) X_t dt + dW_t, \\
d\bar X_t &= \mu_t - (b_tb_t^T + \lambda I_m) \bar X_t dt + d\bar W_t, \\
\frac{ d\tilde X_t^{1} }{dt} &= I_m - (b_tb_t^T + \lambda I_m) \tilde X_t^{1}, \\
\frac{ d\tilde X_t^{2, i} }{dt} &= -
\frac{\partial b_tb_t^T}{\partial b^i} X_t - (b_tb_t^T + \lambda I_m) \tilde X_t^{2, i}, \quad i = 1,2,\cdots, m.
\end{aligned}\end{equation}
We will select $\lambda =1$ and examine the algorithm's performance for dimensions $m =3, 10$. In Figures \ref{multi_correlated_mean_object1} and \ref{multi_correlated_mean_object2}, the objective function $J(\theta_t) \to 0$.
\begin{figure}[htbp]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{multi_correlated_mean_object1.eps}
\caption{Object function of the online algorithm \eqref{multi correlated} when $m =3$. }
\label{multi_correlated_mean_object1}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{multi_correlated_mean_object2.eps}
\caption{ Objective function of the online algorithm \eqref{multi correlated} when $m =10$.}
\label{multi_correlated_mean_object2}
\end{minipage}
\end{figure}
\subsection{Multi-dimensional Nonlinear SDE}
\hspace{1.4em} In our next example, we optimize over the stationary distribution of a multi-dimensional nonlinear SDE:
\begin{equation}
\label{MV process}
dX_t^{\theta, i} = \left( \theta - \frac1N \sum_{j=1}^N X_t^{\theta, i} - (X_t^{\theta, i})^3 \right) dt + dW_t^i, \quad i = 1,2,\cdots, N,
\end{equation}
where the objective function is
\begin{eqnarray}
J(\theta) = \left( \frac1N \sum_{i=1}^N E_{\pi_\theta} Y_i^2 - 2 \right)^2.
\end{eqnarray}
The nonlinear SDE (\ref{MV process}) has a mean-field limit as $N \rightarrow \infty$. Thus, for large $N$, our algorithm could also be used to optimize over the mean-field limit equation for (\ref{MV process}).
The online algorithm for (\ref{MV process}) is
\begin{equation}\begin{aligned}
\label{MV}
d\theta_t &= -4\alpha_t \left(\frac1N \sum_{i=1}^N (\bar X^i_t)^2 - 2\right) \times \left( \frac1N \sum_{i=1}^N X^i_t \tilde X^i_t \right) dt, \quad i = 1,2,\cdots, N\\
dX^i_t &= \left( \theta_t - \frac1N \sum_{i=1}^N X^i_t - (X_t^i)^3 \right)dt + dW^i_t, \quad i = 1,2,\cdots, N\\
d\tilde X^{i}_t &= \left(1 - \frac1N \sum_{i=1}^N \tilde X^{1,i}_t - 3 (X_t^i)^2 \tilde X_t^i \right) dt, \quad i = 1,2,\cdots, N\\
d\bar X^i_t &= \left( \theta_t - \frac1N \sum_{i=1}^N \bar X^i_t - (\bar X_t^i)^3 \right)dt + d\bar W^i_t, \quad i = 1,2,\cdots, N.
\end{aligned}\end{equation}
We will select $N = 100$ for our numerical experiment. In Figure \ref{MV parameter}, the parameter converges. To compute the object function $J(\theta_t)$ during training, we use a time-average. In Figure \ref{MV object}, the objective function $J(\theta_t) \rightarrow 0$.
\begin{figure}[htbp]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{MV.eps}
\caption{ Parameter evolution for the online algorithm \eqref{MV}.}
\label{MV parameter}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{MV_object.eps}
\caption{Objective function for the online algorithm \eqref{MV}.}
\label{MV object}
\end{minipage}
\end{figure}
\subsection{Path-dependent SDE}
\hspace{1.4em} We consider the path-dependent SDE
\begin{equation}
\label{path}
dX_t^\theta = \left(\theta - X_t^\theta - \frac1t \int_0^t X_s^\theta ds \right) dt + dW_t,
\end{equation}
where $X_t^\theta, W_t \in \mathbb{R}$. The objective function is
\begin{equation}
J(\theta) = ( E_{\pi_\theta} Y - 2 )^2.
\end{equation}
The online algorithm is:
\begin{equation}\begin{aligned}
\label{path dependent}
d\theta_t &= -4\alpha_t (\bar X_t - 2) \tilde X_t dt, \\
dX_t &= \left(\theta_t - X_t - \frac1t \int_0^t X_s ds \right) dt + dW_t,\\
d\tilde X_t &= \left(1 - \tilde X_t - \frac1t \int_0^t \tilde X_s ds \right) dt, \\
d\bar X_t &= \left(\theta_t - \bar X_t - \frac1t \int_0^t \bar X_s ds \right)dt + d\bar W_t.
\end{aligned}\end{equation}
In Figure \ref{path dependent parameter}, the trained parameter converges. The objective function $J(\theta_t)$ is approximated using a time-average. In Figure \ref{path dependent object}, the objective function $J(\theta_t)$ converges to $0$ very quickly.
\begin{figure}[htbp]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{path_dependent.eps}
\caption{Parameter evolution for the online algorithm \eqref{path dependent}.}
\label{path dependent parameter}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{path_dependent_object.eps}
\caption{Objective function for the online algorithm \eqref{path dependent}. }
\label{path dependent object}
\end{minipage}
\end{figure}
\subsection{Optimizing over the Auto-Covariance of an SDE} \label{AutoCov}
\hspace{1.4em} As our final numerical example, consider the OU process
\begin{equation}
d X_t^{\theta} = (\mu - \lambda X_t^{\theta} ) dt + \sigma dW_t,
\end{equation}
where $\theta = (\mu, \lambda, \sigma)$. Define $\pi_{\theta}$ as the stationary distribution of $X_t^{\theta}$ and $\pi_{\theta, \tau}(x, x')$ as the stationary distribution of $(X_{t- \tau}^{\theta}, X_t^{\theta})$. The objective function is
\begin{equation}
J(\theta) = \left({\bf E}_{\pi_{\theta}} X - 1\right)^2 + \left({\bf E}_{\pi_{\theta}} Y^2 - 2\right)^2 + \left({\bf E}_{\pi_{\theta, \tau}} YY' - 1.6\right)^2,
\end{equation}
where we will select $\tau = 0.1$ for our numerical experiment.
The online algorithm is
\begin{equation}\begin{aligned}
\label{auto}
d\mu_t &= -2\alpha_t \left[ (\bar X_t - 1 )\tilde X_t^1 + 2(\bar X^2_t - 2 )X_t \tilde X_t^1 + ( \bar X_{t-\tau} \bar X_t - 1.6) \left( \tilde X^1_{t-\tau} X_t + X_{t-\tau} \tilde X^1_t \right) \right]dt, \\
d\lambda_t &= -2\alpha_t \left[ (\bar X_t - 1 )\tilde X_t^2 + 2(\bar X^2_t - 2 )X_t \tilde X_t^2 + ( \bar X_{t-\tau} \bar X_t - 1.6) \left( \tilde X^2_{t-\tau} X_t + X_{t-\tau} \tilde X^2_t \right) \right]dt, \\
d\sigma_t &= -2\alpha_t \left[ (\bar X_t - 1 )\tilde X_t^3 + 2(\bar X^2_t - 2 )X_t \tilde X_t^3 + ( \bar X_{t-\tau} \bar X_t - 1.6) \left( \tilde X^3_{t-\tau} X_t + X_{t-\tau} \tilde X^3_t \right) \right]dt, \\
dX_t &= (\mu_t - \lambda_t X_t) dt + \sigma_t dW_t, \\
d\tilde X^1_t &= ( 1 - \lambda_t \tilde X^1_t ) dt, \\
d\tilde X^2_t &= (-X_t - \lambda_t \tilde X^2_t ) dt, \\
d\tilde X^3_t &= - \lambda_t \tilde X^3_t dt + dW_t, \\
d\bar X_t &= (\mu_t - \lambda_t \bar X_t) dt + d\bar W_t.
\end{aligned}\end{equation}
Figures \ref{auto parameter} and \ref{auto object} display the trained parameters and the objective function. The trained parameters have $\sim 0.8-1.8\%$ relative error compared to the global minimizers. The objective function $J(\theta_t)$ is computed from the exact formula
\begin{equation}
\label{auto objective}
J(\theta) =\left(\frac{\mu}{\lambda} -1 \right)^2 + \left( \left(\frac{\mu}{\lambda}\right)^2 + \frac{\sigma^2}{2\lambda} - 2 \right)^2 + \left( \left(\frac{\mu}{\lambda}\right)^2 + \frac{\sigma^2 e^{-\lambda\tau}}{2\lambda} - 1.6 \right)^2.
\end{equation}
\begin{figure}[htbp]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{auto_corr.eps}
\caption{ Parameter evolution for the online algorithm \eqref{auto}.}
\label{auto parameter}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=6cm]{auto_corr_object.eps}
\caption{Objective function for the online algorithm \eqref{auto}.}
\label{auto object}
\end{minipage}
\end{figure}
\section{Proof of Proposition \ref{ergodic estimation}} \label{ergodic appendix}
We first present a useful lemma before proving Proposition \ref{ergodic estimation}. The bound \eqref{key} will be frequently used in the proof of Proposition \ref{ergodic estimation}.
\begin{lemma}
\label{key lemma}
For any $m', k \in \mathbb{R}_+$, there exist constants $C, m > 0$ such that for any $x, x' \in \mathbb{R}^d$,
\begin{equation}
\label{key}
e^{-\left| x' - x \right|^2} \cdot \left| x' - x \right|^k \le C \frac{1+|x|^m}{1+|x'|^{m'}}.
\end{equation}
\end{lemma}
\begin{proof}
For any fixed $x \in \mathbb{R}^d$, when $\frac{\left| x' \right|}{2} \ge \left| x \right|$ we have
\begin{eqnarray}
\left| x' - x \right| &\ge& \left| x' \right| - \left| x \right| \ge \frac{\left| x' \right|}{2}, \notag \\
\left| x' - x \right| &\le& \left| x' \right| + \left| x \right| \le \frac{3\left| x' \right|}{2}.
\label{xminusxprimeIneq}
\end{eqnarray}
Therefore, we have that for any $m', k>0$ there exists a constant $C_1>0$ such that
\begin{equation}
e^{-\left| x' - x \right|^2} \cdot \left| x' - x \right|^k \le e^{ -\frac{\left| x' \right|^2}{4}} \left( \frac{3}{2} \left| x' \right|\right)^k \overset{(a)}{\le} \frac{C_1}{1+|x'|^{m'}},
\end{equation}
where the first inequality is due (\ref{xminusxprimeIneq}) and step (a) uses the fact that
\begin{equation}
\label{order}
\lim\limits_{s \to +\infty} \frac{s^m}{e^s} = 0, \quad \forall m > 0.
\end{equation}
When $\frac{\left| x' \right|}{2} < \left| x \right|$, for any $m',k>0$ there exist constants $C_2, m > 0$ such that
\begin{equation}
e^{-\left| x' - x \right|^2} \cdot \left| x' - x \right|^k \le \left( 3|x| \right)^k \le \frac{\left( 3|x| \right)^k \cdot \left( 1+|2x|^{m'}\right) }{1+|x'|^{m'}} \le C_2 \frac{1+|x|^m}{1+|x'|^{m'}}.
\end{equation}
Let us now choose $C= C_1 + C_2 $ and then \eqref{key} holds.
\end{proof}
\begin{proof}[Proof of Proposition \ref{ergodic estimation}:]
The proof for the convergence results leverages the closed-form formula for the distribution. Let
\begin{equation}
f(t,x,\theta) = e^{-h(\theta)t} x + h(\theta)^{-1} \left( I_d - e^{-h(\theta)t} \right)g(\theta), \quad \Sigma_t(\theta) = \sigma^2(2h(\theta))^{-1}\left( I_d - e^{-2h(\theta)t} \right),
\end{equation}
and from \eqref{solution} we know that
\begin{equation}
\label{multi dim normal}
X_t^\theta \sim N\left( f(t,x,\theta),\ \Sigma_t(\theta) \right).
\end{equation}
Thus, the stationary distribution for $X_t^\theta$ is $N\left( h^{-1}(\theta) g(\theta),\ \sigma^2(2h(\theta))^{-1} \right)$.
As $h(\theta)$ is positive definiteness and then there exists orthogonal matrix $Q(\theta)$ such that
$$
h(\theta) = Q(\theta)^\top \Lambda(\theta) Q(\theta)
$$
where $\Lambda(\theta) = \text{diag}(\lambda_1(\theta), \cdots, \lambda_d(\theta))$ is a diagonal and all its eigenvalues are positive. Thus for $t>0$
\begin{equation}
\label{spectrum}
\Sigma_t(\theta) = \frac{\sigma^2}{2} Q(\theta)^T \Lambda^{-1}(\theta) \left(I_d - e^{-2\Lambda(\theta)t}\right) Q(\theta),
\end{equation}
and the eigenvalues of $\Sigma_t(\theta)$ are $\left(\frac{\sigma^2 \left( 1-e^{-2\lambda_1(\theta)t}\right)}{2\lambda_1(\theta)} , \cdots, \frac{\sigma^2 \left( 1-e^{-2\lambda_d(\theta)t}\right)}{2\lambda_d(\theta)} \right)$.
Then we know the covariance matrix $\Sigma_t(\theta)$ is also positive definiteness for any $t>0$ and the density is
\begin{equation}\begin{aligned}
\label{close formula}
p_t(x, x', \theta) &= \frac{1}{\sqrt{(2\pi)^{d} \left| \Sigma_t(\theta) \right|}} \exp\left\{ -\frac12 (x' -f(t,x,\theta))^\top \Sigma^{-1}_t(\theta) (x' -f(t,x,\theta)) \right\}, \ t>0 \\
p_\infty(x',\theta) &= \frac{1}{\sqrt{(2\pi)^d \left| \sigma^2 (2h(\theta))^{-1} \right| }} \exp\left\{ - (x' -h(\theta)^{-1}g(\theta))^\top \frac{h(\theta)}{\sigma^2} (x' - h(\theta)^{-1} g(\theta)) \right\}.
\end{aligned}\end{equation}
\begin{itshape}Proof of (\romannumeral1).\end{itshape} Recall that (by assumption) $h(\theta)$ is uniformly positive definite and thus
\begin{equation}
\label{invariant bound}
p_\infty(x', \theta) \le C \sqrt{ \left| h(\theta) \right| } \exp\left\{ -c|x' - h(\theta)^{-1}g(\theta)|^2 \right\} \overset{(a)}{\le} \frac{C}{1+|x'|^m}
\end{equation}
where step $(a)$ uses the bounds for $g, h$ in Assumption \ref{condition} and \eqref{order}. Due to \eqref{close formula}, we have for any $k \in \{ 1, 2, \cdots, \ell\} $ that
\begin{equation}\begin{aligned}
\label{stationary first theta}
&\left| \frac{\partial}{\partial \theta_k} p_\infty(x', \theta) \right| \\
\le& C \left( \frac{\partial}{\partial \theta_k} \sqrt{|h(\theta)|} \right) \cdot \exp\left\{ -c\left|x' - h(\theta)^{-1} g(\theta)\right|^2 \right\} + C \sqrt{|h(\theta)|} \exp\left\{ -c\left|x' -h(\theta)^{-1} g(\theta)\right|^2 \right\}\\
\cdot& \left[ \left| \left(x'- h(\theta)^{-1} g(\theta)\right)^\top \frac{\partial h(\theta)}{\partial \theta_k} (x' - h(\theta)^{-1} g(\theta)) \right| + 2\left| \left( \frac{\partial \left( h(\theta)^{-1} g(\theta)\right) }{\partial \theta_k} \right)^\top h(\theta) \left(x' - h(\theta)^{-1} g(\theta) \right) \right| \right] \\
\overset{(a)}{\le}& C \exp\left\{ -c\left|x' -h(\theta)^{-1} g(\theta)\right|^2 \right\} + C \exp\left\{ -c\left|x' - h(\theta)^{-1} g(\theta)\right|^2 \right\} \left( \left|x' - h(\theta)^{-1} g(\theta)\right|^2 + \left|x' - h(\theta)^{-1} g(\theta)\right| \right) \\
\overset{(b)}{\le}& \frac{C}{1+|x'|^m},
\end{aligned}\end{equation}
where step $(a)$ is by the boundedness of $g(\theta), \frac{\partial g(\theta)}{ \partial \theta_k}, h(\theta), \frac{\partial h(\theta)}{\partial \theta_k}$ and the positive definiteness of $h(\theta)$ in Assumption \ref{condition}. Step $(b)$ is due to equation \eqref{key} with $x = h(\theta)^{-1}g(\theta)$ and equation (\ref{order}). Using the same method as in \eqref{stationary first theta}, we can obtain the bound for $\nabla^2_\theta p_\infty(x, \theta)$.
\begin{itshape}Proof of (\romannumeral2) and (\romannumeral3).\end{itshape}
We now prove \eqref{x prime decay}. First let
$$
X:= x' - f(t,x,\theta), \quad Y:= x' -h(\theta)^{-1}g(\theta),
$$
and then by the uniform positive definiteness of $h$
\begin{equation}\begin{aligned}
\label{difference}
|X - Y| = \left|e^{-h(\theta)t}x - e^{-2h(\theta)t}h(\theta)^{-1}g(\theta) \right| \le Ce^{-ct}(1+|x|).
\end{aligned}\end{equation}
We will use the following decomposition:
\begin{equation}
\begin{aligned}
\label{decomposition0}
&|p_t(x,x',\theta) - p_\infty(x',\theta)| \\
\le& C \left( \frac{1}{\sqrt{ \left| \left( I_d - e^{-2h(\theta)t} \right) \right|}} - 1 \right) + C \left| \exp\left\{ -X^\top \frac{h(\theta)}{\sigma^2}\left( I_d - e^{-2h(\theta)t}\right)^{-1} X \right\} - \exp\left\{ -Y^\top \frac{h(\theta)}{\sigma^2}\left( I_d - e^{-2h(\theta)t}\right)^{-1} Y \right\} \right| \\
+& \left|\exp\left\{ -Y^\top \frac{h(\theta)}{\sigma^2} \left( I_d - e^{-2h(\theta)t}\right)^{-1} Y \right\} - \exp\left\{ -Y^\top \frac{h(\theta)}{\sigma^2} Y \right\} \right| \\
=&: I_1 + I_2 + I_3
\end{aligned}
\end{equation}
For $I_1$, note that when $t>1$
\begin{equation}
\label{dif1}
\frac{1}{\sqrt{ \left| \left( I_d - e^{-2h(\theta)t} \right) \right|}} - 1 = \frac{1}{ \sqrt{ \prod\limits_{k=1}^d \left( 1 - e^{-2\lambda_k(\theta)t} \right)} } - 1 \le C\left[ 1 - \prod_{k=1}^d \left( 1 - e^{-2\lambda_k(\theta)t} \right) \right] \le C e^{-2\lambda_1(\theta)t} \le C e^{-2ct},
\end{equation}
where $\lambda_1(\theta) \le \lambda_2(\theta) \le \cdots \le \lambda_d(\theta)$ are the eigenvalues of the matrix $h(\theta)$. For $I_3$, similar to \eqref{spectrum}, we know the eigenvalues of $h(\theta) \left( \left( I_d - e^{-2h(\theta)t}\right)^{-1} -I_d \right)$
are $\frac{\lambda_i(\theta) e^{-2\lambda_i(\theta)t}}{1-e^{-2\lambda_i(\theta)t}},\ i=1,\cdots,d$, which implies that $h(\theta)\left(\left( I_d - e^{-2h(\theta)t}\right)^{-1} -I_d\right)$
is also a positive definite matrix. When $t>1$, by the uniform positive definiteness of $h(\theta)$, the eigenvalues will have a uniform upper bound:
\begin{equation}
\label{eigen bound}
\frac{\lambda_i(\theta) e^{-2\lambda_i(\theta)t}}{1-e^{-2\lambda_i(\theta)t}} \le \frac{C}{1-e^{-c}} \le C , \quad t>1, \ \forall i \in \{1, \cdots, d\}.
\end{equation}
Thus for any $m',k>0$, there exists a constant $C>0$ such that when $t>1$
\begin{equation}
\begin{aligned}
\label{dif2}
&\left| \exp\left\{ -Y^\top \frac{h(\theta)}{\sigma^2}\left( I_d - e^{-2h(\theta)t}\right)^{-1} Y \right\} - \exp\left\{ -Y^\top \frac{h(\theta)}{\sigma^2} Y \right\} \right| \\
=& \exp\left\{ -Y^\top \frac{h(\theta)}{\sigma^2} Y \right\} \left| \exp\left\{ -Y^\top \frac{h(\theta)}{\sigma^2}\left( \left( I_d - e^{-2h(\theta)t}\right)^{-1} -I_d\right) Y \right\} - 1 \right| \\
\overset{(a)}{\le}& C \exp\left\{ -Y^\top \frac{h(\theta)}{\sigma^2} Y \right\} \left|Y^\top \frac{h(\theta)}{\sigma^2}\left( \left( I_d - e^{-2h(\theta)t}\right)^{-1} -I_d\right) Y \right|
\\
\overset{(b)}{\le}& C \exp\left\{ -Y^\top \frac{h(\theta)}{\sigma^2} Y \right\} |Y|^2 \cdot \lambda_{\max} \left( h(\theta) \left( \left( I_d -e^{-2h(\theta)t}\right)^{-1} -I_d\right)\right) \\
\overset{(c)}{\le}& C \exp\left\{ -c\left|x' - h(\theta)^{-1} g(\theta)\right|^2 \right\} \cdot \left|x' - h(\theta)^{-1} g(\theta)\right|^2
\\
\overset{(d)}{\le}& C e^{-ct} \frac{1}{1+|x'|^{m'}}\\
\le& C\frac{1}{(1+|x'|^{m'})(1+t)^k},
\end{aligned}
\end{equation}
where step $(a)$ is by the positive definiteness of $\frac{h(\theta)}{\sigma^2}\left( \left( I_d - e^{-2h(\theta)t}\right)^{-1} -I_d\right)$, which means
$$
Y^\top\frac{h(\theta)}{\sigma^2}\left( \left( I_d - e^{-2h(\theta)t}\right)^{-1} -I_d\right) Y \ge 0,
$$
and the fact $0\le 1-e^{-s} \le s,\ \forall s\ge0$. In step $(b)$, $\lambda_{\max}$ denotes the largest eigenvalue and step $(c)$ uses \eqref{eigen bound}. Step $(d)$ follows from \eqref{key} with $x = h(\theta)^{-1}g(\theta)$ and the boundedness of $g,h$.
For $I_2$, define the function on $F_t: \mathbb{R}^d \rightarrow \mathbb{R}$ for $t>0$
$$
F_t(x) := \exp \left \{ -x^\top \frac{h(\theta)}{\sigma^2}\left( I_d - e^{-2h(\theta)t}\right)^{-1} x \right\}.
$$
By mean value theorem,
\begin{equation}
F_t(x) - F_t(y) = \nabla F_t(x_0)^\top (x-y) = -\frac{2h(\theta)}{\sigma^2} \left( I_d - e^{-2h(\theta)t}\right)^{-1} F_t(x_0)x_0^\top (x-y),
\end{equation}
where $x_0 = t_0 x + (1-t_0)y$ for some $t_0 \in [0, 1]$. Thus for any $m', k>0$ there exist constants $C, m>0$ such that when $t>1$
\begin{equation}
\begin{aligned}
\label{dif3}
\left| F_t(x) - F_t(Y) \right| &\overset{(a)}{=} \frac{2}{\sigma^2} \left| \exp\left\{-(X_0)^\top \frac{h(\theta)}{\sigma^2}\left( I_d - e^{-2h(\theta)t}\right)^{-1} X_0 \right\} X_0^\top (X-Y) \right|\\
&\overset{(b)}{\le} e^{-c |X_0|^2} |X_0| Ce^{-ct}(1+|x|) \\ &\overset{(c)}{\le} C\frac{1+|x|^m}{(1+|x'|^{m'})(1+t)^k},
\end{aligned}
\end{equation}
where in step $(a)$
\begin{equation}
\label{mean value}
X_0 = t_0 X+ (1-t_0)Y = x' - t_0 f(t,x,\theta) - (1-t_0) h(\theta)^{-1}g(\theta),
\end{equation}
for some $t_0 \in [0,1]$. Step $(b)$ uses \eqref{difference} and \eqref{eigen bound} and step $(c)$ is by substituting in $x$ in \eqref{key} to be the $X_0$ in \eqref{mean value}. Combining \eqref{decomposition0}, \eqref{dif1}, \eqref{dif2}, and \eqref{dif3}, we have for $t>1$
\begin{equation}
\label{exp conv}
|p_t(x,x',\theta) - p_\infty(x',\theta)| \le C\frac{1+|x|^m}{(1+|x'|^{m'})(1+t)^k}.
\end{equation}
The proof of \eqref{x prime decay} for the case $i=1,2$ and \eqref{x decay} is the same as the proof for $|p_t(x,x',\theta) - p_\infty(x',\theta)|$ above (i.e., one uses the decomposition in \eqref{decomposition0} and \eqref{key} with different choices of $x$). The only challenge is establishing a bound for $\nabla_\theta e^{-h(\theta)t}$. $e^{-h(\theta)t}$ satisfies the ODE
\begin{equation}
\label{ode}
\frac{d}{dt} e^{-h(\theta)t} = -h(\theta) e^{-h(\theta)t}
\end{equation}
with initial value $I_d$.\footnote{Here we use the fact that $\frac{\partial}{\partial y} e^{A y} = A e^{Ay} = e^{A y} A$.} Differentiating \eqref{ode} with respect to $\theta_i, i \in \{1, \cdots, d\}$ yields an ODE for $\frac{\partial}{\partial \theta_i} e^{-h(\theta)t}$:
\begin{equation}
\frac{d}{dt} \frac{\partial}{\partial \theta_i} e^{-h(\theta)t} = -\frac{\partial h(\theta) }{\partial \theta_i} e^{-h(\theta)t} - h(\theta) \frac{\partial}{\partial \theta_i}e^{-h(\theta)t},
\end{equation}
with initial value $0$. Using an integrating factor yields
$$
\frac{d}{dt} \left( e^{h(\theta) t} \frac{\partial}{\partial \theta_i} e^{-h(\theta)t} \right) = -e^{h(\theta) t} \frac{\partial h(\theta)}{\partial \theta_i} e^{-h(\theta)t},
$$
and thus
\begin{equation}
\frac{\partial}{\partial \theta_i} e^{-h(\theta)t} = e^{-h(\theta)t} \int_0^t e^{h(\theta)s} \frac{\partial h(\theta)}{\partial \theta_i} e^{-h(\theta)s} ds.
\end{equation}
Since $e^{h(\theta)t}$ is invertible for any $t$, we know the matrices $e^{h(\theta)s} \frac{\partial h(\theta)}{\partial \theta_i} e^{-h(\theta)s}$ and $\frac{\partial h(\theta)}{\partial \theta_i}$ are similar and thus their eigenvalues are the same, which implies that their spectral norm are also the same. We therefore can show that
\begin{equation}
\label{norm}
\left| \frac{\partial}{\partial \theta_i} e^{-h(\theta)t} \right| \le C \left| e^{-h(\theta)t} \right| \int_0^t \left| \frac{\partial h(\theta)}{\partial \theta_i} \right| ds \overset{(a)}{\le} Ce^{-ct} t,
\end{equation}
where step $(a)$ is by the bound for $\nabla_\theta h(\theta)$ in Assumption \ref{condition}. Using the same method, we also can show that
\begin{equation}
\label{norm 2}
\left| \frac{\partial^2}{\partial \theta_i \partial \theta_j} e^{-h(\theta)t} \right| \le C \left| e^{-h(\theta)t} \right| \int_0^t \left| \frac{\partial h(\theta)}{\partial \theta_i \partial \theta_j} \right| ds \overset{(a)}{\le} Ce^{-ct} t, \quad \forall i,j \in \{1, \cdots, d\}.
\end{equation}
\begin{itshape} Proof of (\romannumeral4).\end{itshape}
The first part of \eqref{normal bound} follows from the fact that $X_t^\theta$ has a multivariate normal distribution whose mean and variance are uniformly bounded. \eqref{normal bound} is obvious when $t=0$. For $t>0$, as we know $\Sigma_t(\theta)$ is positive definite for $t>0$, thus the random variable
\begin{equation}
\label{standard normal}
Y:= \Sigma_t^{-\frac12}(\theta) \left( X_t^\theta - f(t,x,\theta) \right)
\end{equation}
has a $d$-dimensional standard normal distribution, where $\Sigma_t^{\frac12}(\theta)$ denotes the square root matrix of $\Sigma_t(\theta)$. Since for any $m>0$ there exists a $C_m>0$ such that ${\bf E}\left|Y\right|^m = C_m <\infty$.
\begin{equation}\begin{aligned}
\label{X theta normal bound}
{\bf E}_x\left|X_t^\theta\right|^m = {\bf E}_x\left|\Sigma_t^{\frac12}(\theta) Y + f(t,x,\theta) \right|^m \le C \left( \left|\Sigma_t^{\frac12}(\theta) \right|^m {\bf E}_x \left| Y\right|^m + \left|f(t,x,\theta)\right|^m \right)
\overset{(a)}{\le} C(1+|x|^m),
\end{aligned}\end{equation}
where step $(a)$ is by the uniform bound for $g(\theta)$ and $h(\theta)$ in Assumption \ref{condition}. For the second part of \eqref{normal bound}, we use \eqref{X theta normal bound} to develop the following bound:
\begin{equation}\begin{aligned}
\label{tilde thete bound}
{\bf E}_{x,\tilde x}|\tilde X^\theta_t|^m &\le 2|\tilde x|^m + 2{\bf E}_{x, \tilde x}\left| \int_0^t \left| e^{-h(\theta)(t-s)}\right| \cdot \left| \nabla_\theta g(\theta) - \nabla_\theta h(\theta)X^\theta_s \right| ds \right|^m\\
&\overset{(a)}{\le} 2|\tilde x|^m + C_m {\bf E}_{x, \tilde x}\left| \int_0^t e^{-c(t-s)} \left( 1 + |X^\theta_s| \right) ds \right|^m\\
&\le 2|\tilde x|^m + C_m {\bf E}_{x}\left| \int_0^t \frac{e^{cs}}{e^{ct} - 1} \left( 1 + |X^\theta_s| \right) ds \right|^m e^{-cm t}\left( e^{ct} - 1 \right)^m \\
&\overset{(b)}{\le} 2|\tilde x|^m + C_m {\bf E}_x\left| \int_0^t \frac{e^{cs}}{e^{ct} - 1} \left( 1 + |X^\theta_s| \right)^m ds \right|\\
&\le C_m \left( 1 + |x|^m + |\tilde x|^m \right),
\end{aligned}\end{equation}
where step $(a)$ is by Assumption \ref{condition} and the fact
\begin{equation}
\lambda_{\max} \left( e^{-h(\theta)(t-s)} \right) = e^{ -\lambda_{\min}\left( h(\theta)(t-s) \right)} \le e^{-c(t-s)}
\end{equation}
and step (b) is by Jensen's inequality. In particular, let $p(s) = \frac1c \frac{e^{cs}}{e^{ct}-1}$ and we have $\int_0^t p(s) ds = 1$, and therefore $p(s)$ is a probability density function on $[0,t]$. By Jensen's inequality,
\begin{equation}
\left| \int_0^t \left( 1 + |X^\theta_s| \right) p(s) ds \right|^m \le \int_0^t \left( 1 + |X^\theta_s| \right)^m p(s)ds,
\end{equation}
which we have used in step $(b)$ of equation (\ref{tilde thete bound}).
\begin{itshape} Proof of (\romannumeral5).\end{itshape}
For \eqref{expectation bound}, the conclusion for $t=0$ is trivial. When $t>0$, by \eqref{poly} and \eqref{normal bound}, we have for any polynomial bounded function $f$ that
\begin{equation}
\label{exp bound}
|{\bf E}_x f(X_t^\theta) | \le {\bf E}_x| f(X_t^\theta) | \le C {\bf E}_x (1 + |X_t^\theta|^m) \le C(1+|x|^m).
\end{equation}
For the derivatives, we will use the dominated convergence theorem. By \eqref{close formula}, we have
\begin{equation}
\label{expectation z}
{\bf E}_x f(X_t^\theta) = \int_{\mathbb{R}^d} f\left(f(t,x,\theta) + x'\right) \frac{1}{\sqrt{(2\pi)^d \left| \Sigma_t(\theta) \right|}} \exp\left\{ -\frac12 x'^\top \Sigma^{-1}_t(\theta) x' \right\}dx'.
\end{equation}
Let $Z^\theta$ denote a normal distribution
$$
Z_t^\theta \sim N\left( 0, \Sigma_t(\theta) \right)
$$
and then
\begin{equation}
{\bf E}_x f(X_t^\theta) = {\bf E} f \left( f(t,x,\theta) + Z_t^\theta \right) = {\bf E} f \left( e^{-h(\theta)t} x + h(\theta)^{-1} \left( I_d - e^{-h(\theta)t} \right)g(\theta) + Z_t^\theta \right).
\end{equation}
For $\nabla_x {\bf E}_x f(X_t^\theta)$, we change the order of $\nabla_x$ and ${\bf E}_x$ and obtain for $t \in (0,1]$
\begin{equation}\begin{aligned}
& {\bf E} \left| \nabla_x f \left( e^{-h(\theta)t} x + h(\theta)^{-1} \left( I_d - e^{-h(\theta)t} \right)g(\theta) + Z_t^\theta \right) \right| \\
=& {\bf E} \left| e^{-h(\theta)t} \nabla f \left( e^{-h(\theta)t} x + h(\theta)^{-1} \left( I_d - e^{-h(\theta)t} \right)g(\theta) + Z_t^\theta \right)\right| \\
\le& e^{-ct} {\bf E}_x \left| \nabla f(X_t^\theta)\right| \\
\le& C(1+|x|^m).
\end{aligned}\end{equation}
Therefore, by DCT we have that
\begin{equation}
\left| \nabla_x {\bf E}_x f(X_t^\theta) \right| = \left| {\bf E} \nabla_x f \left( e^{-h(\theta)t} x + h(\theta)^{-1} \left( I_d - e^{-h(\theta)t} \right)g(\theta) + Z_t^\theta \right) \right| = \left| e^{-h(\theta)t} {\bf E}_x \nabla f(X_t^\theta) \right| \le C(1+|x|^m).
\end{equation}
Similarly for $\nabla^2_x {\bf E}_x f(X_t^\theta)$, we have for $t \in (0,1]$
\begin{equation}\begin{aligned}
\left| \nabla^2_x {\bf E}_x f(X_t^\theta) \right| =& \left| {\bf E} e^{-h(\theta)t} \nabla^2 f \left( e^{-h(\theta)t} x + h(\theta)^{-1} \left( I_d - e^{-h(\theta)t} \right)g(\theta) + Z_t^\theta \right) e^{-h(\theta)t} \right| \\
=& \left| e^{-h(\theta)t} {\bf E}_x \nabla^2 f(X_t^\theta) e^{-h(\theta)t} \right| \\
\le& C(1+|x|^m).
\end{aligned}\end{equation}
Finally, for $\nabla_\theta \nabla^2 _x{\bf E}_x f(X_t^\theta)$, by \eqref{norm} we have for $t\in(0,1]$ that
\begin{equation}\begin{aligned}
\label{theta x 1}
\left| \frac{\partial}{\partial \theta_i} \nabla^2_x {\bf E}_x f(X_t^\theta) \right| &\le 2\left| \frac{\partial}{\partial \theta_i} e^{-h(\theta)t} \right| \left| {\bf E}_x \nabla^2 f(X_t^\theta) \right| \left| e^{-h(\theta)t} \right| + \left| e^{-h(\theta)t} \frac{\partial}{\partial \theta_i} {\bf E}_x \nabla^2 f(X_t^\theta) e^{-h(\theta)t} \right| \\
&\le C(1+|x|^m) + e^{-ct} \left| \frac{\partial}{\partial \theta_i} {\bf E}_x \nabla^2 f(X_t^\theta) \right|.
\end{aligned}\end{equation}
Thus, it remains to prove a bound for $\frac{\partial}{\partial \theta_i} {\bf E}_x f_0(X_t^\theta)$, where $f_0$ is any polynomial bounded function such that
$$
|f_0(x)| + |\nabla f_0(x)| \le C(1+|x|^m),\quad \forall x\in \mathbb{R}^d.
$$
In order to establish this result, we need a bound for $\nabla_\theta \Sigma^{-1}_t(\theta)$ when $t \in [0,1]$. For $t \in (0,1]$,
\begin{equation}\begin{aligned}
\frac{\partial}{\partial \theta_i} \Sigma^{-1}_t(\theta) &= 2\sigma^2 \frac{\partial}{\partial \theta_i} \left[h(\theta)\left( I_d - e^{-2h(\theta)t} \right)^{-1} \right]\\
&\overset{(a)}{=} 2\sigma^2 \left( \frac{\partial}{\partial \theta_i}h(\theta) \right) \left( I_d - e^{-2h(\theta)t} \right)^{-1} + 2\sigma^2 \left( I_d - e^{-2h(\theta)t} \right)^{-1} h(\theta) \left(\frac{\partial}{\partial \theta_i}e^{-2h(\theta)t}\right) \left( I_d - e^{-2h(\theta)t} \right)^{-1} \\
&= 2\sigma^2 \left( I_d - e^{-2h(\theta)t} \right)^{-1} \left[ I_d - e^{-2h(\theta)t} - 2 e^{-2h(\theta)t} h(\theta)t\right] \left( \frac{\partial}{\partial \theta_i} h(\theta)t \right) \left( I_d - e^{-2h(\theta)t} \right)^{-1},
\end{aligned}\end{equation}
where in step $(a)$ we change the order of $\left( I_d - e^{-2h(\theta)t} \right)^{-1} $ and $h(\theta)$ since $h(\theta) e^{h(\theta)t} = e^{h(\theta) t} h(\theta)$. For $t \in [0,1]$, $0$ is the only singular point for $\nabla_\theta \Sigma^{-1}_t(\theta)$. Therefore to prove the uniform bound, it suffices to prove the limit exists when $t \to 0^+$. As $t \to 0+$,
\begin{equation}
I_d - e^{-2h(\theta)t} - 2 e^{-2h(\theta)t} h(\theta)t = I_d - 2h(\theta)t - \left(I_d -2h(\theta)t + 2h^2(\theta)t^2 + o(t^2) \right) = -2h^2(\theta)t^2 + o(t^2).
\end{equation}
Therefore,
\begin{equation}\begin{aligned}
\lim_{t \to 0+} \frac{\partial}{\partial \theta_i} \Sigma^{-1}_t(\theta) &= 2\sigma^2 \lim_{t \to 0+} \left( 2h(\theta)t +o(t) \right)^{-1} \left( -2h^2(\theta)t^2 + o(t^2)\right)\left( \frac{\partial}{\partial \theta_i} h(\theta) \right) \left( 2h(\theta)t +o(t) \right)^{-1} \\
&= 2\sigma^2 \lim_{t \to 0+} \left( 2h(\theta) +o(1) \right)^{-1} \left( -2h^2(\theta) + o(1)\right)\left( \frac{\partial}{\partial \theta_i} h(\theta) \right) \left( 2h(\theta) +o(1) \right)^{-1} \\
&= -16 h(\theta) \left( \frac{\partial}{\partial \theta_i} h(\theta) \right) h^{-1}(\theta),
\end{aligned}\end{equation}
which together with the bound for $h(\theta)$ from Assumption \ref{condition} yields
\begin{equation}
\label{inverse bound}
\left| \nabla_\theta \Sigma^{-1}_t(\theta) \right| \le C, \quad t\in[0, 1].
\end{equation}
We will now analyze $\frac{\partial}{\partial \theta_i} {\bf E}_x f_0(X_t^\theta)$ for $t \in (0,1]$ using formula \eqref{expectation z} and changing the order of $\frac{\partial}{\partial \theta_i}$ and ${\bf E}_x$.
\begin{equation}
\begin{aligned}
\label{theta x 2}
&\int_{\mathbb{R}^d} \left| \frac{\partial}{\partial \theta_i} \left( f_0\left(f(t,x,\theta) + x'\right) \frac{1}{\sqrt{(2\pi)^d \left| \Sigma_t(\theta) \right|}} \exp\left\{ -x'^\top \Sigma^{-1}_t(\theta) x' \right\} \right) \right| dx' \\
\le& \int_{\mathbb{R}^d} \left| \left( \frac{\partial}{\partial \theta_i} f(t,x,\theta) \right)^\top \nabla f_0\left(f(t,x,\theta) + x'\right) \frac{1}{\sqrt{(2\pi)^d \left| \Sigma_t(\theta) \right|}} \exp\left\{ -x'^\top \Sigma^{-1}_t(\theta) x' \right\} \right| dx'\\
+& \int_{\mathbb{R}^d} \left| f_0\left(f(t,x,\theta) + x'\right) \frac{\partial}{\partial \theta_i} \left( \frac{1}{\sqrt{(2\pi)^d \left| \Sigma_t(\theta) \right|}} \right) \exp\left\{ -x'^\top \Sigma^{-1}_t(\theta) x' \right\} \right| dx'\\
+& 2\int_{\mathbb{R}^d} \left| f_0\left(f(t,x,\theta) + x'\right) \frac{1}{\sqrt{(2\pi)^d \left| \Sigma_t(\theta) \right|}} \exp\left\{ -x'^\top \Sigma^{-1}_t(\theta) x' \right\} x'^\top \frac{\partial}{\partial \theta_i} \left( \Sigma^{-1}_t(\theta) \right) x' \right| dx' \\
\overset{(a)}{\le}& C {\bf E} \left| \nabla f_0\left(f(t,x,\theta) + Z_t^\theta\right) \right| + C {\bf E} \left| f_0\left(f(t,x,\theta) + Z_t^\theta \right) \right| + C {\bf E} \left| f_0\left(f(t,x,\theta) + Z_t^\theta \right) (Z_t^\theta)^\top Z_t^\theta \right| \\
\le& C {\bf E}_x \left| \nabla f_0\left( X_t^\theta \right) \right| + {\bf E}_x \left| f_0\left(X_t^\theta \right) \right| + {\bf E}_x \left| f_0^2\left(X_t^\theta \right)\right| + {\bf E} \left| Z_t^\theta \right|^4\\
\overset{(b)}{\le} & C(1+|x|^m),
\end{aligned}
\end{equation}
where step $(a)$ is by \eqref{inverse bound} and the uniform bounds for $g(\theta), h(\theta)$ and step $(b)$ is by \eqref{exp bound} and the polynomial boudnds for $f_0^2, \nabla f_0$. Then, by the dominated convergence theorem,
\begin{equation}
\label{theta x 3}
\left|\nabla_\theta {\bf E}_x f_0(X_t^\theta)\right| \le C(1+|x|^m), \quad t\in(0,1].
\end{equation}
Combining \eqref{theta x 1} and \eqref{theta x 3}, we obtain the bound for $\nabla_\theta \nabla^2 _x{\bf E}_x f(X_t^\theta)$. The bound $\nabla^2_\theta \nabla^2_x{\bf E}_x f(X_t^\theta)$ can be obtained using similar calculations, which concludes the proof of the proposition.
\end{proof}
\section{Conclusion}
\hspace{1.4em}In this paper, we proposed a new online algorithm for computationally efficient optimization over the stationary distribution of ergodic SDEs. In particular, our algorithm can optimize over parameterized SDEs in order to minimize the distance between their stationary distribution and target statistics. By proving bounds for a new class of Poisson PDEs, we can analyze the parameters' fluctuations during training and rigorously prove convergence to a stationary point for linear SDE models. We also study the numerical performance of our algorithm for nonlinear examples. In the nonlinear cases which we present in this paper, the algorithm performs well and the parameters converge to a minimizer.
Our algorithm can be used for applications where optimizing over the stationary distribution of an SDE model is of interest. In many applications, the stationary distribution $\pi_{\theta}$ is unknown and the dimension of the stochastic process may be large. The online algorithm developed in this paper is well-suited for such problems.
Finally, there are several future research directions which should be explored. First, a convergence analysis for nonlinear SDEs would be an important next step. The focus of our paper is a convergence analysis for linear SDEs; this required addressing several non-trivial mathematical challenges, in particular the development and rigorous analysis of a new class of Poisson PDEs. Our results in this paper provide the building blocks for a future nonlinear analysis. The convergence of our online algorithm for discrete-time stochastic processes would also be interesting to study.
\section*{Acknowledgement}
This research has been supported by the EPSRC Centre for Doctoral Training in Mathematics of Random Systems: Analysis, Modelling and Simulation (EP/S023925/1).
\bibliographystyle{plain}
|
{'timestamp': '2022-02-15T02:42:03', 'yymm': '2202', 'arxiv_id': '2202.06637', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06637'}
|
arxiv
|
\section{Introduction}\label{sec:intro}
Automatic code completion (also called autocompletion)
is the task of completing source code statements
by predicting what the developer would write
given the current context.
It helps developers finish their programming tasks faster by
decreasing the typing effort and saving keystrokes,
correcting typographical errors,
and enabling them to explore APIs
in a context-sensitive manner~\cite{amann2016study}.
Autocompletion has therefore emerged
as one of the most prominent features
in Integrated Development Environments (IDEs).
To support autocompletion,
current IDEs exploit the regular structure of programming languages.
For example,
an IDE knows that an opening parenthesis character (`\texttt{(}`)
at a function-call position
must be followed by enough arguments to match the function's arity.
It can therefore propose argument names for variables that are in scope.
The availability of types in the host programming language
helps increase the precision of suggestions;
continuing with the example above,
the IDE will only propose variable names
for variables whose types match the function argument.
Recent autocompletion systems also
take into account past completions~\cite{robbes2010improving}
and analyze large code bases~\cite{bruch2009learning}
to rank suggestions according to their past popularity.
Despite the best efforts of researchers and IDE developers,
developers find rule-based code completion mechanisms lacking.
Ranking suggestions based on alphabetical or usage frequency
(or even the suggestion list length~\cite{xianhao2018the})
neglects the current context,
leading to unrelated recommendations~\cite{allamanis2018survey}.
These problems are exacerbated in dynamically typed language settings,
as the IDE is lacking significant information to provide accurate suggestions.
To mitigate rule-based autocompletion issues,
researchers have proposed
statistical~\cite{nguyen2013statistical, hellendoorn2017deep} and
learning-based~\cite{liu2016neural,hellendoorn2017deep,li2017code,svyatkovskiy2019pythia,liu2020self,aye2020sequence}
autocompletion models.
Motivated by the \textit{naturalness} hypothesis~\cite{hindle2012naturalness},
learning-based models treat source code as natural language text,
hence code completion becomes an instance of the well-studied
text completion problem.
However, treating source code as text deprives learning-based models
of important code structure and semantic information~\cite{hellendoorn2019code}.
Moreover, the open-ended nature of code
leads to extremely large prediction spaces
due to developers constantly inventing identifier names~\cite{karampatsis2020big}.
In an illuminating study, Hellendoorn et al.~\cite{hellendoorn2019code}
identified a set of issues with current research in code completion.
Initially, the current approach of evaluating
accuracy as masked token prediction
does not reflect how autocompletion is used;
developers only trigger autocompletion after specific,
and certainly not arbitrary, points
in a program's syntax (e.g., after an opening parenthesis).
Thus, treating all tokens equally
masks the fact that some tokens (e.g., punctuation)
are much easier to predict than others (e.g., identifiers).
Moreover, most approaches (especially learning-based ones)
do not account for names coming from dependencies,
which deprives them of important context.
In this work, we propose \textit{CodeFill},
a novel learning-based
approach that aims to address the problems identified above.
CodeFill{} borrows from the bimodality hypothesis~\cite{santanu2018refinym}
to model source code inputs.
Specifically, CodeFill{} exploits that information is conveyed by
source code through two channels;
the \textit{natural language channel} (variable names, functions, etc.),
and the \textit{code structure channel} (inheritance, containment, etc.).
Inputs are fed into the model
simultaneously as both sequences of token values,
which enable it to learn relationships among token values,
and, uniquely, sequences of token types,
which enable it to learn associations between syntactic elements.
CodeFill{} is then asked to predict either the value or the type of the
next \emph{n} tokens.
To enable CodeFill{} to learn name dependencies across longer ranges,
we also train it with an additional task,
multi-token statement completion at the value level.
The input token names to CodeFill{} is encoded with Byte-Pair Encoding (BPE),
which enables CodeFill{} to both
compress the input name space and generate names that are not in the input vocabulary.
To present suggestions relevant to the developer's context,
CodeFill{} includes a post-processing step
that re-ranks the predictions based on
the context visible to the model at the completion point.
CodeFill{} is instantiated as a set of
three Transformers (GPT2-based)
trained with soft parameter sharing Multi-Task Learning (MTL) setting.
Each transformer models one of the three tasks,
namely token value, token type, and multi-token prediction;
a joint loss function across all three tasks
updates the weights of all three model components.
During each epoch, the model is trained
on one task according to a configurable task-picking policy.
Our target language is Python, to both demonstrate the efficiency of the model when
type information is missing and also make our work comparable with the state of the art.
We pit CodeFill{} against four baseline models and two the-state-of-the-art models, namely
GPT-C~\cite{svyatkovskiy2020intellicode} and TravTrans+~\cite{kim2020code}.
We use two deduplicated datasets:
the ETH150K dataset (deduplicated: \textit{PY117K})
and a manually collected dataset
consisting of practically all
non-forked Python repositories on GitHub (\textit{PY1690K}).
We evaluate all models on two tasks:
\textit{Token-Level} and \textit{Statement-Level} Predictions (TLP and SLP).
For TLP, we evaluate for
i) next token prediction (TLP-A),
ii) next token type prediction (TLP-B),
iii) next token value prediction (TLP-C).
To ensure that the evaluation setting reflects real-world use of autocompletion,
we also evaluate completions after specific syntactic
elements, e.g., a dot \texttt{.} or an \texttt{AWAIT} keyword (TLP-D).
We devise an algorithm to identify those syntactic elements
(\emph{cardinal points}) automatically given a corpus.
We use top-1 Accuracy and the Mean Reciprocal Rank (MRR)
as evaluation metrics.
For the SLP task, we assess the models
on statement completion with $n$ tokens
and we compare them using METEOR and ROUGE-L measures.
To show that each component in the CodeFill{} model is necessary,
we perform an ablation study.
The results demonstrate that CodeFill{} outperforms all the competing approaches in all tasks.
Indicatively,
for each of the TPL-A, TPL-B, TPL-C, and TPL-D evaluation tasks,
CodeFill{} achieves a state of the art MRR of
$81.7\%$, $87.2\%$, $69.5\%$, $70.2\%$
while TravTrans+, a current state of the art, scores
$79.4\%$, $83.6\%$, $63.8\%$, and $66.2\%$,
respectively.
In the SLP evaluation task,
for completing statements with four tokens
(the average completion length in our datasets)
CodeFill{} obtains $70.2\%$ and $63.8\%$
for the METEOR and ROUGE-L metrics respectively,
and thus significantly surpasses TravTrans+
($64.5\%$ and $52.4\%$).
The main contributions of this work are:
\begin{itemize}
\item CodeFill{}, a model that unifies learning of structural and name-based information for the autocompletion task.
\item An implementation of CodeFill{}, including training procedures,
for the Python programming language.
We make our code and datasets available.~\footnote{\url{https://github.com/saltudelft/codefill}}
\item An extensive evaluation of CodeFill{}
against four baseline models and two state-of-the-art approaches, demonstrating its superior performance.
\end{itemize}
\section{Background and Related Work}\label{sec:bg}
In this section,
we briefly review the background work relating to our approach.
Then, we present the main approaches to autocompletion,
including the baselines we used for comparison.
\subsection{Language Models and Transformers}
\label{sec:bg_transformers}
Statistical Language Modeling (LM)
is the task of developing a probabilistic model for predicting
the next tokens in a sequence given its preceding tokens,
i.e., the context~\cite{goldberg2017neural}.
This context for simpler LMs is a short sequence of words,
while it can be sentences or paragraphs for larger models~\cite{schutze2008introduction}.
LMs are either used without modification,
e.g., in a text generation task,
or used inside a down-stream task
which requires language understanding.
Programming languages also
contain predictable statistical properties
which can be learned using LMs~\cite{hindle2012naturalness}.
Recently, Neural LMs have gained popularity
due to their superior performance and generalization capabilities~\cite{mikolov2010recurrent,goldberg2017neural}.
Neural LMs address the n-gram data sparsity problem
through parameterization of words as vectors~\cite{kim2016character}.
A real-valued vector (word embedding) is used to
represent each word in a vector space.
This representation of words
is learned based on their usage.
This allows words with a similar meaning
to have a similar representation.
Note that traditional statistical LMs
were not able to achieve this level
of generalization~\cite{schwenk2002connectionist}.
Moreover, the distributed representation approach
makes it easier for the embedding representation to scale
with the vocabulary size.
This is specifically useful with source code,
where the vocabulary size can be unlimited
due to the use of arbitrary identifiers.
Initially, feed-forward neural network models,
then Recurrent Neural Networks (RNNs)
and next, networks with long-term memory,
such as Long Short Term Memory (LSTM) networks were used.
Most recently, there have been significant improvements
with the introduction of self-attention architectures in the Transformer
which is a sequence-to-sequence architecture
for transforming a given sequence of elements to another form~\cite{vaswani2017attention}.
Attention enable Transformers
to focus on selective parts of an input,
thus generating more relevant outputs~\cite{luong2015effective}.
Transformers outperform previous deep models
such as RNNs and LSTMs on multiple NLP tasks~\cite{vaswani2017attention}.
A Transformer consists of two main components,
an encoder, and a decoder.
GPT-2 introduced by OpenAI~\footnote{\url{https://openai.com/}},
is a large generative Transformer-based LM
trained on a dataset of $8$M web pages~\cite{radford2019language}.
GPT-2 has been successfully exploited
for various NLP and source code analysis tasks~\cite{budzianowski2019hello,lee2020patent,ham2020end,svyatkovskiy2020intellicode}.
\subsection{Multi-Task Learning}\label{sec:bg_mtl}
Multi-Task Learning (MTL) is a model training technique that combines
multiple tasks and a joint loss function,
with the goal of maximizing performance on one or all of the tasks.
MTL enables knowledge transfer across related tasks
and improves generalization by leveraging the domain-specific
information contained in the training signals of related
tasks~\cite{caruana1997multitask}.
An MTL model captures the common features among all the tasks
through sharing hidden layers among them.
MTL has been applied successfully in both NLP~\cite{devlin2018bert}
and source code analysis~\cite{liu2020self,liu2020multi}.
There are two approaches to jointly train models using MTL,
\textit{hard-parameter} and \textit{soft-parameter} sharing.
In the former, the hidden layers
are shared between all tasks
while keeping several task-specific output layers.
For the latter,
each task has its own model with its own parameters.
However, the distance between them is regularized
to encourage the parameters to be similar.
In the soft-parameter sharing case, training can happen
either \textit{sequentially} (one task per training round)
or \textit{alternatively} (one task per epoch).
\subsection{Related Work}\label{sec:related}
Autocompletion is an active research area
for both practitioners and researchers.
Below, we review the latest approaches to autocompletion.
\subsubsection{Conventional Autocompletion}
Traditionally, autocompleters used
heuristic rules
static type information~\cite{hou2010towards},
similar code examples~\cite{bruch2009learning},
and program history data~\cite{robbes2008program}
for suggesting completions.
For instance, IDEs conventionally return
a list of type-checked names
either based on the order of alphabet or usage frequency.
\subsubsection{Statistical LMs and Grammar-based Models}
Several studies use statistical LMs for modeling source code~\cite{hindle2012naturalness,nguyen2013statistical,tu2014localness,hellendoorn2017deep}.
Tu et al.~\cite{tu2014localness} built upon an n-gram model
using a cache mechanism to capture locality in source code.
Hellendoorn and Devanbu~\cite{hellendoorn2017deep} improved the n-gram model
by exploiting various techniques including
nested scopes, locality, and unlimited vocabulary.
Raychev et al.~\cite{raychev2016probabilistic}
proposed a probabilistic model
based on decision trees and domain-specific grammars.
Researchers also studied the use of syntactic structure
through exploiting probabilistic graphical models.
Allamanis et al.~\cite{allamanis2014mining}
employ probabilistic context-free grammars,
while Raychev et al.~\cite{raychev2016probabilistic,raychev2016learning,bielik2016phog}
use probabilistic higher order grammars to this end.
\subsubsection{Deep Learning for Autocompletion}
Recently, deep neural networks
such as RNNs, LSTMs and Transformers
are being effectively used
for modeling source code~\cite{li2017code,hellendoorn2017deep,aye2020sequence,karampatsis2020big,kim2020code}.
In 2018, Li et al.~\cite{li2017code} proposed
a pointer mixture model to mitigate the Out-Of-Vocabulary (OOV) problem.
They trained two LSTM models on types and tokens.
Karampatsis et al.~\cite{karampatsis2020big}
presented a large-scale open-vocabulary neural LM.
They incorporated BPE, beam search, and cache mechanism
to address the OOV problem.
Most recently, Kim et al.~\cite{kim2020code},
incorporated the syntactic structure of trees
into their Transformer-based model to better learn
from source code.
\subsubsection{Multi-token Autocompletion}
Although most research on code completion
is focused on single-token prediction,
several studies aimed to complete entire statements or blocks of code~\cite{svyatkovskiy2020intellicode,nguyen2019combining,yang2017language,wen2021siri}.
Yang et al.~\cite{yang2017language}
proposed \textit{PCC} and
introduced an intermediate representation for source code,
to put tokens into groups using lexeme and variable relative order.
Nguyen et al.~\cite{nguyen2019combining}
proposed \textit{AUTOSC}
to combine program analysis and software naturalness
and fill in a partially completed statement
with frequent and valid recommendations.
Svyatkovskiy et al.~\cite{svyatkovskiy2020intellicode}
recently proposed a GPT-2 based multi-lingual model,
\textit{GPT-C}, for completing lines.
Wen et al.~\mbox{\cite{wen2021siri}}
introduced \textit{FeaRS} which recommends the next method
given the current code in an IDE
using implementation patterns
learned through mining open source projects.
\subsubsection{MTL for Autocompletion}
MTL has been used in various NLP-related tasks~\cite{zhang2021survey,ruder2017overview,sener2018multi}.
Recently, it has also been employed
for programming language processing tasks.
Liu et al.~\cite{liu2020multi,liu2020self}
proposed two approaches based on MTL for autocompletion.
In the first study, the authors used a Transformer-XL and an RNN
for predicting next token type and value~\cite{liu2020self}.
They develop a partial AST encoder and a path2root encoder
and use them in their MTL framework.
In their second study,
Liu et al.~\cite{liu2020multi}
pre-train their model with hybrid objective functions
for code understanding and code generation tasks.
Next, they fine-tune it on code completion.
The pre-training tasks are masked bidirectional LM,
next code segment prediction, and unidirectional LM.
The fine-tuning tasks are unidirectional masked LM,
and unidirectional LM.
\subsubsection{Practical Aspects of Autocompletion}
Hellendoorn et al.~\cite{hellendoorn2019code} claim
the accuracy of autocompleters evaluated on synthetic data
can drop on real-world data.
Aye et al.~\cite{aye2021learning},
trained models on real-world code completion examples
of an internal dataset (Facebook).
They showed that models trained on data distributions that
are closer to those of where the model will be deployed
can outperform models trained on
committed source code in public repositories.
Svyatkovskiy et al.~\cite{svyatkovskiy2019pythia}
integrated Pythia, an LSTM model, to \textit{IntelliCode},
an extension to Microsoft VS Code IDE.
In a follow-up study~\cite{svyatkovskiy2020intellicode},
they introduced \textit{IntelliCode Compose}
as a general-purpose multilingual autocompletion using Transformers.
The improved model predicts sequences of code tokens,
generating up to entire statements.
IntelliCode Compose is integrated into the Microsoft VS Code IDE.
Finally, Svyatkovskoy et al.~\cite{svyatkovskiy2021fast} implemented
and evaluated several neural code completion models, which
offer varying trade-offs in terms of memory, speed, and accuracy.
Commercial autocompletion tools,
such as \textit{TabNine} and \textit{GitHub Copilot} also exist,
but very little technical information has been shared about them.
\subsection{Baselines}
We include six
recent models as baselines
to provide a comprehensive evaluation.
For all baselines,
we use the replication packages provided by the authors
and set the parameters as defined in each respective study.
For the statement level prediction task,
we modified the output layer of the baselines
to predict up until the end of a statement.
\textbf{N-gram + LSTM (FSE, 2017)}:
Hellendoorn et al.~\cite{hellendoorn2017deep}
claim that a well-engineered and simple approach
(n-gram based language models)
can provide better performance than more complex models (deep neural networks).
The authors show that the combination of an n-gram and LSTM-based model outperforms the rest of their models.
\textbf{Pointer Mixture (IJCAI, 2018)}:
Li et al.~\cite{li2017code},
propose a pointer mixture model
to address the OOV problem.
They also try to incorporate structural information in their models
by training two models (token types and values) separately.
\textbf{T-XL + Bi-LSTM (ICPC, 2020)}:
Liu et al.~\cite{liu2020self,liu2020multi},
propose two models based on the MTL technique.
The first study uses Transformer-XL and a Bi-LSTM
to train two models for tokens and AST paths
for dynamically-typed languages such as Python.
The second study by the same group
presents a pre-trained language model
which is fine-tuned for code completion.
The authors use static analysis and type annotations
for their type prediction task, for Java.
We compare against the first model only,
as it most closely matches our setup.
\textbf{OpenVocab (ICSE, 2020)}:
To address the OOV problem,
Karampatsis et al.~\cite{karampatsis2020big}
present a BPE-based language model.
We include it here for completeness,
even though their model is not tuned for autocompletion.
\textbf{IntelliCode Compose (FSE, 2020)}:
Svyatkovskiy et al.~\cite{svyatkovskiy2020intellicode}
propose a general-purpose, multi-lingual autocompletion
supporting multi-token statement completion.
They train a GPT-2 model on $1.2B$ LOC
written in Python, C\#, TypeScript, and JavaScript.
This tool is deployed as a cloud-based web service
and uses client-side caching and parallel implementation
to speed up the predictions.
As the source code
is not publicly available,
we trained a GPT-2 model for source code
and did our best to adhere to the settings reported in the study.
As the focus of our study is mono-lingual,
we only train this model on Python code.
\textbf{TravTrans+ (ICSE, 2021)}:
Kim et al.~\cite{kim2020code}
propose a transformer-based approach
which exploits AST paths.
We use their best model, TravTrans+,
as the state of the art in our evaluation.
\section{Approach}\label{sec:approach}
The CodeFill{} pipeline comprises two main phases;
\textit{pre-processing},
\textit{model training}.
Figure \ref{fig:workflow} presents the overall workflow.
Initially, CodeFill{} pre-processes, tokenizes
and converts the input source code
to equivalent syntax token sequences.
Training consists of two main phases
\textit{pre-training} with 3 tasks (token sequence type and name completion, statement completion)
and \textit{fine-tuning} on 2 tasks (name and statement completion).
For both stages, CodeFill{} uses
soft-parameter sharing MTL
to learn from different representations of source code.
At evaluation time, Codefill also
re-orders recommendations
based on their type and the visible context.
In the following section, we present how the proposed approach works in detail.
\begin{figure}[tb!]
\centering
\includegraphics[width=\linewidth]{images/workflow.pdf}
\caption{CodeFill{} Workflow}
\label{fig:workflow}
\end{figure}
\subsection{Pre-processing}\label{sec:approach_link}
During pre-processing, CodeFill{}
converts the input program files
to an equivalent format where keywords and identifiers
are swapped with their AST equivalents.
The algorithm starts by removing comment sections, blank spaces, and blank lines.
It then extracts the list of
\textit{modules}, \textit{libraries}, and their \textit{aliases}
using the Python \textit{AST} library.
Those are stored in a dictionary
and, using it, CodeFill{} replaces all their occurrences in code
with their respective types
(i.e., \texttt{MODULE}, \texttt{LIBRARY}, and \texttt{ALIAS}).
CodeFill{} also pre-processes and tokenizes the input source code.
For each line, it reads the tokenized information
and stores four types of information about each token
namely
(1) its value,
(2) its type,
(3) its line number,
and (4) its position in the line.
For instance, for the statement \texttt{return node}
in Figure~\ref{fig:sample_code},
it stores two tokens
as shown in the table following the code example.
Moreover, variable visibility information
(e.g., global vs. local variables),
is maintained, to differentiate
between different name usages in the same context.
\begin{figure}[tb]
\centering
\begin{minted}[
linenos,frame=single,
breaklines=true,
framerule=0.5pt,
breaksymbolleft=,
numbersep=1mm,
fontsize=\footnotesize]{python}
def transform(node, ctx):
node = qual_names.resolve(node)
node = CallTreeTransformer(ctx).visit(node)
return node
\end{minted}
\begin{tabular}{cccc}
Type & Value & \#Line & Position \\\midrule
RETURN & return & 4 & 1 \\
NAME & node & 4 & 2 \\
\bottomrule
\end{tabular}
\caption{Sample code snippet and the extracted information}
\label{fig:sample_code}
\end{figure}
To address the OOV problem,
CodeFill{} uses a BPE-encoded name representation.
Exploiting word segmentation,
BPE iteratively merges the most frequently occurring character sequences.
Prior to applying BPE encoding,
and similarly to other studies~\cite{svyatkovskiy2020intellicode,izadi2021topic,izadi2022predicting},
CodeFill{} normalizes the input strings
by replacing
\textit{string}, and \textit{numeric} literals
with respective special tokens,
i.e., \texttt{STRING} and \texttt{NUMBER}.
A unique characteristic of the Python language
is that indentation defines code blocks;
it is therefore important for source code models
to learn to encode indentation as part of their learned representation.
To do so, CodeFill{} stores the positioning of indentation markers.
For the first line with an indentation,
it adds a special token $\langle INDENT \rangle$
at the beginning of the given line.
It passes through the following lines with the same indentation,
to reach the next indentation or a dedentation position,
at which point it adds a respective $\langle INDENT\rangle$
or $\langle DEDENT\rangle$ token.
The pre-processing step results in two files for each input source code file;
(1) one containing sequences of token names
minus the comments and extra blank lines, and
(2) one containing sequences of token types.
Both are fed into CodeFill{}
as two different but corresponding representations of source code.
Figure~\ref{fig:cherry} shows a sample function
and its corresponding type information with the correct indention.
\begin{figure}[tb!]
\centering
\begin{minted}[
linenos,frame=single,
breaklines=true,
framerule=0.5pt,
breaksymbolleft=,
numbersep=1mm,
fontsize=\footnotesize]{python}
# Raises an error when the required variable is missing
def required_env(var):
value = os.environ.get(var)
if value is None:
raise RuntimeError("Var is required to start the service.")
return value
\end{minted}
\begin{minted}[
linenos,frame=single,
breaklines=true,
framerule=0.5pt,
breaksymbolleft=,
numbersep=1mm,
fontsize=\footnotesize]{python}
def required_env(var):
value = os.environ.get(var)
if value is None:
raise RuntimeError("STRING")
return value
\end{minted}
\begin{minted}[
linenos,frame=single,
breaklines=true,
framerule=0.5pt,
breaksymbolleft=,
numbersep=1mm,
fontsize=\footnotesize]{python}
DEF FUNCTION_NAME(LOCAL_VARIABLE): EOS
INDENT LOCAL_VARIABLE = LIB.MODULE.FUNCTION_NAME(LOCAL_VARIABLE) EOS
IF LOCAL_VARIABLE IS NONE: EOS
INDENT RAISE ERRORTOKEN("STRING") EOS
DEDENT RETURN LOCAL_VARIABLE EOS
\end{minted}
\caption{An example code snippet and its converted version}\label{fig:cherry}
\end{figure}
\begin{figure*}[tb!]
\centering
\includegraphics[width=0.9\linewidth]{images/approach.pdf}
\caption{Model training}
\label{fig:approach}
\end{figure*}
\subsection{Model Training}\label{sec:approach_modeltrainingl}
In this phase,
CodeFill{} learns from two granularity levels;
token- and statement-level completions
with three simultaneous tasks,
namely
(1) next Token \textit{Value} Prediction (TVP),
(2) next Token \textit{Type} Prediction (TTP),
and (3) \textit{Statement} Completion (SC).
Model training follows a two-stage process;
First, a generic language modeling objective
is used on the unlabeled data
to learn the initial parameters.
Then, these parameters are adapted
to the target tasks using the corresponding objective.
Thus, while pre-training,
CodeFill{} learns from all three tasks
while fine-tuning is restricted to
the TVP and SC tasks.
The reason for excluding the TTP task is that
the number of types for all the program files is limited.
Hence, the model quickly learns how to properly predict these type sequences
(i.e., learns an effective representation of the Python grammar),
eliminating the need for further fine-tuning.
The main neural network architecture
for all tasks is based on the GPT-2 Transformer with $L$ layers.
CodeFill{} uses three distinct GPT-2 transformers,
each with its own input and training objective.
The models are initialized with random weights.
Transformer blocks include
self-attention layer,
feed-forward neural nets,
and a normalization layer.
Self-attention blocks identify which tokens to focus on.
Feed-forward neural nets consist of an input layer to accept information,
hidden layers to capture the hidden correlations between each data point,
and finally, an output layer to transmit information.
The parameters are transferred to the next decoder
in the stack after being regularised (with $l2$ norm)
to be similar to the respective decoder's parameters.
CodeFill{} uses softmax activation function in the output layer
to generate probability distributions
over the vocabulary.
To train the model to predict a sequence of tokens,
$\{v_t\} \subset D, t \in [1, \dots, N]$,
with $D$ as the vocabulary,
and $C$ as the existing code context,
CodeFill{} estimates the following conditional probability distribution, $P$:
\begin{equation}
P(v_0,\dots,v_N|c_0,\dots,c_T) = \prod_{i=1}^{N}{P(v_i | c_0, \dots,c_T,v_0,\dots,v_{i-1})}.
\label{eq:prob}
\end{equation}
We use a standard language modeling objective,
predicting the next token given a context,
and maximize the following likelihood
based on our unsupervised corpus of tokens.
In Equation~\ref{eq:log_statement},
$m$ is the length of the predicted sequence of code token values
and $\theta$ is the set of parameters
that is learned through
stochastic gradient descent optimization to model $P$~\cite{robbins1951stochastic}.
\begin{equation}
L(V) = \sum_{i}{\log{P(v_i | c_0,...,c_T,v_{i-m},...,v_{i-1};\theta)}}.
\label{eq:log_statement}
\end{equation}
In each layer, multi-attention heads are used
to aggregate the output of the previous layer
for each transformer block.
Multi-headed self-attention is applied over the
input context tokens followed by position-wise feed-forward layers
to produce the output distribution.
\begin{equation}
h_0 = C W_e + W_p,
\label{eq:attention1}
\end{equation}
\begin{equation}
h_l = transformer\_block(h_{l-1}), l \in [1, \dots, L],
\label{eq:attention2}
\end{equation}
\begin{equation}
P(v_t) = softmax(h_L W_e^T), t \in [ 0,\dots,N]
\label{eq:attention3}
\end{equation}
where $C$ is the context vector of tokens,
$L$ is the number of layers,
$W_e$ is the token embedding matrix,
and $W_p$ is the position embedding matrix.
For training with MTL,
CodeFill{} uses the alternative training strategy,
which aims to prevent catastrophic forgetting
(as opposed to the sequential strategy).
With a probability of
20\%, 40\%, and 40\% for each of the
TTP, TVP,
and SC tasks, respectively,
CodeFill{} picks a random task for each epoch.
TTP requires fewer epochs
as its vocabulary is fairly limited.
Further on, for TVP and SC tasks,
CodeFill{} uses beam search
to identify the most likely (sub-)token sequences.
Loss is shared among all tasks.
During pre-training, the parameters are tuned
to minimize the absolute minimum of the cross entropy losses
among the three pre-training
tasks, namely, TVP, TTP, and SC (Equation~\ref{eq:shared_loss}).
When fine-tuning, only TVP and SC losses are used.
\begin{equation}
Loss_{final} = \mid\min({Loss_{TVP}, Loss_{TTP}, Loss_{SC}})\mid
\label{eq:shared_loss}
\end{equation}
\subsubsection{Token Value Prediction Task (TVP)}
CodeFill{} uses different representations of programs for each task
within the soft-parameter sharing MTL framework.
CodeFill{} treats the TVP task as masked unidirectional prediction;
left-side context is used to predict the next token.
The inputs to the task are sequences of token values,
represented as real-valued vectors of $[v_1, v_2, \dots, v_n]$.
\subsubsection{Token Type Prediction Task (TTP)}
Similarly to TVP, TTP is also treated as left-to-right
masked unidirectional prediction.
The input are corresponding token type representations
as real-valued vector of $ [t_1, t_2, \dots, t_n]$
As both the TTP and TVP models are trained jointly,
CodeFill{} is capable of exploiting token types
when the ultimate goal is to predicting token values.
\subsubsection{Statement Completion Task (SC)}
As useful as next-token prediction may be,
developers can also benefit from
getting longer suggestions to complete code statements~\cite{svyatkovskiy2020intellicode,aye2020sequence,nguyen2019combining}.
Correspondingly, CodeFill{} can also benefit
from training to predict longer sequences,
as training will enable it to better prioritize context use.
Thus, we add a third task
to train CodeFill{} to provide completion suggestions
up and until the end of a statement.
To predict a whole statement
given the existing code context $C$,
and the vocabulary $D$,
CodeFill{} attempts to generate token values
$\{v_t\} \subset D$,
conditioned on the sequence of preceding token values
$\{c_t\} \subset D$,
For this task, the pre-processing steps introduce a special token ($\langle EOS \rangle$)
to demarcate the end of a statement.
CodeFill{} is trained to
keep predicting sequences of token names
until it produces an $\langle EOS \rangle$ token.
\subsubsection{Beam search}
CodeFill{} uses greedy (beam) search to identify the most probable sequences
given a sequence of probabilistic predictions.
Specifically, $ |B| $ (width of the beam) top probabilities,
are recorded partially for every step.
This heuristic algorithm does not necessarily optimize results;
however, its computational complexity equals to $ O(|B| \times |V|) $
which is much faster than computing all cases.
As $ |B| $ increases, the quality of generated summaries improves,
however, the learning time increases as well.
We experimented with several beam values (3, 5, and 10),
and settled to $5$, as it provided a good balance of accuracy and speed.
\subsection{Post-processing}\label{sec:appraoch_post}
\paragraph{Re-ranking Recommendations}
For a recommendation system to be useful,
predictions should be ranked similarly to user expectations.
To optimize ranking,
CodeFill{} includes a post-processing layer to re-rank the leaf nodes in the final
recommendation list based on the visible scope
(i.e., the current file).
This is based on the observation that most completions should be local to the edited file,
as naming visibility rules should force names to cluster.
To re-rank the suggestions,
CodeFill{} hierarchically divides the visible scope
to file, class, and closest function.
The intuition here is,
when the model is predicting the next token
and its type is expected to be a variable name,
candidates in the closest scope
have a higher probability of being correct.
However, when the next token
is predicted to be a function name,
candidates from the same class
(functions defined in the same class)
should be probably at the top of the list.
The re-ranking process consists of
multiplying the prediction probabilities of the top-10 predictions
with a corresponding weight coefficient.
The weights are selected based on
the type of the predicted token
and the scope of the declaration of the identifier.
Each prediction consists of a
\texttt{<token, type, probability>} triplet
with respect to the prediction point
that it is made available,
We generate the list of all visible names
and their hierarchical scope (function, class, file).
Each prediction is then cross-checked with this list,
in the case where the predicted identifier
is indeed already declared in the file (and thus in the list),
its prediction probability is multiplied by a weight
depending on the type of the predicted token
and the scope associated with the item in the list.
As the weights impact the quality of predictions,
we first defined a range/ratio
for different categories based on our programming intuition.
Then, we experimented with this range
and selected the best performing weights.
Table~\ref{tab:reranking-weights} presents
the weights used in this process.
Although the current weights
improve the predictions,
this only sets the minimum bar.
Future work can exploit automatic learning of these weights.
\begin{table}[tb!]
\caption{Weights in the post-processing layer for re-ranking}
\begin{small}
\centering
\begin{tabular}{cccc}
\toprule
Leaf node type & Function & Class & File \\
\midrule
Attribute Access & 1.625 & 1.250 & 1.125 \\
Variable names & 1.625 & 1.125 & 1.500 \\
Function names & 1.125 & 1.625 & 1.500 \\
\bottomrule
\label{tab:reranking-weights}
\end{tabular}
\end{small}
\end{table}
\begin{algorithm}[tb!]
\caption{Re-ranking final recommendations}
\label{alg:reranking}
\begin{algorithmic}[1]
\State \textbf{input} Predictions, WeightsList
\State \textbf{output} Predictions \Comment{List of updated predictions}
\State Names $\gets$ getSignificantNames() \Comment{Get the list of important names in left context from the file}
\State \textbf{for} pred \textbf{in} Predictions \textbf{do}
\State \hskip1em \textbf{while} \textit{true} \textbf{do}
\State \hskip2em Names $\gets$ getSignificantName.pop()
\State \hskip2em \textbf{if} significantName.token = prediction.token \textbf{then}
\State \hskip3em typeCategory $\gets$ getTypeCategory()
\State \hskip3em weight $\gets$ weights[typeCategory][scope]
\State \hskip3em pred.probability $\gets$ pred.probability $\times$ weight
\State \hskip3em \textbf{break}
\State \hskip2em \textbf{end if}
\State \hskip1em \textbf{end while}
\State \textbf{end for}
\end{algorithmic}
\end{algorithm}
\section{Experimental Setup}\label{sec:experiments}
To train and evaluate CodeFill{},
we use two Python datasets.
We evaluate the models based on different evaluation scenarios,
to achieve a more realistic and comprehensive outlook
on the performance of code completion models
to benefit developers in real-world cases.
\subsection{Evaluation Tasks}\label{sec:eval_tasks}
We evaluate CodeFill{} on two tasks, namely
\textit{Token-Level} and \textit{Statement-Level} Predictions (TLP and SLP).
\subsubsection{Token-Level Prediction}
We use TLP to assess the ability of the model
to predict a single next token. We split this part of the evaluation
into four subtasks presented below.
\paragraph{Any token prediction} Our first sub-task is to evaluate the predictions
of any token irrespective of its type (TLP-A).
This is the baseline evaluation task employed in the literature,
but as research has shown~\cite{hellendoorn2019code},
it is not representative of
real-world autocompletion use. For this reason, we resort to more detailed
evaluations, as presented below.
\paragraph{Token Type Prediction} To assess the model's ability to learn grammatical sequences,
we evaluate how well a model can predict a correct AST token given
a context (TLP-B).
We group together AST tokens in the following categories:
\textit{Identifiers},
\textit{Keywords},
\textit{Operators},
\textit{Punctuation},
and finally numerals and string \textit{Literals}.
\paragraph{Leaf Node Prediction} Inspired by the evaluation setup of the state-of-the-art study by Kim et al.~\cite{kim2020code},
we investigate the ability of models when predicting AST leaf nodes (TLP-C),
including
\textit{Attribute access},
\textit{Names},
\textit{Function parameters},
and \textit{Constants}.
\paragraph{Cardinal Point Prediction}
The three tasks presented up to now give a comprehensive view
of the prediction ability of a model.
However, in practical settings, autocompletion is only triggered
at specific points
(e.g., after a dot,
or after specific keywords such as \texttt{for})
while the developer is editing source code.
To ensure that predictions translate to practical benefits
for the developers,
we evaluate completions on cardinal points (TLP-D).
To obtain a list of keywords
after which autocompletion is likely to be triggered,
we first select the list of
punctuation and keywords tokens that can be completed.
We then compute the frequency of
all bi-grams with any of these tokens as their first token
in our dataset.
Then, we remove three sets of bi-grams;
(1) those that are mostly written together
with occurrence frequency above $95\%$ (e.g., \texttt{async def}),
(2) those that are normally not predictable (e.g., \texttt{class NAME} or \texttt{def FUNCTION-NAME}),
and finally (3) those that are usually not practical completions (e.g., \texttt{TRUE :}).
The resulting list of tokens
after which it is most beneficial for autocompletion to be triggered
is as follows.
\vspace{1em}
\noindent\fbox{
\parbox{0.47\textwidth}{
DOT, AWAIT, ASSERT, RAISE, DEL, LAMBDA, YIELD, RETURN,
EXCEPT, WHILE, FOR, IF, ELIF, ELSE, GLOBAL, IN, AND,
NOT, OR, IS, BINOP, WITH, ;, ,, [, (, \{, \textasciitilde
}
}
\paragraph{Evaluation Metrics}\label{sec:TLP_metrics}
As the model only predicts a single token in the TLP task,
we include two evaluation metrics, namely
the \textit{Accuracy} of the top prediction
and the Mean Reciprocal Rank (\textit{MRR})
for the top-10 recommendations.
\textbf{Accuracy}
measures the proportion of samples
for which the suggested completion token exactly matches the single target label.
\textbf{MRR}
assesses the whole top $N$ recommended completions
and takes into account the first position
the target is matched~\cite{radev2002evaluating}.
For a single query, the reciprocal rank is
$\frac{1}{rank}$
where $rank$ is the position of the highest-ranked answer
$(1, 2, 3, ..., N$ for $N$ answers).
If no correct answer exists in top-$N$,
then the reciprocal rank is $0$.
For multiple queries $Q$,
the MRR is the mean of the $Q$ reciprocal ranks.
\subsubsection{Statement Level Prediction (SLP)}
The SLP task
assesses a model's ability to complete
statements with up to $n$ tokens.
The boxplot in
Figure~\ref{fig:stats_tokens_completion}
shows the distribution of number of tokens
for completions
in the evaluation dataset ($PY117K$).
In our datasets,
statements are $4.2$ tokens long on average (median: $4$, maximum: $13$).
To provide a comprehensive view,
we evaluate the performance of the models
when predicting next-$n$ tokens with $n \in [2,3,\ldots, 8]$.
\begin{figure}[tb!]
\centerline{\includegraphics[width=0.6\linewidth]{images/boxplots_eth.pdf}}
\caption{Length of statements in the PY117K dataset}
\label{fig:stats_tokens_completion}
\end{figure}
\paragraph{Evaluation Metrics:}\label{sec:SLP_metrics}
On absence of code-specific metrics,
we use two metrics commonly-used for automatic evaluation of
text generation,
namely Metric for Evaluation of Translation with Explicit ORdering (METEOR)~\cite{lavie2004significance}
and Recall-Oriented Understudy for Gisting Evaluation (ROUGE-L)~\cite{lin2004rouge}.
\textbf{ROUGE}:
ROUGE-N refers to overlapping n-grams.
ROUGE-L, one of the variations of the ROUGE metric,
counts longest matching sequence of words
using the Longest Common Subsequence algorithm.
It considers sentence-level structure similarity
and automatically identifies the longest co-occurring chain
of in sequence n-grams.
Thus, it does not require consecutive matches
but in-sequence matches that reflect sentence-level word order.
\textbf{METEOR}
is based on the term-to-term mapping of the generated code
with its corresponding reference code.
It focuses mainly on recall.
Lavie et al.~\cite{lavie2004significance} showed
metrics based on recall consistently achieve
higher correlation with user preferences
than those based on precision alone.
\subsection{Datasets}\label{sec:datasets}
We use two Python datasets for training and evaluation:
\begin{itemize}
\item The ETH $150$K Python dataset~\cite{raychev2016probabilistic}
for compatibility with previous work.
The authors collected Python programs from GitHub repositories
and removed duplicate files, project forks, files that do not parse and have more
than $30$K nodes in their ASTs.
They also removed obfuscated files
and only used repositories with permissive licenses
including MIT, BSD, and Apache.
\item The CodeFill{} dataset, which was collected
by querying GHTorrent~\cite{gousios2012ghtorrent} for all non-forked Python
repositories with more than $20$ stars ($58$k repositories).
\end{itemize}
After deduplication, using the method
proposed by Allamanis~\cite{allamanis2019adverse},
we ended up with two versions of the original datasets, $PY117K$ and $PY1690K$
for the ETH and CodeFill{} datasets, respectively.
Note that $PY1690K$ and $PY117K$ do not have any common files.
Table~\ref{tab:dataset_info}
presents an overview of the contents of the datasets.
We use $PY1690K$ exclusively for pre-training our LM.
We then use $90\%$ of $PY117K$
for fine-tuning the model on the tasks presented in Section~\ref{sec:eval_tasks},
and finally the last $10\%$ of $PY117K$ for evaluation.
For the baselines,
we concatenate $PY1690K$
with the same $90\%$ portion of $PY117K$ as above for training,
and evaluate on the remaining $10\%$ of $PY117K$.
\begin{table}[tb!]
\caption{Datasets used for training and evaluation}
\centering
\begin{tabular}{ccc}
\toprule
& PY1690K & PY117K\\\midrule
\#Repositories & $32.7$K & $24.9$K \\
\#Files & $1.7$M & $117$K \\
\#LOC & $425$M & $29$M \\
\#Tokens (unique) & $5.7$M & $766$K \\
\#Types (unique) & $103$ & $103$ \\
\bottomrule
\label{tab:dataset_info}
\end{tabular}
\end{table}
\subsection{Implementation and Configuration}\label{sec:config}
We use Python's AST~\footnote{\url{https://docs.python.org/3/library/ast.html}},
Tokenize~\footnote{\url{https://docs.python.org/3/library/tokenize.html}},
and the
DIS~\footnote{\url{https://docs.python.org/3/library/dis.html}}
libraries in our conversion tool.
Moreover, we use the \textit{HuggingFace}~\footnote{https://huggingface.co}
library for the implementation of our GPT-2 and MTL models.
We set the learning rate to $0.00001$,
maximum sequence length to $2048$,
and trained our model for $100$ epochs.
We set the remaining parameters to default values.
Our experiments are conducted on a machine
equipped with two GeForce GTX 1080 Ti GPUs,
an Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz CPU
with $14$ core processors, and $128$G RAM.
\section{Results and Discussion}\label{sec:results}
In this section, we present the results for each evaluation task,
along with an ablation study and a characterization of the models'
performance.
\subsection{Token-level Prediction (TLP)}
\subsubsection{Any token prediction}
The most basic form of evaluation for an autocompletion model
is to gauge its ability
to predict the next token given some context as input.
TLP-A can provide an overview
on the ability of an autocompleter to predict,
however, it does not account for
the prior probabilities of different types
of tokens. We present this task for compatibility
with existing work, and further elaborate CodeFill{}'s performance
in the following tasks.
The results can be seen in Table~\ref{tab:results_TPL_A};
our model outperforms all the baselines
across all metrics.
\begin{table}
\caption{TPL-A results: Any token prediction}
\centering
\begin{small}
\begin{tabular}{cccc}
\toprule
Approach & Venue & {Accuracy} & {MRR} \\
\midrule
n-gram + LSTM~\cite{hellendoorn2017deep} & (FSE, 2017) & 65.1 & 67.9 \\
Pointer Mixture~\cite{li2017code} & (IJCAI, 2018) & 65.8 & 70.0 \\
OpenVocab~\cite{karampatsis2020big} & (ICSE, 2020) & 67.2 & 69.8 \\
T-XL + Bi-LSTM~\cite{liu2020self} & (ICPC, 2020) & 75.0 & 76.4 \\
GPT-C~\cite{svyatkovskiy2020intellicode} & (FSE, 2020) & 79.8 & 80.0 \\
TravTrans+~\cite{kim2020code}& (ICSE, 2021) & 78.9 & 79.4 \\\midrule
CodeFill{} & Proposed & \textbf{80.6} & \textbf{81.7} \\
\bottomrule
\label{tab:results_TPL_A}
\end{tabular}
\end{small}
\end{table}
\subsubsection{Token Type Prediction}
We investigate the performance of the models
when predicting different types of tokens, i.e., their
ability to assimilate how developers use grammar to express concepts.
Models generally struggle more with specific token types.
For instance, it is known that predicting identifiers
is harder than predicting keywords~\cite{hellendoorn2019code}.
Table~\ref{tab:results_TPL_B}
present the Accuracy and MRR results based on all token types.
As demonstrated, CodeFill{} outperforms the baselines
for all token types based on both metrics (except for MRR on keywords
and punctuation, where its performance is on par).
Transformer-based approaches are highly capable of
predicting specific types of tokens, namely keywords and punctuation;
effectively, this means that given enough training examples, they
can efficiently learn syntactical patterns.
Predicting identifiers and literals across all models is more challenging.
For identifiers, all models' result
range from $37\%$ to $56\%$ accuracy.
In both cases, CodeFill{} maintains a non-trivial edge over the baselines,
which we attribute to the statement completion task. We believe it helps
CodeFill{} to learn syntactical patterns over longer ranges.
\begin{table}
\caption{TPL-B Results: Token type predictions}
\centering
\begin{small}
\begin{tabular}{cccccccc}
\toprule
\rotatebox{90}{Metric} & Approach
& \rotatebox{90}{Identifier} & \rotatebox{90}{Keyword}
& \rotatebox{90}{Punctuation} & \rotatebox{90}{Literals}
& \rotatebox{90}{Operators} & \rotatebox{90}{All} \\
\midrule
& Token Percentage & 21\% & 28\% & 33\% & 5\% & 13\% & - \\\midrule
\multirow{7}{*}{\rotatebox{90}{Accuracy}}
& N-gram+LSTM~\cite{hellendoorn2017deep}
& 40.2 & 74.2 & 81.4 & 46.2 & 62.7 & 66.6 \\
& Pointer Mixture~\cite{li2017code}
& 37.0 & 85.3 & 80.0 & 43.9 & 62.8 & 68.4\\
& OpenVocab~\cite{karampatsis2020big}
& 42.3 & 89.8 & 93.4 & 54.4 & 65.0 & 76.0\\
& T-XL + Bi-LSTM~\cite{liu2020self}
& 47.4 & 93.1 & 92.4 & 59.4 & 68.7 & 78.4\\
& GPT-C~\cite{svyatkovskiy2020intellicode}
& 50.0 & 96.5 & 95.1 & 62.0 & 71.0 & 81.2\\
& TravTrans+~\cite{kim2020code}
& 51.1 & 95.9 & 97.0 & 59.3 & 71.3 & 81.8 \\
\cmidrule{2-8}
& CodeFill{}
& \textbf{54.4} & \textbf{97.3} & \textbf{98.0} & \textbf{65.8} & \textbf{71.4} & \textbf{83.8} \\
\midrule
\multirow{7}{*}{\rotatebox{90}{MRR}}
& N-gram+LSTM~\cite{hellendoorn2017deep}
& 40.6 & 76.8 & 84.6 & 49.8 & 64.2 & 68.8\\
& Pointer Mixture~\cite{li2017code}
& 38.5 & 85.9 & 85.2 & 46.7 & 64.5 & 71.0 \\
& OpenVocab~\cite{karampatsis2020big}
& 43.2 & 90.3 & 96.0 & 57.0 & 67.1 & 77.6\\
& T-XL + Bi-LSTM~\cite{liu2020self}
& 49.8 & 96.1 & 96.6 & 61.3 & 70.0 & 81.4\\
& GPT-C~\cite{svyatkovskiy2020intellicode}
& 52.3 & {\bfseries 98.8} & {\bfseries 98.8} & 64.0 & 73.3 & 83.9\\
& TravTrans+~\cite{kim2020code}
& 53.7 & 97.1 & 98.6 & 62.2 & 73.0 & 83.6 \\
\cmidrule{2-8}
& CodeFill{}
& \textbf{56.0} & 98.1 & 98.0 & \textbf{66.1} & \textbf{74.4} & \textbf{87.2} \\
\bottomrule
\label{tab:results_TPL_B}
\end{tabular}
\end{small}
\vspace{-3mm}
\end{table}
\subsubsection{Leaf Node Prediction}
We compare each model's performance
in predicting different types of \textit{leaf nodes} in an AST,
e.g., function calls, variables, and attribute names.
Tables~\ref{tab:results_TLP_C}
present the Accuracy and MRR results for this task.
CodeFill{} is the best model in both accuracy, and, especially, MRR.
This means that its name predictions, which is arguably the most important
feature for an autocompleter,
are 2 out of 3 times correct and have a high
probability ($> 70\%$) of being included in the top suggestions.
\begin{table}
\caption{TLP-C results: Leaf node prediction}
\centering
\begin{small}
\begin{tabular}{ccccccc}
\toprule
\rotatebox{90}{Metric} & Approach
& \rotatebox{90}{\parbox{1cm}{Attribute\\Access}}
& \rotatebox{90}{Names}
& \rotatebox{90}{\parbox{1cm}{Function\\names}}
& \rotatebox{90}{\parbox{1cm}{Numeric\\constant}}
& \rotatebox{90}{All}\\
\midrule
& Token Percentage & 32\% & 13\% & 33\% & 22\% & \\\midrule
\multirow{7}{*}{\rotatebox{90}{Accuracy}}
& N-gram + LSTM~\cite{hellendoorn2017deep}& 56.3 & 61.8 & 63.5 & 45.1 & 56.9\\
& Pointer Mixture~\cite{li2017code} & 53.5 & 62.0 & 59.8 & 42.0 & 54.2 \\
& OpenVocab~\cite{karampatsis2020big} & 59.8 & 63.7 & 66.2 & 51.7 & 60.6 \\
& T-XL + Bi-LSTM~\cite{liu2020self} & 59.9 & 58.1 & 62.8 & 54.8 & 59.5 \\
& GPT-C~\cite{svyatkovskiy2020intellicode}& 60.0 & 59.9 & 64.0 & {\bfseries 56.0} & 60.4 \\
& TravTrans+~\cite{kim2020code} & 60.2 & 65.4 & 68.3 & 52.7 & 61.7 \\
\cmidrule{2-7}
& CodeFill{} & \textbf{64.0} & \textbf{67.3} & \textbf{72.2} & 53.1 & \textbf{66.3} \\
\midrule
\multirow{7}{*}{\rotatebox{90}{MRR}}
& N-gram + LSTM~\cite{hellendoorn2017deep}& 57.9 & 64.7 & 65.2 & 47.5 & 58.9\\
& Pointer Mixture~\cite{li2017code} & 57.1 & 59.0 & 60.2 & 43.1 & 55.3 \\
& OpenVocab~\cite{karampatsis2020big} & 61.2 & 64.8 & 70.1 & 51.7 & 62.5 \\
& T-XL + Bi-LSTM~\cite{liu2020self} & 61.9 & 65.3 & 69.9 & 55.3 & 63.5 \\
& GPT-C~\cite{svyatkovskiy2020intellicode}& 63.4 & 62.9 & 66.5 & \textbf{57.2} & 63.0 \\
& TravTrans+~\cite{kim2020code} & 62.8 & 65.4 & 70.0 & 55.2 & 63.8 \\
\cmidrule{2-7}
& CodeFill{} & \textbf{72.0} & \textbf{69.7} & \textbf{76.9} & 56.0 & \textbf{69.5} \\
\bottomrule
\label{tab:results_TLP_C}
\end{tabular}
\end{small}
\end{table}
\subsubsection{Cardinal Point Completion}\label{sec:cardinal-completion}
In Table~\ref{tab:results_TPL_D}, we report the performance of models
when predicting at cardinal points
(described in Section~\ref{sec:eval_tasks}).
As indicated,
CodeFill{} outperforms all the baselines.
Consequently, it is more capable of presenting correct recommendations
at points where autocompletion is more likely to be triggered.
\begin{table}
\caption{TPL-D Results: Cardinal Points Completion}
\begin{small}
\centering
\begin{tabular}{ccc}
\toprule
Approach & {Accuracy} & {MRR} \\
\midrule
N-gram + LSTM~\cite{hellendoorn2017deep}
& 49.0 & 52.3 \\
Pointer Mixture~\cite{li2017code}
& 51.3 & 52.4 \\
OpenVocab~\cite{karampatsis2020big}
& 52.2 & 53.5 \\
T-XL + Bi-LSTM~\cite{liu2020self}
& 64.0 & 64.7 \\
GPT-C~\cite{svyatkovskiy2020intellicode}
& 66.1 & 67.8 \\
TravTrans+~\cite{kim2020code}
& 65.0 & 66.2 \\\midrule
CodeFill{}
& \textbf{70.0} & \textbf{70.9} \\
\bottomrule
\label{tab:results_TPL_D}
\end{tabular}
\end{small}
\end{table}
\subsection{Statement-Level Prediction (SLP)}
We report the results for autocompleting code statements,
by predicting the remaining $n$ tokens at a given statement position
(with $n$ ranging between $2$ and $8$).
Figure~\ref{fig:statement}
presents the results of this experiment
based on the achieved METEOR and ROUGE-L scores.
All Transformer-based models~\cite{liu2020self,svyatkovskiy2020intellicode,kim2020code},
are consistently more capable than the three baseline approaches.
CodeFill{} improves over
all competitors.
The margin grows wider
as the number of tokens required
to complete statements increase
(especially in the ROUGE-L case).
This result highlights the merits of our statement completion task.
In turn, this can help developers code faster
by reducing the number of required keystrokes;
the experience of using statement completion should be reminiscent
of text line completion in popular
online email or document editors.
Statistically, \emph{more than 2 out of 3 statement completions of 4 or fewer tokens will be correct.}
\begin{figure*}
\centering
\subfigure
{\includegraphics[width=0.4\linewidth]{images/eth_meteor.pdf}}
\subfigure
{\includegraphics[width=0.4\linewidth]{images/eth_roughe_l.pdf}}
\caption{Results for the SLP task}
\label{fig:statement}
\end{figure*}
\subsection{Ablation Study}
We perform an ablation study to examine the impact
of different components of CodeFill{} .
Table~\ref{tab:results_ablation}
presents the results of this study.
We include the performance of a vanilla GPT-2 model
to show the importance of employing the MTL approach
to jointly train models on different representations of source code.
The results show that employing the MTL technique to
train the models jointly on multiple tasks
indeed helps the model learn better.
Next, we conduct experiments to compare
hard-parameter and soft-parameter models with the two-task MTL model.
It is worth mentioning
that for the hard-parameter sharing variation,
we need to input a unified representation to the models.
Thus, we concatenate the type and value of each token
as $x_i = [t_i, v_i]$
and then feed the vectors of this concatenated representation to the MTL model.
The results indicate that
the soft-parameter sharing works better in our case.
This is probably because this setting
allows each task to have its own model and parameters
and then regularizes the distance between them
to encourage the parameters to be similar.
Finally, to verify whether adding information regarding statements helps,
we investigate the effect of adding the third task,
\textit{statement completion}.
The results demonstrate that training
on two different granularity (single-token and statement)
also helps them learn better.
To conclude,
each component of the proposed model adds to its value.
Although the training time increases,
it can be argued that training time is a one-time cost,
and can be significantly reduced with parallel training on
multiple GPUs.
\begin{table}
\caption{Effectiveness of Different Components of the Model}
\centering
\begin{small}
\begin{tabular}{cccccc}
\toprule
Approach & Tasks & Train Time & Accuracy & MRR\\
\midrule
GPT-2 & Value & 12h & 77.7 & 78.2\\
MTL HP & Value, Type & 17h & 78.3 & 79.6\\
MTL SP & Value, Type & 19h & 78.9 & 79.5\\\midrule
MTL SP & Value, Type, Statement & 24h & \textbf{80.6} & \textbf{81.7} \\
\bottomrule
\label{tab:results_ablation}
\end{tabular}
\end{small}
\end{table}
\subsection{Runtime Characteristics}
An important aspect of ML-based autocompletion tools is
their prediction latency. A very accurate model that takes
$1$ second per prediction will not be very useful in practice
as it will interfere with the developer's workflow.
As Table~\ref{tab:complexity}, all models feature an average
latency of less than $100$ milliseconds, which is considered
the golden standard in the industry.
Moreover, the model size and number of parameters
are important practical aspects
that affect a model's deployment; if the model is too big,
it will need to be deployed centrally and clients should
connect to the model server over a network connection (which
may affect latency negatively), otherwise, it could be distributed
to the clients.
As Table~\ref{tab:complexity} shows,
CodeFill{}'s number of parameters is more than other baselines
due to our architecture specification.
However, the size of all Transformer-based models
makes them impractical
for distribution to clients,
necessitating centralized deployments.
\begin{table}
\caption{Runtime Characteristics}
\centering
\begin{tabular}{cccc}
\toprule
Approach & \parbox{2cm}{Train Time (hr)} & \parbox{1.7cm}{Latency (ms)} & \#Params\\
\midrule
n-gram + LSTM~\cite{hellendoorn2017deep} & 23 & 75 & 168M\\
Pointer Mixture~\cite{li2017code} & 18 & 62 & 177M\\
OpenVocab~\cite{karampatsis2020big} & 21 & 61 & 145M\\
T-XL + Bi-LSTM~\cite{liu2020self} & 24 & 79 & 173M\\
GPT-C~\cite{svyatkovskiy2020intellicode} & 23 & 74 & 125M\\
TravTrans+~\cite{kim2020code} & 15 & 53 & 119M \\
\midrule
CodeFill{} & 24 & 73 & 258M\\
\bottomrule
\label{tab:complexity}
\end{tabular}
\end{table}
\section{Contributions and Implications}
Autocompletion is a popular research area,
however, the existing challenges
leave substantial margin for improvement,
particularly for recommending identifiers
or completing longer sequences~\mbox{\cite{hellendoorn2019code}}.
In this study, CodeFill{} learns from sequences of
both token types and token names simultaneously using MTL.
The contribution of this work is twofold;
\textbf{\textit{Technical novelty}}:
Similar to the
state-of-the-art~\mbox{\cite{kim2020code,svyatkovskiy2020intellicode}},
we use transformers
for learning a name-based sequencing model,
and similar to the studies
by Liu et al.~\mbox{\cite{liu2020self,liu2020multi}},
we use the MTL technique
to condition our models under different tasks.
However, IntelliCodeCompose~\mbox{\cite{svyatkovskiy2020intellicode}}
treats code as natural text,
neglecting the rich structure inherent in programs.
Moreover they focus on multi-lingual LMs.
TravTrans+~\mbox{\cite{kim2020code}} uses serialized ASTs
in an attempt to learn from structure,
however, we show that our novel transformation,
which we designed so that it is closer to
how developers treat source code structure, outperforms TravTrans+.
CodeFill{} also learns from our novel statement completion task
to consider longer contexts.
Both \mbox{\autoref{fig:statement}}
and \mbox{\autoref{tab:results_ablation}}
show that this technique improves the model,
probably by helping it better utilize completion context.
The combination of the above demonstrably
results in higher evaluation scores and better recommendations.
\textbf{\textit{Evaluation}}:
We propose two novel evaluation tasks,
\textit{cardinal point}, and \textit{statement completion},
to address deficiencies in current autocompletion evaluation setups.
We also collect, pre-process, deduplicate,
and share an large Python dataset,
consisting of practically all Python code on GitHub.
\section{Threats to the Validity}\label{sec:threats}
\textbf{Threats to internal validity}:
These include the threats
pertaining to the parameters affecting the performance of the model.
Another threat in this section relates to the errors in
the implementation of the baselines.
For all of these approaches,
we have used the replication packages provided by these studies.
\textbf{Threats to external validity}:
These threats relate to the quality of the datasets
we used and the generalizability of the results.
We used two Python datasets;
PY117K is a benchmark dataset ~\cite{raychev2016probabilistic}
frequently used in the
literature~\cite{li2017code,liu2020self,karampatsis2020big,kim2020code}.
PY1690K, our second dataset, is ten times larger
with approximately $1.7M$ program files.
More data can lead to more generalizable results.
Furthermore, as Allamanis.~\cite{allamanis2019adverse} suggests,
we have de-duplicated both datasets to avoid biasing the models.
All of the programs in both datasets are collected from
open-source GitHub repositories.
However, further studies are
needed to validate and generalize our findings
to other programming
languages.
\textbf{Threats to construct validity}:
These relate to the suitability of the evaluation setting and metrics.
In this work, we have tried to incorporate diverse evaluation measures.
For the TLP task,
we have used standard evaluation metrics,
namely Accuracy and MRR
in the top-one and top-ten recommendations
which are both frequently used in the literature~\cite{li2017code,liu2020self,karampatsis2020big,kim2020code}.
Furthermore, we use ROUGE-L and METEOR scores for evaluation
in the SLP task as used in previous studies
on source sequence of code generation, summarization, and translation~\cite{svyatkovskiy2020intellicode,aghamohammadi2020generating}.
\section{Conclusion and Future Work}\label{sec:conclusion}
Unlike natural language text, source code is more structured,
its grammar is more well defined but its vocabulary is orders
of magnitude bigger.
Consequently, NLP-based models and corresponding evaluation methods
need to be adapted to the particular case of source code.
In this work, we proposed CodeFill{},
a Transformer-based generative LM for source code
pre-trained on three tasks closely relevant to programming.
Given a context of tokens (and their types),
CodeFill{} is trained to predict
(1) the type of the next token,
(2) its value,
and (3) the values of up to $n$ next tokens.
We employ the MTL approach
to jointly train CodeFill{} on the above tasks.
We also propose 2 novel evaluation tasks,
cardinal point prediction and statement-level multi-token prediction,
which we argue that they better represent how autocompletion systems
are used in practice.
We extensively evaluate CodeFill{}
against six baselines on both tasks.
Our results indicate that CodeFill{} outperforms
all the baselines in all scenarios,
achieving state of the art scores on both accuracy (80.6\%)
and MRR (81.7\%) in the basic token-level prediction task.
Moreover, we show that CodeFill{} also learns to autocomplete statements
of up to 4 tokens with over 70\% accuracy,
a significant improvement over the baselines,
making it practical to offer statement completions as an IDE feature.
In the future, we plan to incorporate more domain specific
knowledge on aspects of training and evaluating a
training ML models.
For instance, one can limit the context fed to the model
based on the programming language
to better incorporate related information of functions
and nested scopes in a piece of code.
We also plan to further investigate statement completion,
including better metrics for its evaluation.
\begin{acks}
This work has received funding from
the European Union’s Horizon 2020 research and innovation programme
under grant number 825328 (FASTEN project),
and also the NWO MIPL project,
grant number 628.008.003.
\end{acks}
\bibliographystyle{ACM-Reference-Format}
\section{Introduction}\label{sec:intro}
Automatic code completion (also called autocompletion)
is the task of completing source code statements
by predicting what the developer would write
given the current context.
It helps developers finish their programming tasks faster by
decreasing the typing effort and saving keystrokes,
correcting typographical errors,
and enabling them to explore APIs
in a context-sensitive manner~\cite{amann2016study}.
Autocompletion has therefore emerged
as one of the most prominent features
in Integrated Development Environments (IDEs).
To support autocompletion,
current IDEs exploit the regular structure of programming languages.
For example,
an IDE knows that an opening parenthesis character (`\texttt{(}`)
at a function-call position
must be followed by enough arguments to match the function's arity.
It can therefore propose argument names for variables that are in scope.
The availability of types in the host programming language
helps increase the precision of suggestions;
continuing with the example above,
the IDE will only propose variable names
for variables whose types match the function argument.
Recent autocompletion systems also
take into account past completions~\cite{robbes2010improving}
and analyze large code bases~\cite{bruch2009learning}
to rank suggestions according to their past popularity.
Despite the best efforts of researchers and IDE developers,
developers find rule-based code completion mechanisms lacking.
Ranking suggestions based on alphabetical or usage frequency
(or even the suggestion list length~\cite{xianhao2018the})
neglects the current context,
leading to unrelated recommendations~\cite{allamanis2018survey}.
These problems are exacerbated in dynamically typed language settings,
as the IDE is lacking significant information to provide accurate suggestions.
To mitigate rule-based autocompletion issues,
researchers have proposed
statistical~\cite{nguyen2013statistical, hellendoorn2017deep} and
learning-based~\cite{liu2016neural,hellendoorn2017deep,li2017code,svyatkovskiy2019pythia,liu2020self,aye2020sequence}
autocompletion models.
Motivated by the \textit{naturalness} hypothesis~\cite{hindle2012naturalness},
learning-based models treat source code as natural language text,
hence code completion becomes an instance of the well-studied
text completion problem.
However, treating source code as text deprives learning-based models
of important code structure and semantic information~\cite{hellendoorn2019code}.
Moreover, the open-ended nature of code
leads to extremely large prediction spaces
due to developers constantly inventing identifier names~\cite{karampatsis2020big}.
In an illuminating study, Hellendoorn et al.~\cite{hellendoorn2019code}
identified a set of issues with current research in code completion.
Initially, the current approach of evaluating
accuracy as masked token prediction
does not reflect how autocompletion is used;
developers only trigger autocompletion after specific,
and certainly not arbitrary, points
in a program's syntax (e.g., after an opening parenthesis).
Thus, treating all tokens equally
masks the fact that some tokens (e.g., punctuation)
are much easier to predict than others (e.g., identifiers).
Moreover, most approaches (especially learning-based ones)
do not account for names coming from dependencies,
which deprives them of important context.
In this work, we propose \textit{CodeFill},
a novel learning-based
approach that aims to address the problems identified above.
CodeFill{} borrows from the bimodality hypothesis~\cite{santanu2018refinym}
to model source code inputs.
Specifically, CodeFill{} exploits that information is conveyed by
source code through two channels;
the \textit{natural language channel} (variable names, functions, etc.),
and the \textit{code structure channel} (inheritance, containment, etc.).
Inputs are fed into the model
simultaneously as both sequences of token values,
which enable it to learn relationships among token values,
and, uniquely, sequences of token types,
which enable it to learn associations between syntactic elements.
CodeFill{} is then asked to predict either the value or the type of the
next \emph{n} tokens.
To enable CodeFill{} to learn name dependencies across longer ranges,
we also train it with an additional task,
multi-token statement completion at the value level.
The input token names to CodeFill{} is encoded with Byte-Pair Encoding (BPE),
which enables CodeFill{} to both
compress the input name space and generate names that are not in the input vocabulary.
To present suggestions relevant to the developer's context,
CodeFill{} includes a post-processing step
that re-ranks the predictions based on
the context visible to the model at the completion point.
CodeFill{} is instantiated as a set of
three Transformers (GPT2-based)
trained with soft parameter sharing Multi-Task Learning (MTL) setting.
Each transformer models one of the three tasks,
namely token value, token type, and multi-token prediction;
a joint loss function across all three tasks
updates the weights of all three model components.
During each epoch, the model is trained
on one task according to a configurable task-picking policy.
Our target language is Python, to both demonstrate the efficiency of the model when
type information is missing and also make our work comparable with the state of the art.
We pit CodeFill{} against four baseline models and two the-state-of-the-art models, namely
GPT-C~\cite{svyatkovskiy2020intellicode} and TravTrans+~\cite{kim2020code}.
We use two deduplicated datasets:
the ETH150K dataset (deduplicated: \textit{PY117K})
and a manually collected dataset
consisting of practically all
non-forked Python repositories on GitHub (\textit{PY1690K}).
We evaluate all models on two tasks:
\textit{Token-Level} and \textit{Statement-Level} Predictions (TLP and SLP).
For TLP, we evaluate for
i) next token prediction (TLP-A),
ii) next token type prediction (TLP-B),
iii) next token value prediction (TLP-C).
To ensure that the evaluation setting reflects real-world use of autocompletion,
we also evaluate completions after specific syntactic
elements, e.g., a dot \texttt{.} or an \texttt{AWAIT} keyword (TLP-D).
We devise an algorithm to identify those syntactic elements
(\emph{cardinal points}) automatically given a corpus.
We use top-1 Accuracy and the Mean Reciprocal Rank (MRR)
as evaluation metrics.
For the SLP task, we assess the models
on statement completion with $n$ tokens
and we compare them using METEOR and ROUGE-L measures.
To show that each component in the CodeFill{} model is necessary,
we perform an ablation study.
The results demonstrate that CodeFill{} outperforms all the competing approaches in all tasks.
Indicatively,
for each of the TPL-A, TPL-B, TPL-C, and TPL-D evaluation tasks,
CodeFill{} achieves a state of the art MRR of
$81.7\%$, $87.2\%$, $69.5\%$, $70.2\%$
while TravTrans+, a current state of the art, scores
$79.4\%$, $83.6\%$, $63.8\%$, and $66.2\%$,
respectively.
In the SLP evaluation task,
for completing statements with four tokens
(the average completion length in our datasets)
CodeFill{} obtains $70.2\%$ and $63.8\%$
for the METEOR and ROUGE-L metrics respectively,
and thus significantly surpasses TravTrans+
($64.5\%$ and $52.4\%$).
The main contributions of this work are:
\begin{itemize}
\item CodeFill{}, a model that unifies learning of structural and name-based information for the autocompletion task.
\item An implementation of CodeFill{}, including training procedures,
for the Python programming language.
We make our code and datasets available.~\footnote{\url{https://github.com/saltudelft/codefill}}
\item An extensive evaluation of CodeFill{}
against four baseline models and two state-of-the-art approaches, demonstrating its superior performance.
\end{itemize}
\section{Background and Related Work}\label{sec:bg}
In this section,
we briefly review the background work relating to our approach.
Then, we present the main approaches to autocompletion,
including the baselines we used for comparison.
\subsection{Language Models and Transformers}
\label{sec:bg_transformers}
Statistical Language Modeling (LM)
is the task of developing a probabilistic model for predicting
the next tokens in a sequence given its preceding tokens,
i.e., the context~\cite{goldberg2017neural}.
This context for simpler LMs is a short sequence of words,
while it can be sentences or paragraphs for larger models~\cite{schutze2008introduction}.
LMs are either used without modification,
e.g., in a text generation task,
or used inside a down-stream task
which requires language understanding.
Programming languages also
contain predictable statistical properties
which can be learned using LMs~\cite{hindle2012naturalness}.
Recently, Neural LMs have gained popularity
due to their superior performance and generalization capabilities~\cite{mikolov2010recurrent,goldberg2017neural}.
Neural LMs address the n-gram data sparsity problem
through parameterization of words as vectors~\cite{kim2016character}.
A real-valued vector (word embedding) is used to
represent each word in a vector space.
This representation of words
is learned based on their usage.
This allows words with a similar meaning
to have a similar representation.
Note that traditional statistical LMs
were not able to achieve this level
of generalization~\cite{schwenk2002connectionist}.
Moreover, the distributed representation approach
makes it easier for the embedding representation to scale
with the vocabulary size.
This is specifically useful with source code,
where the vocabulary size can be unlimited
due to the use of arbitrary identifiers.
Initially, feed-forward neural network models,
then Recurrent Neural Networks (RNNs)
and next, networks with long-term memory,
such as Long Short Term Memory (LSTM) networks were used.
Most recently, there have been significant improvements
with the introduction of self-attention architectures in the Transformer
which is a sequence-to-sequence architecture
for transforming a given sequence of elements to another form~\cite{vaswani2017attention}.
Attention enable Transformers
to focus on selective parts of an input,
thus generating more relevant outputs~\cite{luong2015effective}.
Transformers outperform previous deep models
such as RNNs and LSTMs on multiple NLP tasks~\cite{vaswani2017attention}.
A Transformer consists of two main components,
an encoder, and a decoder.
GPT-2 introduced by OpenAI~\footnote{\url{https://openai.com/}},
is a large generative Transformer-based LM
trained on a dataset of $8$M web pages~\cite{radford2019language}.
GPT-2 has been successfully exploited
for various NLP and source code analysis tasks~\cite{budzianowski2019hello,lee2020patent,ham2020end,svyatkovskiy2020intellicode}.
\subsection{Multi-Task Learning}\label{sec:bg_mtl}
Multi-Task Learning (MTL) is a model training technique that combines
multiple tasks and a joint loss function,
with the goal of maximizing performance on one or all of the tasks.
MTL enables knowledge transfer across related tasks
and improves generalization by leveraging the domain-specific
information contained in the training signals of related
tasks~\cite{caruana1997multitask}.
An MTL model captures the common features among all the tasks
through sharing hidden layers among them.
MTL has been applied successfully in both NLP~\cite{devlin2018bert}
and source code analysis~\cite{liu2020self,liu2020multi}.
There are two approaches to jointly train models using MTL,
\textit{hard-parameter} and \textit{soft-parameter} sharing.
In the former, the hidden layers
are shared between all tasks
while keeping several task-specific output layers.
For the latter,
each task has its own model with its own parameters.
However, the distance between them is regularized
to encourage the parameters to be similar.
In the soft-parameter sharing case, training can happen
either \textit{sequentially} (one task per training round)
or \textit{alternatively} (one task per epoch).
\subsection{Related Work}\label{sec:related}
Autocompletion is an active research area
for both practitioners and researchers.
Below, we review the latest approaches to autocompletion.
\subsubsection{Conventional Autocompletion}
Traditionally, autocompleters used
heuristic rules
static type information~\cite{hou2010towards},
similar code examples~\cite{bruch2009learning},
and program history data~\cite{robbes2008program}
for suggesting completions.
For instance, IDEs conventionally return
a list of type-checked names
either based on the order of alphabet or usage frequency.
\subsubsection{Statistical LMs and Grammar-based Models}
Several studies use statistical LMs for modeling source code~\cite{hindle2012naturalness,nguyen2013statistical,tu2014localness,hellendoorn2017deep}.
Tu et al.~\cite{tu2014localness} built upon an n-gram model
using a cache mechanism to capture locality in source code.
Hellendoorn and Devanbu~\cite{hellendoorn2017deep} improved the n-gram model
by exploiting various techniques including
nested scopes, locality, and unlimited vocabulary.
Raychev et al.~\cite{raychev2016probabilistic}
proposed a probabilistic model
based on decision trees and domain-specific grammars.
Researchers also studied the use of syntactic structure
through exploiting probabilistic graphical models.
Allamanis et al.~\cite{allamanis2014mining}
employ probabilistic context-free grammars,
while Raychev et al.~\cite{raychev2016probabilistic,raychev2016learning,bielik2016phog}
use probabilistic higher order grammars to this end.
\subsubsection{Deep Learning for Autocompletion}
Recently, deep neural networks
such as RNNs, LSTMs and Transformers
are being effectively used
for modeling source code~\cite{li2017code,hellendoorn2017deep,aye2020sequence,karampatsis2020big,kim2020code}.
In 2018, Li et al.~\cite{li2017code} proposed
a pointer mixture model to mitigate the Out-Of-Vocabulary (OOV) problem.
They trained two LSTM models on types and tokens.
Karampatsis et al.~\cite{karampatsis2020big}
presented a large-scale open-vocabulary neural LM.
They incorporated BPE, beam search, and cache mechanism
to address the OOV problem.
Most recently, Kim et al.~\cite{kim2020code},
incorporated the syntactic structure of trees
into their Transformer-based model to better learn
from source code.
\subsubsection{Multi-token Autocompletion}
Although most research on code completion
is focused on single-token prediction,
several studies aimed to complete entire statements or blocks of code~\cite{svyatkovskiy2020intellicode,nguyen2019combining,yang2017language,wen2021siri}.
Yang et al.~\cite{yang2017language}
proposed \textit{PCC} and
introduced an intermediate representation for source code,
to put tokens into groups using lexeme and variable relative order.
Nguyen et al.~\cite{nguyen2019combining}
proposed \textit{AUTOSC}
to combine program analysis and software naturalness
and fill in a partially completed statement
with frequent and valid recommendations.
Svyatkovskiy et al.~\cite{svyatkovskiy2020intellicode}
recently proposed a GPT-2 based multi-lingual model,
\textit{GPT-C}, for completing lines.
Wen et al.~\mbox{\cite{wen2021siri}}
introduced \textit{FeaRS} which recommends the next method
given the current code in an IDE
using implementation patterns
learned through mining open source projects.
\subsubsection{MTL for Autocompletion}
MTL has been used in various NLP-related tasks~\cite{zhang2021survey,ruder2017overview,sener2018multi}.
Recently, it has also been employed
for programming language processing tasks.
Liu et al.~\cite{liu2020multi,liu2020self}
proposed two approaches based on MTL for autocompletion.
In the first study, the authors used a Transformer-XL and an RNN
for predicting next token type and value~\cite{liu2020self}.
They develop a partial AST encoder and a path2root encoder
and use them in their MTL framework.
In their second study,
Liu et al.~\cite{liu2020multi}
pre-train their model with hybrid objective functions
for code understanding and code generation tasks.
Next, they fine-tune it on code completion.
The pre-training tasks are masked bidirectional LM,
next code segment prediction, and unidirectional LM.
The fine-tuning tasks are unidirectional masked LM,
and unidirectional LM.
\subsubsection{Practical Aspects of Autocompletion}
Hellendoorn et al.~\cite{hellendoorn2019code} claim
the accuracy of autocompleters evaluated on synthetic data
can drop on real-world data.
Aye et al.~\cite{aye2021learning},
trained models on real-world code completion examples
of an internal dataset (Facebook).
They showed that models trained on data distributions that
are closer to those of where the model will be deployed
can outperform models trained on
committed source code in public repositories.
Svyatkovskiy et al.~\cite{svyatkovskiy2019pythia}
integrated Pythia, an LSTM model, to \textit{IntelliCode},
an extension to Microsoft VS Code IDE.
In a follow-up study~\cite{svyatkovskiy2020intellicode},
they introduced \textit{IntelliCode Compose}
as a general-purpose multilingual autocompletion using Transformers.
The improved model predicts sequences of code tokens,
generating up to entire statements.
IntelliCode Compose is integrated into the Microsoft VS Code IDE.
Finally, Svyatkovskoy et al.~\cite{svyatkovskiy2021fast} implemented
and evaluated several neural code completion models, which
offer varying trade-offs in terms of memory, speed, and accuracy.
Commercial autocompletion tools,
such as \textit{TabNine} and \textit{GitHub Copilot} also exist,
but very little technical information has been shared about them.
\subsection{Baselines}
We include six
recent models as baselines
to provide a comprehensive evaluation.
For all baselines,
we use the replication packages provided by the authors
and set the parameters as defined in each respective study.
For the statement level prediction task,
we modified the output layer of the baselines
to predict up until the end of a statement.
\textbf{N-gram + LSTM (FSE, 2017)}:
Hellendoorn et al.~\cite{hellendoorn2017deep}
claim that a well-engineered and simple approach
(n-gram based language models)
can provide better performance than more complex models (deep neural networks).
The authors show that the combination of an n-gram and LSTM-based model outperforms the rest of their models.
\textbf{Pointer Mixture (IJCAI, 2018)}:
Li et al.~\cite{li2017code},
propose a pointer mixture model
to address the OOV problem.
They also try to incorporate structural information in their models
by training two models (token types and values) separately.
\textbf{T-XL + Bi-LSTM (ICPC, 2020)}:
Liu et al.~\cite{liu2020self,liu2020multi},
propose two models based on the MTL technique.
The first study uses Transformer-XL and a Bi-LSTM
to train two models for tokens and AST paths
for dynamically-typed languages such as Python.
The second study by the same group
presents a pre-trained language model
which is fine-tuned for code completion.
The authors use static analysis and type annotations
for their type prediction task, for Java.
We compare against the first model only,
as it most closely matches our setup.
\textbf{OpenVocab (ICSE, 2020)}:
To address the OOV problem,
Karampatsis et al.~\cite{karampatsis2020big}
present a BPE-based language model.
We include it here for completeness,
even though their model is not tuned for autocompletion.
\textbf{IntelliCode Compose (FSE, 2020)}:
Svyatkovskiy et al.~\cite{svyatkovskiy2020intellicode}
propose a general-purpose, multi-lingual autocompletion
supporting multi-token statement completion.
They train a GPT-2 model on $1.2B$ LOC
written in Python, C\#, TypeScript, and JavaScript.
This tool is deployed as a cloud-based web service
and uses client-side caching and parallel implementation
to speed up the predictions.
As the source code
is not publicly available,
we trained a GPT-2 model for source code
and did our best to adhere to the settings reported in the study.
As the focus of our study is mono-lingual,
we only train this model on Python code.
\textbf{TravTrans+ (ICSE, 2021)}:
Kim et al.~\cite{kim2020code}
propose a transformer-based approach
which exploits AST paths.
We use their best model, TravTrans+,
as the state of the art in our evaluation.
\section{Approach}\label{sec:approach}
The CodeFill{} pipeline comprises two main phases;
\textit{pre-processing},
\textit{model training}.
Figure \ref{fig:workflow} presents the overall workflow.
Initially, CodeFill{} pre-processes, tokenizes
and converts the input source code
to equivalent syntax token sequences.
Training consists of two main phases
\textit{pre-training} with 3 tasks (token sequence type and name completion, statement completion)
and \textit{fine-tuning} on 2 tasks (name and statement completion).
For both stages, CodeFill{} uses
soft-parameter sharing MTL
to learn from different representations of source code.
At evaluation time, Codefill also
re-orders recommendations
based on their type and the visible context.
In the following section, we present how the proposed approach works in detail.
\begin{figure}[tb!]
\centering
\includegraphics[width=\linewidth]{images/workflow.pdf}
\caption{CodeFill{} Workflow}
\label{fig:workflow}
\end{figure}
\subsection{Pre-processing}\label{sec:approach_link}
During pre-processing, CodeFill{}
converts the input program files
to an equivalent format where keywords and identifiers
are swapped with their AST equivalents.
The algorithm starts by removing comment sections, blank spaces, and blank lines.
It then extracts the list of
\textit{modules}, \textit{libraries}, and their \textit{aliases}
using the Python \textit{AST} library.
Those are stored in a dictionary
and, using it, CodeFill{} replaces all their occurrences in code
with their respective types
(i.e., \texttt{MODULE}, \texttt{LIBRARY}, and \texttt{ALIAS}).
CodeFill{} also pre-processes and tokenizes the input source code.
For each line, it reads the tokenized information
and stores four types of information about each token
namely
(1) its value,
(2) its type,
(3) its line number,
and (4) its position in the line.
For instance, for the statement \texttt{return node}
in Figure~\ref{fig:sample_code},
it stores two tokens
as shown in the table following the code example.
Moreover, variable visibility information
(e.g., global vs. local variables),
is maintained, to differentiate
between different name usages in the same context.
\begin{figure}[tb]
\centering
\begin{minted}[
linenos,frame=single,
breaklines=true,
framerule=0.5pt,
breaksymbolleft=,
numbersep=1mm,
fontsize=\footnotesize]{python}
def transform(node, ctx):
node = qual_names.resolve(node)
node = CallTreeTransformer(ctx).visit(node)
return node
\end{minted}
\begin{tabular}{cccc}
Type & Value & \#Line & Position \\\midrule
RETURN & return & 4 & 1 \\
NAME & node & 4 & 2 \\
\bottomrule
\end{tabular}
\caption{Sample code snippet and the extracted information}
\label{fig:sample_code}
\end{figure}
To address the OOV problem,
CodeFill{} uses a BPE-encoded name representation.
Exploiting word segmentation,
BPE iteratively merges the most frequently occurring character sequences.
Prior to applying BPE encoding,
and similarly to other studies~\cite{svyatkovskiy2020intellicode,izadi2021topic,izadi2022predicting},
CodeFill{} normalizes the input strings
by replacing
\textit{string}, and \textit{numeric} literals
with respective special tokens,
i.e., \texttt{STRING} and \texttt{NUMBER}.
A unique characteristic of the Python language
is that indentation defines code blocks;
it is therefore important for source code models
to learn to encode indentation as part of their learned representation.
To do so, CodeFill{} stores the positioning of indentation markers.
For the first line with an indentation,
it adds a special token $\langle INDENT \rangle$
at the beginning of the given line.
It passes through the following lines with the same indentation,
to reach the next indentation or a dedentation position,
at which point it adds a respective $\langle INDENT\rangle$
or $\langle DEDENT\rangle$ token.
The pre-processing step results in two files for each input source code file;
(1) one containing sequences of token names
minus the comments and extra blank lines, and
(2) one containing sequences of token types.
Both are fed into CodeFill{}
as two different but corresponding representations of source code.
Figure~\ref{fig:cherry} shows a sample function
and its corresponding type information with the correct indention.
\begin{figure}[tb!]
\centering
\begin{minted}[
linenos,frame=single,
breaklines=true,
framerule=0.5pt,
breaksymbolleft=,
numbersep=1mm,
fontsize=\footnotesize]{python}
# Raises an error when the required variable is missing
def required_env(var):
value = os.environ.get(var)
if value is None:
raise RuntimeError("Var is required to start the service.")
return value
\end{minted}
\begin{minted}[
linenos,frame=single,
breaklines=true,
framerule=0.5pt,
breaksymbolleft=,
numbersep=1mm,
fontsize=\footnotesize]{python}
def required_env(var):
value = os.environ.get(var)
if value is None:
raise RuntimeError("STRING")
return value
\end{minted}
\begin{minted}[
linenos,frame=single,
breaklines=true,
framerule=0.5pt,
breaksymbolleft=,
numbersep=1mm,
fontsize=\footnotesize]{python}
DEF FUNCTION_NAME(LOCAL_VARIABLE): EOS
INDENT LOCAL_VARIABLE = LIB.MODULE.FUNCTION_NAME(LOCAL_VARIABLE) EOS
IF LOCAL_VARIABLE IS NONE: EOS
INDENT RAISE ERRORTOKEN("STRING") EOS
DEDENT RETURN LOCAL_VARIABLE EOS
\end{minted}
\caption{An example code snippet and its converted version}\label{fig:cherry}
\end{figure}
\begin{figure*}[tb!]
\centering
\includegraphics[width=0.9\linewidth]{images/approach.pdf}
\caption{Model training}
\label{fig:approach}
\end{figure*}
\subsection{Model Training}\label{sec:approach_modeltrainingl}
In this phase,
CodeFill{} learns from two granularity levels;
token- and statement-level completions
with three simultaneous tasks,
namely
(1) next Token \textit{Value} Prediction (TVP),
(2) next Token \textit{Type} Prediction (TTP),
and (3) \textit{Statement} Completion (SC).
Model training follows a two-stage process;
First, a generic language modeling objective
is used on the unlabeled data
to learn the initial parameters.
Then, these parameters are adapted
to the target tasks using the corresponding objective.
Thus, while pre-training,
CodeFill{} learns from all three tasks
while fine-tuning is restricted to
the TVP and SC tasks.
The reason for excluding the TTP task is that
the number of types for all the program files is limited.
Hence, the model quickly learns how to properly predict these type sequences
(i.e., learns an effective representation of the Python grammar),
eliminating the need for further fine-tuning.
The main neural network architecture
for all tasks is based on the GPT-2 Transformer with $L$ layers.
CodeFill{} uses three distinct GPT-2 transformers,
each with its own input and training objective.
The models are initialized with random weights.
Transformer blocks include
self-attention layer,
feed-forward neural nets,
and a normalization layer.
Self-attention blocks identify which tokens to focus on.
Feed-forward neural nets consist of an input layer to accept information,
hidden layers to capture the hidden correlations between each data point,
and finally, an output layer to transmit information.
The parameters are transferred to the next decoder
in the stack after being regularised (with $l2$ norm)
to be similar to the respective decoder's parameters.
CodeFill{} uses softmax activation function in the output layer
to generate probability distributions
over the vocabulary.
To train the model to predict a sequence of tokens,
$\{v_t\} \subset D, t \in [1, \dots, N]$,
with $D$ as the vocabulary,
and $C$ as the existing code context,
CodeFill{} estimates the following conditional probability distribution, $P$:
\begin{equation}
P(v_0,\dots,v_N|c_0,\dots,c_T) = \prod_{i=1}^{N}{P(v_i | c_0, \dots,c_T,v_0,\dots,v_{i-1})}.
\label{eq:prob}
\end{equation}
We use a standard language modeling objective,
predicting the next token given a context,
and maximize the following likelihood
based on our unsupervised corpus of tokens.
In Equation~\ref{eq:log_statement},
$m$ is the length of the predicted sequence of code token values
and $\theta$ is the set of parameters
that is learned through
stochastic gradient descent optimization to model $P$~\cite{robbins1951stochastic}.
\begin{equation}
L(V) = \sum_{i}{\log{P(v_i | c_0,...,c_T,v_{i-m},...,v_{i-1};\theta)}}.
\label{eq:log_statement}
\end{equation}
In each layer, multi-attention heads are used
to aggregate the output of the previous layer
for each transformer block.
Multi-headed self-attention is applied over the
input context tokens followed by position-wise feed-forward layers
to produce the output distribution.
\begin{equation}
h_0 = C W_e + W_p,
\label{eq:attention1}
\end{equation}
\begin{equation}
h_l = transformer\_block(h_{l-1}), l \in [1, \dots, L],
\label{eq:attention2}
\end{equation}
\begin{equation}
P(v_t) = softmax(h_L W_e^T), t \in [ 0,\dots,N]
\label{eq:attention3}
\end{equation}
where $C$ is the context vector of tokens,
$L$ is the number of layers,
$W_e$ is the token embedding matrix,
and $W_p$ is the position embedding matrix.
For training with MTL,
CodeFill{} uses the alternative training strategy,
which aims to prevent catastrophic forgetting
(as opposed to the sequential strategy).
With a probability of
20\%, 40\%, and 40\% for each of the
TTP, TVP,
and SC tasks, respectively,
CodeFill{} picks a random task for each epoch.
TTP requires fewer epochs
as its vocabulary is fairly limited.
Further on, for TVP and SC tasks,
CodeFill{} uses beam search
to identify the most likely (sub-)token sequences.
Loss is shared among all tasks.
During pre-training, the parameters are tuned
to minimize the absolute minimum of the cross entropy losses
among the three pre-training
tasks, namely, TVP, TTP, and SC (Equation~\ref{eq:shared_loss}).
When fine-tuning, only TVP and SC losses are used.
\begin{equation}
Loss_{final} = \mid\min({Loss_{TVP}, Loss_{TTP}, Loss_{SC}})\mid
\label{eq:shared_loss}
\end{equation}
\subsubsection{Token Value Prediction Task (TVP)}
CodeFill{} uses different representations of programs for each task
within the soft-parameter sharing MTL framework.
CodeFill{} treats the TVP task as masked unidirectional prediction;
left-side context is used to predict the next token.
The inputs to the task are sequences of token values,
represented as real-valued vectors of $[v_1, v_2, \dots, v_n]$.
\subsubsection{Token Type Prediction Task (TTP)}
Similarly to TVP, TTP is also treated as left-to-right
masked unidirectional prediction.
The input are corresponding token type representations
as real-valued vector of $ [t_1, t_2, \dots, t_n]$
As both the TTP and TVP models are trained jointly,
CodeFill{} is capable of exploiting token types
when the ultimate goal is to predicting token values.
\subsubsection{Statement Completion Task (SC)}
As useful as next-token prediction may be,
developers can also benefit from
getting longer suggestions to complete code statements~\cite{svyatkovskiy2020intellicode,aye2020sequence,nguyen2019combining}.
Correspondingly, CodeFill{} can also benefit
from training to predict longer sequences,
as training will enable it to better prioritize context use.
Thus, we add a third task
to train CodeFill{} to provide completion suggestions
up and until the end of a statement.
To predict a whole statement
given the existing code context $C$,
and the vocabulary $D$,
CodeFill{} attempts to generate token values
$\{v_t\} \subset D$,
conditioned on the sequence of preceding token values
$\{c_t\} \subset D$,
For this task, the pre-processing steps introduce a special token ($\langle EOS \rangle$)
to demarcate the end of a statement.
CodeFill{} is trained to
keep predicting sequences of token names
until it produces an $\langle EOS \rangle$ token.
\subsubsection{Beam search}
CodeFill{} uses greedy (beam) search to identify the most probable sequences
given a sequence of probabilistic predictions.
Specifically, $ |B| $ (width of the beam) top probabilities,
are recorded partially for every step.
This heuristic algorithm does not necessarily optimize results;
however, its computational complexity equals to $ O(|B| \times |V|) $
which is much faster than computing all cases.
As $ |B| $ increases, the quality of generated summaries improves,
however, the learning time increases as well.
We experimented with several beam values (3, 5, and 10),
and settled to $5$, as it provided a good balance of accuracy and speed.
\subsection{Post-processing}\label{sec:appraoch_post}
\paragraph{Re-ranking Recommendations}
For a recommendation system to be useful,
predictions should be ranked similarly to user expectations.
To optimize ranking,
CodeFill{} includes a post-processing layer to re-rank the leaf nodes in the final
recommendation list based on the visible scope
(i.e., the current file).
This is based on the observation that most completions should be local to the edited file,
as naming visibility rules should force names to cluster.
To re-rank the suggestions,
CodeFill{} hierarchically divides the visible scope
to file, class, and closest function.
The intuition here is,
when the model is predicting the next token
and its type is expected to be a variable name,
candidates in the closest scope
have a higher probability of being correct.
However, when the next token
is predicted to be a function name,
candidates from the same class
(functions defined in the same class)
should be probably at the top of the list.
The re-ranking process consists of
multiplying the prediction probabilities of the top-10 predictions
with a corresponding weight coefficient.
The weights are selected based on
the type of the predicted token
and the scope of the declaration of the identifier.
Each prediction consists of a
\texttt{<token, type, probability>} triplet
with respect to the prediction point
that it is made available,
We generate the list of all visible names
and their hierarchical scope (function, class, file).
Each prediction is then cross-checked with this list,
in the case where the predicted identifier
is indeed already declared in the file (and thus in the list),
its prediction probability is multiplied by a weight
depending on the type of the predicted token
and the scope associated with the item in the list.
As the weights impact the quality of predictions,
we first defined a range/ratio
for different categories based on our programming intuition.
Then, we experimented with this range
and selected the best performing weights.
Table~\ref{tab:reranking-weights} presents
the weights used in this process.
Although the current weights
improve the predictions,
this only sets the minimum bar.
Future work can exploit automatic learning of these weights.
\begin{table}[tb!]
\caption{Weights in the post-processing layer for re-ranking}
\begin{small}
\centering
\begin{tabular}{cccc}
\toprule
Leaf node type & Function & Class & File \\
\midrule
Attribute Access & 1.625 & 1.250 & 1.125 \\
Variable names & 1.625 & 1.125 & 1.500 \\
Function names & 1.125 & 1.625 & 1.500 \\
\bottomrule
\label{tab:reranking-weights}
\end{tabular}
\end{small}
\end{table}
\begin{algorithm}[tb!]
\caption{Re-ranking final recommendations}
\label{alg:reranking}
\begin{algorithmic}[1]
\State \textbf{input} Predictions, WeightsList
\State \textbf{output} Predictions \Comment{List of updated predictions}
\State Names $\gets$ getSignificantNames() \Comment{Get the list of important names in left context from the file}
\State \textbf{for} pred \textbf{in} Predictions \textbf{do}
\State \hskip1em \textbf{while} \textit{true} \textbf{do}
\State \hskip2em Names $\gets$ getSignificantName.pop()
\State \hskip2em \textbf{if} significantName.token = prediction.token \textbf{then}
\State \hskip3em typeCategory $\gets$ getTypeCategory()
\State \hskip3em weight $\gets$ weights[typeCategory][scope]
\State \hskip3em pred.probability $\gets$ pred.probability $\times$ weight
\State \hskip3em \textbf{break}
\State \hskip2em \textbf{end if}
\State \hskip1em \textbf{end while}
\State \textbf{end for}
\end{algorithmic}
\end{algorithm}
\section{Experimental Setup}\label{sec:experiments}
To train and evaluate CodeFill{},
we use two Python datasets.
We evaluate the models based on different evaluation scenarios,
to achieve a more realistic and comprehensive outlook
on the performance of code completion models
to benefit developers in real-world cases.
\subsection{Evaluation Tasks}\label{sec:eval_tasks}
We evaluate CodeFill{} on two tasks, namely
\textit{Token-Level} and \textit{Statement-Level} Predictions (TLP and SLP).
\subsubsection{Token-Level Prediction}
We use TLP to assess the ability of the model
to predict a single next token. We split this part of the evaluation
into four subtasks presented below.
\paragraph{Any token prediction} Our first sub-task is to evaluate the predictions
of any token irrespective of its type (TLP-A).
This is the baseline evaluation task employed in the literature,
but as research has shown~\cite{hellendoorn2019code},
it is not representative of
real-world autocompletion use. For this reason, we resort to more detailed
evaluations, as presented below.
\paragraph{Token Type Prediction} To assess the model's ability to learn grammatical sequences,
we evaluate how well a model can predict a correct AST token given
a context (TLP-B).
We group together AST tokens in the following categories:
\textit{Identifiers},
\textit{Keywords},
\textit{Operators},
\textit{Punctuation},
and finally numerals and string \textit{Literals}.
\paragraph{Leaf Node Prediction} Inspired by the evaluation setup of the state-of-the-art study by Kim et al.~\cite{kim2020code},
we investigate the ability of models when predicting AST leaf nodes (TLP-C),
including
\textit{Attribute access},
\textit{Names},
\textit{Function parameters},
and \textit{Constants}.
\paragraph{Cardinal Point Prediction}
The three tasks presented up to now give a comprehensive view
of the prediction ability of a model.
However, in practical settings, autocompletion is only triggered
at specific points
(e.g., after a dot,
or after specific keywords such as \texttt{for})
while the developer is editing source code.
To ensure that predictions translate to practical benefits
for the developers,
we evaluate completions on cardinal points (TLP-D).
To obtain a list of keywords
after which autocompletion is likely to be triggered,
we first select the list of
punctuation and keywords tokens that can be completed.
We then compute the frequency of
all bi-grams with any of these tokens as their first token
in our dataset.
Then, we remove three sets of bi-grams;
(1) those that are mostly written together
with occurrence frequency above $95\%$ (e.g., \texttt{async def}),
(2) those that are normally not predictable (e.g., \texttt{class NAME} or \texttt{def FUNCTION-NAME}),
and finally (3) those that are usually not practical completions (e.g., \texttt{TRUE :}).
The resulting list of tokens
after which it is most beneficial for autocompletion to be triggered
is as follows.
\vspace{1em}
\noindent\fbox{
\parbox{0.47\textwidth}{
DOT, AWAIT, ASSERT, RAISE, DEL, LAMBDA, YIELD, RETURN,
EXCEPT, WHILE, FOR, IF, ELIF, ELSE, GLOBAL, IN, AND,
NOT, OR, IS, BINOP, WITH, ;, ,, [, (, \{, \textasciitilde
}
}
\paragraph{Evaluation Metrics}\label{sec:TLP_metrics}
As the model only predicts a single token in the TLP task,
we include two evaluation metrics, namely
the \textit{Accuracy} of the top prediction
and the Mean Reciprocal Rank (\textit{MRR})
for the top-10 recommendations.
\textbf{Accuracy}
measures the proportion of samples
for which the suggested completion token exactly matches the single target label.
\textbf{MRR}
assesses the whole top $N$ recommended completions
and takes into account the first position
the target is matched~\cite{radev2002evaluating}.
For a single query, the reciprocal rank is
$\frac{1}{rank}$
where $rank$ is the position of the highest-ranked answer
$(1, 2, 3, ..., N$ for $N$ answers).
If no correct answer exists in top-$N$,
then the reciprocal rank is $0$.
For multiple queries $Q$,
the MRR is the mean of the $Q$ reciprocal ranks.
\subsubsection{Statement Level Prediction (SLP)}
The SLP task
assesses a model's ability to complete
statements with up to $n$ tokens.
The boxplot in
Figure~\ref{fig:stats_tokens_completion}
shows the distribution of number of tokens
for completions
in the evaluation dataset ($PY117K$).
In our datasets,
statements are $4.2$ tokens long on average (median: $4$, maximum: $13$).
To provide a comprehensive view,
we evaluate the performance of the models
when predicting next-$n$ tokens with $n \in [2,3,\ldots, 8]$.
\begin{figure}[tb!]
\centerline{\includegraphics[width=0.6\linewidth]{images/boxplots_eth.pdf}}
\caption{Length of statements in the PY117K dataset}
\label{fig:stats_tokens_completion}
\end{figure}
\paragraph{Evaluation Metrics:}\label{sec:SLP_metrics}
On absence of code-specific metrics,
we use two metrics commonly-used for automatic evaluation of
text generation,
namely Metric for Evaluation of Translation with Explicit ORdering (METEOR)~\cite{lavie2004significance}
and Recall-Oriented Understudy for Gisting Evaluation (ROUGE-L)~\cite{lin2004rouge}.
\textbf{ROUGE}:
ROUGE-N refers to overlapping n-grams.
ROUGE-L, one of the variations of the ROUGE metric,
counts longest matching sequence of words
using the Longest Common Subsequence algorithm.
It considers sentence-level structure similarity
and automatically identifies the longest co-occurring chain
of in sequence n-grams.
Thus, it does not require consecutive matches
but in-sequence matches that reflect sentence-level word order.
\textbf{METEOR}
is based on the term-to-term mapping of the generated code
with its corresponding reference code.
It focuses mainly on recall.
Lavie et al.~\cite{lavie2004significance} showed
metrics based on recall consistently achieve
higher correlation with user preferences
than those based on precision alone.
\subsection{Datasets}\label{sec:datasets}
We use two Python datasets for training and evaluation:
\begin{itemize}
\item The ETH $150$K Python dataset~\cite{raychev2016probabilistic}
for compatibility with previous work.
The authors collected Python programs from GitHub repositories
and removed duplicate files, project forks, files that do not parse and have more
than $30$K nodes in their ASTs.
They also removed obfuscated files
and only used repositories with permissive licenses
including MIT, BSD, and Apache.
\item The CodeFill{} dataset, which was collected
by querying GHTorrent~\cite{gousios2012ghtorrent} for all non-forked Python
repositories with more than $20$ stars ($58$k repositories).
\end{itemize}
After deduplication, using the method
proposed by Allamanis~\cite{allamanis2019adverse},
we ended up with two versions of the original datasets, $PY117K$ and $PY1690K$
for the ETH and CodeFill{} datasets, respectively.
Note that $PY1690K$ and $PY117K$ do not have any common files.
Table~\ref{tab:dataset_info}
presents an overview of the contents of the datasets.
We use $PY1690K$ exclusively for pre-training our LM.
We then use $90\%$ of $PY117K$
for fine-tuning the model on the tasks presented in Section~\ref{sec:eval_tasks},
and finally the last $10\%$ of $PY117K$ for evaluation.
For the baselines,
we concatenate $PY1690K$
with the same $90\%$ portion of $PY117K$ as above for training,
and evaluate on the remaining $10\%$ of $PY117K$.
\begin{table}[tb!]
\caption{Datasets used for training and evaluation}
\centering
\begin{tabular}{ccc}
\toprule
& PY1690K & PY117K\\\midrule
\#Repositories & $32.7$K & $24.9$K \\
\#Files & $1.7$M & $117$K \\
\#LOC & $425$M & $29$M \\
\#Tokens (unique) & $5.7$M & $766$K \\
\#Types (unique) & $103$ & $103$ \\
\bottomrule
\label{tab:dataset_info}
\end{tabular}
\end{table}
\subsection{Implementation and Configuration}\label{sec:config}
We use Python's AST~\footnote{\url{https://docs.python.org/3/library/ast.html}},
Tokenize~\footnote{\url{https://docs.python.org/3/library/tokenize.html}},
and the
DIS~\footnote{\url{https://docs.python.org/3/library/dis.html}}
libraries in our conversion tool.
Moreover, we use the \textit{HuggingFace}~\footnote{https://huggingface.co}
library for the implementation of our GPT-2 and MTL models.
We set the learning rate to $0.00001$,
maximum sequence length to $2048$,
and trained our model for $100$ epochs.
We set the remaining parameters to default values.
Our experiments are conducted on a machine
equipped with two GeForce GTX 1080 Ti GPUs,
an Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz CPU
with $14$ core processors, and $128$G RAM.
\section{Results and Discussion}\label{sec:results}
In this section, we present the results for each evaluation task,
along with an ablation study and a characterization of the models'
performance.
\subsection{Token-level Prediction (TLP)}
\subsubsection{Any token prediction}
The most basic form of evaluation for an autocompletion model
is to gauge its ability
to predict the next token given some context as input.
TLP-A can provide an overview
on the ability of an autocompleter to predict,
however, it does not account for
the prior probabilities of different types
of tokens. We present this task for compatibility
with existing work, and further elaborate CodeFill{}'s performance
in the following tasks.
The results can be seen in Table~\ref{tab:results_TPL_A};
our model outperforms all the baselines
across all metrics.
\begin{table}
\caption{TPL-A results: Any token prediction}
\centering
\begin{small}
\begin{tabular}{cccc}
\toprule
Approach & Venue & {Accuracy} & {MRR} \\
\midrule
n-gram + LSTM~\cite{hellendoorn2017deep} & (FSE, 2017) & 65.1 & 67.9 \\
Pointer Mixture~\cite{li2017code} & (IJCAI, 2018) & 65.8 & 70.0 \\
OpenVocab~\cite{karampatsis2020big} & (ICSE, 2020) & 67.2 & 69.8 \\
T-XL + Bi-LSTM~\cite{liu2020self} & (ICPC, 2020) & 75.0 & 76.4 \\
GPT-C~\cite{svyatkovskiy2020intellicode} & (FSE, 2020) & 79.8 & 80.0 \\
TravTrans+~\cite{kim2020code}& (ICSE, 2021) & 78.9 & 79.4 \\\midrule
CodeFill{} & Proposed & \textbf{80.6} & \textbf{81.7} \\
\bottomrule
\label{tab:results_TPL_A}
\end{tabular}
\end{small}
\end{table}
\subsubsection{Token Type Prediction}
We investigate the performance of the models
when predicting different types of tokens, i.e., their
ability to assimilate how developers use grammar to express concepts.
Models generally struggle more with specific token types.
For instance, it is known that predicting identifiers
is harder than predicting keywords~\cite{hellendoorn2019code}.
Table~\ref{tab:results_TPL_B}
present the Accuracy and MRR results based on all token types.
As demonstrated, CodeFill{} outperforms the baselines
for all token types based on both metrics (except for MRR on keywords
and punctuation, where its performance is on par).
Transformer-based approaches are highly capable of
predicting specific types of tokens, namely keywords and punctuation;
effectively, this means that given enough training examples, they
can efficiently learn syntactical patterns.
Predicting identifiers and literals across all models is more challenging.
For identifiers, all models' result
range from $37\%$ to $56\%$ accuracy.
In both cases, CodeFill{} maintains a non-trivial edge over the baselines,
which we attribute to the statement completion task. We believe it helps
CodeFill{} to learn syntactical patterns over longer ranges.
\begin{table}
\caption{TPL-B Results: Token type predictions}
\centering
\begin{small}
\begin{tabular}{cccccccc}
\toprule
\rotatebox{90}{Metric} & Approach
& \rotatebox{90}{Identifier} & \rotatebox{90}{Keyword}
& \rotatebox{90}{Punctuation} & \rotatebox{90}{Literals}
& \rotatebox{90}{Operators} & \rotatebox{90}{All} \\
\midrule
& Token Percentage & 21\% & 28\% & 33\% & 5\% & 13\% & - \\\midrule
\multirow{7}{*}{\rotatebox{90}{Accuracy}}
& N-gram+LSTM~\cite{hellendoorn2017deep}
& 40.2 & 74.2 & 81.4 & 46.2 & 62.7 & 66.6 \\
& Pointer Mixture~\cite{li2017code}
& 37.0 & 85.3 & 80.0 & 43.9 & 62.8 & 68.4\\
& OpenVocab~\cite{karampatsis2020big}
& 42.3 & 89.8 & 93.4 & 54.4 & 65.0 & 76.0\\
& T-XL + Bi-LSTM~\cite{liu2020self}
& 47.4 & 93.1 & 92.4 & 59.4 & 68.7 & 78.4\\
& GPT-C~\cite{svyatkovskiy2020intellicode}
& 50.0 & 96.5 & 95.1 & 62.0 & 71.0 & 81.2\\
& TravTrans+~\cite{kim2020code}
& 51.1 & 95.9 & 97.0 & 59.3 & 71.3 & 81.8 \\
\cmidrule{2-8}
& CodeFill{}
& \textbf{54.4} & \textbf{97.3} & \textbf{98.0} & \textbf{65.8} & \textbf{71.4} & \textbf{83.8} \\
\midrule
\multirow{7}{*}{\rotatebox{90}{MRR}}
& N-gram+LSTM~\cite{hellendoorn2017deep}
& 40.6 & 76.8 & 84.6 & 49.8 & 64.2 & 68.8\\
& Pointer Mixture~\cite{li2017code}
& 38.5 & 85.9 & 85.2 & 46.7 & 64.5 & 71.0 \\
& OpenVocab~\cite{karampatsis2020big}
& 43.2 & 90.3 & 96.0 & 57.0 & 67.1 & 77.6\\
& T-XL + Bi-LSTM~\cite{liu2020self}
& 49.8 & 96.1 & 96.6 & 61.3 & 70.0 & 81.4\\
& GPT-C~\cite{svyatkovskiy2020intellicode}
& 52.3 & {\bfseries 98.8} & {\bfseries 98.8} & 64.0 & 73.3 & 83.9\\
& TravTrans+~\cite{kim2020code}
& 53.7 & 97.1 & 98.6 & 62.2 & 73.0 & 83.6 \\
\cmidrule{2-8}
& CodeFill{}
& \textbf{56.0} & 98.1 & 98.0 & \textbf{66.1} & \textbf{74.4} & \textbf{87.2} \\
\bottomrule
\label{tab:results_TPL_B}
\end{tabular}
\end{small}
\vspace{-3mm}
\end{table}
\subsubsection{Leaf Node Prediction}
We compare each model's performance
in predicting different types of \textit{leaf nodes} in an AST,
e.g., function calls, variables, and attribute names.
Tables~\ref{tab:results_TLP_C}
present the Accuracy and MRR results for this task.
CodeFill{} is the best model in both accuracy, and, especially, MRR.
This means that its name predictions, which is arguably the most important
feature for an autocompleter,
are 2 out of 3 times correct and have a high
probability ($> 70\%$) of being included in the top suggestions.
\begin{table}
\caption{TLP-C results: Leaf node prediction}
\centering
\begin{small}
\begin{tabular}{ccccccc}
\toprule
\rotatebox{90}{Metric} & Approach
& \rotatebox{90}{\parbox{1cm}{Attribute\\Access}}
& \rotatebox{90}{Names}
& \rotatebox{90}{\parbox{1cm}{Function\\names}}
& \rotatebox{90}{\parbox{1cm}{Numeric\\constant}}
& \rotatebox{90}{All}\\
\midrule
& Token Percentage & 32\% & 13\% & 33\% & 22\% & \\\midrule
\multirow{7}{*}{\rotatebox{90}{Accuracy}}
& N-gram + LSTM~\cite{hellendoorn2017deep}& 56.3 & 61.8 & 63.5 & 45.1 & 56.9\\
& Pointer Mixture~\cite{li2017code} & 53.5 & 62.0 & 59.8 & 42.0 & 54.2 \\
& OpenVocab~\cite{karampatsis2020big} & 59.8 & 63.7 & 66.2 & 51.7 & 60.6 \\
& T-XL + Bi-LSTM~\cite{liu2020self} & 59.9 & 58.1 & 62.8 & 54.8 & 59.5 \\
& GPT-C~\cite{svyatkovskiy2020intellicode}& 60.0 & 59.9 & 64.0 & {\bfseries 56.0} & 60.4 \\
& TravTrans+~\cite{kim2020code} & 60.2 & 65.4 & 68.3 & 52.7 & 61.7 \\
\cmidrule{2-7}
& CodeFill{} & \textbf{64.0} & \textbf{67.3} & \textbf{72.2} & 53.1 & \textbf{66.3} \\
\midrule
\multirow{7}{*}{\rotatebox{90}{MRR}}
& N-gram + LSTM~\cite{hellendoorn2017deep}& 57.9 & 64.7 & 65.2 & 47.5 & 58.9\\
& Pointer Mixture~\cite{li2017code} & 57.1 & 59.0 & 60.2 & 43.1 & 55.3 \\
& OpenVocab~\cite{karampatsis2020big} & 61.2 & 64.8 & 70.1 & 51.7 & 62.5 \\
& T-XL + Bi-LSTM~\cite{liu2020self} & 61.9 & 65.3 & 69.9 & 55.3 & 63.5 \\
& GPT-C~\cite{svyatkovskiy2020intellicode}& 63.4 & 62.9 & 66.5 & \textbf{57.2} & 63.0 \\
& TravTrans+~\cite{kim2020code} & 62.8 & 65.4 & 70.0 & 55.2 & 63.8 \\
\cmidrule{2-7}
& CodeFill{} & \textbf{72.0} & \textbf{69.7} & \textbf{76.9} & 56.0 & \textbf{69.5} \\
\bottomrule
\label{tab:results_TLP_C}
\end{tabular}
\end{small}
\end{table}
\subsubsection{Cardinal Point Completion}\label{sec:cardinal-completion}
In Table~\ref{tab:results_TPL_D}, we report the performance of models
when predicting at cardinal points
(described in Section~\ref{sec:eval_tasks}).
As indicated,
CodeFill{} outperforms all the baselines.
Consequently, it is more capable of presenting correct recommendations
at points where autocompletion is more likely to be triggered.
\begin{table}
\caption{TPL-D Results: Cardinal Points Completion}
\begin{small}
\centering
\begin{tabular}{ccc}
\toprule
Approach & {Accuracy} & {MRR} \\
\midrule
N-gram + LSTM~\cite{hellendoorn2017deep}
& 49.0 & 52.3 \\
Pointer Mixture~\cite{li2017code}
& 51.3 & 52.4 \\
OpenVocab~\cite{karampatsis2020big}
& 52.2 & 53.5 \\
T-XL + Bi-LSTM~\cite{liu2020self}
& 64.0 & 64.7 \\
GPT-C~\cite{svyatkovskiy2020intellicode}
& 66.1 & 67.8 \\
TravTrans+~\cite{kim2020code}
& 65.0 & 66.2 \\\midrule
CodeFill{}
& \textbf{70.0} & \textbf{70.9} \\
\bottomrule
\label{tab:results_TPL_D}
\end{tabular}
\end{small}
\end{table}
\subsection{Statement-Level Prediction (SLP)}
We report the results for autocompleting code statements,
by predicting the remaining $n$ tokens at a given statement position
(with $n$ ranging between $2$ and $8$).
Figure~\ref{fig:statement}
presents the results of this experiment
based on the achieved METEOR and ROUGE-L scores.
All Transformer-based models~\cite{liu2020self,svyatkovskiy2020intellicode,kim2020code},
are consistently more capable than the three baseline approaches.
CodeFill{} improves over
all competitors.
The margin grows wider
as the number of tokens required
to complete statements increase
(especially in the ROUGE-L case).
This result highlights the merits of our statement completion task.
In turn, this can help developers code faster
by reducing the number of required keystrokes;
the experience of using statement completion should be reminiscent
of text line completion in popular
online email or document editors.
Statistically, \emph{more than 2 out of 3 statement completions of 4 or fewer tokens will be correct.}
\begin{figure*}
\centering
\subfigure
{\includegraphics[width=0.4\linewidth]{images/eth_meteor.pdf}}
\subfigure
{\includegraphics[width=0.4\linewidth]{images/eth_roughe_l.pdf}}
\caption{Results for the SLP task}
\label{fig:statement}
\end{figure*}
\subsection{Ablation Study}
We perform an ablation study to examine the impact
of different components of CodeFill{} .
Table~\ref{tab:results_ablation}
presents the results of this study.
We include the performance of a vanilla GPT-2 model
to show the importance of employing the MTL approach
to jointly train models on different representations of source code.
The results show that employing the MTL technique to
train the models jointly on multiple tasks
indeed helps the model learn better.
Next, we conduct experiments to compare
hard-parameter and soft-parameter models with the two-task MTL model.
It is worth mentioning
that for the hard-parameter sharing variation,
we need to input a unified representation to the models.
Thus, we concatenate the type and value of each token
as $x_i = [t_i, v_i]$
and then feed the vectors of this concatenated representation to the MTL model.
The results indicate that
the soft-parameter sharing works better in our case.
This is probably because this setting
allows each task to have its own model and parameters
and then regularizes the distance between them
to encourage the parameters to be similar.
Finally, to verify whether adding information regarding statements helps,
we investigate the effect of adding the third task,
\textit{statement completion}.
The results demonstrate that training
on two different granularity (single-token and statement)
also helps them learn better.
To conclude,
each component of the proposed model adds to its value.
Although the training time increases,
it can be argued that training time is a one-time cost,
and can be significantly reduced with parallel training on
multiple GPUs.
\begin{table}
\caption{Effectiveness of Different Components of the Model}
\centering
\begin{small}
\begin{tabular}{cccccc}
\toprule
Approach & Tasks & Train Time & Accuracy & MRR\\
\midrule
GPT-2 & Value & 12h & 77.7 & 78.2\\
MTL HP & Value, Type & 17h & 78.3 & 79.6\\
MTL SP & Value, Type & 19h & 78.9 & 79.5\\\midrule
MTL SP & Value, Type, Statement & 24h & \textbf{80.6} & \textbf{81.7} \\
\bottomrule
\label{tab:results_ablation}
\end{tabular}
\end{small}
\end{table}
\subsection{Runtime Characteristics}
An important aspect of ML-based autocompletion tools is
their prediction latency. A very accurate model that takes
$1$ second per prediction will not be very useful in practice
as it will interfere with the developer's workflow.
As Table~\ref{tab:complexity}, all models feature an average
latency of less than $100$ milliseconds, which is considered
the golden standard in the industry.
Moreover, the model size and number of parameters
are important practical aspects
that affect a model's deployment; if the model is too big,
it will need to be deployed centrally and clients should
connect to the model server over a network connection (which
may affect latency negatively), otherwise, it could be distributed
to the clients.
As Table~\ref{tab:complexity} shows,
CodeFill{}'s number of parameters is more than other baselines
due to our architecture specification.
However, the size of all Transformer-based models
makes them impractical
for distribution to clients,
necessitating centralized deployments.
\begin{table}
\caption{Runtime Characteristics}
\centering
\begin{tabular}{cccc}
\toprule
Approach & \parbox{2cm}{Train Time (hr)} & \parbox{1.7cm}{Latency (ms)} & \#Params\\
\midrule
n-gram + LSTM~\cite{hellendoorn2017deep} & 23 & 75 & 168M\\
Pointer Mixture~\cite{li2017code} & 18 & 62 & 177M\\
OpenVocab~\cite{karampatsis2020big} & 21 & 61 & 145M\\
T-XL + Bi-LSTM~\cite{liu2020self} & 24 & 79 & 173M\\
GPT-C~\cite{svyatkovskiy2020intellicode} & 23 & 74 & 125M\\
TravTrans+~\cite{kim2020code} & 15 & 53 & 119M \\
\midrule
CodeFill{} & 24 & 73 & 258M\\
\bottomrule
\label{tab:complexity}
\end{tabular}
\end{table}
\section{Contributions and Implications}
Autocompletion is a popular research area,
however, the existing challenges
leave substantial margin for improvement,
particularly for recommending identifiers
or completing longer sequences~\mbox{\cite{hellendoorn2019code}}.
In this study, CodeFill{} learns from sequences of
both token types and token names simultaneously using MTL.
The contribution of this work is twofold;
\textbf{\textit{Technical novelty}}:
Similar to the
state-of-the-art~\mbox{\cite{kim2020code,svyatkovskiy2020intellicode}},
we use transformers
for learning a name-based sequencing model,
and similar to the studies
by Liu et al.~\mbox{\cite{liu2020self,liu2020multi}},
we use the MTL technique
to condition our models under different tasks.
However, IntelliCodeCompose~\mbox{\cite{svyatkovskiy2020intellicode}}
treats code as natural text,
neglecting the rich structure inherent in programs.
Moreover they focus on multi-lingual LMs.
TravTrans+~\mbox{\cite{kim2020code}} uses serialized ASTs
in an attempt to learn from structure,
however, we show that our novel transformation,
which we designed so that it is closer to
how developers treat source code structure, outperforms TravTrans+.
CodeFill{} also learns from our novel statement completion task
to consider longer contexts.
Both \mbox{\autoref{fig:statement}}
and \mbox{\autoref{tab:results_ablation}}
show that this technique improves the model,
probably by helping it better utilize completion context.
The combination of the above demonstrably
results in higher evaluation scores and better recommendations.
\textbf{\textit{Evaluation}}:
We propose two novel evaluation tasks,
\textit{cardinal point}, and \textit{statement completion},
to address deficiencies in current autocompletion evaluation setups.
We also collect, pre-process, deduplicate,
and share an large Python dataset,
consisting of practically all Python code on GitHub.
\section{Threats to the Validity}\label{sec:threats}
\textbf{Threats to internal validity}:
These include the threats
pertaining to the parameters affecting the performance of the model.
Another threat in this section relates to the errors in
the implementation of the baselines.
For all of these approaches,
we have used the replication packages provided by these studies.
\textbf{Threats to external validity}:
These threats relate to the quality of the datasets
we used and the generalizability of the results.
We used two Python datasets;
PY117K is a benchmark dataset ~\cite{raychev2016probabilistic}
frequently used in the
literature~\cite{li2017code,liu2020self,karampatsis2020big,kim2020code}.
PY1690K, our second dataset, is ten times larger
with approximately $1.7M$ program files.
More data can lead to more generalizable results.
Furthermore, as Allamanis.~\cite{allamanis2019adverse} suggests,
we have de-duplicated both datasets to avoid biasing the models.
All of the programs in both datasets are collected from
open-source GitHub repositories.
However, further studies are
needed to validate and generalize our findings
to other programming
languages.
\textbf{Threats to construct validity}:
These relate to the suitability of the evaluation setting and metrics.
In this work, we have tried to incorporate diverse evaluation measures.
For the TLP task,
we have used standard evaluation metrics,
namely Accuracy and MRR
in the top-one and top-ten recommendations
which are both frequently used in the literature~\cite{li2017code,liu2020self,karampatsis2020big,kim2020code}.
Furthermore, we use ROUGE-L and METEOR scores for evaluation
in the SLP task as used in previous studies
on source sequence of code generation, summarization, and translation~\cite{svyatkovskiy2020intellicode,aghamohammadi2020generating}.
\section{Conclusion and Future Work}\label{sec:conclusion}
Unlike natural language text, source code is more structured,
its grammar is more well defined but its vocabulary is orders
of magnitude bigger.
Consequently, NLP-based models and corresponding evaluation methods
need to be adapted to the particular case of source code.
In this work, we proposed CodeFill{},
a Transformer-based generative LM for source code
pre-trained on three tasks closely relevant to programming.
Given a context of tokens (and their types),
CodeFill{} is trained to predict
(1) the type of the next token,
(2) its value,
and (3) the values of up to $n$ next tokens.
We employ the MTL approach
to jointly train CodeFill{} on the above tasks.
We also propose 2 novel evaluation tasks,
cardinal point prediction and statement-level multi-token prediction,
which we argue that they better represent how autocompletion systems
are used in practice.
We extensively evaluate CodeFill{}
against six baselines on both tasks.
Our results indicate that CodeFill{} outperforms
all the baselines in all scenarios,
achieving state of the art scores on both accuracy (80.6\%)
and MRR (81.7\%) in the basic token-level prediction task.
Moreover, we show that CodeFill{} also learns to autocomplete statements
of up to 4 tokens with over 70\% accuracy,
a significant improvement over the baselines,
making it practical to offer statement completions as an IDE feature.
In the future, we plan to incorporate more domain specific
knowledge on aspects of training and evaluating a
training ML models.
For instance, one can limit the context fed to the model
based on the programming language
to better incorporate related information of functions
and nested scopes in a piece of code.
We also plan to further investigate statement completion,
including better metrics for its evaluation.
\begin{acks}
This work has received funding from
the European Union’s Horizon 2020 research and innovation programme
under grant number 825328 (FASTEN project),
and also the NWO MIPL project,
grant number 628.008.003.
\end{acks}
\bibliographystyle{ACM-Reference-Format}
|
{'timestamp': '2022-02-15T02:44:04', 'yymm': '2202', 'arxiv_id': '2202.06689', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06689'}
|
arxiv
|
\section{Introduction}
The prevailing solution concept in mechanism design is dominant-strategy incentive-compatibility, otherwise known as strategyproofness, which stipulates that for any joint strategy of the other agents, a given agent always weakly prefers to act truthfully than to act dishonestly. The canonical example of such a mechanism is the second-price sealed-bid auction, in which it is always in an agent's best interests to submit her true valuation for the item to the auctioneer. While this is appealing from a theoretical standpoint it relies on the assumption that the players of the game act perfectly rationally, meaning they are able to correctly reason about the behaviour of the other players as well as solve an optimisation problem to identify an optimal strategy. This places a high cognitive or temporal burden on the player and it can be unrealistic to assume this is how they act in the real world.
Empirical evidence in fact shows that people facing mechanisms that are not strategyproof might fail to understand that lying is beneficial. Examples include mechanisms both with and without monetary transfers. The Deferred Acceptance Algorithm, used in many countries to allocate doctors to hospitals, is known to perform well in practice and produce stable outcomes, even though hospitals could lie and hire better candidates \cite{Roth1991}. Uniform-price auctions are a natural generalisation of second-price auctions to the multi-unit case: with a supply of $k$, they charge the winners the $(k+1)$-th highest bid for each unit received. Variants of uniform-price auctions are used by search engines to charge for sponsored ad slots and governments to sell bonds. These auctions are famously not strategyproof and yet there is little evidence that bidders cheat in practice \cite{Kastl2011}. On the other hand, there are manipulable mechanisms where people can easily figure out a way to lie profitably: the Boston Mechanism for school choice is known to be manipulable \cite{Pathak2008} and empirical data shows evidence of misreports \cite{Dur2018}. Similarly, there is evidence of bid shading in pay-as-bid multi-unit auctions \cite{Hortacsu2010}.
Motivated by these observations, Troyan and Morrill~\cite{Troyan2020} study \emph{non-obvious manipulability}, an alternative solution concept to strategyproofness for cognitively limited agents. Under this relaxation of strategyproofness, simply referred to as NOM, a mechanism is allowed to be vulnerable to certain types of manipulations, specifically those which are harder to identify by agents with bounded rationality. Instead of requiring the truthful action for each agent $i$ to be a dominant strategy at each possible interaction of the player with the mechanism, under non-obvious manipulability we need only to compare best-case utilities for truthful outcomes (i.e., maximum, over the reports of the other agents, utility for $i$ when she is truthful) to best-case utilities for dishonest outcomes, \emph{and} similarly to compare worst-case utilities for truthful outcomes to worst-case utilities for dishonest outcomes. This is justified under the assumption that cognitively-limited agents can only identify this type of \emph{obvious} manipulation, where the agents need only to compare the extremes of her utility function.
In this paper we study NOM mechanisms that use monetary transfers. We have a threefold aim: we want to (i) understand which restrictions NOM imposes on the allocation function; (ii) characterise both allocation functions and payments for the large class of single-parameter agents; and, (iii) assess the power of NOM mechanisms for double-sided markets. We focus on the class of direct-revelation mechanisms\footnote{Whether extensive-form NOM mechanisms are more powerful than direct-revelation ones is an open problem.} as in \cite{Troyan2020} and develop both conceptual and technical tools to obtain answers against each of these desiderata.
\subsection{Our Contribution}
In order to understand whether NOM is too permissive a solution concept in terms of allocation functions, we take a careful look at the constraints that NOM somewhat intrinsically imposes. Given an allocation function and payments to augment it, NOM requires that truthtelling yields a greater utility than misreporting for best- and worst-case outcomes. Indirectly, this means that the utility for all the remaining outcomes is in between these best and worst utilities. In other words, the set of incentive-compatibility constraints that one ought to satisfy \emph{depends on the actual payments and allocation function} since they define the maximum and minimum utilities.
This is quite dissimilar from classic strategyproofness where the set of constraints is independent from the components of the mechanism, but somewhat closer to the twin solution concept of obvious strategyproofness (OSP) \cite{Li2017}. Differently from NOM, OSP requires truthtelling to be ``obvious'' over lying. It turns out that the obviousness of being honest is captured by the extensive-form implementation of the mechanism, which in turn implies that the set of OSP incentive-compatibility constraints depends on this component of the mechanism. This dependence for OSP is successfully handled in \cite{Ferraioli2018} via a generalisation of the classical cycle-monotonicity technique for strategyproofness~\cite{Rochet1987}.
As a first contribution of this work, we abstract the NOM dependency in terms of what we call \emph{labellings} and extend the cycle monotonicity technique to NOM. Informally, a labelling is a choice of profiles defining the best and worst outcomes that the mechanism will define through its allocation and payments. Given a labelling, we can identify two sets of constraints: (i) NOM incentive-compatibility constraints between the given labels, and (ii) labelling-induced constraints, that enforce the validity of the labels. Similarly to previous work on cycle monotonicity, we define a weighted graph $G_{i,f}^\lambda$ encoding these constraints for each player $i$, given the allocation function $f$ and labelling $\lambda$. We prove that the existence of payments guaranteeing the constraints is related to the cycles of this graph.
\smallskip
\begin{center}
\begin{minipage}[c]{0.85\textwidth}
\textbf{Theorem 1 (informal).} \textit{An allocation function $f$ is NOM implementable if and only if there exists a labelling $\lambda$ such that no $G_{i,f}^\lambda$ has negative-weight cycles.}
\end{minipage}
\end{center}
This result provides a powerful tool to study the class of allocation functions for which one can find payments leading to NOM mechanisms. As a case in point we apply our cycle monotonicity framework to the well-studied class of single-parameter agents, in which each agent $i$ has a private type that is described by a single number $t_i$. Her utility for the bid profile $(x_i, x_{-i})$ is the sum of the payment she receives from the mechanism and her \emph{valuation} for the output she receives from the allocation function on this bid profile; this valuation can be expressed as the product of $t_i$ and $f_i(x_i,x_{-i})$. We observe that negative weight cycles in the graph exist when the labels are antimonotone, meaning that, given two types $x_i$ and $x_i'$ with $x_i < x_i'$ from the \emph{domain} (also known as type space) of player $i$, $f$ allocates more to agent $i$ for the label corresponding to $x_i$ than it does for the label corresponding to $x_i'$. We then prove that a \emph{monotone labelling} guarantees no negative-weight cycles and is possible whenever the image of $f_i$ is rich enough. Specifically, we say that $f$ is \emph{overlapping} if for each agent $i$ and pair of types $x_i, x_i'$ the sets $\{f_i(x_i, x_{-i})\}_{x_{-i}}$ and $\{f_i(x_i', x_{-i})\}_{x_{-i}}$ have a non-empty intersection.
\smallskip
\begin{center}
\begin{minipage}[c]{0.85\textwidth}
\textbf{Theorem 2 (informal).} \textit{An allocation function $f$ is NOM implementable for single-parameter agents if and only if $f$ is overlapping.}
\end{minipage}
\end{center}
\smallskip
Essentially, our second main contribution proves that as long as the labels define a monotone restriction of the allocation function $f$ then there are payments such that $f$ is part of a NOM mechanism for single-parameter agents. This uncovers a connection with strategyproof mechanisms for single-parameter agents, which allows us to also characterise the payment functions that NOM mechanisms ought to use in this case. For strategyproof mechanisms $f$ must be monotone for each fixed $x_{-i}$, and given this property it is known the form payments must take \cite{ArcherTardos2001}. We then observe that we can use the very same payments along the monotone restriction defined by the labels, whilst we can easily characterise the payments for the remaining profiles.
This result gives a complete picture on the power of NOM mechanisms for single-parameter agents. We then ask if this finding can help assess the power of NOM mechanisms for double-sided markets, where both sides of the market consist of selfish agents. These markets are widespread but are notoriously too complex for strategyproofness. We wonder whether the relaxation from no manipulability at all to non-obvious manipulability can help in this context. We study the classical setting of bilateral trade, in which a single item is to be sold by a (strategic) seller who has a production cost for the item, to a (strategic) buyer who has a valuation for the item. We want to guarantee efficiency -- trade occurs only when the buyer's valuation is at least the seller's production cost --, weak budget balance (WBB) -- upon trade, the buyer pays more than the seller receives -- and, individual rationality (IR) -- the quasi-linear utilities of both buyer and seller are non-negative. We know already that NOM cannot simultaneously guarantee these three properties \cite{Troyan2020}. We here ask the extent to which a subsidy of $\alpha$, guaranteeing that the buyer pays at least a fraction 1/$\alpha$ of the payment that the seller receives upon trade (a.k.a., $\alpha$-WBB), would allow to obtain NOM, efficiency and IR.
\smallskip
\begin{center}
\begin{minipage}[c]{0.85\textwidth}
\textbf{Theorem 3 (informal).} \textit{Any NOM, IR and $\alpha$-WBB mechanism for bilateral trade has unbounded $\alpha$.}
\end{minipage}
\end{center}
\smallskip
The proof of this theorem actually highlights a more fine grained and dichotomous state of affairs. The toolkit developed to prove our first two main theorems can independently handle best-case labels (BNOM) and worst-case labels (WNOM). We use our result for single-parameter agents to characterise the monotone restriction of an allocation function $f$ guaranteeing efficiency and BNOM (WNOM, respectively) for both the buyer and the seller. We prove that the incentive-compatibility constraints for the monotone BNOM restriction immediately yields unbounded $\alpha$ as we can conclude by our explicit payment formula that the buyer pays $0$ for each of her best labels whereas the seller needs to receive a positive payment for all of her best labels. For WNOM, instead we observe that whilst incentive compatibility does not require infinite subsidies, the infinite $\alpha$ is implied by the validity constraints for the worst labels.
We can in fact shed further light on subsidies for BNOM and WNOM, respectively. A technicality about the strategyproofness-inspired explicit payment formulae is crucial here. Once $f$ is overlapping then the monotone restriction of $f$ is only one possible way of guaranteeing BNOM and WNOM; this choice in fact restricts to a \emph{single line} the labels used the mechanisms. Can alternative labels lead to different payments satisfying IR and finite subsidies for an overlapping and efficient $f$? The answer is more surprising; non-single line BNOM mechanisms continue to require infinite subsidies whereas non-single line WNOM mechanisms can actually guarantee WBB (i.e., $\alpha=1$ and no subsidies). There exists in fact a definition of worst labels that implement first-price auctions; it is not hard to see that these auctions are WNOM.
We also show that we can further strengthen the incentive-compatibility property on either side of the market to strategyproofness, e.g., the buyer being strategyproof and the seller being WNOM, by combining first-price auction for one side (seller in the example) and second-price auction for the other (buyer in the example). Interestingly, this hybrid solution would leave the spread (difference between the bids) to the market designer whereas a fully WNOM bilateral trade (where both payments equal the bid) would be budget balanced. We consider this result to be of significance for some classes of double-sided markets, where the rationality is asymmetric and depends on the role played in the market. This asymmetry might be useful to the market designer in terms of gain from trade.
Finally, we conclude our paper by characterising individually rational NOM mechanisms that might be inefficient but require no subsidies. Intuitively, this result says that there exist trading windows defined by payment thresholds that partition the domain of buyer and seller into three sets; bids guaranteeing that the trade occurs, bids guaranteeing that the trade will not occur, and bids where the decision to trade depends on the bid at the other side of the market.
\subsection{Related Work}
There has been a growing body of work in the algorithmic mechanism design literature that studies agents with bounded rationality. The aforementioned notion of obvious strategproofness (OSP) was introduced by Li~\cite{Li2017} to study the setting in which agents lack contingent reasoning skills. Li characterises OSP mechanisms as those in which agents lack the ability to reason contingent upon unobserved events (such as concluding that a truthful bid is optimal in a second-price sealed-bid auction), or those in which a mechanism may not be able to commit to all outcomes. OSP is a more stringent solution concept than strategyproofness and provides stronger incentive guarantees, thus OSP mechanisms are harder to construct than strategyproof ones. Where the Revelation Principle allows us to restrict our attention to direct mechanisms for strategyproofness, the same is not true for OSP: the extensive-form implementation of the mechanism is crucial to a mechanism's obvious strategyproofness. The relationship between the extensive-form implementation and the allocation function of OSP mechanisms is studied in \cite{Ferraioli2018}, where together with the introduction of the cycle monotonicity variant for OSP mechanisms with transfers, the authors give some bounds on the approximation guarantee of these mechanisms for scheduling related machines. Binary allocation problems are then studied in \cite{Ferraioli2019} first for single-parameter agents with small domains and more recently in \cite{Ferraioli2021} for the general case. Further OSP mechanisms using some form of verification power of the mechanism designer are given in \cite{FerraioliV2021,DBLP:conf/ijcai/FerraioliV18,Kyropoulou2019}. OSP mechanisms for combinatorial auctions with single-minded bidders are given in \cite{Keijzer20}. Relaxations of OSP that interpolate between OSP and strategyproofness are studied in \cite{FerraioliSAGT2019}.
Troyan and Morrill~\cite{Troyan2020} consider agents with bounded rationality from the opposite perspective and introduce the concept of non-obvious manipulability (NOM) to study the types of manipulations available to a cognitively limited agent. In contrast to OSP, where the worst-case truthful outcome must be at least as good as the best-case dishonest outcome, NOM stipulates that both the best- and worst-case truthful outcomes are no worse than the best- and worst-case dishonest outcomes, respectively. They provide a characterisation of NOM in the context of direct mechanisms and classify existing mechanisms as either obviously manipulable (OM) or NOM in the settings of school choice, two-sided matching, and auctions. They show, similarly to \cite{Li2017}, that a manipulation is obvious if and only if it can be recognised by a cognitively limited agent. They go on to characterise OM matching mechanisms as ones which are either stable or which Pareto-dominate a stable mechanism, and moreover show that all stable mechanisms are individually rational, Pareto efficient, and NOM. For the case of auctions they show that a generalisation of the second-price single-item auction is NOM, the double auction for bilateral trade is OM, and finally that every efficient, individually rational, and weakly budget balanced mechanism for bilateral trade is OM.
There have been few papers that build directly on \cite{Troyan2020} so far. Aziz and Lam~\cite{Aziz2020} study NOM in the context of voting rules and provide conditions under which certain rules and classes of rules are NOM. They show that certain rules are OM if the number of outcomes is large relative to the number of voters. They also look at how to compute such manipulations and present algorithms based on polynomial-time reductions to the Constructive Coalitional Unweighted Manipulation problem. These yield polynomial-time algorithms for computing obvious manipulations under the $k$-approval voting rule. Ortega and Segal-Halevi~\cite{Ortega2019} study NOM and indirect mechanisms in the context of cake-cutting and show that the conflict between truthtelling and fairness is resolved when relaxing strategyproofness to NOM. They show that NOM is compatible with the notion of proportionality, in which each agent receives an equal portion of the cake, and that both of these properties are satisfied by a discrete adaptation of the moving knife mechanism. Like \cite{Li2017}, they note how incentive properties may vary between theoretically equivalent mechanisms for agents with bounded rationality.
\section{Preliminaries}
We consider mechanism design settings with the possibility of monetary transfers. There is a set of $n$ \emph{agents}, where each agent $i$ has a certain \emph{type} $t_i$ that comes from a type set $D_i$ also called \emph{domain}. We let $D = \times_{i \in [n]} D_i$ be the set of \emph{type profiles}.
There is furthermore a set of possible \emph{outcomes} $O$, and the type of an agent specifies for each outcome to what extent the agent values it. Thus, a type is a function mapping outcomes to real numbers. For a type profile $t = (t_1,t_2,\ldots,t_n)$, player $i$, and type $x_i \in D_i$, we use the standard notation $(x_i,t_{-i})$ to denote the type profile obtained from $t$ by replacing $t_i$ by $x_i$. We furthermore define $D_{-i}$ as $\times_{j \in [n]\setminus\{i\}} D_j$.
The agents interact with a \emph{mechanism} $\mathcal{M}$ that solicits from the agents their types. The mechanism selects, based on the agents' reports, an outcome and a payment for each agent. We may thus view $\mathcal{M}$ as a function mapping $D$ to $O \times \mathbb{R}^n$. Agents are assumed to report so as to maximise their \emph{utility}, and the agents' utility functions are standard quasi-linear ones: for an agent $i$, the output $(o,p)$ of the mechanism results in a utility of $t_i(o) + p_i$. We overload the notation and denote the utility of agent $i$ under $(o,p)$ by $t_i(o,p)$.
A \emph{social choice function} $f : D \to O$ is a function that maps some input $x$ from some domain $D$ to an arbitrary outcome $f(x) \in O$. We say that a mechanism $\mathcal{M}$ \emph{implements} a given social choice function $f$ iff for all $t \in D$, the outcome returned by $\mathcal{M}(t)$ is equal to $f(t)$.
Note that each player $i$'s type $t_i$ is private information and they may therefore submit a misreport $x_i \neq t_i$ to a mechanism in an attempt to gain a more favourable outcome. In this paper we are interested in finding, for a given social choice function $f$, a mechanism $\mathcal{M}$ implementing $f$ such that $\mathcal{M}$ is not obviously manipulable (NOM) by any of the agents; we define this property precisely later in this section. This objective boils down to finding an appropriate payment function $p : D \rightarrow \mathbb{R}^n$ for $\mathcal{M}$ such that $\mathcal{M} = (f,p)$ is a mechanism that satisfies the NOM property.
We will in particular consider the setting where $O$ is a vector of length $n$, and where the type of an agent $i$ is a function that is only dependent on the $i$'th coordinate of the the outcome vector. In this case, we call the outcomes \emph{allocations}, and we refer to the social choice function as an \emph{allocation function}. Restricting the social choice function to an allocation function is clearly without any loss of generality, and is done purely for interpretational purposes, since we mainly focus on auction settings in which the mechanism assigns some object to each agent and an agent's type describes the utility she gets from that allocation.
The prevailing solution concept in mechanism design is that of strategyproofness: a mechanism $\mathcal{M}$ is \emph{strategyproof} iff $t_i(\mathcal{M}(t_i,x_{-i})) \ge t_i(\mathcal{M}(x_i,x_{-i}))$ for all agents $i$, all $x \in D$, and all $t_i \in D_i$. Troyan and Morrill~\cite{Troyan2020} define NOM, which is a relaxation of strategyproofness, informally stated as follows: a manipulation is defined as \emph{obvious} if either the best-case dishonest outcome is strictly greater than the best-case truthful one, or if the worst-case dishonest outcome is strictly greater than the worst-case truthful one. Here, best-case and worst-case are defined with respect to the type profile of all agents excluding $i$. Formally stated, mechanism $\mathcal{M}$ is \emph{best-case non-obviously manipulable (BNOM)} if:
\begin{equation}
\sup_{x_{-i}} \{ t_i(\mathcal{M}(t_i,x_{-i})) \} \ge
\sup_{x_{-i}} \{ t_i(\mathcal{M}(x_i,x_{-i})) \}
\end{equation}
for all $t_i,x_i \in D_i$ and for all players $i$. Similarly $\mathcal{M}$ is \emph{worst-case non-obviously manipulable (WNOM)} if:
\begin{equation}
\inf_{x_{-i}} \{ t_i(\mathcal{M}(t_i,x_{-i})) \} \ge
\inf_{x_{-i}} \{ t_i(\mathcal{M}(x_i,x_{-i})) \}
\end{equation}
Mechanism $\mathcal{M}$ is \emph{non-obviously manipulable (NOM)} if it is both BNOM and WNOM. If either inequality does not hold then $x_i$ is an obvious manipulation of $\mathcal{M}$. We study the conditions under which we may endow an obviously manipulable social choice function $f$ with payments $p$ to achieve a mechanism $(f,p)$ that is non-obviously manipulable. If this is possible then we will call $f$ NOM-implementable, with analogous definitions for BNOM- and WNOM-implementability.
We consider several additional mechanism properties in our analysis. A mechanism $\mathcal{M}=(f,p)$ is \emph{individually rational (IR)} if $t_i(\mathcal{M}(t_i,x_{-i})) \ge 0$ for all $t_i,x_i \in D_i$, $x_{-i} \in D_{-i}$, for each player $i$, and makes \emph{no positive transfers (NPT)} if for all $p_i(x) \le 0$ for all $x \in D$. In \Cref{sec:bilateral-trade} we will also study efficiency and budget-balance in the context of bilateral trade, which we will define when needed.
We will often need to reference specific types from a player $i$'s domain. In this case we will enumerate the types in the domain as $t_1,t_2,\ldots,t_d$, and when we focus on single-parameter agents, we will treat types as scalar multipliers rather than functions, and assume that $t_1 < t_2 < \ldots < t_d$. We conclude this section by noting that NOM is a strict relaxation of strategyproofness.
\begin{theorem}
\label{thm:SP-implies-NOM}
If mechanism $\mathcal{M}$ is strategyproof then it is also NOM.
\end{theorem}
\begin{proof}
We will prove the claim by showing that if $\mathcal{M}$ is strategyproof then it is both BNOM and WNOM, starting with the former. Fix player $i$ with type $t_i$. By strategyproofness we have $t_i(\mathcal{M}(t_i,x_{-i})) \ge t_i(\mathcal{M}(x_i,x_{-i}))$ for all $t_i,x_i \in D_i$ and for all $x_{-i}$. Assume for contradiction that $\mathcal{M}$ is obviously manipulable in the best case, so $\sup_{x_{-i}} \{ t_i(\mathcal{M}(x_i,x_{-i})) \} > \sup_{x_{-i}} \{ t_i(\mathcal{M}(t_i,x_{-i})) \}$ for some manipulation $x_i$. Let $\hat{x}_{-i} \in \arg \sup \{ t_i(\mathcal{M}(x_i,x_{-i}))$ denote the bid profile leading to $i$'s best-case dishonest utility. Then
\begin{equation*}
t_i(\mathcal{M}(t_i,\hat{x}_{-i})) \ge
t_i(\mathcal{M}(x_i,\hat{x}_{-i})) >
\sup_{x_{-i}} \{ t_i(\mathcal{M}(t_i,x_{-i})) \}
\end{equation*}
and thus $t_i(\mathcal{M}(t_i,\hat{x}_{-i}))$ is strictly greater than the maximum utility $i$ gets when bidding $t_i$ truthfully, a contradiction. We can arrive at a similar contradiction to show that $\mathcal{M}$ is also WNOM. Let $\hat{x}_{-i} \in \arg \inf \{ t_i(\mathcal{M}(x_i,x_{-i})) \}$ be the bid profile leading to $i$'s worst-case dishonest utility. So
\begin{equation*}
\inf_{x_{-i}} \{ t_i(\mathcal{M}(x_i,x_{-i})) \} >
t_i(\mathcal{M}(t_i,\hat{x}_{-i})) \ge
t_i(\mathcal{M}(x_i,\hat{x}_{-i}))
\end{equation*}
meaning $t_i(\mathcal{M}(x_i,\hat{x}_{-i}))$ is strictly less than the worst-case dishonest utility of player $i$. Thus strategyproof $\mathcal{M}$ is also NOM.
\end{proof}
\section{Labellings}
The extra flexibility of NOM mechanisms as opposed to strategyproof ones enables a useful technique for designing them. While strategyproofness requires satisfying a constraint on each pair of bid profiles $(x_i,x_{-i})$ and $(x_i',x_{-i})$ for every $x_i,x_i' \in D_i$ and every $x_{-i} \in D_{-i}$, for NOM we may attempt, as a designer, to ``choose'' for each player $i$ and type $t_i$ which two profiles of the opposing players will lead to the best- and worst-case outcomes respectively; we need then only satisfy the respective BNOM and WNOM constraints for those chosen profiles. We model this concept with objects that we will call \emph{labellings}. These are simply designations of the type profiles that lead to an agent's best- and worst-case outcomes in $\mathcal{M}$ according to her true type and what she reports.
Fix a player $i$ and let $d=|D_i|$ denote the size of their domain. The \emph{best-case and worst-case labellings} respectively are the matrices $\beta,\omega \in D_{-i}^{d \times d}$ in which
\begin{gather*}
\beta_{jk} \in \arg \sup_{x_{-i}} \{ t_j(\mathcal{M}(t_k,x_{-i})) \} \\
\omega_{jk} \in \arg \inf_{x_{-i}} \{ t_j(\mathcal{M}(t_k,x_{-i})) \},
\end{gather*}
so that the entries at row $j$ and column $k$ denote the profile in $D_{-i}$ achieving the greatest and least utilities that can potentially be obtained by player $i$ when reporting $t_k$ under the assumption that $i$ has type $t_j$. Given a label $\lambda_{jk}$ for $\lambda \in \{\beta,\omega\}$ we will sometimes write $\lambda_{jk}$ to denote the entire profile $(t_k,\lambda_{jk})$.
Originally introduced by Rochet~\cite{Rochet1987} cycle monotonicity has been used for the design of incentive-compatible mechanisms in various settings, including truthful mechanisms for multidimensional scheduling~\cite{Lavi2009}, truthful mechanisms with verification~\cite{Ventre2014}, and obviously strategyproof mechanisms~\cite{Ferraioli2018}, among others. We will adapt this approach to our setting by using the labellings $\beta,\omega$ to construct a graph for each player which we will then use to characterise which social choice functions and labellings lead to NOM mechanisms.
For a given player $i$, social choice function $f$, and labellings $\beta,\omega$ of $\mathcal{M}$ for player $i$ we will define two directed weighted multi-graphs $G_{i,f}^\beta = (V,E^\beta,w)$ and $G_{i,f}^\omega = (V,E^\omega,w)$. Both graphs have the same node set which is simply the set of all type profiles, i.e. $V=D$, and we represent edges as a tuple $(x,y;t)$ where $x,y \in V$ and $t \in D_i$ can be thought of as an annotation that is used to calculate an edge's weight. Specifically an edge in either graph is defined to have weight $w(x,y;t) = t(f(x))-t(f(y))$. We will also use $x \rightarrow^t y$ to denote edges and paths in these graphs.
The edge sets $E^\beta$ and $E^\omega$ differ slightly in their definitions but represent the same thing -- given an edge $(x,y;t)$, the utility of player $i$ on output $\mathcal{M}(x)$ is at least the utility on output $\mathcal{M}(y)$ when she has type $t \in D_i$. From the labellings $\beta,\omega$ arise two sets of constraints which we will call \emph{labelling constraints} and \emph{incentive-compatibility (IC) constraints}. For the former, if a particular node $v$ of the graph is a label in $\beta$, say $v = \beta_{jk}$, then when $i$ has type $t_j$ and bids $t_k$, her utility on outcome $\mathcal{M}(t_k,\beta_{jk})$ must be at least her utility on outcome $\mathcal{M}(t_k,x_{-i})$ for all $x_{-i}$. Hence there must be an edge $(t_k,\beta_{jk}) \rightarrow^{t_j} (t_k,x_{-i})$ for all $x_{-i}$ which represents the constraint $t_j(\mathcal{M}(t_k,\beta_{jk})) \ge t_j(\mathcal{M}(t_k,x_{-i}))$ that is implicit in the definition of BNOM. The same is true for labelling constraints for the worst-case labelling $\omega$, but in this case there is an incoming (rather than outgoing) edge $(t_k,x_{-i}) \rightarrow^{t_j} (t_k,\omega_{jk})$ for every $x_{-i}$ and each $\omega_{jk}$. The IC constraints represent the explicit constraints that arise from NOM, which requires that best- and worst-case truthful outcomes are no worse than best- and worst-case dishonest ones.
In short, labelling constraints designate a profile as leading to the best- or worst-case outcome for $i$, while IC constraints ensure the requirements for NOM are met. The formal definitions of these edge sets are given in \eqref{eq:graph-edge-sets} and \eqref{eq:graph-edge-sets2}. Note that, given a type $t_j \in D_i$ and labelling $\lambda \in \{ \beta,\omega \}$ for player $i$, all edges corresponding to a labelling constraint for $\lambda$ are contained in the subgraph of $G_{i,f}^\lambda$ in which all nodes are of the form $(t_j,x_{-i})$, i.e. profiles in which $i$ reports type $t_j$ to the mechanism. When talking about these edges we will refer to them as edges in the ``$j$-island'' of $G_{i,f}^\lambda$. The edges representing the IC constraints are then exactly those edges which cross from the $j$-island to the $k$-island of $G_{i,f}^\lambda$ for any two types $t_j,t_k \in D_i$.
\begin{gather}
\label{eq:graph-edge-sets}
E^\beta = \{ (t_j,\beta_{ij}) \rightarrow^{t_i} (t_j,x_{-k}) \, : \, t_i,t_j \in D_i, x_{-k} \in D_{-k} \} \cup \{ (t_i,\beta_{ii}) \rightarrow^{t_i} (t_j,\beta_{ij}) \, : \, t_i,t_j \in D_k \} \\
E^\omega = \{ (t_j,x_{-k}) \rightarrow^{t_i} (t_j,\omega_{ij}) \, : \, t_i,t_j \in D_i, x_{-k} \in D_{-k} \} \cup \{ (t_i,\omega_{ii}) \rightarrow^{t_i} (t_j,\omega_{ij}) \, : \, t_i,t_j \in D_k \} \label{eq:graph-edge-sets2}
\end{gather}
With the graph thus defined we use the cycle-monotonicity technique to derive a necessary and sufficient condition for the NOM-implementability of a social choice function based on the structure of the graph. We note that the proof of necessity follows standard reasoning used in the literature, while the proof of sufficiency is similar though requires some additional work. Moreover, this characterisation only holds for finite domains as the argument requires reasoning about shortest paths in $G_{i,f}^\lambda$, which are undefined in infinite graphs.
\begin{theorem}
\label{thm:nom-implementable}
Social choice function $f$ is:
\begin{itemize}
\item BNOM-implementable if and only if for each agent $i$ there exists a best-case labelling $\beta$ such that $G_{i,f}^\beta$ contains no negative weight cycles.
\item WNOM-implementable if and only if for each agent $i$ there exists a worst-case labelling $\omega$ such that $G_{i,f}^\omega$ contains no negative weight cycles.
\end{itemize}
\end{theorem}
\begin{proof}
We will prove the claim for WNOM and note that the proof for BNOM follows identical reasoning.
($\implies$) Suppose payments $p$ exist such that $(f,p)$ is WNOM. Fix player $i$ and assume for contradiction that every choice of $\omega$ induces a negative weight cycle in $G_{i,f}^\omega$. Let $C = \langle x^{(1)} \rightarrow^{t_1} x^{(2)} \rightarrow^{t_2} \ldots \rightarrow^{t_{k-1}} x^{(k)} \rightarrow^{t_k} x^{(1)} \rangle$ be such a cycle with $w(C) = w(x^{(1)},x^{(2)};t_1) + \ldots + w(x^{(k)},x^{(1)};t_k) < 0$. Since $f$ is WNOM-implementable then the inequality encoded by each edge is satisfied:
\begin{gather*}
t_1(f(x^{(1)}))+p_i(x^{(1)}) \ge t_1(f(x^{(2)}))+p_i(x^{(2)}) \\
t_2(f(x^{(2)}))+p_i(x^{(2)}) \ge t_2(f(x^{(3)}))+p_i(x^{(3)}) \\
\vdots \\
t_k(f(x^{(k)}))+p_i(x^{(k)}) \ge t_k(f(x^{(1)}))+p_i(x^{(1)})
\end{gather*}
The sum of all the inequalities must also be satisfied, in which case the payments cancel out and we are left with:
\[
t_1(f(x^{(1)}))-t_1(f(x^{(2)})) +
t_2(f(x^{(2)}))-t_2(f(x^{(3)})) +
\ldots +
t_k(f(x^{(k)}))-t_k(f(x^{(1)})) \ge 0,
\]
which is simply the expression for the sum of edge weights along $C$. Therefore we have $w(C) \ge 0$, a contradiction, so there must be a labelling $\omega$ such that $G_{i,f}^\omega$ has no negative weight cycles.
($\impliedby$) Let $\omega$ be a labelling such that $G_{i,f}^\omega$ has no negative weight cycles. Augment $G_{i,f}^\omega$ with an artificial node $\gamma$ and an edge $(\gamma,x;0)$ for each $x \in D$ with weight 0. Since $G_{i,f}^\omega$ contains no negative cycles and the addition of $\gamma$ creates no new cycles (since we only have outgoing edges from $\gamma$) then shortest paths are well-defined in this new graph. We will now set $p_i(x) = \text{SP}(\gamma,x)$, where $\text{SP}$ denotes the shortest path between two nodes in $G_{i,f}^\omega$. For any node $y$ connected to $x$ by an edge labelled by type $t$, by definition of the shortest path we have $\text{SP}(\gamma,y) \le \text{SP}(\gamma,x) + w(x,y;t)$. Thus $p_i(y) \le pi(x) + t(f(x)) - t(f(y))$ and so $t(f(x)) + p_i(x) \ge t(f(y)) + p_i(y)$ for any two profiles $x,y$ connected by an edge labelled by type $t$. It remains to show that, whenever such an edge appears as per our definition of $G_{i,f}^\omega$, the corresponding WNOM constraint that it represents is satisfied.
\emph{Case 1: $t = x_i$.} In this case the edge $(x,y;t)$ either encodes an incentive-compatibility constraint or a truthful labelling constraint. Suppose first that it is the former. Then $x$ must be the profile in which $i$ gets her lowest utility when she bids $x_i$ truthfully, while $y$ must be the profile in which she gets her lowest utility when she has type $x_i$ and bids $y_i$ dishonestly. Thus $x_i(f(x)) + p_i(x) \ge x_i(f(y)) + p_i(y)$ and so her worst-case truthful outcome is no worse than her worst-case dishonest outcome when she has type $x_i$. Now suppose the edge encodes the latter constraint. Then we have $x=(x_i,x_{-i})$ and $y=(x_i,x_{-i})$, where $y$ designates the input yielding her her worst outcome when she has type $x_i$. Thus $i$ prefers $\mathcal{M}(x)$ to $\mathcal{M}(y)$ and we have $x_i(f(x)) + p_i(x) \ge x_i(f(y)) + p_i(y)$.
\emph{Case 2: $t \neq x_i$.} In this case the edge $(x,y;t)$ encodes a labelling constraint for a dishonest interaction of $i$ with $\mathcal{M}$. Now $y=(x_i,y_{-i})$ must be the profile in which $i$ receives her lowest utility when she has type $t$ and bids $x_i$ dishonestly. Thus she prefers the outcome when $\mathcal{M}$ is given input $x=(x_i,x_{-i})$ and so $t(f(x)) + p_i(x) \ge t(f(y)) + p_i(y)$.
In all cases whenever we have an edge $(x,y;t)$ all constraints are satisfied and so the mechanism $(f,p)$ is WNOM.
\end{proof}
Some cycles are guaranteed to exist in $G_{i,f}^\beta$ and $G_{i,f}^\omega$, regardless of the labellings we choose. We can use the existence of such cycles to further study the conditions under which particular social choice functions are implementable as NOM mechanisms. Consider first any labelling $\beta$ and let $t_j,t_k \in D_i$ be two types from the domain of player $i$. In the $j$-island of $G_{i,f}^\beta$ w have an edge from node $(t_j,\beta_{jj})$, player $i$'s best outcome when she bids $t_j$ truthfully, to all other nodes $(t_j,x_{-i})$ and annotated by type $t_j$. In particular one of these nodes will coincide with the profile $(t_j,\beta_{kj})$, the bid profile leading to $i$'s best outcome when she bids $t_j$ dishonestly.\footnote{It may be the case that $\beta_{jj}=\beta_{kj}$ in which case we would have a zero-weight self-loop, but this does not affect the analysis.} Symmetrically we have an edge from $(t_j,\beta_{kj})$ to every other node $(t_j,x_{-i})$ annotated by type $t_k$. Hence for any labelling we will have the two-cycle $\langle (t_j,\beta_{jj}) \rightarrow^{t_j} (t_j,\beta_{kj}) \rightarrow^{t_k} (t_j,\beta_{jj}) \rangle$. Now including incentive-compatibility edges, we have an edge from player $i$'s best-case truthful profile to her best-case dishonest profile for each possible manipulation when she has type $t_j$ and bids type $t_k$, and using similar reasoning as before we can show that the four-cycle $\langle (t_j,\beta_{jj}) \rightarrow^{t_j} (t_k,\beta_{jk}) \rightarrow^{t_j} (t_k,\beta_{kk}) \rightarrow^{t_k} (t_j,\beta_{kj}) \rightarrow^{t_k} (t_j,\beta_{jj}) \rangle$ is present in any best-case labelling we choose. We can repeat the reasoning for any worst-case labelling $\omega$ to show the existence of two-cycles $\langle (t_j,\omega_{kj}) \rightarrow^{t_j} (t_j,\omega_{jj}) \rightarrow^{t_k} (t_j,\omega_{kj}) \rangle$ and four-cycles $\langle (t_j,\omega_{jj}) \rightarrow^{t_j} (t_k,\omega_{jk}) \rightarrow^{t_k} (t_k,\omega_{kk}) \rightarrow^{t_k} (t_j,\omega_{kj}) \rangle$ in $G_{i,f}^\omega$.
We can generalise these arguments to show that for any $p$ types $t_1,\ldots,t_p \in D_i$ there is always a cycle of length $2p$ which alternates between traversing edges for labelling constraints and edges for incentive-compatibility constraints. These $2p$-cycles have weight equal to $w(C_p^\beta)$ and $w(C_p^\omega)$ where $C_p^\beta,C_p^\omega$ are given by:
\begin{gather}
\label{eq:bnom-guaranteed-cycles}
C_p^\beta = \{
(t_j,\beta_{jj}) \rightarrow^{t_j} (t_{j+1},\beta_{(j+1),(j+1)}) \, : \, j \in [p]
\} \\
\label{eq:wnom-guaranteed-cycles}
C_p^\omega = \{
(t_j,\omega_{(j-1),j}) \rightarrow^{t_j} (t_{j+1},\omega_{j,(j+1)}) \, : \, j \in [p]
\}
\end{gather}
where the index wraps around appropriately at -1 and $p+1$. Note that $C_p^\beta$ and $C_p^\omega$ do not necessarily exist in $G_{i,f}^\beta$ and $G_{i,f}^\omega$; it is simply that there are cycles of length $2p$ which \emph{are} guaranteed to exist which have weight equal to $C_p^\beta$ and $C_p^\omega$. Restricting our attention to a particular $j$-island of $G_{i,f}^\beta$ and $G_{i,f}^\omega$ we can also show that for any two types $t_k,t_\ell \in D_i$ we will have the edges:
\begin{gather}
\label{eq:bnom-two-cycles}
\{ (t_j,\beta_{kj}) \rightarrow^{t_k}
(t_j,\beta_{\ell j}) \rightarrow^{t_\ell}
(t_j,\beta_{kj}) \, : \, t_j,t_k,t_\ell \in D_i \} \\
\label{eq:wnom-two-cycles}
\{ (t_j,\omega_{kj}) \rightarrow^{t_\ell}
(t_j,\omega_{\ell j}) \rightarrow^{t_k}
(t_j,\omega_{kj}) \, : \, t_j,t_k,t_\ell \in D_i \}
\end{gather}
We will use these guaranteed cycles in the following section in which we characterise the NOM-implementable allocation functions for single-parameter agents.
\section{Single-parameter agents}
\label{sec:single-parameter}
For the remainder of this work we shall consider single-parameter agents. In this setting agent types can be described by a single number: when agent $i$ has type $t_i$ she values the outcome of $f$ on input $x$ as $t_i(f(x)) = t_i \cdot f_i(x)$, allowing us to decouple an agent's type from the outcome of the mechanism. Archer and Tardos~\cite{ArcherTardos2001} use this to characterise truthfully-implementable work functions and then formulate payments using the area under a curve. In our setting while the ``shape'' of the allocation function will depend on the labelling we choose, we can use the cycles given in \eqref{eq:bnom-guaranteed-cycles} and \eqref{eq:wnom-guaranteed-cycles} to show some necessary properties of any labelling. Let $p = 2$ for these cycles $C_p^\beta$ and $C_p^\omega$. By \Cref{thm:nom-implementable} we know $\beta,\omega$ are valid labellings if and only if all cycles in $G_{i,f}^\beta$ and $G_{i,f}^\omega$ are non-negative, thus $w(C_2^\beta),w(C_2^\omega) \ge 0$ in any valid labelling. Since agents are single-parameter we may factor the expressions for the cycle weights as follows:
\begin{gather}
(t_j-t_k)(f_i(t_j,\beta_{jj})-f_i(t_k,\beta_{kk})) \ge 0 \\
(t_j-t_k)(f_i(t_j,\omega_{kj})-f_i(t_k,\omega_{kj})) \ge 0
\end{gather}
for all $t_j,t_k \in D_i$. In other words, when $t_j > t_k$ then player $i$ must receive more from $f$ in her best truthful outcome of $\mathcal{M}$ when she has type $t_j$ than when she has type $t_k$, while she must receive more in the worst case from $f$ when she misreports her true type $t_k$ as $t_j$ compared to when she misreports her true type $t_j$ as $t_k$. We will refer to this property as \emph{label monotonicity}. Similarly the two-cycles given in \eqref{eq:bnom-two-cycles} and \eqref{eq:wnom-two-cycles} must also have non-negative weight. We may separate them as before to get:
\begin{gather}
(t_k-t_\ell)(f_i(t_j,\beta_{kj})-f_i(t_j,\beta_{\ell j})) \ge 0 \\
(t_k-t_\ell)(f_i(t_j,\omega_{\ell j})-f_i(t_j,\omega_{kj})) \ge 0
\end{gather}
Let $S_{ij} = \{ f_i(t_j,x_{-i}) \, : \, x_{-i} \in D_{-i} \}$ denote the set of outcomes of $f$ for player $i$ when she submits bid $t_j$, and let $S_i = \times_{j \in D} S_{ij}$. We will call $f$ \emph{overlapping for $i$} if there exists $\mathbf{o}=(o_1,\ldots,o_d) \in S_i$ such that $o_1 \le o_2 \le \ldots \le o_d$. Let $\hat{f}_i : D_i \times S_i \to D$ denote a pseudo-inverse of $f$ which returns any bid profile $x=(t_j,x_{-i})$ such that $f_i(x)=o_j$. We will show that $f$ is BNOM- and WNOM-implementable if and only it is overlapping for each $i$. Our proof will be for the WNOM case but note that the proof for BNOM follows exactly the same reasoning.
\begin{theorem}
\label{thm:overlapping}
Allocation function $f$ is either BNOM- or WNOM-implementable for single-parameter agent $i$ if and only if it is overlapping for $i$.
\end{theorem}
\begin{proof}
($\implies$) Assume for the sake of contradiction that there are two bids $t_1,t_2 \in D_i$ with $t_1 < t_2$ such that $f$ is not overlapping for $i$. That is, for any choice of $o_1 \in S_{i1}$ we must have $o_2 < o_1$ for $o_2 \in S_{i2}$. Since $f$ is WNOM-implementable then there exists a worst-case labelling $\omega$ such that the graph $G_{i,f}^\omega$ contains no cycles of negative weight. By the monotone labelling property we require $(t_1-t_2)(f_i(t_1,\omega_{21})-f_i(t_2,\omega_{12})) \ge 0$, so $f_i(t_1,\omega_{21}) \le f_i(t_2,\omega_{12})$. Since $o_2 < o_1$ for any choice of $o_1$ then we must have $f_i(t_1,\omega_{j1}) > f_i(t_2,\omega_{k2})$ for all (not necessarily distinct) $t_j,t_k \in D_i$. Thus $f$ cannot be WNOM-implementable for $i$, a contradiction, so $f$ must be overlapping for $i$.
($\impliedby$) We will use the overlaps of $f$ for player $i$ to define a valid worst-case labelling $\omega$ and note that the exact same reasoning carries over for best-case labellings $\beta$. Define iteratively the values $W(j) = \max \{ \min_{o_j \in S_{ij}} \{ o_j \}, W(1), W(2), \ldots, W(j-1) \}$ for $j \in [d]$. Note that $W(j) \ge W(k) \iff t_j \ge t_k$. We will use $W$ to label $f$ with $\omega_{ij} = \hat{f}_i(j,W(j))$ for each $t_i,t_j \in D_i$. Since for every bid $t_j$ we have $\omega_{ij} = \omega_{kj}$ for all types $t_i,t_k \in D_i$ we use a single subscript $\omega_j$ to denote this bid profile. We now show that no cycles that appear in the graph $G_{i,f}^\omega$ are negative and hence $\omega$ is a valid worst-case labelling.
First note that since for every bid $t_j$ we label the worst-case outcome for $i$ to occur at the same bid profile $\omega_j$ no matter her type, then each subgraph of $G_{i,f}^\omega$ containing only nodes $(t_j,x_{-i})$ in which $i$ has bid $t_j$ will have no cycles, and these edges represent the labelling constraints. Hence we need only focus on edges which go from node $(t_j,\omega_j)$ to some $(t_k,\omega_k)$, which represent the incentive-compatibility constraints. Recall that the type annotation on each of these edges is always equal to the bid of player $i$ at the source node, so every edge has the form $(t_u,\omega_u) \rightarrow^{t_u} (t_v,\omega_v)$. Consider any cycle $C$ in $G_{i,f}^\omega$ with weight $w(C) = \sum_{(u,v;t_u) \in C} t_u(f_i(\omega_u)-f_i(\omega_v))$. We will refer to negative weight edges in $C$ as ``uphill'' edges and positive weight edges as ``downhill'' edges. We can safely ignore edges of zero weight. Note that uphill edges occur when the output of $f$ for player $i$ is lower at the source than the destination profile, and since $W(j) \ge W(k) \iff t_j \ge t_k$ then all such edges go from a node in which $i$ bids a smaller type to one in which she bids a larger one. The opposite is true for downhill edges. For a given bid $t_j$ we will refer to the types $\max \{ t_k \in D_i \, : \, t_k < t_j \}$ and $\min \{ t_k \in D_i \, : \, t_k > t_j \}$ as the adjacent type to $t_j$, and adjacent nodes in $G_{i,f}^\omega$ will be those in which $i$ submits adjacent types as bids to the mechanism. We will show that the weight of $C$ is bounded below by the weight of a (non-simple) cycle $C'$ which only contains edges between adjacent nodes, whose weight is in turn always non-negative.
In the following we will use simply the label $\omega_j$ as shorthand for the bid profile $(t_j,\omega_j)$. First consider a downhill edge $e^+ = \omega_j \rightarrow^{t_j} \omega_{j-k}$ going directly from $\omega_j$ to $\omega_{j-k}$ that ``skips'' $k-1$ adjacent nodes. Since $t_j > t_{j-k}$ then $W(j) = f_i(t_j,\omega_j) > f_i(t_{j-k},\omega_{j-k}) = W(j-k)$. The weight $w(e^+)$ of such an edge is therefore:
\begin{align*}
w(e^+) & = t_j [ f_i(\omega_j) - f_i(\omega_{j-k}) ] \\
& = t_j [ f_i(\omega_j) - f_i(\omega_{j-1}) + f_i(\omega_{j-1}) - f_i(\omega_{j-2}) + \ldots + f_i(\omega_{j-k+1}) - f_i(\omega_{j-k}) ] \\
& \ge t_j(f_i(\omega_j)-f_i(\omega_{j-1})) + t_{j-1}(f_i(\omega_{j-1})-f_i(\omega_{j-2})) + \ldots + t_{j-k+1}(f_i(\omega_{j-k+1})-f_i(\omega_{j-k}))
\end{align*}
Following the same reasoning we can show that the weight of an uphill edge $e^- = (t_j,\omega_j) \rightarrow^{t_j} (t_{j+k},\omega_{j+k})$, in which we skip $k-1$ adjacent nodes, can be similarly lower bounded:
\begin{align*}
w(e^-) & = t_j [ f_i(\omega_j) - f_i(\omega_{j+k}) ] \\
& = t_j [ f_i(\omega_j) - f_i(\omega_{j+1}) + f_i(\omega_{j+1}) - f_i(\omega_{j+2}) + \ldots + f_i(\omega_{j+k-1}) - f_i(\omega_{j+k}) ] \\
& \ge t_j(f_i(\omega_j)-f_i(\omega_{j+1})) + t_{j+1}(f_i(\omega_{j+1})-f_i(\omega_{j+2})) + \ldots + t_{j+k-1}(f_i(\omega_{j+k-1})-f_i(\omega_{j+k}))
\end{align*}
Notice in both cases that the right hand side of the final inequality is the expression for the weight of a path between two non-adjacent nodes that only traverses edges between adjacent nodes. Now if we take any cycle $C$ and replace all such non-adjacent edges with a path comprising only adjacent edges then we will be left with a non-simple cycle that is composed of many two-cycles (see \Cref{fig:nonnegative-cycles}). We know from the labelling monotonicity property of our labelling $\omega$ that all two-cycles are non-negative, and so too must be their sum. This non-negative value lower bounds $w(C)$, thus under $\omega$ there must be no negative cycles, and by \Cref{thm:nom-implementable} the proof is complete.
\end{proof}
\begin{figure}[ht]
\centering
\begin{subfigure}{.4\textwidth}
\centering
\ctikzfig{tikzfigs/uphill-edges}
\caption{Uphill edges}
\label{fig:uphill-edges}
\end{subfigure}
\begin{subfigure}{.4\textwidth}
\centering
\ctikzfig{tikzfigs/downhill-edges}
\caption{Downhill edges}
\label{fig:downhill-edges}
\end{subfigure}
\caption{Substituting cycles with non-adjacent types for cycles with only
adjacent types}
\label{fig:nonnegative-cycles}
\end{figure}
\begin{corollary}
Allocation function $f$ is NOM-implementable if and only if there exists non-decreasing sequences $\mathbf{o}^\beta,\mathbf{o}^\omega \in S_i$ for all $i$, and unless $f_i$ is constant then $\hat{f}_i(t_j,o_j^\beta) \neq \hat{f}_i(t_j,o_j^\omega)$.
\end{corollary}
\begin{proof}
The vectors of real numbers $\mathbf{o}^\beta,\mathbf{o}^\omega$ correspond to the outcomes at the best- and worst-case nodes of $\mathcal{M}$, according to $\beta,\omega$ respectively. We have shown that $f$ is singularly BNOM- or WNOM-implementable if and only if $\mathbf{o}^\beta$ and $\mathbf{o}^\omega$ are non-decreasing sequences -- we can combine them to achieve a mechanism that is NOM, with the only extra caveat being that, unless $f$ is constant, then the best- and worst-case outcomes occur at different bid profiles.
Let $(t_j,\hat{x}_{-i})$ be some bid profile at which $i$ receives both her best- and worst-case utility when she bids $t_j$. Then $\hat{f}_i(t_j,o_j^\beta)=\hat{f}_i(t_j,o_j^\omega)=(t_j,\hat{x}_{-i})$. Then the $j$-island of $G_{i,f}^{\beta,\omega}$ consists only of the two-cycles $\langle (t_j,\hat{x}_{-i}) \rightarrow^{t_k} (t_j,x_{-i}) \rightarrow^{t_\ell} (t_j,\hat{x}_{-i}) \rangle$ for all types $t_k,t_\ell \in D_i$. Requiring the weights of all such cycles to be non-negative means we need both $(t_k-t_\ell)(f_i(t_j,\hat{x}_{-i})-f_i(t_j,x_{-i})) \ge 0$ and $(t_\ell-t_k)(f_i(t_j,\hat{x}_{-i})-f_i(t_j,x_{-i})) \ge 0$, which is only satisfied when $f_i(t_j,\hat{x}_{-i})=f_i(t_j,x_{-i})$ for all $x_{-i}$.
\end{proof}
In the proof of sufficiency in \Cref{thm:overlapping} above we used a particular labelling in which the best- and worst-case outcome for a given bid of player $i$ all occurred at the same bid profile, no matter her type. These are of course not the only labellings possible, and different labellings can and do lead to different payments (as we will see in \Cref{sec:bilateral-trade}). For the following characterisation, however, we will focus on the above type of \emph{single-line} labellings. Formally, a labelling $\lambda \in \{\beta,\omega\}$ is single-line if $\lambda_{kj} = \lambda_{\ell j}$ for all $t_j,t_k,t_\ell \in D_i$ for every player $i$. We shall call a mechanism single-line if the labelling it uses is single-line. This allows us to express payments that NOM-implement an allocation function succintly for single-parameter agents, following a result originally due to Archer and Tardos~\cite{ArcherTardos2001}.
In \cite{ArcherTardos2001} they consider functions which allocate \emph{work} to the single-parameter agents, so their types are analogous to costs rather than valuations. They show that such a work function admits truthful payments if and only if it is non-increasing and fully characterise the payments by expressing them using various areas on the work curves. While our setting is one in which agent types are valuations it is simple to translate between the two, and we show that NOM payments exist if and only if the best- and worst-case curves are non-decreasing. The proof of the following claim follows the exact same reasoning as \cite{ArcherTardos2001}, where instead of treating $f$ as a function only of $x_i$ by fixing the bid profile of other bidders $x_{-i}$ we treat it as a function only of $x_i$ by arguing that the labellings $\beta,\omega$ are fixed. We can then solve the differential equations in the same way.
\begin{theorem}
If $f_i$ is a single-line mechanism for player $i$ then $f$ is NOM-implementable if and only if for each player $i$ payments are of the form:
\begin{gather}
\label{eq:nom-explicit-payments}
p_i(t_j,\lambda_j) = h_i(\lambda) - t_j f_i(t_j,\lambda_j) + \int_0^{t_j} f_i(u,\lambda_u) \, \mathrm{d} u
\end{gather}
for $\lambda \in \{\beta,\omega\}$, where $h_i(\lambda)=h_i(\lambda_1,\ldots,\lambda_d)$ is an arbitrary function that only depends on the labelling $\lambda$.
\end{theorem}
The remaining payments -- for bid profiles which are not best- or worst-case inputs -- are then easy to define and entail some degree of flexibility. Since we use a single-line mechanism we simply need to satisfy a total of $|D_{-i}|-1$ constraints for each bid $x$ of player $i$ of the form $t_i(f_i(t_j,\beta_j)) + p_i(t_j,\beta_j) \ge t_i(f_i(t_j,x_{-i})) + p_i(t_j,x_{-i})$ for BNOM, and $t_i(f_i(t_j,x_{-i})) + p_i(t_j,x_{-i}) \ge t_i(f_i(t_j,\omega_j)) + p_i(t_j,\omega_j)$ for WNOM. It is important to note the move from discrete to continuous domains. This is not an issue conceptually since the labels $\lambda$ are simply bid profiles. In practice we would need to assume the existence of an oracle that returns the labelled profile $\lambda_{jk}$ when queried with two types $t_j$ and $t_k$. Note that when we have discrete domains this is not an issue but we would need to replace the integral with a summation. By assuming IR and NPT we can place restrictions on the functions $h_i(\beta)$ and $h_i(\omega)$. When types are valuations we get $h_i(\beta)=h_i(\omega)=0$. When types are costs then $h_i(\beta) \ge \int_0^{t_j} f_i(u,\beta_u) \, \mathrm{d} u$ and $h_i(\omega) \ge \int_0^{t_j} f_i(u,\omega_u) \, \mathrm{d} u$ for all $x \in D_i$.
\section{Bilateral Trade}
\label{sec:bilateral-trade}
We now study the bilateral trade setting in which there are two agents, $B$ and $S$, where $B$ is a potential buyer of an item that $S$ is looking to produce and sell. The agents have types $v \in D_B$ and $u \in D_S$ respectively, where $v$ describes the buyer's valuation for the item and $u$ describes the seller's cost for producing the item. Let $D = D_B \times D_S$. A mechanism for bilateral trade is a tuple $\mathcal{M}=(f,p)$ where $f : D \to \{0,1\}$ indicates whether a trade takes place and $p : D \to \mathbb{R}_{\ge 0}$ describes the payments. The agents' utilities are given by
\begin{gather*}
v(\mathcal{M}(x,y)) = v \cdot f(x,y) - p_B(x,y) \\
u(\mathcal{M}(x,y)) = p_S(x,y) - u \cdot f(x,y)
\end{gather*}
We focus primarily on studying the following three properties: a function $f$ is \emph{efficient} if trade only occurs whenever the buyer's bid exceeds that of the seller's; a mechanism is \emph{individually rational} if an agent can never end up worse off by submitting a truthful bid to the mechanism; and a mechanism is weakly budget-balanced if the seller is never paid more than what we receive as payment from the buyer. We can relax the last property to $\alpha$ weak budget balance, where our payment to the seller is never more than an $\alpha$ factor away from the payment received from the buyer for $\alpha \ge 1$. Formally:
\begin{itemize}
\item Efficiency: $f(x,y)=1$ if and only if $x \ge y$ for all $(x,y) \in D$
\item Weak Budget Balance (WBB): $p_S(x,y) \le p_B(x,y)$ for all $(x,y) \in D$
\item $\alpha$-WBB: $p_S(x,y) \le \alpha \cdot p_B(x,y)$ for all $(x,y) \in D$ and $\alpha \ge 1$.
\end{itemize}
Since its introduction by Chatterjee and Samuelson~\cite{Chatterjee1983}, bilateral trade has received and continues to receive considerable attention in the economics and algorithmic game theory literature. Here, we give a brief overview of some examples of recent work. In their seminal work, Myerson and Satterthwaite~\cite{MyersonSatterthwaite1983} show that there is no mechanism that is simultaneously Bayesian Incentive-Compatible (BIC), IR, WBB, and efficient, thus efforts have largely been focused on analysing the mechanisms satisfying an approximate form of efficiency instead. Recently it was shown by Deng et al.~\cite{Deng2021} that there exists a mechanism that guarantees a Bayes-Nash equilibrium with a constant-factor approximation to the optimal ``gains from trade'' (GFT) (i.e. the expected utility gain as a result of trading). Babaioff, Dobzinski, and Kupfer~\cite{Babaioff2021} show that this mechanism cannot approximate the optimal GFT better than $0.495$ for some distributions. Blumrosen and Dobzinski~\cite{Blumrosen2021} show that for every pair of distributions of types for the buyer and seller there exists a IR, WBB, fixed-price mechanism -- a mechanism that posts a price asks players to ``take it or leave it'' -- that achieves at least a $(1-1/e)$ fraction of the optimal efficiency in dominated strategies. This was improved to $(1-1/e)+10^{-4}$ by Kang, Pernice, and Vondr\'ak~\cite{Kang2021}.
The above merely form an example of some recent works on the topic. These studies and most other works in the mechanism design literature are concerned with implementations in dominant strategy or Bayes-Nash equilibria. Bilateral trade under NOM was studied in \cite{Troyan2020}, where it was proved that WBB, efficiency, and IR cannot be satisfied simultaneously under NOM. In this section we investigate this combination of properties further, where we relax WBB to $\alpha$-WBB, and consider WNOM and BNOM separately as relaxations of NOM.
\subsection{Single-line mechanisms require unbounded subsidies}
Recall that when we use a single-line mechanism then NOM payments exist if and only if they are of the form given in \eqref{eq:nom-explicit-payments}, and that this was technically for the case in which payments are \emph{given} to players (since they are added to their utilities) and moreover this was when agents valued the outcome of $f$, as opposed to incurring a cost. This setup slightly changes in our setting for bilateral trade: now the buyer values the outcome of $f$ and payments are subtracted from her utility, while the seller induces a cost for producing the item but receives payments as compensation. In the following discussion we will highlight some of the issues of using single-line mechanisms for bilateral trade mechanisms, so we note that the payments for such mechanisms take the following form:
\begin{gather*}
p_B(x,\lambda_x) = h_B(\lambda) + x f(x,\lambda_x) - \int_0^x f(u,\lambda_u) \, \mathrm{d} u, \\
p_S(\lambda_y,y) = h_S(\lambda) + y f(\lambda_y,y) - \int_0^y f(\lambda_u,u) \, \mathrm{d} u,
\end{gather*}
for $\lambda \in \{\beta,\omega\}$. Again note that if we have IR and NPT then $h_B(\lambda)$ goes to zero, while for the seller this must be at least the area under the curve.
Before proceeding with the following claims it will be useful to note a few facts we will reuse. Let $x$ and $y$ be bids of the buyer and seller, respectively. Whenever our bilateral trade mechanism is IR and efficient then for all $x \ge y$ we require $p_B(x,y) \le x$ and $p_S(x,y) \ge y$, while for $x < y$ we have $-p_B(x,y) \ge 0$ and hence $p_B(x,y) = 0$. Therefore whenever trade does not take place the utility of the buyer is 0 no matter her true type. In \Cref{lem:bnom-threshold} and \Cref{lem:wnom-threshold} we will prove that when we have a single-line mechanism the curves representing the best- and worst-case outcomes of $f$ are constant. Since the buyer receives value from the item while the seller incurs a cost then by \Cref{thm:overlapping} the outcomes at her best- and worst-case outcomes must be non-decreasing in her bid $x$; conversely since the seller incurs a cost for producing the item then her curve must be non-increasing. Since $f \in \{0,1\}$ and our mechanism is either BNOM or WNOM then there must be a threshold $\theta \in [0,1]$ at which, for all bids that are at least this threshold, the output of $f$ flips from one value to the other, depending on the player we are analysing. For the buyer we must have $f(x,\beta_x) = f(x,\omega_x) = 1$ for all $x \ge \theta$, while for the seller we require $f(\beta_y,y) = f(\omega_y,y) = 0$ for all $y \ge \theta$. We will show that these thresholds are placed at the extremes, i.e. 0 or 1.
\begin{lemma}
\label{lem:bnom-threshold}
In any efficient, IR, single-line BNOM mechanism $\mathcal{M}$ the best-case outcomes occur for both the buyer and the seller when the trade is executed, regardless of their bid.
\end{lemma}
\begin{proof}
Consider first from the buyer's side. Since $\mathcal{M}$ is single-line BNOM then $f$ must be non-decreasing in the buyer's bid, and let $\theta$ be such that $f(x,\beta_x)=1$ for all $x \ge \theta$. Fix $x$ and let $x < \theta$ and $y$ be a bid of the seller such that $f(x,y)=1$. By the BNOM labelling constrains we have $v(\mathcal{M}(x,\beta_x)) = 0 \ge v - p_B(x,y)$ for all $v \in D_B$, so $1 \le p_B(x,y) \le x$, where the second inequality follows from IR and efficiency. We arrive at a contradiction from our assumption that $x < \theta$ since $1 \le x < \theta$ where $\theta \in [0,1]$. Thus $\theta \le x$ for all $x$, meaning $\theta = 0$: in other words $f$ is 1 everywhere and trade always occurs in the buyer's best-case outcome.
Now consider the seller. She incurs a cost for producing the item when the trade is to be executed, hence from her perspective $f$ must be non-increasing in her bid. As before there must be a threshold $\theta \in [0,1]$ such that $f(\beta_y,y)=1$ for all $y \le \theta$ and 0 otherwise. For some bid $y > \theta$ of the seller her best case utility is $u(\mathcal{M}(\beta_y,y)) = p_S(\beta_y,y) = h_S(\beta) + y f(\beta_y,y) - \int_0^y f(\beta_u,u) \, \mathrm{d} u$. Recall that the value of $h_i(\beta)$ for costs is at least the area under the work curve. Setting $h_S(\beta)$ to this area\footnote{We can of course pay the seller more, as long as it doesn't interfere with incentives. We will be using this lemma to prove the impossibility of (bounded) $\alpha$-WBB, so if we can show this when we are being as frugal as possible then the claim will hold even when using more generous payments. Thus we set $h_S(\beta)$ to be as small as possible, i.e. exactly the area under the curve, and this is enough to prove the unboundedness. This same reasoning is used in the proof of \Cref{lem:wnom-threshold}.} gives $p_S(\beta_y,y) = y f(\beta_y,y) + \int_y^1 f(\beta_u,u) \, \mathrm{d} u$ so her best-case utility is 0. Now take any $x$ such that $f(x,y)=1$. By the BNOM constraints we have $u(\mathcal{M}(x,y)) = p_S(x,y) - u \le 0$ for all $u$. Combining this with individual rationality we have $u \ge p_S(x,y) \ge y$, which gives us a contradiction if we take $u < y$. Thus $y \le \theta$ for all $y$ and so $\theta = 1$, meaning trade always occurs in the best-case outcome for the seller.
\end{proof}
As a corollary of \Cref{lem:bnom-threshold} it must be that the buyer's best outcome is that she gets the item and pays nothing, while the seller's is that she produces the item and is paid at least her bid. Since we assume $\mathcal{M}$ is IR, NPT, and single-line BNOM then payments are of the form given in \eqref{eq:nom-explicit-payments}. Thus $p_B(x,\beta_x) = 0$ and $p_S(\beta_y,y) \ge y + \int_y^1 f(\beta_u,u) \, \mathrm{d} u = 1$.
\begin{theorem}
Any efficient, IR, single-line BNOM mechanism with $\alpha$-WBB has unbounded $\alpha$.
\end{theorem}
\begin{proof}
From \Cref{lem:bnom-threshold} we know that $f(x,\beta_x) = f(\beta_y,y) = 1$ for any $x \in D_B$ and $y \in D_S$, while $p_B(x,\beta_x) = 0$ and $p_S(\beta_y,y) \ge y$. Thus we need to show that there always exists a profile $(x^*,y^*)$ that appears on both the best-case curve of the buyer and the seller to prove the claim. Take any bid $x$ of the buyer and let $y= \beta_x > 0$ be a bid of the seller. Since $f(x,y)=1$ then $p_S(x,y) \ge y$ by efficiency and IR. The labelling constraints require $u(\mathcal{M}(x,y)) \ge u(\mathcal{M}(\beta_y,y))$ for all $u$ and so $p_S(\beta_y,y) \ge p_S(x,y) \ge y$. Since $y = \beta_x$ then $p_S(\beta_y,y) \ge p_S(x,\beta_x) \ge y > 0$, while $p_B(x,\beta_x) = 0$. Therefore at $(x,\beta_x)$ the buyer pays 0 while the seller must receive some positive amount.
Now let $y=0$: the following labelling will result in payments leading to the desired result. For every bid $x$ of the buyer set $\beta_x = 0$. Now for all choices of the bid of the buyer $\beta_y$ leading to the seller's best outcome the resulting profile will also appear on the buyer's best-case curve. Again the buyer pays 0 while the seller must receive a positive amount.
\end{proof}
\begin{lemma}
\label{lem:wnom-threshold}
In any efficient, IR, single-line WNOM mechanism $\mathcal{M}$ the worst-case outcomes occur for both the buyer and the seller when the trade is not executed, regardless of their bid.
\end{lemma}
\begin{proof}
As before first consider the buyer's perspective. Assume there is a bid $x > \theta$ and let $y$ be a bid of the seller such that $f(x,y)=0$. The labelling constraints therefore require that $v - p_B(x,\omega_x) \le 0$ for all $v \in D_B$, and combining this with the previous facts we get $p_B(x,\omega_x) = x$. Now taking $v > x$ the buyer's utility at her worst-case outcome is strictly positive, a contradiction. Hence $\theta \ge x$ for all $x$, or $\theta = 1$. Thus in the buyer's worst case the trade is never executed.
As for the seller let $y < \theta$ and let $x$ be such that $f(x,y) = 0$. Then $p_S(x,y) = 0$, and since trade occurs in the seller's worst case by assumption then $p_S(\omega_y,y) \le y$. By \eqref{eq:nom-explicit-payments} then $p_S(\omega_y,y) \ge h_S(\omega) + y f(\omega_y,y) - \int_0^y f(\omega_u,y) \, \mathrm{d} u = h_S(\omega) + y - y \ge \theta$, where the final inequality follows from the fact that $h_S(\omega)$ must be at least the area under the curve for any IR and NPT mechanism. Thus $p(\omega_y,y) \ge \theta$ and $p_S(\omega_y,y) \le y$ where $y < \theta$, a contradiction. So $\theta = 1$ and the seller's worst case always occurs when the trade is not executed.
\end{proof}
\begin{theorem}
Any efficient, IR, single-line WNOM mechanism with $\alpha$-WBB has unbounded $\alpha$.
\end{theorem}
\begin{proof}
Let $\mathcal{M}=(f,p)$ be an efficient, IR, single-line WNOM mechanism and consider a bid $x \in D_B$ of the buyer for which $f(x,\omega_x)=0$. By IR we have $x f(x,\omega_x) - p_B(x,\omega_x) \ge 0$ and so $p_B(x,\omega_x) = 0$. Thus $v(\mathcal{M}(x,\omega_x))=0$ for any $v$ when $f(x,\omega_x)=0$. Let $y \in D_S$ be a bid of the seller such that $f(x,y)=1$ and note that by efficiency $x \ge y$. Since the worst utility of the buyer is 0 then $p_B(x,y) \le v$ and thus we need $p_B(x,y) \le \min \{ x \, : \, x \ge y \}$.
Consider the same setting for the seller and now a bid $y \in D_S$ such that $f(\omega_y,y)=0$. Let $x \in D_B$ be a bid of the buyer such that $f(x,y)=1$. By the labelling constraints we have $p_S(x,y)-u \ge p_S(\omega_y,y) \ge 0$, hence $p_S(x,y) \ge u$ for all $u$ (since $\mathcal{M}$ is single-line) and thus $p_S(x,y) \ge \max \{ y \, : \, x \ge y \}$. Thus for all $x \ge y$ we have:
\begin{gather}
p_B(x,y) \le \min \{ x \, : \, x \ge y \} = y \\
p_S(x,y) \ge \max \{ x \, : \, x \ge y \} = x
\end{gather}
Now consider the bid profile $(1,\varepsilon)$. The buyer must pay at most $\varepsilon$ while the seller is to receive at least 1, and since $\varepsilon$ is arbitrary we get the desired result.
\end{proof}
The following two results show that single-line mechanisms are overly restrictive for WNOM and by using a more general labelling we can achieve weak budget-balance. On the contrary, unbounded subsidies are unavoidable for BNOM under any labelling.
\begin{theorem}
There is an efficient, IR, WBB, WNOM mechanism.
\end{theorem}
\begin{proof}
Let $D_B=[0,1]$ and $D_S=\{0,1\}$ and consider the labelling $\omega$ in which $\omega_{jk}=1$ if and only if $t_j \ge t_k$, and 0 otherwise. Fix some bid $x$ of the buyer and observe that all cycles within the $x$-island have non-negative weight. There are only two nodes in these $x$-islands in $G_{i,f}^\omega$, namely $(x,0)$ and $(x,1)$, and due to $\omega$ there is an edge $(x,1) \rightarrow^{t} (x,0)$ for all $t \in [0,x)$ and an edge $(x,0) \rightarrow^{t} (x,1)$ for all $t \in [x,1]$. Thus the cycle $C = \langle (x,0) \rightarrow^{t_j} (x,1) \rightarrow^{t_k} (x,0) \rangle$ has weight at least $x(f(x,0)-f(x,1)) + (x-\varepsilon)(f(x,1)-f(x,0)) = \varepsilon > 0$ for positive $\varepsilon$, i.e. when $t_j = x$ and $t_k = x - \varepsilon$. There are many other cycles in $G_{i,f}^\omega$ which use incentive-compatibility edges -- we will show that the shortest of such cycles have non-negative weight, and observe that the weight of longer cycles will only increase. These cycles have the form $(x,1) \rightarrow^{x} (x+\varepsilon,0) \rightarrow^{t} (x+\varepsilon,1) \rightarrow^{x+\varepsilon} (x,1)$ for $t \in [x+\varepsilon,1]$, and its weight is minimised when $t = x+\varepsilon$; the weight of the cycle therefore at least $(-x)+(x+\varepsilon)+0 = \varepsilon$ and hence non-negative. These are the only types of cycles present in the graph induced by $\omega$, and since they are all non-negative then $f$ is WNOM-implementable. It now remains to derive the payments that this labelling produces.
Fix a bid $t_j$ of the buyer. Since $\omega_{jj}=1$ then trade does not occur and we have $v(\mathcal{M}(t_j,1))=0$ for all $v$. Since $\omega_{ij}=0$ for $t_i < t_j$ then trade occurs and we have $v - p_B(t_j,0) \le v(\mathcal{M}(t_j,1)) = 0$. Thus for all $v < t_j$ we have $p_B(t_j,0) \ge v$ and so $p_B(t_j,0)$ tends to $t_j$. Combining this with IR we have $t_j \le p_B(t_j,0) \le t_j$ and therefore when the trade occurs the buyer pays her bid, and 0 otherwise. In other words, this labelling induces first-price payments for the buyer.
Now consider payments for the seller where she gets paid her own bid when trade occurs. It is straightforward to verify that these payments for the seller are strategyproof and therefore NOM by \Cref{thm:SP-implies-NOM}. When trade occurs the payments are $p_B(x,y) = x$ and $p_S(x,y) = y$, and 0 otherwise. Since trade occurs only when $x \ge y$ then the payment given to the seller never exceeds the amount extracted from the buyer, hence we achieve (exact) weak budget balance.
\end{proof}
\begin{theorem}
There is no efficient, IR, $\alpha$-WBB, BNOM mechanism with bounded $\alpha$.
\end{theorem}
\begin{proof}
Let $f$ be an efficient allocation function for bilateral trade. We will prove the claim by case analysis of all possible labellings on the subgraph of $G_{B,f}^\beta$ containing only a $j$-island and a $k$-island for some types $t_j,t_k \in D_B$. Each general labelling falls into one of four cases: it is single-line, for which we have already proved subsidies are unbounded; it is invalid and leads to a negative cycle $G_{B,f}^\beta$, meaning payments ensuring BNOM are impossible; it induces no negative cycles in $G_{B,f}^\beta$ but otherwise leads to contradiction when taken with IR and efficiency; or it leaves us with the same payments as in the single-line case, meaning unbounded subsidies are unavoidable. The first two cases are straightforward so we will focus on the latter two.
Let $D_B=[0,1]$ and $D_S=\{0,1\}$. First note that in any valid labelling $\beta$ each $j$-island of $G_{B,f}^\beta$ will consist only of two nodes, $(t_j,0)$ and $(t_j,1)$, hence for any labelling to be valid it must be that $f(t_j,\beta_{ij}) \ge f(t_j,\beta_{kj}) \iff t_i \ge t_k$. Now fix $t_j,t_k \in D_i$ with $t_j < t_k$ and observe that by IR we have $p_B(t_j,0) \le t_j$, so either $\beta_{jj} = (t_j,0)$ or $\beta_{jj} = (t_j,1)$ and $p_B(t_j,0) = t_j$. The two cases for $\beta$ we will discuss are as follows.
\begin{figure}[ht]
\centering
\begin{subfigure}{.4\textwidth}
\centering
\ctikzfig{tikzfigs/bad-beta-1}
\caption{A valid BNOM labelling incompatible with IR and efficiency.}
\label{fig:bad-beta-1}
\end{subfigure} \quad
\begin{subfigure}{.4\textwidth}
\centering
\ctikzfig{tikzfigs/bad-beta-2}
\caption{A valid BNOM labelling that yields single-line payments.}
\label{fig:bad-beta-2}
\end{subfigure}
\caption{No BNOM labelling can achieve bounded subsidies in an efficient, IR mechanism for bilateral trade.}
\label{fig:bad-beta}
\end{figure}
\emph{Case 1: $\beta$ is incompatible with IR and efficiency.} Consider $\beta$ where $\beta_{jj} = (t_j,1)$, $\beta_{kj} = (t_j,0)$, $\beta_{kk} = (t_k,1)$, and $\beta_{jk} = (t_k,0)$. By the incentive-compatibility constraints (represented by the red edge in \Cref{fig:bad-beta-1}) we have $0 \ge t_k - p_B(t_j,0) = t_k - t_j$, a contradiction since $t_j < t_k$.
\emph{Case 2: $\beta$ leads to single-line payments.} Consider $\beta$ where $\beta_{jj} = \beta_{kj} = (t_j,0)$, $\beta_{kk} = (t_k,0)$, and $\beta_{jk} = (t_k,1)$ and whose graph $G_{B,f}^\beta$ is given in \Cref{fig:bad-beta-1} in which edges are annotated with their weights. By incentive-compatibility constraints we have $0 \ge t_j - p_B(t_k,0)$ (represented by red edge in \Cref{fig:bad-beta-2}) and hence $p_B(t_k,0) \ge t_j$, as well as $t_k - p_B(t_k,0) \ge t_k - p_B(t_j,0)$ (represented by the blue edge in \Cref{fig:bad-beta-2}) and so $p_B(t_k,0) \le p_B(t_j,0)$. Recall that we have $p_B(t_j,0) = t_j$ and therefore $t_j \le p_B(t_k,0) \le p_B(t_j,0) = t_j$, so $p_B(t_k,0) = t_j$. Now take $t_j = 0$ and we see that payments in a profile in which trade occurs are identically zero. This is precisely the issue that leads to unbounded subsidies.
Each possible labelling, even when only considering two types $t_j$ and $t_k$, falls into one of the four above mentioned cases. Thus the only valid labellings that are not incompatible with IR and efficiency lead to exactly the same payments as we get with a single-line mechanism. Hence subsidies remain unbounded for arbitrary labellings for any efficient, IR, BNOM mechanism.
\end{proof}
\subsection{Characterising IR, WBB, NOM bilateral trade mechanisms}
We close our analysis of NOM bilateral trade mechanisms by providing a full characterisation of the class of IR, WBB, NOM mechanisms for this setting. We introduce some notation to conveniently formulate our characterisation. For a number $x$ we denote by $\text{succ}_B(x)$ and $\text{prec}_B(x)$ respectively the least element in $D_B$ strictly greater than $x$ and the greatest element strictly less than $x$. We use $\text{succ}_S(y)$ and $\text{prec}_S(y)$ to analogously for the seller's domain $D_S$. Let $H_B$ denote the least element in $D_B$ that is greater than every element in $D_S$, and $L_B$ the greatest element in $D_B$ that is less than every element in $D_S$. For a mechanism we may partition the type space into three sets: $M_0^B$, $M_1^B$, and $M_{01}^B$. $M_0^B$ consists of all bids of the buyer for which trade is guaranteed not to happen, $M_1^B$ consists of all bids for which trade surely happens, and $M_{01}^B$ consists of the remaining elements of $D_B$, where trade depends on the seller's bid. The sets $M_0^S$, $M_1^S$, and $M_{01}^S$ can be defined analogously for the seller.
For a mechanism $M$ define the \emph{utility interval} $I_B(M,v,x)$ for the buyer as the two numbers $(\ell,h)$ such that $\ell = \min \{ v(M(x,y)) \, : \, y \in D_S \}$ and $h = \max \{ v(M(x,y)) \, : \, y \in D_S \}$, and define $I_S(M,u,y)$ analogously for the seller. The NOM property imposes that $I_B(M,v,v) \ge I_B(M,v,x)$ for all $v,x \in D_B$ and that $I_S(M,u,u) \ge I_S(M,u,y)$ for all $u,y \in D_S$.
\begin{theorem}
A deterministic bilateral trade mechanism $M$ for domains $D_B,D_S$ is IR, WBB, and NOM if and only if there are thresholds $p_B^{\min},p_B^{\max},p_S^{\min},p_S^{\max}$, where $p_B^{\min} \le p_B^{\max}$ and $p_S^{\min} \le p_S^{\max}$, such that:
\begin{enumerate}[topsep=0pt]
\item When trade doesn't occur the buyer's and the seller's price are both zero. When trade occurs the buyer's price always exceeds the seller's price, both prices are non-negative, the buyer's price is less than their valuation, and the seller's price is at least the buyer's valuation.
\item The set $M_0^B$ contains all types in $D_B$ less than $p_B^{\min}$, the set $M_1^B$ contains all types in $D_B$ greater than $p_B^{\max}$, and $M_{01}^B$ contains all types in $D_B$ in between $p_B^{\min}$ and $p_B^{\max}$. If $p_B^{\min}$ is itself in $D_B$ then $p_B^{\min}$ is in either $M_0^B$ or $M_{01}^B$. Similarly if $p_B^{\max}$ is in $D_B$ then $p_B^{\max}$ is in either $M_1^B$ or $M_{01}^B$.
\item For every type $x \in M_{01}^B \cup M_1^B$ the buyer's payment in outcome $M(x,y)$ is at least $p_B^{\min}$ for all $y \in D_S$, and there exists some $y \in D_S$ such that in outcome $M(x,y)$ trade occurs and the buyer pays $p_B^{\min}$. For every type $x \in M_1^B$ the buyer's payment in outcome $M(x,y)$ is at most $p_B^{\max}$ for all $y \in D_S$, and there exists a $y \in D_S$ such that in outcome $M(x,y)$ trade occurs at price $p_B^{\max}$.
\item (Analogous to point 2 but for the seller) The set $M_0^S$ includes all types in $D_S$ greater than $p_S^{\max}$, the set $M_1^S$ includes all types in $D_S$ less than $p_S^{\min}$, and the set $M_{01}^S$ consists of all types in $D_S$ in between $p_S^{\min}$ and $p_S^{\max}$. If $p_S^{\min}$ itself is in $D_S$, then $p_S^{\min}$ is either in $M_1^S$ or $M_{01}^S$. Similarly, if $p_B^{\max}$ is in $D_S$ then $p_B^{\max}$ is in $M_{01}^S$ or $M_1^S$.
\item (Analogous to point 3 but for the buyer) For every type $y \in M_{01}^S \cup M_1^S$ there is some $x \in D_B$ such that in outcome $M(x,y)$ trade occurs with seller's price $p_S^{\max}$. For every type $y \in M_1^S$ there is furthermore a $x \in D_B$ such that in outcome $M(x,y)$ trade occurs at price $p_S^{\min}$.
\end{enumerate}
\end{theorem}
\begin{proof}
($\implies$) Assume that $M$ is IR, WBB, and NOM. Point 1 follows directly from IR and WBB. We will prove points 2 and 3, and since the proofs of points 4 and 5 follow analogous reasoning they are omitted. We assume for simplicity of exposition that $M_0^B$, $M_{01}^B$, and $M_1^B$ are all non-empty. In case one or more of these sets are empty, the proof reduces to a simpler one.
Let $x_0^{\max}$ be the greatest type in $M_0^B$ and let $x$ be an arbitrary type less than $x_0^{\max}$. We show that $x$ is in $M_0^B$. Suppose the contrary and let $y$ be a seller's type such that trade occurs in outcome $M(x,y)$. The buyer's price in $M(x,y)$ is at most $x$ by IR, and hence it is less than $x_0^{\max}$. This means that the second element of $I_B(M,x_0^{\max},x)$ is positive, while $I_B(M,x_0^{\max},x_0^{\max}) = (0,0)$; a contradiction to NOM. We have now established that $x$ is in $M_0^B$ for all $x$ in $D_B$ where $x \le x_0^{\max}$.
Let $x_1^{\min}$ be the least type in $M_1^B$ and let $x$ be an arbitrary type greater than $x_1^{\min}$. We show that $x$ is in $M_1^B$. Suppose the contrary; then the first element of $I_B(M,x,x)$ is 0. However note that any buyer's price charged when reporting $x_1^{\min}$ is less than $x_1^{\min}$ itself by IR, and hence is less than $x$. This would mean that the first element of $I_B(M,x,x_1^{\min})$ is positive; a contradiction to NOM. We have now established that $x$ is in $M_1^B$ for all $x$ in $D_B$ where $x \ge x_1^{\min}$.
The above altogether shows that $M_0^B$, $M_{01}^B$, $M_1^B$ partition $D_B$ into three contiguous ranges: $M_0^B$ consists of all valuations in $D_B$ up to and including $p_0^{\max}$, $M_{01}^B$ consists of all valuations in $D_B$ strictly in between $p_0^{\max}$ and $p_1^{\min}$, and $M_1^B$ consists of all valuations in $D_B$ from $p_1^{\min}$ and up.
Let $x$ be a type in $M_{01}^B \cup M_1^B$, and let $y$ be the seller's bid such that the buyer's price is minimised in outcome $M(x,y)$. Denote this price by $p(x)$. Thus we have that the second element of $I_B(M,x,x)$ is $x - p(x)$. By NOM, for any other bid $x'$ we have that the second element of $I_B(M,x,x')$ is at most $x - p(x)$. In particular for $x'$ in $M_{01}^B \cup M_1^B$ it holds that the second element of $I_B(M,x',x')$ is $x' - p(x')$ and thus the second element of $I_B(M,x,x')$ is $x - p(x')$. Thus, $x - p(x') \le x - p(x)$, or equivalently $p(x) \le p(x')$. Since this inequality holds for all $x,x'$ in $M_{01}^B \cup M_1^B$, we have that $p(\cdot)$ is constant over $M_{01}^B \cup M_1^B$, and we define this constant as $p_B^{\min}$. Observe that $p_B^{\min}$ is at most the least type in $M_{01}^B$, by IR (i.e., the type $\text{succ}_B(x_0^{\max}))$. Furthermore $p_B^{\min} \ge x_0^{\max}$ because otherwise the second element of $I_B(M, x_0^{\max}, \text{succ}_B(x_0^{\max}))$ would equal $x_0^{\max} - p_B^{\min} \ge x_0^{\max} - x_0^{\max} = 0$, where 0 is the second element of $I_B(M,x_0^{\max},x_0^{\max})$; a contradiction to NOM. This establishes that the value $p_B^{\min}$ lies in the interval $[x_0^{\max}, \text{succ}_B(x_0^{\max})]$, as required from points 2 and 3 in the claim.
Let $x$ now be a type in $M_1^B$, and let $y$ be the seller's bid such that the buyer's price is maximised in outcome $M(x,y)$. Denote this price by $P(x)$. Thus, the first element of $I_B(M,x,x)$ is $x - P(x)$, for all $x \in M_1^B$. Also, this implies that the first element of $I_B(M,x,x')$ is $x - P(x')$ for all $x,x' \in M_1^B$, which in turn yields that $P(x) \le P(x')$ for all $x,x' \in M_1^B$, and hence $P(\cdot)$ is constant on $M_1^B$. Let this constant be the value of $p_B^{\max}$.
Note that $p_B^{\max}$ is at most $x_1^{\min}$, by IR. Furthermore, $p_B^{\max} \ge \text{prec}_B(x_1^{\min})$, as otherwise the first element of $I_B(M, \text{prec}_B(x_1^{\min}), x_1^{\min})$ would be positive. The first element of $I_B(M, \text{prec}_B(x_1^{\min}), \text{prec}_B(x_1^{\min}))$ is 0; contradicting with NOM. This proves that points 2 and 3 of the claim hold.
($\impliedby$) Assume that the 5 points of the claim hold for a mechanism $M$. We show that M is IR, WBB, and NOM. The first two properties, IR and WBB, follow trivially from point 1. We next show that NOM holds for the buyer. The proof for the NOM-property for the seller is analogous and is therefore omitted.
Let $x$ be a bid in $M_0^B$ so that $I_B(M,x,x) = (0,0)$. Obviously, $I_B(M,x,x') = (0,0)$ for all $x' \in M_0^B$, as desired. For $x' \in M_{01}^B$ we know that the first element of $I_B(M,x,x')$ is 0 by definition of $M_{01}^B$. The second element of $I_B(M,x,x')$ is $x - p_B^{\min}$ by point 3, and $p_B^{\min}$ is at least $x$ by point 2, thus $x - p_B^{\min}$ is non-positive and $I_B(M,x,x) \ge I_B(M,x,x')$ for all $x' \in M_{01}^B$, as desired. For $x' \in M_1^B$ we have $I_B(M,x,x') = (x - p_B^{\max}, x - p_B^{\min})$, and both these expressions are negative as $p_B^{\max}$ and $p_B^{\min}$ are both at least $x$. Hence $I_B(M,x,x) \ge I_B(M,x,x')$ for all $x' \in M_1^B$, as desired. This establishes that $I_B(M,x,x) \ge I_B(M,x,x')$ for all $x' \in D_B$ and $x \in M_0^B$.
Next, let $x$ be a bid in $M_{01}^B$, so that $I_B(M,x,x) = (0,x - p_B^{\min})$. For $x' \in M_0^B$ we have that $I_B(M,x,x') = (0,0) \le I_B(M,x,x)$. For $x' \in M_{01}^B$ we have that $I_B(M,x,x) = I_B(M,x,x')$ by definition of $M_{01}^B$ and the properties of $p_B^{\min}$ stated under point 3 of the claim. For $x' \in M_1^B$ we have $I_B(M,x,x') = (x - p_B^{\max}, x - p_B^{\min})$. Since $p_B^{\max} \ge x$ the expression $x - p_B^{\max}$ is non-positive, so also in this case we have $I_B(M,x,x) \ge I_B(M,x,x')$. This establishes that $I_B(M,x,x) \ge I_B(M,x,x')$ for all $x' \in D_B$ and $x \in M_{01}^B$.
Lastly let $x$ be a bid in $M_1^B$, so that $I_B(M,x,x) = (x - p_B^{\max}, x - p_B^{\min})$. For any bid $x' \in M_0^B \cup M_{01}^B$ we have that trade may not occur, so that the first element of $I_B(M,x,x')$ is 0, which is less than or equal to $x - p_B^{\max}$. If $x' \in M_0^B$ then also the second element of $I_B(M,x,x')$ is 0, again less than $x - p_B^{\min}$. If $x' \in M_{01}^B$ then the second element of $I_B(M,x,x')$ is $x - p_B^{\min}$, equal to the second element of $I_B(M,x,x)$. Thus $I_B(M,x,x) \ge I(M,x,x')$ for all $x' \in M_0^B \cup M_{01}^B$. For a bid $x' \in M_1^B$ it simply holds that $I_B(M,x,x') = (x - p_B^{\max}, x - p_B^{\min}) = I_B(M,x,x)$, by the properties of $p_B^{\max}$ and $p_B^{\min}$ in point 3 of the claim. This establishes that $I_B(M,x,x) \ge I_B(M,x,x')$ for all $x' \in D_B$ and $x \in M_1^B$. Altogether this yields that $I_B(M,x,x) \ge I_B(M,x,x')$ for all $x,x' \in D_B$, i.e. $M$ is NOM for the buyer.
\end{proof}
\section{Conclusions}
In this paper we have provided a series of results showing that NOM does not trivialise the issues surrounding incentives, even in presence of monetary transfers. It may still be impossible to obtain strong guarantees even if one assumes that imperfectly rational agents will only deviate when it is easy for them. Therefore, we believe that NOM mechanisms deserve to be better understood.
Remaining with bilateral trade, we have shown that we cannot achieve all of efficiency, IR, BNOM, and $\alpha$-WBB with bounded $\alpha$: what can we gain if we also settle for approximate efficiency? For single-parameter agents, we have shown that an allocation function is BNOM- and WNOM-implementable if and only if it is overlapping, and that when this is the case a single-line labelling is sufficient to define the payments. It would be interesting to further explore what can be gained using a more general labelling than single-line, and it is surprising that while this can alleviate the issues of unbounded subsidies in bilateral trade for WNOM, the same is not true for BNOM. In a similar vein, we have largely treated BNOM and WNOM as two sides of the same coin, until they begin to diverge in \Cref{sec:bilateral-trade}. Similarly to \cite{Aziz2020}, it would be useful to further explore how the two sides of NOM relate to one another, as well as the computational aspects of using NOM mechanisms. Finally, we believe that the cycle monotonicity framework we have introduced should help tackle multidimensional domains.
|
{'timestamp': '2022-02-15T02:43:09', 'yymm': '2202', 'arxiv_id': '2202.06660', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06660'}
|
arxiv
|
\section{Introduction}\label{sec:introduction}
Voter coercion and vote buying represents a significant potential risk for remote
electronic voting
(e-voting)~\cite{park2021BadToWorse,daian2018DarkDAOs,benaloh1994ReceiptfreeSecretBallot,juels2010CoercionResistantElections,clarkson2008Civitas,spycher2012JCJLinearTime}
as voters
are capable of casting votes in an unsupervised location and generally capable of
verifying that their votes were cast as intended.
A malicious actor, known as the coercer, could then demand that the voter cast the coercer-intended vote, demand that the voter hand over their voting credential, or
demand that the voter abstain from voting.
Coercion resistance, as defined by Juels, Catalano and Jakobsson (JCJ),
ensures that the coercer cannot determine
whether a targeted voter complies with the demands of the
coercer~\cite{juels2010CoercionResistantElections}.
JCJ proposes the use of fake voting credentials
that the voter could use to evade coercion:
if the coercer instructs the voter to cast the coercer-intended vote,
the voter casts the coerced vote using their fake credential.
If the coercer demands that the voter hand over their real credential,
the voter could instead hand over their fake credential.
When the voter obtains a moment of privacy away from the coercer,
they can then use their \emph{real} credential to cast a real vote.
However, existing coercion-resistant e-voting systems assume that voters
have access to an untappable channel between themselves and a registrar and have
access to an incorruptible device during voter registration to retrieve their real
credential~\cite{juels2010CoercionResistantElections,clarkson2008Civitas,krips2019CRSummary,spycher2012JCJLinearTime}.
This appears to be an unreasonable assumption in the real world,
because a coercer
could reasonably demand that the voter use a coercer-controlled device to
perform voter registration, revealing the voter's real credential in the process.
In this paper, we design, implement and evaluate \textsc{TRIP}\xspace,
an in-person voter registration scheme that enables the voter to
create real and fake credentials without the use of a trusted device.
The in-person component of our scheme provides the voter with the necessary \emph{privacy}
to receive their real and fake credentials while inside a registrar-controlled booth.
Inside this privacy booth, the voter is prohibited from bringing any outside devices,
which would prevent a voter from validating the \emph{integrity}
of their real credential.
A key insight in our work is that the voter will follow the interactive
steps involved in constructing a zero-knowledge proof
and then at a later time, any device the voter trusts can be used to verify the
cryptographic portion of the proof.
With \textsc{TRIP}\xspace, the voter obtains an enforced moment of privacy inside a booth while
remaining confident of the integrity of their real credential.
\textsc{TRIP}\xspace also presents two extensions, standing votes and vote limiting, that
resolve known challenges in the JCJ scheme~\cite{koenig2011PreventingFloodingVotes}.
The standing vote extension enables voters who are under extreme coercion, e.g.,\xspace
incapable of concealing their real credential from a coercer,
with the ability to delegate their vote to a well-known entity, e.g.,\xspace political party.
The vote-limiting extension enables the election authority to cap the number of votes
cast per voter and thus prevents overwhelming the tallying process.
We detail the standing votes and vote limiting extensions
in Appendix~\ref{apx:standingVotes} and \cref{apx:vote_limiting}, respectively
and refer to them in the main body of the paper when relevant.
To evaluate the usability of \textsc{TRIP}\xspace,
we implement and deploy a mock voter registration station inside a classroom
and recruit 41 doctoral students across all disciplines at a university
to retrieve their voting credentials and cast votes in a fictitious election.
We find that while \textsc{TRIP}\xspace suffers in usability compared to
credential distribution mechanisms relying on a trusted registrar~\cite{neto2018CredentialsDistributionUsability}
(real credential sent by email and password set during in-person signup),
42.5\% of participants did grade the usability of \textsc{TRIP}\xspace with a B or higher.
Further, the usability study revealed an encouraging learnability score, meaning that
participants felt they did not need the support of a technical person to
use the system nor need to learn a lot of things before using the system.
Usability studies are rare in the coercion-resistant e-voting literature~\cite{krips2019CRSummary}
and we believe this study on \textsc{TRIP}\xspace provides further evidence
that coercion-resistant e-voting systems can be usable in practice,
even in a setting where the voter interacts with an untrusted registrar-controlled device.
In this paper, we make the following contributions:
\begin{itemize}[leftmargin=*]
\item We introduce the first in-person voter registration scheme
that enables voters create their real credential in a verifiable manner
\emph{without a trusted device}.
\item We introduce two deployable extensions to \textsc{TRIP}\xspace,
one which enables voters to cast standing votes when under extreme coercion
and one which enables vote limiting to optimize the tallying process.
\item We implement a low-cost, low-power version of \textsc{TRIP}\xspace and
evaluate its power consumption to operate in environments
with intermittent power outages.
\item We design, implement and conduct a preliminary usability study demonstrating its promise,
namely that \textsc{TRIP}\xspace offers the first systematic evidence that it may
be feasible for usable e-voting systems to be coercion resistant
without assuming a trusted registrar.
\end{itemize}
\section{Background and Related Work}\label{sec:background}
In this section,
we present an overview of coercion problem in e-voting,
we summarize the JCJ
coercion-resistant remote e-voting scheme,
and we analyze existing work on voter registration for
coercion-resistant e-voting.
\subsection{The Coercion Problem in E-Voting}
The coercion problem in e-voting systems was initially presented
by Benaloh and Tuinstra~\cite{benaloh1994ReceiptfreeSecretBallot} and
independently by Niemi and Renvall~\cite{niemi1994PreventVoteBuying}.
Benaloh and Tuinstra introduced the notion of \emph{receipt-freeness},
informally stated as a voter incapable of proving to an adversary that they
voted in a specific way, even if the voter is willing to disclose their vote.
JCJ demonstrated that systems based solely on receipt-freeness
are vulnerable to at least one of the following three real world attacks:
\emph{Randomization Attack}: forcing voters to submit invalid votes,
\emph{Forced Abstention Attack}: refrain voters from voting, and
\emph{Simulation Attack}: forcing voters to divulge their voting credential.
JCJ then introduced the notion of coercion-resistance, informally stated
as the adversary being incapable of determining whether a coerced voter complies
with the adversary's demands, even if a dishonest voter is willing to comply.
\parhead{Fake Credentials}
The JCJ approach is to use fake credentials to cast fake votes and real credentials
to cast real votes, while ensuring that fake and real votes are indistinguishable.
During the tallying phase, fake votes are removed and only the real votes would
remain via some verifiable and anonymous process.
We note that credentials are meant to be used in numerous elections.
While other anti-coercion strategies have also been proposed,
such as deniable re-voting~\cite{achenbach2015JCJDeniableRevoting,lueks2020VoteAgain},
and proxy voting~\cite{kulyk2017CRProxyVoting},
we opt for the usage of fake credentials.
In deniable re-voting, the voter has a single credential
which is capable of overriding previously cast votes in a deniable manner, but
the voter must obtain a moment of privacy after being coerced and before the voting
phase ends.
In proxy voting, the voter delegates their vote to a trusted third party, but
the voter no longer has control over the contents of their ballot.
Fake credentials could reduce the number of coerced moments
when the coercer demands the voter's real credential as upon successfully deceiving
the coercer with a fake credential, the voter is less likely to receive further demands
from the coercer.
\subsection{Coercion-Resistant E-Voting Scheme}\label{background:JCJScheme}
JCJ consists of four actors (registrar, authority, ledger and voters) and three main phases:
\parhead{Registration} The registrar authenticates the identity of voters,
provides each eligible voter with their real credential via some untappable channel
between the registrar and the voter and publishes the \emph{encrypted}
real credential of each voter onto a public ledger.
\parhead{Voting} For each voting event, the voter casts onto the ledger
a digitally signed encrypted ballot using their real credential.
If the voter is under coercion, the voter generates a fake credential
and uses this credential to comply with the demands of the coercer.
There is no practical limit on the number of fake credentials
and thus malicious actors could cast countless fake ballots.
\parhead{Tallying} The authority retrieves and verifies the content published on the ledger,
and produces a verifiable tally result without revealing
the association between credentials and ballots while filtering the real ballots
from the fake ballots.
\subsection{Voter Registration}\label{background:voter_registration}
Existing coercion-resistant e-voting schemes focus primarily on the tallying process,
and thus assume an untappable channel between the voter and the registrar with an
incorruptible device held by the voter during voter registration without addressing how that
would be accomplished in practice.
Let's then envision how this could work in practice.
We know that an untappable channel is necessary because a coercer could easily perform
an over-the-shoulder attack, where the coercer stands next to the voter and watches the
voter perform voter registration, revealing every action.
It would then seem that the voter must be forcibly given a private moment away from the coercer,
which could only be reasonably enforced by a third party,
revealing the need for in-person registration.
However, what if the registrar is malicious?
How do voters ensure the \emph{integrity} of their real credential?
JCJ suggests that trust is split among distinct
entities, which would not usually be an issue remotely. But in person, how would this work?
A voter first identifies themselves to a registration official to
receives a share of their real credential.
When finished, the voter must interact with another registration official
and complete the same steps to retrieve another share of their real credential.
The voter yet again must interact with another registration official to obtain
another credential share.
While not the most practical process, it could manage as long as the voter
has some incorruptible device with them, or do they?
We do not believe its reasonable to expect voters to have a trusted device with them
because the coercer could demand the voter to record their entire voter registration
session on the device, or even be watching via some alternative device.
The registrar then enforces a no device policy, meaning that the voter must now interact
with numerous voter registration officials all in paper format!
On top of it all, the optimal deployment involves the voter interacting with numerous
registration officials at \emph{distinct} registration offices
to help limit the effect of collusion between officials.
We conclude that expecting ordinary voters to interact with multiple independent
registrars in an in-person registration process with no trusted device appears impractical,
so we seek a different way to make a (single) registrar less trusted
in a usable in-person registration ceremony.
To our knowledge, there exists only one paper by Krivoruchko~\cite{Krivoruchko2007CRVoterRegistration}
that focuses exclusively on coercion-resistant voter registration.
Krivoruchko proposes that the voter creates their own real credential before communicating
with the registrar and then provide the credential during the untappable interaction
with the registrar.
However, this suffers from the same problem: the voter still needs access to
a trusted device to participate in the voter registration process.
Further
this subjects voters to an attack where the
coercer strips voters of any credentials and supplying voters with
only a coercer-controlled credential before
they enter the registration office.
Now that we have established that the voter doesn't have access to
a trusted device, how should a credential be transferred in physical form
between the registrar and the voter?
There are proposals to use smart
cards~\cite{neumann2012CivitasRealWorld,neumann2013SmartCards2,feier2014CRSmartCards,estaji2020UsableCRSmartCards}
but trusted hardware opens up a world of problems, such as having to trust
the smart card containing the voter's real credential.
Not only do smart cards carry all of the security concerns
associated with trusted hardware, but they
incur significant costs to the election authority,
produce environmental waste and
may encounter resistance from smart card vendors~\cite{krips2019CRSummary}.
In our scheme, voters interact with a single registrar-controlled
device, which provides voters with their real credential via QR codes printed on paper,
making it far more secure and cheaper than trusted hardware.
The integrity of a real credential depends solely on its creation process
and we design the physical credential in a manner that ensures privacy
until its ready for activation by the voter.
\section{Implementation \& Evaluation}
In this section we introduce and evaluate
a low-cost, low-power, portable prototype of the kiosk.
\parhead{Software}
The software is implemented in about
750 lines of Go code~\footnote{\href{https://go.dev}{go.dev}}
and utilizes Kyber\footnote{\href{https://github.com/dedis/kyber}{github.com/dedis/kyber}}
to perform cryptographic operations
and gozxing\footnote{\href{https://github.com/makiuchi-d/gozxing}{github.com/makiuchi-d/gozxing}} for QR code operations.
We utilize the M-ElGamal encryption scheme~\cite{juels2010CoercionResistantElections},
the Schnorr signature scheme~\cite{schnorr1991DiscreteLogarithmProof},
and the SHA-256 hash function.
Finally, we adapt the signature scheme and encryption scheme to work with elliptic curve group
Ed25519 as, in practice, QR codes present significant usability challenges
(e.g.,\xspace QR code size, scanning) with the increase in number of bytes that needs to be embedded.
\parhead{Prototype}
Our prototype consists of the components described in appendix~\ref{apx:prototype}, table~\ref{tab:components} for a total
cost of about \$270.66, where 51\% of the cost is associated with a 7'' touchscreen LCD.
The Pi camera is connected to the camera serial interface port on the Pi Zero
using a ribbon cable, enabling both power and data transmission.
The thermal receipt printer is connected to the Raspberry Pi's GPIO headers for data transmission
and is connected directly to power via a DC jack $\rightarrow$ USB (5-9 volts).
The touchscreen display is connected to the Raspberry Pi's Mini HDMI port
and is connected directly to power via a DC jack $\rightarrow$ USB (5 volts).
The entire prototype is capable of running off a 5V Power Bank with 3 USB
ports for a max draw of $\sim$3A (e.g.,\xspace RAVPower 22000mAh Portable Charger 3-Port
Power Bank with a total max draw of 5.8A for \$20.99).
\parhead{Power Usage}
To measure the power usage of the kiosk in milliwatt-hours (mWh),
we utilize the a USB power meter tester.
We proceed by defining 4 scenarios and plot them in~\cref{fig:powerUsage}
grouped by task and device usage for 30 min in mWh.
In the ``Idle" scenario, the screen is lit
and shows the desktop ($\sim$0.782A), the Raspberry Pi is only running the
default services ($\sim$0.13A), and the printer is on standby ($\sim$0.01A).
In the ``1 Signup" scenario, the kiosk boots up,
compiles the voter registration program, performs its side of the check-in process,
generates a real credential and a fake credential,
remains idle until 30 min since bootup has elapsed and then shuts down.
With the ``10 Signup" scenario, we disregard overhead tasks (i.e.,\xspace bootup, shutdown and compile)
and have the kiosk perform check-in, and the creation of a real and fake credential 10 times,
consecutively.
Finally, still disregarding overhead tasks, we calculate the maximum number of signups that can
be conducted in 30 minutes (17 signups) and assume that they can be done consecutively.
Using this information, we find that the prototype can remain ``Idle" with a 100Wh Power Bank
(maximum watt-hour allowed on a commercial aircraft) for about
22 hours or remain in continuous operation issuing 390 signups
(check-in, one real and one fake credential) for about 11 hours.
Assuming continuous signup (same process) of a million voters for about 11 hours per day
(390 signups) and 100 kiosk devices ($\sim$\$27000 and 10,000 voters per device),
this will roughly take 26 days.
\definecolor{first}{HTML}{67D3CC}
\definecolor{second}{HTML}{CFF67B}
\definecolor{third}{HTML}{94DAFB}
\definecolor{fourth}{HTML}{FD8080}
\definecolor{fifth}{HTML}{6D848E}
\definecolor{sixth}{HTML}{26A0FC}
\definecolor{seventh}{HTML}{26E7A6}
\definecolor{eighth}{HTML}{FEBC3B}
\definecolor{ninth}{HTML}{FAB1B2}
\definecolor{tenth}{HTML}{8B75D7}
\begin{figure}[ht]
\centering
\resizebox{\linewidth}{!}{%
\begin{tikzpicture}[
every axis/.style={
ybar stacked,
ymin=0,
x=40pt,
x tick label style={
yshift=-2mm,
xshift=-2mm,
rotate=20,
font=\small},
x axis line style = { opacity = 0 },
y axis line style = { opacity = 0 },
ylabel={30 min Power Usage (mWh)},
tickwidth = 0pt,
enlarge x limits={abs=21pt},
width=7cm,
height=6cm,
xtick distance=1,
symbolic x coords={
Idle,
1 Signup,
10 Signups,
17 Signups,
},
bar width=8pt
},
]
\pgfplotsset{
labelplot/.style 2 args={
forget plot,
draw=none,
nodes near coords=#1,
every node near coord/.style={below,font=\tiny,xshift=#2}
}
}
\begin{axis}[
bar shift=-14pt,
xticklabels={},
legend pos=outer north east,
legend style={nodes={scale=0.7, transform shape}},
reverse legend
]
\addplot [labelplot={Task}{-14pt}] coordinates
{(Idle,0) (1 Signup,0) (10 Signups,0) (17 Signups,0)};
\addplot[color=first,fill=first] coordinates
{(Idle,0) (1 Signup,118) (10 Signups,0) (17 Signups,0)};
\addplot[color=second,fill=second] coordinates
{(Idle,0) (1 Signup,38) (10 Signups,0) (17 Signups,0)};
\addplot[color=third,fill=third] coordinates
{(Idle,0) (1 Signup,8) (10 Signups,80) (17 Signups,136)};
\addplot[color=fourth,fill=fourth] coordinates
{(Idle,0) (1 Signup,130) (10 Signups,1300) (17 Signups,2210)};
\addplot[color=fifth,fill=fifth] coordinates
{(Idle,0) (1 Signup,118) (10 Signups,1180) (17 Signups,2006)};
\addplot[color=sixth,fill=sixth] coordinates
{(Idle,2305) (1 Signup,2002) (10 Signups,973) (17 Signups,32)};
\addplot[color=seventh,fill=seventh] coordinates
{(Idle,0) (1 Signup,15) (10 Signups,0) (17 Signups,0)};
\legend{Bootup,Compiled,Check-In,Real Token,Test Token,Idle,Shutdown}
\end{axis}
\begin{axis}[
bar shift=0pt,
legend pos=outer north east,
legend style={nodes={scale=0.7, transform shape}},
legend style={at={(1.03,0.2)},anchor=west},
reverse legend,
]
\addplot [labelplot={Device}{0pt}] coordinates
{(Idle,0) (1 Signup,0) (10 Signups,0) (17 Signups,0)};
\addplot+[color=eighth,fill=eighth] coordinates
{(Idle,325) (1 Signup,335) (10 Signups,377) (17 Signups,413)};
\addplot+[color=ninth,fill=ninth] coordinates
{(Idle,25) (1 Signup,141) (10 Signups,1191) (17 Signups,2006)};
\addplot+[color=tenth,fill=tenth] coordinates
{(Idle,1955) (1 Signup,1952) (10 Signups,1965) (17 Signups,1972)};
\legend{Pi + Cam,Printer,Screen}
\end{axis}
\end{tikzpicture}
}%
\label{fig:powerUsage}
\caption{Kiosk Power Usage by Task and by Device}
\end{figure}
\section{Voter Registration Scheme}\label{sec:scheme}
In this section, we present our voter registration scheme along with any
modifications necessary in the JCJ scheme.
\parhead{Notations}
Let $\secpar \in \NN$ be a security parameter.
We denote with $s \sample S$ a random uniform sampling of $s$ from the set $S$.
We also denote with $a \gets b$ as assignment of $b$ to $a$ and $a \Leftarrow b$
as appending $b$ to $a$.
Finally, we denote $\vec{c}$ as a set of elements $c$.
\textsc{TRIP}\xspace uses four cryptographic primitives:
(1) the modified ElGamal (M-ElGamal) scheme defined in JCJ~\cite{juels2010CoercionResistantElections},
(2) a EUF-CMA singature scheme,
(3) a cryptographic secure hash function, and
(4) an interactive zero-knowledge proof of equality of discrete logarithms.
All these primitives are formally defined in \cref{sec:crypto_primitives}.
\subsection{Setup}
We discuss the setup procedure which consists of components from JCJ's scheme
with additional components necessary for voter registration.
\parhead{Ledger}
The ledger $\L$ initializes itself to make itself accessible to all parties. There
is some mechanism that $\L$ can use to certify the bindings between public keys
and entities.
\parhead{Authority}
Each tallier runs some distributed $(t, n)$-threshold key generation protocol
for $\pcalgostyle{EG}.\kgen(G, p, g_1, g_2)$,
retaining their share of the private keys $\sk_{i,1}, \sk_{i,2}$ for itself
while producing a collective public key $A$ to be published on the ledger.
If the public key $A$ is not a generator of the group $G$, then talliers
must repeat the key generation process
given that we use $A$ as a generator for the cyclic group $G$
of prime order $q$.
\parhead{Registrar}
Each registration official generates a signing key-pair
$(r_{i}, R_{i}) \gets \sig.\kgen(\secparam)$ and
collectively populate the electoral roll $\V$
by publishing, for each voter $V_{i}$, voter information and a unique public id $V_{id}$.
In addition, registration officials initialize the kiosks in the booths by providing the
collective tallier's public key $A$ and the public keys of registration official
responsible for maintaining and issuing check-in tickets meant for that respective kiosk.
In turn, kiosks generate their own signing key-pairs
$(k_{i}, K_{i}) \gets \sig.\kgen(\secparam)$ and
display the public key $K_{i}$ to be published on the ledger $\L$
by the registration officials.
Each envelope printer also generates their own signing key-pair
$(p_{i}, P_{i}) = \sig.\kgen(\secparam)$ and collectively
supply an abundant number of envelopes $\vec{E}$ to the booths.
Each envelope's QR code consists of the printer's public key $P_{i}$,
a cryptographic nonce $c \sample \bin^{\secpar}$, and a signature
$\sigma_{p} \gets \sig.\sign(p_{i}, \pcalgostyle{H}(c))$.
For each envelope, the issuing printer publishes
$(P_{i}, \pcalgostyle{H}(c), \sigma_{p})$ to the ledger $\L$.
To reduce complexity, the rest of the scheme assumes
a single registration official with signing key-pair $(r, R)$,
a single printer with signing key-pair $(p, P)$,
and a single kiosk with signing key-pair $(k, K)$,
all working together to register a single voter $V_{i}$.
\subsection{Check-In}
As shown in~\cref{fig:check-in}, the check-in ticket $t_{in}$ consists
of the authenticated voter's unique identifier $V_{id}$,
the public key of the registration official issuing the ticket $R$,
the current timestamp $d$ and the official's signature
$\sigma_{r}$ on $(V_{id} \concat d)$.
During check-in inside the booth, the kiosk verifies that the registration
official's public key $R$ is part of the predefined list of acceptable public
keys set during $\pcalgostyle{Setup}$, verifies the integrity of the check-in
ticket with the signature $\sigma_{r}$ and ensures that
the current timestamp is relatively ``fresh" (e.g.,\xspace minutes).
\begin{figure}[ht]
\centering
\begin{pchstack}[center,boxed]
\procedure[codesize=\scriptsize]{$\pcalgostyle{CheckIn}(V_{id})$}{%
\textbf{Registration Official}((r, R), V_{id}) \< \< \\
d \gets \pcalgostyle{Time}() \< \text{\% Get current date and time} \\
\sigma_{r} \gets \sig.\sign_{r}(V_{id} \concat d) \< \text{\% Attest to the voter's identity and timestamp} \\
t_{in} \gets (V_{id} \concat d \concat R \concat \sigma_{r}) \< \text{\% Check-In ticket} \pclb
\pcintertext[dotted]{Check-In Verification}
\textbf{Kiosk}(\R, t_{in}) \< \< \\
(V_{id} \concat d \concat R \concat \sigma_{r}) \gets t_{in} \< \text{\% Retrieve ticket contents} \\
R \in \R \< \text{\% Verify official belongs to registrar} \\
\sig.\verify(R, \sigma_{r}, V_{id} \concat d) \stackrel{?}{=} \top \< \text{\% Verify official's signature} \\
d \geq \pcalgostyle{Time}() - t_{\Delta} \< \text{\% Verify timestamp is `fresh'}}
\end{pchstack}
\caption{Check-In Process.}
\label{fig:check-in}
\end{figure}
\subsection{Real Credential Creation Process}
\input{figs/latex/voter_cred_creation}
The kiosk generates the voter's credential $(v, V) \gets \sig.\kgen(\secparam)$
and M-ElGamal encrypts $V$
using the talliers' collective public key $A$, outputting the ciphertext
$V_e \gets (C_1, C_2, C_3)$ while keeping knowledge of the ElGamal secrets
$x$ and $X = A^x$.
The kiosk then performs a zero-knowledge proof
of equality of discrete logarithms~(Eq.~\ref{eq:zkp})
interactively between itself as the prover and the voter as the verifier:
\begin{equation}
\pcalgostyle{ZKPoE}_{C_1,C_2,X}\{(x): C_1 = g_1^x \land C_2 = g_2^x \land X = A^x\}.
\label{eq:zkp}
\end{equation}
The voter's role is to ensure the correct interactive
construction of the proof ($\Sigma$-protocol: commit, challenge and response)
and at a later time, the voter's supporting device will
ensure the cryptographic correctness of the proof.
Following the $\Sigma$-protocol, the kiosk first computes the \emph{commit}
$Y_1 = g_1^y$, $Y_2 = g_2^y$ and $Y_3 = A^y$ for $y \sample \ZZ_{q}$
and prints the first QR code containing the ZKP commit $Y_c = (Y_1, Y_2, Y_3)$,
the voter's encrypted credential $V_e$
along with a signature $\sigma_{k_1}$ on ($V_{id} \concat d \concat V_e \concat Y_c$).
The voter then supplies the kiosk with an envelope $e_{i} \sample \vec{E}$
containing the \emph{challenge} $c$.
The kiosk then computes the \emph{response} $r = y - cx$,
provides two distinct signatures, one for check-out and one
to attest to the variables used in this process,
and prints the last two QR codes: check-out ticket $t_{ot}$ and a QR code $q_2$.
The check-out ticket contains the information to enable the registration
official to publish $V_e$ to the ledger:
the voter's identifier $V_{id}$, the date and time of registration $d$,
and the kiosk's attestation on these values.
The QR code $q_2$ provides the necessary tools for the voter's device to verify the ZKP
on the voter's credential: voter's identifier $V_{id}$, the ElGamal shared secret $X$,
the ZKP response $r$ and the kiosk's attestation on all the values used in the process.
\subsection{Fake Credential Creation Process}
The kiosk generates a fake credential $(v', V') \gets \sig.\kgen(\secparam)$, and extracts
$C_3 \in V_e$ to \emph{derive} the ElGamal secret $X \gets C_3/V'$;
we derive $X$ from $C_3$ and $v'$ as otherwise the coercion adversary
could trivially determine whether a credential is real or fake by checking the encrypted
credential $V_e$ associated with $V_{id}$ on the public bulletin board.
By deriving the ElGamal secret $X$ in this manner, however, the kiosk has no knowledge
of an $x$ that satisfies $X = A^x$, i.e.,\xspace the discrete logarithm of $X$;
the kiosk must resort to constructing a dishonest zero-knowledge proof~(Eq. \ref{eq:zkp}),
which can only be done with the voter's help.
The kiosk thus prompts the voter to scan an envelope $e_{z\neq i} \sample \vec{E}$ containing
the challenge $c$ necessary to calculate the commit:
$(Y_1, Y_2, Y_3) \gets (g_1^y C_1^c, g_2^y C_2^c, A^y X^c)$ for some $y \sample \ZZ_{q}$;
the ZKP response is then trivial $r \gets y$.
The kiosk finally computes new signatures $\sigma_{k_1}$ and $\sigma_{k_3}$
to attest to the new values used in this
process and prints the three QR codes sequentially, where the check-out ticket $t_{ot}$
is identical to the one in the real credential creation process.
The voter can repeat this process numerous times.
\subsection{Check-Out}\label{subsec:checkout}
During check-out~(\cref{fig:check-out}), the registration official's
check-out device scans a credential $t_{ot}$
in the transport state~(Fig. \ref{fig:transport}).
The check-out device starts by verifying the authenticity of the check-out
ticket using the kiosk's signature $\sigma_{k_1}$
while verifying that the public key $K$ is in the list of kiosk public keys
set on the ledger $\L$.
Once authenticated, the registration official produces their own signature
$\sigma_{r}$ on the voter's identifier $V_{id}$, the check-in timestamp $d$,
the voter's encrypted real credential $V_e$ and the kiosk's signature
$\sigma_{k_2}$.
The registration official publishes a check-out tuple onto the ledger $\L$
containing the voter's identifier $V_{id}$,
the check-in timestamp $d$, the encrypted real credential $V_e$,
the kiosk's public key $K$, the kiosk's signature $\sigma_{k_2}$, their
public key $R$ and their signature $\sigma_{r}$.
The ledger $\L$ will notify the voter $V_{i}$ associated with $V_{id}$
about their voter registration session and provide information about how to report
any irregularities.
As an additional measure, if the voter was renewing their real credential,
then the devices associated with $V_{id}$,
could also notify the voter of the voter registration session
since it would find a new value of $V_e$ associated with $V_{id}$.
\begin{figure}[h]
\centering
\begin{pchstack}[boxed,center]
\procedure[codesize=\scriptsize,colspace=0.5cm]{$\pcalgostyle{CheckOut}(t_{ot})$}{%
\textbf{Registration Official}((r, R), t_{ot}) \< \< \\
(V_{id} \concat d \concat V_e \concat K \concat \sigma_{k_2}) \gets t_{ot} \< \text{\% Check-Out Ticket} \\
K \in \R~\text{from}~\L \< \text{\% Verify Valid Kiosk} \\
\sig.\verify(K, \sigma_{k_2}, V_{id} \concat d \concat V_e) \stackrel{?}{=} \top \< \text{\% Verify Kiosk Signature} \\
\sigma_{r} \gets \sig.\sign_{r}(V_{id} \concat d \concat V_e \concat \sigma_{k_2}) \< \text{\% Official's Signature} \\
\L \Leftarrow (V_{id}, d, V_e, K, \sigma_{k_2}, R, \sigma_{r}) \< \text{\% Publish on Ledger} }
\end{pchstack}
\caption{Check-Out Process}
\label{fig:check-out}
\end{figure}
\subsection{Activation Process}\label{sec:scheme:activate}
During this process~(Fig.~\ref{fig:protocol:activate}),
the voter's device receives the content from QR codes $q_1$, $e$, $q_2$
and verifies the integrity of the voter registration session while storing
the voter's credential private key $v$ if the voter desires
to use this device for casting votes.
To verify the integrity of the voter registration process,
the voter's device performs
(1) an offline verification using only
the values given by the credential and
(2) an online verification
using the values posted on the ledger.
During the offline verification process, the voter's device checks
the kiosk's signatures $\sigma_{k_1}$ and $\sigma_{k_3}$ on the receipt's contents,
the envelope printer's signature $\sigma_{p}$ on the envelope challenge
and assuming the voter has pre-loaded their identity $V_{id}$,
verifies that the voter's identity matches the one on the receipt.
Further, the voter's device derives the ElGamal secret $X$ from $C_3$ and $v$
and verifies the zero-knowledge proof of
equality of discrete logarithms~(Eq.~\ref{eq:zkp}).
During the online verification process,
the voter's device retrieves the items posted on the ledger $\L$ alongside $V_{id}$
and verifies whether the credential is from the latest voter registration session
using $V_e$ and $d$.
Next, the voter's device checks whether the registration official's public key $R$
is authorized and whether the kiosk's public key $K$ is also authorized.
The voter's device also checks the kiosk's signature $\sigma_{k_2}$ and the registration
official's signature $\sigma_{r}$ on their respective values.
Finally, the voter's device checks that the hash of the envelope's challenge
is on the ledger and that the challenge has not yet been posted on the ledger.
\begin{figure}[h]
\centering
\begin{pchstack}[boxed,center]
\procedure[codesize=\scriptsize,colspace=-0.5cm]{$\pcalgostyle{Activate}(q_1, e, q_2)$}{%
\textbf{Voter Device}(V_{id}) \pclb
\pcintertext[dotted]{Offline Verification}
((V_e \concat Y_c \concat \sigma_{k_1}), (P, c, \sigma_p), (V_{id}' \concat d \concat v \concat r \concat K \concat \sigma_{k_3})) \gets (q_1, e, q_2) \< \< \\
V \gets \sig.\pubkey(v) \< \text{\% Get Public Key} \\
\sig.\verify(K, \sigma_{k_1}, V_{id} \concat d \concat V_e \concat Y_c) \< \text{\% Receipt Integrity Check 1}\\
\sig.\verify(K, \sigma_{k_3}, V \concat \hash(V_{id} \concat d \concat V_e \concat v \concat Y_c \concat c \concat r)) \stackrel{?}{=} \top \< \text{\% Receipt Integrity Check 2} \\
\sig.\verify(P, \sigma_p, H(c)) \stackrel{?}{=} \top \< \text{\% Envelope Integrity Check} \\
V_{id}' \stackrel{?}{=} V_{id} \< \text{\% Voter Identity Check} \\
(C_1, C_2, C_3) \gets V_e; X \gets C_3 / v \< \text{\% Retrieve ElGamal secret} \\
Y_{1} \stackrel{?}{=} g_1^r C_1^c;\t Y_{2} \stackrel{?}{=} g_2^r C_2^c;\t Y_{3} \stackrel{?}{=} A^y X^c \< \text{\% Verify ZKP on $C_1, C_2, C_3$} \pclb
\pcintertext[dotted]{Online Verification}
(d', V_e', K', \sigma_{k_2}, R, \sigma_{r}) \gets \pcalgostyle{Get}(\L, V_{id}) \< \text{\% Voter Reg. Session} \\
d' \stackrel{?}{=} d \land V_e' \stackrel{?}{=} V_e \< \text{\% Fresh receipt} \\
R \in \R~\text{from}~\L \land K' \in \K~\text{from}~\L \< \text{\% Eligible Official \& Kiosk} \\
K \stackrel{?}{=} K' \land \sig.\verify(K, \sigma_{k_2}, V_{id} \concat d \concat V_e) \stackrel{?}{=} \top \< \text{\% Verify Kiosk Signature} \\
\sig.\verify(R, \sigma_{r}, V_{id} \concat d \concat V_e \concat \sigma_{k_2}) \stackrel{?}{=} \top \< \text{\% Verify Official Signature} \\
(P, \hash(c), \sigma_{p}) \in \L \land c \notin \L \< \text{\% Challenge Exists \& Unused}}
\end{pchstack}
\caption{Credential Activation Process}
\label{fig:protocol:activate}
\end{figure}
\subsection{Voting}\label{sec:scheme:voting}
Since voting is not our main contribution, we present the JCJ voting procedure, which our scheme
is compatible with; however, we do present a proposed voting procedure that is required for our threat
model and the enabling of the vote limiting extension.
\parhead{Original Voting Procedure}
In JCJ, the voter selects a vote option $c_j$ from a set of voting options $\vec{c}$
defined by the registrar,
and the voter's device casts a ballot $B = (E_1, E_2, P_f)$
where $E_1$ is the M-ElGamal encryption of $c_j$ with $A$,
$E_2$ is the M-ElGamal encryption of the voter's credential $V$ with $A$
and $P_f$ are various \nizk~proofs of knowledge.
\parhead{\textsc{TRIP}\xspace Voting Procedure}\label{sec:scheme:our_voting_scheme}
The ledger accepts ballots consisting of the following format:
$B = (E_1, E_2, P_f, \epsilon, V, \sigma_{v})$,
where $E_1$ and $E_2$ are identical to JCJ, $\epsilon$ is a voting event identifier,
and $\sigma_{v}$ is a digital signature
on $E_1, E_2, P_f$ and $\epsilon$: $\sig.\sign(v, E_1 \concat E_2 \concat P_f \concat \epsilon)$.
$P_f$ would need to contain a verifiable proof that $E_2$ is an encryption of $V$ (fifth item in the tuple);
$E_2$, the encryption of the credential $V$, remains since it is an integral part of the JCJ tallying process.
As an added benefit, whether or not re-voting is allowed, the ledger can either prevent or present
the subsequent ballots, further reducing the workload on the tally operation.
The tallying process remains identical to the one in JCJ's scheme but using only the values
$(E_1, E_2, P_f)$ from each ballot $B_{i}$ posted on the ledger for the relevant voting event
$\epsilon$.
\parhead{Vote Limiting}
To enable vote limiting, where the ledger only accepts ballots with a pre-approved credential,
i.e.,\xspace a credential that has been signed by a kiosk, this requires a slight adaptation to
the $\pcalgostyle{activate}$ protocol and a weaker integrity adversary
as further described in \cref{apx:vote_limiting}.
\parhead{Standing Votes}
To enable standing votes, where the voter delegates their vote to a well-known entity
(e.g.,\xspace political party), this requires a slight technical adaptation to the kiosk and a
weaker integrity and privacy adversary as described in \cref{apx:standingVotes}.
\section{Conclusion}
\textsc{TRIP}\xspace is a coercion-resistant in-person voter registration scheme
with an untrusted registration kiosk, enabling voters to securely
create a verifiable real voting credential and numerous fake credentials without a trusted device
during voter registration.
\textsc{TRIP}\xspace also enables voters under extreme coercion to
cast standing votes instead of creating their real credential.
\textsc{TRIP}\xspace can optimize the tallying process by limiting the number of credentials
issued per voter.
We design, implement and evaluate a low-cost, low-power, portable kiosk prototype
for hard to reach environments and find that the kiosk can run signups
continuously for 11 hours or stay idle for 22 hours with a 100Wh power bank.
Finally, we conducted a usability study on \textsc{TRIP}\xspace, leading to promising results
given the usability challenges of any coercion-resistant approach.
\section{Cryptographic primitives}\label{sec:crypto_primitives}
In this section we formally introduce the cryptographic primitives used by \textsc{TRIP}\xspace.
\parhead{M-ElGamal Encryption Scheme}
\textsc{TRIP}\xspace employs the modified ElGamal (M-ElGamal) encryption scheme
as defined in JCJ~\cite{juels2010CoercionResistantElections}.
This scheme is parametrized by
a cyclic group $G$ of prime order $q$ and two distinct, random generators $g_1$, $g_2$;
and consists of the following algorithms:
$\pcalgostyle{EG}.\kgen(G, q, g_1, g_2)$
which takes as input the group definition
and outputs a public key $\pk$ along with two private keys $\sk_1, \sk_2$
such that
$\pk=g_1^{\sk_1}g_2^{\sk_2}$ where $\sk_1, \sk_2 \sample \ZZ_q$;
a randomized encryption algorithm $\pcalgostyle{EG}.\enc(\pk, m)$
which inputs a public key $\pk$ and a message $m \in G$
and outputs a ciphertext $C = (C_1, C_2, C_3) = (g_1^r, g_2^r, \pk^r m)$
for $r \sample \ZZ_q$;
and, a deterministic decryption algorithm
$\pcalgostyle{EG}.\dec(\sk_1, \sk_2, C)$ which takes as input
two private keys $\sk_1, \sk_2$ and a ciphertext $C$
and outputs a message $m = C_3 (C_1^{\sk_1} C_2^{\sk_2})^{-1}$.
\parhead{Signature Scheme}
\textsc{TRIP}\xspace uses a EUF-CMA signature scheme
defined by the following three algorithms:
a randomized key generation algorithm $\sig.\kgen(\secparam)$
which takes as input the security parameter
and outputs a signing key pair $(\sk, \pk)$;
a signature algorithm $\sig.\sign(\sk, m)$
which inputs a private key and a message $m\in \bin^*$
and outputs a signature $\sigma$;
a signature verification algorithm $\sig.\verify(\pk, m, \sigma)$
which outputs $\top$ if $\sigma$ is a valid signature of $m$ and $\bot$ otherwise;
and, an algorithm $\sig.\pubkey(\sk)$ that takes as input a private key $\sk$
and outputs the corresponding public key $\pk$.
\parhead{Hash}
\textsc{TRIP}\xspace utilizes a cryptographic secure hash function,
defined as $\hash$, for which the output is $2\secpar$.
\parhead{Zero-Knowledge Proof of Equality}
\textsc{TRIP}\xspace employs an interactive zero-knowledge proof of equality of discrete
logarithms~\cite{chaum1993WalletDatabases}
$\pcalgostyle{ZKPoE}$ so that a prover $\prover$ can convince a verifier $\verifier$
that $\prover$ knows $x$, given messages $y \equiv g_1^x$ (mod $p$) and $z \equiv g_2^x$
(mod $p$) without revealing $x$.
In \emph{interactive} zero knowledge proofs, the verifier $\verifier$ must provide the challenge
only \emph{after} the prover $\prover$ has computed and provided the commit to $\verifier$.
\section{Low-Cost Kiosk Prototype}\label{apx:prototype}
\begin{table}[H]
\centering
\scriptsize
\begin{minipage}{\linewidth}
\begin{tabularx}{\linewidth}
{|>{\centering\arraybackslash\hsize=2.2\hsize}X|>{\centering\arraybackslash\hsize=0.4\hsize}X|>{\centering\arraybackslash\hsize=0.4\hsize}X|}
\hline
Component & Quantity & Total Cost (USD) \\
\hline
Raspberry Pi Zero WH\footnotemark (Wireless/Headers) & 1 & 14.00 \\
16GB SD Card with Buster Lite & 1 & 9.95 \\
USB-A to Micro-B cable & 1 & 2.95 \\
\hline
Raspberry Pi Camera Module v2.1 & 1 & 29.95 \\
Raspberry Pi Zero Camera Cable & 1 & 5.95 \\
\hline
Mini Thermal Receipt Printer\footnotemark & 1 & 49.95 \\
Thermal paper roll - 50' long, 2.25" wide & 1 & 1.95 \\
Female DC Power adapter - 2.1mm jack & 1 & 2.95 \\
USB to 2.1mm Male Barrel Jack Cable - 22AWG \& 1 meter & 1 & 2.75 \\
\hline
7" black frame universal HDMI LCD with capacitive multi-touch\footnotemark & 1 & 124.99 \\
Mini HDMI to mini HDMI Cable & 1 & 6.38 \\
USB to 2.7mm/0.7mm DC cable & 1 & 4.99 \\
\hline
5V 1A (1000mA) USB port power supply & 2 & 5.95 \\
5V 2A (2000mA) Switching Power Supply w/ USB-A Connector & 1 & 7.95 \\
\hline
Total & 15 & 270.66 \\
\hline
\end{tabularx}
\end{minipage}
\caption{Components and their respective price}
\label{tab:components}
\end{table}
\addtocounter{footnote}{-1}\addtocounter{footnote}{-1}
\footnotetext{\href{https://www.adafruit.com/product/3708}{www.adafruit.com/product/3708}}
\addtocounter{footnote}{1}\footnotetext{\href{https://www.adafruit.com/product/597}{www.adafruit.com/product/597}}
\addtocounter{footnote}{1}\footnotetext{\href{https://chalk-elec.com/}{chalk-elec.com}}
\section{Vote Limiting}\label{apx:vote_limiting}
Since $\IA$ is capable of rendering an election stale by generating countless fake credentials
and then casting a fake vote with each of them, we look into devising a mechanism to limit the number
of credentials issued per voter.
We know that voters can only create a finite number of credentials at the registrar since
there are only a finite number of envelopes and
the registrar would eventually remove the voter from the booth
(e.g.,\xspace registration official closing time).
We leverage this fact and describe the slight modifications to the voting scheme to enforce
that only these credentials created during voter registrations will be approved by the ledger.
\parhead{Scheme}
We can leverage the fact that all credentials created during voter registration are signed by a kiosk
and thus during credential activation, the voter device submits the following item to the ledger:
$\L \Leftarrow (K, V, \sigma_{k_3}, \hash(V_{id} \concat d \concat V_e \concat v \concat Y_c \concat c \concat r)$
This statement states to the ledger that I have some credential public key $V$
and its been signed by the kiosk.
Now, when casting a ballot using our proposed voting scheme~(\cref{sec:scheme:our_voting_scheme}),
the ledger will check to ensure that the $V$ in the ballot element exists already on the ledger
in the set of credential public keys provided during credential activation.
There is no modification necessary to the JCJ tallying scheme, except for the pre-processing
as discussed in~\cref{sec:scheme:our_voting_scheme}.
\parhead{Threat Model \& Security Analysis}
In comparison to our defined threat model in~\cref{sec:threat_model}, the integrity adversary is now
incapable of compromising the kiosk.
If the integrity adversary could compromise a kiosk, it could then generate any number
of fake credentials because it could get these credentials signed by the kiosk.
\section{Security Analysis}\label{sec:security}
In this section we conduct an informal security analysis of \textsc{TRIP}\xspace for the three
adversaries considered in the threat model:
integrity, privacy and coercion.
\subsection{Integrity}\label{sec:integrityAdversary}
Recall from \cref{sec:threat_model} that the goal of an integrity adversary $\IA$
is to manipulate the outcome of an election \emph{without detection}.
Specifically, this means preventing, altering or cancelling a vote.
Since the JCJ scheme uses a verifiable tallying process
and have a valid voter roll during setup,
this adversary must resort to tampering with other phases.
$\IA$ cannot prevent or cancel votes from being posted on the ledger since
it is incapable of compromising the ledger.
For the integrity adversary to successfully cast a vote acting as the target voter
or prevent the voter from casting a real vote \emph{without detection},
the adversary must be capable of obtaining the voter's real credential.
However, to successfully obtain the voter's real credential,
the adversary must ensure that the voter successfully complete the registration
process:
the voter attests to the voter registration session (ledger notification via \cref{subsec:systemModel}),
attests to the fabrication of a real credential
(voter's knowledge of the real credential creation process via \cref{subsec:voterCapabilities})
and attests to a successful activate process (\cref{sec:scheme:activate}).
\parhead{Impersonation}
$\IA$ could impersonate a target voter and
proceed with voter registration; this is a trivial attack to accomplish if the malicious
actor is part of the registrar.
However, the target voter will not attest to the voter registration session
because the voter does not recognize it.
\parhead{Steal Credential}:
$\IA$ can steal the voter's credential by compromising the kiosk, but any $\IA$
usage of the credential to cast a ballot would be detected by the voter's device
(\cref{subsec:systemModel}, \cref{sec:scheme:voting}).
As a reminder, $\IA$ cannot compromise the voter's device.
\parhead{Deceive Voter}
$\IA$ could then deceive the voter by issuing only fake credentials
during the voter's interaction with the kiosk.
If $\IA$ has the kiosk continuously perform the fake credential process, then the
voter applies their knowledge of the real credential process (\cref{subsec:voterCapabilities})
to detect that the kiosk has not produced a real credential.
If $\IA$ performs the real credential process as described but instead guesses
the challenge that the voter presents, then $\IA$ wins;
however, the kiosk has a success rate of $1/n$ envelopes where $n$
is the number of envelopes in the stack.
While $1/n$ is not negligible in the formal sense, the kiosk has only
one attempt to guess it correctly, meaning that if it guesses incorrectly, the
credential will be invalid and readily detectable during credential activation,
where the voter will then not attest to a successful credential activation.
For each voter, $\IA$ then procures an unclaimed envelope or compromises an envelope
printer to produce one, and replaces all envelopes in the stack of envelopes with a copy
of the unclaimed envelope, giving the malicious kiosk a 100\% success rate.
However, while not all voters will be generating fake credentials,
a non-trivial number of voters will and when they activate
their credentials, they will not attest to a successful credential activation
after successfully activating one of their credentials.
During check-out, $\IA$ can replace the encrypted real credential $V_{e}$ with the encryption
of another credential and post it on the ledger
but this would be detectable during credential activation (\cref{fig:activate})
since the encrypted real credential on the ledger will not match the one on the credential.
\subsection{Privacy}
Recall that the goal of a privacy adversary $\PA$
is to reveal a voter's real vote, i.e.,\xspace revealing the contents of a voter's
real ballot.
For $\PA$ to be successful, $\PA$ must first determine which of the voter's
credential is the real one and then view the contents of the ballot cast
with this credentials.
$\PA$ can achieve the first task by compromising the kiosk but to accomplish the
second task, $\PA$ must compromise the voter's real device which $\PA$ cannot achieve
in on our threat model (\cref{sec:threat_model}).
Finally, $\PA$ may then try to decrypt the voter's real ballot posted on the ledger
but $\PA$ is incapable of compromising more than $t-1$ talliers,
which implies that $\PA$ cannot get the real credential.
\subsection{Coercion}\label{sec:securityCoercion}
The goal of the coercer $\CA$
is to reveal the real voting behavior of controlled voters while being capable
of \emph{interacting} with voters (\S\ref{sec:threat_model}).
Specifically, this means that the coercer may exert influence onto a voter
and demand, e.g.,\xspace that they divulge their real credential,
that they abstain from voting, or that they cast a coercer-intended vote as their real vote.
For $\CA$ to successfully reveal the voter's behavior,
the adversary must determine whether the voter is deceiving them.
\parhead{Forced Abstention}
$\CA$ may demand that the voter refrain from voter registration,
which is not possible under our voter assumptions (\cref{subsec:voterCapabilities}).
However, this may be practically feasible given that certain countries, such as Australia,
mandate voting along with \emph{voter registration}
(as intuitively voter registration is necessary for voting);
even in the most extreme cases of coercion, where a voter is surveilled 24/7
(a really difficult problem for all coercion-resistant systems),
the coerced voter would have the option to cast a standing vote (if enabled)
inside the privacy booth since this is the only place where the voter cannot
be surveilled by the coercer.
If $\CA$, on the other hand, demands that the voter refrains from voting,
the voter is assumed to have a device they trust with their real credential
which has a communication channel with the voting authority that the coercer
cannot monitor (\cref{subsec:voterCapabilities}).
\parhead{Real Credential}
If the coercer demands the voter to refrain from casting a vote or cast a $\CA$-intended vote,
the coercer must be capable of obtaining the voter's real credential.
$\CA$ cannot impersonate voters since $\CA$ cannot compromise the
check-in device (\cref{sec:threat_model}).
Similar to $\PA$, $\CA$ can retrieve a voter's issued real credentials either by
reconstructing the collective authority's private key or by compromising kiosks.
For the former, we assume that $\CA$ like $\PA$ cannot compromise more than $t-1$ talliers
as stated in our threat model (\cref{sec:threat_model}).
For the latter, our threat model states that $\CA$ cannot compromise the kiosk
(\S\ref{sec:threat_model}).
However, $\CA$ is able to interact with voters
directly and demand that they reveal their real credential.
As voters are capable of creating fake credentials while inside the privacy booth
that look indistinguishable from their real credential,
the coercer is none the wiser when the voter provides the coercer with
one of their fake credentials.
$\CA$ could then demand the voter to create exactly $c$ credentials (within reason)
during voter registration so that it knows that one of the credentials is a real credential;
however, the voter will always be capable of creating $c+1$ credentials.
$\CA$ must then gain exposure to the voter's actions inside the privacy booth.
Recall that the registrar enforces a no device policy inside the booth.
The booth, nonetheless, is a physical environment so $\CA$ could exploit side channels,
such as printer noise, timing, or electromagnetism to determine the number of issued credentials
in the voter's voter registration session.
However, we assume that $\CA$ is incapable of side channel attacks and
leave this to future work (\S\ref{sec:threat_model}).
$\CA$ must then resort to instructing the voter to perform a task inside the booth that would
help the adversary gain an advantage in differentiating between a real and fake credential:
$\CA$ knows that the process of creating a real credential differs only with the voter providing
an envelope QR code after the voter has seen the kiosk print a QR code.
$\CA$ could then use this to their advantage by instructing the voter to perform a Fiat-Shamir
heuristic~\cite{fiat1987FiatShamirHeuristic}
by selecting an envelope using the hash result of the printed QR code.
Naturally, the voter cannot enter with a device (i.e.,\xspace computational-capable device) or perform
complex mental calculations so the coercer could instruct the voter to perform a weaker version
of the Fiat-Shamir heuristic: identify an envelope's QR code that is \emph{visually} similar to
the printed QR code and use this envelope's QR code to create your real credential.
While this attack is heavily sophisticated and would likely require the coercer training the voter,
a simple defense is that during the fake credential process, the kiosk could have an ``advanced" option
that would let voters pick and choose the first QR code on-screen before the kiosk prints the entire
receipt.
The kiosk can generate a vast number of different looking QR codes since the first QR
code $q_1$ contains the ZKP commit which involves a random element in $Z_{q}$.
\section{Usability Study Text}\label{apx:study_text}
In this section, we present an in-depth description of the usability study.
Each sentence was meticulously crafted to be as concise as possible, either
educating or instructing the voter.
Headings are used for reference only, it is not spoken in speech or displayed on kiosk.
\subsection{Welcome}
Thank you for coming and wanting to part in evaluating the usability of an experiment e-voting system.
Please find here our information sheet [hand the info sheet with consent form on back],
which I'll briefly summarize.
You will start here at the check-in desk where I will provide you with a check-in ticket.
With this check-in ticket, you will go to that booth [point to booth],
where you will interact with a kiosk to create your e-voting credentials.
After you have collected your credentials, you will come back here for check-out where I will perform
the check-out procedure and provide you with a QR code that you can then scan using your mobile device
to activate your credentials, cast votes and complete an exit survey on your experience.
Please take this time to review the info sheet and the consent form on the back and please let me know
if you have any questions.
\subsection{Check-In}
Please fill out the following form with your name and email address.
[participant fills out form]
Thank you, I will now print your check-in ticket.
[check-in ticket prints]
Please take this check-in ticket and head over to the booth to create your credentials.
\subsection{Kiosk}
\parhead{Start} \\
\emph{Title:} Welcome! \\
\emph{Body:} Press `Start" to begin. \\
\emph{Action:} Press on-screen `Start" Button.
\parhead{Check-In} \\
\emph{Title:} Check-In \\
\emph{Body:} Please show your check-in ticket to the camera at the left edge of the screen. \\
\emph{Action:} Display Check-In Ticket to camera
\parhead{Checked-In} \\
\emph{Title:} Checked-In \\
\emph{Body:} Thank you, you are checked in! \\
We will now create a REAL credential. You will use your REAL credential to cast ballots that WILL be counted. For security, we print your REAL credential in three steps:
\begin{itemize}
\item We first print part of your REAL credential.
\item Then you will pick and scan an envelope.
\item We finally print the rest of your REAL credential.
\end{itemize}
This three-step process is important and is how you know this is your REAL credential. \\
Please proceed and do NOT touch the printer until you are instructed. \\
\emph{Action:} Press `Continue" button;
upon pressing, the button label becomes `Printing. Please wait." in a disabled state.
\parhead{Real Credential - Confirm QR Code} \\
\emph{Title}: Create Your REAL Credential \\
\emph{Body}: Please confirm that the printer has printed a QR code. Do not remove the paper. \\
If no QR code was printed, please STOP and report the problem at the check-in desk. \\
\emph{Action}: Press ``Confirm" button
\parhead{Real Credential - Scan Envelope} \\
\emph{Title}: Create Your REAL Credential \\
\emph{Body}: Please pick one envelope from anywhere in the stack of envelopes. \\
Show the QR code on the envelope to the camera. \\
\emph{Action}: Display an envelope's QR code to the camera;
upon display, a button appears with the label `Printing. Please wait." in a disabled state.
\parhead{Real Credential - Ready} \\
\emph{Title}: Your REAL Credential is Ready! \\
\emph{Body}: Please take the printed paper with 3 QR codes. Insert the paper into the envelope you scanned. \\
In the future, when you renew your REAL credential, please ensure that it is printed with this same three-step process as shown on the left. If you ever suspect an irregularity, please STOP and report it. \\
Please proceed to create TEST credentials. \\
\emph{Action}: Press ``Confirm" button
\parhead{Test Credential - Intro} \\
\emph{Title}: TEST Credential \\
\emph{Body}: We can now create TEST credentials. You can use TEST credentials to cast ballots that WILL NOT be counted. For example, you may:
\begin{itemize}
\item Give a TEST credential to your children or anyone wishing to try the voting system.
\item Sell a TEST credential to anyone who tries to buy your vote.
\item Use a TEST credential to cast the vote demanded by anyone trying to coerce you.
\end{itemize}
Only you will be able to distinguish between your REAL and TEST credentials. \\
Would you like to create a TEST credential? \\
\emph{Action}: Press ``No" button (go to Finish) or ``Yes" button
\parhead{Test Credential - Prepare} \\
\emph{Title}: Create a TEST Credential \\
\emph{Body}: Please use a pen to mark in the box on your REAL credential, so that you can distinguish it from TEST credentials.\\
\emph{Action}: Press ``Continue" button
\parhead{Test Credential - Scan Envelope} \\
\emph{Title}: Create a TEST Credential \\
\emph{Body}: Please pick another envelope from anywhere in the stack of envelopes. \\
Show the QR code on the envelope to the camera. \\
\emph{Action}: Display an envelope's QR code to the camera;
upon display, a button appears with the label `Printing. Please wait." in a disabled state.
\parhead{Test Credential - Ready} \\
\emph{Title}: TEST Credential is Ready! \\
\emph{Body}: Please remove the receipt from the printer and insert the receipt in the envelope you just scanned. \\
You know this is a TEST credential because we printed all three QR codes AFTER you picked and scanned the envelope. \\
Please use a supplied pen to mark your TEST credential at the designated box so that you can distinguish it from your REAL credential. \\
Would you like to create another TEST credential? \\
\emph{Action}: Press ``No" button or ``Yes" button
\parhead{Finish} \\
\emph{Title}: Success! \\
\emph{Body}: Please take your REAL credential with you to the check-out desk. \\
After check-out, please activate your REAL credential using a device you trust. \\
\emph{Action}: Press ``Finish" button
\parhead{Finish With Test Credentials} \\
\emph{Title}: Success! \\
\emph{Body}: Please be careful to reveal your REAL credential ONLY when activating it in private on a device you trust. \\
Now please continue to the check-out desk, and display any ONE credential of your choosing. \\
Feel free to give away or sell your TEST credentials. \\
\emph{Action}: Press ``Finish" button
\subsection{Check-Out}
Please give me any one of your credentials [if the participant has not already done so].
[Scan middle QR code: opens a check-out form, where study operator takes picture of the envelope with receipt fully inserted]
Please take back your credential and scan this QR code to complete the rest of the study, where you will activate your credentials,
cast votes, and complete the exit survey.
\subsection{Credential Activation}
The following is the text used to instruct the voter to lift 1/3 of their receipt along with an animated picture:
``To activate your credential, please place it facing up on a flat surface and in the \emph{activate} state by pulling 1/3 of the receipt
from the envelope. This should reveal a QR code outside the envelope and a new QR code inside the envelope's window as shown on the right. \\
Please take a picture of your credential facing up on a flat surface and in the ACTIVATE state. \\
\emph{Your picture must contain all 3 QR codes}"
\subsection{Voting}
The following text is used to instruct the voter to cast a vote (along with choices):
``Now that your credential is activated, you may cast your votes in this current election! \\
Vote for your 2 favorite cartoon characters? (2 choices max) \\
Vote for your 2 favorite outdoor activities? (2 choices max)" \\
Voters were given the opportunity to activate another credential and cast votes using this credential.
\subsection{Survey}
\parhead{Background}:
The following background questions were asked to each participant:
\begin{itemize}
\item What is your age?
\item What is your gender?
\item What continent are you from?
\item What is your first/native language?
\item How are you affliated with X university?
\item Are you registered to vote in your country?
\item Have you ever cast a ballot in a political election?
\end{itemize}
\parhead{Usability}:
The following questions were asked about the participant's experience with voter registration, including
the questions involved with the system usability scale~\cite{brooke1996SystemUsabilityScale}: \\
``Please indicate whether you agree or disagree with the following statements:
\emph{1 is ``Strongly Disagree" and 5 is ``Strongly Agree"}"
\begin{itemize}
\item I think that I would like to use this voter registration system frequently.
\item I found the voter registration system unnecessarily complex.
\item I thought the voter registration system was easy to use.
\item I think that I would need the support of a technical person to be able to use this voter registration system.
\item I found the various functions in this voter registration system were well integrated.
\item I thought there was too much inconsistency in this voter registration system.
\item I would imagine that most people would learn to use this voter registration system very quickly.
\item I found the voter registration system very cumbersome to use.
\item I felt very confident using the voter registration system.
\item I needed to learn a lot of things before I could get going with this voter registration system.
\end{itemize}
Participants were also asked the following questions about their voter registration experience: \\
\begin{itemize}
\item What did you like the most about the voter registration system?
\item What did you like the least about the voter registration system?
\item Would you be inclined to trust the e-voting system as a whole? Why or Why not?
\end{itemize}
\parhead{Credentials} The following questions were asked about their credential:
\begin{itemize}
\item Do you remember the three steps involved in creating a REAL credential? If so, please describe
\item Did you proceed with creating a TEST credential?
\item What led to your decision of creating a TEST credential? (If proceeded with a TEST credential)
\item What led to your decision of not creating a TEST credential? (If did not proceed with a TEST credential)
\end{itemize}
\parhead{Vote Buying} Next, the participants were given the following vote buying scenario:
``Assume the following scenario: you have just obtained your REAL credential from a local government office
and suddenly someone named Alexis wishes to purchase your unactivated REAL credential so that they may cast votes
they wish while acting as you."
\begin{itemize}
\item How much would Alexis have to offer before you might consider accepting it?
\item Assume now that you had also created TEST credentials and you wish to sell one to Alexis
while secretly voting your conscience with your REAL credential at another time, would you do so?
Why or why not? Would you want the same amount from Alexis?
\item Would you report Alexis' attempt to buy your vote? Why or why not?
\end{itemize}
\parhead{Coercion Scenarios}
Finally, participants were presented with a question to rank coercion scenario from most likely to least likely:
``Please rate the following scenarios from very likely to very unlikely in regards to it happening to you or someone you may know:"
\begin{itemize}
\item An employer either buying or coercing your vote
\item Someone remotely buying or coercing your vote over the Internet
\item An authority (e.g., police, municipal workers) pressuring or coercing voters to cast a vote in a particular manner
\item An individual physically buying your mail-in ballot or coercing you to hand it over
\item A family member (e.g., domestic partner) either buying or coercing your vote
\end{itemize}
and asked the following question: ``Please state, if any, coercion scenarios that are not listed above that you know has happened or
is concerned about it happening to you or to someone you may know"
\subsection{End}
Thank you for taking part in the study, do you have any questions?
[Discussion \& Compensation].
\subsection{Kiosk Page Timing}
\begin{table}[ht]
\centering
\footnotesize
\begin{tabular}{|c|c|c|}
\hline
\multirow{2}{1cm}{Page} & \multirow{2}{1.5cm}{\centering Average (sec)} & \multirow{2}{1.5cm}{\centering Median (sec)} \\
{} & {} & {}\\
\hline
Check-In & 05.7 & 05.2 \\
Checked-In & 25.1 & 23.5 \\
Real Cred. First Print & 01.5 & 01.5 \\
Real Cred. Confirm Print & 07.9 & 07.1 \\
Real Cred. Scan Envelope & 12.1 & 11.7 \\
Real Cred. Second Print & 01.6 & 01.6 \\
Real Cred. Ready & 33.4 & 30.4 \\
Test Cred. Intro & 27.3 & 26.2 \\
Test Cred. Prepare & 21.4 & 19.0 \\
Test Cred. Scan Envelope & 11.1 & 10.7 \\
Test Cred. Print & 01.7 & 01.7 \\
Test Cred. Ready & 29.9 & 29.1 \\
Test Cred. Scan Envelope 2* & 07.7 & 06.0 \\
Test Cred. Print 2* & 01.7 & 01.7 \\
Test Cred. Ready 2* & 35.1 & 22.5 \\
Test Cred. Finish & 21.5 & 18.4 \\
\hline
Total Time (Real Cred.) & 108.850 & 99.512 \\
Total Time (Real \& Test Cred.) & 200.106 & 186.252 \\
Total Time (Real \& 2 Test Cred.) & 244.532 & 216.336 \\
\hline
\end{tabular}
\caption{\emph{Page Timings}: The average and median time that participants were on a certain page of the kiosk \\
* based only on the 7 participants that created a second test credential}
\label{tab:kiosk:timings_full}
\end{table}
\section{Preliminary Usability Study}\label{sec:usability}
To evaluate the usability of \textsc{TRIP}\xspace,
we conducted a usability study consisting of 41 doctoral students
(15 females and 26 males) from a university.
Our ethical considerations for the usability study can be
found in section~\ref{usability:ethics}.
\subsection{Participants}
For our study, we targeted the recruitment of \emph{doctoral} students across all disciplines
as they likely have some experience with democratic elections.
Out of the 41 doctoral students recruited, 34 of them are currently registered
to vote in their own country, and 35 of them have cast a ballot in an election.
The average age of a doctoral student in our study is 27.6 years old, where the
minimum age is 22 and the maximum age is 57.
The distribution of doctoral students by continent is as follows:
Europe (21), Asia (11), North America (6) and South America (3).
\subsection{Study Design}
\begin{figure}
\centering
\includegraphics[width=\linewidth]{figs/IMG_0800.jpeg}
\caption{\emph{Booth}: From right to left: receipt printer, kiosk, stack of upright envelopes, and pen}
\label{fig:booth}
\end{figure}
The study was designed to follow the detailed voter facing design section
(\cref{sec:design:voter-facing}).
Each participant, after completing the formal process to enroll in the study,
received a check-in ticket that they could use to activate a kiosk.
The kiosk behaved exactly as described, educating and issuing the voter both real and fake
credentials; we call fake credentials ``test credentials" in the study because
the use cases go beyond coercion-resistance, such as voter education for family and friends.
Participants were not exposed to the notion of a real or a ``test" credential or its use cases
until the kiosk mentioned it after creating their real credential.
At check-out, the study operator is given any one of the voter's credentials, scans the middle QR
code and returns the credential to the voter.
Diverging slightly, the study operator provides the voter with a QR code that they can on their device
to bring them to a website where they can activate their credentials, cast votes in fictitious elections
and complete an exit survey.
In terms of the physical environment, the check-in and check-out desk are bundled together as one main desk and
the booth is exactly as described (touchscreen device, receipt printer, pen, stack of envelopes).
\subsection{Ethical Considerations}\label{usability:ethics}
The usability study was reviewed by the university's internal human research review board.
Before participating in the study, each participant were given an info sheet,
detailing that upon enrolling, they would be evaluating the usability of an experimental e-voting system.
After reviewing the info sheet, each participant signed a consent form
and are given the opportunity to withdraw from the study at any time.
We collected user data from the check-in device, kiosk and check-out device along with any information provided during the exit survey and all information were stored on devices issued by the university.
Participants were given the opportunity to use their own personal device
or use a university-issued device
to activate their credentials, cast votes, and complete an exit survey.
\subsection{Usability Score}
To reliably measure an individual's rating of a system's usability we use the System Usability Scale (SUS)~\cite{brooke1996SystemUsabilityScale,bangor2008SUSEmpiricalEvaluation}.
SUS consists of ten statements about the system in question (\cref{apx:study_text})
where the voter would respond with a range of 1-5 from Strongly Disagree to Strongly Agree.
Out of the 41 participants, we find one participant having inconsistent results,
i.e.,\xspace agreeing to most positive and negative items, and was removed.
Averaging the SUS scores of all the other participants (n = 40),
we got a final SUS score of 64.3 with a 95\% confidence interval
ranging from 58.70 to 69.80, a standard deviation of 17.4,
and a Cronbach/coefficient Alpha of 0.845 where the latter indicates
that the score is reliable, or more concretely repeatable.
A SUS score by itself does not indicate much, and is instead meant to be compared to similar systems and systems in general.
In terms of comparing it to similar existing systems,
the usability study by Neto et al.~\cite{neto2018CredentialsDistributionUsability}
looked at distributing the voter's
credentials in three different formats:
JSON file with credential on a pen drive, credential sent by email and password set during in-person sign-up.
They provide the SUS score for the latter two channels: 77.5 with a standard deviation of 20.4 for email and 77.4 with a standard
deviation of 13.3 consisting of 26 and 34 participants, respectively.
The industry's average SUS score is about 68 based on the work by Sauro~\cite{SUSGuide}.
In terms of grading scales, \emph{Bangor et al.}~\cite{bangor2009SUSRating}
would place our system and the industry's average inside the 60-70 range
(grade: D, adjective: Ok, Marginal Acceptability)
while the usability study by \emph{Neto et al.} would place in 70-80
range (grade: C, Adjective: Good, Acceptable).
Work by Sauro \& Lewis~\cite{SUSGuide}
would place our system in the range 62.7-64.9 (grade: C-, 40th percentile),
the industry average in the range 65-71 (grade: C, 50th percentile) and
\emph{Neto et al.}'s study in the range 77.2-78.8 (grade: B+, 80th percentile).
In table~\ref{tab:sus_score}, we present the percentiles of the grades
given by the study participants to \textsc{TRIP}\xspace based on their calculated SUS score.
By running a one-sided 2-sample t-test with an alpha of 0.01
for each of the email and password groups defined in \emph{Neto et al.} vs. our credential
distribution mechanism, we find that both times the former group's mean SUS score
is significantly higher than that of our credentialing system.
The SUS score is known to be affected by age and experience~\cite{SUSGuide} so we looked into each.
For age, we divided the participants in 2 groups based on the average age (27.6),
revealing a SUS score of 67.3 with a standard
deviation of 15.3 and coefficient alpha of 0.798 for the 26 participants
that are less than or equal to 27 years old, while
revealing a score of 58.6 with standard deviation of 20.0 and
coefficient alpha of 0.884 for the 14 other participants.
By running a one-sided 2-sample t-test and a one-sided Mann-Whitney U test
with an alpha of 0.1 on these two groups,
we find that first group’s mean SUS score is significantly higher than that of the second group.
($p_{t-test} = 0.079$ and $p_{mann} = 0.092$).
For experience, we divided the participants in 2 groups based on whether
they have ever cast a ballot in an election,
but the coefficient alpha for the second group was non-reliable (0.250)
and only contained 6 participants so we decided
to forego this comparison.
\begin{table}[ht]
\centering
\footnotesize
\begin{tabular}{|c|c|}
\hline
Grade & Percentile (\%) \\
\hline
A+, A, A- & 12.5, 12.5, 17.5 \\
B+, B, B- & 22.5, 42.5, 42.5 \\
C+, C, C- & 47.5, 57.5, 60 \\
D & 72.5 \\
F & 100 \\
\hline
\end{tabular}
\caption{Percentile of the grades for \textsc{TRIP}\xspace
based on the grading scale proposed by Sauro \& Lewis~\cite{SUSGuide}}
\label{tab:sus_score}
\end{table}
\subsection{Coercion Scenarios}
In the exit survey, participants were asked to rank 5 coercion scenarios (\cref{apx:study_text})
from most likely to least likely in regards to it happening to them or someone they know,
and received responses from 34 participants.
We then assigned a score for each scenario based on its place
in the ranking (assigning a score of 5 for most likely
to assigning a score of 1 for least likely).
We found that the reported most likely scenario is
an individual over the Internet buying or coercing votes with a score of 111
followed by an authority pressuring or coercing votes (109),
followed by a family member buying or coercing votes (101),
followed by an individual physically buying or coercing voters to hand over their mail-in ballot (101)
and finished by an employer buying or coercing voters (89).
To give more weight to the participant's top choices,
we squared each score based on its place in the ranking
(similar to quadratic voting where top candidate preferences
are given more weight), i.e.,\xspace $5 = 25, 4 = 16, 3 = 9, 2 = 4, 1 =1$.
We now get authority coercion with a score of 431,
followed by Internet coercion (425), followed by family coercion (387),
followed by physical coercion (338), finished by employer coercion (289).
Participants indicated the following additional coercion scenarios
that they or someone else they know may have experienced:
(1) Arbitrary individuals ``helping" elderly or disabled people to vote;
(2) receiving presents from political parties in an influential way to cast a particular vote;
(3) pressure by social media, health care professionals, friends to vote in a particular manner.
Participants also noted the presence of pressure to \emph{cast} a vote rather than abstaining.
\subsection{Kiosk}
Out of the 41 participants,
1 participant created only a real credential,
33 participants created one real and one fake credential and
7 participants create one real and two fake credentials.
In the survey, when asking voters why they decided to create a fake credentials,
25 participants stated that they were curious, such as wanting to see the difference,
some participants thought that they would be bribed by the study operator,
some said they wanted it for educational purposes
while some participants thought that creating a fake credential was mandatory.
\begin{table}[ht]
\centering
\footnotesize
\begin{tabular}{|c|c|c|}
\hline
\multirow{2}{1cm}{Page} & \multirow{2}{1.5cm}{\centering Average [s]} & \multirow{2}{1.5cm}{\centering Median [s]} \\
{} & {} & {}\\
\hline
Total Time (Real Cred.) & 108.850 & 99.512 \\
Total Time (Real \& Test Cred.) & 200.106 & 186.252 \\
Total Time (Real \& 2 Test Cred.) & 244.532 & 216.336 \\
\hline
\end{tabular}
\caption{\emph{Total Time Timings}: The average and median time that participants spent creating one or more credentials. A timing breakdown for each page is in appendix~\ref{apx:study_text}, table~\ref{tab:kiosk:timings_full}}.
\label{tab:kiosk:timings}
\end{table}
Our primary metric was the time spent by the participant on each page of the kiosk
and is presented in \cref{tab:kiosk:timings_full}.
Participants spent the most time on the following pages (based on median):
1) the success page after creating their real credential (\textasciitilde30 sec),
2) the success page after creating their test credential (\textasciitilde29 sec),
3) the introduction page of what is a test credential (\textasciitilde26 sec),
4) the introduction page on creating a real credential (\textasciitilde23 sec),
5) the success page after creating their second test credential (\textasciitilde22 sec)
With the timings for each page, we can then derive the time it takes
to create a real credential and a fake credential.
We see that the average time to create a real and a test
credential is about 100 seconds, each while creating a subsequent test credential takes half of the time: 50 seconds.
\subsection{Errors}
One participant scanned their check-in ticket twice
during the real and test credential creation process instead of scanning
the QR codes of the envelopes.
One participant inserted the receipt in the envelope in the incorrect position,
although technically this does not matter as discussed in~\cref{sec:design:voter-facing}.
Two participants, however, during credential activation,
did not lift the receipt 1/3 of the way
and two other participants lifted the receipt 1/3
of the way but did not scan all three QR codes;
these errors are more serious but detectable.
\subsection{Feedback by Participants}
Many participants were bothered by the lack of understanding of the steps indicated by
the kiosk; however, at the same time, the procedure made it seem to participants that
the e-voting registration system was secure.
Another concern that participants had is the difficulty that elderly and disability individuals
may encounter in utilizing the voter registration system.
Participants also gave feedback on how to improve the system, such as
providing a small introduction video demonstrating all the steps beforehand to
help voters better visualize the process.
\section{Standing Votes}\label{apx:standingVotes}
Voters may be uncomfortable or incapable of concealing their real credential from a coercer (e.g.,\xspace
coercer performing a search of the voter right after voter registration) or may be incapable
of accessing a trusted device.
In this extreme coercion case, the voter may cast a standing vote,
delegating their real votes to a well-known entity (e.g.,\xspace political party).
\parhead{Scheme} During the setup phase, the registration officials would provide the kiosks
with the credential public key of each of these well-known entities: $\vec{V_{entity}}$.
During the voter's interaction with the kiosk, the kiosk would now start by presenting
the voter with two options: voting credential and standing vote, and if standing vote is selected,
the voter selects an entity: $V \in \vec{V_{entity}}$.
The procedure is then identical to a real credential creation process except that the kiosk encrypts
the entity's credential public key $V \in \vec{V_{entity}}$ and omits the
the private key associated with the public key throughout the process.
After the voter's interaction with the booth, while no longer necessary,
the voter should proceed with the $\pcalgostyle{Activate}$ protocol (\cref{fig:protocol:activate})
to ensure that the registrar behaved honestly.
Although we don't cover tallying, the JCJ tallying scheme remains identical with standing votes,
except that instead of a one to one mapping between the set of encrypted real credentials published
during check-out and encrypted cast ballots,
there will be a many to one mapping (as numerous voters encrypted real credential encrypt $V_{entity}$).
This indicates that an encrypted ballot should count for as many times as there is an encrypted
real credential associated with it.
\parhead{Threat Model \& Security Analysis}
In comparison to our defined threat model in \cref{sec:threat_model},
both the integrity and privacy adversary are incapable of compromising the kiosk when a voter
decides to cast a standing vote.
If the integrity adversary $\IA$ is capable of determining whether a voter is under extreme coercion,
then the integrity adversary could replace the credential public key selected by the voter
with another credential public key, one where the adversary may have control of the private key.
The privacy adversary $\PA$ under our normal threat model is capable of compromising the kiosk
but in the standing vote case, it will immediately see not only that the voter chose to cast
a standing vote but also the contents of the standing votes; under this new threat model,
$\PA$ can no longer compromise the kiosk.
The coercer adversary $\CA$ under our normal threat model cannot compromise the kiosk so the
coercer cannot see whether the voter's real behavior of casting a standing vote.
The coercer adversary $\CA$ could exploit the fact that standing votes has a slightly different
receipt data structure (missing private key) from creating credentials
and then demand the voter to cast a standing vote and bring the receipt.
However, the kiosk can enable the voter to create \emph{fake} standing votes by following the
steps involved to create a fake credential (using the coercer-intended standing vote selection,
and omitting the associated private key); a real and fake standing vote will then have the same
data structure, thus once again being indistinguishable from one another.
\section{\textsc{TRIP}\xspace Design}
This section starts by presenting the system model,
continues by presenting the reasoning behind our solution,
followed by introducing a brief high level design,
continues by presenting voter registration
from the voter's perspective and
finishes by presenting our threat model.
As our focus is on voter registration,
our underlying coercion-resistant e-voting scheme is
JCJ's scheme.
\subsection{System Model}\label{subsec:systemModel}
\textsc{TRIP}\xspace consists of the actors presented in JCJ
(Authority, Registrar, and Voters) but
introduce envelope printers and kiosks as part of the registrar.
We present the actors, their devices, and their interactions with one another,
summarizing them in \cref{fig:voting_actors}.
\begin{figure}[htbp]
\centering
\includegraphics[width=\columnwidth]{figs/Actors.pdf}
\caption{\textsc{TRIP}\xspace Actors}
\label{fig:voting_actors}
\end{figure}
\parhead{Ledger}
Inheriting from the JCJ scheme, the ledger $\L$ is an append-only data structure,
writable and readable by any device in the system; voters only have a partial view
of the ledger contents until the voting phase has concluded.
In \textsc{TRIP}\xspace, the ledger is given the additional responsibility of authenticating incoming data
and operating an automatic notification system that notifies voters of their
voter registration session via some out-of-band channel (e.g.,\xspace postal mail).
\parhead{Authority}
As in JCJ, the authority $\A = (T_{1}, T_{2}, ..., T_{n_{T}})$
consists of a set of talliers that verifiably tally the ballots
retrieved from the ledger to produce the outcome of a voting event.
\parhead{Voters} Voters $\V = (V_{1}, V_{2}, ..., V_{n_{V}})$
are the entities participating in voting events published on the ledger.
They use a voter supporting device to activate their real credential
and any fake credentials to cast real and fake ballots, respectively.
\parhead{Registrar} The registrar consists of
a set of $n_{R}$ registration officials ($\R = \{R_1, R_2,..., R_{n_{R}}\}$),
a set of $n_{K}$ kiosks, ($\K = \{K_1, K_2, ..., P_{n_{K}}\}$) and
a set of $n_{P}$ envelope printers ($\P = \{P_1, P_2, ..., P_{n_{P}}\}$)
who are responsible with issuing credentials to voters and publishing voting event
parameters.
\textsc{TRIP}\xspace introduces kiosks, located inside a booth, that interact with voters
to create their real credential and a number of fake credentials.
\textsc{TRIP}\xspace also introduces envelope printers to supply the booth with envelopes,
each differentiating only by a QR code representing a random nonce,
and maintain a list of issued envelopes on the ledger.
\textsc{TRIP}\xspace presents check-in/check-out devices
(depicted as a smartphone in \cref{fig:voting_actors})
which are operated by registration officials for
the check-in and check-out procedures as described in~\cref{sec:design:high-level}.
\subsection{Verifiability Without a Trusted Device}
The question is \emph{how can voters use a registrar-controlled device (a kiosk) given that the registrar is considered untrusted?}
We know from \cref{background:voter_registration}
that the voter needs a private environment (a booth)
at the registrar to act freely.
With an untrusted registrar, everything in and out of this booth must be verifiable and everything
going inside the booth must be verifiable as well.
However, we need a verifiable process that the voter can accomplish inside the booth without
being verifiable to a coercer as well.
Our key insight is then to have the voter engage in an \emph{interactive} zero-knowledge proof
with the kiosk during the creation of their real credential
since for this proof to be valid, it requires the verification of two elements:
The construction of the proof must follow a three step process (commit, challenge, response)
and then the proof must be cryptographically correct.
While the voter is incapable of verifying the latter, the voter can verify the former, even
if the average voter is completely unaware of this process.
This idea was previously suggested by \emph{Moran and Noar}~\cite{moran2006ReceiptFreeVerifiableEverlastingPrivacy}
but for casting a verifiable, receipt-free ballot using a Direct Recording Device (DRE).
The DRE device had to be somewhat trusted to keep a physical opaque shield where the voter
sees only that a part of the receipt was printed but not its contents.
Further, the protocol also requires the voter enter random words
as the challenge and then later, when the voter has access to a device, verify the
integrity of their cast ballot; this verifiability portion after using a DRE device
is known to be a challenging usability problem~\cite{bernhard2020VotersDetectManipulation}.
In our protocol, we instead solely rely on the exclusion of personal devices inside the kiosk and the fact
that normal voters cannot mentally perform complex cryptographic operations.
\subsection{High Level Design}\label{sec:design:high-level}
We present the high level design of \textsc{TRIP}\xspace.
\begin{figure}[htbp]
\centering
\includesvg[width=\columnwidth]{figs/High_Level_Design.svg}
\caption{\textsc{TRIP}\xspace Design}
\label{fig:design}
\end{figure}
\parhead{Check-In}
A prospective voter at a registrar's office starts by identifying
themselves to a registration official to confirm their identity and
eligibility via some out of scope process.
Upon success, the official provides the voter with a check-in ticket,
requires the voter to deposit their electronic devices
and directs the voter to a location where the voter
is given a perfectly private environment, e.g.,\xspace a booth.
\parhead{Booth}
Inside the booth, the voter unlocks a kiosk with their check-in ticket.
The kiosk then generates the voter's real credential
and constructs an interactive zero-knowledge proof of equality of
discrete logarithms~\cite{chaum1993WalletDatabases}
between itself, as the prover, and the voter, as the verifier.
The kiosk then educates the voter on fake credentials and if desired by the voter,
the kiosk generates fake credentials and forges
an interactive zero-knowledge proof with the help of the voter.
When finished, the kiosk directs the voter to a check-out desk.
\parhead{Check-Out} At check-out, the voter displays \emph{one} of their credentials
to the registration official and recuperates their electronic devices.
\parhead{Activation}
Anytime after check-out, when the voter obtains a trustworthy device,
the voter \emph{activates} their real credential which enables them to
cast real votes in current and future voting events.
Alternatively, the voter may provide their real credential
to a trusted third party to cast votes on their behalf.
After activation, the voter must shred the (paper) credential.
\subsection{Voter-Facing Design}\label{sec:design:voter-facing}
\input{figs/latex/voter-paper}
In this section, we present a detailed voter registration session from the
viewpoint of the voter after completing check-in,
i.e.,\xspace performing authentication, depositing electronic devices and
receiving a check-in ticket~(\cref{fig:checkInTicket}).
It goes further in detail than would be expected because it covers elements
that the participants in our preliminary usability study is exposed to;
we refer to \cref{apx:study_text} for the exact wording used in the usability study.
\parhead{Booth Entrance}
In the booth,
the voter is exposed to a touchscreen kiosk with a camera,
a receipt printer, a pen and a set of upright envelopes~(\cref{fig:envelope}).
An envelope is a hollow rectangle consisting on its front face
a QR code, a hollow square and an outline of a rectangle box
with the words ``Mark Here"
on its upper, middle, and lower third portions, respectively.
Upon starting to interact with the kiosk,
the voter is directed to display the check-in
ticket~(\cref{fig:checkInTicket}) to the camera.
\parhead{Real Credential Creation}
Once the check-in ticket is verified,
the kiosk informs the voter on the process of creating
a real credential.
After the voter digests the information,
the kiosk prints a single QR code and asks
the voter to confirm that they see a QR code.
Upon confirmation by the voter,
the kiosk instructs the voter to \emph{randomly} pick and scan
an envelope from the set of envelopes.
The kiosk then prints two additional QR codes and instructs
the voter to tear the receipt and fully insert it into the envelope,
completing the voter's real credential along with a proof.
The kiosk also educates the voter by stating that in the future, when
the voter renews their credential, the process must follow the same
three step process and to stop and report if there are any irregularities.
When the receipt is completely inserted into the envelope,
we refer to this state as \emph{transport}~(\cref{fig:transport})
since neither the envelope's QR code nor the receipt's middle QR code
presents any confidential information.
We note that our envelope and receipt design enables voters to insert
the receipt in either position, resulting in the same outcome in terms
of respective QR code exposure.
The receipt's middle QR code is referred as the check-out ticket
and it will be identical
to the check-out ticket on the receipts of the voters' fake credentials.
\parhead{Fake Credential Process}
The kiosk then educates the voter on fake credentials, namely
that they can be used to evade coercion along with vote buying or
used for educational purposes as fake credentials cast ballots that
do not count while remaining indistinguishable from their real credential. Next, it asks whether the voter wishes to create one.
If the voter agrees, the kiosk prompts the voter
to mark their real credential using the designated box on the
envelope, ensuring that the voter can distinguish real credential
from fake credentials.
The kiosk then requires the voter to pick and scan another envelope
from the stack of envelopes, enabling the kiosk to print
three QR codes in one pass.
With the receipt printed, the kiosk instructs the voter to tear
the receipt, insert it into the envelope and mark
the fake credential at the designated box to distinguish it from
the real credential.
The kiosk then defaults to asking whether the voter would like another
fake credential, repeating the steps from requiring the voter to pick
and scan another envelope if the voter agrees.
The creation of fake credentials can last until there are no new envelopes,
or until asked to leave by the registrar after an extended period.
At the end, the kiosk informs the voter to only reveal
the real credential when activating it in private on a
device they trust and then instructs the voter to head towards the check-out desk
where they are to display only \emph{one} of their credentials.
\parhead{Check-Out}
At check-out, the voter presents \emph{any one}
credential to the registration official
while the credential remains in the transport state.
The registration official scans the check-out ticket, i.e.,\xspace,
the receipt's middle QR
code presented in the hollow square, hands back the credential,
informs the voter that they have successfully registered for remote e-voting
and will receive a record of their visit via some out of band channel (e.g.,\xspace postal mail),
The voter may now retrieve the deposited electronic devices and
activate the credentials, or postpone the activation to a later time.
\parhead{Activation}
To activate a credential, the device instructs the voter to lift up the receipt
one third of its length from the envelope,
which places the credential in the \emph{activate} state~(\cref{fig:activate}),
revealing, in order, the receipt's top QR code outside the envelope,
envelope's QR code, and receipt's bottom QR code inside the hollow square.
The device then prompts the voter to take a picture of the credential in this
state, completing the activation of the credential and enabling the voter to
discard the physical credential, i.e.,\xspace the receipt and envelope.
\subsection{Voter Assumptions}\label{subsec:voterCapabilities}
We discuss the necessary steps that the voter must be capable of
to register to vote, evade coercion and
ensure the integrity of their real credential.
With an electoral roll containing the plaintext names of registered
voters, we assume the coercer cannot refrain the voter from performing
voter registration at the registrar's office.
Inside the booth, the voter must be incapable of bringing a recording
device or perform any kind of complex cryptographic operations (e.g.,\xspace hash)
either mentally or with a computation-capable device.
During the creation of their real credential, the voter must be
aware that this is a three step process - print, scan and print.
After creating their credentials inside the booth,
the voter must be able to conceal their real credential
until they can activate it on a trustworthy device or hand it
over to a trusted third party.
The voter must also be capable of lying convincingly to a coercer that
demands the voter to hand over their real credential, providing instead
one of their fake credentials.
Finally, voters must be capable of accessing a device to cast their real vote
from that is not monitored by the coercer (e.g.,\xspace some device that the coercer
does not know about or a device owned by a trusted third party).
\subsection{Threat Model}\label{sec:threat_model}
We now informally define three distinct adversaries\footnote{An availability adversary
whose goal is to cause a denial of service attack
is also relevant to e-voting but we assume the e-voting system is deployed on
high availability systems.}: integrity $\IA$, privacy $\PA$ and coercion $\CA$
and present their capabilities~(\cref{table:adversaries}).
We assume that all adversaries are computationally bounded
and cryptographic primitives are secure.
\input{figs/latex/threat-model}
\parhead{Integrity Adversary} The goal of the integrity adversary $\IA$ is
to manipulate the outcome of a voting event \emph{without detection},
e.g.,\xspace pre-empt, alter or cancel votes.
As in any end-to-end verifiable e-voting systems,
this adversary is quite powerful, capable of compromising (observing and tampering)
any of the devices in the system after completing a setup phase.
We assume this adversary cannot compromise the ledger.
We leave the compromise of voter supporting devices out of scope and refer to
literature~\cite{cortier2019CastAsIntended,benaloh2007BallotCasting}
on the cast-as-intended property.
\parhead{Privacy Adversary}
The goal of the privacy adversary $\PA$ is to \emph{reveal} the real vote cast by the voter.
$\PA$ is capable of observing any device in the system except for a threshold of talliers
and the voter supporting devices.
As specified in JCJ and in numerous e-voting systems~\cite{clarkson2008Civitas,kusters2020Ordinos},
talliers use a $(t, n)$ threshold public-key cryptosystem to prevent reconstruction of the
collective private key by malicious talliers.
\parhead{Coercion Adversary}
The coercion adversary (aka. coercer) is a strong form of the privacy adversary,
as formally defined in JCJ~\cite{juels2010CoercionResistantElections},
where the adversary has the additional capability of interacting with voters,
e.g.,\xspace instructing \emph{controlled} voters to divulge their real credential,
to cast ballots in a specific manner, and even to abstain from voting.
To evade coercion, the voter must then be capable of deceiving the coercer into believing
that they behaved as instructed when instead they behaved according to their own free will.
While this adversary may compromise up to $t-1$ talliers, similar to the privacy adversary,
$\CA$ cannot compromise the check-in/out devices, the kiosks, nor the controlled voters'
supporting devices containing their real credential.
We leave side channel attacks (e.g.,\xspace printer noise, timing, electromagnetism)
to deduce information about the voter while they are inside the booth out of scope.
\section{Acknowledgments}
The authors would like to thank the E-Voting Group at Bern University of Applied Sciences,
namely Rolf Haenni and Eric Dubuis, for their valuable feedback.
This project was supported in part by
the Fulbright U.S. Student Program,
the Swiss Government Excellence Scholarships for Foreign Scholars,
the AXA Research Fund, and the US ONR grant N000141912361.
\section{0pt}{2ex plus 1ex minus 1ex}{1ex plus 1ex minus 1ex}
\titlespacing\subsection{0pt}{2ex plus 1ex minus 1ex}{1ex plus 1ex minus 1ex}
\crefformat{section}{§#2#1#3}
\addtolength{\topskip}{-5mm}
\begin{document}
\date{}
\title{\Large \bf TRIP\xspace: Trustless Coercion-Resistant In-Person Voter Registration}
\author{
{\rm Louis-Henri Merino}\\
\and
{\rm Simone Colombo}\\
\and
{\rm Jeff Allen}\\
\and
{\rm Vero Estrada-Galiñanes}\\
\and
{\rm Bryan Ford}\\
\and
{Ecole Polytechnique Fédérale de Lausanne (EPFL)}
}
\maketitle
\begin{abstract}
\input{content/0-abstract}
\end{abstract}
\input{content/1-introduction}
\input{content/2-background}
\input{content/3-design}
\input{content/4-scheme}
\input{content/5-security}
\input{content/6-evaluation}
\input{content/7-usability}
\input{content/8-conclusion}
\input{content/9-acknowledgments}
\bibliographystyle{plain}
|
{'timestamp': '2022-02-15T02:44:14', 'yymm': '2202', 'arxiv_id': '2202.06692', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06692'}
|
arxiv
|
\section{Regret Analysis of Alg. \ref{alg:bdb}}
\label{sec:reg_analysis}
\mainthm*
\begin{proof}[Proof of Theorem~\ref{thm:mainthm}]
The analysis follows from carefully combining our reduction (Theorem~\ref{thm:reduction}) with Theorem~1 of~\cite{zimmert2021tsallis} for MAB to both of the players. Indeed, for each player $i\in \{-1,1\}$, Algorithm~\ref{alg:bdb} chooses $k_{i,t}$ by following the decisions of Tsallis-INF \citep[Alg.~1]{zimmert2021tsallis} with $\alpha = 1/2$, symmetric regularization, learning rate $\eta_t = 4/\sqrt{t}$ and losses $\ell_{i,t}$ estimated in~\eqref{eq:hat_g} with standard importance sampling (IW).
\paragraph{Adversarial regime} A direct application of Theorem~1 of \cite{zimmert2021tsallis}, upper-bounds the pseudo-regret for each player $i \in \{-1,1\}$ as
\begin{equation*}
\max_{k \in [K]} {\mathbf E}\big[R_{i,T}(k)\big] \leq 4 \sqrt{KT} + 1 \,.
\end{equation*}
Combining the about bounds with the reduction from MAB to DB (Theorem~\ref{thm:reduction}) yields the adversarial pseudo-regret upper-bound
\[
{\mathbf E}\big[ R_T(k)\big] = \frac{1}{2}{\mathbf E}\big[ R_{-1,T}(k) + R_{+1,T}(k)\big] \leq 4\sqrt{KT} + 1.
\]
\paragraph{Adversarial regime with a self-bounding constraint} Our self-bounding constraint is slightly different from that of \cite{zimmert2021tsallis}, since it involves both players simultaneously. This is necessary so that our gap vector $\Delta$ can recover the standard suboptimality gaps used in stochastic dueling bandits.
Thus, we cannot directly combine their result with our black-box reduction in this case. However, the proof largely follows their analysis, except that the upper-bounds on the regret of both players must be combined in the middle of their analysis, just before they apply their self-bounding constraint assumption. Thus, we give here only the modification to the proof of their Theorem~1.
Following their proof of Thm. 1 until their pseudo-regret bound at the top of p. 23, we get for each player $i \in {\mathcal I}:= \{-1,+1\}$:
\begin{align*}
{\mathbf E} & \big[R_{i,T}(k)]\\
& \leq \sum_{k \neq k^*} \left(\sum_{t=1}^{T} \frac{\sqrt{{\mathbf E}[p_{i,t}(k)]}}{\sqrt{t}}
+ \sum_{t=T_0+1}^T \frac{{\mathbf E}[p_{i,t}(k)]}{4\sqrt{t}}\right) + M \,,
\end{align*}
where $M:= \sqrt{T_0} + \frac{3}{4}\sqrt{K} + 15 + 14 K \log(T)$ and $T_0 := \lceil \Delta_{\min}^{-2}/4\rceil$. Together with Theorem~\ref{thm:reduction} and taking the $\max$ over $k$, $\overline{R}_T$ is thus upper-bounded by
\begin{equation*}
\frac{1}{2} \sum_{i\in {\mathcal I}} \sum_{k \neq k^*} \left(\sum_{t=1}^{T} \frac{\sqrt{{\mathbf E}[p_{i,t}(k)]}}{\sqrt{t}}
+ \sum_{t=T_0+1}^T \frac{{\mathbf E}[p_{i,t}(k)]}{4\sqrt{t}}\right) + M \,.
\end{equation*}
Now, applying the self-bounding property~\eqref{eq:self_bounded} we get for any $\lambda \in [0,1]$
\begin{align*}
\overline{R}_T \leq \overline{R}_T + \lambda \bigg( \overline{R}_T - \frac{1}{2} {\mathbf E}\bigg[ \sum_{t=1}^{T} \sum_{k \neq k^*} \big(p_{+1,t}(k) + p_{-1,t}(k)\big) \Delta_k \bigg] + C\bigg)
\end{align*}
Thus, combined with the previous bound using $1+\lambda \leq 2$
\begin{align*}
&\overline{R}_T
\leq \frac{1}{2} \sum_{i\in {\mathcal I}}\sum_{k \neq k^*} \Bigg(\sum_{t=1}^{T} \bigg( \frac{2\sqrt{{\mathbf E}[p_{i,t}(k)]}}{\sqrt{t}} - \lambda \Delta_k {\mathbf E}[p_{i,t}]\bigg) \\
& \hspace*{3cm} + \sum_{t=T_0+1}^T \frac{{\mathbf E}[p_{i,t}(k)]}{2\sqrt{t}} \Bigg) + 2M + \lambda C \,. \\
& \leq \sum_{k\neq k^*} \Bigg(\sum_{t=1}^{T_0} \max_{z \geq 0} \Big\{\frac{2\sqrt{z}}{\sqrt{t}} - \lambda \Delta_k z\Big\} \\
& \hspace*{.5cm} + \sum_{t=T_0+1}^T \max_{z\geq 0} \Big\{\frac{2\sqrt{z}+\frac{1}{2} z}{\sqrt{t}} -\lambda \Delta_i z\Big\} \Bigg) + 2M + \lambda C
\end{align*}
Now, we are back with the same upper-bound \cite{zimmert2021tsallis} have in the middle of their page 23. Following their analysis by solving the optimization problems, summing over $t$, and optimizing $\lambda$ concludes.
\end{proof}
\section{Best-of-Both Dueling: Optimal Algorithm for Stochastic and Adversarial DB}
\label{sec:algo_bdb}
This section contains our main result, which is a simple reduction of the best-of-both-worlds result from~\cite{zimmert2021tsallis} to dueling bandits. In particular, it allows us to improve the best existing upper bound on the regret for stochastic and corrupted dueling bandits. The main idea is to apply the reduction of Algorithm~\ref{alg:reduction} with the multi-armed bandit algorithm (Online Mirror Descent with Tsallis regularizer) of~\cite{zimmert2021tsallis}. Of course, as for the classical adversarial multi-armed bandits, the losses $\ell_{i,t}(k) = o_t(k_{-i,t},k)$ cannot be observed for all $k \in [K]$. Therefore, they are estimated in the algorithm with the importance weight estimators
\begin{equation}
\label{eq:hat_g}
\hat{\ell}_{i, t}(k) = \begin{cases}
\ell_{i, t}(k) / p_{i, t}(k) & \text{if } k = k_{i, t} \\
0 & \text{otherwise}
\end{cases} \,.
\end{equation}
The resulted algorithm is described in Algorithm~\ref{alg:bdb}.
\begin{algorithm}[h]
\caption{\textbf{\algbdb\, (Best-of-Both DB)}}
\label{alg:bdb}
\begin{algorithmic}[1]
\STATE {\bfseries input:} Arm set: $[K]$, {$(\Psi_t)_{t=1,2,\dots}$}
\STATE {\bfseries init:} $G_{i,0} \leftarrow {\mathbf 0}_K$ for $i \in \{+1, -1\}$
\FOR{$t = 1, 2, \ldots, T$}
\STATE choose ${\mathbf p}_{i,t} = \nabla(\Psi_t+\mathcal{I}_{\Delta})^*(-\hat L_{i,t-1})$
\STATE For $i \in \{+1, -1\}$, sample $k_{i, t}$ from the distribution $(p_{i, t}(1), \dots, p_{i, t}(K))$
\STATE Observe preference feedback $o_t(k_{+1, t}, k_{-1, t})$
\STATE Compute $\hat{\ell}_{i, t}(k)$ for $i \in \{+1, -1\}$ and $k \in [K]$ using \eqref{eq:hat_g}
\STATE update $\hat L_{i,t} = \hat L_{i,t-1}+\hat{\ell}_{i,t}$\;
\ENDFOR
\end{algorithmic}
\end{algorithm}
\begin{restatable}[]{thm}{mainthm}
\label{thm:mainthm}
For any sequence of preference matrices $P_t$, the pseudo-regret of Algorithm~\ref{alg:bdb} with $\Psi_t(w) = \sqrt{t} \sum_{k=1}^K (\sqrt{w_k} - w_k/2)/8$ satisfies for any $T\geq 1$
\[
\overline{R}_T := \max_{k \in [K]} {\mathbf E}\big[R_T(k)] \leq 4 \sqrt{KT} + 1.
\]
Furthermore, if there exists a gap vector $\Delta \in [0,1]^K$ with a unique zero coordinate $k^* \in [K]$ and $C \geq 0$ such that
\begin{equation}
\label{eq:self_bounded}
\overline{R}_T \geq \frac{1}{2} {\mathbf E}\bigg[ \sum_{t=1}^T \sum_{k \neq k^*} \big(p_{+1,t}(k) + p_{-1,t}(k)\big) \Delta_k \bigg] - C\,,
\end{equation}
the pseudo regret also satisfies
\begin{align*}
\overline{R}_T \leq \sum_{k\neq k^*} \frac{4 \log T + 12}{\Delta_k} + 4 \log T + \frac{1}{\Delta_{\min}} + \frac{3}{2} \sqrt{K} + 8 + C,
\end{align*}
where $\Delta_{\min} = \min_{k \neq k^*} \Delta_k$.
\end{restatable}
The proof is postponed to Appendix~\ref{sec:reg_analysis}. Note that the theorem largely follows from (and is itself highly similar to) the best-of-both worlds regret-bound of \citep[Theorem~1]{zimmert2021tsallis} for MAB. We insist on the fact that our contribution should not be seen as technical. Indeed, the proof is just a clever combination of their MAB analysis with our black box reduction (Theorem~\ref{thm:reduction}). But we believe that the simplicity of our approach is its strength that can benefit the community of dueling bandits. As we will see, several state-of-the-art results of dueling bandits can be simultaneously improved as a direct consequence of this theorem.
Note that for simplicity, we restricted ourselves to importance weighted estimators~\eqref{eq:hat_g}. By using more sophisticated variance reduced estimators, as in \cite{zimmert2021tsallis}, the multiplicative constants can be reduced. Furthermore, similar to \cite{zimmert2021tsallis}, the result holds only for the pseudo-regret and not for the true regret. \citet{auer2016algorithm} have indeed proven that no optimal adversarial and stochastic high probability regret bounds can be obtained simultaneously for standard stochastic bandits. The learner must pay suboptimal logarithmic factors. The result can be extended to dueling bandits.
It is worth to emphasize that this is the first best-of-both worlds regret bound for general dueling bandits (the stochastic bound follows from the choice $C=0$, see Sec~\ref{sec:stoch}). \citet[Cor.~10]{zimmert2021tsallis} obtain a similar result for the very same algorithm but for utility based dueling bandits only.
\begin{rem}
Note that a single sub-routine of OMD to optimize the weights is actually enough to get the same regret guarantee. To do so, one samples both $k_{-1,t}$ and $k_{+1,t}$ independently from the same distribution $p_t = \nabla (\psi_t + {\mathcal I}_\Delta)^*(-\hat L_{t-1})$. Here, $\hat L_t = \sum_{s=1}^t \hat \ell_s \in {\mathbb R}_+^K$ and the importance weight estimator are defined for all $k \in [K]$ by
\[
\hat \ell_t(k) = \frac{1}{2}\big( \hat \ell_{-1,t}(k) + \hat \ell_{+1,t}(k)\big) \,.
\]
Noting that ${\mathbf E}[\hat \ell_t(k)] = {\mathbf E}\big[P_t(k_{-1,t},k) + P_t(k_{+1,t},k)\big]/2$ and ${\mathbf E}\big[\sum_{k=1}^Kp_t(k) \hat \ell_t(k)\big] = {\mathbf E}\big[P_t(k_{-1,t},k_{+1,t}) + P_t(k_{+1,t},k_{-1,t})\big]/2 = 1/2$, the proof follows similarly to the other one. Though the regret upper-bound is exactly the same, we believe that this version might lead to better performance because the two players share information.
\end{rem}
\section{Warm-Up: Near-Optimal Algorithm}
\label{sec:algo_rr}
In this section, we propose a new simple UCB based algorithm for stochastic dueling bandit, which is shown to have a nearly optimal gap-dependent Condorcet regret of $R_T^{\texttt{(cw)}} = O\big( \sum_{i=2}^K { i {\Delta(k^{\texttt{(cw)}},k)^{-1}}\log T}\big)$. Note that existing dueling bandit algorithms, that satisfy a non-asymptotic Condorcet regret bound, suffer an additional constant of order $\Delta_{\min}^{-2}$ \citep{bengs2021preference}, which implies a worst-case regret of order $O(T^{2/3})$ when $\Delta_{\min} \to 0$. The simple elimination algorithm below solves this drawback and depends only on $\Delta_{\min}^{-1}$ but at the cost of a suboptimal quadratic dependence in the number of arms $K$. Despite our efforts, we could not avoid this suboptimal factor by following the classical stochastic dual bandit analysis. In the following sections, we will show how to easily reach the optimal dependence in both $\Delta_{\min}$ and $K$ using a simple reduction from standard MAB.
\textbf{Main Ideas: Algorithm \algrr} The high-level idea of Algorithm~\ref{alg:rr} is to sequentially compare arms in a round-robin fashion and eliminate arms when they are significantly suboptimal compared to any other arm. Typically, after $t$ rounds, a suboptimal arm $k$ has been compared at least $t/K$ times with the Condorcet winner. Denoting by $\Delta_k$ its suboptimality gap, the arm is eliminated after at most $t_k$ rounds, where $(t_k/K)^{-1/2} \approx \Delta_k$. At that time the arm has been played $t_k/K$ times, yielding a regret of order $(t_k/K) \times \Delta_k \approx (K/\Delta_k^2) \times \Delta_k = K/\Delta_k$. Summing over the arms yields a final regret of order $O(K^2/\Delta_{\min})$.
\begin{algorithm}[h]
\caption{\textbf{\algrr\, (Near Optimal DB)}}
\label{alg:rr}
\begin{algorithmic}[1]
\STATE {\bfseries input:} Arm set: $[K]$, Confidence parameter $\delta \in (0,1)$
\STATE {\bfseries init:} Active arms: ${\mathcal A}_1 := [K]$, $n_{ij}(t) \leftarrow 0, ~\forall i,j \in [K]$
\FOR{$t = 1, 2, \ldots, T$}
\STATE Play $(k_{+1,t},k_{-1,t}) \in \text{argmin}_{i,j \in {\mathcal A}_t} \{ n_{ij}(t-1)\}$ \\
\STATE Observe $o_t(k_{+1,t},k_{-1,t}) = 1 - o_t(k_{+1,t},k_{-1,t})$
\FOR{$i,j \in {\mathcal A}_t$}
\STATE Define $\mathds{1}_t(i,j) := \mathds{1}\big\{\{i,j\} = \{k_{-1,s},k_{+1,s}\}\big\}$ and \\
\qquad $n_{ij}(t) := \sum_{s=1}^t \mathds{1}_t(i,j)$ \\
\qquad $\hat p_{ij}(t) := \frac{1}{n_{ij}(t)} \sum_{s=1}^t o_t(i,j) \mathds{1}_t(i,j)$ \\
\qquad $u_{ij}(t) := \hat p_{ij}(t) + \sqrt{\frac{\log (Kt/\delta)}{n_{ij}(t)}}$ \\
where we assume $x/0 = +\infty$.
\ENDFOR
\STATE ${\mathcal A}_{t+1} := {\mathcal A}_t \backslash \big\{i \in {\mathcal A}_t: \exists j \in {\mathcal A}_t \ \text{s.t.}\quad u_{ij}(t) < \frac{1}{2}\big\}$ \,.
\ENDFOR
\end{algorithmic}
\end{algorithm}
Without loss of generality assume the Condorcet winner $k^{\texttt{(cw)}} = 1$, and denote $\Delta_i = \Delta(1,i), ~\forall i \in [K]\setminus \{1\}$.
\begin{restatable}[]{thm}{thmrr}
\label{thm:rr}
Let $\delta \in (0,1/2)$, for any $T\geq 1$, the regret of Algorithm~\ref{alg:rr} is upper-bounded with probability at least $1-\delta$ as
\begin{equation*}
{R}_T^{\texttt{(cw)}} \leq \frac{K^2}{2} + 4 \sum_{i=2}^K \frac{ (i-1) \log (KT/\delta)}{\Delta_i}.
\end{equation*}
%
Further, when $T\geq K^2$, in the worst case (over the problem instance, i.e. $\Delta_2,\ldots,\Delta_K$), the regret of Algorithm~\ref{alg:rr} can be upper bounded as:
\[
{R}_T^{\texttt{(cw)}} \leq 2 K \sqrt{T \log(KT/\delta) }.
\]
\end{restatable}
\begin{rem}
In particular, our regret analysis shows that, except a logarithmic factor, the regret bound of \algrr~(Alg.~\ref{alg:rr}) is off only by a multiplicative factor of $K$, as follows from the known $\Omega(\sum_{k=1}^K \frac{\log T}{\Delta_k})$ Condorcet winner regret lower bound \cite{Yue+12,Komiyama+15}.
\end{rem}
The proof is postponed to Appendix~\ref{app:proofs}.
\section*{\centering\large{Supplementary for Versatile Dueling Bandits: Best-of-both-World Analyses for Online Learning from Preferences}}
\vspace*{1cm}
\section{Regret analysis of Algorithm~\ref{alg:rr}}
\label{app:proofs}
\thmrr*
\begin{proof}[Proof of Theorem~\ref{thm:rr}]
Let us denote by
\[
u_{ij}(t) := {\hat p}_{ij}(t)+c_{ij}(t)
\]
for any pair $(i,j)$ and time $t$, where
\[
c_{ij}(t):=\sqrt{\frac{ \log (Kt/\delta)}{n_{ij}(t)}} \,,
\]
and assume $\Delta_2 \leq \Delta_3 \leq \cdots \leq \Delta_K$ without loss of generality.
We will also assume the confidence bounds of Lem. \ref{lem:conf} holds good for all $t \in [T]$ and all pairs $(i,j)$, which is shown to hold good with probability at least $1-\delta$. In particular, this implies that the best arm cannot be eliminated, i.e., $1\in {\mathcal A}_t$ for all $t\geq 1$.
We start by noting that if the worst arm $K$ (since $\Delta_K = \max_{i = 2}^{K}\Delta_i$, arm-K gets maximally beaten by the CW) is played at time $t$, it means $u_{K1}(t) \geq \frac{1}{2}$.
However we also have,
\begin{align*}
u_{K1}(t) &= {\hat p}_{K1}(t) + c_{K1}(t)\\
& \leq p_{K1} + 2c_{K1}(t) = 1/2 - \Delta_K + 2c_{K1}(t),
\end{align*}
where the inequality holds due to Lem. \ref{lem:conf} and the last equality holds by noting $p_{K1} = 1-p_{1K} = 1 - (1/2 + \Delta_K) = 1/2 - \Delta_K$.
So $u_{K1}(t) > 1/2$ can only hold good if $c_{K1}(t) > \Delta_K/2$ which implies,
\begin{align}
\label{eq:rr1}
& n_{K1}(t) \leq \frac{4 \log (Kt/\delta)}{\Delta_K^2}.
\end{align}
But by the our algorithm design since all the pairs are drawn in a round robin fashion, at any round $t \in [T]$, for any two distinct pairs $(i,j)$ and $(i',j')$ that are in ${\mathcal A}_t$ note that
\begin{align}
\label{eq:rr0}
|n_{ij}(t) - n_{i'j'}(t)| \leq 1\,.
\end{align}
Thus the total regret incurred by Alg. \ref{alg:rr} at rounds where $K \in \{k_{+1,t},k_{-1,t}\}$, can be upper bounded as:
\begin{align*}
\sum_{t=1}^T\sum_{k < K} & {\mathbf 1}(\{k_{+1,t},k_{-1,t}\} = \{k,K\}) \frac{\Delta_{K} + \Delta_k}{2} \\
& \leq \sum_{k=1}^{K-1} n_{kK}(T) \Delta_K \leq (K-1) (1+n_{K1}(T)) \Delta_K \\
& \leq (K-1) \Big(1+ \frac{4 \log (Kt/\delta)}{\Delta_K^2}\Big) \Delta_K \\
& = (K-1) \Big(\Delta_k + \frac{4 \log (Kt/\delta)}{\Delta_K}\Big) \,.
\end{align*}
Similarly, note for any $i \in \{2,3,\ldots K-1\}$, we can upper bound the regret of rounds where $i$ was played in the duel as:
\begin{align*}
\sum_{t=1}^T\sum_{k < i} & {\mathbf 1}(\{k_{+1,t},k_{-1,t}\} = \{k,i\}) \frac{\Delta_{i} + \Delta_k}{2} \\
& \leq \sum_{k=1}^{i-1} n_{ki}(T) \Delta_i \leq (i-1) (1+n_{1i}(T)) \Delta_i \\
& \leq (i-1) \Big(\Delta_i + \frac{4 \log (Kt/\delta)}{\Delta_i}\Big)\,.
\end{align*}
Thus we can bound the total regret of Algorithm \ref{alg:rr} as:
\begin{align*}
\sum_{t=1}^T\sum_{i = 2}^K \sum_{k = 1}^{i-1} & {\mathbf 1}(\{k_{+1,t},k_{-1,t}\} = \{k,i\}) \frac{\Delta_{i} + \Delta_k}{2} \\
& \leq \sum_{i = 2}^K (i-1) \Big(\Delta_i + \frac{4 \log (Kt/\delta)}{\Delta_i}\Big) \\
& \stackrel{(\Delta_i\leq 1/2)}{\leq} \frac{K^2}{4} + 4 \sum_{i = 2}^K (i-1) \frac{ \log (Kt/\delta) }{\Delta_i}
\end{align*}
which concludes the first half of the proof.
Further, to show the second part of the claim (analyzing worst-case gap-independent regret bound of Algorithm \ref{alg:rr}), note that Eqn. \eqref{eq:rr1} equivalently implies for any $i \in [K]\setminus \{1\}$:
\begin{align*}
\Delta_i \leq \sqrt{\frac{4 \log (Kt/\delta)}{n_{i1}(t)}} \,
\end{align*}
Hence we can alternatively upper bound the regret as:
\begin{align*}
R_T &= \sum_{i=2}^K \sum_{k=1}^{i-1} n_{ik}(T) \frac{\Delta_j + \Delta_k}{2} \leq \sum_{i=2}^K \sum_{k=1}^{i-1} n_{ik}(T) \Delta_i\\
& \leq \sum_{i=2}^K \sum_{k=1}^{i-1} n_{ik}(T) \sqrt{\frac{4 \log (KT/\delta)}{n_{i1}(T)}} \\
& \overset{(a)}{\leq} 2 \sum_{i=2}^K \sum_{k=1}^{i-1} \sqrt{2 n_{ik}(T) \log (Kt/\delta)} \\
& \overset{(b)}{\leq} \sum_{i=2}^{K} 2\sqrt{K^2 \sum_{i=2}^K \sum_{k=1}^{i-1} n_{ik}(T)\log(KT/\delta) }\\
&\leq 2K \sqrt{ T \log(KT/\delta)}\,,
\end{align*}
where $(a)$ follows from the observation of Eqn.~\eqref{eq:rr0} which implies $n_{i1}(T) \geq n_{ik}(T)$ when $T \geq K^2$ and $(b)$ from Jensen's inequality and $\sum_{i=2}^K(i-1) \leq K^2/2$.
\end{proof}
\begin{restatable}[]{lem}{lemconf}
\label{lem:conf}
For any $\delta \in (0,1/2)$. Then, with probability at least $1-\delta$, for any pair $i,j \in [K]$ and any time $t \in [T]$%
\[
{\hat p}_{ij}(t)-c_{ij}(t) \leq p_{ij} \leq {\hat p}_{ij}(t)+c_{ij}(t), \qquad \forall t \in [T] ,
\]
where $c_{ij}(t):=\sqrt{\frac{\log (Kt/\delta)}{n_{ij}(t)}}$.
\end{restatable}
\begin{proof}
Let us denote by $u_{ij}(t) := {\hat p}_{ij}(t)+c_{ij}(t)$ and $ \ell_{ij}(t) := {\hat p}_{ij}(t)+c_{ij}(t)$.
Note the inequality holds trivially at round $t$, for any pair $(i,j)$ for which $n_{ij}(t) = 0$ since in these cases $\ell_{ij}(t) \leq 0$ and $u_{ij}(t) \geq 1$.
Now consider any pair $(i,j)$ and round $t \in [T]$ such that $n_{ij}(t) > 0$. Note in this case by Hoeffding's Inequality:
\begin{multline*}
Pr \Bigg(|p_{ij}-\hat p_{ij}(t) | > \sqrt{\frac{\ln (Kt/\delta)}{n_{ij}(t)}} \Bigg) \\
\leq 2e^{-2n_{ij}(t)\frac{\ln (Kt/\delta)}{n_{ij}(t)}} = \frac{2\delta^2}{K^2t^2} \leq \frac{\delta}{K^2t^2}\,.
\end{multline*}
Taking union bound over all $K \choose 2$ pairs and time $t \in [T]$ we get:
\begin{align*}
Pr & \Bigg(\exists i,j \in [K], t \in [T] \text{ s.t. } |p_{ij}-\hat p_{ij}(t) | > \sqrt{\frac{\ln (Kt/\delta)}{n_{ij}(t)}} \Bigg) \\
& \leq \sum_{t = 1}^T \sum_{i=2}^{K}\sum_{j = 1}^{i} \frac{\delta}{K^2t^2} \leq \sum_{t = 1}^\infty \frac{\delta}{2t^2} \leq \frac{\delta\pi^2}{12} \leq \delta,
\end{align*}
where in the second last inequality we used $\sum_{t = 1}^\infty \frac{1}{t^2} < \frac{\pi^2}{6}$. This concludes the claim.
\end{proof}
\section*{Acknowledgment}
Thanks to Julian Zimmert and Karan Singh for the useful discussions on the existing best-of-both-world multiarmed bandits results.
\newpage
\bibliographystyle{plainnat}
\section{Discussions}
\label{sec:concl}
We studied the problem of \texttt {Versatile Dueling Bandits}, which gives the first \emph{`best-of-both' world} result for the problem of Dueling Bandits. The crux of our analyses relies on a \emph{novel idea of decomposing the dueling bandit regret into multiarmed bandit (MAB) regret} by interpreting the dueling preference feedback as a certain realization of adversarial reward sequence.
An important byproduct of our best-of-both dueling analysis is, this gives the first order optimal gap-dependent regret bound for $K$-armed stochastic dueling bandits, closing the decade-long open problem of tightness of `Condorcet dueling bandit regret'.
Further we also analyze the robustness of our algorithm under corrupted preference feedback setting, which provably improves over the state-of-the art corrupted dueling bandits algorithms
\textbf{Future Works.}
Proving the first \emph{best-of-both world} result for dueling bandits using our novel reduction idea is just a first step towards exploring the possibility of understanding how far this idea can be extended to apply existing multiarmed bandits results to dueling bandits frameworks,
instead of putting individual and isolated efforts in developing dueling bandit algorithms, taking inspirations from existing MAB generalizations.
Some such extensions could be to analyze dynamic dueling bandit regret under non-stationary preferences \cite{wei21,luo+19,besbes+15}, item non-availability \cite{neu14,kanade09}, delayed feedback \cite{delay1,delay2,delay3}, budget constraints \cite{budget1,budget2,budget3}, or even the more general reinforcement learning (RL) scenarios \cite{ucrl,talebi18,ng06}, for which there are already well established theory of works with MAB framework.
Also under what settings of Dueling Bandits, its corresponding MAB counterpart based reductions are bound to fail?
Finally it is worth mentioning that, an ambitious (and broad) objective along these line of thoughts is to understand the connection between different learning scenarios to dueling bandits,
e.g. feedback graphs \cite{Alon+15,Alon+17},
partial monitoring problems \cite{pm1,pm2,pm3},
markov games \cite{xie+20,bai+20,bai20},
etc. The obvious motivation being to understand how far we can re-engineer the existing results from related learning literature to solve the online preference bandits problems.
\section{Improvements Over Existing Dueling Bandit Results}
Also our approach and analysis is rather simple, it allows to outperform the best existing regret-upper bounds for stochastic dueling bandits with or without corruption. We believe that the dueling bandit community will benefit from this reduction and that it may be applied to a wider scope such as to deal with non-stationarity, delays, or non-standard feedbacks (graphs) for which many results already exist in standard multi-armed bandits.
\subsection{Stochastic Dueling Bandits with Condorcet Winner}
\label{sec:stoch}
In stochastic dueling bandits, the preference matrices $P_t$ are fixed over time $P_t = P$ for all $t \geq 1$. Under the Condorcet winner assumption there exists $k^{\texttt{(cw)}} \in [K]$ such that $P(k^{\texttt{(cw)}},k) > \frac{1}{2}$ for all $k \neq k^{\texttt{(cw)}}$. Then, the suboptimality gaps of all actions $k \in [K]$ are defined as
$
\Delta_k := P(k^{\texttt{(cw)}}, k) - \frac{1}{2}.
$
Remarking that in this case the self-bounding assumption~\eqref{eq:self_bounded} is satisfied with $C = 0$, since
\begin{align*}
\overline{R}_T
& = \frac{1}{2} \sum_{t=1}^T {\mathbf E}\Big[ P_t(k^{\texttt{(cw)}},k_{+1,t}) + P_t(k^{\texttt{(cw)}},k_{-1,t}) - 1\Big] \\
& = \frac{1}{2} \sum_{t=1}^T {\mathbf E}\Big[\Delta_{k_{+1,t}} + \Delta_{k_{-1,t}}\Big] \\
& = \frac{1}{2} \sum_{t=1}^T {\mathbf E}\Big[ \sum_{k \neq k^{\texttt{(cw)}}} (p_{-1,t} + p_{+1,t}) \Delta_k \Big]\,,
\end{align*}
we get the following corollary from Theorem~\ref{thm:mainthm}.
\begin{corollary} For stochastic dueling bandits with Condorcet winner, the pseudo-regret of Algorithm~\ref{alg:bdb} with well-chosen parameters satisfies
\[
\overline{R}_T \leq \sum_{k\neq k^{\texttt{(cw)}}} \frac{4 \log T + 12}{\Delta_k} + 4 \log T \\
+ \frac{1}{\Delta_{\min}} + \frac{3}{2} \sqrt{K} + 8\,.
\]
\end{corollary}
Note that the above bound is the first pseudo-regret upper-bound for stochastic dueling bandit that does not suffer from a $\Delta_{\min}^{-2}$ dependence under the Condorcet winner assumption, without a quadratic dependence on the number of arms, $K$, which is a concern when it comes to dealing with
large-scale problems. For instance, RUCB \cite{Zoghi+14RUCB} satisfies a regret bound of order $O(K \log(T) \Delta_{\min}^{-2} + K^2)$, MergeRUCB \cite{Zoghi+15MRUCB} has linear dependence on $K$ but suffers $O(K \log(T)\Delta_{\min}^{-2})$. Finally, RMED from \cite{Komiyama+15} is asymptotically optimal when $T\to \infty$ but also suffers from large constant terms ($K^2$ and $\Delta_{\min}^{-2}$) and is only valid for $K\to \infty$. We refer the reader to \cite{bengs2021preference} for existing results on stochastic dueling bandits.
\subsection{Corrupted Regime}
\label{sec:corruption}
Here, we consider the stochastic dueling bandit problem in the presence of adversarial corruptions. The robustness to adversarial corruption has known recent progress in the MAB setting \citep{gupta2019better,lykouris2018stochastic,zimmert2021tsallis} and has recently been extended to the DB framework \citep{agarwal2021stochastic}.
The preference matrices are fixed $P_t = P$ for all $t\geq 1$ and we assume the existence of a Condorcet winner $k^{\texttt{(cw)}}$. Furthermore, an adversary may corrupt the outcomes of some duels by replacing the results of the duels $o_t(k,k')$ with corrupted ones $\tilde o_t(k,k')$. At the end of each round, the player only observes $\tilde o_t(k_{+1,t},k_{-1,t})$. The objective of the player is to minimize the pseudo-regret $\bar R_T$ under a bounded total amount of corruption
\[
C := \sum_{t=1}^T \sum_{k \neq k^{\texttt{(cw)}}} \big|o_t(k^{\texttt{(cw)}},k) - \tilde o_t(k^{\texttt{(cw)}},k)\big|.
\]
We show here that similarly to what happens for standard Multi-armed bandits in \cite{zimmert2021tsallis}, this corrupted setting is a special case of the self-bounding assumption~\eqref{eq:self_bounded}. Indeed, defining $\tilde P_t$ the corrupted preference matrices by $\tilde P_t(k,k') = {\mathbf E}\big[\tilde o_t(k,k')\big]$ and the corrupted pseudo-regret
\[
\widetilde{R}_T(k) = \frac{1}{2} {\mathbf E}\bigg[\sum_{t=1}^T \tilde P_t(k,k_{+1,t}) + P_t(k,k_{-1,t}) -1\bigg] \,,
\]
we have
\begin{align*}
& \widetilde{R}_T(k^{\texttt{(cw)}}) \\
&= \frac{1}{2} {\mathbf E}\bigg[ \sum_{t=1}^T \tilde o_t(k^{\texttt{(cw)}},k_{+1,t}) + \tilde o_t(k^{\texttt{(cw)}},k_{-1,t}) - 1\bigg] \\
&\geq \frac{1}{2} {\mathbf E}\bigg[ \sum_{t=1}^T o_t(k^{\texttt{(cw)}},k_{+1,t}) + o_t(k^{\texttt{(cw)}},k_{-1,t}) - 1\bigg] - C \\
& = \overline{R}_T - C \\
& = \frac{1}{2} \sum_{t=1}^T {\mathbf E}\Big[ \sum_{k \neq k^{\texttt{(cw)}}} (p_{-1,t} + p_{+1,t}) \Delta_k \Big] - C \,.
\end{align*}
Therefore, the corrupted regime satisfies the self-bounding assumption~\eqref{eq:self_bounded}. Applying Theorem~\ref{thm:mainthm} on the corrupted regime and using that we also have $\overline{R}_T(k^{\texttt{(cw)}}) \leq \widetilde{R}_T(k^{\texttt{(cw)}}) + C$, we get the following corollary
\begin{corollary}\label{cor:corruption}
For stochastic dueling bandits with Condorcet winner and corruptions, whose total amount is bounded by $C$, the pseudo-regret $\overline{R}_T$ Algorithm~\ref{alg:bdb} is upper-bounded as
\begin{align*}
\overline{R}_T \leq \sum_{k\neq k^{\texttt{(cw)}}} \frac{4 \log T + 12}{\Delta_k} + 4 \log T
+ \frac{1}{\Delta_{\min}} + \frac{3}{2} \sqrt{K} + 8 + 2C.
\end{align*}
\end{corollary}
Although Corollary~\ref{cor:corruption} easily follows from Theorem~\ref{thm:mainthm} which itself easily follows from Theorem~1 of \cite{zimmert2021tsallis}, the latter result significantly improves upon the recent results on dueling bandit with corruptions obtained by \cite{agarwal2021stochastic}. Indeed, the latter provide for the same setting and a significantly more sophisticated procedure a high-probability regret bound of order
\[
O\left( \frac{K^2 C}{\Delta_{\min}} + \sum_{k \neq k^{\texttt{(cw)}}} \frac{K^2}{\Delta_k^2} \log \Big(\frac{K}{\Delta_k}\Big) + \sum_{k \neq k^{\texttt{(cw)}}} \frac{\log T}{\Delta_k} \right) \,.
\]
As often in the dueling bandit literature, it suffers from both a quadratic dependence on the number of actions and $\Delta_{\min}^{-1}$. Furthermore, our regret bound is sublinear in $T$ as soon as the corruption level is $o(T)$ while \citet{agarwal2021stochastic} can only afford $o(\Delta_{\min} T/K^2)$.
Moreover, \citet{zimmert2021tsallis} also provide an upper-bound for stochastic bandits with adversarial corruption. The latter is of order
$
O\bigg(\sum_{k\neq k^{\texttt{(cw)}}} \frac{\log T}{\Delta_k} + \sqrt{C \sum_{k\neq k^{\texttt{(cw)}}} \frac{\log T}{\Delta_k} }\bigg)\,,
$
which seems to outperform our bound when $C$ is large. The difference is since they upper-bound the corrupted regret $\widetilde R_T(k^{\texttt{(cw)}})$ and not $\bar R_T$.
\section{Experiments}
\label{sec:expts}
\textbf{Algorithms. }
We compared the performances of the following algorithms:
$1.$ VDB: Our proposed \algbdb\, (Alg. \ref{alg:bdb}) algorithm.
$2.$ RUCB: The algorithm proposed in \cite{Zoghi+14RUCB} for K-armed stochastic dueling bandits for CW regret. (We set the algorithm parameter $\alpha = 0.6$).
$3.$ RMED: Another algorithm for CW regret as proposed in \cite{Komiyama+15}. (We set the algorithm parameter $f(K) = 0.3K^{1.01}$ as suggested in their experimental evaluation).
$4.$ DTS: The double thompson sampling algorithm of \cite{DTS}. (Here again we set the similar algorithm parameter $\alpha = 0.6$).
$5.$ REX3: As introduced in \cite{Adv_DB}. Note that their suggested optimal tuning parameters, i.e. the uniform exploration rate $\gamma$ as well as the learning rate $\eta$ requires the knowledge of problem dependent parameters $\tau$ (see Thm. 1 of \cite{Adv_DB}) which are unknown to the learner. We used $T$ in place of $\tau$ henceforth.
\textbf{Performance Measures.} We report the average cumulative regret (Eqn. \eqref{eq:sreg}) of the algorithms averaged over $20$ runs.
\subsection{Stochastic Preferences}
We compared their regret performance across the following stochastic environments:
\textbf{Constructing Preference Matrices ($\P$).}
We use four different utility parameter $\boldsymbol \theta = (\theta_1,\ldots,\theta_K)$ based preference models where the underlying preference model is defined as $P(i,j):= \frac{\theta_i}{\theta_i + \theta_j} ~\forall i,j \in [K]$.
The model is famously studied as BTL model or model generally Plackett-Luce model \cite{SGwin18,ChenSoda+18,shah17}. Note this ensures $P$ to have \emph{total-ordering} \cite{BTM,falahatgar_nips}.
In particular we consider the following choices of $\boldsymbol \theta$:
$1.$ {\it Trivial} $2.$ {\it Easy} $3.$ {\it Medium}, and $4.$ {\it Hard} with their respective $\boldsymbol \theta$ parameters are given by:
$1.$ {\it Trivial:} $\boldsymbol \theta(1) = 1$, $\boldsymbol \theta(2:K) = 0.5$.
$2.$ {\it Easy:} $\boldsymbol \theta(1:\lfloor K /2 \rfloor) = 1$, $\boldsymbol \theta(\lfloor K/2 \rfloor + 1:K) = 0.5$.
$3.$ {\it Medium:} $\boldsymbol \theta(1:\lfloor K/3 \rfloor) = 1$, $\boldsymbol \theta(\lfloor K/3 \rfloor+1:\lfloor 2K/3 \rfloor) = 0.7$, $\boldsymbol \theta(\lfloor 2K/3 \rfloor + 1:K) = 0.4$.
$4.$ {\it Hard:} $\boldsymbol \theta(i) = 1 - (i-1)/K,\, \forall i \in [K]$. Note for each $\boldsymbol \sigma^* = (1 > 2> \ldots K)$.
For the purpose of our experiments we set $K=10$.
We also evaluated the algorithms on two general $10\times 10$ preference matrices {\it Car} and {\it Hurdy} as also used in \cite{niranjan2017,SG18}.
\textbf{Regret vs Time.}
Fig. \ref{fig:vs_t} shows the relative performances of different algorithms with time. As follows from the plots, in general \textit{VDB} (\algbdb) outperforms the rest in all instances, with \textit{DTS} being closely competitive in some cases. In terms of the problem hardness, as their names suggest too, the
\textit{Trivial} and \textit{Easy} instances are easiest to learn as the best-vs-worst item preferences are well separated in these cases and the diversity of the item preferences across different groups are least. Consequently the algorithms yield slightly more regret on \emph{instance-Medium} due to higher preference diversity, and the hardest instance being \emph{Hard} where the algorithms require maximum time to converge, though \textit{VDB} reaching the convergence fastest still.
\begin{figure}[h]
\begin{center}
\includegraphics[width=0.33\textwidth]{trivial.png}\hspace{-5pt}
\includegraphics[width=0.33\textwidth]{easy.png}
\includegraphics[width=0.33\textwidth]{med.png}\hspace{-5pt}
\includegraphics[width=0.33\textwidth]{hard.png}
\includegraphics[width=0.33\textwidth]{car.png}\hspace{-5pt}
\includegraphics[width=0.33\textwidth]{hurdy.png}
\vspace{-10pt}
\caption{Averaged cumulative regret over time}
\label{fig:vs_t}
\end{center}
\end{figure}
\smallskip
\subsection{Corrupted Preferences}
We also evaluated the performances of algorithms in presence of corruption (Sec. \ref{sec:corruption}). In particular, Fig. \ref{fig:vs_corr2} and \ref{fig:vs_corr4} respectively shows the relative performances of the algorithms with $20\%$ and $40\%$ corrupted feedback (at each round, we flip the winner feedback with that certain probability) respectively on \textit{Medium} and \textit{Hard} Plackett-Luce instances. As expected, the performances of all the algorithms decay significantly with increasing degree of feedback-corruption, however as before, \textit{VDB} consistently performed best over all the baselines and tend to converge the fastest among all.
\begin{figure}[h]
\begin{center}
\includegraphics[width=0.34\textwidth]{med-corrupted_20_.png}\hspace{-5pt}
\includegraphics[width=0.34\textwidth]{hard-corrupted_20_.png}
\vspace{-10pt}
\caption{Averaged cumulative regret ($20\%$ corrupted feedback)}
\label{fig:vs_corr2}
\end{center}
\end{figure}
\vspace{-20pt}
\begin{figure}[h]
\begin{center}
\includegraphics[width=0.34\textwidth]{med-corrupted_40_.png}\hspace{-5pt}
\includegraphics[width=0.34\textwidth]{hard-corrupted_40_.png}
\vspace{-10pt}
\caption{Averaged cumulative regret ($40\%$ corrupted feedback)}
\label{fig:vs_corr4}
\end{center}
\end{figure}
\section{Introduction}
\label{sec:intro}
Studies have shown that it is often easier, faster and less expensive to collect feedback on a relative scale rather than asking ratings on an absolute scale. E.g., to understand the liking for a given pair of items, say (A,B), it is easier for the users to answer preference-based queries like: ``Do you prefer Item A over B?", rather than their absolute counterparts: ``How much do you score items A and B in a scale of [0-10]?".
From a system designer's point of view, exploiting such user preference information could greatly aid in improving systems performances,
especially when data can be collected on a relative scale and online fashion; such as recommendation systems, crowd-sourcing platforms, training bots, multi-player games, search-engine optimization, online retail, just to name a few.
In many real world problems, especially where human preferences are elicited in an online fashion, e.g., design of surveys and expert reviews, assortment selection, search engine optimization, recommender systems, ranking in multiplayer games, etc, or even more general reinforcement learning problems where rewards shaping is often a challenging problem (e.g. if multi-objective rewards etc.), and instead, a preference feedback is much easier to elicit.
Due to the widespread applicability and ease of data collection with relative feedback, learning from preferences has gained much popularity in the machine learning community and widely studied as the problem of \emph{Dueling-Bandits} (DB) over last decade \cite{Yue+12,ailon2014reducing,Zoghi+14RUCB,Zoghi+14RCS,Zoghi+15}, which is an online learning framework that generalizes the standard multiarmed bandit (MAB) \cite{Auer+02} setting for identifying a set of `good' arms from a fixed decision-space (set of items) by querying preference feedback of actively chosen item-pairs.
\paragraph{Dueling Bandits Problem (DB)} More formally, in classical dueling bandits with $K$ arms, the learning proceeds in rounds, where at each time step $t \in \{1,2,\ldots,T\}$, the learner selects a pair of arms $(k_{+1,t},k_{-1,t})$ and receives the winner of the duel in terms of a binary preference feedback $o_t(k_{+1,t},k_{-1,t}) \sim \text{Ber}(P_t(k_{+1,t},k_{-1,t}))$, sampled according to an underlying preference matrix $\P_t \in [0,1]^{K \times K}$ (chosen adversarially in the most general setup). The objective of the learner is to minimize the regret with respect to a (or set of) `best' arm(s) in hindsight.
\paragraph{Related Works} Over the years, the problem of Dueling Bandits has been studied with various objectives and generalizations. This includes analyzing the learning rate under various preference structures, such as total ordering, transitivity, stochastic triangle inequality \cite{falahatgar_nips,BTM}, utility based preference structure \cite{ailon2014reducing,Busa_pl,SG18,ChenSoda+18}, or under any general pairwise preference matrices \cite{CDB,SparseDB,Komiyama+16}. Consequently, depending on the underlying preference structure, the learner's performance has been evaluated w.r.t. different benchmarks including
among other promising generalizations. The problem of stochastic dueling bandits has been studied for both PAC \cite{falahatgar2,Busa_pl,sui2018advancements} as well as regret minimization setting \cite{Zoghi+14RUCB,Yue+09,WeakDB,Zoghi+15} under several notions of benchmarks including best arm identification \cite{SGwin18,Busa_aaai,falahatgar_nips}, top-set detection \cite{Busa_top,SG19}, ranking \cite{Ren+18,SGrank18}, amongst many. Some recent works have also looked into the problem for adversarial sequence of preference matrices \cite{gupta2021optimal,Adv_DB,ADB}, robustness to corruptions~\cite{agarwal2021stochastic}, or extending dueling bandits to potentially infinite arm sets \cite{S21,ContDB} and contextual scenarios \cite{CDB,SK21}. Another interesting line of work along dueling bandits is to study the implications for its subsetwise generalization \cite{Ren+18,sui2018advancements,Brost+16,ChenSoda+18}, also studied as battling bandits \cite{SG18,SG19,bengs2021preference}.
Despite widespread surge of interest along this line of research and multiple attempts there are some fundamental long standing open questions in dueling bandits which are (surprisingly!) yet unresolved.
\vspace{3pt}
\paragraph{Unresolved Question \#1}
One of the longest and most widely studied objective in stochastic dueling bandit is to measure regret w.r.t. the Condorcet winner (CW) arm: Given a preference matrix $P$, an arm $k^{\texttt{(cw)}} \in [K]$ is termed as the CW of $P$ if $P(k^{\texttt{(cw)}},k) > 0.5 ~\forall k \in [K]\setminus \{k\}$ \cite{Zoghi+14RUCB}.
Assuming $P$ contains a CW, there have been several attempts to design an optimal regret dueling bandit algorithm against the CW arm $k^{\texttt{(cw)}}$ (see Eq.~\eqref{eq:cwreg} for details) \cite{Zoghi+14RUCB,DTS,Komiyama+15,bengs2021preference}.
\iffals
defined as:
\begin{equation}
\label{eq:cwreg}
R_T^{\texttt{(cw)}} := \sum_{t=1}^T \frac{1}{2}\left( \Delta(k^{\texttt{(cw)}}, k_{+1,t}) + \Delta(k^{\texttt{(cw)}}, k_{-1,t}) \right),
\end{equation}
{\mathbf f}
Without loss of generality, assuming $k^{\texttt{(cw)}}=1$ and by denoting $\Delta_{i} = P(1,i)-0.5$ to be the suboptimality gap of item $i$ w.r.t. the CW, it is well known that the dueling bandit regret lower bound (w.r.t. the CW arm) is $\Omega\big( \sum_{i = 2}^K \frac{\log T}{\Delta_i} \big)$ \cite{Yue+12,Komiyama+15}. However, despite several attempts, it is still unknown how to design an order optimal dueling bandit algorithm for the CW regret. Existing upper-bounds suffer all suboptimal $\Delta_{\min}^{-2}$ and/or $K^2$ dependencies.
Notably, under more restricted structures, e.g. total ordering \cite{BTM}, or utility based preferences \cite{Busa_pl,SGinst20}, or even special preference structures where the suboptimality gaps of all items ($\Delta_i$, $~i \in [K]\setminus \{1\}$) are equal, the problem is easier to solve and tight regret guarantees are available with matching upper and lower bound analysis. However, for the case of any general preference matrix with CW, none of the existing attempts were able to close this regret analysis gap successfully \cite{Zoghi+14RUCB,DTS,WeakDB,Komiyama+15,SG21dbaa}.
Subsequently, the natural questions to ask are:
\begin{center}
\emph{(1). Is the lower bound tight? (2). How to close the gap between the upper and lower bound for CW regret?}
\end{center}
\paragraph{Unresolved Question \#2} Till date, all the proposed algorithms of dueling bandits need to know underlying preference structure ahead of time in order to yield optimal regret bounds. In fact, different algorithms have been proposed based on the nature/structures of the underlying preference matrices, e.g. \cite{BTM} for preferences with total orderings in terms of (relaxed) stochastic transitivity and stochastic triange inequality; \cite{ailon2014reducing,Adv_DB} for linear-utility based preferences, \cite{Busa_pl} for BTL models, \cite{Zoghi+14RUCB,Komiyama+15,DTS} for stochastic preferences in presence of CW, \cite{ADB,Adv_DB} for adversarial sequence of preferences, etc. However, it might not always be realistic to assume complete knowledge of the properties underlying preference matrices.
Thus the daunting question to ask in this regard is
\begin{center}
\emph{Is it possible to design an order optimal `best-of-both-world' algorithm for dueling bandits?}
\end{center}
That is, an algorithm that can adapt itself to the underlying structures of the preference environments and give optimal regret for both stochastic and adversarial settings? There has been a series of work on this line for the MAB framework \citep[e.g.,][]{bubeck2012best,auer2016algorithm,zimmert2021tsallis}, but unfortunately there has not been any existing `best-of-both-world' attempt for general dueling bandits.
\vspace{3pt}
\paragraph{Unresolved Question \#3} In any real world situation, the true feedback are often corrupted with some form of system noise. Undoubtedly, the binary $0/1$ bit dueling preferences are extremely prone to such noises when the learner might get to observe a flipped bit (adversarially corrupted) instead of the true dueling feedback.
\begin{center}
\emph{Can we design an efficient dueling bandit algorithm which is robust to adversarial corruptions and provably optimal?}
\end{center}
\paragraph{Our Contributions}
In this paper, we answer all of the above three questions affirmatively. The list of our specific contributions can be summarized as follows:
\begin{enumerate}[ topsep=-\parskip]
\item \textbf{A novel insight on the reduction from MAB to DB.} \citet{ailon2014reducing} proposed a reduction from MAB to utility-based dueling bandits. We show that the latter can easily be extended to more general dueling bandit problems (including CW), with significant consequences (see below) on the state of the art in dueling bandits theory. We believe that the reduction will find wider application in solving a diverse class of dueling bandit settings, using analyses of their MAB counterparts, which are otherwise studied separately from MAB with often more complex solutions and worse guarantees.
\item \textbf{First Best-of-Both World regret for DB.} Applying the above reduction to a Best-of-Both world algorithm from MAB, we provide an algorithm that simultaneously guarantees a pseudo-regret bound $O(\sqrt{KT})$ in the adversarial setting and $O(K \log(T)/\Delta_{\min})$ in the stochastic one.
\item \textbf{Robustness to adversarial corruptions.} Our algorithm is robust to adversarial corruptions and significantly improves existing results in DB \cite{agarwal2021stochastic}.
\item \textbf{Optimal stochastic gap-dependent Regret.} Our algorithm also provides the first optimal Condorcet regret, which suffers neither from a suboptimal dependence on $\Delta_{\min}^{-2}$ nor from a quadratic dependence on the number of arms.
\item \textbf{Another easy algorithm for stochastic DB.} We also propose a new very simple elimination algorithm with $O(\sum_{i = 2}^K\frac{K\log T}{\Delta_i})$ Condorcet regret.
\item \textbf{Experimental evaluations. } Finally we corroborate our theoretical results with extensive empirical evaluations (Sec.\,\ref{sec:expts}).
\end{enumerate}
\section{Problem Formulation}
\label{sec:prob}
\textbf{Notations.} Decision space (or item/arm set) $[K]: = \{1,2,\ldots, K\}$.
For any matrix ${\mathbf M} \in {\mathbb R}^{K \times K}$, we define $m_{ij} := M(i,j),~\forall i,j \in [K]$.
${\mathbf 1}(\cdot)$ denotes the indicator random variable which takes value $1$ if the predicate is true and $0$ otherwise and $\lesssim$ a rough inequality which holds up to universal constants. For any two items $x,y \in [K]$, we use the symbol $x \succ y$ to denote $x$ is preferred over ${\mathbf y}$.
By convention, we set $\frac{0}{0}:=0.5$.
\noindent \textbf{Setup. } We assume a decision space of $K$ arms denoted by ${\mathcal A}:= [K]$. At each round $t$, the task of the learner is to select a pair of actions $(k_{+1,t},k_{-1,t}) \in [K]\times [K]$, upon which a preference feedback $o_t \sim \text{Ber}(P_t(k_{+1,t},k_{-1,t}))$ is revealed to the learner according to the underlying preference matrix $\P_t \in [0,1]^{K \times K}$ (chosen adversarially), such that the probability of $k_{+1,t}$ being preferred over $k_{-1,t}$ is given by $Pr(o_t = 1):= Pr(k_{+1,t} \succ k_{-1,t}) = P_t(k_{+1,t},k_{-1,t})$, and hence $Pr(o_t = 0):= Pr(k_{-1,t} \succ k_{+1,t}) = 1-P_t(k_{+1,t},k_{-1,t})$.
\noindent \textbf{Objective. }
Assuming the learner selects the duel $(k_{+1,t},k_{-1,t})$ at round $t$, one can measure its performance w.r.t. a single fixed arm $k^* \in [K]$\footnote{Note that this is equivalent to maximizing the expected regret w.r.t. any fixed distribution $\boldsymbol {\pi}^* \in \Delta_K$, i.e. when $k^* \sim \boldsymbol {\pi}^*$. This is because the regret objective is linear in the entries of $\boldsymbol {\pi}^*$, so the maximizer $\boldsymbol {\pi}^*$ is always one hot.} in hindsight by calculating the regret w.r.t. $k^* \in [K]$
\begin{equation}
\label{eq:sreg}
R_T(k^*) := \sum_{t=1}^T \frac{1}{2}\left( P_t(k^*, k_{+1,t}) + P_t(k^*, k_{-1,t}) -1 \right).
\end{equation}
For the \emph{stochastic setting} where $P_t$s are fixed across all time steps $t \in [T]$, we denote $P_t = P ~\forall t\in [T]$. Further assuming there exists a Condorcet winner for $P$, i.e. fixed arm $k^{\texttt{(cw)}} \in [K]$ such that $P(k^{\texttt{(cw)}},k) > 0.5 ~\forall k \in [K]\setminus \{k\}$, the above notion of regret boils down to the regret with respect to the Condorcet winner for the choice of $k^* = k^{\texttt{(cw)}}$, as widely studied in many dueling bandit literature \cite{Zoghi+14RUCB,DTS,Komiyama+15,bengs2021preference}, defined as:
\begin{equation}
\label{eq:cwreg}
R_T^{\texttt{(cw)}} := \sum_{t=1}^T \frac{1}{2}\left( \Delta(k^{\texttt{(cw)}}, k_{+1,t}) + \Delta(k^{\texttt{(cw)}}, k_{-1,t}) \right),
\end{equation}
where $\Delta(i,j):= P(i,j)-1/2$ being the suboptimality gap of item $i$ and $j$ in terms of their relative preferences.
\section{Reduction from MAB to DB}
We now present a simple reduction from a multi-armed bandit algorithm to a dueling bandit one. The latter was already proposed by \cite{gupta2021optimal} to show worst-case guarantees and by~\cite{ailon2014reducing} for utility based dueling bandits only. We recall it here since it is central to our analysis and we believe that it is of important interest for the dueling bandit community that usually uses significantly different algorithms and analysis than the ones from standard multi-armed bandits.
The main idea is to apply the multi-armed bandit algorithm independently to two players $i \in \{-1,+1\}$ respectively with losses defined for any $k \in [K]$ and $t \in [T]$, by
\[
\ell_{i,t}(k) := o_t(k_{-i,t},k) \,,
\]
where $o_t(k,k') = 1-o_t(k',k)$ for $1<k'\leq K$ follows a Bernoulli with parameter $P_t(k,k')$ (and we assume $o_t(k,k) = 1/2$).
\begin{algorithm}[h]
\caption{Reduction from MAB to DB}
\label{alg:reduction}
\begin{algorithmic}[1]
\STATE {\bfseries input:} Arm set: $[K]$, two instances ${\mathcal A}_i$ of an algorithm for MAB, $i\in \{-1,+1\}$.
\FOR{$t = 1, 2, \ldots, T$}
\FOR{$i \in \{+1, -1\}$}
\STATE choose ${\mathbf p}_{i,t}$ from ${\mathcal A}_i$
\STATE sample $k_{i, t}$ from the distribution $p_{i,t}$
\ENDFOR
\STATE Observe preference feedback $o_t(k_{+1, t}, k_{-1, t})$ and set $o_t(k_{-1,t},k_{+1,t}) = 1- o_t(k_{+1, t}, k_{-1, t})$.
\STATE Feed ${\mathcal A}_i$ with loss $\ell_{i,t}(k) := o_t(k_{-i,t},k_{i,t})$ for $i \in \{-1,+1\}$.
\ENDFOR
\end{algorithmic}
\end{algorithm}
We show below that any MAB regret upper-bound satisfied by ${\mathcal A}_i$ can be transformed into a DB regret upper-bound.
\begin{thm}
\label{thm:reduction}
Define for $i\in \{-1,1\}$ and $k \in [K]$ by
\[
R_{i,T}(k) := \sum_{t=1}^T \ell_{i,t}(k_{i,t}) - \ell_{i,t}(k)
\]
the regret achieved by algorithm ${\mathcal A}_i$. Then, the expected regret~\eqref{eq:sreg} of Algorithm~\ref{alg:reduction} for dueling bandits can be decomposed as
\[
{\mathbf E}\big[R_T(k)\big] = \frac{1}{2} {\mathbf E}\big[ R_{-1,T}(k) + R_{+1,T}(k) \big] \,.
\]
\end{thm}
\begin{proof}
The proof follows from
\begin{align*}
{\mathbf E}\big[ & \ell_{-1,t}(k) + \ell_{+1,t}(k)\big]
= {\mathbf E}\big[o_t(k_{+1, t},k) + o_t(k_{-1,t},k)\big] \\
& = {\mathbf E}\big[P_t(k_{+1, t},k) + P_t(k_{-1,t},k)\big]\\
& = 2 - {\mathbf E}\big[P_t(k, k_{+1, t}) + P_t(k, k_{-1,t})\big]
\end{align*}
and
\begin{align*}
{\mathbf E}\big[ &\ell_{-1,t}(k_{+1,t}) + \ell_{+1,t}(k_{-1,t})\big] \\
& = {\mathbf E}\big[o_t(k_{+1, t}, k_{-1, t}) + o_t(k_{+1, t}, k_{-1, t})\big]
= 1 \,.
\end{align*}
We conclude by summing over $t=1,\dots,T$ both equations and by substituting them into the definition of the regret $R_T(k)$ in~\eqref{eq:sreg}.
\end{proof}
Note that such a reduction can also be used to bound $R_T(k)$ directly rather than its expectation. \citet{gupta2021optimal} indeed use this reduction to show a $O(\sqrt{KT})$ high-probability regret upper-bound for adversarial dueling bandit. They also obtain non-stationary regret bounds.
The main message of this paper is that this reduction can be used to transpose many results from standard multi-armed bandit to general dueling bandits. For instance, applying a subroutine ${\mathcal A}_i$ which is robust to delays \citep[e.g.,]{delay3,zimmert2020optimal}, one directly obtains a dueling bandit with the same robustness guarantees.
As we said, this reduction is not new. However, to date, it has only been considered in two specific contexts: the adversarial setting with worst-case regret bounds of order $O(\sqrt{KT})$ and the utility-based setting. Since the losses $\ell_{i,t} = o_t(k_{-i,t},k)$ are not i.i.d. but depend on an adaptive adversary which chooses $k_{-i,t}$, one cannot use stochastic bandit algorithms. And the dueling bandit community usually needs to resort to more sophisticated algorithms and arguments to obtain logarithmic regret bounds for Condorcet stochastic dueling bandits. The only stochastic dueling bandit for which such a reduction was considered \citep[e.g.,]{ailon2014reducing,zimmert2021tsallis} was the utility based-dueling bandits, which is overly restrictive in practice. That is, when the preference matrix if of the form $P_t(k,k') : (1 + u_t(k) + u_t(k'))/2$ for some sequence of utility vectors $(u_t)_{t\geq 1}$. Utility based dueling bandit are known to be easily be reduced to two independent multi-armed bandit problems \citep{ailon2014reducing}.
Our main contribution is to show that this reduction can in fact be easily extended to the much weaker Condorcet winner hypothesis. To do this, as we show in the next sections, we simply apply the reduction with a best-of-both-worlds multi-armed bandit algorithm. As we will see, this recovers and improves the best existing upper bounds on the Condorcet regret for dueling bandits.
|
{'timestamp': '2022-02-15T02:44:15', 'yymm': '2202', 'arxiv_id': '2202.06694', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06694'}
|
arxiv
|
\section{Introduction}
The millimeter-wave (mmWave) communication over the 30-300 GHz spectrum is regarded as a promising technology for 5G and beyond wireless networks due to its large bandwidth and the potential to offer high communication data rates \cite{6824746, niu2015survey}. Large antenna arrays are usually adopted in mmWave communications since they can form highly directional beams to compensate for the severe path loss compared with sub-6 GHz. Meanwhile, the high directivity makes mmWave communication much more sensitive to signal blockage, which can be frequent in the environment \cite{8254900}.
To overcome the blockage issue, reconfigurable intelligent surface (RIS) has been recently introduced to enlarge the coverage of the mmWave communication systems \cite{8910627,9148781}. Specifically, RIS is an artificial meta-surface that is composed of a large number of nearly passive units and can be controlled efficiently by a smart controller \cite{8796365}. RIS can smartly reflect the signals from the base station (BS) to multiple users by adjusting the amplitude and phase of the incident signals. When the BS-user channel is blocked, RIS can create a virtual BS-RIS-user channel, and thus improve the coverage of mmWave systems. There are often no radio frequency (RF) components on RIS. Therefore, RIS is an efficient and cost-effective solution for the blockage problem in mmWave systems.
Motivated by the above attractive advantages, RIS-aided communication systems have been widely studied in various scenarios, e.g., \cite{8811733,8982186,8723525, 9110912, 9234098}. The authors in \cite{8811733} consider the power minimization problem for an RIS-assisted multiple-input single-output (MISO) downlink multi-user system subject to signal-to-interference-plus-noise ratio (SINR) constraints. The weighted sum-rate is maximized in \cite{8982186} under the maximum power budget. The authors of \cite{8723525} focus on maximizing the secrecy rate of the legitimate user. The authors in \cite{9110912} aim to maximize the capacity of an RIS-aided multiple-input multiple-output (MIMO) system and propose an alternating optimization based algorithm. Pertaining to mmWave MIMO systems, the channel capacity maximization problem is investigated in \cite{9234098} by exploiting the sparse structure of mmWave channel to propose an efficient manifold-based algorithm.
However, all of the above contributions are based on instantaneous channel state information (CSI), which is very challenging to obtain due to the fact that RIS is a passive component and can not sense the environment independently \cite{8910627, 8796365}. Thus, some researchers attempt to explore the statistical CSI in RIS-aided communication systems \cite{9195523, singh2021reconfigurable, 8746155,hu2020statistical, zhi2021power, 9352967, 9392378, ouyang2021ergodic }. For single-input single-output systems, \cite{9195523} considers the Rayleigh fading channel and computes the closed-form expression of the coverage probability and the upper bound of ergodic capacity, while the Rician channel is considered in \cite{singh2021reconfigurable}. For MISO systems, \cite{8746155} derives a tight upper bound of the ergodic capacity under Rician fading channels. The maximum ratio transmitting is adopted at the BS and an optimal reflection coefficients design at the RIS is proposed based on the upper bound. In \cite{hu2020statistical}, the authors take the active beamforming at the BS into consideration when deriving the ergodic capacity. Both \cite{8746155} and \cite{hu2020statistical} consider single user scenario, which is extended to the multiuser case in \cite{zhi2021power}. For MIMO systems, \cite{9352967} considers single-stream transmission and obtains a tight upper bound of the ergodic capacity under the Rician channels, while the multi-stream transmission case is considered in \cite{9392378}. In addition, the lower and upper bounds of the ergodic capacity are derived in \cite{ouyang2021ergodic} when equal power allocation is adopted at the BS. Note that all these works consider the Rayleigh or Rician channels. However, the Rayleigh or Rician channels are not suitable for mmWave systems due to the limited scattering, which is usually characterized by the Saleh-Valenzuela (SV) channel \cite{9234098,6847111,6717211,7397861,7962632,8816689}. Therefore, we aim to fill the gap in this work inspired by \cite{8816689}. To the best of the authors' knowledge, this is the first effort to derive the ergodic capacity under the SV channel in RIS-aided mmWave MIMO communication systems.
Against the above background, we concentrate on an RIS-aided downlink mmWave MIMO communication systems with the statistical CSI and SV channel model. The main contributions of this study are summarized as follows:
\begin{itemize}
\item We derive a tight closed-form ergodic capacity approximation for the RIS-aided mmWave MIMO communication systems based on the majorization theory and Jensen's inequality. The approximation holds for arbitrary numbers of paths, antennas and reflection units, and arbitrary antenna structures.
\item We derive a tight upper bound of the ergodic capacity in high-SNR regime. The upper bound shows that the ergodic capacity increases logarithmically with the signal-to-noise ratio (SNR), the number of antennas at the BS and user, the number of the reflection units at the RIS, and the eigenvalues of the steering matrices associated with the BS, user and RIS.
\item We maximize the ergodic capacity by jointly designing the transmit covariance matrix at the BS and the reflection coefficients at the RIS based on the derived closed-form approximation. Specifically, the transmit covariance matrix is optimized by the water-filling algorithm and the reflection coefficients are optimized by the Riemanian conjugate gradient (RCG) algorithm.
\end{itemize}
Finally, we conduct comprehensive simulations and validate the tightness of the derived ergodic capacity approximation. It is shown that the ergodic capacity after optimization could be improved by about 20 bits/s/Hz. In addition, when the BS allocates equal power over transmit signals, the ergodic capacity remains unchanged after the number of antennas at the BS reaches a certain amount. Furthermore, if we are allowed to optimize only one variable of the transmit covariance matrix and the reflection coefficients, optimizing the reflection coefficients is more effective than optimizing the transmit covariance matrix only in the case of a large number of reflection units. Thanks to the low-cost passive elements, RIS usually has a large number of reflection units. In this case, the system still performs well if the BS allocates equal power and the reflection coefficients at the RIS are optimized.
The rest of the paper is organized as follows. Section II introduces the system model and the problem formulation. Section III adopts the majorization theory to derive the ergodic capacity approximation and the upper bound in high-SNR regime. Section IV designs the transmit covariance matrix and the reflection coefficients. Section V presents the extensive simulation results and Section VI concludes this paper.
\emph{Notations}: The imaginary unit is denoted by $j=\sqrt{-1}$. Vectors and matrices are denoted by bold-face lower-case and upper-case letters, respectively. $\mathbb{C}^{x\times y}$ denotes the space of $x\times y$ complex-valued matrices. $ \bf x^*$, $\mathbf{x}^T$, and $\mathbf x^H$ denote the conjugate, transpose and conjugate transpose of vector $\bf x$. $\bf I$ denotes an identity matrix of appropriate dimensions. $\odot$ denotes the Hadamard product. $\mathbb{E}(\cdot)$ denotes the stochastic expectation. $\Re(\cdot)$ denote the real part of a complex number. The $\operatorname{tr}(\cdot)$, $\operatorname{det}(\cdot)$ and $\operatorname{rank}(\cdot)$ denote the trace, determinant and rank operation, respectively. $\operatorname{diag}(\mathbf{x})$ denotes a diagonal matrix with each diagonal element being the corresponding element in $\mathbf{x}$. $\nabla f(\mathbf{x}_i)$ denotes the gradient vector of function $f(\mathbf{x})$ at the point $\mathbf{x}_i$. The distribution of a circularly symmetric complex Gaussian random vector with mean vector $x$ and covariance matrix $\Sigma$ is denoted by $\mathcal{C}\mathcal{N}(x,\Sigma)$; and $\sim$ stands for ``distributed as''. The exponential random variable ${X}$ with parameter $\lambda$ is given by ${X} \sim \exp (\lambda)$.
\section{System Model and Problem Formulation}
\subsection{System Model} \label{sec_system}
\begin{figure}[htb]
\begin{centering}
\includegraphics[width=.5\textwidth]{System_Model.eps}
\caption{Illustration of an RIS-aided mmWave MIMO system.} \label{system_model}
\end{centering}
\vspace{-0.4cm}
\end{figure}
As shown in Fig.~\ref{system_model}, we consider an RIS-aided downlink mmWave MIMO communication system, where one BS equipped with $N_b\geq 1$ antennas communicates with a user equipped with $N_u\geq 1$ antennas, via the assistance of one RIS equipped with $N_r\geq 1$ nearly passive reflecting units. We assume that the BS-user direct link is blocked due to unfavorable propagation conditions.
$\mathbf{G}\in\mathbb{C}^{N_r \times N_b}$ and $\mathbf{T}\in\mathbb{C}^{N_u \times N_r}$ denote the channel matrix from BS to RIS, and from RIS to user, respectively, and $\mathbf{s} \in \mathbb{C}^{N_b \times 1}$ denotes the zero-mean transmitted Gaussian vector with covariance matrix $\mathbf{Q}\in \mathbb{C}^{N_b \times N_b}$. The transmit power constraint at the BS can be expressed as
\begin{equation}\label{budgetP}
\operatorname{tr} \mathbb{E}\{\mathbf{s}\mathbf{s}^H\} = \operatorname{tr}(\mathbf{Q} ) \leq P_T ,
\end{equation}
where $P_T>0$ is the power budget at the BS. Then, the received vector $\mathbf{y}\in \mathbb{C}^{N_u \times 1}$ at the user can be represented as
\begin{equation}
\mathbf{y}=\mathbf{T}\mathbf{\Theta}\mathbf{G} \mathbf{s} + \mathbf{n},
\end{equation}
where $\mathbf{\Theta}= \operatorname{diag} \{\xi_1 e^{j\theta_1}, \xi_2 e^{j\theta_2}, \ldots, \xi_{N_r} e^{j\theta_{N_r}}\}$ represents the response matrix of the RIS, $\theta_i\in [0, 2\pi)$ and $\xi_i \in[0, 1]$ represent the phase shift and the amplitude reflection coefficient of the $i$-th reflecting unit, respectively, and $\mathbf{n} \thicksim\mathcal{C}\mathcal{N}{(\mathbf{0}, \sigma^2 \mathbf{I}_{N_u})}$ represents the additive white Gaussian noise with zero mean and variance $\sigma^2$. In this paper, we assume $\xi_i=1, i= 1,2,\ldots, N_r$ to maximize the signal reflection.
We adopt the widely used narrowband SV channel model for mmWave communications. Suppose uniform linear arrays (ULAs)\footnote{We assume the deployment of ULA for ease of exposition. The results can be extended straightforwardly to other antenna topologies, such as, UPA and so on. } are equipped at the BS and the user, and a uniform planar array (UPA) is equipped at the RIS. Hence, the narrowband BS-RIS channel $\mathbf{G}$ and RIS-user channel $\mathbf{T}$ can be expressed as
\begin{equation}\label{channel_G}
\mathbf{G}= \sqrt{\frac{N_r N_{b}}{P}} \sum_{i=1}^{P} g_i \mathbf{a}_r(\phi_{r,i}^1, \phi_{r,i}^2) \mathbf{a}_b^H (\phi_{b,i}),
\end{equation}
\begin{equation}\label{channel_T}
\mathbf{T}= \sqrt{\frac{N_r N_{u}}{L}} \sum_{i=1}^{L} t_i \mathbf{a}_u(\psi_{u,i}) \mathbf{a}_r^H (\psi_{r,i}^1, \psi_{r,i}^2),
\end{equation}
where $P (L)$ is the number of paths between the BS and the RIS (the RIS and the user), $g_i \sim \mathcal{C}\mathcal{N} (0,1)$ ($t_i \sim \mathcal{C}\mathcal{N} (0,1)$)\footnote{In mmWave MIMO communication systems, it is reasonable to assume that the complex gains of different paths experience the same variances \cite{6847111,6717211,7397861}. Furthermore, the results are extendible to the case of different variances. } denotes complex channel gain of the $i$-th path, $\phi_{r,i}^1$ ($\psi_{r,i}^1$) and $\phi_{r,i}^2$ ($\psi_{r,i}^2$) denote the azimuth and elevation angles of arrival (departure) associated with the RIS, $\phi_{b,i}$ denotes the angle of departure (AOD) associated with the BS, $\psi_{u,i}$ denotes the angle of arrival (AOA) associated with the user, and $\mathbf{a}_i, i\in \{ b, r, u\}$ denote the normalized array response vectors. When an $N$-antenna ULA is employed, the array response vector is given by
\begin{equation}
\mathbf{a}(\phi) = \frac{1}{\sqrt{N}}\left[ 1, e^{j\frac{2\pi d}{\lambda} \sin(\phi)}, \cdots, e^{j \frac{2\pi d}{\lambda} (N-1) \sin(\phi)} \right]^T,
\end{equation}
where $\lambda$ is the signal wavelength, $d$ is the antenna spacing which is assumed to be half wavelength, and $\phi$ denotes the AOA or AOD. For a UPA with $M=M_y \times M_z$ elements, the array response vector is given by
\begin{equation}
\mathbf{a} \left(\phi^1, \phi^2\right)= \frac{1}{\sqrt{M}} \left[1, \ldots, e^{j \frac{2 \pi}{\lambda} d \left(m_y \sin \phi^1 \sin \phi^2 + m_z \cos \phi^2\right)}\right. ,
\left.\ldots, e^{j \frac{2 \pi}{\lambda} d \left((M_y-1) \sin \phi^1 \sin \phi^2)+(M_z-1) \cos \phi^2\right)}\right]^{T},
\end{equation}
where $d$ is the unit cell spacing which is assumed to be half wavelength, while $\phi^1$ and $\phi^2$ denote the azimuth and elevation angles, respectively. Defining
$ \mathbf{A}_{rp} = \left[ \mathbf{a}_r(\phi_{r,1}^1, \phi_{r,1}^2), \ldots, \mathbf{a}_r(\phi_{r,P}^1, \phi_{r,P}^2) \right] \in\mathbb{C}^{N_r \times P}$,
$\mathbf{A}_{b} = \left[ \mathbf{a}_b(\phi_{b,1}), \mathbf{a}_b(\phi_{b,2}), \ldots, \mathbf{a}_b(\phi_{b,P}) \right] \in\mathbb{C}^{N_b \times P}$,
$\mathbf{G}_p = \sqrt{\frac{N_r N_{b}}{P}} \text{diag}( g_1, g_2, \ldots, g_P)$, the channel matrix $\mathbf{G}$ \eqref{channel_G} can be rewritten as
\begin{equation}\label{channelG}
\mathbf{G}= \mathbf{A}_{rp} \mathbf{G}_p \mathbf{A}_b^H.
\end{equation}
Defining $\mathbf{A}_{rL} = \left[ \mathbf{a}_r(\psi_{r,1}^1, \psi_{r,1}^2), \ldots, \mathbf{a}_r(\psi_{r,L}^1, \psi_{r,L}^2) \right] \in\mathbb{C}^{N_r \times L}$,
$ \mathbf{A}_{u} = \left[ \mathbf{a}_u(\psi_{b,1}), \ldots, \mathbf{a}_u(\psi_{b,L}) \right] \in\mathbb{C}^{N_u \times L}$,
$ \mathbf{T}_L = \sqrt{\frac{N_r N_{u}}{L}} \text{diag}( t_1, t_2, \ldots, t_L)$,
the channel matrix $\mathbf{T}$ \eqref{channel_T} can be rewritten as
\begin{equation}\label{channelT}
\mathbf{T}= \mathbf{A}_{u} \mathbf{T}_L \mathbf{A}_{rL}^H.
\end{equation}
Assume that the instantaneous CSI is unknown, the ergodic capacity of the RIS-aided mmWave MIMO communication systems can be expressed as
\begin{equation} \label{capacity_ori}
C(\mathbf{Q}, \mathbf{\Theta}) =\max _{\operatorname{Tr}(\mathbf{Q}) \leqslant P_{T}} \mathbb{E}_{\mathbf{H}}\left[\log _{2} \operatorname{det}\left(\mathbf{I}_{N_{u}}+\frac{1}{\sigma^{2}} \mathbf{H} \mathbf{Q H}^{H}\right)\right],
\end{equation}
where $\mathbf{H}=\mathbf{T}\mathbf{\Theta}\mathbf{G}$ denotes the BS-RIS-user channel.
\subsection{Problem Formulation}
We aim to maximize the ergodic capacity by jointly optimizing the transmit covariance matrix at the BS and the reflection coefficients at the RIS, subject to the maximum power budget \eqref{budgetP} at the BS. Therefore, the problem can be formulated as
\begin{subequations}\label{prob_original}
\begin{align}
\mathcal{P}_0: \max \limits_{ \mathbf{Q}, \mathbf{\Theta} } \quad & C(\mathbf{Q}, \mathbf{\Theta}) \\
\text { s.t. } \quad & \operatorname{tr}(\mathbf{Q}) \leq P_T, \\
& \mathbf{Q} \succeq 0, \\
& \mathbf{\Theta} =\operatorname{diag}\left(e^{j \theta_{1}}, e^{j \theta_{2}}, \cdots, e^{j \theta_{N_r}} \right). \label{const_ris}
\end{align}
\end{subequations}
The problem $\mathcal{P}_0$ is very challenging mainly due to two facts. To begin with, there is no explicit expression of the ergodic capacity, which prevents further optimization exploration. Secondly, the problem is highly non-convex due to the unit-modulus phase shifts constraints \eqref{const_ris}, and thus difficult to be optimally solved. In the following, we will first find the explicit expression to approximate the ergodic capacity, and then maximize the ergodic capacity by optimizing $\mathbf{Q}$ and $\mathbf{\Theta}$.
\section{the Ergodic Capacity}
In this section, we first derive the ergodic capacity approximation as well as the high-SNR capacity upper bound according to the majorization theory. Then, explicit expression is obtained via the Jensen's inequality.
\subsection{Approximation of the Ergodic Capacity}
\begin{theorem}
Under the narrowband SV channel model expressed in \eqref{channelG} and \eqref{channelT}, the ergodic capacity of the RIS-aided mmWave MIMO communication systems can be approximated by
\begin{equation} \label{app_ori}
C_{app}
= \mathbb{E}_{g,t} \left[\sum \limits_{i=1}^{N_s} \log _{2} \left( 1+ \frac{ N_b N_u N_r^2 }{\sigma^2 P L } d_{b,i} d_{u,i} d_{r,i} |g_i|^2 |t_i|^2 \right) \right],
\end{equation}
where $N_s= \min\left(\operatorname{rank}(\mathbf{A}_b^H \mathbf{Q} \mathbf{A}_b), \operatorname{rank}(\mathbf{A}_u^H \mathbf{A}_u), \operatorname{rank}(\mathbf{X}^H \mathbf{X})\right)$, $ \mathbf{X} = \mathbf{A}_{rL}^H \mathbf{\Theta} \mathbf{A}_{rp}$, and $( d_{b,1}, \ldots, d_{b, N_s})$, $(d_{u,1}, d_{u,2}, \ldots, d_{u,N_s})$ and $(d_{r,1}, d_{r,2}, \ldots, d_{r,N_s})$ are descending ordered eigenvalues of $\mathbf{A}_b^H \mathbf{Q} \mathbf{A}_b$, $\mathbf{A}_u^H \mathbf{A}_u$ and $\mathbf{X}^H \mathbf{X}$, respectively.
\end{theorem}
\begin{proof}
See Appendix \ref{append1}.
\end{proof}
It is found that the ergodic capacity is closely related to the eigenvalues of the matrices associated with the BS, the user and the RIS. Their influences on the ergodic capacity can be clearly seen from $\mathbf{A}_b^H \mathbf{Q} \mathbf{A}_b$, $\mathbf{A}_u^H \mathbf{A}_u$ and $\mathbf{X}^H \mathbf{X}$.
\begin{proposition} \label{app_exact}
When $\mathbf{A}_b$, $\mathbf{A}_u$, $\mathbf{A}_{rp}$ and $\mathbf{A}_{rL}$ are composed of the columns of unitary matrices, e.g., the discrete Fourier matrices, and the AOA at the RIS is symmetric to the AOD at the RIS, i.e., $\phi_{r,i}^1 = \psi_{r,i}^1, \phi_{r,i}^2 = \psi_{r,i}^2, \forall i$, $\mathbf{Q} = \frac{P_T}{N_b} \mathbf{I}_{N_b}$, and $\mathbf{\Theta}=\mathbf{I}_{N_r}$, the derived ergodic capacity approximation $C_{app}$ is identical to the exact ergodic capacity, i.e.,
\begin{equation}
C_{app} = C_{exact}.
\end{equation}
\end{proposition}
\begin{proof}
See Appendix \ref{proof_pro1}.
\end{proof}
\textbf{Proposition} \ref{app_exact} implies that the derived capacity approximation exhibits tight performance when the BS allocates equal power, the RIS acts like a mirror, and all steering response matrices are taken from columns of unitary matrices. Specifically, when the number of the antennas or the reflection units is very large, the steering response matrices become asymptotically semi-unitary.
Considering the typical scenario with line-of-sight paths to and from the RIS and the beamforming technique with large antenna arrays, the RIS-aided mmWave systems are likely to operate in high-SNR regime. The following proposition exploits the upper bound of the ergodic capacity in high-SNR regime.
\begin{proposition} \label{prop_upper}
Under the narrowband SV channel model, the ergodic capacity of the RIS-aided mmWave MIMO communication systems in high-SNR regime can be upper bounded by
\begin{equation}
C_h \leq C_h^{upper} = \sum \limits_{i=1}^{N_s} \frac{1}{\ln 2} \left( -2\gamma + \ln \left(\frac{N_b N_u N_r^2}{\sigma^2 P L} d_{b,i} d_{u,i} d_{r,i}\right) \right),
\end{equation}
where $C_h$ denotes the ergodic capacity in the high-SNR regime, $\gamma \approx 0.5772$ is the Euler-Mascheroni constant, $( d_{b,1}, d_{b,2}, \ldots, d_{b, N_s})$, $(d_{u,1}, d_{u,2}, \ldots, d_{u,N_s})$ and $(d_{r,1}, d_{r,2}, \ldots, d_{r,N_s})$ are descending ordered eigenvalues of $\mathbf{A}_b^H \mathbf{Q} \mathbf{A}_b$, $\mathbf{A}_u^H \mathbf{A}_u$ and $\mathbf{X}^H \mathbf{X}$, respectively. The equality holds when $N_s = P =L$.
\end{proposition}
\begin{proof}
See Appendix \ref{proof_pro2}.
\end{proof}
In order to exploit the relationship between the upper bound and the SNR, we transform the upper bound to another formulation. Let $\mathbf{Q}= {P_T} \tilde{\mathbf{Q}}$ and $\mathbf{A}_b^H \tilde{\mathbf{Q}} \mathbf{A}_b = \mathbf{U}_b^H \tilde{\mathbf{D}}_b \mathbf{U}_b$, where $\tilde{\mathbf{D}}_b = \operatorname{diag} (\tilde{d}_{b,1}, \tilde{d}_{b,2}, \ldots, \tilde{d}_{b,P})$ is composed of the eigenvalues of $\mathbf{A}_b^H \tilde{\mathbf{Q}} \mathbf{A}_b$ in descending order. Therefore, the upper bound $C_h^{upper}$ can be transformed to
\begin{equation}
C_h \leq C_h^{upper} = \sum \limits_{i=1}^{N_s} \frac{1}{\ln 2} \left( -2\gamma + \ln \left(\frac{P_T}{\sigma^2} \frac{N_b N_u N_r^2}{P L} \tilde{d}_{b,i} d_{u,i} d_{r,i}\right) \right).
\end{equation}
It can be found that when the SNR is large, the upper bound of the ergodic capacity increases logarithmically with SNR, $N_b$, $N_u$, $N_r$ \footnote{We only consider far-field scenario in this work.} and the eigenvalues of the matrices $\mathbf{A}_b^H \tilde{\mathbf{Q}} \mathbf{A}_b$, $\mathbf{A}_u^H \mathbf{A}_u$ and $\mathbf{X}^H \mathbf{X}$. Specifically, the upper bound of the ergodic capacity has no relationship with the number of antennas at the BS when the number of antennas exceeds a certain amount and the BS allocates equal power over transmit signals, i.e., $\tilde{\mathbf{Q}} = \frac{1}{N_b}\mathbf{I}_{N_b}$. It is because of the asymptotic orthogonality of the array response vectors when the number of antennas is large and $\{\tilde{d}_{b,i}\}_{\forall i}$ is nearly equal to one.
\begin{theorem} \label{theorem2}
The ergodic capacity of the RIS-aided mmWave MIMO communication systems can be further approximated by
\begin{equation} \label{theorem2_eq}
C_{app}
= \frac{1}{ \ln 2} \sum \limits_{i=1}^{N_s} \int_{0}^\infty
e^{-z} e^{ \frac{1}{\alpha_i z} } E_1 \left(\frac{1}{\alpha_i z} \right) dz,
\end{equation}
where $\alpha_i=\frac{ N_b N_u N_r^2 }{\sigma^2 P L } d_{b,i} d_{u,i} d_{r,i}$, and $E_1(z)$ is the exponential integral function, which is defined as $E_1(z) = \int_1^\infty x^{-1} e^{-zx} dx, z>0$.
\end{theorem}
\begin{proof}
See Appendix \ref{appendix_theorem2}.
\end{proof}
Although Theorem \ref{theorem2} gives an explicit expression of the ergodic capacity, there are complex integral items involved in the expression \eqref{theorem2_eq}, which is difficult for further optimization.
\subsection{Jensen's Approximations for the Ergodic Capacity}
It is difficult to utilize the expression \eqref{theorem2_eq} in the optimization procedure. Therefore, we further simplify the expression of the ergodic capacity via the Jensen's inequality.
\begin{proposition}
Under the narrowband SV channel model, the ergodic capacity of the RIS-aided mmWave MIMO communication systems can be approximated by
\begin{equation} \label{jen1}
C_{Jen1} = \sum \limits_{i=1}^{N_s} \log _{2} \left( 1+ \frac{ N_b N_u N_r^2 }{\sigma^2 P L} d_{b,i} d_{u,i} d_{r,i} \right).
\end{equation}
\end{proposition}
\begin{proof}
According to the Jensen's inequality $\mathbb{E}\{\log_2 (1+x)\} \leq \log_2(1+\mathbb{E}\{x\})$ for $x\geq 0$, we have
\begin{equation} \label{jen1_1}
\begin{aligned}
C_{app}
& = \mathbb{E}_{g,t} \left[\sum \limits_{i=1}^{N_s} \log _{2} \left( 1+ \frac{ N_b N_u N_r^2 }{\sigma^2 P L } d_{b,i} d_{u,i} d_{r,i} |g_i|^2 |t_i|^2 \right) \right]\\
& \leq \sum \limits_{i=1}^{N_s} \log _{2} \left(1+ \mathbb{E}\left\{ \frac{ N_b N_u N_r^2 }{\sigma^2 P L } d_{b,i} d_{u,i} d_{r,i} |g_i|^2 |t_i|^2\right\} \right)\\
& = C_{Jen1}.
\end{aligned}
\end{equation}
Since $|g_i|^2 \sim \exp (1)$, $|t_i|^2 \sim \exp (1)$, and $|g_i|^2$ and $|t_i|^2$ are independent with each other, we have
\begin{equation} \label{jen1_2}
\mathbb{E}\left\{ \frac{ N_b N_u N_r^2 }{\sigma^2 P L } d_{b,i} d_{u,i} d_{r,i} |g_i|^2 |t_i|^2\right\}
=\frac{ N_b N_u N_r^2 }{\sigma^2 P L } d_{b,i} d_{u,i} d_{r,i} \mathbb{E} \{ |g_i|^2\}\mathbb{E} \{ |t_i|^2\}
= \frac{ N_b N_u N_r^2 }{\sigma^2 P L } d_{b,i} d_{u,i} d_{r,i}.
\end{equation}
Substituting \eqref{jen1_2} to \eqref{jen1_1}, we can obtain \eqref{jen1}.
\end{proof}
It is important to find that the Jensen's approximation $C_{Jen1}$ \eqref{jen1} is very succinct, which only contains the product of the eigenvalues and the summation over data streams. We can find that the ergodic capacity of the RIS-aided mmWave MIMO system increases logarithmically with the number of antennas of the BS and the user, the number of the reflection units of the RIS, and the eigenvalues of the matrices $\mathbf{A}_b^H \mathbf{Q} \mathbf{A}_b$, $\mathbf{A}_u^H \mathbf{A}_u$ and $\mathbf{X}^H \mathbf{X}$. However, the approximation $C_{Jen1}$ is loose, which can be found in the simulation section.
In order to find tighter approximation, we need to consider the order statistic. According to [\cite{shu2014low}, Theorem 1], let $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$ be positive real numbers with $0\leq a_1 \leq a_2 \leq \cdots \leq a_n$ and $0\leq b_1 \leq b_2 \leq \cdots \leq b_n$, then
\begin{equation}
\prod \limits_{k=1}^n (1+a_k b_k) \geq \prod \limits_{k=1}^n (1+a_k b_{\theta(k)}) \geq \prod \limits_{k=1}^n (1+a_k b_{n-k+1}),
\end{equation}
where $\theta$ is a permutation of $\{1,2,\ldots,n\}$.
The expressions \eqref{theorem2_eq} and \eqref{jen1} are actually obtained when $\{|g_i|^2\}$ and $\{|t_i|^2\}$ are not ordered, and the Jensen's approximation $C_{Jen1}$ is a little larger than the actual results. Therefore, we can obtain tighter approximation if $\{|g_i|^2\}$ and $\{|t_i|^2\}$ are ascending ordered sequences since $\{d_{b,i} d_{u,i} d_{r,i}\}$ are descending ordered sequences. Specifically, we have the following proposition.
\begin{proposition}
Under the narrowband SV channel model, the ergodic capacity of the RIS-aided mmWave MIMO communication systems can be approximated by
\begin{equation} \label{jen2}
C_{Jen2} = \sum \limits_{i=1}^{N_s} \log _{2} \left( 1+ \sum \limits_{j=1}^i \frac{1}{P-j+1}
\sum \limits_{j=1}^i \frac{1}{L-j+1} \frac{ N_b N_u N_r^2 }{\sigma^2 P L} d_{b,i} d_{u,i} d_{r,i} \right).
\end{equation}
\end{proposition}
\begin{proof}
Let $\{|g_{(i)}|^2\}$ and $\{|t_{(i)}|^2\}$ denote the ascending ordered sequences of $\{|g_{i}|^2\}$ and $\{|t_{i}|^2\}$, respectively. According to the order statistic results [\cite{nagaraja2006order}, Eq. (11.2)], the expectation of $|g_{(i)}|^2$ and $|t_{(i)}|^2$ can be calculated as
\begin{equation}
\begin{split}
& \mathbb{E} \{|g_{(i)}|^2\} = \sum \limits_{j=1}^i \frac{1}{P-j+1},\\
& \mathbb{E} \{|t_{(i)}|^2\} = \sum \limits_{j=1}^i \frac{1}{L-j+1}.
\end{split}
\end{equation}
Then, according to the Jensen's inequality, we have
\begin{equation} \label{jen2_1}
\begin{aligned}
C_{app}
& = \mathbb{E}_{g,t} \left[\sum \limits_{i=1}^{N_s} \log _{2} \left( 1+ \frac{ N_b N_u N_r^2 }{\sigma^2 P L } d_{b,i} d_{u,i} d_{r,i} |g_{(i)}|^2 |t_{(i)}|^2 \right) \right]\\
& \leq \sum \limits_{i=1}^{N_s} \log _{2} \left(1+ \frac{ N_b N_u N_r^2 }{\sigma^2 P L } d_{b,i} d_{u,i} d_{r,i} \mathbb{E}\left\{ |g_{(i)}|^2 |t_{(i)}|^2\right\} \right)\\
& = C_{Jen2}.
\end{aligned}
\end{equation}
\end{proof}
Note that both $C_{Jen1}$ and $C_{Jen2}$ have the concise form of the approximation of the ergodic capacity. However, $C_{Jen2}$ exhibits tighter approximation because it exploits the order statistic, and the Jensen's upper bound is minimized by multiplying $d_{b,i} d_{u,i} d_{r,i}$ and $\mathbb{E}\{|g_{(i)}|^2 |t_{(i)}|^2\}$ in opposite order. Consequently, we adopt the expression $C_{Jen2}$ \eqref{jen2} to approximate the ergodic capacity in the following.
\section{ Transmit Covariance Matrix and Reflection Coefficients Optimization}
With the obtained approximate expression $C_{Jen2}$ of the ergodic capacity of the RIS-aided mmWave MIMO communication system, we now focus on maximizing $C_{Jen2}$ by jointly optimizing the transmit covariance matrix at the BS and the reflection coefficients at the RIS. The problem $\mathcal{P}_0$ can be expressed as
\begin{subequations}\label{prob_app}
\begin{align}
\mathcal{P}_1: \max \limits_{ \mathbf{Q}, \mathbf{\Theta} } \quad & \sum \limits_{i=1}^{N_s} \log _{2} \left( 1+ \sum \limits_{j=1}^i \frac{1}{P-j+1}
\sum \limits_{j=1}^i \frac{1}{L-j+1} \frac{ N_b N_u N_r^2 }{\sigma^2 P L} d_{b,i} d_{u,i} d_{r,i} \right) \\
\text { s.t. } \quad & \operatorname{tr}(\mathbf{Q}) \leq P_T, \\
& \mathbf{Q} \succeq 0, \\
& \mathbf{\Theta} =\operatorname{diag}\left(e^{j \phi_{1}}, \cdots, e^{j \phi_{N_r}} \right).
\end{align}
\end{subequations}
Compared with the original problem $\mathcal{P}_0$, the problem $\mathcal{P}_1$ is much clearer. However, the problem $\mathcal{P}_1$ is still challenging due to two facts. Firstly, the objective function is not directly related to the optimizing variables $\mathbf{Q}$ and $\mathbf{\Theta}$. Thus, we need to bridge the gap for the further optimization procedure. Secondly, the problem $\mathcal{P}_1$ is highly non-convex due to the unit-modulus constraints. In the following, we will first introduce a theorem to connect the objective function with the optimizing variables. Then, the alternating optimization method is adopted to decouple the problem $\mathcal{P}_1$ into two sub-problems.
\begin{theorem} \label{theorem_opt}
Let $\mathbf{U}\in\mathbb{C}^{N\times N}$ be unitary matrix, i.e., $\mathbf{U}^H \mathbf{U} = \mathbf{U} \mathbf{U}^H= \mathbf{I}$. If $\mathbf{c} \in \mathbb{R}_+^N$ and $\mathbf{s} \in \mathbb{R}_+^N$ are nonnegative real sequences that are in descending order. Then, we have
\begin{equation}
\operatorname{det} \left[ \mathbf{I} + \operatorname{diag}(\mathbf{c}) \mathbf{U}^H \operatorname{diag}(\mathbf{s}) \mathbf{U}\right]
\leq \operatorname{det} \left[ \mathbf{I} + \mathbf{U}^H \operatorname{diag}(\mathbf{c}) \operatorname{diag}(\mathbf{s}) \mathbf{U}\right]
\end{equation}
\end{theorem}
\begin{proof}
See Appendix \ref{append2}.
\end{proof}
\subsection{Transmit Covariance Matrix Optimization}
Define $\beta = \sum \limits_{j=1}^i \frac{1}{P-j+1}
\sum \limits_{j=1}^i \frac{1}{L-j+1} \frac{ N_b N_u N_r^2 }{\sigma^2 P L} $ and $ \boldsymbol{\gamma} = \beta \operatorname{diag} \left(d_{u,1} d_{r,1}, d_{u,2} d_{r,2}, \ldots, d_{u,N_s} d_{r,N_s},0,\ldots,0\right)\in\mathbb{R}^{P\times P}$, then we have
\begin{equation}
\begin{aligned}
C_{Jen2} &= \sum \limits_{i=1}^{N_s} \log _{2} \left( 1+ \beta d_{b,i} d_{u,i} d_{r,i} \right) \\
& = \log _2 \operatorname{det}\left[ \mathbf{I}_{P} + \boldsymbol{\gamma} \mathbf{D}_b \right] \\
& \overset{(a)}{\geq} \log _2 \operatorname{det}\left[ \mathbf{I}_{P} + \boldsymbol{\gamma} \mathbf{U}_b^H \mathbf{D}_b \mathbf{U}_b \right]\\
& \overset{(b)}{=} \log _2 \operatorname{det}\left[ \mathbf{I}_{P} + \boldsymbol{\gamma} \mathbf{A}_b^H \mathbf{Q} \mathbf{A}_b \right], \\
& = \log _2 \operatorname{det}\left[ \mathbf{I}_{P} + \left(\mathbf{A}_b \boldsymbol{\gamma}^{1/2}\right)^H \mathbf{Q} \left(\mathbf{A}_b \boldsymbol{\gamma}^{1/2}\right) \right],
\end{aligned}
\end{equation}
where $(a)$ holds due to Theorem \ref{theorem_opt} and $(b)$ holds due to $\mathbf{A}_b^H \mathbf{Q} \mathbf{A}_b = \mathbf{U}_{b}^H \mathbf{D}_b \mathbf{U}_{b}$. Note that we find the lower bound of the approximated ergodic capacity through Theorem \ref{theorem_opt}. Thus, it is reasonable to maximize $C_{Jen2}$ by maximizing its lower bound. Therefore, when fixing the reflection coefficients at the RIS, the problem $\mathcal{P}_1$ can be expressed as
\begin{subequations}\label{prob_Q}
\begin{align}
\max \limits_{ \mathbf{Q} } \quad & \log _2 \operatorname{det}\left[ \mathbf{I}_{P} + \left(\mathbf{A}_b \boldsymbol{\gamma}^{1/2}\right)^H \mathbf{Q} \left(\mathbf{A}_b \boldsymbol{\gamma}^{1/2}\right) \right] \\
\text { s.t. } \quad & \operatorname{tr}(\mathbf{Q}) \leq P_T, \\
& \mathbf{Q} \succeq 0.
\end{align}
\end{subequations}
Note that it is a convex optimization problem over $\mathbf{Q}$ and can be optimally solved by the well-know water-filling algorithm. Specifically, define the singular value decomposition (SVD) of $ \left(\mathbf{A}_b \boldsymbol{\gamma}^{1/2}\right)^H$ as
\begin{equation}
\left(\mathbf{A}_b \boldsymbol{\gamma}^{1/2}\right)^H =\mathbf{U}\boldsymbol{\Sigma} \mathbf{V}^H = \left[\begin{array}{ll}
\boldsymbol{U}_{1} & \boldsymbol{U}_{2}
\end{array}\right]\left[\begin{array}{cc}
\boldsymbol{\Sigma}_{1} & \boldsymbol{0} \\
\boldsymbol{0} & \boldsymbol{\Sigma}_{2}
\end{array}\right]\left[\begin{array}{l}
\boldsymbol{V}_{1}^{H} \\
\boldsymbol{V}_{2}^{H}
\end{array}\right],
\end{equation}
where $\mathbf{U}$ is a $P \times P$ unitary matrix, $\boldsymbol{\Sigma}$ is a $P \times N_b$ diagonal matrix of singular values, $\mathbf{V}$ is an $N_b \times N_b$ unitary matrix. The truncated SVD of $ \left(\mathbf{A}_b \boldsymbol{\gamma}^{1/2}\right)^H$ is $\mathbf{U}_1 \boldsymbol{\Sigma}_1 \mathbf{V}_1^H$, where $\boldsymbol{\Sigma}_1 \in \mathbb{R}^{P\times N_s}$ and $\mathbf{V}_1 \in \mathbb{C}^{N_b \times N_s}$. Thus, the optimal solution to the problem \eqref{prob_Q} is given by
\begin{equation} \label{opt_Q}
\mathbf{Q}^\star = \mathbf{V}_1 \operatorname{diag}(p_1, p_2, \ldots, p_{N_s} ) \mathbf{V}_1^H,
\end{equation}
where $p_i = \max \left( 1/p_0 -1/\Sigma_1^2(i,i), 0 \right), i=1,2, \ldots, N_s$ denotes the optimal amount of power allocated to the $i$-th data stream, and $p_0$ is the water level satisfying $\sum_{i=1}^{N_s} p_i = P_T$.
\subsection{Reflection Coefficients Optimization}
Define $\boldsymbol{\Gamma} = \beta \operatorname{diag} \left(d_{u,1} d_{b,1}, d_{u,2} d_{b,2}, \ldots, d_{u,N_s} d_{b,N_s}, 0,\ldots,0\right)\in\mathbb{R}^{P\times P}$, similar to the transmit covariance matrix optimization, we have
\begin{equation}
\begin{aligned}
C_{Jen2} &= \sum \limits_{i=1}^{N_s} \log _{2} \left( 1+ \beta d_{b,i} d_{u,i} d_{r,i} \right) \\
& = \log _2 \operatorname{det}\left[ \mathbf{I}_{P} + \boldsymbol{\Gamma} \mathbf{D}_r \right] \\
& \overset{(a)}{\geq} \log _2 \operatorname{det}\left[ \mathbf{I}_{P} + \boldsymbol{\Gamma} \mathbf{U}_r^H \mathbf{D}_r \mathbf{U}_r \right]\\
& \overset{(b)}{=} \log _2 \operatorname{det}\left[ \mathbf{I}_{P} + \boldsymbol{\Gamma} \mathbf{X}^H \mathbf{X} \right],
\end{aligned}
\end{equation}
where $(a)$ holds due to Theorem \ref{theorem_opt}, $(b)$ holds due to $\mathbf{X}^H \mathbf{X} = \mathbf{U}_{r}^H \mathbf{D}_r \mathbf{U}_{r}$ and $\mathbf{X} = \mathbf{A}_{rL}^H \mathbf{\Theta} \mathbf{A}_{rp}$. Therefore, when fixing the transmit covariance matrix at the BS, the problem $\mathcal{P}_1$ can be expressed as
\begin{subequations}\label{prob_ris}
\begin{align}
\max \limits_{ \mathbf{\Theta} } \quad& \log _2 \operatorname{det}\left[ \mathbf{I}_{P} + \boldsymbol{\Gamma} \mathbf{A}_{rp}^H \mathbf{\Theta}^H \mathbf{A}_{rL} \mathbf{A}_{rL}^H \mathbf{\Theta} \mathbf{A}_{rp} \right] \\
\text { s.t. } \quad & \mathbf{\Theta} =\operatorname{diag}\left(e^{j \phi_{1}}, \cdots, e^{j \phi_{N_r}} \right).
\end{align}
\end{subequations}
The problem \eqref{prob_ris} is highly non-convex due to the non-convex unit-modulus constraints and the fact that the objective function is not concave with respect to $\mathbf{\Theta}$. To the best of the authors' knowledge, there is no general approach to solve the problem \eqref{prob_ris} optimally. Here, we adopt the RCG algorithm to handle it. The RCG algorithm is widely applied in hybrid beamforming design \cite{7397861} and recently applied in RIS-aided systems as well \cite{8982186,9234098, 8855810}. Note that the RCG algorithm is suitable to handle the problems with the unit-modulus constraints, and it usually can carry out a good solution.
Note that the reflection coefficients of the RIS have a diagonal structure. Thus, we introduce a mask matrix $\mathbf{I}$ ($\mathbf{I}$ is an identity matrix). Then, we can rewrite the reflection coefficients of the RIS as $\mathbf{\Theta}=\mathbf{I} \odot \widetilde{\mathbf{\Theta}}$, where $\widetilde{\mathbf{\Theta}}\in \mathbb{C}^{N_r \times N_r}$ is an auxiliary matrix variable without the diagonal constraint and all of its units satisfy the unit-modulus constraints. Thereby, the feasible set of $\widetilde{\mathbf{\Theta}}$ forms a Riemannian manifold $\mathcal{M}= \{\widetilde{\mathbf{\Theta}}\in \mathbb{C}^{N_r \times N_r}: |[\widetilde{\mathbf{\Theta}}_{ij}|=1, \forall i,j\}$ \cite{AbsilMahonySepulchre+2009}. The main idea of the RCG algorithm is to generalize a conjugate gradient method from the Euclidean space to the manifold space. Here, we start with the definition of the tangent space. The tangent space ${T}_{\widetilde{\mathbf{\Theta}}_i} \mathcal{M}$ of the manifold $\mathcal{M}$ at point $\widetilde{\mathbf{\Theta}}_i$ is given by
\begin{equation}
{T}_{\widetilde{\mathbf{\Theta}}_i} \mathcal{M} =\left\{\mathbf{Z} \in \mathbb{C}^{N_r \times N_r}: \Re\left\{\mathbf{Z} \odot \widetilde{\mathbf{\Theta}}_i^{*}\right\}=\mathbf{0}\right\}.
\end{equation}
The main procedure of the RCG algorithm consists of three steps in each iteration.
1) \textsl{Riemannian Gradient}: The Riemannian gradient is one tangent vector (direction) with the steepest increase of the objective function. Define $\mathbf{\Omega}= \mathbf{I}_{P} + \boldsymbol{\Gamma} \mathbf{A}_{rp}^H \mathbf{\Theta}^H \mathbf{A}_{rL} \mathbf{A}_{rL}^H \mathbf{\Theta} \mathbf{A}_{rp}$, the Riemannian gradient of the objective function $f(\widetilde{\mathbf{\Theta}})= -\log_2 \operatorname{det}(\mathbf{\Omega})$ at the point $\widetilde{\mathbf{\Theta}}_i$, denoted by $\operatorname{grad} f(\widetilde{\mathbf{\Theta}}_i) $, is given by
\begin{equation} \label{grad}
\operatorname{grad} f(\widetilde{\mathbf{\Theta}}_i)=\nabla f(\widetilde{\mathbf{\Theta}}_i) -\Re \left\{\nabla f(\widetilde{\mathbf{\Theta}}_i) \odot \widetilde{\mathbf{\Theta}}_i^*\right\} \odot \widetilde{\mathbf{\Theta}}_i,
\end{equation}
where $\nabla f(\widetilde{\mathbf{\Theta}}_i)$ denotes the Euclidean gradient. In the following, we will compute the Euclidean gradient of the objective function.
Based on the differential rule $\operatorname{d}(\operatorname{det}(\mathbf{A})) = \operatorname{det} (\mathbf{A}) \operatorname{tr}(\mathbf{A}^{-1} \operatorname{d}(\mathbf{A}))$, we have
\begin{equation}
\begin{aligned}
\operatorname{d} \left( f(\widetilde{\mathbf{\Theta}}) \right)
&=-\operatorname{d} \left(\log_2 \operatorname{det}(\mathbf{\Omega})\right)\\
&= -\frac{1}{\ln 2} \operatorname{tr} (\mathbf{\Omega}^{-1} \operatorname{d} (\mathbf{\Omega}) )\\
&= -\frac{1}{\ln 2} \operatorname{tr} (\mathbf{\Omega}^{-1} \boldsymbol{\Gamma} \mathbf{A}_{rp}^H \operatorname{d}(\mathbf{\Theta}^H) \mathbf{A}_{rL} \mathbf{A}_{rL}^H \mathbf{\Theta} \mathbf{A}_{rp} ) \\
&\overset{(a)}{=} -\frac{1}{\ln 2}\operatorname{tr} ( \mathbf{A}_{rL} \mathbf{A}_{rL}^H \mathbf{\Theta} \mathbf{A}_{rp} \mathbf{\Omega}^{-1} \boldsymbol{\Gamma} \mathbf{A}_{rp}^H \operatorname{d}(\mathbf{\Theta}^H) ) \\
& \overset{(b)}{=} -\frac{1}{\ln 2}\operatorname{tr} \left( \left(\mathbf{A}_{rL} \mathbf{A}_{rL}^H \mathbf{\Theta} \mathbf{A}_{rp} \mathbf{\Omega}^{-1} \boldsymbol{\Gamma} \mathbf{A}_{rp}^H \right) \left( \mathbf{I} \odot \operatorname{d}(\widetilde{\mathbf{\Theta}}^H)\right) \right) \\
& \overset{(c)}{=} -\frac{1}{\ln 2}\operatorname{tr} \left( \left( \left(\mathbf{A}_{rL} \mathbf{A}_{rL}^H \mathbf{\Theta} \mathbf{A}_{rp} \mathbf{\Omega}^{-1} \boldsymbol{\Gamma} \mathbf{A}_{rp}^H \right) \odot \mathbf{I} \right) \operatorname{d}(\widetilde{\mathbf{\Theta}}^H) \right),
\end{aligned}
\end{equation}
where $(a)$ holds due to $\operatorname{tr}(\mathbf{AB})= \operatorname{tr} (\mathbf{BA})$ for arbitrary matrices $\mathbf{A}$ and $\mathbf{B}$, $(b)$ holds due to $\operatorname{d}(\mathbf{\Theta}) = \mathbf{I} \odot \operatorname{d}(\widetilde{\mathbf{\Theta}})$, and $(c)$ holds due to $ \operatorname{tr}(\mathbf{A} (\mathbf{B} \odot \mathbf{C} )) = \operatorname{tr} ( \left(\mathbf{A} \odot \mathbf{B}^T \right) \mathbf{C} )$ for arbitrary matrices $\mathbf{A}$, $\mathbf{B}$ and $\mathbf{C}$.
According to the fact that $\operatorname{d} \left( f(\widetilde{\mathbf{\Theta}}) \right) = \operatorname{tr} \left( \nabla f(\widetilde{\mathbf{\Theta}}) \operatorname{d}(\widetilde{\mathbf{\Theta}}^H) \right) $, we obtain the Euclidean gradient of the objective function $f(\widetilde{\mathbf{\Theta}})$ as
\begin{equation} \label{grad_eu}
\nabla f(\widetilde{\mathbf{\Theta}}) = -\frac{1}{\ln 2} \left(\mathbf{A}_{rL} \mathbf{A}_{rL}^H \mathbf{\Theta} \mathbf{A}_{rp} \mathbf{\Omega}^{-1} \boldsymbol{\Gamma} \mathbf{A}_{rp}^H \right) \odot \mathbf{I}.
\end{equation}
2) \textsl{Transport}: With the obtained Riemannian gradient, the optimization tools in the Euclidean space can be extended to the manifold space. However, the search direction $\boldsymbol{\eta}_i$ and $\boldsymbol{\eta}_{i+1}$ usually lie in two different tangent spaces. Therefore, the transport operation ${T}_{\widetilde{\mathbf{\Theta}}_i \rightarrow \mathbf{\widetilde{\mathbf{\Theta}}_{i+1}}} \left(\boldsymbol{\eta}_{i}\right)$ is needed to map the tangent vector $\boldsymbol{\eta}_i$ from ${T}_{\widetilde{\mathbf{\Theta}}_i} \mathcal{M}$ to ${T}_{\widetilde{\mathbf{\Theta}}_i+1} \mathcal{M}$, which is given by
\begin{equation} \label{transport}
\begin{aligned}
\mathcal{T}_{\widetilde{\mathbf{\Theta}}_i \rightarrow \widetilde{\mathbf{\Theta}}_{i+1}}\left(\boldsymbol{\eta}_{i}\right) : T_{\widetilde{\mathbf{\Theta}}_i} \mathcal{M} & \mapsto T_{\widetilde{\mathbf{\Theta}}_{i+1}} \mathcal{M}: \\
\boldsymbol{\eta}_{i} & \mapsto \boldsymbol{\eta}_{i}-\Re\left\{\boldsymbol{\eta}_{i} \odot \widetilde{\mathbf{\Theta}}_{i+1}^{*}\right\} \odot \widetilde{\mathbf{\Theta}}_{i+1}.
\end{aligned}
\end{equation}
Then, we can update the search direction as
\begin{equation}\label{direction}
\boldsymbol{\eta}_{i+1}=-\operatorname{grad} f(\widetilde{\mathbf{\Theta}}_{i+1}) + \beta_i \mathcal{T}_{\widetilde{\mathbf{\Theta}}_i \rightarrow \widetilde{\mathbf{\Theta}}_{i+1}}\left(\boldsymbol{\eta}_{i}\right),
\end{equation}
where $\beta_i$ is chosen as the Polak-Ribiere parameter \cite{AbsilMahonySepulchre+2009}.
3) \textsl{Retraction}: After determining the search direction $\eta_i$, we need to determine the step size $\alpha_i$. However, the obtained point $\alpha_i \boldsymbol{\eta}_i$ may leave the manifold. Thereby, an operation called \textsl{retraction} is needed to map it from the tangent space to the manifold itself, which is given by
\begin{equation} \label{retraction}
\begin{aligned}
\mathcal{R}_{\widetilde{\mathbf{\Theta}}_i}(\alpha_i \boldsymbol{\eta}_i) : T_{\widetilde{\mathbf{\Theta}}_i} \mathcal{M} & \mapsto \mathcal{M}: \\
\alpha_i \boldsymbol{\eta}_{i} & \mapsto \frac{\left(\widetilde{\mathbf{\Theta}}_i + \alpha_i \boldsymbol{\eta}_{i}\right)_{j}}{\left| \left(\widetilde {\mathbf{\Theta}}_i + \alpha_i \boldsymbol{\eta}_{i}\right)_{j}\right|},
\end{aligned}
\end{equation}
where $(\widetilde{\mathbf{\Theta}}_i+ \alpha_i \boldsymbol{\eta}_{i})_j$ denotes the $j$-th entry of $\widetilde{\mathbf{\Theta}}_i+ \alpha_i \boldsymbol{\eta}_{i}$.
\begin{algorithm}[t]
\caption{RCG Algorithm for Reflection Coefficients Optimization}
\label{rcg}
\begin{algorithmic}[1]
\State {\bf Input:} $\{\mathbf{\Gamma}, \mathbf{A}_{rp}, \mathbf{A}_{rL}\}$, desired accuracy $\epsilon$
\State Initialize: $\widetilde{\mathbf{\Theta}}_0$, $\boldsymbol{\eta}_0= -\operatorname{grad} f(\widetilde{\mathbf{\Theta}}_0)$, and set $i=0$;
\Repeat
\State Choose the Armijo backtracking line search step size $\alpha_i$;
\State Find the next point $\widetilde{\mathbf{\Theta}}_{i+1}$ using retraction in \eqref{retraction}: $\widetilde{\mathbf{\Theta}}_{i+1} = \mathcal{R}_{\widetilde{\mathbf{\Theta}}_i}(\alpha_i \boldsymbol{\eta}_i)$;
\State Calculate the Euclidean gradient $\nabla f(\widetilde{\mathbf{\Theta}}_{i+1})$ according to \eqref{grad_eu};
\State Calculate the Riemannian gradient $\operatorname{grad} f(\widetilde{ \mathbf{\Theta}}_{i+1})$ according to \eqref{grad};
\State Calculate the transport $\mathcal{T}_{\widetilde{\mathbf{\Theta}}_i \rightarrow \widetilde{\mathbf{\Theta}}_{i+1}} \left(\boldsymbol{\eta}_{i}\right)$ according to \eqref{transport};
\State Calculate the conjugate direction $\boldsymbol{\eta}_{i+1}$ according to \eqref{direction};
\State $i \leftarrow i+1$;
\Until $\|\operatorname{grad} f(\widetilde{\mathbf{\Theta}}_i) \|_2 \leq \epsilon$.
\State {\bf Output:} $\widetilde{\mathbf{\Theta}}^\star = \widetilde{\mathbf{\Theta}}_i$, ${\mathbf{\Theta}}^\star = \mathbf{I} \odot \widetilde{\mathbf{\Theta}}^\star$.
\end{algorithmic}
\end{algorithm}
The key steps used in each iteration of the manifold optimization are introduced above, and the consequent algorithm for reflection coefficients optimization is summarized in \textbf{Algorithm} \ref{rcg}. \textbf{Algorithm} \ref{rcg} is guaranteed to converge to a stationary point \cite{AbsilMahonySepulchre+2009}.
\subsection{Overall Algorithm}
In the above two subsections, the transmit covariance matrix and the reflection coefficients are optimized in each sub-problem. Here, we propose the overall alternating optimization algorithm for problem $\mathcal{P}_1$ in \textbf{Algorithm} \ref{alg_overall}. Firstly, the transmit covariance matrix $\mathbf{Q}^{(0)}$ is initialized as an identity matrix, and the reflection coefficients $\mathbf{\Theta}^{(1)}$ is obtained based on \textbf{Algorithm} \ref{rcg}. Then, the transmit covariance matrix $\mathbf{Q}^{(1)}$ is updated according to \eqref{opt_Q} with fixed $\mathbf{\Theta}^{(1)}$. In each iteration, the lower bound of the objective value of problem $\mathcal{P}_1$ is maximized. Thus, the objective value of problem $\mathcal{P}_1$ is non-decreasing over iterations. Therefore, by iteratively calculating $\mathbf{Q}^{(i+1)}$ and $\mathbf{\Theta}^{(i+1)}$, our proposed algorithm is guaranteed to converge.
Now, let us consider the complexity of the proposed \textbf{Algorithm} \ref{alg_overall}. Firstly, the complexity of the water-filling algorithm is $\mathcal{O} (PN_b \min(P,N_b)) = \mathcal{O}(N_b)$. Secondly, the complexity of the RCG algorithm is dominated by calculating the Euclidean gradient \eqref{grad_eu}. Define $\Xi_1 = \mathbf{A}_{rL}^H \mathbf{\Theta} \mathbf{A}_{rp} \mathbf{\Omega}^{-1} \boldsymbol{\Gamma}$ and $\Xi_2 = \mathbf{A}_{rL} \Xi_1 \mathbf{A}_{rp}^H$. Note that only the diagonal elements of $\Xi_2$ need to be calculated, and the $i$-th diagonal element of $\Xi_2$ can be calculated by multiplying the $i$-th row of $\mathbf{A}_{rL}$, $\Xi_1$ and the $i$-th column of $\mathbf{A}_{rp}^H$. Thus, the complexity of \textbf{Algorithm} \ref{rcg} is $\mathcal{O}(N_r I_1)$, where $I_1$ denotes the number of iterations of the RCG algorithm. Therefore, the overall complexity is $\mathcal{O} ( (N_b + N_r I_1) I_2)$, where $I_2$ denotes the number of iterations of \textbf{Algorithm} \ref{alg_overall}.
\begin{algorithm}[t]
\caption{Alternating Optimization Algorithm for Problem $\mathcal{P}_1$}
\label{alg_overall}
\begin{algorithmic}[1]
\State Initialize: $\mathbf{Q}^{(0)}= \frac{P_T}{N_b} \mathbf{I}_{N_b}$, $\mathbf{\Theta}^{(0)}$ is randomly generated where the phases $\{\theta_l\}_{\forall l}$ are uniformly and independently distributed in $[0,2\pi)$, error tolerance $\epsilon$, and set $i=0$;
\Repeat
\State Calculate $\mathbf{Q}^{(i+1)}$ according to \eqref{opt_Q} with fixed $\mathbf{\Theta}^{(i)}$;
\State Calculate $\mathbf{\Theta}^{(i+1)}$ based on \textbf{Algorithm} \ref{rcg} with fixed $\mathbf{Q}^{(i+1)}$;
\State $i \leftarrow i+1$;
\Until The increase of the objective value of the problem $\mathcal{P}_1$ is below the threshold $\epsilon$.
\end{algorithmic}
\end{algorithm}
\section{Simulation Results}
In this section, we first investigate the tightness of the derived ergodic capacity approximation through Monte-Carlo simulations, then evaluate the performance of the proposed algorithms. We adopt the widely used SV channel model illustrated in Section \ref{sec_system}. {The angles $\phi_{b,i}$ and $\psi_{u,i}$ are randomly generated and uniformly distributed in $[-\pi, \pi)$, $\phi^1_{r,i}$ and $\varphi^1_{r,i}$ in $[-\pi/2,\pi/2]$, and $\phi^2_{r,i}$ and $\varphi^2_{r,i}$ in $[0,\pi]$. } Other system parameters are set as follows unless specified otherwise later: $N_b=16, N_r=8\times 8, N_u =16$. In the first part, we set $\mathbf{Q} = \frac{P_T}{N_b} \mathbf{I}_{N_b}$ and $\mathbf{\Theta}$ is randomly generated where the phases $\{\theta_l\}_{\forall l}$ are uniformly and independently distributed in $[0,2\pi)$. All simulation curves are averaged over 1000 independent channel realizations.
\subsection{Tightness of the Derived Ergodic Capacity Approximation}
\begin{figure}[ht]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=8cm]{ecapacity_app.eps}
\caption{Ergodic capacity against the transmit SNR with $P=6$ and $L=8$.} \label{ecapacity_app}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=8cm]{ecapacity_upper.eps}
\caption{Capacity upper bound in the high-SNR regime against the transmit SNR.} \label{ecapacity_upper}
\end{minipage}
\end{figure}
Fig.~\ref{ecapacity_app} illustrates the ergodic capacity against the transmit SNR. Firstly, it is found that $C_{app}$ fits the Monte-Carlo results well. However, there are complex integral items involved in $C_{app}$, which is not convenient for analysis and optimization. Secondly, $C_{Jen1}$ is much larger than the Monte-Carlo results because it is amplified by the Jensen's inequality. Finally, $C_{Jen2}$ approximates the Monte-Carlo well though it is slightly smaller than the Monte-Carlo results in low-SNR regime. In addition, $C_{Jen2}$ has a very concise expression form. Therefore, it is reasonable to adopt $C_{Jen2}$ to approximate the ergodic capacity in the optimization.
\begin{figure}[ht]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=8cm]{ecapacity_len.eps}
\caption{Ergodic capacity upper bound against the number of antennas or reflection units with $\text{SNR}=50$ dB, $P=6$ and $L=6$.} \label{ecapacity_len}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=8cm]{conver.eps}
\caption{Convergence of the proposed algorithm with $\text{SNR}=10$ dB, $P=6$, and $L=8$.} \label{conver}
\end{minipage}
\end{figure}
Fig.~\ref{ecapacity_upper} provides the ergodic capacity upper bound in the high-SNR regime against the transmit SNR. It is found that when SNR is low, $C_h^{upper}$ is much smaller than the Monte-Carlo results. When SNR becomes large, the Monte-Carlo results are bounded by $C_h^{upper}$, which verifies \textbf{Proposition} \ref{prop_upper}. Specifically, $C_h^{upper}$ is the same as the Monte-Carlo results when $N_s=P=L$ and the SNR is larger than 30 dB.
Fig.~\ref{ecapacity_len} shows the ergodic capacity upper bound $C_h^{upper}$ against the number of antennas or reflection units. The leftmost point in this figure is plotted when $N_b=N_r=N_u=10$, and the other points correspond to the case where one of the three parameters above increases to $(20, 40, 80, 160, 320, 640)$ while the other two remain at 10. Particularly, the RIS is equipped with $N_r^1\times N_r^2$ unit cells where $N_r^1=10$ and $N_r^2$ can vary. It is found that the ergodic capacity increases logarithmically with the number of antennas at the user and the number of reflection units at the RIS. Note that the fluctuation of the curve of the RIS is due to the randomly generated reflection coefficients of the RIS. Furthermore, the ergodic capacity is nearly unchanged when the number of antennas at the BS exceeds 40. It is because the eigenvalues of $\mathbf{A}_b^H \mathbf{A}_b$ are nearly unchanged when the number of antennas at the BS is very large. Thus, the ergodic capacity can not be improved by increasing the number of antennas at the BS.
\subsection{Performance of the Proposed Algorithms}
\begin{figure}[t]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=8cm]{bench_comp_snrright2.eps}
\caption{Performance comparison with benchmarks when $P=6$ and $L=8$. } \label{bench_comp}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=8cm]{optimize_Q_ris.eps}
\caption{Influence comparison between transmit covariance matrix and reflection coefficients with $N_b=16,N_r=64,N_u=16, P=6$ and $L=8$.} \label{opt_Q_ris1}
\end{minipage}
\end{figure}
\begin{figure}[ht]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=8cm]{optimize_Q_ris2.eps}
\caption{Influence comparison between transmit covariance matrix and reflection coefficients with $N_b=32,N_r=64,N_u=16, P=6$ and $L=8$.} \label{opt_Q_ris2}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=8cm]{optimize_Q_ris3.eps}
\caption{Influence comparison between transmit covariance matrix and reflection coefficients with $N_b=64,N_r=64,N_u=16, P=6$ and $L=8$.} \label{opt_Q_ris3}
\end{minipage}
\end{figure}
\begin{figure}[ht]
\begin{centering}
\includegraphics[width=.6\textwidth]{main_rislength2.eps}
\caption{Ergodic capacity against the number of antennas or reflection units with $\text{SNR}=50$ dB, $P=L=6$.} \label{main_rislength}
\end{centering}
\vspace{-0.2cm}
\end{figure}
Fig.~\ref{conver} illustrates the convergence performance of the proposed \textbf{Algorithm} \ref{alg_overall}. It can be found that the proposed algorithm converges within 10 iterations, which verifies the convergence of the proposed algorithm.
In Fig.~\ref{bench_comp}, we compare the proposed algorithm with two state-of-the-art benchmarks that assume the knowledge of perfect instantaneous CSI.
\begin{itemize}
\item Alternating optimization based algorithm (AO) \cite{9110912}: The transmit covariance matrix $\mathbf{Q}$ and each unit of the reflection coefficients of the RIS $\{\theta_i\}_{\forall i}$ are alternately optimized until convergence. Note that the closed-form solution at each step is obtained.
\item Truncated-SVD-based beamforming (T-SVD-BF) \cite{9234098}: By exploiting the sparse structure of the mmWave communication, work \cite{9234098} first proposes a manifold-based method to optimize the reflection coefficients of the RIS, then adopts the water-filling algorithm to handle the active beamforming at the BS. Note that no alternating process is needed and each step only needs to be executed once.
\end{itemize}
It is found that our proposed algorithm outperforms T-SVD-BF and performs a little worse than the AO-based algorithm. When SNR is low, our proposed algorithm performs much worse than the AO-based algorithm because $C_{Jen2}$ is a little smaller than the Monte-Carlo results in low-SNR regime as shown in Fig.~\ref{ecapacity_app}. The AO-based algorithm performs best because it has closed-form solution in each step and converges to a stationary point. However, when the number of reflection units of the RIS is large, its computational complexity is very high, which is not suitable in practice. The T-SVD-BF method exploits the sparse structure of the mmWave communication and runs very fast. However, its performance is the worst. Note that both the AO-based algorithm and the T-SVD-BF method need perfect instantaneous CSI, which is difficult to obtain. Nevertheless, our proposed algorithm only needs the statistical CSI and its performance is attractive.
In addition, we compare the influence on ergodic capacity of transmit covariance matrix and reflection coefficients in Fig.~\ref{opt_Q_ris1} - \ref{opt_Q_ris3}. The only difference among them is the number of antennas at the BS, which changes from 16, 32 to 64. The curve ``Optimize RIS only" indicates that $\mathbf{Q} = \frac{P_T}{N_b} \mathbf{I}_{N_b}$. The curve ``Optimize Q only" indicates that $\mathbf{\Theta}$ is randomly generated by setting the phases $\{\theta_l\}_{\forall l}$ as uniformly and independently distributed in $[0,2\pi)$. Firstly, it is found that the ergodic capacity after optimization is about 20 bits/s/Hz higher than that before optimization on average, which verifies the effectiveness of the optimization. Secondly, we observe that when $N_b=16$, the curve ``Optimize RIS only" outperforms the curve ``Optimize Q only". However, when $N_b=32$ and $N_b=64$, the curve ``Optimize RIS only" performs worse than the curve ``Optimize Q only" and the gap enlarges. Thus, with the same number of antennas at the BS and reflection coefficients at the RIS, optimizing the transmit covariance matrix at the BS is superior to optimizing the reflection coefficients at the RIS. When the number of reflection coefficients is much larger than the number of antennas, optimizing the reflection coefficients outperforms optimizing the transmit covariance matrix. Thanks to the low cost of the RIS elements, the RIS is usually composed of a large number of reflection units. In this case, the systems still perform well when the CSI is not available at the BS and the reflection coefficients at the RIS is optimized.
Finally, Fig.~\ref{main_rislength} depicts the ergodic capacity against the number of antennas or reflection units. The system parameter settings are the same as those of Fig.~\ref{ecapacity_len}, while the proposed algorithm is adopted in Fig.~\ref{main_rislength}. Compared with Fig.~\ref{ecapacity_len}, it is interesting to find that the ergodic capacity increases logarithmically with the number of antennas at the BS when the transmit covariance matrix is optimized. Thus, the optimization of the transmit covariance matrix is very important in the RIS-aided mmWave MIMO systems.
\section{Conclusion}
In this paper, we considered the ergodic capacity of an RIS-aided mmWave MIMO communication system under the SV channel models. The ergodic capacity approximation was derived by means of majorization theory. We also derived the upper bound of the ergodic capacity in high-SNR regime. Based on the derived approximation, we maximized the ergodic capacity by jointly designing the transmit covariance and reflection coefficients at BS and RIS, respectively. Numerical results proved the tightness of the derived ergodic capacity approximation. It was found that the ergodic capacity after optimization could be improved by about 20 bits/s/Hz, which verified the effectiveness of the optimization. In addition, when the BS allocated equal power over transmit signals, the ergodic capacity remained unchanged after the number of antennas at the BS reached a certain amount. Moreover, it was revealed that if we were allowed to optimize either the transmit covariance matrix or the reflection coefficients, optimizing the reflection coefficients was more effective than optimizing the transmit covariance matrix only in the case of a large number of reflection units. The analysis and results in this article provided insights on the deployment and capacity evaluation of RIS-assisted mmWave wireless systems. Future work may consider the situation with multiple users and RISs.
|
{'timestamp': '2022-02-15T02:39:10', 'yymm': '2202', 'arxiv_id': '2202.06564', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06564'}
|
arxiv
|
\subsection{Development Trends}
\section{Introduction}
The {\it IJCAI--19 Proceedings} will be printed from electronic
manuscripts submitted by the authors. These must be PDF ({\em Portable
Document Format}) files formatted for 8-1/2$''$ $\times$ 11$''$ paper.
\subsection{Length of Papers}
All paper {\em submissions} must have a maximum of six pages, plus at most one for references. The seventh page cannot contain {\bf anything} other than references.
The length rules may change for final camera-ready versions of accepted papers, and will differ between tracks. Some tracks may include only references in the last page, whereas others allow for any content in all pages. Similarly, some tracks allow you to buy a few extra pages should you want to, whereas others don't.
If your paper is accepted, please carefully read the notifications you receive, and check the proceedings submission information website\footnote{\url{https://proceedings.ijcai.org/info}} to know how many pages you can finally use (and whether there is a special references-only page or not). That website holds the most up-to-date information regarding paper length limits at all times.
\subsection{Word Processing Software}
As detailed below, IJCAI has prepared and made available a set of
\LaTeX{} macros and a Microsoft Word template for use in formatting
your paper. If you are using some other word processing software, please follow the format instructions given below and ensure that your final paper looks as much like this sample as possible.
\section{Style and Format}
\LaTeX{} and Word style files that implement these instructions
can be retrieved electronically. (See Appendix~\ref{stylefiles} for
instructions on how to obtain these files.)
\subsection{Layout}
Print manuscripts two columns to a page, in the manner in which these
instructions are printed. The exact dimensions for pages are:
\begin{itemize}
\item left and right margins: .75$''$
\item column width: 3.375$''$
\item gap between columns: .25$''$
\item top margin---first page: 1.375$''$
\item top margin---other pages: .75$''$
\item bottom margin: 1.25$''$
\item column height---first page: 6.625$''$
\item column height---other pages: 9$''$
\end{itemize}
All measurements assume an 8-1/2$''$ $\times$ 11$''$ page size. For
A4-size paper, use the given top and left margins, column width,
height, and gap, and modify the bottom and right margins as necessary.
\subsection{Format of Electronic Manuscript}
For the production of the electronic manuscript, you must use Adobe's
{\em Portable Document Format} (PDF). A PDF file can be generated, for
instance, on Unix systems using {\tt ps2pdf} or on Windows systems
using Adobe's Distiller. There is also a website with free software
and conversion services: \url{http://www.ps2pdf.com}. For reasons of
uniformity, use of Adobe's {\em Times Roman} font is strongly suggested. In
\LaTeX2e{}, this is accomplished by putting
\begin{quote}
\mbox{\tt $\backslash$usepackage\{times\}}
\end{quote}
in the preamble.\footnote{You may want also to use the package {\tt
latexsym}, which defines all symbols known from the old \LaTeX{}
version.}
Additionally, it is of utmost importance to specify the American {\bf
letter} format (corresponding to 8-1/2$''$ $\times$ 11$''$) when
formatting the paper. When working with {\tt dvips}, for instance, one
should specify {\tt -t letter}.
\subsection{Title and Author Information}
Center the title on the entire width of the page in a 14-point bold
font. The title should be capitalized using Title Case. Below it, center author name(s) in 12-point bold font. On the following line(s) place the affiliations, each affiliation on its own line using 12-point regular font. Matching between authors and affiliations can be done using numeric superindices. Optionally, a comma-separated list of email addresses follows the affiliation(s) line(s), using 12-point regular font.
\subsubsection{Blind Review}
In order to make blind reviewing possible, authors must omit their
names and affiliations when submitting the paper for review. In place
of names and affiliations, provide a list of content areas. When
referring to one's own work, use the third person rather than the
first person. For example, say, ``Previously,
Gottlob~\shortcite{gottlob:nonmon} has shown that\ldots'', rather
than, ``In our previous work~\cite{gottlob:nonmon}, we have shown
that\ldots'' Try to avoid including any information in the body of the
paper or references that would identify the authors or their
institutions. Such information can be added to the final camera-ready
version for publication.
\subsection{Abstract}
Place the abstract at the beginning of the first column 3$''$ from the
top of the page, unless that does not leave enough room for the title
and author information. Use a slightly smaller width than in the body
of the paper. Head the abstract with ``Abstract'' centered above the
body of the abstract in a 12-point bold font. The body of the abstract
should be in the same font as the body of the paper.
The abstract should be a concise, one-paragraph summary describing the
general thesis and conclusion of your paper. A reader should be able
to learn the purpose of the paper and the reason for its importance
from the abstract. The abstract should be no more than 200 words long.
\subsection{Text}
The main body of the text immediately follows the abstract. Use
10-point type in a clear, readable font with 1-point leading (10 on
11).
Indent when starting a new paragraph, except after major headings.
\subsection{Headings and Sections}
When necessary, headings should be used to separate major sections of
your paper. (These instructions use many headings to demonstrate their
appearance; your paper should have fewer headings.). All headings should be capitalized using Title Case.
\subsubsection{Section Headings}
Print section headings in 12-point bold type in the style shown in
these instructions. Leave a blank space of approximately 10 points
above and 4 points below section headings. Number sections with
arabic numerals.
\subsubsection{Subsection Headings}
Print subsection headings in 11-point bold type. Leave a blank space
of approximately 8 points above and 3 points below subsection
headings. Number subsections with the section number and the
subsection number (in arabic numerals) separated by a
period.
\subsubsection{Subsubsection Headings}
Print subsubsection headings in 10-point bold type. Leave a blank
space of approximately 6 points above subsubsection headings. Do not
number subsubsections.
\paragraph{Titled paragraphs.} You can use titled paragraphs if and
only if the title covers exactly one paragraph. Such paragraphs must be
separated from the preceding content by at least 3pt, and no more than
6pt. The title must be in 10pt bold font and ended with a period.
After that, a 1em horizontal space must follow the title before
the paragraph's text.
In \LaTeX{} titled paragraphs must be typeset using
\begin{quote}
{\tt \textbackslash{}paragraph\{Title.\} text} .
\end{quote}
\subsubsection{Acknowledgements}
You may include an unnumbered acknowledgments section, including
acknowledgments of help from colleagues, financial support, and
permission to publish. If present, acknowledgements must be in a dedicated,
unnumbered section appearing after all regular sections but before any
appendices or references.
Use
\begin{quote}
{\tt \textbackslash{}section*\{Acknowledgements\}})
\end{quote}
to typeset the acknowledgements section in \LaTeX{}.
\subsubsection{Appendices}
Any appendices directly follow the text and look like sections, except
that they are numbered with capital letters instead of arabic
numerals. See this document for an example.
\subsubsection{References}
The references section is headed ``References'', printed in the same
style as a section heading but without a number. A sample list of
references is given at the end of these instructions. Use a consistent
format for references. The reference list should not include unpublished
work.
\subsection{Citations}
Citations within the text should include the author's last name and
the year of publication, for example~\cite{gottlob:nonmon}. Append
lowercase letters to the year in cases of ambiguity. Treat multiple
authors as in the following examples:~\cite{abelson-et-al:scheme}
or~\cite{bgf:Lixto} (for more than two authors) and
\cite{brachman-schmolze:kl-one} (for two authors). If the author
portion of a citation is obvious, omit it, e.g.,
Nebel~\shortcite{nebel:jair-2000}. Collapse multiple citations as
follows:~\cite{gls:hypertrees,levesque:functional-foundations}.
\nocite{abelson-et-al:scheme}
\nocite{bgf:Lixto}
\nocite{brachman-schmolze:kl-one}
\nocite{gottlob:nonmon}
\nocite{gls:hypertrees}
\nocite{levesque:functional-foundations}
\nocite{levesque:belief}
\nocite{nebel:jair-2000}
\subsection{Footnotes}
Place footnotes at the bottom of the page in a 9-point font. Refer to
them with superscript numbers.\footnote{This is how your footnotes
should appear.} Separate them from the text by a short
line.\footnote{Note the line separating these footnotes from the
text.} Avoid footnotes as much as possible; they interrupt the flow of
the text.
\section{Illustrations}
Place all illustrations (figures, drawings, tables, and photographs)
throughout the paper at the places where they are first discussed,
rather than at the end of the paper.
They should be floated to the top (preferred) or bottom of the page,
unless they are an integral part
of your narrative flow. When placed at the bottom or top of
a page, illustrations may run across both columns, but not when they
appear inline.
Illustrations must be rendered electronically or scanned and placed
directly in your document. All illustrations should be understandable when printed in black and
white, albeit you can use colors to enhance them. Line weights should
be 1/2-point or thicker. Avoid screens and superimposing type on
patterns as these effects may not reproduce well.
Number illustrations sequentially. Use references of the following
form: Figure 1, Table 2, etc. Place illustration numbers and captions
under illustrations. Leave a margin of 1/4-inch around the area
covered by the illustration and caption. Use 9-point type for
captions, labels, and other text in illustrations. Captions should always appear below the illustration.
\section{Tables}
Tables are considered illustrations containing data. Therefore, they should also appear floated to the top (preferably) or bottom of the page, and with the captions below them.
\begin{table}
\centering
\begin{tabular}{lll}
\hline
Scenario & $\delta$ & Runtime \\
\hline
Paris & 0.1s & 13.65ms \\
Paris & 0.2s & 0.01ms \\
New York & 0.1s & 92.50ms \\
Singapore & 0.1s & 33.33ms \\
Singapore & 0.2s & 23.01ms \\
\hline
\end{tabular}
\caption{Latex default table}
\label{tab:plain}
\end{table}
\begin{table}
\centering
\begin{tabular}{lrr}
\toprule
Scenario & $\delta$ (s) & Runtime (ms) \\
\midrule
Paris & 0.1 & 13.65 \\
& 0.2 & 0.01 \\
New York & 0.1 & 92.50 \\
Singapore & 0.1 & 33.33 \\
& 0.2 & 23.01 \\
\bottomrule
\end{tabular}
\caption{Booktabs table}
\label{tab:booktabs}
\end{table}
If you are using \LaTeX, you should use the {\tt booktabs} package, because it produces better tables than the standard ones. Compare Tables \ref{tab:plain} and~\ref{tab:booktabs}. The latter is clearly more readable for three reasons:
\begin{enumerate}
\item The styling is better thanks to using the {\tt booktabs} rulers instead of the default ones.
\item Numeric columns are right-aligned, making it easier to compare the numbers. Make sure to also right-align the corresponding headers, and to use the same precision for all numbers.
\item We avoid unnecessary repetition, both between lines (no need to repeat the scenario name in this case) as well as in the content (units can be shown in the column header).
\end{enumerate}
\section{Formulas}
IJCAI's two-column format makes it difficult to typeset long formulas. A usual temptation is to reduce the size of the formula by using the {\tt small} or {\tt tiny} sizes. This doesn't work correctly with the current \LaTeX{} versions, breaking the line spacing of the preceding paragraphs and title, as well as the equation number sizes. The following equation demonstrates the effects (notice that this entire paragraph looks badly formatted):
\begin{tiny}
\begin{equation}
x = \prod_{i=1}^n \sum_{j=1}^n j_i + \prod_{i=1}^n \sum_{j=1}^n i_j + \prod_{i=1}^n \sum_{j=1}^n j_i + \prod_{i=1}^n \sum_{j=1}^n i_j + \prod_{i=1}^n \sum_{j=1}^n j_i
\end{equation}
\end{tiny}%
Reducing formula sizes this way is strictly forbidden. We {\bf strongly} recommend authors to split formulas in multiple lines when they don't fit in a single line. This is the easiest approach to typeset those formulas and provides the most readable output%
\begin{align}
x =& \prod_{i=1}^n \sum_{j=1}^n j_i + \prod_{i=1}^n \sum_{j=1}^n i_j + \prod_{i=1}^n \sum_{j=1}^n j_i + \prod_{i=1}^n \sum_{j=1}^n i_j + \nonumber\\
+ & \prod_{i=1}^n \sum_{j=1}^n j_i
\end{align}%
If a line is just slightly longer than the column width, you may use the {\tt resizebox} environment on that equation. The result looks better and doesn't interfere with the paragraph's line spacing: %
\begin{equation}
\resizebox{.91\linewidth}{!}{$
\displaystyle
x = \prod_{i=1}^n \sum_{j=1}^n j_i + \prod_{i=1}^n \sum_{j=1}^n i_j + \prod_{i=1}^n \sum_{j=1}^n j_i + \prod_{i=1}^n \sum_{j=1}^n i_j + \prod_{i=1}^n \sum_{j=1}^n j_i
$}
\end{equation}%
This last solution may have to be adapted if you use different equation environments, but it can generally be made to work. Please notice that in any case:
\begin{itemize}
\item Equation numbers must be in the same font and size than the main text (10pt).
\item Your formula's main symbols should not be smaller than {\small small} text (9pt).
\end{itemize}
For instance, the formula
\begin{equation}
\resizebox{.91\linewidth}{!}{$
\displaystyle
x = \prod_{i=1}^n \sum_{j=1}^n j_i + \prod_{i=1}^n \sum_{j=1}^n i_j + \prod_{i=1}^n \sum_{j=1}^n j_i + \prod_{i=1}^n \sum_{j=1}^n i_j + \prod_{i=1}^n \sum_{j=1}^n j_i + \prod_{i=1}^n \sum_{j=1}^n i_j
$}
\end{equation}
would not be acceptable because the text is too small.
\section{Algorithms and Listings}
Algorithms and listings are a special kind of figures. Like all illustrations, they should appear floated to the top (preferably) or bottom of the page. However, their caption should appear in the header, left-justified and enclosed between horizontal lines, as shown in Algorithm~\ref{alg:algorithm}. The algorithm body should be terminated with another horizontal line. It is up to the authors to decide whether to show line numbers or not, how to format comments, etc.
In \LaTeX{} algorithms may be typeset using the {\tt algorithm} and {\tt algorithmic} packages, but you can also use one of the many other packages for the task.
\begin{algorithm}[tb]
\caption{Example algorithm}
\label{alg:algorithm}
\textbf{Input}: Your algorithm's input\\
\textbf{Parameter}: Optional list of parameters\\
\textbf{Output}: Your algorithm's output
\begin{algorithmic}[1]
\STATE Let $t=0$.
\WHILE{condition}
\STATE Do some action.
\IF {conditional}
\STATE Perform task A.
\ELSE
\STATE Perform task B.
\ENDIF
\ENDWHILE
\STATE \textbf{return} solution
\end{algorithmic}
\end{algorithm}
\section*{Acknowledgments}
The preparation of these instructions and the \LaTeX{} and Bib\TeX{}
files that implement them was supported by Schlumberger Palo Alto
Research, AT\&T Bell Laboratories, and Morgan Kaufmann Publishers.
Preparation of the Microsoft Word file was supported by IJCAI. An
early version of this document was created by Shirley Jowell and Peter
F. Patel-Schneider. It was subsequently modified by Jennifer
Ballentine and Thomas Dean, Bernhard Nebel, Daniel Pagenstecher,
Kurt Steinkraus, Toby Walsh and Carles Sierra. The current version
has been prepared by Marc Pujol-Gonzalez and Francisco Cruz-Mencia.
\section{Introduction}
Multi-stage Recommender Systems (MRS) are widely adopted by many of today's largest online platforms, including Google \cite{seq2slate}, YouTube \cite{wilhelm2018practical}, LinkedIn \cite{geyik2019fairness}, and Taobao \cite{prm}. MRS is a natural solution to the computational limits in practical recommendation applications, where the numbers of users and items grow into billions.
The recommendation task is split into multiple steps in MRS---each step narrows down the relevant items with a slower but more accurate model \cite{hron2021component}, to guarantee low response latency. A common structure for MRS consists of three stages in general: candidates generation (\emph{a.k.a.,} recall or matching), ranking, and re-ranking. The system firstly generates candidates from a large pool of items. Then these candidates are scored and ranked in the ranking stage.
Finally, the system conducts re-ranking on the top candidates based on certain rules or objectives to further improve the recommendation results. Specifically, the re-ranking stage takes as input the initial ranking list from the ranking stage, and outputs a re-ordered list by considering the listwise context (cross-item interactions).
Whether a user is interested in an item is not only determined by the item itself, but also by other items placed in the same list (\emph{i.e.}, the listwise context) \cite{prm}.
Thus, a key technical challenge is to model the listwise context in re-ranking.
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{imgs/rerank_quadrant.pdf}
\caption{Four quadrants of neural re-ranking models. Shapes denote different objectives, and colors represent the major network structures for re-ranking.}
\label{fig:orgchart}
\end{figure}
Re-ranking dates back to Carbonell's work \shortcite{carbonell1998use}, which greedily adds items to the list with maximal marginal relevance. With deep neural networks led to exciting breakthroughs in various fields \cite{goodfellow2016deep,goldberg2017neural}, re-ranking methods evolved to the recent deep neural architectures.
Neural re-ranking models get rid of the hand-crafted features and benefit from the automatic learning of the listwise context, due to the universal approximation property of neural networks \cite{cybenko1989approximation}. Therefore, applying neural networks for re-ranking is the main focus in both academia and industry in recent years. This paper provides a first review on neural re-ranking for recommendation.
\subsection{A Taxonomy}
We differentiate neural re-ranking models by objectives (single accuracy objective or multiple objectives) and the supervision signals (observed signals or counterfactual signals). The resulting four quadrants are outlined in Fig.~\ref{fig:orgchart}.
Considering the objectives, most studies focus on the single accuracy objective, as accurately predicting users' interests is the foundation of recommender systems. While beyond accuracy, several other objectives are also desired from a re-ranking model like diversity or fairness, thus leading to recent work on how to optimize multiple objectives in re-ranking and better manage the tradeoff between them.
Another important factor that separates different re-ranking models is the supervision signals for relevance. Most work is directly trained by the displayed initial ranking lists and the corresponding observed labels. Some other work, however, points out that the relevance of each item depends on the listwise context, and different permutations of the input list yield different relevance labels \cite{prs}. The supervision signals are therefore provided by an extra evaluator on the unobserved counterfactual permutations that have not been actually displayed to the user, to model the listwise context under different permutations.
From Fig.~\ref{fig:orgchart}, we observe the following development characteristics of existing neural re-ranking work: (i) Most studies seek to purely enhance accuracy with a single accuracy objective, while diversity/fairness-aware methods with multi-objectives have been relatively less explored. (ii) Self-attention \cite{vaswani2017attention} or a combination of RNN \cite{hochreiter1997long} and the attention have become popular network structures in re-ranking. (iii) Few works discuss the influence of counterfactual permutations on relevance in multi-objective learning (the first quadrant of Fig.~\ref{fig:orgchart}), which could be a potential research direction. We will elaborate on the details of each method according to our proposed taxonomy in the following sections.
\section{Neural Re-ranking for Recommendation}
Neural re-ranking usually aims to construct a multivariate scoring function, whose input is a whole list of items from the initial ranking, to model the listwise context/cross-item interactions \cite{setrank,gsf}. This is in contrast to ranking models where the ranking functions are mostly univariate that take one item at a time, and the correlations between items are only modeled at loss level using pairwise or listwise loss functions \cite{xia2008listwise}.
For a specific user, given the initial list $R$ of $n$ items, and the corresponding supervision signals $Y\in\mathbb R^n$, a neural re-ranking problem is to find the optimal ranking
function $\phi_*$ that maps the input to a list of re-ranking scores as
\begin{equation}\label{eq:rerank_function}
\phi_*=\arg\min_{\Phi} \sum_{R,Y} \mathcal L(Y,\phi(R))\,,
\end{equation}
where $\mathcal L(\cdot)$ is the loss function.
The major goal of the re-ranking is to optimize accuracy, which is usually measured by ranking metrics like NDCG or MAP. While beyond accuracy, encouraging diversity or fairness of the re-ranking is also one of the critical goals.
This general formulation of Eq.\eqref{eq:rerank_function} provide another perspective to describe our proposed taxonomy in Fig.~\ref{fig:orgchart}. The design of the loss function, either is purely accuracy-oriented or a combination of multiple objectives, differentiates re-ranking models into the single objective and the multi-objective ones. On the other hand, whether the supervision signal $Y$ comes from the data log or an evaluator, separates re-ranking models into learning by observed signals or by counterfactual signals. Fig.~\ref{fig:flowchart} shows typical network architectures for re-ranking. Learning by observed signals usually follows a direct architecture, outputting re-ranking scores with listwise context modeling. Whereas learning by counterfactual signals generally adopts a generator-evaluator paradigm---the generator generates re-ranking lists under the guidance of an evaluator, where both the generator and the evaluator attend to the listwise contexts. Later we will introduce different neural re-ranking models according to the four quadrants in detail.
\section{Single Objective: Accuracy-oriented}\label{sect:acc}
Recommendation accuracy of the re-ranking model is the fundamental goal for MRS, and the evaluation of a re-ranking model is usually the \textit{overall listwise utility} like NDCG or MAP of the re-ranking list.
According to the supervision signal, we further divide existing re-ranking models into two groups: learning by observed signals and learning by counterfactual signals. Learning by observed signals directly uses the initial ranking list $R$ and the corresponding label $Y$, which is actually displayed to the user and obtained feedback, to train the model. On the contrary, learning by counterfactual signals presumes the item's relevance varies under different permutations---even with the same items, users respond distinctly to different permutations of these items. Therefore, they introduce an additional evaluator to provide signals for counterfactual permutations that have not been actually displayed to the user. Listwise context is thereby estimated on the counterfactual permutations. Below we describe various attempts with their advantages and disadvantages for methods of learning by observed signals and learning by counterfactual signals.
\subsection{Learning by Observed Signals}\label{sect:observed}
Learning by observed signals is simple and straightforward. A typical architecture of the re-ranking model for learning by observed signals can be outlined as in Fig.~\ref{fig:flowchart}(a), which firstly embeds user and item features into low-dimensional dense vectors, and then extracts cross-item interactions by the listwise context modeling to generate the re-ranking scores. The observed labels are actual feedback from users, and thus are less noisy and easier to train. Moreover, the initial list provides strong signals for items' relevance estimated by previous ranking models. Several existing studies have shown the effectiveness of directly learning by observed signals \cite{dlcm,prm,setrank,feng2021revisit}. By the network structure adopted to model the listwise context, we further classify the existing methods into \textit{recurrent listwise modeling} with recurrent neural networks (RNN), \textit{attentive listwise modeling} with self-attention, and \textit{others} like multi-layer perceptrons (MLP), graph neural networks (GNN), \textit{etc}., where different network structures are also plotted in Fig.~\ref{fig:orgchart} by different colors.
\smallskip
\noindent
\textbf{Recurrent listwise modeling.} As one of the earliest neural re-ranking methods for improving accuracy, DLCM \cite{dlcm} uses gated recurrent units (GRU) to sequentially encode the top-ranked items with their feature vectors. The recurrent unit combines the information for the current item with previous items, which naturally captures the sequential dependencies among items and the positional effect of the initial list.
MiDNN \cite{midnn} also applies recurrent networks, the long-short term memory (LSTM), with a global feature extension method to capture cross-item influences. It formulates the re-ranking as a sequence generation problem, and sequentially selects the next items with beam search to conform to the users' browsing habit.
Seq2Slate \cite{seq2slate} extends MiDNN by adopting a more flexible pointer network to solve the re-ranking problem. The pointer network produces the next item with an attention mechanism, attending to the items in the initial list.
\smallskip
\noindent
\textbf{Attentive listwise modeling.}
Lately, inspired by the success of the self-attention architecture used in natural language processing \cite{vaswani2017attention}, several re-ranking models that apply the multi-head self-attention are proposed. Compared to RNN, the self-attention mechanism directly models the interactions between any pair of candidate items without degradation over the encoding distance.
PRM \cite{prm} is a generally straightforward adaptation of the self-attention structure, which is a stack of multiple blocks of self-attention layers and feed-forward networks with position embeddings of the initial list. A pretrained personalized embedding is used to extract user-specific mutual influences between candidate items.
PFRN \cite{pfrn} employs multiple self-attention structures to flight itinerary re-ranking.
Instead of a simple concatenation of a pre-trained user representation with the candidate item representation as in PRM, PFRN exploits users' multiple behaviors, like long-term booking behaviors, real-time clicking behaviors, by individual multi-head self-attentions. The final prediction is generated by capturing the interactions between candidate items and users' multiple behaviors.
A more recent work Raiss \cite{raise} attempts to improve personalization in re-ranking by maintaining individual attention weights in modeling cross-item interactions for each user.
\smallskip
\noindent
\textbf{Other network structures.}
To avoid potential position or contextual bias, List-CVAE \cite{listcvae} further explores conditional variational auto-encoders (CVAE) and directly learns the joint distribution of items conditioned on user responses.
\citet{pivotcvae} find that the generative model of List-CVAE is usually trapped in a few items and fails to cover item variation in the re-ranking list. They propose a pivot selection phase (PivotCVAE) to improve the variation of the list.
HRM \cite{hrm} finds that introducing user behaviors and computing the similarity between candidate items and interested items in history improves the quality of re-ranking.
Liu \textit{et al}. \shortcite{irgpr} further investigate the complementary and substitutable relationships among candidate items and propose a graph-based model, IRGPR.
Above we have provided a brief review of the development for methods of learning by observed signals. Most of the work formulates the re-ranking as a sequential modeling problem to extract the cross-item interactions on initial ranking lists. We also witness a trend of evolving from recurrent to self-attentive structures.
However, despite the various network structures, the above models are only trained with the only permutation that is displayed to the users, with other $n!-1$ permutations unexplored, limiting the potential of selecting the optimal permutation for re-ranking. In the next section, we will focus on learning by counterfactual signals that estimates listwise contexts on different permutations.
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{imgs/rerank_architect.pdf}
\caption{Re-ranking network architectures. (a) A typical neural re-ranking architecture for learning by observed signals. (b) The evaluator-generator paradigm for learning by counterfactual signals.}
\label{fig:flowchart}
\end{figure}
\subsection{Learning by Counterfactual Signals}\label{sect:counterfactual}
To provide signals on counterfactual lists, methods that learn by counterfactual signals usually follow \textit{an evaluator-generator paradigm} (EG)---with a generator to generate feasible permutations and an evaluator to evaluate the listwise utility of each permutation, as shown in Fig.~\ref{fig:flowchart}(b).
\citet{seg} first adopt the evaluator-generator paradigm and propose the SEG model. They point out two desired properties for an evaluator: (i) \textit{Order-sensitivity}, the evaluator needs to be sensitive to the order of the input lists; and (ii)\textit{ Generalizaility}, the evaluator shall generalize well to all possible permutations.
Under the guidance of the evaluator, SEG devises a supervised learning approach and a reinforcement learning approach to train the generator. The supervised learning approach directly learns the estimated utility provided by the evaluator, while the reinforcement learning approach further pursues long-term reward in each step by the temporal difference (TD) error \cite{silver2014deterministic}.
A series of follow-up studies \cite{gcr,prs,grn,crum} explores various network structures like RNN or self-attention for evaluators and the generators. Specific structures are listed in Table \ref{tab:model_comparison}. Though the structures for the generator diverge, we observe that a common choice for the evaluator is the RNN-based structure, due to its satisfying performance in modeling users' sequential behaviors \cite{ncm}.
In addition, these studies also focus on improving the training procedure of the generator. CDIA \cite{cdia} applies the actor-critic reinforcement learning and uses policy gradient with the advantage function to update the generator. To tackle the problem of large action space of $O(n!)$ for the generator, \citet{gcr} adapt the proximal policy optimization (PPO) algorithm and introduce PPO-exploration to train the generator in the proposed GCR model. PRS \cite{prs} exploits the beam search to generate feasible permutations and directly uses the evaluator to select the optimal list. GRN \cite{grn} also employs the policy gradient for optimization, whereas CRUM \cite{crum} utilizes Lambdaloss to train the generator for utility optimization. \citet{egrerank} notice that the evaluator is trained by the offline labeled data and may not generalize well to unseen distribution, and introduce EGRerank with a discriminator to provide a self-confidence score for the evaluation.
Two exceptions without the evaluator-generator architecture are GSF \cite{gsf} and SetRank \cite{setrank}, which learns permutation-invariant re-ranking models that are insensitive to permutations of the input.
A groupwise scoring function (GSF) \cite{gsf} is devised with DNN on all the size-$m$ permutations of items in initial lists ($m\leq n$).
\citet{setrank} apply a variant of self-attention structure without positional encoding and dropout (SetRank) to preserve the permutation invariant property.
Though potentially effective in selecting the optimal re-ranking list by modeling counterfactual permutations, the training procedure is often more complex and the performance depends greatly on the quality of the evaluator.
\begin{table}[t]
\centering
\caption{Comparison of accuracy-oriented re-ranking models. D/M/NP stands for personalized by input data/by model parameters/non-personalized, E/G represents evaluator/generator, $n$ is the re-ranking size, $h$ is the length of the user history, and $m$ is the permutation size for GSF.}
\label{tab:model_comparison}
\begin{adjustbox}{max width=\linewidth}
\setlength{\tabcolsep}{1.6mm}
\begin{tabular}{lllll}
\toprule
& \begin{tabular}[c]{@{}l@{}}Listwise context \\ modeling\end{tabular} & Optimization & P/NP & Complexity \\\midrule
DLCM \shortcite{dlcm} & GRU & AttRank & NP & $\mathcal O(n)$ \\
MiDNN\shortcite{midnn} & LSTM & CE & D & $\mathcal O(n)$ \\
ListCVAE \shortcite{listcvae} & CVAE & KL & NP & $\mathcal O(n)$ \\
Seq2Slate \shortcite{seq2slate} & PointerNet & CE & NP & $\mathcal O(n^2)$ \\
HRM \shortcite{hrm} & Similarity & Hinge & D & $\mathcal O(hn+h^2)$ \\
PRM \shortcite{prm} & Self-attention & CE & D & $\mathcal O(n^2)$ \\
IRGPR \shortcite{irgpr} & GNN & BPR & M & $\mathcal O(n)$ \\
PFRN \shortcite{pfrn} & Self-attention & CE & D & $\mathcal O(n^2+h^2)$ \\
PivotCVAE \shortcite{pivotcvae} & CVAE & KL & NP & $\mathcal O(n)$ \\
Raise \shortcite{raise} & Self-attention & CE & M & $\mathcal O(n^2)$ \\
\midrule
GSF \shortcite{gsf} & DNN & CE & NP & $O\mathcal (\frac{mn!}{(n-m)!})$ \\
\multirow{2}{*}{SEG \shortcite{seg}} & E: BiGRU & \multirow{2}{*}{MSE/Q-learning} & \multirow{2}{*}{D} & \multirow{2}{*}{$\mathcal O(n^2)$ } \\
& G: GRU & & & \\
SetRank \shortcite{setrank} & Self-attention & AttRank & NP & $\mathcal O(n^2)$ \\
\multirow{2}{*}{CDIA \shortcite{cdia}} & E: LSTM & \multirow{2}{*}{Policy gradient} & \multirow{2}{*}{D} & \multirow{2}{*}{$\mathcal O(n^2)$} \\
& G: LSTM & & & \\
\multirow{2}{*}{GCR \shortcite{gcr}} & E: BiGRU+attention & \multirow{2}{*}{PPO-exploration} & \multirow{2}{*}{D} & \multirow{2}{*}{$\mathcal O(n^2)$} \\
& G: GRU & & & \\
\multirow{2}{*}{PRS \shortcite{prs}]} & E: BiLSTM & \multirow{2}{*}{---} & \multirow{2}{*}{D} & \multirow{2}{*}{$\mathcal O(n^2)$} \\
& G: Beam search & & & \\
\multirow{2}{*}{GRN \shortcite{grn}} & E: BiLSTM+attention & \multirow{2}{*}{Policy gradient} & \multirow{2}{*}{D} & \multirow{2}{*}{$\mathcal O(n^2)$} \\
& \begin{tabular}[c]{@{}l@{}}G: GRU+attention+\\ PointerNet\end{tabular} & & &
\\
\multirow{2}{*}{CRUM \shortcite{crum}} & E: BiLSTM+GNN & \multirow{2}{*}{LambdaLoss} & \multirow{2}{*}{D} & \multirow{2}{*}{$\mathcal O(n)$} \\
& G: MLP & & & \\
\multirow{2}{*}{EGRerank \shortcite{egrerank}} & E: LSTM & \multirow{2}{*}{PPO} & \multirow{2}{*}{D} & \multirow{2}{*}{$\mathcal O(n^2)$} \\
& G: LSTM & & & \\
\bottomrule
\end{tabular}
\end{adjustbox}
\end{table}
\subsection{Qualitative Model Comparison}\label{sect:personalization}
Next, we give a thorough comparison of the above-mentioned models in terms of network structure, optimization, personalization, and computational complexity, as shown in Table~\ref{tab:model_comparison}.
\smallskip
\noindent
\textbf{Network structure.}
We notice that using self-attention, or a combination of RNN and the attention mechanism in re-ranking has been especially popular in recent years. For the design of the evaluator, bi-directional RNN (\textit{e.g.}, BiLSTM, BiGRU) is proved to be more effective in many studies \cite{seg,prs,crum}, where BiRNN is capable of capturing the two-way evolution of user’s interests during browsing \cite{grn}.
\smallskip
\noindent
\textbf{Optimization.}
For those models that learn by observed signals (the upper table), the loss function can be broadly grouped into pointwise (cross-entropy loss (CE)), pairwise (BPR loss \cite{rendle2012bpr}, hinge loss \cite{bartlett2008classification}), and listwise (Attention Rank loss (AttRank) \cite{dlcm}, KL loss). The pointwise CE loss is the most adopted loss due to its simplicity and effectiveness.
Methods that learn by counterfactual signals often follow the evaluator-generator paradigm, where the training of the generator is guided by the evaluator. Since the ranking operation is discrete and non-differentiable, these models often rely on the policy gradient \cite{silver2014deterministic} or Lambdaloss \cite{wang2018lambdaloss} to optimize the model.
\smallskip
\noindent
\textbf{Personalization.}
Re-ranking results should be user-specific and cater to individual users' preferences and intents. Moreover, the cross-item interactions of item pairs vary from user to user. Thus personalization is an essential requirement for re-ranking. We observe a trend of emphasizing personalized models over non-personalized ones in recent years. There are mainly two ways to provide personalized re-ranking results: (i) \textit{personalization by input data} and (ii) \textit{personalization by model parameters}. The former way simply takes user features as input, \textit{e.g.}, the user profiles or the user historical behaviors, and extracts personal preferences by specific network architectures like self-attention in PFRN \cite{pfrn}. The network parameters are shared across users. While the latter maintains an individual set of parameters for each user as in Raiss \cite{raise} or IRGPR \cite{irgpr}.
\smallskip
\noindent
\textbf{Complexity.}
Learning by observed signals directly predicts the re-ranking scores for $n$ items and are mainly of the linear time complexity $\mathcal O(n)$, except for the ones that apply the attentive listwise modeling. The runtime for the self-attention is quadratic in $n$ as it computes the interactions between any pair of items, but the calculation can be made parallel to accelerate the process \cite{vaswani2017attention}. Seq2Slate \cite{seq2slate} also yields a $\mathcal O(n^2)$ complexity---for each one of the $n$ steps, Seq2Slate examines the current remaining items and selects the best one from them.
As for learning by counterfactual signals, GSF takes $m$-permutations of $n$ items as input so that the complexity is $O\mathcal (\frac{mn!}{(n-m)!})$. For most evaluator-generator models, the generators sequentially select the next item similar to Seq2Slate, leading to a polynomial complexity $\mathcal O(n^2)$. CRUM \cite{crum}, on the other hand, though have a $\mathcal O(n^2)$ training time, the time complexity for inference is $\mathcal O(n)$ by directly predicting the re-ranking scores for all the $n$ items with an MLP structure.
\section{Multiple Objectives}\label{sect:multiple}
Accuracy is no doubt the most important objective for recommender systems. Apart from accuracy, other objectives like diversity or fairness are also crucial measurements in MRS. Purely optimizing accuracy, if applied carelessly, can yield similar or near-duplicate results and further result in the \textit{echo chamber} effects \cite{ge2020understanding}. Many studies aim to simultaneously optimize accuracy and other objectives (diversity/fairness). How to delicately manage the tradeoff between multiple objectives becomes a key problem, as sometimes diversity and fairness can contradict accuracy \cite{liu2019personalized}. We introduce diversity-aware and fairness-aware re-ranking in Section \ref{sect:div} and \ref{sect:fair}, respectively.
\subsection{Diversity-aware Re-ranking}\label{sect:div}
Diversity usually measures the dissimilarity of the re-ranking list for each user. In contrast to non-learning re-ranking methods like MMR \cite{carbonell1998use}, neural diversity-aware models usually conduct an end-to-end learning scheme, with no need of handcrafting relevance and diversity features. Below we give a brief review of neural diversity-aware re-ranking by broadly classifying existing studies into \textit{implicit approaches} and \textit{explicit approaches}. The implicit approaches measure diversity by inter-item similarity and do not require subtopics (\textit{e.g.}, category of items) to evaluate diversity, while explicit approaches aim at promoting the coverage of items over specified subtopics.
For implicit approaches, NTN \cite{ntn} proposes a neural tensor network to learn the dissimilarity between any pairs of items. The re-ranking list is sequentially generated by a linear combination of the relevance and the dissimilarity of candidate items. MDP-DIV \cite{mdpdiv} directly optimizes general diversity measures like $\alpha$-DCG or $S$-recall, and uses the policy gradient to optimize the long-term reward. M$^2$DIV \cite{m2div} enhances MDP-DIV by introducing LSTM and the lookahead Monte Carlo Tree Search (MCTS) to the ranking policy. \citet{daletor} derive a smooth approximation of diversity metrics in the proposed DALETOR model and apply a self-attention structure to model the listwise context.
While for explicit approaches, \citet{dssa} notice the advantage of using the attention mechanism to determine the importance for the under-covered subtopics, and propose DSSA, where the relevance and the diversity are jointly estimated with a subtopic attention.
As a follow-up to DSSA, DVGAN \cite{dvgan} formulates the problem of generating diverse re-ranking lists as a minimax game. It adapts DSSA as a generator, and involves a discriminator to determine how relevant and diverse the given list is. DESA \cite{desa} explores to leverage item dependencies in terms of both relevance and diversity, which is composed of an encoder and a decoder with the self-attention to extract item and subtopic correlations. \citet{airbnb} investigate the potential of deploying a diversity-aware re-ranking to Airbnb search. They design a metric for measuring the distance between two lists and use an LSTM structure to generate the re-ranking list.
The balance between accuracy and fairness is managed either by learning a trade-off parameter \cite{ntn}, or directly optimizing a specific metric that combines accuracy and fairness like $\alpha$-NDCG \cite{daletor}.
\subsection{Fairness-aware Re-ranking}\label{sect:fair}
Fairness, with a growing influence on IR community, has been made a critical objective for re-ranking. In this review, we focus on the \textit{item fairness}, since it is the main focus of existing re-ranking literature. Item fairness ensures each item or item group receives a fair proportion of exposure (\textit{e.g.}, proportional to its merits or utility). Neural re-ranking, however, has been a relatively under-explored domain. FMMR \cite{fmmr} first constructs fairness representation for each demographic group using CNN and adopts MMR to trade-off relevance and fairness. \citet{pgrank} aim to optimize a general utility metric while satisfying the fairness of exposure constraints by the Plackett-Luce model \cite{plackett1975analysis} in PGRank. A follow-up study, PLRank \cite{plrank}, improves the policy gradient in PGRank by deriving an unbiased estimate of the gradient. FULTR \cite{fultr} further explores a counterfactual estimate for both utility and fairness constraints for the Plackett-Luce model. \citet{gen} empirically show the prevalence of unfairness in cold-start recommendation, and propose an auto-encoder re-ranking model, GEN, to alleviate the fairness issue for cold-start items.
\begin{table*}[]
\centering
\caption{Performance Comparison on Ad and PRM Public datasets. The initial ranking list (Init) is produced by LambdaMart.}
\label{tab:overall}
\setlength{\tabcolsep}{5pt}
\renewcommand{\arraystretch}{0.8}
\begin{adjustbox}{max width=0.95\linewidth}
\begin{tabular}{l cccc cccc}
\toprule
\multirow{2}{*}{} & \multicolumn{4}{c}{Ad} & \multicolumn{4}{c}{PRM Public} \\
\cmidrule(lr){2-5} \cmidrule(lr){6-9}
& MAP@5 & NDCG@5 & MAP@10 & NDCG@10 & MAP@10 & NDCG@10 & MAP@20 & NDCG@20 \\
\midrule
Init \shortcite{lambdamart} & 0.6037 & 0.6840 & 0.6075 & 0.6990 & 0.1842 & 0.2178 & 0.1901 & 0.3202 \\ \midrule
MiDNN \shortcite{midnn} & 0.6080 & 0.6876 & 0.6117 & 0.7021 & 0.3069 & 0.3482 & 0.2977 & 0.4265 \\
GSF \shortcite{gsf} & 0.6090 & 0.6883 & 0.6126 & 0.7028 & 0.3060 & 0.3459 & 0.2968 & 0.4241 \\
EGRerank \shortcite{egrerank} & 0.6092 & 0.6890 & 0.6126 & 0.7029 & 0.3075 & 0.3502 & 0.2985 & 0.4286\\
DLCM \shortcite{dlcm} & 0.6126 & 0.6914 & 0.6162 & 0.7055 & 0.3082 & 0.3500 & 0.2991 & 0.4287 \\
SetRank \shortcite{setrank} & 0.6132 & 0.6917 & 0.6168 & 0.7060 & 0.3094 & 0.3515 & 0.3002 & 0.4297 \\
PRM \shortcite{prm} & 0.6140 & 0.6923 & 0.6178 & 0.7066 & 0.3096 & 0.3516 & 0.3003 & 0.4301\\
\bottomrule
\end{tabular}
\end{adjustbox}
\end{table*}
\section{Emerging Applications}\label{sect:app}
Neural re-ranking has also been seen in many emerging and interesting industrial applications.
\subsubsection{Integrated Re-ranking}\label{sect:int}
Integrated re-ranking (\textit{a.k.a.,} mixed re-ranking) is a rapidly emerging domain driven by practical problems, where the MRS is required to display \textit{a mix of items} from different sources/channels with heterogeneous features \textit{e.g.}, integrated feeds of articles, videos, and news \cite{hrlrec}. The input is extended from a single list to multiple lists.
DHANR \cite{dhanr} proposes a hierarchical self-attention structure to consider cross-channel interactions.
\citet{hrlrec} decompose the integrated re-ranking problem into two sub-tasks---source selection and item ranking, and use hierarchical reinforcement learning (HRL) to solve the problem. DEAR \cite{dear,ram} learns to interpolate ads and organic items by the designed deep Q-networks. \citet{liao2021cross} also adopts a reinforcement learning solution with a cross-channel attention unit.
\subsubsection{Edge Re-ranking}\label{sect:edge}
In a framework of \textit{cloud-to-edge}, \citet{gong2020edgerec} find that real-time computing on edge helps capture user preferences more delicately and improve the performance of recommendations. Therefore, they propose EdgeRec, which generates initial ranking lists on cloud, and conducts re-ranking with instant feedback on mobile devices. Edge re-ranking opens up interesting research topics especially for on-device personalized models or federated learning \cite{hard2018federated}.
\section{Experiments}
For understanding and analyzing the performance of re-ranking algorithms, we provide a re-ranking library---\texttt{LibRerank}, which automates the re-ranking experimentation and integrates a major collection of re-ranking algorithms. It is designed to support researchers by simplified access to popular re-ranking algorithms, thereby making experimental results more reproducible.
We conduct benchmarking experiments on two public recommendation datasets, \textbf{Ad}\footnote{https://tianchi.aliyun.com/dataset/dataDetail?dataId=56} and \textbf{PRM Public}\footnote{https://github.com/rank2rec/rerank}. A detailed explanation of the benchmarking experiments, and the processed datasets are also released together with the \texttt{LibRerank} library\footnote{https://github.com/LibRerank-Community/LibRerank}. We use LambdaMART \cite{lambdamart} to produce the initial ranking lists. Baselines include: MiDNN \cite{midnn}, GSF \cite{gsf}, DLCM \cite{dlcm}, PRM \cite{prm}, SetRank \cite{setrank}, and EGRerank \cite{egrerank}. We anticipate adding support for more re-ranking algorithms, including diversity- or fairness-aware ones in the near future.
\smallskip
\noindent
\textbf{Principles.}
For fair comparisons, our implementation follows several principles: (i) To cover every detail in each algorithm, we use the open-sourced implementation if applicable. Otherwise, the algorithms are implemented according to the original paper. (ii) We conduct careful parameter tuning for every algorithm and report the best results.
\subsection{Quantitative Evaluation}
For the quantitative evaluation, we focus on the popular ranking metrics MAP@$k$ and NDCG@$k$, with $k=5,10$ for Ad, $k=10,20$ for PRM Public due to the different re-ranking sizes. The results are reported in Table \ref{tab:overall}, from which we have the following observations.
\noindent
\textit{(i) Effectiveness of Re-ranking.} The first row in Table \ref{tab:overall} shows the performance of the initial ranking, generated in the ranking stage by LambdaMART. The results of all the re-ranking algorithms are appealing and outperform the initial ranker by a large margin. This confirms the necessity of the re-ranking stage in MRS by integrating the listwise context.
\noindent
\textit{(ii) Listwise Context Modeling.} Considering re-ranking algorithms with different listwise context modeling structure, algorithms with self-attention architecture like SetRank and PRM, achieves better results. It is because the self-attention structure effectively encodes the cross-item interactions between any pairs of items.
\noindent
\textit{(iii) Robustness of EG framework.} EGRerank adopts an evaluator-generator (EG) paradigm, but its performance is less impressive. Possible reasons may be that the performance of the generator largely depends on the quality of the evaluator, which is relatively hard to measure and select.
\section{Summary and Future Prospects}
Over the past several years, neural re-ranking has continued to become an inspiring domain, motivated by both scientific challenges and industrial demands. A considerable amount of studies have been conducted, and many of them have already found use in industrial applications. Major advances in this domain are summarized in Fig.~\ref{fig:orgchart}. A review of the re-ranking algorithms with corresponding objectives can be found in Section \ref{sect:acc} and \ref{sect:multiple}. Our benchmarking results manifest the superiority of the neural re-ranking models. Despite the great progress in recent years, we still note that there are some significant challenges and open issues in this domain.
\smallskip
\noindent
\textbf{Sparse Feedback.}
The re-ranking problem is challenging due to the sparse supervised signal, where only the feedback for the displayed lists can be observed---feedback for the other $n!-1$ permutations is unavailable. Evaluators or click models \cite{ncm,cacm,ccm} can be potentially used to generate feedback, but current click models are just trained to fit the offline click data by performance metrics like log-likelihood, without particular designs on how evaluators should be trained to address the data sparsity problem and help improve the training of the re-ranking models.
\smallskip
\noindent
\textbf{Personalization for Diversity/Fairness}.
Personalization is the core of MRS, but recent literature mostly focuses on personalization in accuracy-oriented re-ranking, leaving personalization in diversity and fairness unexplored. Different users have various demands for diversity and fairness.
It is of great potential to involve personalized diversity or fairness.
\smallskip
\noindent
\textbf{Tradeoff between Multiple Objectives.}
Different recommendation scenarios have different degrees of demand for diversity or fairness. Existing studies mainly manage the tradeoff by heuristics or parameter tuning. It could be a promising topic to automatically balance multiple objectives without human intervention.
\smallskip
\noindent
\textbf{Joint Training of MRS.}
Re-ranking models are trained separately, decoupling from other stages in MRS. But the ranking quality of other stages affects the performance of re-ranking \cite{seq2slate}. Utilizing the information learned by other stages (\textit{e.g.}, parameter transfer, gradient transfer) would be of high value for both academia and industry.
\newpage
\bibliographystyle{named}
|
{'timestamp': '2022-02-15T02:41:02', 'yymm': '2202', 'arxiv_id': '2202.06602', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06602'}
|
arxiv
|
\section{Introduction}
\label{introduction}
Reinforcement Learning (RL) offers a great framework for solving sequential decision-making problems using interactions with an environment~\cite{sutton2018reinforcement}. In this context, safety constraint satisfaction and robustness are vital properties for successful deployment of RL algorithms. Safe RL has received a significant attention in recent years, but many unsolved challenges remain, e.g., constraint satisfaction during and after training, efficient algorithms etc. While different types of constraints were considered in the past, e.g. averaged over trajectory, CVaR and chance constraints~\cite{chow2017risk}, satisfying constraints almost surely (or with probability one) received less attention to date. This problem is quite important as many safety critical applications require constraint satisfaction almost surely. For example, we ideally would like to guarantee safe plane landing and take-off with probability one, while landing with probability $0.99$ may not be sufficient. Similarly, an autonomous vehicle should be able to stay in the lane with probability one, while keeping this constraint ``on average'' can potentially lead to catastrophic consequences.
We represent the safety constraints as a (discounted) sum of nonnegative costs bounded from above by (what we call) \emph{a safety budget}. As the safety costs are accumulated during an episode, there is less freedom in choosing a safe trajectory and hence the available safety budget diminishes over time. In fact, we can treat the remaining safety budget as a new state quantifying the risk of constraint violation. This idea can be traced back to classical control methods of augmenting the safety constraints into the state-space~cf.~\cite{daryin2005nonlinear}, however, we adapt it to stochastic problems and RL applications. First, we reshape the objective to take into account the remaining safety budget by assigning infinite values if the budget was spent. Thus we obtain Safety AUgmenTEd (SAUTE) Markov Decision Process (MDP). Incorporating the constraint into the objective enforces this constraint for every controlled trajectory which leads to constraint satisfaction with probability one. Furthermore, Saute MDP satisfies Bellman equation justifying the use of \emph{any critic-based RL method}. Finally, since the value functions now additionally depend on the safety information, the cost-to-go in our setting implicitly includes information about possible safety constraint violations.
Employing the state augmentation for safe RL has been explored in the past. For example,~\cite{calvo2021state} augmented the Lagrangian multiplier into the state space, while keeping the Lagrangian objective. The Lagrangian multiplier contains the information about the safety cost that could be exploited by the policy. We argue that such a construction is not required as we can track the accumulated safety cost instead. \cite{chow2017risk} augmented the CVaR constraint in the state-space, however, their augmentation had a realization suitable only for the CVaR constraint. They also had to resort to the Lagrangian approach for solving the problem due to (again) the specificity of the CVaR constraint. We discuss in detail these state augmentation methods in Appendix~\ref{app:state_augmentation}, but note that \cite{calvo2021state}, \cite{chow2017risk} have not extended their methods to modern model-free and model-based RL methods such as trust region policy optimization (TRPO)~\cite{schulman2015trust}, proximal policy optimization (PPO)~\cite{schulman2017proximal}, soft actor critic (SAC)~\cite{haarnoja2018soft}, model-based policy optimization (MBPO)~\cite{janner2019trust}, probabilistic ensembles with trajectory sampling (PETS)~\cite{chua2018deep}.
We argue that our state augmentation approach allows viewing the safe RL problem from a different angle. In fact, our state augmentation should be seen as a modification of an environment rather than an RL algorithm. It is implemented as a wrapper around OpenAI gym~\cite{brockman2016openai} environments, which allows ``sauteing'' \emph{any} RL algorithm. While we mostly test with model-free approaches (PPO, TRPO, SAC), the model-based methods are also ``sauteable'', which we illustrate on MBPO and PETS. We then demonstrate that a policy trained on one safety budget can generalize to other budgets. Further, if we randomly sample the initial safety state (i.e., the safety budget), then we can learn a policy \emph{for all safety budgets} in a set.
\textbf{Related work.} Safe RL is based on the constrained MDP (c-MDP) formalism~\cite{altman1999constrained}, which has spawned many directions of research. A topic of a considerable interest is safe exploration~\cite{turchetta2016safe, koller2018learning, dalal2018safe, wachi2018safe, zimmer2018safe, bharadhwaj2020conservative}, where the goal is to ensure constraint satisfaction while exploring for policy improvement. Another line of research is to use classical control methods and concepts in order to learn a safe policy~\cite{chow2018lyapunov, chow2019lyapunov, berkenkamp2017safe, ohnishi2019barrier, cheng2019end, akametalu2014reachability, deanlqr2019, Fisac2019}. In these works, the authors also make strong prior assumptions such as partial knowledge of the model, initial safe policy in order to define a problem that can be solved. Besides classical control other tools were used in safe RL, e.g., a two-player framework with task agent and safety agent cooperating to solve the task~\cite{mguni2021desta}, a curriculum learning approach, where the teacher resets the student violating safety constraints~\cite{turchetta2020safe}, learning to reset if the safety constraint is violated~\cite{eysenbach2018leave}.
While these are interesting topics of research, the classical RL setting with minimal assumptions is arguably more common in RL literature. A considerable effort was made in solving safe RL in the model-based setting~\cite{polymenakos2020safepilco, cowen2020samba, kamthe2018data}. In these works the model was learned using Gaussian processes~\cite{GPbook, deisenroth2011pilco} allowing for an effective uncertainty estimation albeit with scalability limitations. Constrained versions of model-free RL algorithms such as TRPO, PPO, SAC were also developed. For example, CPO~\cite{achiam2017constrained} generalized TRPO to a constrained case by explicitly adding constraints to the trust region update. \cite{raybenchmarking} were the first, to our best knowledge, to implement Lagrangian version of PPO, SAC and TRPO. These methods largely followed~\cite{chow2017risk}, who, however, considered an RL problem with a conditional-value-at risk (CVaR) constraints instead of average constraints. While Chow et al used classical policy gradient algorithms, recently this work was extended to PPO~\cite{cowen2020samba} and SAC~\cite{yang2021wcsac} algorithms. Finally, \cite{ding2020natural} proposed a natural policy gradient for c-MDPs.
\section{Vanilla RL and Safe RL with Constraints}
We first review basic RL and MDP concepts and adapt some definitions to our setting.
\begin{defn}
We define a Markov Decision Process (MDP) as a tuple ${\mathcal M} = \langle \cS, {\mathcal A}, \cP, c, \gamma_c \rangle$, where $\cS$ is the state space; ${\mathcal A}$ is the action space; $\gamma_c \in (0, 1)$ is the task discount factor, $\cP: \cS \times {\mathcal A} \times \cS \rightarrow [0, 1]$, i.e., ${\bm s}_{t+1} \sim p(\cdot | {\bm s}_t , {\bm a}_t)$, and $c:\cS \times {\mathcal A} \rightarrow [0, +\infty)$ is the task cost. We associate the following optimization problem with the MDP:
\begin{equation}\label{prob:vanilla_mdp}
\begin{aligned}
\min\limits_{\pi}~ \mathbb{E}^\pi_{\bm s} J_{\rm task},\,\, J_{\rm task}\triangleq \sum\limits_{t=0}^\infty \gamma_c^t c({\bm s}_t, {\bm a}_t),
\end{aligned}
\end{equation}
where ${\bm a}_t \sim \pi$, $\mathbb{E}^\pi_{\bm s}$ is the mean over the transitions and the policy $\pi$.
\end{defn}
The objective $J_{\rm task}$ implicitly depends on the initial state ${\bm s}_0$ distribution and the policy $\pi$, but we drop this dependence to simplify notation. Throughout we assume that spaces $\cS$ and ${\mathcal A}$ are continuous, e.g., $\cS\subset\R^{n_s}$ and ${\mathcal A}\subset\R^{n_a}$, where $n_s$ and $n_a$ are the dimensions of the state and action spaces.
We consider an infinite-horizon problem for theoretical convenience, in practice, however, we use the finite horizon (or episodes) setting as common in the RL literature~\cite{sutton2018reinforcement}. We also minimize the objective adapting the notation by~\cite{chow2017risk}. In order to solve the problem, the value functions are typically introduced:
\begin{equation*}
\begin{aligned}
V(\pi, {\bm s}_0) = \mathbb{E}^\pi_{\bm s} J_{\rm task}, \qquad
V^\ast({\bm s}) = \min\limits_{\pi} V(\pi, {\bm s}),
\end{aligned}
\end{equation*}
where with a slight abuse of notation $\mathbb{E}^\pi_{\bm s}$ is not averaging over the initial state ${\bm s}_0$. In general, finding the representation of the optimal policy is not easy and the optimal policy can depend on the past trajectory. Remarkably, under some mild assumptions (see Appendix~\ref{app:theory}) the optimal policy solving Problem~\ref{prob:vanilla_mdp} depends only on the current state, i.e., ${\bm a}_t \sim \pi(\cdot | {\bm s}_t)$. This is a consequence of the Bellman equation which holds for the optimal value function $V^\ast_{\rm task}$:
\begin{equation*}
V^\ast_{\rm task}({\bm s}) = \min\limits_{{\bm a}\in{\mathcal A}} \left(c({\bm s}, {\bm a}) + \gamma_c\mathbb{E}_{{\bm s}'\sim p(\cdot| {\bm s}, {\bm a})} V^\ast_{\rm task}({\bm s}')\right).
\end{equation*}
Additionally, using the Bellman equation we can also reduce the cost-to-go estimation to a static optimization rather than dynamic\footnote{There are still some non-stationary components in learning the value functions, since the new data is constantly acquired}. Both of these properties are at the heart of all RL algorithms. Now we can move on to constrained MDPs.
\begin{defn}\label{defn:constrained_mdp}
The constrained MDP (c-MDP) is a tuple ${\mathcal M}_c = \langle \cS, {\mathcal A}, \cP, c, \gamma_c, l, \gamma_l \rangle$ where additional terms are the safety cost $l:\cS \times {\mathcal A} \rightarrow [0, +\infty)$ and the safety discount factor $\gamma_l \in(0, 1)$. The associated optimization problem is:
\begin{subequations}
\begin{align}
\min\limits_{\pi}~&\mathbb{E}^\pi_{\bm s} J_{\rm task}
\label{prob:average_objective}\\
\text{s. t.: }&\mathbb{E}^\pi_{\bm s} J_{\rm safety}\ge 0,\,\, J_{\rm safety} \triangleq d - \sum\limits_{t=0}^\infty \gamma_{l}^t l({\bm s}_t, {\bm a}_t). \label{prob:average_constraint}
\end{align}\label{prob:average_constrained_mdp}
\end{subequations}
We will refer to the nonnegative value $d$ as \emph{the safety budget}.
\end{defn}
The average over the accumulated cost can be replaced by another statistic. For example, \cite{chow2017risk} proposed to use conditional value at risk $\textrm{CVaR}_\alpha(X) = \min\limits_{\nu \in \R} \left(\eta + \frac{1}{1-\alpha} \mathbb{E}~\textrm{ReLU}( X - \nu) \right)$ for $\alpha\in(0,1)$:
\begin{equation*}
\begin{aligned}
&\min\limits_{\pi, \nu}~\mathbb{E}^\pi_{\bm s} J_{\rm task},\\
&\text{s. t.: }\nu + \frac{1}{1-\alpha}\mathbb{E}^\pi_{\bm s} ~\textrm{ReLU}\left(d- J_{\rm safety} - \nu\right) \le d.
\end{aligned}
\end{equation*}
In both cases, the problem can be solved using the Lagrangian approach, cf.~\cite{chow2017risk}. For example, in the case of Problem~\ref{prob:average_constrained_mdp} we can rewrite this problem as
\begin{equation*}
\begin{aligned}
\min\limits_\pi &~~\mathbb{E}^\pi_{\bm s} J_{\rm task} - \lambda^\ast \mathbb{E}^\pi_{\bm s} J_{\rm safety}, \text{ where}\\
\lambda^\ast &= \begin{cases}
0 & \text{ if } \mathbb{E}^\pi_{\bm s} J_{\rm safety} \ge 0,\\
+\infty & \text{ if } \mathbb{E}^\pi_{\bm s} J_{\rm safety} < 0.
\end{cases}
\end{aligned}
\end{equation*}
Instead, of optimizing over an indicator $\lambda^\ast$, one instead formulates an equivalent min-max problem~\cite{bertsekas1997nonlinear}:
\[
\min_{\pi} \max\limits_{\lambda \ge 0} \widehat J \triangleq \mathbb{E}^\pi_{\bm s} J_{\rm task} - \lambda \mathbb{E}^\pi_{\bm s} J_{\rm safety}.
\]
Indeed, for every fixed policy $\pi$, the optimal $\lambda$ is equal to $\lambda^\ast$: if $\mathbb{E}^\pi_{\bm s} J_{\rm safety}$ is nonnegative then there is no other choice but setting $\lambda$ to zero, if the $\mathbb{E}^\pi_{\bm s} J_{\rm safety}$ is negative then maximum over $\lambda$ is $+\infty$~cf.~\cite{bertsekas1997nonlinear}. Thus we obtained the Lagrangian formulation of c-MDP. Now for actor-critic algorithms we need to estimate an additional value function $V_{\rm safety}(\pi, {\bm s}_0) = \mathbb{E}^\pi_{\bm s} J_{\rm safety}$ tracking the safety cost.
Note that it is not clear if the optimal policy can be found using the commonly used representation ${\bm a}_t \sim \pi(\cdot | {\bm s}_t)$, since it is not clear what is the equivalent of the Bellman equation in the constrained case. Hence, the policy representation ${\bm a}_t \sim \pi(\cdot | {\bm s}_t)$ can create some limitations. Even intuitively the actions should depend on the safety constraint in some way, but they do not.
\section{Saute RL: Safety AUgmenTEd Reinforcement Learning}
\subsection{Main Idea in the Deterministic Case} \label{sec:main_idea}
Let us consider a c-MDP with deterministic transitions, costs and one constraint:
\begin{subequations}\label{prob:cmdp_det}
\begin{align}
\min\limits_{\pi}~&J_{\rm task}, \label{objective:cmdp_det}\\
\text{s. t.: }& J_{\rm safety}\ge 0.\label{constraint:cmdp_det}
\end{align}
\end{subequations}
and its Lagrangian formulation
\begin{equation}\label{prob:cmdp_lagrangian_det}
\min_{\pi} \max\limits_{\lambda \ge 0} \widehat J \triangleq J_{\rm task} - \lambda J_{\rm safety}.
\end{equation}
Inspired by the ideas from~\cite{daryin2005nonlinear} we adapt it to the RL case, we propose to reduce the problem to an MDP. In particular, we remove the constraint by reshaping the cost and using state augmentation. Let us take a step back and note that enforcing Constraint~\ref{constraint:cmdp_det} is equivalent to enforcing the infinite number of the following constraints:
\begin{equation}\tag{\ref{prob:cmdp_det}b$^\ast$}
\sum\limits_{k=0}^t \gamma_{l}^k l({\bm s}_k, {\bm a}_k) \le d, \,\,\forall t\ge 0.
\end{equation}
This is because we assumed that the instantaneous cost is nonnegative and the accumulated safety cost cannot decrease. Therefore, if the constraint is violated at some time $t_v$, it will be violated for all $t \ge t_v$. It seems counter-intuitive to transform one constraint into the infinite number of constraints. However, our goal here is to incorporate the constraints into the instantaneous task cost, thus taking into account safety while solving the task. The quantity ${\bm w}_t = d - \sum_{m=0}^t \gamma_l^m l({\bm s}_m, {\bm a}_m)$ is the remaining safety budget, which can easily be tracked in order to assess constraint satisfaction. We will track, however, the variable ${\bm z}_{t} = {\bm w}_{t-1}/\gamma_l^{t}$, which has a time-independent update:
\begin{equation*}
{\bm z}_{t+1} =
({\bm w}_{t-1} - \gamma_l^t l({\bm s}_t, {\bm a}_t))/ \gamma_l^{t+1} =
({\bm z}_t - l({\bm s}_t, {\bm a}_t) )/ \gamma_l,
\end{equation*}
and ${\bm z}_0 = d$. Since the variable ${\bm z}_t$ is Markovian (i.e., ${\bm z}_{t+1}$ depends only on ${\bm z}_t$, ${\bm a}_t$ and ${\bm s}_t$), we can augment our state-space with the variable ${\bm z}_t$. Now since we enforce the constraint ${\bm z}_t \ge 0$ for all times $t\ge 0$, we can reshape the instantaneous task cost to account for the safety constraint:
\begin{equation*}
\begin{aligned}
\widetilde c({\bm s}_t,{\bm z}_t, {\bm a}_t) =
\begin{cases}
c({\bm s}_t, {\bm a}_t) & {\bm z}_t \ge 0, \\
+\infty & {\bm z}_t <0.
\end{cases}
\end{aligned}
\end{equation*}
Now we can formulate the problem \emph{without} constraints
\begin{equation}\label{prob:augmented_mdp}
\min\limits_{\pi}~\sum\limits_{t=0}^\infty \gamma_c^t \widetilde c({\bm s}_t, {\bm z}_t, {\bm a}_t).
\end{equation}
Note that the safety cost $l$, the safety discount factor $\gamma_l$ are now part of the transition. The variable ${\bm z}_t$ can be intuitively understood as a risk indicator for constraint violation. The policy can learn to tread carefully for some values of ${\bm z}_t$ thus learning to interpret ${\bm z}_t$ as the distance to constraint violation. Note that the augmented state by~\cite{chow2017risk} tracks a value related to the CVaR computation rather than the remaining safety budget (see Appendix~\ref{app:state_augmentation_chow}), while the augmented state by~\cite{calvo2021state} is the Lagrange multiplier (see Appendix~\ref{app:state_augmentation_calvo}). In both cases, the augmented state by itself is not a very intuitive risk indicator for safety during an episode. Furthermore, in our case the safety budget $d$ is the initial safety state, which enables generalization across safety budgets as we show in our experiments. This was not done by~\cite{calvo2021state} and~\cite{chow2017risk}.
To summarize, we have effectively showed the following:
\begin{thm} \label{thm:determinstic_equivalence}
An optimal policy for any of Problems~\ref{prob:cmdp_det},~\ref{prob:cmdp_lagrangian_det} and~\ref{prob:augmented_mdp} is also an optimal policy for all of these problems.
\end{thm}
Next we discuss how to deal with the infinity in the cost function and we generalize this idea to the stochastic case.
\subsection{Safety Augmented Markov Decision Processes}
In the general case, we also derive as above the following transition functions:
\begin{equation}
\begin{aligned}
{\bm s}_{t+1} &\sim p(\cdot | {\bm s}_t , {\bm a}_t), &&{\bm s}_0 \sim {\cal S}_0, \\
{\bm z}_{t+1} &= ({\bm z}_t - l({\bm s}_t, {\bm a}_t))/ \gamma_l, &&{\bm z}_0 = d.
\end{aligned}\label{eq:augmented_mdp}
\end{equation}
As the cost $\widetilde c({\bm s}_t, {\bm z}_t, {\bm a}_t)$ can take infinite values, we introduce a computationally friendlier cost:
\begin{equation}
\widetilde c_n({\bm s}_t,{\bm z}_t, {\bm a}_t) =
\begin{cases}
c({\bm s}_t, {\bm a}_t) & {\bm z}_t \ge 0, \\
n & {\bm z}_t <0.
\end{cases}
\label{eq:bounded_augmented_reward}
\end{equation}
and introduce the Safety AUgmenTEd (Saute) MDP $\widetilde {\mathcal M}_n$.
\begin{defn}
Given a c-MDP ${\mathcal M}_c = \langle \cS, {\mathcal A},\cP, c, \gamma_c \rangle$, we define a Safety Augmented Markov Decision Process (Saute MDP) as a tuple $\widetilde {\mathcal M}_n = \langle \widetilde \cS, {\mathcal A}, \widetilde\cP, \widetilde c_n, \gamma_c, \gamma_l \rangle$, where $\widetilde \cS = \cS\times {\mathcal Z}$;
$\widetilde\cP: \widetilde\cS \times {\mathcal A} \times \widetilde\cS \rightarrow [0, 1]$ and defined in Equation~\ref{eq:augmented_mdp}, and
$\widetilde c_n:\widetilde\cS \times {\mathcal A} \rightarrow [0,+\infty)$. We associate the following problem with Saute MDP:
\begin{equation}\label{prob:saute_mdp}
\min\limits_{\pi}~ \mathbb{E} \sum\limits_{t=0}^\infty \gamma_c^t \widetilde c_n({\bm s}_t, {\bm z}_t, {\bm a}_t).
\end{equation}
\end{defn}
While the costs $\widetilde c_n$ converge monotonically to $\widetilde c_\infty \triangleq \widetilde c$ (i.e., for all ${\bm s}$, ${\bm z}$, ${\bm a}$ $\widetilde c_n({\bm s}, {\bm z}, {\bm a}) \uparrow \widetilde c_\infty({\bm s}, {\bm z}, {\bm a})$), the optimal policies of $\widetilde {\mathcal M}_n$ do not necessarily converge to the optimal policies of $\widetilde {\mathcal M}_\infty$. Therefore, we need to answer two questions: a) what is the optimal representation of $\pi_n^\ast$; b) what is the relation of the MDPs $\widetilde {\mathcal M}_n$ and $\widetilde {\mathcal M}_\infty$. In order to do so we make the following assumptions:\\
\textbf{A1.} The functions $\widetilde c_n({\bm s}, {\bm z}, {\bm a})$ are bounded, measurable, nonnegative, and lower semi-continuous on $\widetilde\cS \times {\mathcal A}$;\\
\textbf{A2.} ${\mathcal A}$ is compact;\\
\textbf{A3.} The transition $\cP$ is weakly continuous on $\widetilde \cS\times{\mathcal A}$, i.e., for any continuous and bounded function $u$ on $\widetilde\cS$ the map $({\bm s},{\bm z}, {\bm a}) \rightarrow \int_{\widetilde \cS}u({\bm x},{\bm y}) \cP(d{\bm x}, d{\bm y}| {\bm s},{\bm z}, {\bm a})$ is continuous
These assumptions are rather mild and satisfied in many RL tasks.
Assumption A3, for example, is satisfied, if the transition function $\cP$ is a Gaussian with continuous mean and variance (cf.~\cite{arapostathis1993discrete}). We delegate the proof of the following theorem to Appendix~\ref{app:theory}.
\begin{thm} \label{thm:optimal_policy} Consider
a Saute MDP $\widetilde {\mathcal M}_n$ satisfying Assumptions A1-A3 with the associated Problem~\ref{prob:saute_mdp}, then:
a) for any finite $n$ the Bellman equation is satisfied, i.e., there exists a function $V_n^\ast({\bm s}, {\bm z})$ such that
\begin{equation*}
V_n^\ast({\bm s}, {\bm z}) = \min\limits_{{\bm a} \in {\mathcal A}}\left(\widetilde c_n({\bm s}, {\bm z}, {\bm a}) + \gamma_c \mathbb{E}_{{\bm s}',{\bm z}'} V_n^\ast({\bm s}', {\bm z}') \right),
\end{equation*}
where ${\bm s}',{\bm z}'\sim \widetilde p(\cdot|{\bm s},{\bm z}, {\bm a})$. Furthermore, the optimal policy solving $\widetilde {\mathcal M}_n$ has the representation ${\bm a} \sim \pi_n^\ast(\cdot | {\bm s}, {\bm z})$;
b) the optimal value functions $V_n^\ast$ for $\widetilde{\mathcal M}_n$ converge monotonically to $V_\infty^\ast$ --- the optimal value function for $\widetilde{\mathcal M}_\infty$.
\end{thm}
The practical implication of our theoretical result is three-fold: a) we can use critic-based methods and guarantee their convergence under standard assumptions, b) the optimal policy is Markovian and depends on the safety budget, i.e., ${\bm a} \sim \pi_n^\ast(\cdot | {\bm s}, {\bm z})$, and c) vanilla RL methods can be applied to solve $\widetilde {\mathcal M}_n$. We finally stress that we can solve $\widetilde {\mathcal M}_\infty$ only approximately by solving $\widetilde {\mathcal M}_n$ for a large enough $n$.
\subsection{Almost Surely Safe Markov Decision Processes}
We now ready to introduce our formulation for almost surely safe reinforcement learning.
\begin{defn} An \emph{almost surely constrained MDP} is a c-MDP ${\mathcal M}_c$ with the associated optimization problem:
\begin{subequations}
\begin{align}
\min\limits_{\pi(\cdot| {\bm s}_t, {\bm z}_t)}~&\mathbb{E} J_{\rm task},\\
\text{s.t.: }&{\bm z}_t \ge 0~~a.s.,~\forall t\ge 0, \label{con:as_safety}\\
& {\bm z}_{t+1} = ({\bm z}_t - l({\bm s}_t, {\bm a}_t)) / \gamma_l, {\bm z}_0 = d,
\end{align}\label{prob:as_constrained_mdp}
\end{subequations}
where \text{a.s.} stands for ``almost surely'' (i.e., with probability one).
\end{defn}
Solving this problem using RL should deliver almost surely safe policies benefiting safety-critical applications. This formulation is much stronger than the average and the CVaR constrained ones. Solving Saute MDP $\widetilde {\mathcal M}_\infty$ is equivalent to solving Problem~\ref{prob:as_constrained_mdp} in the following sense:
\begin{thm} \label{thm:AlmostSureSafeRL}
Consider a Saute MDP $\widetilde {\mathcal M}_\infty$ and Problem~\ref{prob:saute_mdp}. Suppose there exists an optimal policy $\pi^\ast(\cdot| {\bm s}_t, {\bm z}_t)$ solving Problem~\ref{prob:saute_mdp} with a finite cost, then $\pi^\ast(\cdot| {\bm s}_t, {\bm z}_t)$ is an optimal policy for Problem~\ref{prob:as_constrained_mdp}.
\end{thm}
\begin{proof}
The finite cost in $\widetilde {\mathcal M}_\infty$ implies the satisfaction of Constraint~\ref{con:as_safety} almost surely. Now since the policy $\pi^\ast$ was obtained by minimizing the same objective as in Problem~\ref{prob:as_constrained_mdp} and satisfies Constraint~\ref{con:as_safety} almost surely, it also minimizes the objective in Problem~\ref{prob:as_constrained_mdp}.
\end{proof}
\section{Experiments}
\textbf{Implementation.} The main benefit of our approach to safe RL is the ability to ``saute'' \emph{any RL algorithm}. This is because we do not need to change the algorithm itself (besides some cosmetic changes), but create a wrapper around the environment. The implementation is quite straightforward and the only ``trick'' we used is normalizing the safety state by dividing it with the safety budget:
\begin{equation*}
{\bm z}_{t+1} = ({\bm z}_t - l({\bm s}_t, {\bm a}_t) / d) / \gamma_l, {\bm z}_0 = 1.
\end{equation*}
Hence the variable ${\bm z}_t$ is always between zero and one. The reset and step functions have to be overloaded in order to augment the safety state and shape the cost as in Equation~\ref{eq:bounded_augmented_reward}. More details on ``sauteed'' environment implementation are available in Appendix~\ref{app:detailed_implementation_details}. We used safety starter agents~\cite{raybenchmarking} as the core implementation for model-free methods, their Lagrangian versions (PPO, TRPO, SAC) and CPO. We use the hyper-parameters listed in Appendix~\ref{app:default_hyperparameters}. For our model-based implementations we used \cite{Pineda2021MBRL} as the core library, which has PyTorch implementation of MBPO~\cite{janner2019trust}, and PETS~\cite{chua2018deep}.
\begin{figure}[ht]
\centering
\begin{subfigure}[b]{0.25\columnwidth}
\centering
\includegraphics[width=0.99\textwidth]{figures/envs/safe_pendulum.pdf}
\caption{Safe single pendulum.}
\label{mt_fig:safe_pendulum}
\end{subfigure}~~~
\begin{subfigure}[b]{0.25\columnwidth}
\centering
\includegraphics[width=0.99\textwidth]{figures/envs/safe_double_pendulum.pdf}
\caption{Safe double pendulum}
\label{mt_fig:safe_double_pendulum}
\end{subfigure}
\vspace{0.1mm}
\begin{subfigure}[b]{0.25\columnwidth}
\centering
\includegraphics[width=0.99\textwidth]{figures/envs/safe_reacher.pdf}
\caption{Safe fetch reacher}
\label{mt_fig:safe_fetch_reacher}
\end{subfigure}~~~
\begin{subfigure}[b]{0.25\columnwidth}
\centering
\includegraphics[width=0.99\textwidth]{figures/envs/safety_gym.pdf}
\caption{Safety gym}
\label{mt_fig:static_env_gym}
\end{subfigure}
\caption{Panels a and b: safe pendulum environments. In both cases, $\theta$ - is the angle from the upright position, $a$ is the action, $\delta$ - is the unsafe pendulum angle, the safety cost is the distance toward the unsafe pendulum angle, which is incurred only in the red area. Panel e: safe fetch reacher: robot needs to avoid the unsafe region (in red). Panel d: a safety gym environment: robot needs to reach the goal (in green) while avoiding the unsafe region (in blue).}
\label{mt_fig:envs}
\end{figure}
\textbf{Environments.} We demonstrate the advantages and the limitations of our approach on three OpenAI gym environments with safety constraints (single pendulum swing-up, double pendulum balancing, reacher) and the OpenAI safety gym environment (schematically depicted in Figure~\ref{mt_fig:envs}). In the environment design we follow previous work by~\cite{kamthe2018data},~\cite{cowen2020samba},~\cite{yang2021wcsac} and delegate the details to Appendix~\ref{app:environments}.
\begin{figure*}[ht!]
\centering
\begin{subfigure}[b]{0.29\textwidth}
\centering
\includegraphics[width=0.99\textwidth]{figures/boxplots/ppo_box_single.pdf}
\caption{PPO}
\label{mt_fig:ppo_single}
\end{subfigure}
\begin{subfigure}[b]{0.29\textwidth}
\centering
\includegraphics[width=0.99\textwidth]{figures/boxplots/sac_box_single.pdf}
\caption{SAC}
\label{mt_fig:sac_single}
\end{subfigure}
\begin{subfigure}[b]{0.39\textwidth}
\centering
\includegraphics[width=0.99\textwidth]{figures/boxplots/trpo_box_single.pdf}
\caption{TRPO}
\label{mt_fig:trpo_single}
\end{subfigure}
\caption{Saute RL as a plug-n-play approach. Evaluation results for SAC, PPO and TRPO-type algorithms on pendulum swing-up environment with the safety budget $30$ after 300 epochs of training. In all figures the task cost are divided by $100$ and the safety costs are divided by $30$, hence the dashed lined indicate the safety threshold. In all cases, ``sauteed'' algorithms delivery safe policies with probability one (whiskers do not cross the dashed line and there are no outlier trajectories beyond the dashed line), while Lagrangian methods and CPO have outlier trajectories violating the safety constraints.}
\label{mt_fig:single_pendulum}
\end{figure*}
\textbf{Evaluation protocols.} In all our experiments we used $5$ different seeds, we save the intermediate policies and evaluate them on $100$ different trajectories in all our figures and tables. One exception is evaluation of PETS, for which we used $25$ trajectories. Note that in all the plots we use returns based on the original task costs $c$, not the reshaped task costs $\widetilde c_n$ to evaluate the performance. In all our experiments we set the safety discount factor for Saute RL equal to one, while the safety discount factor for other algorithm varies. We also use box-and-whisker plots with boxes showing median, $q_3$ and $q_1$ quartiles of the distributions ($75$th and $25$th percentiles, respectively), whiskers depicting the error bounds computed as $1.5 (q_3 - q_1)$, as well as outliers, e.g., points lying outside the whisker intervals~ \cite{Waskom2021}. We add black dots to the plots which signify the mean. We use box-and-whisker plots so that we can showcase the outliers and the percentiles, which are important criteria for evaluation of almost surely constraints.
\textbf{Saute RL is an effective plug-n-play approach.} We first demonstrate that Saute RL can be easily applied to both on-policy (PPO, TRPO) and off-policy algorithms (SAC) without significant issues. We run all these algorithms on the pendulum swing-up environment. We test the policies with the initial state sampled around the downright position of the pendulum. The results in Figure~\ref{mt_fig:single_pendulum} indicate that PPO, TRPO and SAC can be effectively ``sauteed'' and deliver policies safe almost surely (i.e., with probability one and all trajectories satisfy the constraint). Note that the difference in behavior for Trust Region based algorithms is the smallest, while Saute SAC delivers the best overall performance. We also present the evaluation during training in Figures~\ref{fig:saute_RL_single},~\ref{fig:trpo_single_pendulum},~\ref{fig:ppo_single_pendulum} and~\ref{fig:sac_single_pendulum} in Appendix.
\begin{figure*}[ht]
\centering
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[width=0.99\textwidth]{figures/boxplots/mbpo_box_single.pdf}
\caption{MBPO}
\label{mt_fig:mbpo}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[width=0.99\textwidth]{figures/boxplots/pets_box_single.pdf}
\caption{PETS}
\label{mt_fig:pets}
\end{subfigure}
\begin{subfigure}[b]{0.48\textwidth}
\centering
\includegraphics[width=0.99\textwidth]{figures/boxplots/trpo_box_double_l.pdf}
\caption{TRPO}
\label{mt_fig:double_pendulum}
\end{subfigure}
\caption{Saute MBRL on the pendulum swing-up environment (Panels a and b) and Saute TRPO on the double pendulum environment (panel c). Box plots for normalized task and safety costs. Panels a and b: The task costs are divided by $100$, while the safety costs by $30$ with $30$ being the safety budget. Panel c: The task costs are divided by $-80$, while the safety costs by $40$ with the safety budget $40$. In all plots dashed lines indicate the safety threshold. }
\label{mt_fig:res}
\end{figure*}
\textbf{Saute Model-Based RL.} We proceed by ``sauteing'' MBRL methods: MBPO and PETS. As the results in Figures~\ref{mt_fig:mbpo} and~\ref{mt_fig:pets} suggest, we lose some performance, but guarantee safety in both cases. Remarkably we could ``saute'' both MPC and policy-based methods without significant issues.
As we have demonstrated the plug-n-play nature of our approach for model-free and model-based methods, in all further experiments we evaluate our method on Trust Region based algorithms only, i.e., Vanilla TRPO, its variants and CPO. We did so because Saute TRPO has a lower gap in performance with Lagrangian TRPO than Saute SAC and Saute PPO have with their Lagrangian versions. However, a fair evaluation against CPO was also appealing.
\textbf{``Safety on average'' can be very unsafe even in the deterministic environments.} While safety on average is less restrictive than safety almost surely, in some situations safety on average can lead to unwanted behaviors. We design the safe double pendulum environment in such a way that task and safety costs are correlated. Hence restricting the safety cost leads to restricting the task cost and forces the Lagrangian algorithm to balance a trade-off between these objectives. Further, the constraints on ``average'' allow Lagrangian TRPO and CPO to learn the policies that prioritize minimizing task costs for some initial states and minimizing safety costs for other initial states. While the constraint is satisfied on average, the distributions of task and safety costs for both CPO and Lagrangian TRPO have a large variance (see Figure~\ref{mt_fig:double_pendulum}). Further, some outliers have similar behavior to the Vanilla TRPO. Saute TRPO on the other hand achieves best overall performance. We plot the evaluation curves during training in Appendix in Figure~\ref{fig:trpo_double_pendulum}.
\begin{figure}[ht]
\centering
\begin{subfigure}[b]{0.45\columnwidth}
\centering
\includegraphics[width=0.99\textwidth]{figures/all_safety_budgets/greedy_returns.pdf}
\caption{Task costs}
\label{mt_fig:ggeneralizing_task_cost}
\end{subfigure}
\begin{subfigure}[b]{0.45\columnwidth}
\centering
\includegraphics[width=0.99\textwidth]{figures/all_safety_budgets/greedy_costs.pdf}
\caption{Safety costs}
\label{mt_fig:generalizing_safety_cost}
\end{subfigure}
\caption{The normalized task and safety costs for generalization across safety budgets. The task costs are divided by $-2 d$, while the safety costs by $d$ with $d$ being the safety budget, hence dashed lines indicate the safety threshold. The \emph{baseline} policies are trained and evaluated on the same safety budges; the \emph{naive} approach trains policies on the safety budget $60$ and the \emph{meta} approach trains policy by sampling the safety budget from the interval $[5,100]$. }
\label{mt_fig:generalizing}
\end{figure}
\textbf{Generalization across safety budgets.} Since the safety budget $d$ enters the problem formulation as the initial value of the safety state, we can generalize to a different safety budget \emph{after training} by changing the initial safety state. We train three separate set of policies for safety budgets $40$, $60$, $80$, we then take the policies trained for the safety budget $60$ and evaluate them on the safety budgets $40$ and $80$. The test results of this \emph{naive} generalization approach over 5 different seeds are depicted in Figure~\ref{mt_fig:generalizing} showing that the naive generalization approach has a similar performance with policies explicitly trained for budgets $40$ and $80$. We further train another set of policies with the initial safety state uniformly sampled from the interval $[5, 100]$. When it comes to safety constraint satisfaction this \emph{meta} approach outperforms the naive approach, which has some outlier trajectories for safety budgets $40$ and $80$ (see Figure~\ref{mt_fig:generalizing}).
\begin{figure}[t]
\centering
\begin{subfigure}[b]{0.45\columnwidth}
\centering
\includegraphics[width=0.99\columnwidth]{figures/abblation/ablation_double.pdf}
\caption{Ablation on components. Double Pendulum}
\label{mt_fig:components_double}
\end{subfigure}
\begin{subfigure}[b]{0.45\columnwidth}
\centering
\includegraphics[width=0.99\columnwidth]{figures/abblation/ablation_single.pdf} \caption{Ablation on components. Single Pendulum}
\label{mt_fig:components_single}
\end{subfigure}
\begin{subfigure}[b]{0.55\columnwidth}
\centering
\includegraphics[width=0.99\columnwidth]{figures/abblation/ablation_cost_shaping.pdf}
\caption{Task cost shaping}
\label{mt_fig:reward_shaping}
\end{subfigure}
\caption{Normalized task and safety costs in ablation studies for Saute TRPO. Panels a and b: ablation on components for double (Panel a) and single (Panel b) pendula. ``no SA'' stands for no state augmentation, ``no CS'' stands for no cost shaping. Panel c: varying values $n$ in reshaped costs $\widetilde c_n$ for the safety budget $d = 40$. In all plots the task costs are divided by $-80$, while the safety costs by $40$, hence dashed lines indicate the safety threshold.} \label{mt_fig:ablation_cost}
\end{figure}
\textbf{Ablation.} Since we have only two main components (cost shaping and state augmentation) our ablation study is rather straightforward. We perform evaluations on the double pendulum environment with the safety budget set to $40$. According to the results in Figure~\ref{mt_fig:components_double} removing cost shaping produce results similar to Vanilla TRPO, which is expected. Removing state augmentation leads to a significant deterioration in task cost minimization and the safety costs are much lower. It appears that the trained policy hedges its bets by not using the whole safety budget, which leads to task cost increase.
Interestingly, in the pendulum swing-up case, removing the state augmentation is not catastrophic, see Figure~\ref{mt_fig:components_single}. This is because we evaluate the policy while sampling the initial states in a close proximity to the same initial position. Hence the safety states are similar at every time for different trajectories. This allows the algorithm without state augmentation to still produce competitive results. This experiment shows that the effect of state augmentation may be easily overlooked.
All the parameters in a ``sauteed'' algorithm are the same as in its ``vanilla'' version except for the parameter $n$ in the cost $\widetilde c_n$. Hence we only need to perform the second ablation with respect to $n$. In all our previous experiments with the double pendulum we set $n=200$, and here we test different values $n$ for the safety budget $40$ and present the evaluation results after $600$ epochs of training in Figure~\ref{mt_fig:reward_shaping}. Increasing $n$ from $0$ to $100$ helps to improve the performance of Saute RL by decreasing number of outliers in safety cost distributions as well as satisfying the cost constraints. However, increasing the value of $n$ to $10000$ and $100000$ leads to additional outliers in safety and task cost distributions. We attribute this to numerical issues as the costs $c$ take values between zero and one, and the large value of $n$ can lead to numerical issues in training. We present the numerical values in Table~\ref{tab:reward_shaping} in Appendix.
\begin{figure}[t]
\centering
\begin{subfigure}[b]{0.4\columnwidth}
\centering
\includegraphics[width=0.99\columnwidth]{figures/boxplots/trpo_box_reacher.pdf}
\caption{Reacher}
\label{mt_fig:reacher}
\end{subfigure}
\begin{subfigure}[b]{0.47\columnwidth}
\centering
\includegraphics[width=0.99\columnwidth]{figures/boxplots/trpo_box_point.pdf}
\caption{Safety gym. Point}
\label{mt_fig:safety_gym_point}
\end{subfigure}
\begin{subfigure}[b]{0.47\columnwidth}
\centering
\includegraphics[width=0.99\columnwidth]{figures/boxplots/trpo_box_car.pdf}
\caption{Safety gym. Car}
\label{mt_fig:safety_gym_car}
\end{subfigure}
\caption{Normalized task and safety costs in Reacher and Safety Gym. Panel a: Results for the reacher environment with the safety budget $10$, where the task costs are divided by $-60$, while the safety costs by $10$. Panel b: Results for the safety gym point environment with the safety budget $20$, where the safety costs are divided by $20$. Dashed lines indicate the safety threshold.} \label{mt_fig:boxplots}
\end{figure}
\textbf{Further Experiments}. We then test Saute TRPO on Fetch-Reacher Environment as well as a Safety Gym environment with Car and Point robots. Results in Figure~\ref{mt_fig:reacher} are quite similar to the results on the single and double pendulum environments, where both Lagrangian TRPO and CPO delivered the policies safe on average, but not safe almost surely as Saute TRPO. While the fetch-reacher task is closer in nature to pendula, safety gym is quite a complicated environment. Every environment in the safety gym has dozens of states ($46$ for the point environment and $56$ for the car environment) due to the inclusion of LIDAR measurements. Finally, the instantaneous task costs are shaped so that their values close to zero, which is tailored for TRPO and PPO-like algorithms. This makes our approach a bit harder to use since we reshape the costs. Nevertheless the results in Figure~\ref{mt_fig:safety_gym_point} indicate that Saute RL delivers a safe set of policies with only a few outliers violating the constraints. Most of the trajectories have the same returns as Lagrangian TRPO, but the average task cost is brought down by a few outliers. It appears that in these outlier trajectories the ``sauteed'' policies prioritize safety over task costs. While Lagrangian TRPO and CPO produce on average better task costs, the safety constraints are being violated on a rather regular basis. Note that in our experiments the safety budget is chosen to be the average incurred cost by Vanilla TRPO (i.e., $20$) and neither Lagrangian TRPO nor CPO decrease the variance of the safety cost. While Lagrangian TRPO and CPO lower the average cost, the number of outlier trajectories remains quite high. These experiments showcase the existing trade-offs between different safety problems.
\section{Conclusion}
We presented an approach to safe RL using state augmentation, which we dubbed Saute RL. The key difference of our approach is that we ensure the safety constraints almost surely (with probability one), which is desirable in many applications. We showed that state augmentation is essential in some environments. In deterministic environments having an ``average'' constraint can lead to unwanted effects, when the safety cost is high for some initial states and is low for other initial states at the same time satisfying the average constraint. Our approach deals with this case by ensuring that the same constraint is satisfied for all initial states. However, the constraint satisfaction almost surely is a rather strong criterion and in some applications it can be too restrictive. This is, however, a design choice and application dependent, now let us discuss method specific pros and cons.
\textbf{Advantages.} Saute RL has a plug-n-play nature, which allows for straightforward extensions as we demonstrated by sauteing PPO, TRPO and SAC. Furthermore, we can used sauteed environments in the model-based RL setting (MBPO and PETS) as well. We showed that Saute RL generalizes across safety budgets and can learn safe policies for all safety budgets simultaneously. This feature is enabled by the architecture of our state augmentation. Since the remaining safety budget is the initial state, we can randomly sample different safety budgets at the beginning of the episode. At the test time the safety budget could be set in a deterministic fashion to evaluate specific Safe RL problem.
\textbf{Limitations.} ``Sauteing'' an RL algorithm increases the state-space by the number of constraints. Therefore, the dimension of value functions and policy grows and potentially can lead to scalability issues. While this is a common issue in constrained problems, using a Lagrangian approach can be more sample efficient. Since the theoretical sample efficiency estimates usually depend on the number of states~\cite{mania2018simple}, it would be interesting to find means to counteract this loss of efficiency.
Saute RL does not currently address the problem of constraint violation during training, which is still a major problem in safe RL. However, the combination of Saute RL and methods for addressing such problem could be an interesting direction of future work as well. After all the cost-to-go in Saute RL does incorporate potential safety violations and this information can potentially be used for safe training.
\textbf{Future Work.} Besides addressing the limitations, it would be interesting to extend our approach to model-based algorithms applicable to high-dimensional systems including PlaNet~\cite{hafner2019dream}, Dreamer~\cite{hafner2019dream}, Stochastic Latent Actor Critic~\cite{lee2020stochastic} etc.
\bibliographystyle{plain}
|
{'timestamp': '2022-02-17T02:18:20', 'yymm': '2202', 'arxiv_id': '2202.06558', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06558'}
|
arxiv
|
\section{Background}\label{s:background}
\subsection{Recurrent Neural Networks}\label{s:rnn_networks}
A Recurrent Neural Network (RNN) is a state-of-the-art machine learning approach that
has achieved tremendous success in applications such as machine translation or video
description. The key characteristic of RNNs is that they include
loops, a.k.a. recurrent connections, that allow the information to persist from one time-step
of execution to the next ones and, hence, they have the potential to use unbounded
context information (i.e. past or future) to make predictions. Another important
feature is that RNNs are recurrently executed for every element of the
input sequence and, thus, they are able to handle input and output with
variable length. Because of these characteristics, RNNs provide an effective
framework for sequence-to-sequence applications (e.g. machine translation), where they
outperform feed forward Deep Neural Networks (DNNs)~\cite{greff2016lstm, schuster1997bidirectional}.
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/LSTM_Cell.pdf}
\caption{Structure of a LSTM cell. $\odot$ denotes an element-wise
multiplication of two vectors. $\phi$ denotes the hyperbolic
tangent.}
\label{f:lstm_cell}
\end{figure}
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/GRU_Cell.pdf}
\caption{Structure of a GRU cell.}
\label{f:gru_cell}
\end{figure}
Basic RNN architectures can capture and exploit short term dependencies
in the input sequence. However, capturing long term dependencies is challenging
since useful information tend to dilute over time. In order
to exploit long term dependencies, Long Short Term Memory (LSTM)~\cite{hochreiter1997long} and Gated Recurrent Units (GRU)~\cite{cho14Gru} networks
were proposed. These types of RNNs represent the most successful and widely used RNN architectures. They
have achieved tremendous succcess for a variety of applications such as speech
recognition~\cite{miao2015eesen, deepspeech2}, machine translation~\cite{britzGLL17} and video
description~\cite{Vinyals_2015_CVPR}. The next subsections provide further details on
the structure and behavior of these networks.
\subsubsection{Deep RNNs}\label{s:lstm_rnn}
RNNs are composed of multiple layers that are stacked together to create deep RNNs. Each of these layers consists of an LSTM or a GRU cell. In addition, these layers can be unidirectional or bidirectional. Unidirectional layers only use past information to make predictions, whereas bidirectional LSTM or GRU networks use both past and future context.
The input sequence ($X$) is composed of $N$ elements, i.e. $X = [x_1, x_2, ..., x_N]$,
which are processed by an LSTM or GRU cell in the forward direction, i.e. from $x_1$ to $x_N$.
For backward layers in bidirectional RNNs, the input sequence is evaluated in the backward direction,
i.e from $x_N$ to $x_1$.
\subsubsection{LSTM Cell}\label{s:lstm_cell}
Figure~\ref{f:lstm_cell} shows the structure of an LSTM cell. The key component is the
cell state ($c_t$), which is stored in the cell memory. The cell state is updated
by using three fully connected single-layer neural networks, a.k.a. gates. The input gate,
($i_t$, whose computations are shown in Equation~\ref{e:input_gate}) decides how much
of the input information, $x_t$, will be added to the cell state. The forget gate ($f_t$,
shown in Equation~\ref{e:forget_gate}) determines how much information will be erased
from the cell state ($c_{t-1}$). The updater gate ($g_t$, Equation~\ref{e:update_gate})
controls the amount of input information that is being considered a candidate to update the cell state ($c_t$).
Once these three gates are executed, the cell state is updated according to
Equation~\ref{e:cell_state}. Finally, the output gate ($o_t$, Equation~\ref{e:output_gate})
decides the amount of information that will be emitted from the cell to create the output ($h_t$).
Figure~\ref{f:lstm_equations} shows the computations carried out by an LSTM cell.
As it can be seen, a neuron in each gate has two types of connections: forward
connections that operate on $x_t$ and recurrent connections that take as input
$h_{t-1}$. The evaluation of a neuron in one of these gates requires a dot
product between weights in forward connections and $x_t$, and another
dot product between weights in recurrent connections and $h_{t-1}$. Next, a
peephole connection~\cite{gers2000recurrent} and a bias are also applied,
followed by the computation of an activation function, typically
a sigmoid or hyperbolic tangent.
\subsubsection{GRU Cell}\label{s:gru_cell}
Analogous to an LSTM cell, a GRU cell includes gates to control the flow of information inside the cell. However, GRU cells
do not have an independent memory cell (i.e. cell state). As it can be seen in Figure~\ref{f:gru_cell}, in a GRU cell the update gate ($z_t$) controls how much of the candidate information ($g_t$) is used
to update the cell activation. On the other hand, the reset gate ($r_t$) modulates the amount of information that is removed from the previous computed state. Note that GRUs do not include an output gate and, hence, the whole state of
the cell is exposed at each timestep. The computations carried out by each gate in a GRU cell are very similar to those in Equations~\ref{e:input_gate}, ~\ref{e:forget_gate} and ~\ref{e:update_gate}. We omit them for the sake of brevity, the exact details are provided in~\cite{cho14Gru}. For the rest of the paper, we used the term RNN cell to refer to both LSTM and GRU cells.
\begin{figure}[t!]
\centering
\begin{align}
i_t = \sigma(W_{ix} x_t + W_{ih} h_{t-1} + b_i)
\label{e:input_gate}
\end{align}
\begin{align}
f_t = \sigma(W_{fx} x_t + W_{fh} h_{t-1} + b_f)
\label{e:forget_gate}
\end{align}
\begin{align}
g_t = \phi(W_{gx} x_t + W_{gh} h_{t-1} + b_g)
\label{e:update_gate}
\end{align}
\begin{align}
c_t = f_t \odot c_{t-1} + i_t \odot g_t
\label{e:cell_state}
\end{align}
\begin{align}
o_t = \sigma(W_{ox} x_t + W_{oh} h_{t-1} + b_o)
\label{e:output_gate}
\end{align}
\begin{align}
h_t = o_t \odot \phi(c_t)
\label{e:cell_output}
\end{align}
\caption{Computations of an LSTM cell. $\odot$, $\phi$, and $\sigma$ denote element-wise multiplication,
hyperbolic tangent and sigmoid function respectively.}
\label{f:lstm_equations}
\end{figure}
\subsection{Binarized Neural Networks}\label{s:bnn_networks}
State-of-the-art DNNs typically consist of millions of parameters (a.k.a. weights)
represented as floating point numbers using 32 or 16 bits and, hence, their storage
requirements are quite large. Linear quantization may be used to reduce memory
footprint and improve performance \cite{wu2016google, jouppi2017TPU}. In addition,
real-time evaluation of DNNs requires a high energy cost. As an attempt to improve
the energy-efficiency of DNNs, Binarized Neural Networks (BNNs)~\cite{courbariaux2016binarized} or
Bitwise Neural Networks~\cite{kim2016bitwise} are a promising alternative to conventional DNNs. BNNs use one-bit weights and inputs that are constrained to +1 or -1. Typically, the binarization is done using the following function:
\begin{equation}
x^b = \begin{cases}
+1 &\text{if } x>=0, \\
-1 &\text{otherwise, }
\end{cases}
\label{e:x_binarization}
\end{equation}
where $x$ is either a weight or an input and $x^b$ is the binarized value which is stored
as 0 or 1. Regarding the output of a given neuron, its computation is analogous to
conventional DNNs, but employing the binarized version of weights and inputs,
as shown in Equation~\ref{e:binarized_neuron}:
\begin{equation}
y_t^b = \sum w^bx_t^b
\label{e:binarized_neuron}
\end{equation}
where $w^b$ and $x^b_t$ are the binarized weight and input vectors respectively. Note that
evaluating the neuron output ($y_t^b$) only involves multiplications and additions that,
with binarized operands, can be computed with XNORs and integer adders. BNN evaluation
is orders of magnitude more efficient, in terms of both performance and energy, than conventional
DNNs~\cite{courbariaux2016binarized}. Nonetheless, DNNs and RNNs still deliver significantly higher
accuracy than BNNs~\cite{rastegari2016xnor}.
\subsection{Fuzzy Memoization}\label{s:lfuzzy_memoization}
Memoization is a well-known optimization technique used to improve performance
and energy consumption that has been used both in software~\cite{acar2003SM} and hardware~\cite{gonzalezTM99}. In some applications, a given function is executed many times, but the inputs of different executions are not always different. Memoization exploits this fact to avoid these redundant computations by reusing the result of a previous evaluation. In general, the
first time an input is evaluated, the result is cached in a memoization table. Subsequent
evaluations probe the memoization table and reuse previously cached results if the current input matches a previous execution.
In a classical memoization scheme, a memoized value is only reused when it is known to be
equal to the real output of the computation. However, for some applications such as
multimedia~\cite{alvarez2005FMF}, graphics~\cite{arnau2014}, and
neural networks~\cite{Zhang:2015:AAC:2755753.2755913}, this scheme can be extended to tolerate a small loss in accuracy with negligible impact in the quality of the results, and is normally referred to as fuzzy memoization.
\section{Conclusions}\label{s:conclusions}
This paper has shown that 25\% of neurons in an LSTM network change their output value by less than 10\%, which motivated us to propose a fuzzy memoization scheme to
save energy and time. A significant challenge to perform neuron-level fuzzy memoization is to predict accurately, in a simple manner, whether the output of a given neuron will be similar to a previously computed and cached value. To this end, we propose to use a
Binarized Neural Network (BNN) as a predictor, based on the observation that the full-precision output of a neuron is highly correlated with the output of the corresponding
BNN. We show that a BNN predictor achieves 26.7\% computation reuse on average, which is very similar to the results obtained with an Oracle predictor. Moreover, we have shown that including
our technique during the training phase further improves the BNN predictor's accuracy by 4\% or more.
We have implemented our technique on top of E-PUR, a state-of-the-art accelerator for
LSTM networks. Results show that our memoization scheme achieves significant time and energy savings with minimal impact on the accuracy of the RNNs. When compared
with the E-PUR accelerator, our system achieves 21\%
energy savings on average, while providing 1.4x speedup at the expense of a minor
accuracy loss.
\section{Introduction}\label{s:introduction}
Recurrent Neuronal Networks (RNNs) represent the
state-of-the-art solution for many sequence
processing problems such as speech recognition~\cite{6638947}, machine
translation~\cite{wu2016google} or automatic caption generation~\cite{Vinyals_2015_CVPR}.
Not surprisingly, data recently published in~\cite{jouppi2017TPU} show that around
30\% of machine learning workloads in Google's datacenters
are RNNs, whereas Convolutional Neuronal
Networks (CNNs) only represent 5\% of the applications.
Unlike CNNs, RNNs use information
of previously processed inputs to improve
the accuracy of the output, and they
can process variable length input/output sequences.
\begin{figure*}[t!]
\centering
\includegraphics[width=6.5in]{figures/Accuracy_Th.pdf}
\caption{Accuracy loss of different RNNs versus the relative output error
threshold using an oracle predictor. If the difference between the previous
and current output predicted is smaller than the threshold, the memoized output
is employed instead of calculating the new one.}
\label{f:accuracy_th}
\end{figure*}
Although RNN training can be performed efficiently
on GPUs~\cite{appleyard2016optimizing}, RNN inference is more challenging.
The small batch size (just one input sequence per batch)
and the data dependencies in recurrent layers severely constrain
the amount of parallelism. Hardware acceleration
is key for achieving high-performance
and energy-efficient RNN inference and, to this end,
several RNN accelerators have been
recently proposed~\cite{Han:2017:EES:3020078.3021745,lee2016fpga,guan2017fpga,li2015fpga}.
Neurons in an RNN are recurrently executed for processing the
elements in an input sequence. An analysis of the output results reveals
that many neurons produce very similar outputs for
consecutive elements in the input sequence. On average, the relative difference
between the current and previous output of a neuron is smaller than 23\% in our set of
RNNs, whereas previous work in~\cite{riera2018computation} has reported similar results. Since RNNs
are inherently error tolerant~\cite{Zhang:2015:AAC:2755753.2755913},
we propose to exploit the aforementioned property to save computations by using a neuron-level
fuzzy memoization scheme. With this approach, the outputs of a neuron
are dynamically cached in a local memoization buffer. When the next output
is predicted to be extremely similar to the previously computed result,
the neuron's output is read from the memoization buffer rather than
recalculating it, avoiding all the corresponding computations and memory
accesses.
Figure~\ref{f:accuracy_th} shows the potential benefits of this memoization
scheme by using an oracle that accurately predicts the relative difference between
the next output of the neuron and the previous output stored in the memoization
buffer. The memoized value is used when this difference is smaller
than a given threshold, shown in the x-axis of Figure~\ref{f:accuracy_th}.
As it can be seen, the RNNs can tolerate relative errors in the outputs of a
neuron in the range of 30-50\% with a negligible impact on accuracy.
With these thresholds, a memoization scheme with an oracle predictor
can save more than 30\% of the computations.
A key challenge for our memoization scheme is how to predict
the difference between the current output and the previous output
stored in the memoization buffer, without performing all the
corresponding neuron computations. To this end, we propose
to extend each recurrent layer with a
Bitwise Neural Network (BNN)~\cite{kim2016bitwise}. We do this
by reducing each input and weight to one bit that represents the
sign as described in~\cite{courbariaux2016binarized}.
We found that BNN outputs are highly correlated with
the outputs of the original recurrent layer, i.e. a similar
BNN outputs indicates a high likelihood of having
similar RNN output (although BNN outputs are very different to RNN outputs). The BNN is extremely small,
hardware-friendly and very effective at predicting
when memoization can be safely applied.
Note that by simply looking at the inputs, i.e. predicting
that similar inputs will produce similar outputs, might
not be accurate. Small changes in an input that is multiplied
by a large weight will introduce a significant change
in the output of the neuron. Our BNN approach takes into account
both the inputs and the weights.
In short, we propose a neuron-level hardware-based fuzzy
memoization scheme that works as follows. The output of
a neuron in the last execution is dynamically cached
in a memoization table, together with the output of the
corresponding BNN. For every new input in the sequence,
the BNN is first computed and the result is compared with
the BNN output stored in the memoization table. If the
difference between the new BNN output and the cached
output is smaller than a threshold, the neuron's cached output is used as the current output,
avoiding all the associated computations and
memory accesses in the RNN. Otherwise, the neuron is
evaluated and the memoization table is updated.
Note that only using the BNN would result in a large
accuracy loss as reported elsewhere~\cite{rastegari2016xnor}. In this paper, we take a completely
different approach and use the BNN to predict when
memoization can be safely applied with negligible impact
on accuracy. The inexpensive BNN is computed for every
element of the sequence and every neuron, whereas the
large RNN is evaluated on demand as indicated by the BNN.
By doing so, we maintain high accuracy while saving
more than 26.7\% of RNN computations.
In this paper, we make the following contributions:
\begin{itemize}
\item We provide an evaluation of the outputs of neurons in recurrent layers,
and show that they exhibit small changes in consecutive executions.
\item We propose a fuzzy memoization scheme that
avoids more than 26.7\% of neuron evaluations by reusing previously computed
results stored in a memoization buffer.
\item We propose the use of a BNN to determine when memoization
can be applied with small impact on accuracy. We show that BNN
and RNN outputs are highly correlated.
\item We show that the BNN predictor's accuracy improves significantly when it is also included during the training.
\item We implement our neuron-level memoization scheme on top of a
state-of-the-art RNN accelerator. The required hardware introduces
a negligible area overhead, while it provides 1.4x speedup and
21\% energy savings on average for several RNNs.
\end{itemize}
\section*{Acknowledgments}
This work has been supported by the CoCoUnit ERC Advanced Grant of the EU's Horizon 2020 program (grant No 833057), the Spanish State Research Agency (MCIN/AEI) under grant PID2020-113172RB-I00, and the ICREA Academia program.
\bibliographystyle{IEEEtranS}
\section{Evaluation Methodology}\label{s:methodology}
We use a cycle-level simulator of
E-PUR customized to model our scheme as described in Section~\ref{s:binary_memoizing_support}.
This simulator estimates the total energy consumption (static and dynamic) and execution time of
the LSTM networks. The different pipeline components were
implemented in Verilog and we synthesized them using the Synopsys Design Compiler to obtain
their delay and energy consumption. Furthermore, we used a typical process corner with
voltage of 0.78V. We employed CACTI~\cite{muralimanohar2009cacti} to estimate the delay
and energy consumption (static and dynamic) of on-chip memories. Finally, to estimate timing
and energy consumption of main memory we used MICRON's memory model~\cite{Micron}. We model 4 GB of LPDDR4 DRAM.
In order to set the clock frequency, the delays reported by Synopsys
Design Compiler and CACTI are used. We set a clock frequency that allows most hardware
structures to operate at one clock cycle. In addition, we evaluated alternative frequency
values in order to minimize energy consumption.
Regarding the memoization unit, the configuration parameters are shown in
Table~\ref{t:epur_params}. Since E-PUR supports large
LSTM networks, the memoization unit is designed to match the largest models
supported by E-PUR. This unit has a latency of 5 clock cycles for the largest
supported LSTM networks. In this unit, integer and fixed-point operations are
used to perform most computations. The memoization buffer is modeled as 8KiB scratch-pad eDRAM.
The remaining configuration parameters of the accelerator used in our experiments are shown
in Table~\ref{t:epur_params}. We strive
to select an energy-efficient configuration for all the neural networks in Table~\ref{t:lstm_networks}.
Because the baseline accelerator is designed to accommodate large LSTM networks,
some of its on-chip storage and functional units might be oversized for some of our RNNs.
In this case, unused on-chip memories and functional units are power gated when not needed.
As for benchmarks, we use four modern LSTM networks which are described in
Table~\ref{t:lstm_networks}. Our selection includes RNNs for popular application
such as speech recognition, machine translation and image description. These networks have different number of internal layers and neurons. We include both bidirectional (EESEN) and unidirectional networks (the other three).
On the other hand, the length of the input sequence is also different for
each RNN and it ranges from 20 to a few thousand input elements.
The software implementation of the networks was done in Tensorflow~\cite{tensorflow2016}.
We used the network models and the test set provided in~\cite{daiL15a,vinyalsTBE16,miao2015eesen,britzGLL17}
for each RNN. The original accuracy for each RNN is listed in Table~\ref{t:lstm_networks}, and the accuracy loss is later reported as the absolute loss with respect to this baseline accuracy.
\section{Related Work}\label{s:related_work}
Increasing energy-efficiency and performance of LSTM networks has attracted
the attention of the architectural community in recent
years~\cite{Han:2017:EES:3020078.3021745,li2015fpga,guan2017fpga,lee2016fpga}.
Most of these works employ pruning and compression techniques to improve
performance and reduce energy consumption. Furthermore, linear quantization
is employed to decrease the memory footprint. On the contrary, our technique
improves energy-efficiency by relying solely on computation reuse at the neuron
level. To the best of our knowledge, this is the first work using a BNN as a
predictor for a fuzzy memoization scheme. BNNs have been used
previously~\cite{courbariaux2016binarized,rastegari2016xnor,kim2016bitwise}
as standalone networks, whereas we employs BNNs in conjunction
with the LSTM network to evaluate neurons on demand.
Fuzzy memoization has been extensively researched in the past and
has been implemented both in hardware and software. Hardware schemes to
reuse instructions have been proposed in~\cite{sodani1997,alvarez2001PTR,gonzalezTM99,arnau2014}.
Alvarez et al.~\cite{alvarez2005FMF} presented a fuzzy memoization scheme to improve performance of floating point operations
in multimedia applications. In their scheme floating point operations are memoized using a
hash of the source operands, whereas in our technique, a whole function (neuron inference) is memoized
based on the values predicted by a BNN.
Finally, software schemes to memoize entire functions have been presented
in the past~\cite{xu2007dpa,acar2003SM}. These schemes are tailored to general purpose
programs whereas our scheme is solely focused in LSTM networks, since it exploits
the intrinsic error tolerance of LSTM networks.
\section{Experimental Results}\label{s:results}
\begin{figure*}[!t]
\centering
\includegraphics[width=6.5in]{figures/Reuse_Accuracy.pdf}
\caption{Percentage of computations that could be reused versus accuracy loss using Fuzzy Neuron Level Memoization with an Oracle and a Binary Network as predictors for several LSTM networks.}
\label{f:reuse_accuracy}
\end{figure*}
This section presents the evaluation of the proposed fuzzy memoization technique for RNNs, implemented on top of E-PUR~\cite{silfa2017epur}. We refer to it as E-PUR+BM. First, we present the percentage of computation reuse and the accuracy achieved. Second, we show the performance and energy improvements, followed by an analysis of the area overheads of our technique.
Figure~\ref{f:reuse_accuracy} shows the percentage of computation reuse achieved by the BNN and
the Oracle predictors. The percentage of computation reuse indicates the percentage of neuron
evaluations avoided due to fuzzy memoization.
For accuracy losses smaller than 2\%, the BNN obtains a percentage
of computation reuse extremely similar to the Oracle. The networks EESEN and IMDB are highly tolerant
to errors in neuron's outputs, thus, for these networks, our memoization scheme achieves reuse percentages of up to 40\%
while having an accuracy loss smaller than 3\%. Note that, for classification problems,
BNNs achieve an accuracy close to the state-of-the-art~\cite{rastegari2016xnor} and,
hence, it is not surprising that the BNN predictor is highly accurate for approximating
the neuron output.~In the case of the networks DeepSpeech (speech recognition) and NNMT (machine translation), the BNN predictor is also included in the training as discussed in Section~\ref{s:improving_bnn}. For DeepSpeech, the reuse percentage is up to 24\% for
accuracy losses smaller than 2\%. In this network, the input sequence tends to be large
(i.e, 900 elements on average). As the reuse is increased, the error introduced to
the output sequence of a neuron persists for a larger number of elements. Therefore,
the introduced error will have a bigger impact both in the evaluation of the current layer, due
to the recurrent connections, and the following layers. As a result, the overall accuracy
of the network decreases faster.~For MNMT, the BNN predictor and the oracle achieve
similar reuse versus accuracy trade-off for up to 32\% of computation reuse. Note that,
for this network, the linear correlation between the BNN and the full precision neuron
output is typically lower than for the other networks in the benchmark set.
Figure~\ref{f:energy_reuse} shows the energy savings and computation reuse achieved
by our scheme, for different thresholds of accuracy loss.
For a conservative loss of 2\%, the average energy saving is 27.3\%, whereas the reuse
percentage is 33\%. In this case, the networks DeepSpeech and MNMT have energy savings of 19.5\% and 27.6\%, respectively. In contrast, IMDB and EESEN are more tolerant of errors in the neuron output; thus, they exhibit the most considerable savings, 34.2\% and 30\%, respectively. For a highly conservative 1\% of accuracy loss, the computation reuse and energy saving are 26.82\% and 21\% on average, respectively. EESEN and DeepSpeech achieve 25.3\% and 14\% energy savings, respectively, for a 1\% accuracy loss. Regarding the MNMT and IMDB networks, the energy savings for 1\% accuracy loss are 22.2\% and 25\%, respectively.
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/Energy_Reuse.pdf}
\caption{Energy savings and computation reuse of E-PUR+BM with respect to the baseline.}
\label{f:energy_reuse}
\end{figure}
Regarding the sources of energy savings, Figure~\ref{f:energy_breakdown} reports the energy breakdown, including static and dynamic energy, for the baseline accelerator and E-PUR+BM, for an accuracy loss of 1\%. The sources of energy consumption are grouped into on-chip memories ("scratch-pad"
memories), pipeline components ("operations", i.e. multipliers), main memory
(LPDDR4) and the energy consumed by our FMU component. Note that most of the energy consumption
is due to the scratch-pad memories and the pipeline components, and, as it can be seen,
both are reduced when using our memoization scheme. In E-PUR+BM,
each time a value from the memoization buffer is reused, we avoid accessing all the neuron's weights and the input buffers, achieving significant energy savings. Besides, since the extra buffers used by E-PUR+BM are fairly small (i.e., 8 KB), the energy overhead due to the
memoization scheme is negligible. The energy consumption due to the operations is also reduced, as the memoization scheme avoids neuron computations.
Furthermore, the leakage of scratch-pad and operations are also reduced since the memoization scheme decreases the execution time. Finally, the energy consumption due to accessing the main memory is not affected by our technique since both E-PUR and E-PUR+BM must access the main memory to load all the weights once for each input sequence.
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/Energy_Breakdown.pdf}
\caption{Energy breakdown for E-PUR and EPUR+BM. FMU Energy is the overhead due to the memoization scheme.}
\label{f:energy_breakdown}
\end{figure}
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/Time_Reuse.pdf}
\caption{Speedup of E-PUR+BM over the baseline (E-PUR).}
\label{f:time_reuse}
\end{figure}
Figure~\ref{f:time_reuse} shows the performance improvements for the different RNNs. On average,
a speedup of 1.4x is obtained for a 1\% accuracy loss, whereas accuracy losses of 2\% and
3\% achieve improvements of 1.5x and 1.7x, respectively. The performance improvement comes from avoiding the dot product computations for the memoized neurons. Therefore, the larger the
degree of computation reuse, the more significant the performance improvement. Note that the memoization
scheme introduces an overhead of 5 cycles per neuron (see Table~\ref{t:epur_params}) which is mainly due to the evaluation of the binarized neuron. If the full-precision neuron computation is avoided, our scheme saves between 16 and 80 cycles depending on the RNN. Therefore,
configurations with a low degree of computation reuse, like Deepspeech at 1\% accuracy loss,
exhibit more minor speedups due to the memoization scheme's overhead. On the other hand,
RNNs that show higher computation reuse, such as EESEN at 2\% accuracy loss,
achieve a speedup of 1.55x.
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/oracle_vs_bnn.pdf}
\caption{Computation reuse achieved by our BNN-based memoization scheme. BNN+T and BNN refer to our scheme on a model trained with and without memoization, respectively. }
\label{f:reuse_training}
\end{figure}
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/area_break.pdf}
\caption{Area breakdown for E-PUR and EPUR+BM. }
\label{f:area_break}
\end{figure}
Figure~\ref{f:reuse_training} shows the accuracy and computation reuse for the oracle predictor and our memoization scheme using two different configurations. The configuration BNN refers to the evaluation of a trained model without memoization, whereas the configuration BNN+T includes our memoization scheme on the training phase, as explained in Section 7. As shown in Figure~\ref{f:reuse_training}, for the Deepspeech model, the computation reuse is 13.9\% for an accuracy loss of 1\%. Note that the percentage of reuse increases by around 4\%, compared to the implementation that does not include the memoization scheme during training. For the NNMT model, the reuses percentages also increased by 4\% when adding our scheme to the training.
Figure~\ref{f:area_break} shows the area breakdown of E-PUR and E-PUR+BM.
Regarding the area, E-PUR has an area of 64.6 $mm^2$, whereas E-PUR+BM requires 66.8 $mm^2$ (4\% area overhead). As shown in Figure 21, the area for the on-chip memories to store the weights is 69\% and 72\%, for E-PUR and E-PUR+BM, respectively. E+PUR+BM requires an extra 3\% since the on-chip memories for the weights are split into two separate banks: storing the BNN and the other to store the full-precision weights. The computations' area requirements are 2\% and 3\%, for E-PUR and E-PUR+BM, respectively. The overhead due to computations comes from the extra logic added to implement the memoization unit.
\section{Neuron Level Memoization}\label{s:technique}
In this section, we propose a novel memoization scheme to reduce computations
and memory accesses in RNNs. First, we discuss the main
performance and energy bottlenecks on state-of-the-art hardware accelerators
for RNN inference. Next, we introduce the key idea for our
neuron-level fuzzy memoization technique. Finally, we describe the hardware
implementation of our technique.
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/Output_Change.pdf}
\caption{Relative change in neuron output between consecutive input elements. }
\label{f:output_change}
\end{figure}
\subsection{Motivation}
As shown in Figure \ref{f:lstm_equations}, RNN inference involves the evaluation
of multiple single-layer feed-forward neural networks or gates that, from a computational
point of view, consist of multiplying a weight matrix by an input vector ($x_t$ for
forward connections and $h_{t-1}$ for recurrent connections). Typically,
the number of elements in the weight matrices ranges from a few thousands to millions of
elements and, thus, fetching them from on-chip buffers or main memory is one of
the major sources of energy consumption. Not surprisingly, it accounts for up to
80\% of the total energy consumption in state-of-the-art accelerators~\cite{silfa2017epur}.
For this reason, a very effective way of saving energy in RNNs is to avoid
fetching the synaptic weights. In addition, avoiding the corresponding computations also increases
the energy savings. In this work, we leverage fuzzy memoization to selectively avoid neurons
evaluations and, hence, to avoid their corresponding memory
accesses and computations. For fuzzy memoization
to be effective, applications must be tolerant to small errors and its hardware implementation
must be simple. In the next sections, we show that RNNs are resilient to
small errors in the outputs of the neurons, and we provide an efficient
implementation of the memoization scheme that requires simple hardware support.
\begin{figure}[t!]
\begin{equation}
\delta =\left| \frac {y_t^o - y_{m}}{y^o_{t}} \right|
\label{e:delta_error}
\end{equation}
\begin{equation}
y_t = \begin{cases}
y_{m} &\text{if } \delta<=\theta \\
y_t^o &\text{otherwise, }
\end{cases}
\label{e:yt_basic}
\end{equation}
\begin{equation}
y_m = \begin{cases}
y^o_{t} &\text{if } \delta>\theta \\
\text{not updated} &\text{otherwise, }
\end{cases}
\label{e:ym_basic}
\end{equation}
\caption{Neuron Level memoization with Oracle Predictor. $y_t$ is the neuron output. $y_m$ corresponds to the memoized evaluation and $y_t^o$ is the output of the Oracle predictor. $\delta$, $\theta$ are the relative error and the maximum allowed output error respectively.}
\label{f:oracle_memoization}
\end{figure}
\subsubsection{RNNs Redundancy}\label{s:rnn_redundancy}
Memoization schemes rely on a high degree of redundancy in the computations. For RNNs, a key
observation is that the output of a given neuron tends to change lightly between consecutive
input elements. Note that RNNs are used in sequence processing problems such as speech recognition
or video processing, where RNN inputs in consecutive time-steps tend to be extremely similar. Prior work in~\cite{riera2018computation} reports high similarity across consecutive frames of audio or video. Not surprisingly,
our numbers for our set of RNNs also support this claim. Figure~\ref{f:output_change} shows the relative difference between consecutive outputs of a neuron in our set of RNNs. As it can be seen, a neuron's output exhibits minor changes (less than 10\%)
for 25\% of consecutive input elements. On average, consecutive outputs change by 23\%. Furthermore, RNNs can
tolerate small errors in the neuron output~\cite{Zhang:2015:AAC:2755753.2755913}. This observation
is supported by data shown in Figure~\ref{f:accuracy_th}, where the accuracy curve shows the accuracy
loss when the output of a neuron is reused using fuzzy memoization, for different thresholds
(x-axis) that control the aggressiveness of the memoization scheme. For this study,
the relative error ($\delta$) between a predicted neuron output ($y_t^p$) and a previously
cached neuron output ($y_m$) is used as the discriminating factor to decide whether the previous
output is reused, as shown in Figure~\ref{f:oracle_memoization}. To evaluate the potential
benefits of a memoization scheme, the predicted value is provided by an Oracle predictor,
which is 100\% accurate, i.e., its prediction is always equal to the neuron output ($y_t^p = y_t$).
As shown in Figure~\ref{f:accuracy_th}, neurons can
tolerate a relative output error between 0.3 and 0.5 without significantly affecting
the overall network accuracy (i.e., accuracy loss smaller than 1\%). On the other hand, the reuse curve shows the
percentage of neuron computations that could be avoided through this memoization with an
Oracle predictor. Note that by allowing neurons to have an output error between 0.3 to 0.5,
at least 30\% of the total network computations could be avoided.
The memoization scheme must add a small overhead to the system to achieve significant savings. Therefore, the critical challenge is approximating the Oracle predictor's behavior with simple hardware to decide when memoization can be safely applied with a negligible impact on the overall RNN accuracy. We describe an effective solution in the next section.
\subsubsection{Binary Network Correlation}\label{s:bnn_correlation}
A key challenge for an effective fuzzy memoization scheme is to identify when the next
neuron output will be similar to a previously computed (and cached) output. Note that
having similar inputs does not necessarily result in similar outputs, as inputs with
small changes might be multiplied by large weights. Our proposed approach is based on
a Bitwise Neural Network (BNN). In particular, each fully-connected neural
network (NN) is extended to an equivalent BNN, as described in
Section~\ref{s:memoizing_overview}. We use BNNs for two reasons.
First, the outputs of a BNN and its corresponding original NN are highly
correlated~\cite{andersonB17}, i.e., a small change in a BNN output indicates that the neuron's
output in the original NN is likely to be similar.
Second, BNNs can be implemented with extremely low hardware cost.
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/Output_Correlation_EESEN.pdf}
\caption{Outputs of the binarized neurons (y-axis) versus outputs of the full-precision neurons (x-axis) in EESEN: an RNN for speech recognition. BNN and RNN outputs are highly correlated, showing a correlation coefficient of 0.96.}
\label{f:output_correlation_EESEN}
\end{figure}
Regarding the correlation between BNN and RNN, Anderson et al.~\cite{andersonB17} show that the binarization
approximately preserves the dot-products that a neural network performs for computations. Therefore, there should be a
high correlation between the outputs of the full-precision neuron and the outputs of the
corresponding binarized neuron. We have empirically validated the dot product preservation property for our
set of RNNs. Figure~\ref{f:output_correlation_EESEN} shows the linear correlation between
RNN outputs and the corresponding BNN outputs for EESEN network. Although the range of the outputs of
the full-precision (RNN) and binarized (BNN) dot products are significantly different,
their values exhibit a strong linear correlation (correlation coefficient of 0.96). On the other
hand, Figure~\ref{f:output_correlation} shows the histogram of the correlation coefficients
for the neurons in four different RNNs. As it can be seen, correlation between binarized
and full-precision neurons tend to be high for all the RNNs. More specifically, for the networks EESEN, IMDB SENTIMENT, and DEEPSPEECH, 85\% of the
neurons have a linear correlation factor greater than 0.8 and for the Machine Translation network most of them have a correlation factor greater than 0.5.~These results indicate that if
the output of a binarized neuron shows very small changes with respect to a previously
computed output, it is very likely that the full-precision neuron will also show small
changes and, hence, memoization can be safely applied.
As shown in Equation~\ref{e:binarized_neuron},
the output of a given neuron in a BNN can be computed with an N-bit XOR operation
for bit multiplication and an integer adder to sum the resulting bits. These
two operations are orders of magnitude cheaper than those required by the traditional
data representation (i.e., FP16). Therefore, a BNN represents a low overhead and
accurate manner to infer when the output of a neuron is likely to exhibit significant
changes with respect to its recently computed outputs.
\subsection{Overview}\label{s:memoizing_overview}
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/Output_Correlation.pdf}
\caption{Correlation factor between the neuron output computed using full precision and the output computed with a BNN. }
\label{f:output_correlation}
\end{figure}
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/Binary_Neuron.pdf}
\caption{The figure illustrates how a binary neuron is created from a full-precision neuron in
the RNN network. \textit{Bin} is the binarization function shown in Equation \ref{e:x_binarization}.
Peepholes, bias and activation functions are omitted for simplicity.}
\label{f:lstm_binary_mapping}
\end{figure}
\begin{figure}[t!]
\begin{equation}
\epsilon_t^b =\left| \frac {y_t^b - y^b_{m}}{y^b_{t}} \right|
\label{e:bin_epsilon}
\end{equation}
\begin{equation}
\delta_t^b =\sum_{i=m}^{i=t} \epsilon_i^b
\label{e:bin_delta_error}
\end{equation}
\begin{equation}
y_t = \begin{cases}
y_{m} &\text{if } \delta_t^b<=\theta \\
\text{evaluate neuron} &\text{otherwise, }
\end{cases}
\label{e:yt_bin}
\end{equation}
\begin{equation}
y_m = \begin{cases}
y_{t} &\text{if } \delta_t^b>\theta \\
\text{not updated} &\text{otherwise,}
\end{cases}
\label{e:ym_bin}
\end{equation}
\begin{equation}
y_m^b = \begin{cases}
y^b_t &\text{if } \delta_t^b>\theta \\
\text{not updated} &\text{otherwise,}
\end{cases}
\label{e:vm_bin}
\end{equation}
\begin{equation}
\delta_t^b = \begin{cases}
0.0 &\text{if } \delta_t^b>\theta \\
\text{not updated} &\text{otherwise,}
\end{cases}
\label{e:delta_bin_reset}
\end{equation}
\caption{Neuron level fuzzy memoization with binary network as predictor. $y_t$, $y_m$
correspond to the neuron current and memoized output computed by the LSTM Network. $y^b_t$, $y^b_m$
are the current and memoized output computed by the Binary Network. $\epsilon_t^b$ is the
relative difference between BNN outputs. $\delta_t^b$ is the summation of relative differences
in successive time-steps.}
\label{f:binary_memo_equations}
\end{figure}
The target of our memoization scheme is to reuse a recently computed neuron output,
$y_{m}$, as the output for the current time-step, $y_t$, provided that they are very
similar. Reusing the cached neuron output avoids performing all the corresponding
computations and memory accesses. To determine whether $y_t$ will be similar to
$y_{m}$, we use a BNN as a predictor.
In our memoization scheme, we extend the RNN with a much simpler BNN.
The BNN model is created by mirroring the full precision trained model
of an LSTM or GRU gate, as illustrated in Figure~\ref{f:lstm_binary_mapping}.
More specifically, each neuron is binarized by applying the binarization
function shown in Equation~\ref{e:x_binarization} to its corresponding
set of weights. Therefore, in an gate, every neuron $n$ with
weights vector $\vec{w}$ is mirrored to a neuron $n^{b}$ with
weights vector $\vec{w}^{b}$ corresponding to the element-wise
binarization of $\vec{w}$.
Our scheme stores recently computed outputs for the binary neuron
$n^{b}$ and its associated full-precision neuron $n$. We refer to
these memoized values as $y_m^b$ and $y_m$, respectively.
On every time-step $t$, the binarized version of the neuron,
$n^{b}$, is evaluated first obtaining $y_t^b$. Next, we compute
the relative difference, $\epsilon_t^b$, between $y_t^b$ and
$y_m^b$, i.e. the current and memoized outputs of the BNN,
as shown in Equation~\ref{e:bin_epsilon}.
If $\epsilon_t^b$ is small, i.e., if the BNN outputs
are similar, it means that the outputs
of the full precision neuron are likely to be similar.
As we discuss in Section~\ref{s:bnn_correlation},
there is a high correlation between BNN and RNN
outputs. In this case, we can reuse the memoized output $y_m$ as the
output of neuron $n$ for the current time-step, avoiding
all the corresponding computations. If the
relative difference $\epsilon_t^b$ is significant, we compute
the full-precision neuron output, $y_t$, and update our memoization buffer,
as shown in Equations~\ref{e:ym_bin}, \ref{e:vm_bin} and \ref{e:delta_bin_reset}
so that these values can be reused in subsequent time-steps.
We have observed that applying memoization to the same neuron in a large number
of successive time-steps may negatively impact
accuracy, even though the relative difference $\epsilon_t^b$ in each
individual time-step is small. We found that using a simple throttling
mechanism can avoid this problem. More specifically,
we accumulate the relative differences over successive time-steps
where memoizaiton is applied, as shown in Equation~\ref{e:bin_delta_error}.
We use the summation of relative differences, $\delta^b_t$, to
decide whether the memoized value is reused. As illustrated in
Equation~\ref{e:yt_bin}, the memoized value is only reused when
$\delta^b_t$ is smaller or equal than a threshold $\theta$.
Otherwise, the full-precision neuron is computed.
This throttling mechanism avoids long sequences of
time-steps where memoization is applied to the same
neuron, since $\delta^b_t$ includes the differences
accumulated in the entire sequence of reuses.
Figure~\ref{f:rfactor_distance} shows that the
throttling mechanism provides higher computation
reuse for the same accuracy loss.
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/Static_Threshold.pdf}
\caption{Computation reuse achieved by our BNN-based memoization scheme with and without the
throttling mechanism, for accuracy losses of 1\% and 2\%. The throttling
mechanism provides an extra 5\% computation reuse on average for the same accuracy.}
\label{f:rfactor_distance}
\end{figure}
Figure~\ref{f:memoization_scheme} summarizes the overall memoization scheme, that
is applied to the gates in an RNN cell as follows. For the first input element ($x_0$),
i.e. the first time-step, the output values $y_0^b$ (binarized version) and $y_0$
(in full-precision) are computed for each neuron and stored in a memoization buffer.
$\delta^b_0$ is set to zero. In the next time-step, with input $x_1$, the value $y_1^b$
is computed first by the BNN. Then, the relative error ($\epsilon^b_1$) between $y_1^b$
and the previously cached value, $y_0^b$, is computed and added to $\delta^b_0$ to
obtain $\delta^b_1$. Then, $\delta^b_1$ is compared with a threshold $\theta$. If
$\delta^b_1$ is smaller than $\theta$, the cached value $y_0$ is reused,
i.e. $y_1$ is assumed to be equal to $y_0$, and $\delta^b_1$ is stored in the
memoization buffer. On the contrary, if $\delta^b_1$ is larger than $\theta$, the
full precision neuron output $y_1$ is computed and its value is cached in a
memoization buffer. In addition, $y_1^b$ is also cached and $\delta^b_1$ is set
to zero. This process is repeated for the remaining time-steps and for all the
neurons in each gate.
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/Memoization_Scheme.pdf}
\caption{Fuzzy memoization scheme. $W_x$ and $W_h$ are the weights for the forward ($x_t$)
and recurrent connections ($h_{t-1}$) respectively. $y_t$, $y_m$ correspond to the current and
cached neuron output computed in full precision. $y^b_t$, $y^b_m$ are the current and cached
output computed by the Binary Network. $\delta_t^b$ is the summation of relative differences
in successive time-steps.}
\label{f:memoization_scheme}
\end{figure}
\subsubsection{Improving the BNN Predictor Accuracy}\label{s:improving_bnn}
As discussed later in Section~\ref{s:results}, the percentage of computation reuse achieved by the BNN predictor is smaller than the oracle's percentage. Aiming to improve the BNN predictor's accuracy, we include the memoization scheme described in Section~\ref{s:memoizing_overview} during the training. The intuition is that by allowing the network to reuse similar weights (i.e., less than $\theta$) during the training, we could transfer the obtained knowledge to the inference phase. We show in Section~\ref{s:results} that by doing this, the accuracy of the BNN predictor increases.
To include our memoization scheme into the training, we modified the forward pass as follows. First, at time-step ($t_0$), for a given neuron (i.e., $n_k$), its floating-point ($y_0$) and binarized output values $y^b_0$ are computed and cached. Second, in the next time-step ($t_1$), to set the output value of $n_k$, we first evaluate $n_k$ using its current weights and inputs. Then, we compare its binarized output value $y_1$ with its binarized output in the previous time-step $y^b_0$. If the similarity between these two values is below a threshold (i.e., $theta$), the previous output ($y_0$) is reused. Otherwise, the output value $y_1$ is cached and set as output. Finally, this process is repeated for all the time-steps and neurons in the model. Hence, our neuron-level memoization scheme is included in the inference pass during training, whereas the backward pass and update of weights are performed as usual.
Regarding the training hyper-parameters, we use the same values as the baseline implementation of the models (i.e., model without memoization). However, we train each model for several values of $thetha$ and choose the model with the highest amount of computation reuse and an accuracy equal to the baseline model.
\subsubsection{Finding the threshold value}
The threshold $\theta$ is one of the key parameters in our scheme, and to find its value for a target accuracy loss and a given RNN model, we perform an exploration of it for different values. Each RNN model is evaluated using the training set during this process, and then the accuracy and degree of computation reuse for each threshold value is obtained. Then, for each RNN model, we select the value of $\theta$ that achieves the highest computation reuse for the target accuracy loss (i.e., less than 1\%). Note that this is done only once for each RNN model. Also, once $\theta$ is determined, it is used for inference on the test dataset.
\subsection{Hardware Implementation}\label{s:hardware_implementation}
We implement the proposed memoization scheme on top of EPUR, a state-of-the-art RNN accelerator for low-power mobile applications~\cite{silfa2017epur}.
Figure~\ref{f:epur_overview} shows a high-level block diagram of this accelerator. E-PUR is composed of four computational units tailored to the evaluation of each gate in an RNN cell and a dedicated on-chip memory used to store intermediate results. In the following subsections, we outline the E-PUR architecture's main components and detail the necessary hardware modifications required to support our fuzzy memoization scheme.
\subsubsection{Hardware Baseline}\label{s:hardware_baseline}
In E-PUR each of the Computation Units (CUs), shown in Figure~\ref{f:computation_unit},
are composed of a dot product unit (DPU), a Multi-functional Unit (MU) and buffers to
store the weights and inputs. The DPU is used to evaluate the matrix vector multiplications
between the weights and inputs (i.e. $x_t$ and $h_{t-1}$) whereas the MU is used to compute
activation functions and scalar operations. Note that in E-PUR computations can be performed using
32 or 16 bits floating points operations.
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/EPUR_Overview.pdf}
\caption{Overview of E-PUR architecture which consist of 4 Computation Units (CU) and an on-chip memory (OM).}
\label{f:epur_overview}
\end{figure}
In E-PUR, while evaluating an RNN cell, all the gates are computed in parallel for
each input element. On the contrary, the neurons in each gate are evaluated
in a sequential manner for the forward and recurrent connections. The following steps are executed
in order to compute the output value ($y_t$) for a given neuron (i.e. $n_i$). First, the input
and weight vectors formed by the recurrent and forward connections (i.e, $x_t$ and $h_{t-1}$) are
split into \textit{K} sub-vectors of size \textit{N}. Then, two sub-vectors of size \textit{N} are
loaded from the input and weight buffer respectively and the dot product between them is computed
by the DPU, which also accumulates the result. Next, the steps are repeated for the next $k^{th}$
sub-vector and its result is added to the previously accumulated dot products. This process is
repeated until all \textit{K} sub-vectors are evaluated and added together. Once the output
value $y_t$ is computed, the DPU sends it to the MU where bias and peephole calculations are
performed. Finally, the MU computes the activation function and stores the result in the
on-chip memory for intermediate results. Note that once the DPU sends a value to the MU,
it will continue with the evaluation of the next neuron output, hence, overlapping the computations
executed by the MU and DPU since they are independent. Finally, these steps are repeated until
all the neurons in the gate (for all cells) are evaluated for the current input element.
\subsubsection{Support for Fuzzy Memoization }\label{s:binary_memoizing_support}
In order to perform fuzzy memoization through a BNN, two modifications are done to each
CU in E-PUR. First, the weight buffer is split into two buffers: one buffer is used to store
the weight signs (sign buffer) and the other is used to store the remaining bits of the weights.
Note that the sign buffer is always accessed to compute the output of the binary network ($y_t^b$)
whereas the remaining bits are only accessed if the memoized value ($y_m$) is not reused. The binarized weights are stored in a small memory which has low energy cost but, as a consequence of splitting the weight buffer, its area increases a bit (less than one percent).
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/Computation_Unit.pdf}
\caption{ Structure of E-PUR Computation Unit.}
\label{f:computation_unit}
\end{figure}
\begin{figure}[t!]
\centering
\includegraphics[width=3.375in]{figures/Memoizing_Unit.pdf}
\caption{Structure of the Fuzzy Memoization Unit (FMU).}
\label{f:memoizing_unit}
\end{figure}
The second modification to the CUs is the addition of the fuzzy memoization unit (FMU) which
is used to evaluate the binary network and to perform fuzzy memoization. This unit takes as input
two size-\textit{T} vectors (i.e., number of neurons in an RNN cell). The first vector is a weight
vector loaded from the sign buffer whereas the other is created as the concatenation of the
forward ($x_t$) and the recurrent connections ($h_{t-1}$).
As shown in Figure \ref{f:memoizing_unit}, the main components of the FMU are the BDPU that computes the binary dot product and the comparison unit (CMP) which decides when to
reuse a memoized value. In addition, the FMU includes a buffer (memoization buffer) which
stores the $\delta_t^b$ for every neuron and the latest evaluation of the neurons by the full precision and binary
networks. BNN neurons (i.e, binary dot product) are evaluated using a bitwise XNOR operation and an
adder reduction tree to gather the resulting bit vector. In the CMP unit, the relative error ($\delta_t^b$)
is computed using integer and fixed-point arithmetic.
The steps to
evaluate the RNN cell, described in Section \ref{s:hardware_baseline}, are executed in a
slightly different manner to include the fuzzy memoization scheme. First, the binarized input and weight vectors for a given neuron in
a gate are loaded into an FMU from the
input and sign buffers respectively. Next, the BDPU computes the dot product and sends the
result ($y_t^b$) to the comparison unit (CMP). Then, the CMP loads the previously cached
values $y_m^b$ and $\delta^b_{t-1}$ from the memoization buffer and it uses them to compute the
relative error ($\epsilon^b_t$) and the $\delta^b_t$. Once $\delta^b_t$ is computed, it is compared with
a threshold ($\theta$) to determine whether the full-precision neuron needs to be
evaluated or the previously cached value is reused instead. In the case
that $\delta^b_t$ is greater than $\theta$, an evaluation in full-precision is triggered. In that regard, the DPU is signaled to start the full precision evaluation which is done following the steps described in
Section \ref{s:hardware_baseline}. After the full precision evaluation, the values $y_t$, $y_t^b$, and $0.0$ are cached in the memoization table corresponding to $y_m$, $y_m^b$, and $\delta^b_t$ respectively. On the other hand, if memoization can be applied (i.e. $\delta^b_t$ is smaller than the maximum
allowed error), $\delta^b_t$ is updated in the memoization table and
the memoized value ($y_m$) is sent directly to the MU (bypassing the DPU), so the full-precision evaluation of the neuron is avoided.
Finally,
these steps are repeated until all the neurons in a gate are evaluated for the current input element. Since LSTM or GRU gates are processed by independent CUs, the above process is executed concurrently by all gates.
|
{'timestamp': '2022-02-15T02:39:10', 'yymm': '2202', 'arxiv_id': '2202.06563', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06563'}
|
arxiv
|
\section*{Acknowledgements}
\section{Details of Our ActDial{} Dataset}
\label{sec:appendix-annotation}
\input{table/tag_definition}
\subsection{Segment Acts definitions}
\label{sec:appendix-intent-definition}
For the formal definitions of segment act, please refer to Table \ref{tab:tag-definition}.
The eleven segment act labels cover three major communication activities: (i) general task, which includes information-transfer activities and action-discussion activities; (ii) social obligation management, which includes typical social conventions in communication; and (iii) simple feedback, which includes simple non-informative feedback about the processing of previous utterances.
Table \ref{tab:tag-definition} shows our eleven segment act labels and their examples.
\subsection{Crowdsourcing Segment Act Annotation}
\label{sec:appendix-dataset-crowdsource}
We crowdsourced segment act annotation from annotators whose native language is Mandarin Chinese (zh-cmn), and more importantly, they are proficient in English (en-US).
More than 50 annotators participated after rigorous training to ensure data quality.
Each segment is annotated by three different annotators.
If the initial three annotations are all different, further round(s) of annotation on this segment would be conducted until it got a majority vote (at least two annotations are the same).
Besides Fleiss' kappa \citep{fleiss1971measuring} mentioned in Section \ref{sec:dataset}, we here report the sample accuracy to show the quality of our annotations.
Although it is impossible to check the correctness of every single annotation, we do perform sampling inspection when collecting the annotations everyday.
In total, We sampled 8,000 segments randomly and annotated these segments by ourselves.
Since we have a deeper understanding than our annotators and our annotations are examined multiple times by ourselves, our annotations on these 8,000 segments can be considered as ground truth.
The majority votes of crowdsourced annotations are later compared with the ground truth labels to obtain sample accuracy. The sample accuracy in DailyDialog annotation is 0.90 and that in ConvAI2 is 0.93.
The small gap of the accuracy is due to the difference in dialogue complexity.
\subsection{Dataset Statistics and Distributions}
\label{sec:appendix-dataset-statistics}
For the ConvAI2 dataset, we collected 481,937 segment acts on the training set, and 29,232 segment acts on the validation set.
Since the testing set is not publicly available, we did not annotate it.
For the DailyDialog dataset, we gathered 178,604 segment acts on the training set, 16,500 segment acts on the validation set, and 16,028 segment acts on the testing set.
Note that even though ConvAI2 and DailyDialog split their data for training, validation, and testing purpose, it is not always necessary to mechanically follow the splits.
Our annotations on ConvAI2 and DailyDialog can be used as a unity, \textit{ActDial{}}, depending on the research problems.
Table \ref{tab:tag-definition} shows the distribution of all segment acts on our dataset.
The segment act distribution is very unbalanced.
Specifically, the distribution is highly skewed to \texttt{question}, which is not surprising because ConvAI2 and DailyDialog are chitchat datasets and the majority of communication activities is asking for more information.
On the other hand, few written dialogues between two strangers, the setting of ConvAI2 and DailyDialog, involve apology or encounter communicative difficulties, which results in the rare appearance of \texttt{apology}, \texttt{backchennel-failure}, and \texttt{check-understanding} segment acts.
However, it is still essential to include these segment acts as they take place far more commonly in spoken dialogues in the real world.
\section{Human Evaluation for Controllable Dialogue}
\label{sec:appendix-h2beval}
\input{table/h2b_eval}
We collected human judgements from Amazon Mechanical Turk (AMT).
The crowd-workers are provided with the full multi-turn conversation for evaluation.
We ask crowd-workers to evaluate the \textit{relevancy}, \textit{avoiding contradiction}, \textit{avoiding repetition}, \textit{persona consistency} and \textit{overall quality} of the conversation.
The reason for designing the human evaluation on different aspects is that we assume a good conversation between human and {a dialogue system} should satisfy the following properties:
(1) generating relevant and non-repetitive responses (\textit{relevancy} and \textit{avoiding repetition}),
(2) memorizing the dialogue history and generating non-contradictory information (\textit{avoiding contradiction}),
(3) maintaining a consistent persona/topic (\textit{persona/topic consistency}),
(4) formulating a natural conversation (\textit{overall quality}).
The first four aspects are formulated as binary-choice questions, and the overall quality is formulated as Likert question on a 1-5 scale, where higher is better.
{During} evaluation, we did not distinguish whether {an} utterance is generated by human or by dialogue model, because we want {the evaluation is about} the full conversation, rather than just utterances generated by the dialogue model.
To ensure better data quality, Turkers are selected by their job success rate and geographic location (only admits turkers from English speaking countries). Before starting our evaluation job, turkers must read through our detailed guideline.
For each dialogue, a turker is asked to evaluate the dialogue from the following perspectives:
\begin{enumerate}
\item \textbf{Irrelevant response (binary)}: Whether or not the speaker generates a response which seems to come out of nowhere according to the conversation history. Binary score.
\item \textbf{Contradictory information (binary)}: Whether or not the speaker generates a response which contradicts to the common sense or to what himself just said in the previous conversation. Binary score.
\item \textbf{Repetitive response (binary)}: Whether or not the speaker generates a response which has the same meaning as his previous utterance(s). Binary score.
\item \textbf{Inconsistent with persona (binary)}: Whether or not the speaker generates a response which is not consistent with his persona profile. \textbf{Only used if the dialogues-to-evaluate follow ConvAI2 setting and are generated with personas.} Binary score.
\item \textbf{Topic shifts (binary)}: Whether or not the speaker generates a response which belongs to a completely different topic compared with the previous conversation history. \textbf{Only used if the dialogues-to-evaluate follow Daily Dialogue setting and are not generated with personas.} Binary score.
\item \textbf{Overall score (1-5)}: An overall impression of the dialogue quality, not necessary to have any relationship with the aspects above. Score is between 1 to 5 inclusive, all integer.
\end{enumerate}
The evaluation results are examined by ourselves. Incorrect annotation would be rejected and re-evaluated by another turker.
\section{Implementation of ActBERT}
\label{sec:appendix-actbert}
ActBERT follows the architecture of RoBERTa \citep{DBLP:journals/corr/abs-1907-11692}.
The vocabulary size is relatively small as it only contains 11 segment acts and other special tokens.
It has 4 hidden layers, 4 attention heads, and a hidden dimension size of 256.
Speaker information is included using different input token type.
Similar to the masked language model task, we use a masked segment act task during the training.
\section{Implementation of BLEU and BERTScore}
\label{sec:appendix-bleu&bertscore}
Controllable Dialogue \citep{see2019makes} are trained on ConvAI2 dataset whose setting is two participants talking about their own personas.
This unique characteristics makes it feasible to find references for BLEU, BERTScore, or other reference-based metrics.
We take dialogues, from the testing set of ConvAI2, that have the most overlapping personas as the references for a dialogue.
Although not as convincing as references in machine translation task, references obtained in this way prove to be helpful to dialogue evaluation.
Both BLEU and BERTScore reaches relatively high correlations on Controllable Dialogue.
The smooth function of the BLEU score is NIST geometric sequence smoothing \citep{bird-loper-2004-nltk}. BERTScore are calculated by using the package from its authors \citep{DBLP:conf/iclr/ZhangKWWA20}.
\section{Cases Analysis}
\label{sec:appendix-case-analysis}
\input{table/success_case}
\input{table/failure_case}
In this section, we exhibit two real cases from Controllable Dialogue to show the strengths and weaknesses of our FlowEval{}.
\paragraph{A Successful Case}
Table~\ref{table:success-case} shows a poor conversation with human rating 1 point, the lowest point possible. Our FlowEval{} can successfully rank this dialogue as the worst among 278 dialogues, while DynaEval and Flow score consider it not bad but mediocre.
To be exact, DynaEval ranks it at the top 170th and Flow score places it at the 114th.
Repetition is the main flaw of this conversation.
From the segment act feature perspective, the abnormal long \texttt{inform} flows caused by a series of ``old'' provide FlowEval{} enough evidence to penalize this behavior.
From content feature aspect, the repeated words do not contribute well to our word overlapping assessment in FlowEval{} either.
Other methods do not have specific mechanism that help them distinguish this repetition, which makes them vulnerable in similar cases.
\paragraph{A Failure Case}
Here we show an example where FlowEval{} fails to deliver the correct evaluation.
The dialogue in Table~\ref{table:failure-case} is of high quality: annotators give it 4 points, the highest points among 278 dialogues.
However, FlowEval{} ranks it at the 253rd. and Flow score ranks it at the 178th.
DynaEval gets it right, reviewing it as the 3rd best dialogue.
The segment act flow of this dialogue is relatively natural.
The contents appear not so frequently in the ActDial{} dataset.
These characteristics make it hard for FlowEval{} to output a correct ranking.
Just like our competing baselines, more analysis and case study are needed to determine a more concrete pattern.
\section{Conclusion}
\label{sec:conclusion}
In this work, we propose a consensus-based reference-free framework for open-domain dialog evaluation with segment act flows. From extensive experiments against the state-of-the-art baselines, our method can reach the best or comparable correlation with human evaluation.
Our segment-act-based methods complement well to previous semantic-meaning-focused methods, pushing the ceiling of correlations. Moreover, the promise of our consensus-based framework encourages us to step further in the direction of dialog evaluation.
\section{ActDial{}: A Segment Act Dataset on Open-Domain Dialogues}
\label{sec:dataset}
We propose the new concept of segment act, extracting the core function of each segment in an utterance.
We then crowdsource a large-scale open-domain dialogue dataset with our proposed segment act labels, called \emph{ActDial{}}.
\subsection{Our Segment Act Tagset}
We design an open-domain segment act tagset based on the ISO 24617-2 annotation criteria \citep{bunt2019dialogbank}.
We define a segment act as a functional label that expresses the communicative goal of participants in a conversation, which is irrelevant to syntactic or sentiment details.
Based on this definition, we conduct combination operations, like merging \texttt{Choice-Question}, \texttt{Check Question}, etc. into \texttt{question}, on the original 56 labels proposed by \citet{bunt2019dialogbank} and eventually obtain 11 labels as our tagset.
These combination operations guarantee a robust coverage on diverse dialogue expressions and mutual exclusiveness between different segment act labels.
From our later experiments, these 11 labels capture key information from dialogues while remain simple enough to enable large-scale accurate annotations. Detailed definition and examples of each segment act can be found in Appendix \ref{sec:appendix-intent-definition}
\subsection{Datasets and Segmentation}
\label{subsec:dial-seg}
We crowdsourced segment act annotations on ConvAI2 \citep{dinan2020second} and DailyDialog \citep{li2017dailydialog}.
The details of the crowdsourcing process are in Appendix \ref{sec:appendix-dataset-crowdsource}
The \textbf{ConvAI2} dataset
is based on the PersonaChat dataset \citep{zhang-etal-2018-personalizing}, where all dialogues are constructed by asking two crowd-workers to chat with each other based on randomly assigned persona profiles.
ConvAI2 is a widely-used benchmark for many state-of-the-art dialogue systems \citep{golovanov2019large,bao2019plato,shuster2019dialogue,roller2020recipes}.
The \textbf{DailyDialog} dataset \cite{li2017dailydialog}
is constructed by crawling raw data from various English-learning websites.
Note that DailyDialog already has 4 dialog act labels: \texttt{question}, \texttt{inform}, \texttt{directive}, and \texttt{commissive}.
Our finer-grained annotation which takes social chit-chat and simple feedback into account can better cover diverse dialogue scenarios and provide extra information.
Following our definition of segment acts, we split each utterance into multiple segments using NLTK \citep{bird-loper-2004-nltk} sentence punctuation tokenizer \citep{kiss-strunk-2006-unsupervised}.
The resulting segments will have their own segment act labels during annotation.
Each segment is annotated by three different crowd-workers.
With our special tagset design and the segmentation process, annotators can easily reach substantial agreement and deliver a high-quality dataset:
Fleiss' kappa \citep{fleiss1971measuring} achieves 0.754 for DailyDialog and 0.798 for ConvAI2.
Detailed statistics of our ActDial{} dataset is documented in Appendix \ref{sec:appendix-dataset-statistics}
\section{Ethical Considerations}
\label{sec:ethical}
A big part of this work contains (1) the data annotation on two existing benchmark datasets of conversation modeling: the ConvAI2 dataset and the DailyDialog dataset and (2) human evaluation on the overall quality of generated conversations.
As our ActDial{} is built upon the existing datasets, we follow the original copyright statements of these two datasets and will further release our segment act annotations to the research community.
During annotation, we only collected the segment act annotations, and no demographic or annotator's identity information was collected.
In addition, we provide a detail description of human evaluation design in Appendix \ref{sec:appendix-h2beval}.
\section{Experiments and Analysis}
\label{sec:experiments}
\begin{comment}
We conduct extensive experiments to discuss these three topics:
\begin{enumerate}[noitemsep,nolistsep]
\item How does our method perform against state-of-the-art baselines?
\item What do segment acts bring to dialogue evaluation?
\item Why does consensus work?
\end{enumerate}
\end{comment}
\input{table/results}
\subsection{Benchmark Datasets}
\noindent\textbf{Controllable Dialogue Dataset} contains the human-to-bot conversation data collected by \citet{see2019makes}.
These conversations are based on the ConvAI2 dataset \citep{dinan2020second}.
We extend the original dataset by crowdsourcing segment act labels and human evaluation scores.
The detailed human evaluation procedural are documented in Appendix \ref{sec:appendix-h2beval}.
In total, there are 278 dialogues coming from 3 generative models.
\noindent\textbf{FED Dataset} \citep{DBLP:journals/corr/fed} contains 125 human-to-bot conversations coming from three systems.
We take the mean of the 5 overall scores for each dialogue as the human evaluation score in our experiments.
We annotate all the segment act labels using the trained classifier described in Section~\ref{sub-sec:annotation}.
\noindent\textbf{DSTC9 Dataset} are collected from the Interactive Evaluation of Dialog Track @ The Ninth Dialog System Technology Challenge (DSTC9) \citep{DBLP:journals/corr/dstc9}.
It contains 2200 human-to-bot conversations from eleven chatbots.
We take the mean of the 3 human ratings as the final evaluation score.
Similar to those in FED dataset, all the segment act labels are predicted by a trained classifier.
\subsection{Methods}
\label{sub-sec:methods}
We describe all the baselines used for comparison and the implementation details of our method.\\
\noindent\textbf{FED metric} \citep{DBLP:journals/corr/fed}, leveraging the ability of DialoGPT-large \citep{DBLP:journals/corr/dialogpt} and the use of follow-up utterances, is an automatic and training-free evaluation method widely used by the community \citep{DBLP:journals/corr/dstc9}.\\
\noindent\textbf{DynaEval} \citep{DBLP:journals/corr/dynaeval} adopts the graph convolutionl network to model dialogues, where the graph nodes are dialogue utterances and graph edges represents the relationships between utterances.
DynaEval\_emp and DynaEval\_daily denote two variants trained on Empathetic Dialogues \citep{rashkin-etal-2019-towards} and DailyDialog \citep{li2017dailydialog} respectively.
DynaEval\_emp reaches the best correlation on FED dataset.\\
\noindent\textbf{Flow score} \cite{li-etal-2021-conversations}, considering the semantic influence of each utterance and modeling the dynamic information flow in dialogues, becomes the best evaluation method on DSTC9 dataset.\\
\noindent\textbf{BLEU} \citep{papineni-etal-2002-bleu} and \textbf{BERTScore} \citep{DBLP:conf/iclr/ZhangKWWA20} are two popular reference-based metrics.
The performance of BLEU and BERTScore are tested on Controllable Dialogue dataset only, as finding suitable reference is unfeasible on FED and DSTC9 dataset.
The process of how to find references on Controllable Dialogue and the implementation of BLEU and BERTScore are documented in Appendix \ref{sec:appendix-bleu&bertscore}.
\noindent\textbf{FlowEval{} (our method)}
's hyperparameters are tuned on Controllable Dialogue dataset and directly apply to FED and DSTC9.
Besides, since Controllable Dialogue dataset is constructed on top of ConvAI2 \cite{see2019makes}, we only use the DailyDialog part of ActDial{} for all the training and retrieval to prevent any data leakage.
\subsection{Results and Analysis}
The common practice to show the effectiveness of a dialogue evaluation metric is to calculate the Pearson, Spearman's, and Kendall correlation between human evaluation and the automatic evaluation \citep{DBLP:journals/corr/fed, DBLP:journals/corr/dynaeval, li-etal-2021-conversations, Yeh2021comprehensive}.
Table \ref{tab:results} list the correlations between automatic metrics and human evaluation.
From these results, four conclusions can be drawn.
\noindent\textbf{FlowEval{} Reaches Comparable Performance.}
Across three datasets, our FlowEval{} achieves the best or comparable correlations with human evaluation.
On Controllable Dialogue dataset, all baseline metrics fail to reach meaningful correlation , while FlowEval{} becomes the top performer.
On the other two datasets, the results of FlowEval{} are comparable with most baselines, though the gap to the best method is obvious.
We list one successful and one failure cases in the Appendix~\ref{sec:appendix-case-analysis} to enable a closer observation of our approach.
\noindent\textbf{Automatic Evaluation Metrics Lack Transferability.}
We can observe that the best method on one dataset becomes mediocre on the other datasets, including our FlowEval{}.
FlowEval{} outperforms all other methods on Controllable Dialogue dataset, but can only get to the second tier on the other two datasets.
DynaEval, the best method on FED dataset, loses its advantage when tested on other datasets.
The same story also happens for Flow score, a state-of-the-art metric in the DSTC9 dataset.
This observation is consistent with study from previous work \cite{Yeh2021comprehensive}.
One reason for the brittleness of these methods is that their calculations rely on large models.
The data used to train these large models plays an decisive role, as we can see from the performance difference between DynaEval\_emp and DynaEval\_daily.
In addition, FlowEval{} depends on the segment act labels and these labels on FED dataset and DSTC9 dataset are annotated by a trained classifier.
Even though the classifier has relatively high accuracy (90\%), it still injects some errors to the segment act flow, which hinders the application of FlowEval{} on new datasets.
These observations indicate that how to construct a robust dialogue evaluation metric remains a problem for the community.
\noindent\textbf{FlowEval{} Can Provide Complementary Information to Other Methods.}
Similar to \citet{Yeh2021comprehensive}, we test different combinations of metrics by directly averaging one metric with the best metrics on the three datasets, which are BERTScore on Controllable Dialogue dataset, DynaEval\_emp on FED dataset, and Flow score on DSTC9 dataset.
The last 4 rows of Table~\ref{tab:results} show that FlowEval{} can consistently push the current correlation ceiling to a new level the most, while many other combinations improve little or even hurt performance.
These results imply that segment act is an important missing aspect in dialogue evaluation that worth even further exploration in the future.
\noindent\textbf{Our Consensus-Based Framework Shows Potential.}
In our consensus-based framework, the retrieval step of FlowEval{} could find pseudo-references for other reference-based metrics like BLEU \citep{papineni-etal-2002-bleu} and BERTScore \citep{DBLP:conf/iclr/ZhangKWWA20} and make them reference-free.
Here we experiment with BERTScore, as it is the best performing reference-based metric on Controllable Dialogue.
The reference-free form of BERTScore, called \emph{Consensus BERTScore}, is similar to our FlowEval{}, except that we do not employ segment act features in the retrieval step and we exclude the segment act score, i.e., Eq.~\ref{eqn:fi}, in the assessment step.
As shown in the third row of Table~\ref{tab:results}, while Consensus BERTScore marginally underperforms BERTScore in Pearson correlation (0.271 vs. 0.281), Consensus BERTScore is slightly better in Spearman's and Kendall correlation (0.223 vs. 0.208, 0.170 vs. 0.157).
This promising result shows the potential of our consensus-based framework. It leads a new way to rethink the usability of reference-based metrics in dialogue evaluation.
\subsection{What Does Segment Act Bring to Dialogue Evaluation?}
Compared with semantic-meaning-focused metrics, what does segment act bring to dialogue evaluation?
We hypothesize the explicit involvement of segment acts can bring useful information, complementary to semantic-meaning-focused metrics.
\begin{figure*}
\centering
\includegraphics[scale=0.34]{figure/dist.png}
\caption{Segment act feature space of Controllable Dialogue, FED, DSTC9 dataset and the retrieval set ActDial{}. We have separate plots for Controllable Dialogue because the ActBERT we used to extract features and the retrieval set are different (See Section~\ref{sub-sec:methods}).}
\label{fig:dist}
\end{figure*}
We illustrate our hypothesis in Figure~\ref{fig:rank-vec}.
If segment act is useful, the segment-act-based evaluation $\vec{v}_p$ should be positively correlated to human evaluation $\vec{v}_o$, i.e., $\vec{v}_p$ has roughly the same direction as $\vec{v}_o$ but with a small angle $\theta_2$.
If segment act is complementary to semantic-meaning-focused metrics, the segment-act-based evaluation $\vec{v}_p$ should be almost orthogonal to the semantic-meaning-focused evaluation $\vec{v}_m$, i.e., $\vec{v}_m$ falls into the other side of $\vec{v}_o$ so that $\vec{v}_m$ is also positively correlated to $\vec{v}_o$ with a small angle $\theta_1$ but almost orthogonal to $\vec{v}_p$ with a large angle $\theta_3=\theta_1+\theta_2$.
These angles $\theta_1,\theta_2$ and $\theta_3$ could be characterized by the correlation of two evaluation results.
A higher correlation implies a smaller angle.
\begin{figure}
\begin{center}
\includegraphics[scale=0.4]{figure/explain.jpg}
\end{center}
\caption{
\label{fig:rank-vec}
The relationships, in our hypothesis, between human evaluation $\vec{v}_o$, semantic-meaning-focused evaluation $\vec{v}_m$, and segment-act-based evaluation $\vec{v}_p$.
}
\end{figure}
\input{table/complementary}
We conduct experiments on Controllable Dialogue dataset to validate our hypothesis.
Two of the popular semantic-meaning-focused metrics are BERTScore \cite{DBLP:conf/iclr/ZhangKWWA20} and BLEU \cite{papineni-etal-2002-bleu}.
We modify the retrieval and assessment parts of our FlowEval{}, so that only segment act information is utilized.
We denote this variant as \emph{FlowEval{}\_seg}.
As we could observe from the first three rows of Table \ref{table:complementary} that the FlowEval{}\_seg, BLEU and BERTScore all exhibit strong correlation to human evaluation.
Unsurprisingly, BLEU and BERTScore are highly correlated (the last row of Table~\ref{table:complementary}), since both of them focus on the semantic meaning of dialogues.
In line with our hypothesis, the BLEU-FlowEval{}\_seg correlation and BERTScore-FlowEval{}\_seg correlation is far smaller (rows 4-5 of Table~\ref{table:complementary}), which indirectly shows that segment act can evaluate dialogues from a complementary perspective.
This findings resonate with the theory in \citet{bender-koller-2020-climbing}, where the \emph{meaning} and the \emph{communicative intent}, i.e., segment act here, are considered to be two decoupled and complementary dimensions.
\subsection{Why Does Consensus Work?}
In this section, we investigate the problem of why consensus-based framework can perform well in dialogue evaluation by visualizing the segment act feature space, an essential aspect in the retrieval process of FlowEval{}.
We compare the segment act feature distribution between the three test sets and their corresponding retrieval sets, projecting these features to 2-dimensional space by t-SNE \citep{JMLR:v9:tsne}.
These visualizations are plotted in Figure~\ref{fig:dist}.
The core idea of consensus lies on using the nearest neighbors as references to measure a newcomer.
Only if the suitable nearest neighbors consistently exist, will the consensus of them have meaningful indication to evaluate a new subject.
We can observe from Figure~\ref{fig:dist} that, even though dialogues in three test sets are diverse, every datapoint from the test sets is surrounded by datapoints from the retrieval sets.
This observation can explain why using consensus in dialog evaluation is promising, since we can always reliably find good references for a new dialogue.
Moreover, this desirable coverage is achieved by an attainable amount of datapoints.
It only needs 10,494 and 31,993 dialogues as retrieval sets in our experiments to get good results.
The power of the consensus may go stronger and more reliable if the size of retrieval set grows, which could be a favorable property in many of industrial applications.
\section{Introduction}
\label{sec:introduction}
Dialogue evaluation plays a crucial role in the recent advancement of dialogue research.
While human evaluation is often considered as a universal and reliable method by the community \citep{Smith2022HumanEO}, automatic dialogue evaluation metrics draw growing attention as they can assess dialogues with faster speed and lower cost \citep{DBLP:conf/aaai/TaoMZY18, DBLP:conf/emnlp/HuangYQLL20, DBLP:journals/corr/fed}.
Traditional word-overlap metrics, like BLEU \citep{papineni-etal-2002-bleu} and METEOR \citep{banerjee-lavie-2005-meteor}, lose some of their effectiveness in the dialogue setting as reliable references are hard to obtain \citep{liu-etal-2016-evaluate}.
Recent works tackle this problem by leveraging more sophisticated architectures \citep{DBLP:journals/corr/dynaeval, li-etal-2021-conversations} and harnessing the power of large models \citep{DBLP:journals/corr/fed}.
Although these recent metrics claim to show some progress towards higher correlation with humans, the gap between automatic metrics and human evaluation is still noticeable \citep{Yeh2021comprehensive}.
Automatic open-domain dialogue evaluation is still an open question, and extensive efforts have been made to improve performance from different angles \citep{pang-etal-2020-towards-holistic, DBLP:journals/corr/predictive-engagement, mehri-eskenazi-2020-usr, phy-etal-2020-deconstruct}.
\input{table/dialogue_example}
Among those newly released metrics \citep{DBLP:journals/corr/dynaeval, DBLP:journals/corr/fed, li-etal-2021-conversations, pang-etal-2020-towards-holistic, DBLP:conf/aaai/TaoMZY18, mehri-eskenazi-2020-usr, phy-etal-2020-deconstruct}, hardly any explicitly employs dialog act, one of the pillars of dialogue study, in their methods.
Intuitively, introducing dialog act into open-domain dialogue evaluation should be beneficial:
a sequence of dialog acts distills the core function of each utterance and can potentially reveal how speakers interact in general.
However, directly using preexisting dialog act definitions \cite{DBLP:journals/corr/switchboard, hemphill-etal-1990-atis} seems undesirable, as an utterance can contain several segments that possess different conversational functions.
We show our observation in Table~\ref{table:dialog-example}.
By saying ``\textit{Hmm. Certainly. What kind of coffee do you like? We have espresso and latte.}'', the participant first acknowledge the conversation with backchannel, then commit to finish the request by saying ``\textit{Certainly}''.
Later, the speaker drives the conversation deeper, asking for a more concrete order and offering all the options.
In human conversations, it is common to have more than one function for each utterance, which means using a single dialog act to express the core function of an utterance inevitably suffers from information loss.
To solve this issue, we extend the concept of dialog act from the utterance level to the segment level.
We name these segment level dialog act \emph{segment act} and a sequence of segment acts a \emph{segment act flow}.
One difficulty of using segment act for open-domain dialogue evaluation is the lack of related data.
Since there is no dataset for segment act, we follow the ISO 24617-2 annotation criteria \citep{bunt2019dialogbank} and propose a simplified ISO-format segment act tagset.
We crowdsource large-scale segment act annotations on two popular open-domain dialogue datasets: ConvAI2 \citep{dinan2020second} and DailyDialog \citep{li2017dailydialog}.
We name our dataset \emph{ActDial{}}.
Another challenge of incorporating segment act into open-domain dialogue evaluation lies in finding a suitable way to assess dialogues with the segment act feature.
Modeling segment act flow is not trivial.
On the one hand, dialogues have different numbers of turns and, thus, have varying lengths of segment act sequences.
On the other hand, defining and finding the ground-truth segment act flow for a dialogue are almost infeasible, discouraging the development of any reference-based methods.
To overcome this challenge, we design the first consensus-based reference-free open-domain dialogue evaluation framework, \emph{FlowEval{}}.
For a dialogue to be evaluated, our \emph{FlowEval{}} first obtains the segment act flow, e.g., from a trained classifier.
Then, we harvest segment act features, from a dedicated BERT-like \citep{devlin-etal-2019-bert} masked segment act model, and content features, from RoBERTa-large \citep{DBLP:journals/corr/abs-1907-11692}.
We retrieve pseudo-references from the training set, according to the segment act features as well as content features. Last, we evaluate the dialogue with the consensus of the pseudo-references, fusing metrics from both segment act and word-overlap perspectives. The essence of our consensus-based framework lies in retrieving pseudo-references and using the consensus of pseudo-references to assess a new dialogue.
Not limited to segment act feature, our proposed consensus-based framework is compatible to a wide range of features and metrics, such as sentiment features, engagingness feature, etc.
Extensive experiments are carried out against the state-of-the-art baselines
on Controllable Dialogue dataset \citep{see2019makes}, FED dataset \citep{DBLP:journals/corr/fed}, and DSTC9 dataset \citep{DBLP:journals/corr/dstc9}.
The result supports that segment act flow is effective in dialogue evaluation:
our consensus-based method achieve the best or comparable correlation with human evaluation. Additionally, segment act flow can bring complementary information to metrics that heavily focus on the raw text of dialogues.
In summary, the contributions of this work are three-fold:
\begin{enumerate}[noitemsep,nolistsep]
\item We propose to model the segment level act as the dialog flow information for open-domain dialogue evaluation.
\item We are the first to propose a consensus-based framework for open-domain dialogue evaluation.
Our studies show that the consensus approach can work efficiently even when the size of the search set, i.e., the number of dialogues in the training set, is around ten thousand. This attainable size shows the promise of our consensus approach for dialogue evaluation and other natural language evaluation tasks.
\item Our method can reach the best or comparable performance when compared with state-of-the-art baselines.
Additional experiments are conducted to examine detailed properties of our method and consensus process.
\end{enumerate}
\section{FlowEval{}: A Segment-Act-Flow Aware Evaluation Metric}
\label{sec:methods}
In this section, we describe the details of our proposed dialogue evaluation framework, \emph{FlowEval{}}.
FlowEval{} is implemented in three stages: segment act harvesting, retrieval, and assessment.
\subsection{Segment Act Harvesting}
\label{sub-sec:annotation}
In order to utilize the segment act flow, we first need to harvest the segment act labels for an unseen raw dialogue $U$.
In our experiments unless specified, the segment act labels are acquired by a text classification model, based on RoBERTa-large \cite{DBLP:journals/corr/abs-1907-11692} and fine-tuned on ActDial{}.
The accuracy of this classifier is 90\% on unseen data.
In the end, we will have the annotated segment act flow $A_U=\{a_1,\cdots,a_i,\cdots,a_n\}$ for the dialogue $U$, where $a_i$ is the segment act label for $i$-th segment and $n$ is the number of segments in $U$.
\begin{figure*}
\begin{center}
\includegraphics[scale=0.4]{figure/retrieval.pdf}
\end{center}
\caption{
\label{fig:retrieval}
Extract segment act and content features. Retrieve closest human dialogues from ActDial{} dataset.
}
\end{figure*}
\subsection{Retrieval}
\label{sec:retrieval}
For the retrieval process, FlowEval{} retrieves two sets of dialogues based on segment act features and content features respectively.
The search space for FlowEval{} is our ActDial{} dataset and the unseen raw dialogue $U$ serves as query.
FlowEval{} first extracts segment act features from a masked segment act model, and retrieves $k^a$ nearest neighbors for $U$ based on our defined similarity function.
Then, FlowEval{} extracts content features from a RoBERTa-large model, and retrieves $k^c$ nearest neighbours for $U$ based on another similarity function.
The final outcome of this retrieval stage is $k=k^a+k^c$ relevant dialogues for the unseen dialogue $U$.
Figure~\ref{fig:retrieval} illustrates this process in detail.
\paragraph{Segment Act Features.}
To extract segment act features, we treat a segment act label as a word and the segment act flow of a dialogue as a sequence.
We then train a masked language model \cite{devlin-etal-2019-bert} called \emph{ActBERT} on all segment act flows in our ActDial{} datasets.
Detailed implementation of ActBERT is documented at Appendix \ref{sec:appendix-actbert}.
ActBERT has an accuracy of 81\% for predicting the masked segment act on unseen data, which is significantly higher than guessing the majority segment act label (67\%).
This means that our ActBERT indeed captures reliable features from the segment act flow.
ActBERT will be used to extract segment act features for any dialogue that has segment act flow.
Given a dialogue $D$, we first pass $D$'s segment act flow $A_D$ into ActBERT.
The output of $h$-th intermediate layer of ActBERT, $H^h_D\in\mathbb{R}^{n\times d}$, will be chosen, where $h$ is a hyper-parameter, $n$ is the number of segments in $D$ and $d$ is the hidden size of ActBERT.
$H^h_D$ is then max-pooled along the $n$ dimension to construct a fixed length vector $\bar{H}^h_D\in\mathbb{R}^{d}$ as the segment act feature of $D$.
We further employ TF-IDF features to constrain the retrieved dialogues to have a similar topic as $U$.
We collect the word count statistics from our ActDial{} dataset and compute the TF-IDF feature vector $T_D\in\mathbb{R}^{v}$ for any dialogue $D$, where $v$ is the vocabulary size.
Having the feature set $\{\bar{H}^h_U,T_U\}$ of $U$ and $\{\bar{H}^h_R,T_R\}$ of a human dialogue $R$ in ActDial{}, we define an segment-act-based similarity metric $S^a$ to retrieve $k^a$ nearest neighbors $\{R_i\}_{k^a}$:
\begin{equation}
\label{eqn:act}
S^a(U,R)=(1+\mathrm{cos}(\bar{H}^h_U,\bar{H}^h_R))(1+\mathrm{cos}(T_U,T_R))
\end{equation}
where $\mathrm{cos}$ is the cosine similarity.
$S^a$ in Eq.~\ref{eqn:act} will only score high if $R$ has a segment act flow as well as a topic closed to $U$.
\paragraph{Content Features.}
Retrieval with segment act features only might miss dialogues that discussed similar contents as $U$ but speakers communicated in a different way to $U$.
Therefore, we retrieve from ActDial{} again but using features with regard to the content of $U$.
We use RoBERTa-large \cite{DBLP:journals/corr/abs-1907-11692}, a pre-trained language models, to extract the content feature of any dialogue $D$.
We first feed the raw text of $D$ into RoBERTa and take the $l$-th layer representation $L^l_D\in\mathbb{R}^{m\times d}$ of RoBERTa, where $l$ is a hyper-parameter, $m$ is the number of tokens in $D$ and $d$ is the hidden size of RoBERTa.
$L^l_D$ is then max-pooled along the $m$ dimension to obtain a fixed-length content feature vector $\bar{L}^l_D\in\mathbb{R}^{d}$ for $D$.
Having the content feature $L^l_U$ of $U$ and $L^l_R$ of $R$ in ActDial{}, we define a content-based similarity metric $S^c$ for the second-round retrieval to retrieve $k_c$ nearest neighbors $\{R_i\}_{k^c}$:
\begin{equation}
\label{eqn:content}
S^c(U,R)=\cos (L^l_U,L^l_R)
\end{equation}
$S^c$ in Eq.~\ref{eqn:content} will output a high score if $R$'s content is closed to $U$.
The final retrieved set of dialogues will be $\{R_i\}_k=\{R_i\}_{k^a}\bigcup\{R_i\}_{k^c}$.
\subsection{Assessment}
\begin{comment}
\begin{figure}
\begin{center}
\includegraphics[scale=0.47]{figure/Assessment.pdf}
\end{center}
\caption{
\label{fig:assessment}
Assess the retrieved dialogues by Eq.~\ref{eqn:f}, \ref{eqn:fi}, \ref{eqn:fc} to get the final score.
}
\end{figure}
\end{comment}
We define a metric to find the closest $R^{*}\in\{R_i\}_k$ to $U$ by treating this small retrieved set $\{R_i\}_k$ as pseudo-references.
The distance between $R^{*}$ and $U$ will be the final score of $U$.
Concretely, we have the following scoring function $F$:
\begin{equation}
\label{eqn:f}
F(U)=\max_{R\in\{R_i\}_k}w F^a(U,R)+(1-w) F^c(U,R)
\end{equation}
\begin{align}
\label{eqn:fi}
F^a(U,R)&=S^a(U,R)\cdot\mathrm{BLEU}(A_U,A_R)\\
\label{eqn:fc}
F^c(U,R)&=\mathrm{BERTScore}(U,R)
\end{align}
where $w$ is a hyper-parameter between 0 and 1.
Eq.~\ref{eqn:f} assess $U$ from two aspects:
$F^a$, computed by Eq.~\ref{eqn:fi}, indicates whether speakers in $U$ interact naturally and is evaluated by ActBERT in Eq.~\ref{eqn:act} and BLEU score \cite{papineni-etal-2002-bleu} of the raw segment act flow $A_U$;
$F^c$, on the other hand, measures how natural sentences in $U$ are using BERTScore \cite{DBLP:conf/iclr/ZhangKWWA20} in Eq.~\ref{eqn:fc}.
\section{Related Works}
\label{sec:related-works}
\subsection{Automatic Dialog Evaluation Metrics}
\label{related:auto-metrics}
RUBER \citep{DBLP:conf/aaai/TaoMZY18} combines a reference-based metric and a reference-free metric where the reference-free metric is learned by an RNN-based model to judge if a response is appropriate for the dialogue history.
GRADE \citep{DBLP:conf/emnlp/HuangYQLL20} adopts the graph structure to represent dialogue topics and enhances the utterance-level contextualized representations with topic-level graph representations to better evaluate the coherence of dialogues.
DynaEval \citep{DBLP:journals/corr/dynaeval} reaches the highest correlation with human evaluation on FED dataset \citep{DBLP:journals/corr/fed}, by utilizing the Graph Convolutional Network to capture the dependency between dialogue utterances.
FED \citep{DBLP:journals/corr/fed} measures 18 different qualities of dialogues by computing the likelihood of DialoGPT \citep{DBLP:journals/corr/dialogpt} generating corresponding handwritten follow-up utterances.
In addition to commonly-used dialogue context, Flow score \citep{li-etal-2021-conversations} takes into account the semantic influence brought by each utterance, which is defined to be the difference between the dense representations of two adjacent dialogue histories.
Flow score employs special tasks to promote a better modeling of semantic influence during pretraining.
It correlates best with human evaluation on the DSTC9 dataset \citep{DBLP:journals/corr/dstc9}.
Different from Flow score and other related works, our method explicitly models the segment acts of a dialog, which deliver clear and interpretable functions for each utterance segment, rather than dense representations.
\subsection{Dialog Act in Dialogue Systems}
\label{related:segment-act}
Dialog act \citep{DBLP:journals/corr/switchboard, shriberg-etal-2004-icsi} and similar concepts, like intent \citep{hemphill-etal-1990-atis, larson-etal-2019-intent-oos}, have been widely studied in the past decades.
\citet{walker-passonneau-2001-date} construct a dialog act tagging scheme and evaluate travel planning systems \cite{Walker2001DARPACD} based on standalone dialog acts, rather than dialog act sequences.
This tagging scheme, while provides more detailed information compared with previous works, only focuses on the system side in a task-oriented setting and may need major modifications when applied to open-domain dialogues.
After the initial flourish, recent works come with their own definitions and tagsets for dialog act, tailored for different scenarios or special needs \citep{DBLP:journals/corr/multiwoz, DBLP:journals/corr/midas}.
In this work, we propose segment act, an extension of dialog act to the utterance segment level, and design its corresponding tagset. Our segment-focused arrangement can not only cover the diverse scenarios of open-domain dialogues, but also provide finer-grained information for dialogue evaluation than prevailing dialog act designs.
\subsection{Consensus-Based Methods}
\label{related:consensus}
Consensus-based methods have been adopted in image captioning \citep{DBLP:journals/corr/DevlinGGMZ15,wang2017diverse,deshpande2019fast} and evaluation \citep{DBLP:journals/corr/cider, DBLP:journals/corr/CIDEr-R}.
\citet{DBLP:journals/corr/DevlinGGMZ15} retrieve nearest neighbors in the sense of image feature and use them as consensus.
They later take the caption that has the best word overlap with the consensus as the generation results and achieve competitive performance against other caption generation techniques.
Consensus-based Image Description Evaluation (CIDEr) \cite{DBLP:journals/corr/cider} measures the similarity of a generated caption against a set of human-written sentences using a consensus-based protocol.
Our proposed method shares similar element as it also involves evaluating by the closeness to a consensus of human sentences.
However, to the best of our knowledge, this is the first work that adapts the consensus-based evaluation to dialogues.
|
{'timestamp': '2022-02-15T02:41:41', 'yymm': '2202', 'arxiv_id': '2202.06633', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06633'}
|
arxiv
|
\section{Introduction}
In recent years, tuning the frozen large-scale pre-trained language model (PLM) attracts a lot of attention in the natural language processing area. We have witnessed a lot of remarkable works, including Prefix tuning~\cite{li-liang-2021-prefix}, Adapter tuning~\cite{pmlr-v97-houlsby19a,pfeiffer-etal-2020-adapterhub,pfeiffer-etal-2021-adapterfusion} and Prompt tuning~\cite{liu2021gpt,lester2021power}. Without updating the original parameters of the large PLM, these parameter efficient tuning methods can achieve comparable or even better performance than fully fine-tuning, leading to more flexible and efficient applications of such models. However, one can notice that most of them only focus on language-only tasks.
In this work, we introduce a novel perspective to extend the parameter efficient PLM tuning to the cross-modal vision-and-language generation scenario. Our goal is to tune the frozen large PLMs with images, so that PLMs can generate captions based on the visual information with the help of their remarkable language generation ability~\cite{radford2018improving,radford2019language,brown2020language}. The most similar work is the ClipCap model~\cite{mokady2021clipcap}, which transforms the images into the fixed-length prefix embeddings and adopts the same method as Prefix tuning to tune the frozen GPT2-large model~\cite{radford2019language}. However, the image captioning performance of ClipCap is less attractive, which cannot make full use of the power of large PLM. Therefore, how to leverage the great language generation ability of a frozen PLM effectively for captions generation is still an under-explored problem.
\begin{figure}
\centering
\includegraphics[height=6cm]{ITuning.pdf}
\caption{\textbf{An overview of our I-Tuning framework} for Image Captioning. The PLM module can be the attention module, feedforward module or the whole transformer layer. We investigate how to tune the pre-trained language model for image captioning without updating its parameters.}
\label{fig:overview}
\end{figure}
To fill up such gap, we propose a novel method, \textbf{I-Tuning} (Image-Tuning, see Figure~\ref{fig:overview}). For Prefix tuning and Adapter tuning, PLMs leverage the task-specific knowledge in the Prefix embeddings or the Adapter modules to adjust their output hidden states, so that the PLMs can adapt to different downstream tasks without updating their pre-trained parameters. However, there exists a misalignment problem between the language and the vision modals, hindering us directly embedding the extra visual knowledge in PLMs. To solve this problem, we are inspired by the idea of Memory Network~\cite{NIPS2015_8fb21ee7}. The visual information of Images is extracted by the state-of-the-art pre-trained model, CLIP-ViT~\cite{radford2021learning} and treated as the fixed visual memory. The \textbf{I-Tuning} module serves as a cross-modal filter that picks the visual information from the visual memory to adjust the output hidden states of each PLM layer. Beyond this, we also propose I-Tuning Dropping, removing the I-Tuning modules in the first few layers to further reduce the computational overhead during training and inference.
Evaluating on the image captioning tasks (MSCOCO~\cite{lin2015microsoft} and Flickr30k~\cite{plummer2016flickr30k}), \textbf{I-Tuning} can outperform the baseline systems without vision-and-language pre-training (VLP). After small-scale VLP, \textbf{I-Tuning} achieves comparable or even better performance than the baseline VLP systems which have 2-4 times more trainable parameters and/or consume millions of distinct VLP images. In addition, we show that \textbf{I-Tuning} are agnostic to the PLMs (e.g., base, medium, large), which makes our method broadly applicable.
Our contributions can be summarized as follows:
\begin{itemize}
\item We propose a novel method, \textbf{I-Tuning} to tune the frozen large PLMs with images for captions generation.
\item We conduct extensive experiments to corroborate the effectiveness of our \textbf{I-Tuning} method.
\item Evaluating on the image captioning tasks, \textbf{I-Tuning} achieves comparable or even better performance than the baseline systems which consume much more computational resources.
\end{itemize}
\section{The I-Tuning Framework}\label{sec:framework}
In this part, we make a detailed illustration of our \textbf{I-Tuning}. First, we review the parameter efficient tuning and its relation with \textbf{I-Tuning} in section~\ref{sec:recap}. Beyond this, we introduce the structure of our framework in section~\ref{sec:structure}. Finally, we present our training objective in section~\ref{sec:objective}.
\subsection{The Recap of Parameter Efficient Tuning}\label{sec:recap}
Since 2019, the number of parameters in the PLMs are scaling from millions to trillions~\cite{NEURIPS2020_1457c0d6,shoeybi2020megatronlm,fedus2021switch,zeng2021pangualpha}. Fine-tuning such gigantic PLMs on the downstream tasks consumes a huge amount of computational resources, which is not affordable for most researchers and companies. To leverage such PLMs, people come up with several parameter efficient tuning methods to adapt the PLMs on the downstream tasks without updating the pre-trained parameters~\cite{pmlr-v97-houlsby19a,pfeiffer-etal-2020-adapterhub,pfeiffer-etal-2020-mad,pfeiffer-etal-2021-adapterfusion,li-liang-2021-prefix,liu2021ptuning,liu2021gpt,lester2021power}. Though these previous methods have different forms, \citet{he2022unified} indicate that all of them can be unified as a simple composition function:
\begin{equation}
h \gets h + \Delta h,
\end{equation}
where $h$ is the output hidden states of a PLM module. The difference between different methods is how to inject the extra information into the frozen PLMs through $\Delta h$. Our \textbf{I-Tuning} framework follows the same paradigm to inject the visual information into large PLMs efficiently, so that the frozen PLMs can generate captions of given images.
\subsection{Model Structure}\label{sec:structure}
\noindent\textbf{Overview.}\indent For our framework, given an image $v$, a visual encoder first generates the visual memory embeddings $V_M$. Then the frozen PLM is tuned by the \textbf{I-Tuning} modules based on $V_M$.\\
\noindent\textbf{Visual Encoder and PLMs.}\indent In our framework, we adopt the state-of-the-art vision pre-trained model, CLIP-ViT~\cite{radford2021learning} to generate the visual memory embeddings $V_M$ of an image. Such model takes a sequence of image patches as input and visual representations for each patch as output. Since it has extraordinary visual recognition ability, it is widely used in the previous cross-modal vision-and-language works~\cite{dou2021empirical,shen2021clip,mokady2021clipcap,luo2022vcgpt}. Our framework can benefit from the excellent visual representation ability of CLIP-ViT.
For the PLMs, we leverage the state-of-the-art auto-regressive PLM, GPT2~\cite{radford2019language}, which is a multi-layer Transformer Decoder model~\cite{NIPS2017_3f5ee243}. Pre-trained with a large amount of text data, it shows remarkable language generation ability.\\
\begin{figure}
\centering
\includegraphics[height=7cm]{ITCross.pdf}
\caption{An illustration of the cross attention memory network.}
\label{fig:cross_memory}
\end{figure}
\noindent\textbf{I-Tuning Module.}\indent In our framework, the \textbf{I-Tuning} module is the key component to align the cross-modal information, which is parallel to a specific PLM module (attention, feedforward or whole layer) in each layer. It is a bottleneck neural network, sharing a similar structure as the Adapter module~\cite{pfeiffer-etal-2020-adapterhub}, but the non-linear activation function is replaced by a cross-attention memory network (see Figure~\ref{fig:cross_memory}). The calculation process is as follows:
\begin{align}
Q &= W_{down}^Q(X) + b^Q,\\
K &= W_{down}^K(V_M) + b^K,\\
V &= W_{down}^V(V_M) + b^V,
\end{align}
where $X$ is the input hidden states of a specific PLM module. Then we can get the attention scores across the visual memory embeddings:
\begin{equation}
S = softmax(QK^T).
\end{equation}
Based on the scores, we can get the final \textbf{I-Tuning} output to adjust the output hidden states of the PLM module:
\begin{equation}
\Delta h = \lambda W_{up}^O\left(\sum_{i}s_iV_{Mi}\right)+b^O,
\end{equation}
where $\lambda$ is a scaling hyper-parameter, introduced by \citet{hu2021lora}.
Since the lower layers of PLMs have weaker representation ability~\cite{jawahar-etal-2019-bert,ruckle2021adapterdrop}, we also propose \textbf{I-Tuning Dropping} to remove the \textbf{I-Tuning} modules in the first-few layers (see Figure~\ref{fig:ITuningDrop}). As a result, backpropagating through fewer layers can further improve the training efficiency of our models.
\begin{figure}
\centering
\includegraphics[height=5cm]{ITuningDrop.pdf}
\caption{Standard I-Tuning vs. I-Tuning w/ Dropping. The left model includes I-Tuning module at every layer whereas the right model has I-Tuning module dropped at the first N layers}
\label{fig:ITuningDrop}
\end{figure}
\subsection{Training Objective}\label{sec:objective}
The training objective is the auto-regressive language modeling conditioned on the visual information:
\begin{equation}
\mathcal{L}_{ar}=-\Sigma_{t=1}^T\log P(x_t|x_{<t}, V_{M}),
\end{equation}
where $V_{M}$ represents the visual memory embeddings encoded by CLIP-ViT, T denotes the length of a sequence and $x_{<t} = (x_0,...,x_{t-1})$. The probability of the token in the $t^{th}$ position is determined by all the past tokens and $V_{M}$.
\section{Experiments}
In this section, we conduct extensive experiments to examine the effectiveness of our \textbf{I-Tuning}. Specifically, we first explore how to design and train our models without VLP in section~\ref{sec:woVLP}. Then we compare our models with the previous works with/without VLP in section~\ref{sec:compare}.
\subsection{Setup}
\noindent\textbf{Default Model Configuration.}\indent In our experiments, we adopts CLIP-ViT B/16\footnote{\url{https://huggingface.co/openai/clip-vit-base-patch16}} pre-trained model as our visual encoder and GPT2 pre-trained model as our language decoder. CLIP-ViT contains 12 transformer layers with 768 model size and 12 attention heads. For GPT2, we include 4 different model sizes, including GPT2-distill\footnote{\url{https://huggingface.co/distilgpt2}}(6 layers), GPT2-base\footnote{\url{https://huggingface.co/gpt2}}(12 layers), GPT2-medium\footnote{\url{https://huggingface.co/gpt2-medium}}(24 layers) and GPT2-large\footnote{\url{https://huggingface.co/gpt2-large}}(36 layers). The number of parameters are ranging from 82M to 774M. For the \textbf{I-Tuning} modules, we initialize their parameters randomly. The other model parameters details can be seen in the Appendix.\\
\noindent\textbf{Datasets.}\indent For VLP, we use a small-scale cross-modal datasets, Visual Genome\footnote{\url{http://visualgenome.org/}} which contains 110k distinct images and 5.4M captions. For evaluation, we choose to use two different datasets, including MSCOCO Captions\footnote{\url{https://cocodataset.org/\#home}} and Flickr30k.\footnote{\url{http://hockenmaier.cs.illinois.edu/DenotationGraph/}} In these two datasets, each image corresponds to 5 different captions. We follow the standard Karpathy’s split~\cite{karpathy2015deep} to split 113.2k/5k/5k and 29.8k/1k/1k images for train/val/test, respectively. We adopt 4 standard evaluation metrics to evaluate the generated captions, including CIDEr~\cite{vedantam2015cider}, BLEU@4~\cite{papineni-etal-2002-bleu}, METEOR~\cite{banerjee-lavie-2005-meteor} and SPICE~\cite{anderson2016spice}. For simplicity, we also denote CIDEr as C, BLEU@4 as B@4, METEOR as M and SPICE as S.\\
\noindent\textbf{Implementation Details.}\indent For all the experiments, the parameters of CLIP-ViT and GPT-like models are frozen. We train our models with the AdamW optimization algorithm~\cite{loshchilov2019decoupled}, 4k batch size, mixed-precision training and FP16. For VLP, our models are pre-trained with 10 epochs. For training on downstream tasks, our models are trained with 30 epochs. We also adopt the linear learning rate decay strategy. The warm-up step is set to 10\% of the total training steps. For inference, we use the beam search (beam size = 5) to generate captions. Each image is resized into the size of 288x288 with center-crop. The other hyper-parameters can be found in the Appendix. All experiments are conducted on 8 NVIDIA A100 GPUs.\\
\noindent\textbf{Baseline System.}\indent To evaluate our method comprehensively, we include several previous works in the comparison. The first type is the works that do not use any VLP, including NBT~\cite{lu2018neural}, SGAE~\cite{yang2018autoencoding}, AoANet~\cite{huang2019attention}, BUTD~\cite{anderson2018bottomup}, GVD~\cite{zhou2019grounded} and ClipCap~\cite{mokady2021clipcap}. The last one, ClipCap shares a similar idea as ours, which parameter efficiently tunes GPT2-large with Prefix-tuning. The second type is the works with VLP, including OSCAR~\cite{li2020oscar}, Unified VLP~\cite{zhou2019unified}, XGPT~\cite{xia2020xgpt}, UNICORN~\cite{yang2021crossing}, VL-BART/T5~\cite{pmlr-v139-cho21a} and VC-GPT~\cite{luo2022vcgpt}. All of these VLP models contain 2-4 times more trainable parameters than ours and/or consume a large amount of cross-modal pre-training data. Beyond this, we also include the performance of the state-of-the-art VLP model, SimVLM~\cite{wang2021simvlm}, as our upper bound, which is pre-trained with 1.8B un-publicly cross-modal datasets.
\subsection{Exploration without VLP}\label{sec:woVLP}
Since pre-training is time-consuming, we perform exploration on how to design and train our models without cross-modal pre-training. We use the GPT2-base as our basic language decoder. All models are trained with the MSCOCO training set and evaluated on the MSCOCO validation set.
\subsubsection{Where to Place the I-Tuning Module?}
\begin{table}
\centering
\begin{tabular}{l|cccc}
\hline
\multirow{2}{*}{\textbf{PLM Module}} & \multicolumn{4}{c}{\textbf{MSCOCO (val)}}\\
& \textbf{C} & \textbf{B@4} & \textbf{M} & \textbf{S}\\
\hline
Attention & 109.1 & 32.9 & \textbf{27.6} & 20.6\\
Feedforward & \textbf{110.3} & \textbf{33.6} & \textbf{27.6} & \textbf{20.7}\\
Whole Layer & 109.4 & 33.4 & \textbf{27.6} & 20.4\\
\hline
\end{tabular}
\caption{If the \textbf{I-Tuning} module is parallel to the Feedforward PLM module, it achieves the best performance.}
\label{tab:plm_module}
\end{table}
In a Transformer layer of the PLMs, there are two different sub-networks, Attention and Feedforward. Then, there are three ways for us to place our \textbf{I-Tuning} module in each layer: (1) parallel to Attention; (2) parallel to Feedforward; (3) parallel to the whole layer.
Table~\ref{tab:plm_module} compares these three different designs empirically. Placing the \textbf{I-Tuning} module parallel to Feedforward in each layer achieves the best performance, which is also inline with~\citet{he2022unified}. Such design can be considered as a special MoE network~\cite{fedus2021switch} without gating. The original Feedforward is a single-modal expert and the \textbf{I-Tuning} module is a cross-modal expert. In the following experiments, we choose this design as our default setting.
\subsubsection{Scaling Factor and Image Resolution}
\begin{figure}
\centering
\includegraphics[height=5cm]{scalar.pdf}
\caption{Comparison different scalar factors for \textbf{I-Tuning} on MSCOCO. When the scalar is set to 4, our model achieves the best overall performance.}
\label{fig:scalar}
\end{figure}
In this part, we intend to examine two tricks in our \textbf{I-Tuning} module. First, \citet{hu2021lora} and \citet{he2022unified} indicate that multiplying the output hidden states of the tuning module by a scaling factor ($\lambda \geq 1$) leads to better performance. We compare different scaling factors for our models. Figure~\ref{fig:scalar} reveals that setting the scaling factor to 4 achieves the best overall performance.
\begin{figure}
\centering
\includegraphics[height=5cm]{resolution.pdf}
\caption{Increasing the image resolution degenerates model performance.}
\label{fig:resolution}
\end{figure}
The second trick is for image resolution. \citet{dou2021empirical} find that increasing the image resolution can boost their model performance on downstream tasks. Similar results are also discussed by \citet{yuan2021volo,kim2021vilt,luo2022vcgpt}. To examine this trick, we compare different image resolutions for our models. Figure~\ref{fig:resolution} indicates that increasing the image resolution degenerates our model performance. The possible reason is that the pre-training resolution of CLIP-ViT is different from ours. We need to first interpolate the position embeddings of CLIP-ViT. However, the parameters of the frozen vision encoder cannot be updated to adapt to the interpolation. As a result, increasing the image resolution leads to larger gaps. Therefore, we chose to use the smallest image size (288x288) as our default setting.
\subsubsection{Scaling Law}
\begin{table}
\centering
\begin{tabular}{l|cccc}
\hline
\multirow{2}{*}{\textbf{GPT2}} & \multicolumn{4}{c}{\textbf{MSCOCO (val)}}\\
& \textbf{C} & \textbf{B@4} & \textbf{M} & \textbf{S}\\
\hline
Distill & 105.3 & 32.0 & 27.3 & 20.5\\
Base & 115.5 & 34.7 & 28.4 & 21.4\\
Medium & 119.4 & \textbf{35.6} & 28.9 & 21.9\\
Large & \textbf{119.6} & 35.5 & \textbf{29.4} & \textbf{22.2}\\
\hline
\end{tabular}
\caption{Scaling up GPT2 leads to better overall performance.}
\label{tab:gpt2}
\end{table}
According to the scaling law of neural language model~\cite{kaplan2020scaling}, larger PLMs have better performance and are much more sample efficient. We examine such law in our cross-modal setting. We adopt four different sizes of the GPT2 model, including GPT2-Distill,\footnote{GPT2-Distill is pretrained with the supervision of GPT2-Base with the OpenWebTextCorpus of Huggingface.} GPT2-Base, GPT2-Medium and GPT2-Large. Table~\ref{tab:gpt2} indicates that scaling up frozen GPT2 can lead to better overall performance. Especially, the performances of Medium and Large are already comparable to some VLP models after pre-training.
\subsubsection{I-Tuning Dropping}
\begin{figure}
\centering
\includegraphics[height=5cm]{ITDrop.pdf}
\caption{Dropping the \textbf{I-Tuning} modules in the first-N layers of GPT2-Large.}
\label{fig:Dropping}
\end{figure}
\begin{table*}[h!]
\small
\centering
\begin{tabular}{l|c|c|cccc|cccc}
\hline
\multirow{2}{*}{\textbf{Model}} & \multirow{2}{*}{\textbf{\#Images}} & \multirow{2}{*}{\textbf{\#Params}} & \multicolumn{4}{c|}{\textbf{MSCOCO (test)}} & \multicolumn{4}{c}{\textbf{Flickr (test)}}\\
& & & \textbf{C} & \textbf{B@4} & \textbf{M} & \textbf{S} & \textbf{C} & \textbf{B@4} & \textbf{M} & \textbf{S}\\
\hline
\hline
\multicolumn{9}{l}{{\textit{\color[HTML]{C0C0C0} Upper Bound}}}\\
\hline
{\color[HTML]{C0C0C0} SimVLM$_{base}$} & {\color[HTML]{C0C0C0} 1.8B} & {\color[HTML]{C0C0C0} 220M} &{\color[HTML]{C0C0C0}134.8} & {\color[HTML]{C0C0C0}39.0} & {\color[HTML]{C0C0C0}32.9} & {\color[HTML]{C0C0C0}24.0} & {\color[HTML]{C0C0C0}-} & {\color[HTML]{C0C0C0}-} & {\color[HTML]{C0C0C0}-} & {\color[HTML]{C0C0C0}-}\\
\hline
\hline
\multicolumn{9}{l}{\textit{Without vision-and-language pre-training}}\\
\hline
\textbf{NBT (with BBox)} & 0 & 144M & 107.2 & 34.7 & 27.1 & 20.1 & 57.5 & 27.1 & 21.7 & 15.6\\
\textbf{SGAE} & 0 & 126M & 116.7 & 36.9 & 27.7 & 20.9 & - & - & - & -\\
\textbf{AoANet} & 0 & 87M & 119.8 & 37.2 & 28.4 & 21.3 & - & - & - & -\\
\textbf{GVD (with BBox)} & 0 & 58M & - & - & - & - & 62.3 & 27.3 & 22.5 & 16.5\\
\textbf{BUTD} & 0 & 52M & 113.5 & 36.2 & 27.0 & 20.3 & 56.6 & 27.3 & 21.7 & 16.0\\
\textbf{ClipCap}(GPT2-Large) & 0 & 43M & 113.1 & 33.5 & 27.5 & 21.1 & - & - & - & -\\
\hline
\hline
\multicolumn{9}{l}{\textit{With vision-and-language pre-training}}\\
\hline
\textbf{OSCAR$_{base}$} & 4M & 86M & 123.7 & 36.5 & 30.3 & 23.1 & - & - & - & -\\
\textbf{Unified VLP} & 3M & 86M & 117.7 & 36.5 & 28.4 & 21.3 & 67.4 & 30.1 & 23.0 & 17.0\\
\textbf{XGPT} & 3M & 86M & 120.1 & 37.2 & 28.6 & 21.8 & 70.9 & 31.8 & 23.6 & 17.6\\
\hline
\textbf{UNICORN} & 200k & 86M & 119.1 & 35.8 & 28.4 & 21.5 & 70.1 & 30.7 & 23.7 & 17.4\\
\textbf{VL-BART} & 180k & 86M & 116.6 & 35.1 & 28.7 & 21.5 & - & - & - & -\\
\textbf{VL-T5} & 180k & 172M & 116.5 & 34.5 & 28.7 & 21.9 & - & - & - & -\\
\textbf{VC-GPT} & 110k & 262M & 127.7 & 37.3 & 30.1 & 23.8 & 79.6 & 31.2 & 25.8 & 20.1\\
\hline
\hline
\multicolumn{9}{l}{\textit{Our Models w/o VLP}}\\
\hline
\textbf{I-Tuning}(GPT2-Base) & 0 & 14.2M(5.7\%) & 116.7 & 34.8 & 28.3 & 21.8 & 61.5 & 25.2 & 22.8 & 16.9\\
\textbf{I-Tuning}(GPT2-Medium) & 0 & 44.1M(8.6\%) & 120.0 & 35.5 & 28.8 & 22.0 & 72.3 & 28.8 & 24.6 & 19.0\\
\textbf{I-Tuning}(GPT2-Large) & 0 & 94.5M(9.7\%) & 119.4 & 34.8 & 29.3 & 22.4 & 75.4 & 29.8 & 25.1 & 19.2\\
\hline
\multicolumn{9}{l}{\textit{Our Models w/ VLP}}\\
\hline
\textbf{I-Tuning}(GPT2-Base) & 110k & 14.2M(5.7\%) & 118.3 & 35.2 & 28.5 & 22.0 & 68.4 & 27.5 & 24.0 & 18.4\\
\textbf{I-Tuning}(GPT2-Medium) & 110k & 44.1M(8.6\%) & 119.1 & 34.8 & 29.2 & 22.2 & 73.2 & 29.1 & 25.2 & 19.9\\
\textbf{I-Tuning}(GPT2-Large) & 110k & 94.5M(9.7\%) & \textbf{122.2} & 35.9 & \textbf{29.5} & \textbf{22.6} & 77.2 & 30.0 & \textbf{25.5} & \textbf{20.2}\\
\hline
\multicolumn{9}{l}{\textit{Our Models w/ I-Tuning Dropping}}\\
\hline
\textbf{I-Tuning}(GPT2-Large) & 110k & 47.2M(4.8\%) & 122.1 & \textbf{36.1} & 29.4 & \textbf{22.6} & \textbf{79.2} & \textbf{31.1} & 25.3 & 19.9\\
\hline
\end{tabular}
\caption{Comparisons with previous models on MSCOCO and Flickr Image Captioning. \textbf{Bold} indicates the best score of our I-Tuning models. \underline{\#Images} represents the number of distinct images during VLP. \underline{\#Params} represents the number of trainable parameters. For our I-Tuning models, the number in ``(xxx\%)'' represents the percentage of trainable parameters to the total number of parameters. All models are fine-tuned with cross-entropy loss.}
\label{tab:previous_work_comparsion}
\end{table*}
Since the lower layers of PLMs have weaker representation ability, we investigate whether we can drop the \textbf{I-Tuning} modules in the first few layers. In this part, we focus on the GPT2-Large, which is a 36-layer model. If we place the \textbf{I-Tuning} module in each layer, the number of trainable parameters is up to 94.5M. Though this number is far less than the total number of parameters (974M), removing the \textbf{I-Tuning} module in the first-few layers still can reduce the computational overhead.
Figure~\ref{fig:Dropping} indicates that dropping the \textbf{I-Tuning} modules in the first-18 layers has little negative effects on the image captioning performance, while the number of trainable parameters is reduced by 50\% (from 94.5M to 47.2M). This further improves the efficiency of our models during training and inference.
\subsection{Comparing with Previous Works}\label{sec:compare}
In section~\ref{sec:woVLP}, we conduct an extensive exploration of our \textbf{I-Tuning} method without VLP. In this part, we compare with the previous works to verify the effectiveness of our method. All results are reported on the test sets.
\subsubsection{Quantitative Evaluation}
Table~\ref{sec:compare} reveals that our method achieves comparable or even better performance than the baseline systems which contains 2-4 times more trainable parameters and/or consume much more VLP data.
Compared with ClipCap, it shares a similar idea as ours to tune the PLM in a parameter efficient manner, but one can notice that our method with GPT2-Base already outperforms ClipCap with GPT2-Large. For our model with \textbf{I-Tuning Dropping}, it only contains 47.2M trainable parameters, but it can retain the same level of performance as its counterpart without dropping.
All quantitative results corroborate the effectiveness of our method to leverage the great language generation power of the frozen GPT-like models.
\subsubsection{Qualitative Evaluation}
\begin{table*}[h!]
\tiny
\centering
\begin{tabular}{l|llll}
\hline
\textbf{Image} &
\begin{minipage}[b]{0.4\columnwidth}
\centering
\raisebox{-.5\height}{\includegraphics[width=\linewidth]{coco1.pdf}}
\end{minipage}
&
\begin{minipage}[b]{0.4\columnwidth}
\centering
\raisebox{-.5\height}{\includegraphics[width=\linewidth]{coco2.pdf}}
\end{minipage}
&
\begin{minipage}[b]{0.4\columnwidth}
\centering
\raisebox{-.5\height}{\includegraphics[width=\linewidth]{coco3.pdf}}
\end{minipage}
&
\begin{minipage}[b]{0.4\columnwidth}
\centering
\raisebox{-.5\height}{\includegraphics[width=\linewidth]{coco4.pdf}}
\end{minipage}
\\
\hline
\hline
\textbf{Ground Truth}
&
\begin{tabular}[c]{@{}l@{}}
(1) A man with a red helmet on a\\
small moped on a dirt road.\\
(2) Man riding a motor bike on a\\
dirt road on the countryside.\\
(3) A man riding on the back of\\
a motorcycle.\\
\end{tabular}
&
\begin{tabular}[c]{@{}l@{}}
(1) A young girl inhales with the\\
intent of blowing out a candle.\\
(2) A young girl is preparing to\\
blow out her candle.\\
(3) Girl blowing out the candle\\
on an ice-cream\\
\end{tabular}
&
\begin{tabular}[c]{@{}l@{}}
(1) A man on a bicycle riding next\\
to a train.\\
(2) A person is riding a bicycle but\\
there is a train in the background.\\
(3) a red and white train and a man\\
riding a bicycle\\
\end{tabular}
&
\begin{tabular}[c]{@{}l@{}}
(1) A kitchen is shown with a variety\\
of items on the counters.\\
(2) A kitchen has the windows open\\
and plaid curtains.\\
(3) A kitchen with two windows and\\
two metal sinks.\\
\end{tabular}
\\
\hline
\hline
\textbf{Model} &\multicolumn{4}{c}{\textbf{Generated Caption}}\\
\hline
\begin{tabular}[c]{@{}l@{}}
\textbf{ClipCap}\\
(GPT2-Large)\\
\end{tabular}
&
\begin{tabular}[c]{@{}l@{}}
a man is riding a motorbike on\\
a dirt road.\\
\end{tabular}
&
\begin{tabular}[c]{@{}l@{}}
a young girl {\color{blue}sitting} at a table\\
with a cup of cake.\\
\end{tabular}
&
\begin{tabular}[c]{@{}l@{}}
a man is {\color{blue}standing} next to a train.
\end{tabular}
&
\begin{tabular}[c]{@{}l@{}}
a kitchen with {\color{blue}a} sink and {\color{blue}a} window\\
\end{tabular}
\\
\hline
\textbf{OSCAR}$_{base}$
&
\begin{tabular}[c]{@{}l@{}}
a man riding a motorcycle down\\
a dirt road.\\
\end{tabular}
&
\begin{tabular}[c]{@{}l@{}}
{\color{blue} a woman sitting at a table with}\\
{\color{blue} a plate of food}.
\end{tabular}
&
\begin{tabular}[c]{@{}l@{}}
a {\color{blue} woman} riding a bike down a\\
street next to a train.\\
\end{tabular}
&
\begin{tabular}[c]{@{}l@{}}
a kitchen with {\color{blue}a} sink, dishwasher\\
and {\color{blue}a} window\\
\end{tabular}
\\
\hline
\begin{tabular}[c]{@{}l@{}}
\textbf{I-Tuning}\\
(GPT2-Large)\\
\end{tabular}
&
\begin{tabular}[c]{@{}l@{}}
A man riding a motorcycle on\\
a dirt road.\\
\end{tabular}
&
\begin{tabular}[c]{@{}l@{}}
A little girl blowing out a\\
candle on a birthday cake.\\
\end{tabular}
&
\begin{tabular}[c]{@{}l@{}}
A man {\color{blue}standing} next to a train\\
on a train track.\\
\end{tabular}
&
\begin{tabular}[c]{@{}l@{}}
A kitchen sink sitting under a window\\
next to a window.\\
\end{tabular}
\\
\hline
\end{tabular}
\caption{Image captioning examples of our \textbf{I-Tuning} (GPT2-Large, w/ VLP), OSCAR and ClipCap for the first 4 images in the MSCOCO test set. {\color{blue} Blue} indicates that such caption or word is inaccurate, after comparing with the ground truth.}
\label{tab:generated_example}
\end{table*}
\begin{figure*}
\centering
\includegraphics[height=4cm]{vis.pdf}
\caption{Visualization of the cross-attention maps in the final \textbf{I-Tuning} module (GPT2-Large) of text tokens in the caption ``A woman in a blue shirt holding a racquet.". (\textbf{Lighter = Higher Attention Score})}
\label{fig:visualization}
\end{figure*}
Table~\ref{tab:generated_example} presents the image captioning examples of our \textbf{I-Tuning}, OSCAR and ClipCap for the first 4 images in the MSCOCO test set. As can be seen, the generated captions of \textbf{I-Tuning} depict the image successfully. Compared with the baseline systems, our work can identify the movement of the people in the image. For example, our model can recognize that the little girl is blowing the candles, while ClipCap and OSCAR cannot. However, one can notice that our method cannot recognize the bike in the third image. The same error also exists in ClipCap. The possible reason is that the bike is mixed with the man in the image, which is hard for models to recognize.
\section{Visualization}
In this section, we visualize the cross-attention maps in our \textbf{I-Tuning} to examine whether it learns the cross-modal alignment implicitly. We randomly choose an image in the MSCOCO dataset and present the cross-attention heatmaps in the final \textbf{I-Tuning} model of GPT2-Large. In Figure~\ref{fig:visualization}, our \textbf{I-Tuning} module can correctly attend to the corresponding regions given different tokens. These examples reveal that our method can learn visual grounding implicitly.
\section{Related Work}
Recently, we have witnessed that the model size of a PLM becomes larger and larger, which makes us hard to fully fine-tune such models. To make use of them without updating the pre-trained parameters, researchers have come up with several great works, including Prefix tuning~\cite{li-liang-2021-prefix}, Adapter tuning~\cite{pmlr-v97-houlsby19a,pfeiffer-etal-2020-adapterhub,pfeiffer-etal-2020-mad,pfeiffer-etal-2021-adapterfusion,wang-etal-2021-k,zhang2021unsupervised} and Prompt tuning~\cite{liu2021gpt,liu2021ptuning,lester2021power,he2022protum,zhang2022differentiable}. All of them provide effective methods to adapt the frozen PLMs on the downstream tasks. However, most of them only focus on the natural language processing area. Our \textbf{I-Tuning} extends the parameter efficient PLM tuning idea to the cross-modal setting.
In addition, the most similar works are proposed by \citet{mokady2021clipcap} and \citet{tsimpoukelli2021multimodal}. Both of them extend the Prefix tuning into the cross-modal setting. However, their models are less competitive on the image captioning tasks. \citet{li-liang-2021-prefix} also points out that directly optimizing the prefix is very sensitive to the learning rate and the parameter initialization. Therefore, we choose not to design \textbf{I-Tuning} based on the Prefix tuning.
Beyond this, there is an explosion of works about cross-modal vision-and-language pre-training~\cite{zhou2019unified,li2020oscar,xia2020xgpt,pmlr-v139-cho21a,wang2021simvlm,dou2021empirical,luo2022vcgpt}. Most of them focus on how to train a cross-modal from scratch, but the goal of our work is to parameter efficiently tune the PLMs with images for captions generation.
\section{Conclusion}
In this paper, we present \textbf{I-Tuning} for parameter efficient tuning PLMs with images for captions generation. Extensive experiments are conducted on how to design and train our framework. Evaluating on the image captioning tasks, \textbf{I-Tuning} achieves comparable or even better performance than the previous works which contain 2-4 times more trainable parameters and/or consume much more cross-modal pre-training data.
|
{'timestamp': '2022-02-15T02:39:44', 'yymm': '2202', 'arxiv_id': '2202.06574', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06574'}
|
arxiv
|
\section{Application}
\label{sec:application}
This section presents the applications of our filtering framework, including a proof-of-concept data cleaning toolbox and a high-quality code search dataset.
\subsection{\emph{NLQF}\xspace: Natural Language Query Filter}
We release the implementation of our filtering framework as a third-party Python library, \underline{N}atural \underline{L}anguage \underline{Q}uery \underline{F}ilter (\emph{NLQF}\xspace), which is designed to systemically filter queries for neural code search models.
As a lightweight library with convenient APIs, \emph{NLQF}\xspace can be easily integrated into the development pipeline of any code search model. Besides, \emph{NLQF}\xspace is extensible at several features to ensure its applicability in a wide range of contexts:
\noindent\textbf{Extensible Ruleset} The ruleset in \emph{NLQF}\xspace is configurable, which enables users to specify the rules based on the characteristics of their own data. Besides, \emph{NLQF}\xspace accepts user-defined functions as a part of rule-based filtering. One can easily extend the filter implementation by creating the filtering function for any new rule.
\noindent\textbf{Open-source Filtering Model} \emph{NLQF}\xspace requires a trained VAE model in the model-based filter. We release the source code for training the VAE model used in this paper. Following the instructions, users can easily train a new model with their own bootstrap query corpus\xspace, which may boost the filtering performance further.
\noindent\textbf{Tunable Dividing Proportion} Besides the recommended clustering method, EM-GMM, \emph{NLQF}\xspace also provides an interface accepting user-defined dividing points. Users can create their own method for finding the dividing point and configure \emph{NLQF}\xspace to adopt it easily.
\subsection{\emph{COFIC}\xspace: Codebase Paired with Filtered Comments}
We build and release a \underline{Co}debase paired with \underline{Fi}ltered \underline{C}omments (\emph{COFIC}\xspace) for Java programming language.
\subsubsection{Dataset Building}
We collect the source code of Java repositories from Github according to the list maintained by Libraries.io~\cite{Nesbitt2017LibrariesioOS},
From these files, we extract the methods and corresponding comments using the scripts provided by CodeSearchNet~\cite{Husain2019CodeSearchNetCE}.
In the end, 2,475,692 raw comment-code pairs are obtained.
Through the processing with \emph{NLQF}\xspace, there are 1,048,519 data points left in the cleaned query-code dataset.
Detailed statistics of the dataset during filtering are reported in~\Cref{tab:change}.
\begin{table}[t]
\caption{The statistics during the data filtering.}
\input{tables/change}
\label{tab:change}
\end{table}
\begin{table}[t]
\caption{A comparison between the training datasets for code search tasks.}
\begin{center}
\input{tables/comparison}
\end{center}
\label{tab:comparison}
\end{table}
\subsubsection{Dataset Comparison}
We compare \emph{COFIC}\xspace, on the query quality, with several other datasets currently used in neural code search research.
Following the same manual inspection convention as in~\cref{sec:re2}, the annotators rate the queries sampled from each dataset, reported in~\cref{tab:comparison}. Again, we measure the agreement level between the two annotators with Cohen's Kappa, which is 0.73 and within the range of fair to good.
Among all the datasets collected from Github, \emph{COFIC}\xspace receives the highest score on data quality, but there is still a gap compared with the StackOverflow dataset, StaQC.
Indeed, the datasets collected from StackOverflow have high-quality queries, but they suffer from the unstable code quality in answers\cite{Terragni2016CSNIPPEXAS,Zhang2018AreCE}.
With our filtering framework, a Github dataset with better quality is established.
Besides the user study, we also experimentally compare \emph{COFIC}\xspace with CSN-t. We train the DeepCS and CARLCS models with three datasets: CSN-t, \emph{COFIC}\xspace, and a controlled \emph{COFIC}\xspace (same size as CSN-t).
The model trained with \emph{COFIC}\xspace outperforms other experimental settings on the three validation datasets (CSV-v, CB, and NCSED).
The detailed results are reported in \Cref{tab:cofic}.
\begin{table*}[t]
\setlength\tabcolsep{2.3pt}
\caption{The results of the experimental comparison between COFIC and CSN-t.}
\begin{center}
\input{tables/cofic}
\end{center}
\label{tab:cofic}
\end{table*}
\section{The Data Cleaning Framework}
\label{sec:approach}
\begin{figure}[t]
\centerline{\includegraphics[width=7cm]{figs/filter_process.pdf}}
\caption{An overview of our data cleaning framework.}
\label{fig:process}
\end{figure}
This section introduces our automated and effective data cleaning framework for code search datasets, mainly to filter out query-code pairs with inappropriate queries.
The framework consists of two subsequent filters, the \emph{rule-based syntactic filter} and \emph{model-based semantic filter}.
An overview of the framework, when applied to clean the comment-code pairs collected from Github, is shown in~\cref{fig:process}.
The raw comment-code pairs are firstly cleaned by the rule-based filter, where a ruleset is applied to detect the existence of invalid query syntax.
Next, for the model-based filter, leveraging a small bootstrap query corpus\xspace as the semantics reference, a VAE model is trained to model its characteristics and further used to reject comments violating the natural query semantics.
Here we collect the bootstrap query corpus\xspace (no need of the paired code snippets) from StackOverflow, and more details can be found in~\cref{sec:dataset}.
Such, we take advantage of both the Github and StackOverflow data sources and produce a large set of high-quality query-code pairs.
In the following, we elaborate on the design of the two filters.
\subsection{The Rule-based Syntactic Filter}
\label{sec:rule}
Code comments contain richer information than just descriptions on code functionalities and manifest various syntactic features rarely existing in actual code search quires.
For example, URLs are used for external references, and HTML tags are used in comments for documentation autogeneration.
To reduce such deviations from natural queries, we sampled 1\% code comments from CodeSearchNet, manually inspected and summarized noises in these 3,949 instances.
We establish a black list of invalid syntax features to reject unqualified code comments.
If a comment matches any of these features, we remove the invalid parts if they are detachable; otherwise, we abandon this comment-code pair.
Based on a comparative observation of code comments and user queries, we develop a set of rules to precisely identify synthetically inappropriate queries and leave the fine-grained semantic check to the model-based filter.
To facilitate the management, we define three criteria that the ruleset must comply with: 1) any rule should define a unique and specific construction pattern, 2) the rules should be conservative and limit the preclusion of valid queries within an acceptable range, and 3) any rule is not a subrule of other rules in the set.
As a plug-in framework, the ruleset is extensible, and any rules that meet these criteria can be appended to the set.
We introduce the syntax features covered by our ruleset in the following, and their examples can be found in~\cref{tab:definations}.
We empirically decide whether to keep the content enclosed by a feature structure or not and validate the decisions with experiments (see our website~\cite{hqtd} for more details) and manual inspection (see~\Cref{sec:re2}).
From the results, our decisions help improve the naturalness and bring greater improvement to the model performance.
\noindent\textbf{HTML tags} HTML tags are used for documentation autogeneration in comments and should not appear in user queries. However, the content wrapped by the tags can still be informative.
Therefore, we remove the HTML tags from the comments but keep the wrapped content.
\noindent\textbf{Parentheses} Parentheses in comments are for adding supplementary information and do not appear in user queries. Due to such purpose, the removal of the content inside the parentheses does not have much influence on the completeness of the comments. We only retain the content outside of the parentheses.
\noindent\textbf{Javadoc tags} Javadoc tags starting with an ``@'' sign are special tags indicating a Javadoc comment. Such comments are only consumed by the Javadoc project for autogenerating well-formatted documentation. Considering that the special syntax of the tags may mislead code search models on natural language understanding, we reject all comments containing Javadoc tags.
\noindent\textbf{URLs} URLs in comments provide external references to relevant code snippets, but natural language queries do not contain any URLs. We reject all comments containing URLs.
\noindent\textbf{Non-English Languages} Non-English expressions exist as developers from different countries may write comments in their first languages. However, current code search models are not designed to handle multi-languages. We reject all non-English comments.
\noindent\textbf{Punctuation} Sometimes, punctuation symbols are used for section partitioning in the comments.
For example, developers use a row of equal signs ($=$) or asterisks signs ($*$) (see examples in~\cref{tab:definations}) to indicate a new section.
For effectiveness, we reject comments containing no English letters in our implementation.
\noindent\textbf{Interrogation} Based on our observation, some of the comments in the dataset are interrogative. Developers seem to use comments to communicate with their collaborators during the code review process.
There may be some sparse information about the code functionality, but the quality is hard to control.
We reject comments ending with a question mark.
\noindent\textbf{Short Sentence} The sentence length is a commonly used criterion for comment filtering.
Extremely short comments are not informative enough for code search models to establish their mapping to the corresponding code snippets.
We reject comments containing no more than two words.
\subsection{The Model-based Semantic Filter}
\label{subsection:model-filter}
This section introduces the model-based semantic filter, which takes the initially cleaned comment-code pairs from the rule-based filter as input and further selects the pairs with comments semantically close to the queries in a pre-collected bootstrap query corpus\xspace.
We present the detailed design of the VAE model and discuss how it is used for filtering.
\subsubsection{The VAE Model}
The two main components of a VAE model are the encoder and decoder, which are generally composed of deep neural networks.
Here, we use Gated Recurrent Unit (GRU)~\cite{Cho2014LearningPR} for both the encoder and decoder in our VAE model.
GRU is a variant of Recurrent Neural Network (RNN), which enables the model to capture information from sequential texts. \cref{fig:overview} illustrates an overview of the design of the model structure. Details about each layer are as follows.
\begin{figure}[t]
\centerline{\includegraphics[width=9cm]{figs/model.pdf}}
\caption{The structure of the Variational Auto-Encoder in the model-based filter. The dashed lines denote the propagation of hidden states in neural cells.}
\label{fig:overview}
\end{figure}
\textbf{Embedding} Given a query $w_0w_1\dots w_n$ of length $n$, the $i$-th token is $w_i$.
The embedding layer is responsible for mapping each token into an embedding vector.
It consists of an embedding matrix $\textbf{E} \in \mathbb{R}^{o_w \times d}$, where $o_w$ is the vocabulary size of the query language and $d$ is the dimension of embedding vectors.
The matrix is initialized with random values and updated during training.
\textbf{GRU Encoder} We design the encoder of VAE as a bi-directional GRU.
Sequentially, it deals with the input tokens, and propagates the upstream and downstream context through the hidden states, respectively in the forward and backward directions, as shown in~\cref{eq:encoder-forward} and~\cref{eq:encoder-backward}.
$emb$ maps a token to its embedding vector.
Finally, we sum up the last hidden states of both directions to get the final hidden state, as in~\cref{eq:encoder-sum}, and pass it to the next layer.
\begin{align*}
\overrightarrow{\textbf{h}_{i}} &= \overrightarrow{GRU}(emb(w_{i}), \overrightarrow{\textbf{h}_{i-1}}) \numberthis \label{eq:encoder-forward} \\
\overleftarrow{\textbf{h}_{i}} &= \overleftarrow{GRU}(emb(w_{i}), \overleftarrow{\textbf{h}_{i+1}}) \numberthis \label{eq:encoder-backward}\\
\textbf{h} &= \overrightarrow{\textbf{h}_{n}} + \overleftarrow{\textbf{h}_{n}} \numberthis \label{eq:encoder-sum}
\end{align*}
\textbf{Latent Variable} Based on the hidden state \textbf{h} from the encoder, we estimate the parameters of a Gaussian distribution with a fully-connected layer, which are the mean vector $\bm{\mu}$ and variance vector $\bm{\sigma}^2$.
The latent variable $\textbf{z}$ is randomly sampled from this distribution.
The equations are as follows:
\begin{align*}
\bm{\mu};\bm{\sigma^2} &= FC(\textbf{h})\\
\textbf{z} &= \bm{\mu} + \textbf{r} \cdot \textbf{e}^{\bm{\sigma^2} / 2}
\end{align*}
where $FC$ is a fully-connected layer and $\textbf{r}$ is a random vector from the standard normal distribution.
\textbf{GRU Decoder} The latent variable represents the key features of the original input in a highly abstract and compact way.
The decoder works to reconstruct the input solely based on the latent variable. Iteratively, the decoder computes the hidden state $s_i$ at each step $i$ and reconstructs token $w_i'$, based on the previous state $s_{i-1}$ (or $\textbf{z}$ at step 0) and $w_{i-1}'$ generated in the previous step.
The equations are as follows:
\begin{align*}
\textbf{s}_{i} &=
\begin{cases}
GRU(emb(bos),\textbf{z})) & \text{i=0}\\
GRU(emb(w_{i-1}'),\textbf{s}_{i-1})) & \text{i\textgreater{}0}
\end{cases} \\
p_i &= FC(\textbf{s}_i)\\
w_i' &= argmax(p_i)
\end{align*}
where $bos$ is a special token indicating the start of a sentence, and $p_i \in \mathbb{R}^{o_w}$ represents the probability of $i$-th token to be generated.
\textbf{Loss} We measure the likelihood of reconstructing the original input with the Cross-Entropy (CE) loss. Hence, the ELBO loss introduced in \cref{sec:vae} can be computed as:
\begin{equation}
\mathcal{L} = - \frac{1}{n}\sum_{i=1}^{n}CELoss(w_i,w_i') + KLDivergence(\bm{\mu},\bm{\sigma}^2) \nonumber
\end{equation}
where $CELoss$ and $KLDivergence$ represents the calculation of the CE loss and KL divergence.
\subsubsection{The Filtering Algorithm}
\label{sec:trend}
We train the VAE model with a set of high-quality code search queries collected from near-real scenarios, which we call the bootstrap query corpus\xspace.
After the training, the VAE model is able to recognize whether a query semantically resembles those in the corpus.
We measure the reconstruction loss, i.e., the CE loss, of an input when fed to the VAE model, which just reflects how well it is within the training set distribution.
Intuitively, the loss value is the anomaly score gauging how far an input stays away from the queries in bootstrap query corpus\xspace.
Comments with smaller losses are more likely to be query-appropriate.
To select comments resembling queries in bootstrap query corpus\xspace, we sort the comments based on their reconstruction losses, in ascending order, and retain the top-ranked ones.
It is tricky to decide an appropriate dividing point for retaining the portion with better quality and discarding the remaining.
The less data we keep from the top, the higher the dataset quality.
However, a sharp reduction in the data size hinders the performance of the trained code search model.
\cref{fig:trend} shows a theoretical model illustrating the relation between the dividing point and the model performance.
As the amount of retained data increases, the model performance firstly increases and then decreases after reaching the peak.
There is a trade-off between the quality and quantity of the dataset.
\begin{figure}[t]
\centerline{\includegraphics[width=5cm]{figs/trend.pdf}}
\caption{An illustration of the relation between the portion of retained data and the performance of the code search model trained with it.}
\label{fig:trend}
\end{figure}
We leverage an unsupervised clustering algorithm, EM-GMM (Expectation-Maximization for Gaussian Mixture Model)~\cite{Dempster1977MaximumLF}, to decide the partition automatically.
It is widely used to model the mixed distributions of a dataset.
For our task, EM-GMM divides a set of comments into the qualified and the unqualified groups based on the reconstruction loss. For each group, GMM fits a Gaussian probability density function and mixes them together as the distribution of the whole dataset, which can be represented as:
\begin{align*}
P(x) = \pi N(x|\mu_q,\sigma_q) + (1-\pi)N(x|\mu_{uq},\sigma_{uq})
\end{align*}
where $\pi$ is the mixture coefficient for the qualified group, ($\mu_q,\sigma_q$) and ($\mu_{uq},\sigma_{uq}$) are the parameters for the Gaussian probability density functions of the qualified and unqualified groups, respectively.
Finally, the EM algorithm~\cite{Dempster1977MaximumLF} is applied to estimate a set of optimal values for all the parameters.
Note that, to establish a high-quality code search dataset, all comments are processed together with their paired code snippets.
Hence, we obtain a set of comment-code pairs after applying this semantic filter, where the comments are syntactically and semantically close to natural user queries.
\section{Conclusion}
\label{sec:conclusion}
We propose the first data cleaning framework for code search tasks, which improves the quality and naturalness of the queries.
The framework leverages two subsequent filters, the rule-based syntactic filter, and the model-based semantic filter.
The rule-based filter uses configurable heuristics rules to filter out comments with syntactic anomalies.
The model-based filter aims to refine the dataset semantically.
It trains a VAE model over a pre-collected bootstrap query corpus\xspace, and exploits it to select comments with smaller reconstruction losses. Experiments show that our filtering framework can significantly save computing resources and improve the model accuracy.
Finally, we release our framework as a Python library \emph{NLQF}\xspace and make public a high-quality cleaned code search dataset \emph{COFIC}\xspace, to facilitate relevant research in academia and industry.
\flushend
\bibliographystyle{ACM-Reference-Format}
\section{Experiment setup}
\begin{table*}[h]
\setlength\tabcolsep{2.8pt}
\caption{The Answered@k and MRR scores of the DeepCS and CARLCS models trained over different datasets.
}
\centering
\input{tables/rq1-results}
\label{tab:rq1_deepcs}
\end{table*}
\label{sec:experiment-setup}
We introduce the research questions, the basic experimental setup about the datasets and models, and the evaluation metrics used throughout the evaluation. The research questions we aim to answer include:
\noindent \textbf{RQ1:} How effective is our data cleaning framework?
\noindent \textbf{RQ2:} What is the impact of each filter component and each rule on the effectiveness of our framework?
\noindent \textbf{RQ3:} How is the dividing point determined by the clustering algorithm during the model-based filtering?
\subsection{Datasets}
\label{sec:dataset}
Three types of datasets are involved in our evaluation, including the training and validation datasets used to train and assess the performance of code search models and the bootstrap query corpus\xspace used to develop our model-based filter.
To make the best use of existing resources, we focus on the Java programming language in this work, for which there have been the most public datasets and models in the field of neural code search.
Theoretically, our framework is language-independent and applicable to other programming languages with a proper adaptation of the filtering rules.
\subsubsection{Training Datasets}
We use the popular CodeSearchNet (CSN)~\cite{Husain2019CodeSearchNetCE} dataset to train all the code search models.
CSN is a collection of datasets and benchmarks for semantic code retrieval.
It extracts functions and their paired comments from Github repositories.
It covers six programming languages, and we take the training dataset for Java, which contains 394,471 data points.
We took the first sentence of each comment.
In what follows, we denote it as \textbf{CSN-t}.
Another widely used dataset in DeepCS~\cite{Gu2018DeepCS} is not included because the authors only released the processed data, but our framework cannot work without accessing the raw data.
\subsubsection{Validation Datasets}
We utilize human-annotated validation datasets to evaluate how well a code search model performs in a real-world scenario, and three widely used datasets are adopted.
It is noteworthy that the validation datasets are \emph{never} filtered by our framework in order to ensure the fairness of our experiments.
They are listed as follows:
\begin{itemize}[leftmargin=*]
\item \textbf{CSN-v} CSN also offers a validation benchmark for Java, containing query-code pairs collected from Bing and StackOverflow.
Human annotators are hired to rate the relevance between the query and the code.
Pairs with a score greater than $0$ are deemed as relevant, and there are 434 relevant pairs in total.
In the dataset, each pair is accompanied by 999 distractor code snippets.
It means, given a query, the code search model needs to retrieve the ground truth among 1000 candidates.
\item \textbf{CB} CosBench (CB)~\cite{Yan2020AreTC} is a validation dataset consisting of 52 selective queries from StackOverflow.
For each query, the authors prepared around ten paring code snippets as its ground truths, including its best answer on StackOverflow and several other matched code snippets selected from GitHub.
Additionally, there is a pool of 4,199,769 distractor code snippets.
The model needs to search the ground truths from a mixture with the complete code pool given a query.
\item \textbf{NCSED} Proposed in~\cite{Li2019NeuralCS}, the NCSED dataset contains 287 question queries manually collected from StackOverflow.
For each query, there are around three pairing code snippets selected from GitHub.
The ground truths are mixed with other 4,716,814 distractor code snippets collected from GitHub.
The search model is required to retrieve the ground truths from the large corpus for a query.
\end{itemize}
The extremely
large search space in NCSED and CB makes it extremely hard for code search models to achieve a good performance, and the performances variations brought by data cleaning can also be too marginal to compare. Without loss of generality, for each query in NCSED and CB,
we construct 999 distractor snippets, following a similar fashion as CSN-v.
\subsubsection{Bootstrap Query Corpus} StackOverflow is an ideal source for collecting resemblers of actual user queries, though the quality of the pairing code snippets is hard to guarantee.
It becomes an optimal choice to establish the bootstrap query corpus\xspace.
We surveyed existing StackOverflow datasets in the code search field, and found that they were of severely limited size.
With their aim to collect high-quality question-code pairs, numerous questions were discarded due to the lack of qualified code answers.
Hence, to better facilitate the training of our VAE model, we determined to construct a question-only corpus from StackOverflow instead of using existing ones.
According to a study~\cite{Nasehi2012WhatMA}, the StackOverflow questions can be divided into four types: ``Debug/Corrective'', ``Need-To-Know'', ``How-To-Do-It'' and ``Seeking-Different-Solution''. Among them, questions of the ``How-To-Do-It'' type are most relevant to queries for the code search task.
Aiming to select the most qualified resemblers, we require the question titles to 1) start with ``how to'', 2) be tagged with ``Java'', and 3) pass the rule-based syntactic filter proposed in~\Cref{sec:rule} (except for the Interrogation rule).
In the end, 168,779 out of 1,709,703 Java-related question titles were retained.
Afterwards, we transformed them into declarative sentences by removing the starting ``how to'' and the question marks if any, thus forming the bootstrap query corpus\xspace, which is used to train the VAE model later.
\subsection{Code Search Model}
Two code search models, DeepCS~\cite{Gu2018DeepCS} and CARLCS~\cite{Shuai2020ImprovingCS}, are used in our experiments.
They are designed with representative architectures among most neural code search models.
DeepCS is based on the Siamese architecture, and CARLCS is an Interaction-based network~\cite{mitra2018introduction}.
The Siamese architecture consists of two DL models to represent the query and code, respectively, with independent embedding vectors, and the similarity between these vectors is used to measure the relevance between query and code.
The Interaction-based network compares the query and code directly by generating an interaction matrix to reflect their relevance.
When training the models with our training dataset, we adopted the recommended settings for all the hyper-parameters, except for the training epoch of the DeepCS model.
In order to save some time and computation resources, we set the maximum training epoch of DeepCS to 100 instead of the recommended 500.
Without loss of fairness, the same setting has been used for training with the dataset either before or after the data cleaning.
This change should not affect the evaluation conclusion on the effectiveness of our framework, which focuses more on whether the model performance improves after removing the noises instead of its absolute level.
\subsection{Evaluation Metrics}
Two widely used metrics are adopted in our experiments to evaluate the code retrieval performance.
\begin{itemize}[leftmargin=*]
\item \textbf{Answered@k}: Answered@k (abbrev. A@k) is the number of queries answered by snippets in the top-k results.
\item \textbf{Mean Reciprocal Rank (MRR)}: MRR is the average of the reciprocal ranks of the ground truth in the result list.
\end{itemize}
\section{Results}
\label{sec:results}
In this section, we show the experimental results and answer the research questions.
Measures for both evaluation metrics are reported as the medium over five independent runs.
\subsection{RQ1: Effectiveness}
\label{sec:rq1}
This experiment evaluates the effectiveness of our data cleaning solution as a pre-processing step when training neural code search models.
Specifically, one training dataset (CSN-t), two code search models (DeepCS and CARLCS), and three validation datasets (CSN-v, CB, and NCSED) are used in the evaluation.
Thus, we have six $(1 \times 2 \times 3)$ experimental settings in total.
During experiments, a relatively smaller filtered training set will be derived from CSN-t after our framework is applied for the data cleaning.
To also benchmark the performance variation brought by the size shrinking, we further derive a controlled training set by randomly selecting from CSN-t an equivalent number of data as the filtered set.
We observe the model performance resulted from training with these three datasets respectively.
The model performance is measured with four evaluation metrics, namely, A@1, A@5, A@10, and MRR, and the results are shown in~\Cref{tab:rq1_deepcs}.
Under all the six experimental settings, our data cleaning framework demonstrates a positive influence on the model's searching ability and helps it hit the best score.
On average of the three validation datasets, DeepCS trained over the filtered data outperforms the one trained over original data by 21.3\% A@1, 17.4\% A@5, 7.8\% A@10, and 19.2\% MRR.
Correspondingly, the improvements of CARLCS are 63.3\% A@1, 58.6\% A@5, 16.0\% A@10, and 38.6\% MRR.
Regarding the MRR on the three validation datasets, CSN-v,CB, and NCSED, DeepCS achieves 0.512, 0.644 and 0.271, and CARLCS achieves 0.302, 0.056 and 0.168, respectively.
Basically, DeepCS and CARLCS are boosted to their new best records, and CARLCS sees a greater improvement.
Note that the A@1 score of CARLCS over NCSED is increased by 75.0\% (from 20 to 35), which is an extraordinary improvement.
Overall, with around half of the data quantity and half of the training time, models trained over the filtered data achieve a significant improvement on the number of answered queries and the rank of ground truth in search results.
\begin{tcolorbox}[size=title]
{\textbf{Answer to RQ1:}}
Our filtering framework produces a high-quality query-code dataset, which shortens the training time by reducing the training data and effectively improves the performance of the code search model under a real-world application scenario.
\end{tcolorbox}
\begin{table*}[t]
\caption{Results of the ablation experiments on the filter components.
}
{
\setlength\tabcolsep{2.8pt}
\begin{center}
\input{tables/merged-rq2-results}
\end{center}
}
\label{tab:rq2}
\end{table*}
\subsection{RQ2: The impact of each filter component and each rule}
\label{sec:re2}
We evaluate the effectiveness of each filter component with ablation experiments and conduct manual inspection on the queries accepted/rejected by each syntactic rule and the model-based filter to study their precision in identifying noises.
Each time, one of the two filter components is muted for the ablation experiments.
We observe the model performance after training with such derived filtered dataset and compare it with their previous performance (in \Cref{sec:rq1}).
If the performance declines compared with when both filters are enabled, we can infer a positive impact of the muted component on the framework effectiveness.
We evaluate the performance of DeepCS and CARLCS trained under ablation and report the results in~\Cref{tab:rq2}.
The removal of any filter leads to worse performance scores.
Without the model-based filter, the A@1, A@5, A@10, and MRR scores of DeepCS on the three validation sets reduce by 5.4\%, 5.6\%, 3.6\%, and 4.6\% on average. CARLCS sees a much more severe deduction, and on average, A@1, A@5, A@10, and MRR decrease by 35.5\%, 18.7\%, 10.4\%, and 20.6\%.
After removing the rule-based filter, the performance of DeepCS averagely drops by 8.4\% A@1, 6.4\% A@5, 5.2\% A@10, and 7.6\% MRR. Meanwhile, the average reduction percentages of CARLCS on all the validation sets are 32.7\% A@1, 15.5\% A@5, 9.9\% A@10, and 14.3\% MRR.
It is noteworthy that the A@1 score of CARLCS on NCSED drops from 35 to 18 when the rule filter is muted, indicating that the ruleset plays a very influential part during the data cleaning.
For the manual inspection, two annotators, with over two years' development experience, are hired to rate how likely a sentence is to be used as a code search query.
The rating score ranges from 0 to 2, where 0 means worst and 2 best.
There are 11 groups of data to annotate, including eight groups of comments rejected by each rule, the group of comments discarded by the model filer, the original CSN-t dataset, and the filtered dataset after the two-filter cleaning.
The last two groups are for comparison purposes.
For rules focusing on detachable features, i.e., the Parentheses and HTML tags, we let the annotators judge how well the removed part can help with a query expression.
We sample a subset of data from its full set for each group.
The sample size $ss$ of each group is computed by a statistical formula which is extracted from \cite{cochran1977sampling},
$
ss = \frac{z^2*p*(1-p)/c^2}{1+\frac{z^2*p*(1-p)/(c^2-1)}{population}},
$
where $population$ is the size of the entire dataset, $p$ is the standard deviation of the population, $c$ is the confidence interval (margin of error), $z$ is the Z-Score determined by the confidence level. In this experiment, we choose to work with a 95\% confidence level (i.e., 1.96 Z-Score according to \cite{israel1992determining}), a standard deviation of 0.5 (0.5 is the maximum standard deviation, and a safe choice given the exact figure unknown), and a confidence interval of 5\%.
We also measure the agreement between the two annotators with Cohen's Kappa~\cite{Cohen1960A}, which is 0.69 and within the range of fair to good.
For each data, we finalize its score as the average of scores from the two annotators and display the statistics in \Cref{tab:rq4}.
We report the number of data examined in each group, the respective portion of data scored as 0 or no less than 1, and the group's average score, in the last four columns.
In general, the comments rejected by either the rule-based filter or the model-based filter poorly resemble real user queries, with 96.9\% and 85.9\% of them receiving a score of 0 and the average scores being as low as 0.04 and 0.20, respectively.
Still, it comes at an acceptable cost of losing a small set of good quality data, where 3.1\% and 14.1\% of the discarded data by the two filters score at least 1.
Each of the eight rules rejects code comments in an effective way, with four of them rejecting non-query-like data at 100\% precision.
The precision of the Parentheses rule is relatively low, where 11\% of the discarded data is of high quality.
In the future, when deciding whether the content inside the parentheses should be removed, a more refined rule can be derived.
Also, the model-based semantic filter is accompanied by a larger sacrifice, indicating it as a more challenging task.
\begin{table}[t]
\caption{Results of the manual inspection.}
{
\setlength\tabcolsep{1.7pt}
\begin{center}
\input{tables/manual-evaluation}
\end{center}
}
\label{tab:rq4}
\end{table}
Overall, through the two-phase filtering, the average likeness score increases from 0.27 to 0.61.
In particular, the portion of non-query-like data drops from 79.0\% to 59.2\%, and the portion of highly query-like data scoring at least 1 improves from 21\% to 40.8\%.
There are still many comments inappropriate to be seen as code search queries, but our data cleaning framework makes a substantial contribution to alleviating the situation.
We call for more attention to be drawn to overcoming related challenges.
\begin{tcolorbox}[size=title]
{\textbf{Answer to RQ2:}}
Each filter and rule in our framework demonstrates a positive contribution to the effectiveness.
The full setting boosts it to the best performance.
However, there remain many unqualified comments even after the filtering, and it calls for more attention to be paid from the community.
\end{tcolorbox}
\begin{table*}[t]
\caption{Results of changing the EM-GMM to other methods.}
\setlength\tabcolsep{2.3pt}
\begin{center}
\input{tables/cluster-results}
\end{center}
\label{tab:rq3}
\end{table*}
\subsection{RQ3: Quality of dividing point determined in the model-based filtering}
In the model-based filter, we use EM-GMM to decide the dividing point between the qualified and the unqualified groups.
To assess the quality of the dividing point, we observe the model performance resulting from alternative dividing points, including fix proportions and the one decided by K-means, another widely used clustering algorithm.
For the fixed proportions, we set a 25\% step and select 25\%, 50\%, 75\%, and 100\% top-ranked comments, respectively.
The results on DeepCS and CARLCS are reported in Table~\ref{tab:rq3}.
For DeepCS, EM-GMM outperforms K-means and the fixed proportions on all the validation sets. Compared with the second-best partition, 75\%, EM-GMM still achieves higher average performances by 4.3\% A@1, 4.2\% A@5, 4.3\% A@10, and 3.3\% MRR. The superiority is also observed on CARLCS at every metric, and EM-GMM outperforms K-means on average of CSN-v and NCSED by 30.4\% A@1, 5.9\% A@5, 2.8\% A@10, and 15.0\% MRR.
EM-GMM ultimately retains 192,031 data points, accounting for 67.3\% of the original dataset,
which locates between 57.5\%, the dividing point set by K-means and 75\%.
As discussed in~\Cref{sec:trend}, the relation between the data quantity and the model performance should be a convex function.
According to the property of the convex function, if there exists another optimal dividing point, it would locate between 57.5\% and 75.0\%.
Therefore, EM-GMM successfully identifies an optimal solution of the dividing point with an error less than 9.8\% (calculated by $67.3\%-57.5\%$).
\begin{tcolorbox}[size=title]
{\textbf{Answer to RQ3:}} EM-GMM produces a better approximation of the best dividing point for the datasets and is adequate to be used in the framework.
\end{tcolorbox}
\section{Introduction}
\label{sec:intro}
A semantic code search engine is a vital software development assistant, which significantly improves the development efficiency and quality.
With a description of the intended code functionality in natural language, a search engine can retrieve a list of semantically best-matched code snippets from its codebase.
Recently, deep learning (DL) has been widely applied in this area in view of its advantages in semantic modeling and understanding of languages. In the task of code search, DL models learn and represent the semantic mappings between the natural language and the programming language from query-code pairs.
\begin{figure}[t]
\centerline{\includegraphics[width=0.96\columnwidth]{figs/statistics_new.pdf}}
\caption{Statistics of 394,471 code comments used in CodeSearchNet (Java). The feature definitions are presented in \cref{sec:rule}.}
\label{fig:statistic}
\end{figure}
Like many other DL tasks, code search models are data-hungry and require large-scale and high-quality training datasets.
Nevertheless, collecting a large set of query-code pairs is challenging, where the queries are supposed to be natural expressions from developers and the code to be a valid semantic match.
Instead, considering the scale and availability, code comments are popularly used as an alternative to the queries, many of which describe the core functionalities and with the corresponding code implementation rightly available.
To better understand the quality of datasets hence constructed, we investigated a Github dataset, CodeSearchNet (Java)~\cite{Husain2019CodeSearchNetCE}, which is popularly used in current code search research.
Surprisingly, we found a considerable amount of noise and unnaturalness in the queries of its data samples, which can hinder the training of high-quality models for practical usage.
As shown in~\cref{fig:statistic}, one-third of its queries contain text features (see Table~\ref{tab:definations} for examples of different features) that hardly exist in actual user queries.
The features are summarized based on our observations of the dataset, and may not be sufficient.
Comments may also be used for other purposes, such as copyright and to-do, instead of describing the core functionalities, thus shall not be seen as queries.
The proportion of noise data can be higher than one-third.
Code search models trained with noisy queries will face severe performance degradation when dealing with actual user queries.
The gap between the collected comment-code pairs and the natural user queries violates the basic assumption of learning algorithms that the training data and the evaluation data share a similar distribution.
It is also noteworthy that evaluating the model with a noisy comment-code benchmark can hardly reflect how useful the model would be in practice, and, even worse, may bring non-negligible bias to the model design, evaluation and application.
Many other researchers~\cite{Cambronero2019WhenDL,Ling2020AdaptiveDC,sun2020pscs} also point out the misalignment between code comments and natural user queries, and report it as a threat to the validity of their approaches.
As mentioned in~\cite{Liu2020OpportunitiesAC, zhao2021impact}, improving the quality of the training data is still a research opportunity for machine learning, including DL-based code search models.
Considering that there are still plenty of comments close to actual user queries and naturally paired with high-quality code snippets, a promising solution is to filter out the noisy ones.
Manual filtering can produce the most accurate results but is hardly practical for large-scale datasets.
Automated data cleaning methods are of demanding needs.
Queries for code retrieval possess specific \emph{syntactic} and \emph{semantic} characteristics, which can be utilized as key features to distinguish genuine user queries from noise.
Typical syntactic features include text attributes such as keywords, sentence length, and language type. Semantic features are related to the intention underneath the text expression, which usually describes the computational functionality of code snippets and might be influenced by the design convention of common program APIs.
Compared with syntactic features, semantic features are more abstract, implicit, and hard to be matched by simple rules.
Recently, some initial efforts have emerged on query quality enhancement, but primarily focusing on the regularization of syntactic features.
Simple filtering heuristics are proposed, based on the appearance of verb and noun phrases~\cite{Ling2020AdaptiveDC}, keywords uncommonly used in queries~\cite{Cambronero2019WhenDL}, and constraints on the query length~\cite{Husain2019CodeSearchNetCE,Ling2020AdaptiveDC}.
However, the improvement in data quality is limited.
As declared in~\cite{Husain2019CodeSearchNetCE}, the collected dataset is still noisy despite their data cleaning efforts.
The proposed rules are not sufficient to cover the various syntactic violations, let alone the semantic misalignment.
For example, warning messages such as ``Use of this property requires Java 6'' widely exist in the code comments, but few code queries would request this way.
Hence, a remaining challenge is recognizing the code comments that are syntactically valid but encode semantics rarely seen in natural user queries.
To tackle this challenge, we propose an automated and effective data cleaning framework that distills high-quality queries from generally collected code comments on a large scale.
The framework is orthogonal to the design of code search algorithms and could be integrated with any of them to improve the quality of the training dataset.
Basically, it encompasses two subsequent filters: \emph{a rule-based syntactic filter} and \emph{a model-based semantic filter}.
The rule-based filter includes a set of systematically designed heuristic rules and weeds out data with anomalous syntactic features, e.g., HTML tags and Javadoc tags.
It is developed to cover a diverse range of syntactic violations, and each member inside is validated to reduce the noises effectively.
It is also extensible to fulfill the specific requirements for the dataset based on the applications.
The model-based semantic filter further refines the dataset produced by the rule-based filter and retains the comments that are semantically close to the natural queries.
The filter relies on a bootstrap query corpus\xspace, a set of high-quality queries, which represents how semantically the queries should look.
It learns the semantic features of the corpus, such as the expression style and topic, with a DL model, and leverages it to identify samples with similar semantics.
The bootstrap query corpus\xspace could be constructed with any trusted sources of natural user queries, and we formulate it with question titles from StackOverflow in this work.
These titles are an ideal approximation of natural queries and could be re-used by related studies.
Then, a Variational Auto-Encoder~\cite{Kingma2014AutoEncodingVB} is trained with the bootstrap query corpus\xspace, which maps the inputs into a latent space and attempts to reconstruct the original inputs solely based on the latent features.
The reconstruction loss reflects ``how far away'' an input is from the training data distribution, i.e., the distribution of queries in the bootstrap query corpus\xspace.
The lower the reconstruction loss, the more qualified an input is as a natural query.
We compute the reconstruction loss for each code comment in the raw dataset and cluster them into two groups.
The group of qualified queries is retained for training, and the group of noises is discarded.
\begin{table}[t]
\caption{Examples of syntactic rules.}
\begin{center}
\input{tables/definitions}
\end{center}
\label{tab:definations}
\end{table}
To evaluate the effectiveness of our data cleaning framework, we compare the performance of code search models trained with datasets before and after the filtering.
One training dataset, two neural models, and three manually annotated validation datasets are used in the experiments, and our framework brings a significant performance improvement under all settings.
In particular, the performance of the popular DeepCS~\cite{Gu2018DeepCS} model is improved by 19.2\% MRR and 21.3\% Answer@1, on average with the three validation datasets.
More importantly, with less training data used after the filtering, we also save the training time and computation resources.
Further, we carry out a comprehensive ablation study to validate the usefulness of each filter component and each rule and manually inspect the quality of the rejected and retained data.
Finally, we release the implementation of our framework, \emph{NLQF}\xspace, and a cleaned code search dataset, \emph{COFIC}\xspace, to facilitate future research.
The source code and datasets are available at \url{https://github.com/v587su/NLQF}.
To the best of our knowledge, this is the first systematic data cleaning framework for comment-based code search datasets. Our main contributions include:
\begin{itemize}[leftmargin=*]
\item A two-step data cleaning framework for code search datasets, which bridges the gap between code comments and natural user queries, both syntactically and semantically.
\item Implementation of the framework as a Python library for the code search task in academia and industry.
\item A comprehensive evaluation of our framework's effectiveness, which demonstrates significant model performance improvement on three manually-annotated validation benchmarks.
\item The first systematically distilled Github dataset for neural code search, containing over one million comment-code pairs.
\end{itemize}
\section{Preliminaries}
\label{sec:preliminaries}
We prepare readers with the primary sources for collecting query-code pairs and the Variational Auto-Encoder, a major building block of our framework.
\subsection{Data Source}
\label{sec:data source}
A query for neural code search describes, in natural language, the functionality of the code snippets desired by users, e.g., ``convert string to JSON object''.
The ideal data source for genuine code queries is the production data from existing neural code search engines.
However, these queries are not publicly accessible due to privacy and business sensitivity.
In academia, researchers use texts with similar intentions (e.g., code comments) as a replacement.
The primary alternative data sources for semantic code search research include GitHub and StackOverflow.
\subsubsection{Github}
Github\cite{github} is an open-source community, hosting more than 100 million repositories. It is the most popular platform for developers to share and manage their projects.
The large-scale well-maintained repositories on Github are a treasury for code reuse during development, thus naturally becoming the main retrieval source for code search tasks.
Moreover, mature projects are usually accompanied by canonical development documents.
According to Javadoc\cite{javadoc}, a code comment style guide, the first sentence of doc comments should be a summary sentence. Therefore, it is convenient to construct a code search dataset by collecting the code snippets paired with the first sentence of comments, forming the comment-code pairs. Javadoc-generated comments have hence been widely used in practice for various software engineering purposes~\cite{li2020cda, liu2021identifying, li2018characterising, li2016accessing} due to their large scale, ease of obtaining, and being close to
actual use scenarios.
However, developers write comments for their software projects without considering the retrieval purposes. Not all the comments properly map to queries.
As mentioned in~\cref{sec:intro}, the CodeSearchNet collected from Github contains plenty of anomalies that rarely exist in natural user queries.
It is not appropriate to include these comments in the dataset, and we call for more attention to be drawn to this problem.
\subsubsection{StackOverflow} StackOverflow\cite{stackoverflow} serves as a Q$\&$A community specialized for software developers. It is a rich resource of software-related questions and answers.
When asking about codes or APIs for implementing a specific functionality, users would propose a question title to express their intention.
These are natural user queries with valid syntax and semantics.
Hence, researchers\cite{Yin2018LearningTM,Yao2018StaQCAS} also collect the titles of StackOverflow questions paired with proper answers containing sample code snippets, which also form the query-code pairs.
Others also evaluate their code search models with queries manually selected from StackOverflow~\cite{Cambronero2019WhenDL,Gu2018DeepCS,Liu2020SimplifyingDM}, and additional public evaluation benchmarks could be found in~\cite{Li2019NeuralCS,Yan2020AreTC}.
Compared with the Github data source, queries from StackOverflow have a significant advantage of being closer to natural user queries, but the quality of code samples is hard to guarantee.
Hence, the dataset collected from StackOverflow is still not as desired.
Nevertheless, the query corpus is valuable.
It is worth investigating whether and how it could be leveraged to improve the other query-code datasets.
\subsection{Variational Auto-Encoder}
\label{sec:vae}
Variational Auto-Encoder (VAE)~\cite{An2015VariationalAB} is a neural model that learns the distribution of a set of data. A VAE model consists of an encoder and a decoder.
The encoder learns to map an input data $x$ into a prior distribution $p_\theta(z)$, from which a latent variable $z$ is sampled, and the decoder maps $z$ back to $\hat{x}$, a reconstruction of $x$. It is expensive to calculate $p_\theta(z)$ directly, so VAE introduces an approximate posterior $q_\phi(z|x)$.
$\theta$ and $\phi$ are parameters of the prior and the approximate posterior.
The loss function, Evidence Lower Bound (ELBO), which seeks to maximize the likelihood of reconstructing the original data and minimize the Kullback-Leibler (KL) divergence between the actual and estimated posterior distributions, is represented as:
\begin{equation}
\mathcal{L} = \mathbb{E}_{q_\phi(z|x)}[-logp_\theta(x|z)]
+ KL(q_\phi(z|x)||p_\theta(z)), \label{eq:elbo}
\end{equation}
where $KL$ represents the KL divergence.
Theoretically, the distributions of $q_\phi(z|x)$ and $p_\theta(z)$ can be arbitrary. In practice, the Gaussian distribution is mostly adopted.
\section{Related Work}
\label{sec:related}
\noindent\textbf{Code Search Dataset} Recent years have witnessed a growing interest in the semantic search for code snippets~\cite{kim2018facoy}.
DL models are applied to establish links between natural language and programming language. To train these models~\cite{Gu2018DeepCS,Chen2018ANF,Cambronero2019WhenDL,Wan2019MultimodalAN,Yao2019CoaCorCA,Shuai2020ImprovingCS,Ling2020AdaptiveDC,Ye2020LeveragingCG,Wang2020TranS3AT,Haldar2020AMA,Li2020LearningCI,Qihao2020OCoRAO,Hu2020NeuralJA}, code snippets paired with comments are collected from Github~\cite{Barone2017APC,Gu2018DeepCS,Hu2018DeepCC,Wan2019MultimodalAN,Husain2019CodeSearchNetCE}. According to a manual investigation\cite{pascarella_classifying_2019}, there are 16 categories of comments in source code, most of which, e.g., TODO, License, and Exception, are not appropriate to serve as queries. However, to the best of our knowledge, the comments in code search datasets have never been fully cleaned. For example, Barone et al.~\cite{Barone2017APC} remove empty or non-alphanumeric lines from the docstrings. CodeSearchNet~\cite{Husain2019CodeSearchNetCE} filters each comment-code pair with its comment length. Ling et al.~\cite{Ling2020AdaptiveDC} use heuristic rules (e.g., the existence of verb and noun phrases) to filter comments. Cambronero et al.~\cite{Cambronero2019WhenDL} filter out queries that contain specific keywords. These simple and scattered efforts are not enough to filter out the various noises, especially the texts that are semantically unrelated to real queries. Liu et al.~\cite{Liu2020OpportunitiesAC} also mention that improving the data quality is still a research opportunity for deep-learning-based code search models, which well motivates our work.
There are two evaluation methods for neural code search research: train-test split and actual user query evaluation. A lot of works~\cite{Cambronero2019WhenDL, Shuai2020ImprovingCS,Wang2020TranS3AT,Ye2020LeveragingCG} split their datasets into train and test sets. The queries of their test set contain the same defects as the train set so that the results fail to reflect the model performance in an actual environment.
Manually reviewed queries~\cite{Li2019NeuralCS,Husain2019CodeSearchNetCE,Yan2020AreTC} can overcome this problem but they are usually on a small scale and cannot serve as the training dataset.
\noindent\textbf{Unsupervised Anomaly Detection} Comments cleaning is an application of the unsupervised anomaly detection algorithm as labeled comments are non-trivial to obtain. Unsupervised anomaly detection algorithms identify the outliers solely based on the intrinsic properties of the data instances. Various techniques can be applied, such as Principal Component Analysis~\cite{Wold1987PrincipalCA}, Generative Adversarial Network~\cite{Lawson2017FindingAW}, Spatio Temporal Networks~\cite{Chianucci2016UnsupervisedCD} and LSTM~\cite{Singh2017AnomalyDF}. Among them, Auto-Encoder (AE) is the fundamental architecture for unsupervised anomaly detection~\cite{Sydney2019DeepLF}. It has been applied in many tasks. For example, Zhang et al.~\cite{Zhang2017DetectingRO} detect the rumors in social media using multi-layer AE. Castellini et al.~\cite{Castellini2017FakeTF} apply AE to detect false followers on Twitter. Luo and Nagarajan~\cite{Luo2018DistributedAD} use AE to identify the error events of interest such as equipment faults and undiscovered phenomena in wireless sensor networks.
The encoder of AE maps an input to a point in the latent space, while VAE maps an input to a region. In this way, VAE can extract more abstract semantic features. It has been applied to unsupervised anomaly detection with promising evaluation scores~\cite{An2015VariationalAB,Suh2016EchostateCV, Xu2018UnsupervisedAD, Lin2020AnomalyDF}.
\section{Threats to validity}
\label{sec:threats}
\noindent\textbf{Rule Design} Though our experiments have evaluated the usefulness of each rule in the ruleset; the rule-based filter may still introduce a few false positives or false negatives due to its design and implementation.
For example, the widely used query ``quick sort'' can be filtered out by the rule Short Sentences.
Besides, some rules are tricky to be implemented exactly in line with our aim.
For example, non-English letters in the comments are identified based on ASCII encoding. It may leave out several other languages also using English letters. But no English sentences will be falsely filtered out.
Overall, it requires further exploration on balancing the trade-off between precision and recall better.
\noindent\textbf{Bootstrap Query Corpus} The bootstrap query corpus\xspace in this work is built based on the questions on StackOverflow. Only titles starting with ``how to'' are collected into the corpus, which limits the sentence pattern. The VAE model trained over this corpus may not have a good tolerance to other patterns.
Besides, StackOverflow titles are also not fully query-appropriate.
Although we filter the titles by rules, there are still semantically irrelevant texts left.
\noindent\textbf{Generalization} Limited by the accessibility of models and evaluation benchmarks for code search tasks, we evaluate our solution only on Java datasets. In theory, our approach is capable of any comment-based code search dataset. Yet, the generalization of our filtering framework in different programming languages has not been experimentally verified. Besides, we only evaluate our filtering framework on two code search models, DeepCS and CARLCS, which is also a threat to the generalizability of our approach.
|
{'timestamp': '2022-02-15T02:42:40', 'yymm': '2202', 'arxiv_id': '2202.06649', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06649'}
|
arxiv
|
\section{Introduction}
Detecting keywords represents a crucial task in several text intensive applications. News industry relies on keywords for organization, linking and summarization of articles according to the content and topics they cover. With the current trend of fast-paced type of writing and an ever-growing amount of generated news, it becomes an infeasible task for the journalists to manually extract keywords and the development of tools for automatic extraction has become essential for speeding up the media production.
Keyword extraction can be tackled in a supervised or an unsupervised way. The current supervised state-of-the-art approaches are based on transformer-based \cite{vaswani2017attention} deep neural networks and employ large-scale language model pretraining. Despite being very successful in solving the task, they do require substantial amounts of labeled data which is expensive to obtain or non-existent for some low-resource languages and domains. To cope with this, researchers in most cases employ unsupervised keyword extraction in this low-resource scenarios. Unsupervised approaches require no prior training and can be applied to most languages, making them a perfect fit for domains and languages that have low to no amount of labeled data. On the other hand, they offer non-competitive performance when compared to supervised approaches \cite{martinc2020tnt}, since they can not be adapted to the specific language, domain and keyword assignment regime through training.
In this work, we explore another option for keyword extraction in low-resource settings, which has not been extensively explored in the past, a zero-shot cross-lingual keyword detection. More specifically, we investigate how multilingual pretrained language models, which have been fine-tuned to detect keywords on a set of languages, perform, when applied to a new language not included in the train set, and compare these results to the results achieved by several state-of-the-art unsupervised keyword extractors. In addition, we also investigate whether in a setting, where training data is available, supervised monolingual models can benefit from additional data from another language. The main contributions are the following:
\begin{itemize}
\item
We conduct and extensive zero-shot cross-lingual study of keyword extraction on six languages, four of them less-resourced European languages, and demonstrate that a multilingual BERT model fine-tuned on the training data not matching target language, performs better than state-of-the-art unsupervised keyword extraction algorithms.
\item We evaluate the performance of supervised zero-shot cross-lingual models in comparison to the supervised monolingual models in order to better determine the decrease in the performance when no language specific data is available.
\item We investigate if the performance of monolingual models can be improved by including additional multilingual data and whether there is a trade-off between the amount of data available and the language specificity of this data.
\item We produce new supervised keyword extraction models for a new \textit{Slovenian} dataset for keyword extraction, contributing to the development of new language resources for a less-resourced European language.
\end{itemize}
The rest of this paper is organized in the following way: Section \ref{sec:related_work} presents the related work in the field of keyword extraction, focusing also on the cross-lingual zero-shot learning. Section \ref{sec:data} describes the data used in our experiments and Section \ref{sec:experiments} explains our experimental settings. While Section \ref{sec:discusion} presents and discuses the results of our experiments, Section \ref{sec:conclusion} concludes the paper and proposes further work on this topic.
\section{Related Work}
\label{sec:related_work}
We can divide approaches for keyword extraction into supervised and unsupervised. As stated above, state-of-the-art supervised learning approaches have become very successful at tackling the keyword extraction task but are data-intensive and time consuming. Unsupervised keyword detectors can tackle these two problems and usually require a lot less computational resources and no training data, yet this comes at the cost of the reduced overall performance.
We can divide unsupervised approaches into four main categories, namely statistical, graph-based, embeddings-based, and
language model-based methods. Statistical and graph based methods are the most popular and the main difference between them is that statistical methods, such as KPMiner \cite{el2009kp}, RAKE \cite{rose2010automatic}, and YAKE \cite{yake}, leverage various text statistics to capture keywords, while Graph-based methods, such as TextRank \cite{mihalcea2004textrank}, Single Rank, KeyCluster \cite{liu2009clustering}, and RaKUn \cite{DBLP:journals/corr/abs-1907-06458} build graphs and rank words according to their keyword potential based on their position in the graph. Among the most recent statistical approaches is YAKE \cite{yake}, which we also test in this study. It is based on features such as casing, position, frequency, relatedness to context and dispersion of a specific term, which are heuristically combined to assign a single score to every keyword. KPMiner \cite{el2009kp} is an older, simpler method that focuses on the frequency and the position of appearance of a potential keyphrase. In order to enrich the quality of the retrieved phrases, the model proposes several filtering steps, e.g. removing rare candidate phrases that do not appear at least \textit{n}-times and that do not appear within some cutoff distance from the beginning of the document.
TextRank \cite{mihalcea2004textrank}, which we evaluate in this study, is one of the first graph-based methods for keyword detection. It leverages Google's PageRank algorithm to rank vertices in the lexical graph according to their importance inside a graph. Other method that employs PageRank is PositionRank \cite{florescu2017positionrank}. The so-called MultiPartiteRank algorithm \cite{Multipartite} encodes the potential candidate keywords of a given document into a multipartite graph structure, which also considers topic information. In this graph two nodes, representing keyphrase candidates, are connected only if they belong to different topics and the edges are weighted according to the distance between
the two candidates in the document. In order to rank the verticies, the method leverages PageRank, similarly to \newcite{mihalcea2004textrank}. One of the most recent graph-based keyword extractors is RaKUn \cite{DBLP:journals/corr/abs-1907-06458}. The main novelty in this algorithm is the expansion of the initial lexical graph with the introduction of meta-vertices, i.e., aggregates of existing vertices. It employs \textit{load centrality} measure for ranking vertices and relies on several graph redundancy filters.
Embedding-based keyword extraction methods are less popular but are nevertheless recently gaining traction. The first methods of this type were proposed by \newcite{wang2014corpus}, who proposed Key2Vec \cite{mahata2018key2vec}, and \newcite{bennani-smires-etal-2018-simple}, who proposed EmbedRank. Both of these methods employ semantic information from distributed word and sentence representations. The most recent state-of-the-art method of this type is KeyBERT proposed by \newcite{grootendorst2020keybert}, which leverages pretrained BERT based embeddings for keyword extraction. In this approach, embedding representations of candidate keyphrases are ranked according to the cosine similarity to the embedding of the entire document.
Language model-based keyword methods, such as the ones proposed by \newcite{tomokiyo2003language} use language model derived statistics to extract keywords from text. These type of keyword extraction models are quite rare and are not included in our study.
One of the first supervised approaches to keyword extraction was KEA proposed by \newcite{witten2005kea}. It considers keyword identification as a classification task and employs Naive Bayes classifier to determine for each word or phrase in the text if it is a keyword or not. It uses only TF-IDF and the term's position in the text as classification features. A more recent non-neural supervised approach employs a sequence labelling approach to keyword extraction and was proposed by \newcite{gollapalli2017incorporating}. The approach relies on Conditional Random Field (CRF) tagger. First neural sequence labeling approach was proposed by \newcite{luan2017scientific}, who proposed a neural network comprising of a bidirectional Long Short-Term Memory (BiLSTM) layer and a CRF tagging layer.
Keyword detection can also be considered as a sequence-to-sequence generation task. This idea was first proposed by \newcite{meng2017deep}, who employed a recurrent generative mode with an attention mechanism and a copying mechanism \cite{gu2016incorporating} based on positional information for keyword prediction. What distinguishes this model from others is that besides being able to detect keywords in the input text sequence, it can also potentially find keywords that do not appear in the text.
The most recent approaches tackle keyword detection with transformer architectures \cite{vaswani2017attention} and formulate keyword extraction task as a sequence labelling task. In the study by \newcite{sahrawat2019keyphrase}, contextual embeddings generated using BERT \cite{devlin2019bert}, RoBERTa \cite{liu2019roberta} and GPT-2 \cite{radford2019gpt2} were fed into a bidirectional Long short-term memory network (BiLSTM) with an optional Conditional random fields layer (BiLSTM-CRF). They conclude that contextual embeddings generated by transformer architectures outperform static. Another study employing transformer architecture and sequence labelling approach was conducted by \newcite{martinc2020tnt}. Their approach, named TNT-KID did not rely on massive pretraining but rather on pretraining the transformer based language model on much smaller domain specific corpora. They report good results employing this tactic and claim that this makes their model more transferable to low-resource languages with limited training resources.
Most keyword detection studies still focus on English. Nevertheless, recently several multilingual and cross-lingual studies, which also include low-resource languages, were conducted. On of them is the study by \newcite{koloski-etal-2021-extending} where the performance of two supervised transformer-based models, multilingual BERT with a BiLSTM-CRF classification head and TNT-KID were compared in a multilingual settings, on Estonian, Latvian, Croatian and Russian news corpora. The authors also explored if combining the outputs of the supervised models with the outputs of unsupervised models can improve the recall of the system.
Cross-lingual zero-shot transfer represents an arising hot-topic in the research community. The main idea behind this family of approaches is that models can benefit from transfer from one language to another and therefore be able to conduct tasks in new, `unseen languages`, on which they were not trained in a supervised way. These approaches are especially useful for low-resource languages without manually labeled resources. We are aware of two unsupervised cross-lingual approaches to keyword extraction. One of them is BiKEA \cite{huang2014cross}, where the authors construct word graphs for documents in parallel corpora and rely on cross-lingual word statistics for keyword extraction. Another one is the study by \newcite{cross_ling_latent}, where the focus is on building single latent space over two languages, and later extracting keywords, to be used as topic categories for the articles, from this common latent space.
Researchers conducted various studied on the effect of applying zero-shot cross-language modelling to multiple domains of NLP, with most of the experiments showing promising results. For example, a zero-shot approach, in which a model was trained on one language and applied on the other, for the task of automatic reading comprehension was carried out by \newcite{crossling_comperhension}. Phoneme recognition is another task that cross-lingual zero-shot learning seems to improve. In the work by \newcite{crossling_phoeme} they show that cross-lingual phoneme recognition offers performance comparable to the state-of-the-art unsupervised models for the task at hand.
Recently, masked language models based on transformers such as BERT \cite{devlin2019bert} have taken the field by the storm, achieving state-of-the-art results on many tasks. In a study by \newcite{crossling_bert_study} they explored how well does the multilingual variant of BERT performs when used in a zero-shot setting. The study included 39 languages and covered 5 different tasks, including document classification, natural language inference, named entity recognition, part-of-speech tagging, and dependency parsing. The results were very promising, with the model outscoring several unsupervised and non-transformer based cross-lingual approaches. A zero-shot approach relying on multilingual BERT was also adopted to tackle the tasks of news-sentiment classification \cite{app10175993}, offensive speech detection \cite{pelicon2021investigating} and abusive language detection \cite{glavas-etal-2020-xhate}. These studies concluded that pretrained models can be used in a cross-lingual fashion, serving as a strong baseline in the low-resource scenario. To the best of our knowledge, zero-shot transfer has not yet been investigated for the task of keyword extraction.
\section{Data}
\label{sec:data}
\begin{table*}[!h]
\centering
\resizebox{\textwidth}{!}{
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
\cline{2-10}
\multicolumn{1}{c|}{}& \multicolumn{3}{c|}{ \textbf{Train}} & \multicolumn{3}{c|}{\textbf{Valid}} & \multicolumn{3}{c|}{\textbf{Test}} \\ \hline
Language & size & kw\_per\_doc & kw\_present & size & kw\_per\_doc & kw\_present & size & kw\_per\_doc & kw\_present \\ \hline
Latvian & 10506 & 3.2204 & 0.8691 & 2627 & 3.2687 & 0.8658 & 11641 & 3.1964 & 0.8624 \\ \hline
Estonian & 8600 & 3.8244 & 0.7809 & 2150 & 3.7386 & 0.7785 & 7747 & 4 944 & 0.8073 \\ \hline
Slovenian & 4796 & 4.0052 & 0.5991 & 1199 & 4.1643 & 0.6054 & 1519 & 3.8861 & 0.5995 \\ \hline
Croatian & 25778 & 3.5375 & 0.7047 & 6445 & 3.5469 & 0.6988 & 3582 & 3.5274 & 0.7009 \\ \hline
English & 207938 & 5.324 & 0.4599 & 51985 & 5.0350 & 0.4583 & 20000 & 5 349 & 0.6205 \\ \hline
Russian & 11064 & 5.6377 & 0.7779 & 2767.0 & 5.7311 & 0.7797 & 11475.0 & 5.4261 & 0.7918 \\ \hline
\end{tabular}
}
\caption{Number of documents (size), keywords per document (kw\_per\_doc) and percentage of keywords present in document's text (kw\_present) per split in our experiments. Percentage of present keywords represents the percentage of keywords that appear in the text of the document.}
\label{tab:datasets}
\end{table*}
For model evaluation we use six different datasets from the news domain.
We include Russian, Croatian, Latvian, and Estonian news article datasets with manually labeled keywords from the
\newcite{clarin_kw} dataset repository, using the same splits as in
\newcite{koloski-etal-2021-extending}. Additionally, we include a benchmark English dataset, the KPTimes dataset \cite{gallina2019kptimes}, and a Slovenian SentiNews \cite{slovenian_dataset}, which was originally used for news sentiment analysis, but nevertheless does contain manually labeled keywords and was therefore identified as suitable for keyword extraction. Before feeding the datasets to the models, they are lowercased. Each dataset is split into three different splits: \textit{train}, \textit{validation} and \textit{test}. For English, we use the data splits introduced in \cite{gallina2019kptimes}, for other languages besides Slovenian we use the same data splits as in \cite{koloski-etal-2021-extending}, while for Slovene we first removed the articles without keywords and randomly split the dataset into training, validation and test splits. We use the splits in the following manner:
\begin{itemize}
\item \textit{train split} - used for fine-tuning of the cross-lingual supervised model. The procedure is explained in detail in Section \ref{subsec:supervised}.
\item \textit{valid split} - used for early stopping in order to prevent over-fitting during the fine-tuning phase of the supervised models.
\item \textit{test split} - used for evaluation of the supervised and unsupervised methods. This split is not used during training of any of the methods.
\end{itemize}
The dataset statistics are available in Table \ref{tab:datasets}. For each split we report on the \textit{size} (number of articles), the average amount of keywords per document (\textit{kw\_per\_doc}) and finally the percentage of keywords that actually appear in the text of the news articles (\textit{kw\_present}). \textit{Latvian} dataset has on average least keywords per document ($3.22$) while the English and Russian datasets contain most keywords per article, $5.32$ and $5.64$, respectively.
Note that some of the keywords accompanying an article in the data do not appear in the text of the document. For evaluation purposes we only use the \textbf{keywords present} in the documents. \textit{English} has the lowest amount of present keywords ($46\%$), while \textit{Latvian} has the highest percentage of present keywords ($87\%$). We consider keyword or keyphrase as present if a stemmed (English and Lativan) or lemmatized version (for other languages) appears in the stemmed or lemmatized version of the document. We use the NLTK's \cite{bird2009natural} implementation of the \textit{PorterStemmer} for English and \textit{LatvianStemmer}\footnote{\url{https://github.com/rihardsk/LatvianStemmer}} for Latvian. For \textit{Croatian, Slovenian, Estonian} and \textit{Russian} we use the \textit{Lemmagen3} \cite{jurvsic2010lemmagen} lemmatizer.
\section{Experimental Setup}
\label{sec:experiments}
In our experiments, we employ several unsupervised models to which we compare several supervised cross-lingual, multilingual and monolingual approaches.
\subsection{Unsupervised Approaches}
\label{subsec:unusper}
We evaluate three types of unsupervised keyword extraction methods, statistical, graph-based, and embedding-based, described in Section \ref{sec:related_work}.
\subsubsection{Statistical Methods}
\begin{itemize}
\item \textbf{YAKE} \cite{yake}: We consider n-grams with $n \in \{1,2,3\}$ as potential keywords.
\item \textbf{KPMiner} \cite{el2009kp}: We apply least allowable seen frequency of $3$, while we set the \textit{cutoff} to $400$.
\end{itemize}
\subsection{Embedding-based Methods}
\begin{itemize}
\item \textbf{KeyBERT} \cite{grootendorst2020keybert}: For document embedding generation we employ sentence-transformers \cite{reimers-2019-sentence-bert}, more specifically the \textit{distiluse-base-multilingual-cased-v2} model available in the Huggingface library\footnote{\url{https:/huggingface.co/sentence-transformers/distiluse-base-multilingual-cased-v2}}. Initially, we tested two different KeyBERT configurations: one with n-grams of size $1$ and another with n-grams ranging from 1 to 3, with \textit{MMR}=$false$ and with \textit{MaxSum}=$false$. The unigram model outscored the model that considered n-grams of sizes 1 to 3 as keyword candidates for all languages, therefore in the final report we show only the results for the unigram model.
\end{itemize}
\subsubsection{Graph-based Methods}
\begin{itemize}
\item \textbf{TextRank} \cite{mihalcea2004textrank}: For languages supported by the PKE library \cite{pke} (Russian and English), we employ stemming for normalization, and part-of-speech tagging during candidate weighting. $33\%$ of the highest ranked words are considered as potential candidates.
\item \textbf{MultipartiteRank} \cite{Multipartite}: We employ part-of-speech tagging during candidate weighting for supported languages, and we set the minimum similarity threshold for clustering at $74\%$.
\item \textbf{RaKUn} \cite{DBLP:journals/corr/abs-1907-06458}: We use edit distance for calculating distance between nodes, use language specific stopwords from the \textit{stopwords-iso} library\footnote{\url{https://github.com/stopwords-iso/stopwords-iso}}, a \textit{bigram-count\_threshold} of $2$ and a \textit{distance\_threshold} of $2$.
\end{itemize}
We use the PKE \cite{pke} implementations of
\textit{YAKE}, \textit{KPMiner}, \textit{TextRank} and \textit{MultiPartiteRank}. We use the official implementation for the RaKUn model \cite{DBLP:journals/corr/abs-1907-06458} and for the KeyBERT model \cite{grootendorst2020keybert}. For unsupervised models, the number of returned keywords need to be set in advance. Since we employ F1@10 as the main evaluation measure (see Section \ref{sec:evaluation-setting}), we set the number of returned keywords to 10 for all models.
\subsection{Supervised Approaches}
\label{subsec:supervised}
We utilize the transformer-based BERT model \cite{devlin2019bert} with a token-classification head consisting of a simple linear layer for all our supervised approaches. We treat the keyword extraction task as a sequence classification task. We follow the approach proposed in \newcite{martinc2020tnt} and predict binary labels (1 for `keywords' and 0 for `not keywords') for all words in the sequence. The sequence of two or more sequential keyword labels predicted by the model is always interpreted as a multi-word keyword. We do not follow the related work \cite{koloski-etal-2021-extending} on adding a BilSTM-CRF classification head on top of BERT for sequence classification. Sincethe classification head needs to be randomly initialized (i.e. it was not pretrained during the BERT pretraining) and since, among others, we apply the model in a cross-lingual setting, we prefer to keep the token classification head simple, since the layers inside the head do not obtain any multilingual information during fine-tuning. The hypothesis is that using a simple one-layer classification head will result in a better generalization of the model in a cross-lingual setting.
More specifically, we employ the \textit{bert-uncased-multilingual} model from the HuggingFace library \cite{huggingface} and fine-tune it using an adaptive learning rate (starting with the learning rate of $3\cdot10^{-5}$), for up to $10$ \textit{epochs} with a batch-size of $8$.
\subsubsection{Cross-lingual Setup}
Let $C_{k}$ be the collection of all of the possible tuples of size $k$ that can be constructed from the $6$ languages. For example, $C_{2}$ denotes the collection of all possible two language combinations in a set of $6$ languages, e.g.
\begin{equation*}
C_{2} = \{(English, Russian), (English, Latvian) , \dots \}
\end{equation*}
We denote the \textit{i-th} tuple of size $k$ with $C_{k}^{i}$, e.g. for the previous example, $C_{2}^{1}$ would yield $(English, Russian)$. The cardinality of the collection $C_{k}$, $|C_{k}|$ is calculated as:
\begin{equation*}
|C_{k}| = \binom{6}{k}
\end{equation*}
We create the \textit{i-th} training dataset D from the collection of tuples $C_{k}$ of size \textit{k}, as a concatenation of datasets in the tuple, or more formally $D_{i,k}$:
\begin{equation*}
D_{i,k} = \bigcup_{language \in C_{k}^{i}} \textit{train-split(language)}
\end{equation*}
where \textit{train-split} represents the respective data-split of the given \textit{language} as described in Section \ref{sec:data}.
Dependent on the number of languages $k$ included in the training set, and depending on what languages are the trained models employed, we define the following specific settings, for which we report results in Section \ref{sec:discusion}:
\begin{itemize}
\item \textbf{MON} - monolingual ($k=1$ ; $D_{i,1}$ for $i \in {1,|C_{1}|}$) - where we fine-tune the model on a single language (for example \textit{English}). In this setting we train a total of 6 \textbf{monolingual} models\footnote{Note that even in this `monolingual setting' we employ BERT pretrained on a multilingual corpus, since we are more interested in the comparison of fine-tuning regimes in this paper than in the comparison of different pretrained models.} and \textbf{we train and test each model on the same language}. We use this setting as a baseline to which we compare unsupervised, cross-lingual and multilingual settings, i.e. for cross-lingual (LOO) and unsupervised settings, MON indicates how much we would gain, if language specific training data was available.
\item \textbf{LOO} - \textit{Leave One Out} ($k=5$ ; $D_{i,5}$ for $i \in {1,|C_{5}|}$) - where we fine-tune the model on a concatenation of five languages (for example \textit{Slovenian, Estonian, Latvian, Russian, Croatian}) and test it on the sixth language not appearing in the train set (e.g. \textit{English}). In this manner we obtain 6 different models. This is the so-called \textbf{zero-shot cross-lingual} setting, since we do not include the test language at the training time. The main idea behind this setting is to test how well does a model do if no language specific training data is available. This setting represents the core of our experiments.
\item \textbf{MUL} - multilingual ($k=6$ ; $D_{i,6}$ for $i \in {1,|C_{6}|}$) - where we fine-tune just one model on all languages from the language set and apply it on all the test datasets. With this experiment we want to check if adding more domain-specific data from other languages improves the performance in comparison to the monolingual setting described above.
\end{itemize}
\subsection{Evaluation Setting}
\label{sec:evaluation-setting}
In order to evaluate the models, we calculate F1, recall and precision at 10 retrieved words. We omit the documents that do not have present keywords or do not contain keywords. We do this since we only use approaches that extract words (or multi-word expressions) from the given document and cannot handle keywords not appearing in the text. All approaches are evaluated on the same monolingual test splits, which are not used for training of supervised models. Lowercasing and stemming (for English and Latvian) or lemmatization (for other languages) are performed on both the gold standard and the extracted keywords (keyphrases) during the evaluation.
\section{Discussion of Results}
\label{sec:discusion}
Table \ref{tab:evaluation_F1} presents the results in terms of F1@10, Table \ref{tab:evaluation_precision} presents the results in terms of precision@10 and Table \ref{tab:evaluation_recall} presents the results in terms of recall@10.
All unsupervised approaches are outperformed by the cross-lingual approaches (see row LOO) across all of the datasets and according to all criteria. For all languages besides Slovenian, the cross-lingual model improves on the best performing unsupervised model by more than 10 percentage points in terms of F1@10, the improvement being the smallest for Slovenian (about 8 percentage points) and the biggest for Latvian and Estonian (about 15 percentage points). The best performing unsupervised model in terms of F1@10 is KeyBert, which outperforms other unsupervised models on all languages.
The difference in F@10 between the cross-lingual and monolingual models (see row MON) is substantial. If no training data for the target language is used, the performance is more than halved on three languages, Latvian, Estonian and Russian. For the other three languages, the drop is smaller yet still substantial. Similar drops can be observed according to two other measurements precision@10 and recall@10.
The monolingual and multilingual models offer comparable performance according to all measures and across all languages. This indicates that including other languages into the train set, besides the target language, does generally not improve performance of the models, especially if the training dataset is sufficiently large. This finding supports the so-called curse of multilinguality \cite{conneau2019unsupervised}, i.e. a trade-off between the number of languages the model supports and the overall decrease in performance on monolingual and cross-lingual benchmarks. It is however very likely that the transfer between languages would be more successful if the language set would contain more similar languages.
\begin{table}[!ht]
\resizebox{\linewidth}{!}{\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{Language} & English & Slovenian & Croatian & Latvian & Estonian & Russian \\ \hline
Model & T & \multicolumn{6}{c|}{F1@10} \\ \hline
\hline
\multicolumn{8}{|c|}{Without training data in the target language} \\ \hline
KPMiner&U&0.1584&0.0941&0.1043&0.131&0.0641&0.0578 \\ \hline
YAKE&U&0.1449&0.0794&0.1248&0.095&0.0653&0.0966 \\ \hline
KeyBert&U&0.1702&0.1153&0.1668&0.1330&0.0923&0.1352\\ \hline
TextRank&G&0.0440&0.0042&0.0041&0.0196&0.0239&0.0392 \\ \hline
RaKUn&G&0.1176&0.0875&0.0902&0.0862&0.0605&0.0731 \\ \hline
MPRU&G&0.1549&0.0455&0.0683&0.0821&0.0398&0.1171 \\ \hline
LOO & C &\textbf{0.2856}&\textbf{0.2000}&\textbf{0.2883}&\textbf{0.2844}&\textbf{0.2368}&\textbf{0.2395} \\ \hline \hline
\multicolumn{8}{|c|}{With training data} \\ \hline
MON & S & 0.4658 & 0.3259 & 0.4644 &\textbf{ 0.6533 } & \textbf{ 0.4920 } & \textbf{ 0.5979 } \\ \hline
MUL & S &\textbf{0.4702}&\textbf{0.3371}&\textbf{0.4674}&0.6532&0.4900&0.5943 \\ \hline
\end{tabular}}
\caption{Performance of the models according to the F1@10. The \textit{T} column denotes the type of model - \textit{U} denotes unsupervised statistical model, \textit{G} denotes unsupervised graph based model, \textit{S} denotes the supervised BERT model and finally \textit{C} denotes the cross-lingual
\textit{LOO} model. MPRU entry in the Model column denotes the MultiPartiteRank model.}
\label{tab:evaluation_F1}
\end{table}
\begin{table}[ht!]
\resizebox{\linewidth}{!}{ \begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{Language} & English & Slovenian & Croatian & Latvian & Estonian & Russian \\ \hline
Model & T & \multicolumn{6}{c|}{precision@10}\\ \hline
\hline
\multicolumn{8}{|c|}{Without training data in the target language} \\ \hline
KPMiner&U&0.1493&0.1280&0.0974&0.1243&0.0822&0.0578 \\ \hline
YAKE&U&0.1068&0.0591&0.0818&0.0602&0.0432&0.0966 \\ \hline
KeyBert&U&0.1640&0.1213&0.1428&0.0995&0.0747&0.1352\\ \hline
TextRank&G&0.0322&0.0036&0.0028&0.0120&0.0157&0.0392 \\ \hline
RaKUn&G&0.0871&0.0672&0.0605&0.0550&0.0417&0.0731 \\ \hline
MPRU&G&0.1151&0.0339&0.0462&0.0524&0.0273&0.1171 \\ \hline
LOO & C & \textbf{0.3337}&\textbf{0.2728}&\textbf{0.2955}&\textbf{0.3158}&\textbf{0.3247}&\textbf{0.2395} \\ \hline \hline
\multicolumn{8}{|c|}{With training data} \\ \hline
MON & S & 0.5278 & 0.2954 & 0.4514 & \textbf{0.7056} & 0.5053 & \textbf{ 0.5979 } \\ \hline
MUL & S & \textbf{0.5318}&\textbf{0.3429}&\textbf{0.4799}&0.7021&\textbf{0.5212}&0.5943 \\ \hline
\end{tabular}}
\caption{Performance of the models according to the precision@10. The \textit{T} column denotes the type of model - \textit{U} denotes unsupervised statistical model, \textit{G} denotes unsupervised graph based model, \textit{S} denotes the supervised BERT model and finally \textit{C} denotes the cross-lingual
\textit{LOO} model. MPRU entry in the Model column denotes the MultiPartiteRank model. }
\label{tab:evaluation_precision}
\end{table}
\begin{table}[ht!]
\resizebox{\linewidth}{!}{\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{Language} & English & Slovenian & Croatian & Latvian & Estonian & Russian \\ \hline
Model & T & \multicolumn{6}{c|}{recall@10} \\ \hline
\hline
\multicolumn{8}{|c|}{Without training data in the target language} \\ \hline
KPMiner&U&0.1688&0.0744&0.1123&0.1384&0.0525&0.0578 \\ \hline
YAKE&U&0.2251&0.1213&0.2625&0.2254&0.1336&0.0966 \\ \hline
KeyBert&U&0.1768&0.1200&0.2001&0.2007&0.1206&0.1352\\ \hline
TextRank&G&0.0694&0.0051&0.0076&0.0536&0.0502&0.0392 \\ \hline
RaKUn&G&0.1813&0.1252&0.1772&0.1995&0.1099&0.0731 \\ \hline
MPRU&G&0.2367&0.0696&0.1310&0.1899&0.0734&0.1171 \\ \hline
LOO & C &\textbf{ 0.2496}&\textbf{ 0.1579}&\textbf{ 0.2815}&\textbf{ 0.2586}&\textbf{ 0.1863}&\textbf{0.2395} \\ \hline \hline
\multicolumn{8}{|c|}{With training data} \\ \hline
MON & S & 0.4169 &\textbf{ 0.3634 } & \textbf{ 0.4781 } & 0.6082 & \textbf{ 0.4794 } & \textbf{ 0.5979 } \\ \hline
MUL & S &\textbf{0.4215}&0.3314&0.4556&\textbf{0.6107}&0.4624&0.5943 \\ \hline
\end{tabular}}
\caption{Performance of the models according to the recall@10. The \textit{T} column denotes the type of model - \textit{U} denotes unsupervised statistical model, \textit{G} denotes unsupervised graph based model, \textit{S} denotes the supervised BERT model and finally \textit{C} denotes the cross-lingual
\textit{LOO} model. MPRU entry in the Model column denotes the MultiPartiteRank model. }
\label{tab:evaluation_recall}
\end{table}
\subsection{Adding More Languages in a Cross-lingual Setting}
Above we have showed that adding other languages into the train set already containing the data that matches the target language does generally not improve the performance. On the other hand, here we explore if it is worth adding more languages in a cross-lingual setting. We consider \textit{English} as a testing language, and train on different combinations of languages that do not include English. Figure \ref{fig:docsize_F1} presents the correlation between the number of languages and the performance of the model according to the F1@10. The Figure does indicate some positive correlation between the number of languages in the train set and the F1@10 improvement. The best was the model trained on Croatian (labeled as C) achieving F1@10 of $35\%$. Overall, the best performing model on English was trained on the concatenation of the Croatian and Estonian corpus (labeled as CE). Adding additional languages to the train set did not improve the performance further. It does however improve the stability of the models, i.e. the models trained on more languages tend to have higher performance minimum but also lower performance maximum, as can be clearly seen in Figure \ref{fig:box_combined}.
\begin{figure}[H]
\centering
\includegraphics[width=\linewidth]{kws_vs_F10.pdf}
\caption{Correlation between the number of languages and the performance of the model according to the F1@10, when the model is tested on an unseen language (English). The best-performing combinations per language are labeled with a sequence of letters representing languages: Croatian - \textit{C}, Slovenian - \textit{S}, Estonian - \textit{E}, Latvian - \textit{L} and Russian - \textit{R}.}
\label{fig:docsize_F1}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=\linewidth]{Box_plot_figs2.pdf}
\caption{Correlation between the number of languages and the performance of the model according to the F1@10, when the models is tested on an unseen language (English). The models are split into groups according to the number of languages they were trained on and each group is represented by a boxplot. The best-performing combinations per language are labeled with a sequence of letters representing languages: Croatian - \textit{C}, Slovenian - \textit{S}, Estonian - \textit{E}, Latvian - \textit{L} and Russian - \textit{R}..}
\label{fig:box_combined}
\end{figure}
\subsection{Zero-shot Performance of the Monolingual Models}
We explored how powerful are the monolingual (\textbf{MON}) models described in Section \ref{subsec:supervised} in a cross-lingual zero-shot keyword extraction setting. Each of six trained monolingual models was tested on six languages to obtain a heatmap presented in Figure \ref{fig:heatmap}. There was no single monolingual model that worked best for all of the remaining languages. For \textit{English}, the best-performing model was trained on \textit{Croatian}, most likely due to the fact that both datasets contain news from 2019, suggesting some topic intersection. The best performance on the \textit{Estonian} dataset was achieved by the model trained on the \textit{Latvian} dataset, most likely due to the fact that both of these datasets contain news from the same time period and were collected by the same media company, which covers news for both neighboring countries, Estonia and Latvia. Not surprisingly, the reverse correlation si also true: the best-performing model on the \textit{Latvian} dataset was trained on the \textit{Estonian} dataset. The best performance on the \textit{Russian} dataset was achieved by the \textit{Estonian} model due to both of the datasets coming from the same media-house stationed in Estonia, as reported by \newcite{koloski-etal-2021-extending}. Finally, the best performance on the \textit{Slovenian} data was achieved by the \textit{Croatian} model, most likely because both of these languages belong to the Southern-Slavic language group and since Slovenia and Croatia are neighbouring countries.
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{all_f_10_2.pdf}
\caption{Evaluation of F1-score@10 retrieved keywords of the monolingual models in a setting of zero-shot cross-lingual learning. The rows represent the training language while the columns represent the testing languages. }
\label{fig:heatmap}
\end{figure}
We also conducted hierarchical clustering, using the cross-lingual scores of the monolingual models as affinities. We present the resulting dendrogram in Figure \ref{fig:hirearc}. The results mostly confirm relations between languages, countries and sources of data, pointed out above. \textit{Estonian} and \textit{Latvian} datasets seem to be most similar. \textit{Russian} dataset is the natural addition to this cluster, most likely due to language and content similarity. Interestingly, \textit{Croatian} and \textit{English} form a separate cluster, most likely on the premises of both containing news from 2019, while the Slovenian dataset appears to be most dissimilar to other datasets.
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{dendrogram_F1.pdf}
\caption{Dendrogram of the agglomerative clustering of the monolingual models applied in a cross-lingual setting.}
\label{fig:hirearc}
\end{figure}
\section{Conclusions and Further Work}
\label{sec:conclusion}
In this work, we have presented a comprehensive comparison study covering multiple unsupervised, cross-lingual, multilingual and monolingual approaches for keyword extraction. While we did not manage to improve the performance of the supervised monolingual models by adding additional foreign language data to the training dataset, the results clearly indicate that cross-lingual models outperform unsupervised methods by a large margin. This suggests that if a labeled keyword train set from a specific domain is not available for a specific low-resource language, one opt to try to train a supervised model on a dataset covering the same domain in some other (preferably similar) language and employ that model in a zero-shot setting, before employing the unsupervised methods.
While cross-lingual models tend to outperform unsupervised approaches by a large margin, the discrepancy in performance between the supervised cross-lingual setting and the supervised monolingual setting is nevertheless substantial and training the model on the target languages is still the preferred option in terms of performance. This is in line with further experiments conducted during the study, which suggest that the models perform really well for target languages similar to the languages on which the model was trained and when there is some intersection between the news content in the training and test datasets.
For further work we propose exploring few-shot shot scenarios, in which a small amount of target language data will be added to the multilingual train set. We plan to pinpoint the amount of needed target language data in order to bridge the gap in performance between the monolingual and cross-lingual models. Additionally, we propose ensambling multiple methods and explore how would that benefit the performance of the approach.
\section{Acknowledgements}
This work was supported by the Slovenian Research Agency (ARRS) grants for the core programme Knowledge technologies (P2-0103), the project Computer-assisted multilingual news discourse analysis with contextual embeddings (CANDAS, J6-2581), as well as the European Union’s Horizon 2020 research and innovation programme under grant agreement No 825153, project EMBEDDIA (Cross-Lingual Embeddings for Less-Represented Languages in European News Media). The third author was financed via young research ARRS grant.
\section{Bibliographical References}\label{reference}
\bibliographystyle{lrec2022-bib}
|
{'timestamp': '2022-02-15T02:42:41', 'yymm': '2202', 'arxiv_id': '2202.06650', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06650'}
|
arxiv
|
\section{\@startsection{section}{1}{\z@}%
{-18\p@ \@plus -4\p@ \@minus -4\p@}%
{12\p@ \@plus 4\p@ \@minus 4\p@}%
{\normalfont\large\bfseries\boldmath
\rightskip=\z@ \@plus 8em\pretolerance=10000 }}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
{-6\p@ \@plus -2\p@ \@minus -2\p@}%
{-0.5em \@plus -0.22em \@minus -0.1em}%
{\normalfont\normalsize\bfseries\boldmath}}
\newcommand\mysubsec{\@startsection{paragraph}{4}{\z@}%
{-6\p@ \@plus -4\p@ \@minus -4\p@}%
{-0.5em \@plus -0.22em \@minus -0.1em}%
{\normalfont\normalsize\bfseries}}
\makeatother
\include{preamble}
\title{Coalgebraic Semantics for Nominal Automata}
\titlerunning{Coalgebraic Language Semantics for Nominal Automata}
\author{Florian Frank \and Stefan Milius\thanks{Supported by Deutsche Forschungsgemeinschaft (DFG) under project MI~717/7-1} \and Henning Urbat\thanks{Supported by Deutsche Forschungsgemeinschaft (DFG) under proj.~SCHR~1118/15-1}}
\authorrunning{F.~Frank, S.~Milius and H.~Urbat}
\institute{Friedrich-Alexander-Universit\"at Erlangen-N\"urnberg}
\begin{document}
\maketitle
\begin{abstract}
This paper provides a coalgebraic approach to the language semantics
of regular nominal non-deterministic automata (RNNAs), which were
introduced in previous work. These automata feature ordinary as well
as name binding transitions. Correspondingly, words accepted by RNNAs
are strings formed by ordinary letters and name binding
letters. Bar languages are sets of such words modulo
$\alpha$-equivalence, and to every state of an RNNA one associates
its accepted bar language. We show that this semantics arises both
as an instance of the Kleisli-style coalgebraic trace semantics as
well as an instance of the coalgebraic language semantics obtained
via generalized determinization. On the way we revisit coalgebraic
trace semantics in general and give a new compact proof for the main
result in that theory stating that an initial algebra for a functor
yields the terminal coalgebra for the Kleisli extension of the
functor. Our proof requires fewer assumptions on the functor than
all previous ones.
\end{abstract}
\section{Introduction}\label{S:intro}
Classical automata and their language semantics have long been
understood in the theory of coalgebras. For example, it is a well-known
exercise~\cite{Rutten98} that standard deterministic automata over a
fixed alphabet can be modelled as coalgebras, that the terminal
coalgebra is formed by all formal languages over that alphabet, and
the unique homomorphism into the terminal coalgebra assigns to each
state of an automaton the language it accepts. Non-deterministic
automata are also coalgebras for a functor extending the one for
deterministic automata in order to accomodate non-deterministic
branching. Their language semantics can be obtained coalgebraically in
two different ways. First, in the \emph{coalgebraic trace semantics}
by Hasuo et al.~\cite{HasuoEA07} one considers coalgebras for composed
functors $TF$ where $F$ is a set functor modelling the type of
transitions and $T$ is a set monad modelling the type of branching;
for example, for non-deterministic branching one takes the power-set
monad. Under certain conditions on $F$ and $T$, including that $F$ has
an extension $\mybar{0.6}{2.5pt}{F}$ to the Kleisli category of $T$, an initial
$F$-algebra is seen to lift to the terminal coalgebra for $\mybar{0.6}{2.5pt}{F}$. Its
universal property then yields the coalgebraic trace semantics. Among
the instances of this is the standard language semantics of
non-deterministic automata.
Second the \emph{coalgebraic language semantics}~\cite{bms13} is based on
generalized determinization by Silva et al.~\cite{SilvaEA13}. Here one
considers coalgebras for composed functors~$GT$ where $G$ models
transition types and $T$ again models the branching type. Assuming
that $G$ has a lifting to the Eilenberg-Moore category for $T$, generalized
determinization turns such a coalgebra into a $G$-coalgebra by taking
the unique extension of the coalgebra structure to the free
Eilenberg-Moore algebra on the set of states. Moreover, taking the
unique homomorphism from that coalgebra into the terminal
$G$-coalgebra yields the coalgebraic language semantics. In the
leading instance of non-deterministic automata, generalized
determinization is the well-known power-set construction and
coalgebraic language semantics the standard automata-theoretic
language semantics once again.
These two approaches were brought together by Jacobs et
al.~\cite{JacobsEA15} who study those species of systems which can be
modelled as coalgebras in both of the above ways. They show that
whenever there exists an \emph{extension} natural transformation
$TF \to GT$ satisfying two natural equational laws, then the two above
semantics are canonically related, and they agree in the
instances studied in op.~cit.
It is our aim in this paper to draw a similar picture for
non-deterministic automata for languages over infinite alphabets. Such
alphabets allow to model \emph{data}, such as nonces~\cite{KurtzEA07},
object identities~\cite{GrigoreEA13}, or abstract
resources~\cite{CianciaSammartino14}, and the ensuing languages are
therefore called \emph{data languages}. There are several species of
automata for data languages in the literature. We focus on two types
which are known to have a presentation as coalgebras:
non-deterministic orbit-finite automata (NOFA)~\cite{BojanczykEA14}
and regular non-deterministic nominal automata
(RNNA)~\cite{SchroderEA17}. For both of these types of automata one works
with the category of nominal sets and takes the set of \emph{names} as
the alphabet. While NOFAs are a straightforward nominal version of
standard non-deterministic automata, RNNAs feature \emph{binding
transitions}, which can be thought as storing an input name in a
`register' for comparison with future input names. Correspondingly,
they accept words including name binding letters and which are taken modulo
$\alpha$-equivalence; such words form \emph{bar languages} (the name
stems from the bar in front of name binding letters $\newletter
a$). However, while these automata are understood as coalgebras, their
semantics has not been studied from a coalgebraic perspective sofar.
We fill this gap here and prove that the data language accepted by a NOFA and the bar
language accepted by an RNNA arise as instances of both coalgebraic trace semantics
\renewcommand{\theoremautorefname}{Theorems}%
(\autoref{T:NOFA-Kl} and~\ref{T:RNNA-Kl})
\renewcommand{\theoremautorefname}{Theorem}%
and coalgebraic language semantics
\newcommand{\corollaryautorefname}{Corollaries}%
(\autoref{C:NOFA-EM} and~\ref{C:RNNA-EM}).
\renewcommand{\corollaryautorefname}{Corollary}%
The latter result is obtained by using canonical extension natural
transformations obtained from the result by Jacobs et al.~\cite{JacobsEA15}.
While these results will perhaps hardly surprise the cognoscenti, and
the treatment of NOFAs indeed appears as an(other) exercise in coalgebra, we
should like to point out that there are a number of technical
subtleties arising in the treatment of RNNAs. Essentially, what causes
some trouble is the presence of the binding functor in their type. We
solve all these difficulties by working with the uniformly finitely
supported power-set monad $\pow_{\ufs}$ on nominal sets in lieu of the
more common finitely supported power-set monad $\pow_{\fs}$ (which provides
the power objects of the topos of nominal sets). Note also that for a
nominal set $X$, neither $\pow_{\fs} X$ nor $\pow_{\ufs} X$ form cpos (so, in
particular, they do not form complete lattices). Hence, it may come as
a bit of a surprise that the Kleisli categories of both monads are
nevertheless enriched over complete lattices (\autoref{P:dcpo}), one of
the key requirements for coalgebraic trace semantics.
We present our
results in a modular way so that they may be resusable for the study
of coalgebraic semantics for other types of nominal systems, such as nominal tree automata. For
example, we show that all \emph{binding polynominal functors},
i.e.~those functors arising from a nominal algebraic (a.k.a.~binding)
signature in the sense of Pitts~\cite{Pitts13} have a canonical
extension to the Kleisli category of $\pow_{\ufs}$
(\autoref{cor:extension-pufs}). Analogously, we show a lifting result
for terminal coalgebras to the Eilenberg-Moore category for a subclass
of these functors (\autoref{C:lift-nu}).
Last but not least, on the way to the coalgebraic semantics of NOFAs
and RNNAs we take a fresh look at coalgebraic trace semantics in
general. We provide a new compact proof for the main theorem of that
theory. It states that for a functor $F$ and a monad $T$ satisfying
certain conditions, including that $F$ has an extension $\mybar{0.6}{2.5pt}{F}$ to the
Kleisli category of $T$, the initial $F$-algebra extends to a terminal
coalgebra for $\mybar{0.6}{2.5pt}{F}$ (\autoref{T:Kl}). We obtain this essentially as
a combination of Hermida and Jacobs' adjoint lifting
theorem~\cite[Thm.~2.14]{HermidaJ98} and an argument originally given
by Freyd~\cite{Freyd92} that for locally continuous endofunctors on
categories enriched in cpos an initial algebra yields a terminal
coalgebra. Here we adjust this argument to work for locally monotone
endofunctors on categories enriched in directed-complete partial
orders. As a consequence, our proof does not require the existence of
a zero object in the Kleisli category of $T$ and, notably, we only
need the mere existence of the initial algebra for $F$ and not that it is
obtained after $\omega$ steps of the initial-algebra chain given by
$F^n 0$ ($n <\omega$).
\section{Preliminaries}\label{S:prelim}
\subsection{Nominal Sets}
\hunote[inline]{Copy \& paste from our CONCUR paper.}
Nominal sets form a convenient formalism for dealing with names and
freshness; for our present purposes, names play the role of data. We
briefly recall basic notions and facts and refer to Pitts'
book~\cite{Pitts13} for a comprehensive introduction. Fix a countably
infinite set $\mathbb{A}$ of \emph{names}, and let $\mathrm{Perm}(\mathbb{A})$ denote
the group of finite permutations on $\mathbb{A}$, which is generated by
the \emph{transpositions} $(a\, b)$ for $a\neq b\in\mathbb{A}$ (recall
that $(a\, b)$ just swaps~$a$ and~$b$). A \emph{nominal set} is a
set~$X$ equipped with a (left) group action
$\mathrm{Perm}(\mathbb{A})\times X\to X$, denoted $(\pi,x)\mapsto \pi\cdot x$,
such that every element $x\in X$ has a finite
\emph{support}~$S\subseteq\mathbb{A}$, i.e.~$\pi\cdot x=x$ for every
$\pi\in \mathrm{Perm}(\mathbb{A})$ such that $\pi(a)=a$ for all $a\in S$. Every
element~$x$ of a nominal set $X$ has a least finite support, denoted
$\supp(x)$. Intuitively, one should think of $X$ as a set of syntactic
objects (e.g.~strings, $\lambda$-terms, programs), and of $\supp(x)$
as the set of names needed to describe an element $x\in X$. A name
$a\in\mathbb{A}$ is \emph{fresh} for~$x$, denoted $a\mathbin{\#} x$, if
$a\notin\supp(x)$. The \emph{orbit} of an element $x\in X$ is given by
$\{ \pi\cdot x: \pi\in\mathrm{Perm}(\mathbb{A})\}$. The orbits form a partition of
$X$. The nominal set $X$ is \emph{orbit-finite} if it has only
finitely many orbits.
A map $f\colon X\to Y$ between nominal sets is \emph{equivariant} if
$f(\pi\cdot x)=\pi\cdot f(x)$ for all $x\in X$ and
$\pi\in \mathrm{Perm}(\mathbb{A})$. Equivariance implies
$\supp(f(x))\subseteq \supp(x)$ for all $x\in X$. We denote by $\mathsf{Nom}$ the category of nominal sets and equivariant
maps.
Putting $\pi\cdot a = \pi(a)$ makes $\mathbb{A}$ into a nominal
set. Moreover,~$\mathrm{Perm}(\mathbb{A})$ acts on subsets $A\subseteq X$ of a
nominal set~$X$ by $\pi\cdot A = \{\pi\cdot x : x \in A\}$. A
subset $A\subseteq X$ is \emph{equivariant} if $\pi\cdot A=A$ for all
$\pi\in \mathrm{Perm}(\mathbb{A})$. More generally, it is \emph{finitely
supported} if it has finite support w.r.t.\ this action, i.e.~there
exists a finite set $S\subseteq \mathbb{A}$ such that $\pi\cdot A = A$ for all
$\pi\in \mathrm{Perm}(\mathbb{A})$ such that $\pi(a)=a$ for all $a\in S$. The set
$A$ is \emph{uniformly finitely supported} if
$\bigcup_{x\in A} \supp(x)$ is a finite set. This implies that $A$ is
finitely supported, with least support
$\supp(A)=\bigcup_{x\in A}
\supp(x)$~\cite[Theorem~2.29]{gabbay2011}. (The converse does not
hold, e.g.~the set $\mathbb{A}$ is finitely supported but not uniformly
finitely supported.) Uniformly finitely supported orbit-finite sets
are always finite (since an orbit-finite set contains only finitely
many elements with a given finite support). We denote by $\mathcal{P}_{\mathsf{ufs}}\colon \mathsf{Nom}\to \mathsf{Nom}$ and
$\pow_{\fs}\colon \mathsf{Nom}\to \mathsf{Nom}$ the endofunctors sending a nominal set $X$ the its set of (uniformly) finitely supported subsets and an equivariant map
$f\colon X\to Y$ to the map $A\mapsto f[A]$.
The coproduct $X+Y$ of nominal sets $X$ and $Y$ is given by their
disjoint union with the group action inherited from the two
summands. Similarly, the product $X \times Y$ is given by the
cartesian product with the componentwise group action; we have
$\supp(x,y) = \supp(x) \cup \supp(y)$. Given a nominal set $X$
equipped with an equivariant equivalence relation, i.e.~an equivalence
relation $\sim$ that is equivariant as a subset
$\mathord{\sim} \subseteq X \times X$, the quotient $X/\mathord{\sim}$
is a nominal set under the expected group action defined by
$\pi \cdot [x]_\sim = [\pi \cdot x]_\sim$.
A key role in the theory of nominal sets is played by
\emph{abstraction sets}, which provide a semantics for binding
mechanisms~\cite{GabbayPitts99}. Given a nominal set $X$, an equivariant equivalence relation $\sim$ on
$\mathbb{A} \times X$ is defined by $(a,x)\sim (b,y)$ iff
$(a\, c)\cdot x=(b\, c)\cdot y$ for some (equivalently, all)
fresh~$c$. The \emph{abstraction set} $[\mathbb{A}]X$ is the quotient
set $(\mathbb{A}\times X)/\mathord{\sim}$. The $\sim$-equivalence class
of $(a,x)\in\mathbb{A}\times X$ is denoted by
$\braket{a} x\in [\mathbb{A}]X$. We may think of~$\sim$ as an abstract notion of $\alpha$-equivalence,
and of~$\braket{a}$ as binding the name~$a$. Indeed we have
$\supp(\braket{a} x)= \supp(x)\setminus\{a\}$ (while
$\supp(a,x)=\{a\}\cup\supp(x)$), as expected in binding constructs.
The object map $X\mapsto [\mathbb{A}]X$ extends to an endofunctor
$[\mathbb{A}]\colon \mathsf{Nom} \to \mathsf{Nom}$
sending an equivariant map $f\colon X\to Y$ to the equivariant map $[\mathbb{A}]f\colon [\mathbb{A}]X\to [\mathbb{A}]Y$ given by $\braket{a}x\mapsto \braket{a}f(x)$ for $a\in \mathbb{A}$ and $x\in X$.
\subsection{Nominal Automata}\label{sec:nom-aut}
In this section, we recall two notions of nominal automata earlier
introduced in the literature: non-deterministic orbit-finite automata
(NOFAs)~\cite{BojanczykEA14} and regular non-deterministic nominal
automata (RNNAs)~\cite{SchroderEA17}. The former accept \emph{data
languages} (consisting of finite words over an infinite alphabet)
while the latter accept \emph{bar languages} (consisting of finite
words with , taken modulo
$\alpha$-equivalence).
\begin{notheorembrackets}
\begin{defn}[\cite{BojanczykEA14}]
(1)~A \emph{NOFA} $A=(Q,R,F)$ is given by an orbit-finite nominal set $Q$
of \emph{states}, an equivariant relation
$R\subseteq Q\times \mathbb{A} \times Q$ specifying \emph{transitions}, and
an equivariant set $F\subseteq Q$ of
\emph{final states}. We write $q \xra{a} q'$ in lieu of $(q,a,q')
\in R$.
\begin{enumerate}\stepcounter{enumi}
\item Given a string
$w=a_1a_2\cdots a_n\in \mathbb{A}^*$ and a state $q\in Q$, a \emph{run} for
$w$ from $q$ is a sequence of transitions
\(
q\xto{a_1}q_1\xto{a_2}\cdots \xto{a_n}q_n.
\)
The run is \emph{accepting} if $q_n$ is final. The state $q$
\emph{accepts} $w$ if there exists an accepting run for $w$ from
$q$. The data language \emph{accepted} by $q$ is given by $\{ w\in \mathbb{A}^*: \text{$q$ accepts $w$}\}$.
\end{enumerate}
\end{defn}
\end{notheorembrackets}
Note that in contrast to \cite{BojanczykEA14} we do not require NOFAs to have an explicit initial state $q_0\in Q$; this is more natural from a coalgebraic point of view. NOFAs are known to be expressively equivalent to \emph{finite memory
automata}~\cite{KaminskiFrancez94}.
\begin{rem}\label{rem:nofa-as-coalgebras}
\begin{enumerate}
\item%
\smnote{In general, we should not start sentences with `recall' if
we don't say \emph{from where} one should this recall; this is the
arrogant mathematicians way of assuming s.th.~about the knowledge
of the reader.} Given an endofunctor $F$ on a category $\mathscr{C}$, an
\emph{$F$-coalgebra} is a pair $(C,c)$ of an object $C$ and a
morphism $c\colon C\to FC$ on $\mathscr{C}$. A \emph{homomorphism} of
$F$-coalgebras from
$(C,c)$ to $(D,d)$ is a morphism $h\colon C\to D$ in
$\mathscr{C}$ such that $d\o h = Fh\o c$.
\item A NOFA corresponds precisely to an
orbit-finite coalgebra
\(
\langle f, \delta\rangle\colon Q\longrightarrow 2\times \pow_{\fs}(\mathbb{A}\times Q)
\)
for the functor on $\mathsf{Nom}$ given by
\[
Q\mapsto \pow_{\fs}(1+\mathbb{A}\times Q)\cong 2\times \pow_{\fs}(\mathbb{A}\times
Q).
\]
In fact, $f\colon Q\to 2$ defines the equivariant set $F\subseteq Q$ of
final states and $\delta\colon Q\to \pow_{\fs}(\mathbb{A}\times Q)$ defines
the transitions via
$q\xto{a}q'$ iff $(a,q')\in \delta(q)$.
\end{enumerate}
\end{rem}
In order to incorporate explicit name binding into the
automata-theoretic setting, we work with \emph{bar strings},
i.e. finite words over the infinite alphabet
\[
\barA := \mathbb{A} \cup \{\newletter a: a\in \mathbb{A}\}.
\]
We denote the nominal set of all bar strings by $\barA^*$, and we
equip it with the group action defined pointwise. The letter
$\newletter a$ is interpreted as binding the name~$a$ to the
right. Accordingly, a name $a\in \mathbb{A}$ is said to be \emph{free} in
a bar string $w\in \barA^*$ if (1)~the letter $a$ occurs in $w$, and
(2)~the first occurrence of $a$ is not preceded by any occurrence of
$\newletter a$. For instance, the name $a$ is free in
$a\newletter aba$ but not free in $\newletter aaba$, while the name
$b$ is free in both bar strings. This yields a natural notion of
$\alpha$-equivalence:
\begin{defn}[$\alpha$-equivalence]\label{def:alpha-fin}
Let $=_\alpha$ be the least equivalence relation on~$\barA^*$ such
that
$x\newletter av =_\alpha x\newletter bw$
for all $a,b\in \mathbb{A}$ and $x,v,w\in \barA^*$ such that
$\braket{a} v = \braket{b} w$.
We denote by $\barA^*/\mathord{=_\alpha}$ the sets of $\alpha$-equivalence classes of
bar strings, and we write $[w]_\alpha$ for the
$\alpha$-equivalence class of $w\in \barA^*$.
\end{defn}
\begin{rem}\label{rem:alpheq-technical}
\begin{enumerate}
\item By Pitts~\cite[Lem.~4.3]{Pitts13}, for every pair
$v,w\in \barA^*$ the condition $\braket{a} v = \braket{b} w$ holds
if and only if
\[
\text{$a=b$ and $v=w$,}
\qquad \text{or}\qquad
\text{$b\mathbin{\#} v$ and $(a\, b)\cdot v = w$.}
\]
\item The equivalence relation $=_\alpha$ is equivariant. Therefore,
$\barA^*/{=_\alpha}$ forms a nominal set with the group
action $\pi\cdot [w]_\alpha = [\pi\cdot w]_\alpha$ for
$\pi\in \mathrm{Perm}(\mathbb{A})$ and $w\in \barA^*$. The least support of
$[w]_\alpha$ is the set of free names of $w$.
\end{enumerate}
\end{rem}
\makeatletter
\newcommand\gobblepars{%
\@ifnextchar\par%
{\expandafter\gobblepars\@gobble}%
{}}
\makeatother
\begin{notheorembrackets}
\begin{defn}[\cite{SchroderEA17}]%
(1)~An \emph{RNNA} $A=(Q,R,F)$ is given by an orbit-finite
nominal set $Q$ of \emph{states}, an equivariant relation
$R\subseteq Q\times \barA \times Q$ specifying \emph{transitions}, and an equivariant set $F\subseteq Q$
of \emph{final states}. We write $q\xto{\sigma}q'$ if
$(q,\sigma,q')\in R$. The transitions are subject to two
conditions:
\begin{enumerate}[label=(\alph*)]
\item \emph{$\alpha$-invariance}: if $q\xto{\scriptnew a}q'$ and
$\braket{a} q'=\braket{b} q''$, then $q\xto{\scriptnew b}q''$.
\item \emph{Finite branching up to $\alpha$-invariance:} For every
$q\in Q$ the sets
\[
\set{(a,q') : q\xto{a}q'}
\qquad\text{and}\qquad
\set{\braket{a} q' : q\xto{\scriptnew a} q'}
\]
are finite (equivalently, uniformly finitely supported).
\end{enumerate}
\begin{enumerate}\stepcounter{enumi}
\item Given a bar string
$w=\sigma_1\sigma_2\cdots \sigma_n\in \barA^*$ and a state
$q\in Q$, a \emph{run} for $w$ from $q$ is a sequence of
transitions
\(
q\xto{\sigma_1}q_1\xto{\sigma_2}\cdots \xto{\sigma_n}q_n.
\)
The run is \emph{accepting} if $q_n$ is final. The state $q$
\emph{accepts} $w$ if there exists an accepting run for $w$ from
$q$. The bar language \emph{accepted} by $q$ is given
by $\{ [w]_\alpha : w\in \barA^*, \, \text{$A$ accepts $w$} \}$.
\end{enumerate}
\end{defn}
\end{notheorembrackets}
\begin{rem}\label{rem:rnna-as-coalgebras}
\begin{enumerate}
As for NOFAs, we do not equip RNNAs with explicit initial states. Similar to \autoref{rem:nofa-as-coalgebras}, RNNAs are seen to correspond to
coalgebras
\(
\langle f, \delta, \tau\rangle\colon Q\longrightarrow 2\times \mathcal{P}_{\mathsf{ufs}}(\mathbb{A}\times Q)\times
\mathcal{P}_{\mathsf{ufs}}([\mathbb{A}]Q)
\)
for the functor on $\mathsf{Nom}$ given by
\[
Q\mapsto \pow_{\ufs}(1+\mathbb{A}\times Q+[\mathbb{A}]Q)
\cong
2\times \pow_{\ufs} (\mathbb{A}\times Q) \times \pow_{\ufs}([\mathbb{A}] Q).
\]
Here $f$ and $\delta$ correspond to final states and free
transitions, and the equivariant map
$\tau\colon Q\to \pow_{\ufs}([\mathbb{A}]Q)$ defines the alpha-invariant
bound transitions via
$
q\xto{\scriptnew{a}} q'$ iff $\braket{a}q'\in
\tau(q)$.
The use of $\pow_{\ufs}$ (in lieu of $\pow_{\fs}$) ensures that if $Q$ is
orbit-finite, then the finiteness conditions in the definition of
an RNNA are met.
\end{enumerate}
\end{rem}
Our goal is to interpret the above ad-hoc definition of the data
languages of a NOFA and the bar languages of an RNNA within the
coalgebraic framework.
\subsection{Initial algebras in $\mathsf{DCPO}_\bot$-enriched categories}
\label{S:DCPOb}
For the Kleisli-style coalgebraic trace semantics we shall make use of
a result which shows that in categories where the hom-sets are
enriched over directed-complete partial orders, the initial algebra and
terminal coalgebra coincide.
Recall that a subset $D \subseteq P$ of a poset $P$ is \emph{directed}
if every finite subset of $D$ has an upper bound in $S$; equivalently,
$D$ is nonempty and for every $x,y \in D$, there exists a $z \in D$
with $x,y \leq z$. The poset $P$ is a \emph{dcpo with bottom} if it
has a least element and \emph{directed joins}, that is, every directed
subset has a join in $P$. We write $\mathsf{DCPO}_\bot$ for the category of dcpos
with bottom and continuous maps between them; a map is
\emph{continuous} if it is monotone and preserves directed joins.
\begin{defn}
\begin{enumerate}
\item A category $\mathscr{C}$ is \emph{left strictly $\mathsf{DCPO}_\bot$-enriched} provided that each
hom-set is equipped with the structure of a dcpo with bottom, and
composition preserves bottom on the left and is \emph{continuous}: for every morphism
$f$ and appropriate directed sets of morphisms $g_i$ ($i \in D$)
we have
\[
\textstyle
\bot \cdot f = \bot, \qquad
f \cdot \bigvee_{i\in D} g_i = \bigvee_{i\in D} f \cdot g_i,\qquad
\big(\bigvee_{i \in D} g_i\big) \cdot f = \bigvee_{i\in D} g_i
\cdot f.
\]
\item A functor on $\mathscr{C}$ is \emph{locally monotone} if its
restrictions $\mathscr{C}(A,B) \to \mathscr{C}(FA,FB)$ to the hom-sets are monotone.
\end{enumerate}
\end{defn}
\begin{notheorembrackets}
\begin{theorem}[{\cite[Prop.~5.6]{amm21}}]\label{T:DCPOb}\label{T:dcpo}
%
Let $F$ be a locally monotone functor on a left strictly $\mathsf{DCPO}_\bot$-enriched category.
If an initial algebra $(\mu F, \iota)$ exists, then $(\mu F, \iota^{-1})$ is a
terminal coalgebra.
\end{theorem}
\end{notheorembrackets}
\noindent
This result is an adaptation of an earlier related result proved by
Freyd~\cite{Freyd92} for locally continuous functors on
$\omega$-cpo-enriched categories. Note that preservation of bottom on
the right ($f \cdot \bot = \bot$) is not needed for this result.
\section{Coalgebraic Trace Semantics}
\label{S:trace}
In this section we shall see that the (bar) language semantics of NOFAs
and RNNAs is an instance of coalgebraic trace semantics. To this end we
first adapt and generalize the coalgebraic trace semantics for set
functors by Hasuo et al.~\cite{HasuoEA07} to arbitrary
categories. Here one considers coalgebras for composed functors~$TF$,
where $T$ is a monad modelling a branching type like non-determinism
or probabilistic branching, and $F$ models the type of transitions of
systems. We then instantiate this to coalgebras in $\mathsf{Nom}$ for functors
$TF$, where $T$ is $\pow_{\fs}$ and $F$ a polynominal functor or
$T=\pow_{\ufs}$ and $F$ a binding polynomial functor. Specifically, we
obtain the two desired types of nominal automata as instances.
\subsection{General Coalgebraic Trace Semantics Revisited}
We begin by recalling a few facts about extensions of functors to
Kleisli categories.
\begin{rem}\label{R:Kleisli}
Let $F$ be a functor and $(T, \eta, \mu)$ a monad both on
the category~$\mathscr{C}$.
\begin{enumerate}
\item\label{R:Kleisli:1} The \emph{Kleisli category} $\Kl T$ has the
same objects as $\mathscr{C}$ and a morphisms $f$ from $X$ to $Y$ is a
morphism $f\colon X \to TY$ of $\mathscr{C}$. The composition of $f$ with
$g\colon Y \to TZ$ is defined by $\mu_Z \cdot Tg \cdot f$ and the
identity on $X$ is $\eta_X \colon X \to TX$. We have the
identity-on-objects functor $J\colon \mathscr{C} \to \Kl T$ defined by
$J(f\colon X \to Y) = \eta_Y \cdot f$.
\item An endofunctor $\mybar{0.6}{2.5pt}{F}\colon \Kl T \to \Kl T$ \emph{extends}
the functor $F$ if $\bar F J = J F$. It is well-known and easy to
prove (see Mulry~\cite{Mulry94}) that extensions of $F$ to $\Kl T$ are in
bijective correspondence with \emph{distributive laws} of $F$ over
$T$; these are natural transformations $\lambda\colon FT \to
TF$ compatible with the monad structure of~$T$:
\[
\begin{tikzcd}
F
\arrow{r}{F\eta}
\arrow{rd}[swap]{\eta F}
&
FT
\arrow{d}{\lambda}
\\
&
TF
\end{tikzcd}
\qquad\qquad
\begin{tikzcd}
FTT
\arrow{r}{\lambda T}
\arrow{d}[swap]{F\mu}
&
TFT
\arrow{r}{T\lambda}
&
TTF
\arrow{d}{\mu F}
\\
FT
\arrow{rr}{\lambda}
&&
TF
\end{tikzcd}
\]
\item\label{R:Kleisli:3} Let $G$ be a quotient functor of $F$, which means that we have
a natural transformation with epimorphic components
$q\colon F \twoheadrightarrow G$. Suppose that $F$ extends to $\Kl T$
via a distributive law $\lambda\colon FT \to TF$. Then an
object-indexed family of morphisms $\rho_X\colon GTX \to TGX$ is a
distributive law of $G$ over $T$ provided that the following
squares commute
\[
\begin{tikzcd}
FTX
\ar{r}{\lambda_X}
\ar[->>]{d}[swap]{q_{TX}}
&
TFX
\ar[->>]{d}{Tq_X}
\\
GTX
\ar{r}{\rho_X}
&
TGX
\end{tikzcd}
\qquad
\text{for every object $X$ of $\mathscr{C}$.}
\]
\end{enumerate}
\end{rem}
\begin{expl}\label{E:ext}
\begin{enumerate}
\item\label{E:ext:1} Constant functors and the identity functor on $\mathscr{C}$ obviously
extend to $\Kl T$.
\item\label{E:ext:2} Suppose that $\mathscr{C}$ has coproducts. Then for a coproduct $F+G$
of functors $F$ and $G$ one uses that $J\colon \mathscr{C} \to \Kl T$
preserves coproducts. Given extensions $\mybar{0.6}{2.5pt}{F}$ and $\mybar{0.6}{2pt}{G}$, it is
then clear that $\mybar{0.6}{2.5pt}{F} + \mybar{0.6}{2pt}{G}$ extends $F+G$:%
\smnote{We will need the definition on morphisms in the proof of
\autoref{T:RNNA-Kl}; so we need to provide more details.}
for every morphism $f\colon X \to TY$ in $\Kl T$ one has
\[
\mybar{0.9}{2pt}{F + G} (f) = \big(FX + FY \xra{\bar Ff + \bar Gf} TFY+TGY
\xra{[T\mathsf{inl}, T\mathsf{inr}]} T(FY+GY)\big),
\]
where $FY \xra{\mathsf{inl}} FY + GY \xla{\mathsf{inr}} GY$ are the coproduct
injections. This works similarly for arbitrary coproducts.
\item\label{E:ext:3} Suppose that $\mathscr{C}$ has finite products. Then
finite products of functors with an extension can be extended when
the monad $T$ is \emph{commutative}; this notion was introduced by
Kock~\cite[Def.~3.1]{Kock70}. It is based on the notion of a
\emph{strong} monad, that is a monad $T$ equipped with a natural
transformation $s_{X,Y}\colon X \times TY \to T(X\times Y)$
(called \emph{strength}) satisfying four natural equational laws
(two w.r.t.~to~$1$ and~$\times$ on $\mathscr{C}$ and two w.r.t.~the monad
structure). We do not recall these laws explicitly since they are
not needed for our exposition. A strength gives rise to a
\emph{costrength} $t_{X,Y}\colon TX \times Y \to T(X\times Y)$
defined by
\[
t_{X,Y} = \big( TX\times Y\cong Y \times TX \xra{s_{Y,X}} T(Y
\times X) \xra{T(\cong)} T(X\times Y) \big).
\]
The monad $T$ is \emph{commutative} if the following diagram
commutes:
\[
\begin{tikzcd}[row sep = 0, column sep = 30]
&
T(TX \times Y)
\ar{r}{Tt_{X,Y}}
&
TT(X\times Y)
\ar{rd}[near start]{\mu_{X\times Y}}
\\
TX \times TY
\ar{ru}[near end]{s_{TX,Y}}
\ar{rd}[near end, swap]{t_{X,TY}}
\ar[dashed]{rrr}{d_{X,Y}}
&&&
T(X\times Y)
\\
&
T(X \times TY)
\ar{r}{Ts_{X,Y}}
&
TT(X \times Y
\ar{ru}[near start,swap]{\mu_{X\times Y}}
\end{tikzcd}
\]
The ensuing natural transformation $d$ in the middle is used to
extend the product $F \times G$ of endofunctors on $\mathscr{C}$
having extensions $\mybar{0.6}{2.5pt}{F}$ and $\mybar{0.6}{2pt}{G}$ on $\Kl T$: for every
morphism $f\colon X \to TY$ in $\Kl T$ one puts%
\smnote{Note that the barF and barG macros don't work on the label
arrows; TODO: perhaps fix this later.}
\[
\mybar{0.9}{2pt}{F \times G} (f) = \big(FX \times GX \xra{\bar F f \times \bar G f} TFY
\times TGY \xra{d_{FY,GY}} T(FY \times GY)\big).
\]
\end{enumerate}
\end{expl}
\begin{rem}
\begin{enumerate}
\item Every set monad is strong via a canonical strength; this
follows, for example, from Moggi's
result~\cite[Thm.~3.4]{Moggi91}. Commutative set monads are those
in whose algebraic theory every operation is a homomorphism. For
example, the power-set functor $\mathcal{P}\colon \mathbf{Set} \to \mathbf{Set}$ is
commutative via its canonical strength having the components
\begin{equation}\label{eq:pstr}
s_{X,Y}\colon X \times \mathcal{P} Y \to \mathcal{P}(X \times Y)
\quad
\text{defined by}
\quad
(x,S) \mapsto \set{(x,s) : s \in S}.
\end{equation}
\item As a consequence of what we saw in \autoref{E:ext} every
polynomial set functor has a canonical extension to the Kleisli
category of any commutative set monad
(cf.~\cite[Lem.~2.4]{HasuoEA07}).
\item More generally, this results holds for analytic set
functors~\cite[Thm.~2.9]{mps09}. That notion was introduced by
Joyal~\cite{Joyal81,Joyal86}, and he proved that analytic set
functors are precisely those set functors which weakly preserve wide
pullbacks.
\end{enumerate}
\end{rem}
With the help of Hermida and Jacobs' result~\cite[Thm.~2.14]{HermidaJ98} on
extending adjunctions to categories of algebras one easily obtains the
following extension result for initial algebras:
\begin{proposition}\label{P:ini}
Let $T$ be a monad on the category $\mathscr{C}$ and let $F\colon \mathscr{C} \to \mathscr{C}$
have an extension $\bar F$ on $\Kl T$. If $(\mu F, \iota)$ is an
initial $F$-algebra, then $\mu F$ is an initial $\mybar{0.6}{2.5pt}{F}$-algebra with
the structure $J\iota = \eta_{\mu F} \cdot \iota\colon \mu F
\to TF(\mu F)$.
\end{proposition}
Coalgebraic trace semantics can be defined when the extended initial
algebra above is also a terminal coalgebra for $\mybar{0.6}{2.5pt}{F}$.
\begin{theorem}\label{T:Kl}
Let $F$ be a functor and $T$ a monad on the category
$\mathscr{C}$. Assume that $\Kl T$ is left strictly $\mathsf{DCPO}_\bot$-enriched and that $F$ has a locally monotone extension
$\mybar{0.6}{2.5pt}{F}$ on $\Kl T$ and an
initial algebra $(\mu F, \iota)$. Then $(\mu F, J\iota^{-1})$ is a terminal
coalgebra for $\mybar{0.6}{2.5pt}{F}$.
\end{theorem}
\begin{proof}
Immediate from \autoref{P:ini} and \autoref{T:dcpo}.
\qed
\end{proof}
\noindent
Compared to the previous result for $\mathbf{Set}$~\cite[Thm.~3.3]{HasuoEA07}
our assumption on the enrichment of the Kleisli category is slightly
stronger; in op.~cit.~only enrichment in $\omega$-cpos is required. A
related result~\cite[Thm.~5.3.4]{Jacobs16} for general
base categories uses enrichment in directed-complete partial
orders. However, in contrast to both of these results, we do not
require that $\Kl T$ has a zero object and, most notably, we only need
the mere existence of $\mu F$ and not that the initial algebra for $F$
is obtained by the first $\omega$ steps of the initial-algebra chain,
that is, as the colimit of the $\omega$-chain given by $F^n 0$
($n < \omega$). The technical reason for this is that the proof of
\autoref{T:dcpo} does not make use of the classical limit-colimit
coincidence technique used e.g.~by Smyth and Plotkin in their seminal
work~\cite{SmythPlotkin82}. Consequently, our proof is easier and
shorter than the previous ones.
\begin{definition}[Coalgebraic Trace Semantics]\label{D:tr}
Given $F$ and $T$ on $\mathscr{C}$ satisfying the assumptions in
\autoref{T:Kl} and a coalgebra $c\colon X \to TFX$. The
\emph{coalgebraic trace map} is the unique coalgebra homomorphism
$\mathsf{tr}_c$ from $(X, c)$ to $(\mu F, J\iota^{-1})$; that is, the
following diagram commutes in $\Kl T$:
\begin{equation}\label{eq:trc}
\begin{tikzcd}[column sep = 30, row sep = 15]
X \ar{d}[swap]{c} \ar{r}{\mathsf{tr}_c}
&
\mu F
\ar{d}{J\iota^{-1}}
\\
\mybar{0.6}{2.5pt}{F} X
\ar{r}{\bar F \mathsf{tr}_c}
&
\mybar{0.6}{2.5pt}{F}(\mu F)
\end{tikzcd}
\end{equation}
\end{definition}
Among the instances of coalgebraic trace semantics are the trace
semantics of labelled transition systems with explicit
termination~\cite{HasuoEA07}, which are the coalgebras for the set
functor $\mathcal{P}(1 +\Sigma \times X)$ and that of labelled probabilistic
labelled transitions systems~\cite[Ch.~4]{Hasuo08}, which are the
coalgebras for the set functor $\mathcal D_\leq(1 + \Sigma \times X)$,
where $\mathcal D_\leq$ denotes the subdistribution monad.
\subsection{Coalgebraic Trace Semantics of Non-deterministic Nominal
Systems}
We will now work towards showing that the semantics of nominal
automata is an instance of the coalgebraic trace semantics. To this
end we will instantiate \autoref{T:Kl} to $\mathscr{C}=\mathsf{Nom}$,
$FX=1+\mathbb{A}\times X$ and $T=\pow_{\fs}$ (for NOFAs), or to
$FX = 1 + \mathbb{A} \times X + [\mathbb{A}] X$ and $T = \pow_{\ufs}$ (for RNNAs),
\newcommand{\remautorefname}{Remarks}%
cf.~\autoref{rem:nofa-as-coalgebras} and~\ref{rem:rnna-as-coalgebras}.
\renewcommand{\remautorefname}{Remark}%
More generally, we show that every endofunctor arising from a nominal
algebraic signature in the sense of Pitts~\cite[Def.~8.2]{Pitts13} has
a locally monotone extension to $\Kl\pow_{\ufs}$. For $T = \pow_{\fs}$ most
of the development works out, as we shall see. However, the
distributive law for the abstraction functor in the proof of
\autoref{P:abs-dist} is not well-defined for $\pow_{\fs}$.
But the first obstacle is that the nominal sets $\pow_{\fs} X$ and
$\pow_{\ufs} X$ are in general no complete lattices (and not even
$\omega$-cpos) since the union of a chain of (uniformly) finitely
supported sets may fail to be (uniformly) finitely supported.%
\smnote{TODO: We need to mention a concrete counterexampel (in the
appendix)!} In this light, the following result is slightly
surprising.
\begin{proposition}\label{P:dcpo}
For every pair $X,Y$ of nominal sets, the sets $\Kl\pow_{\fs}(X,Y)$ and $\Kl\pow_{\ufs}(X,Y)$
form complete lattices (whence dcpos with bottom).
\end{proposition}
\begin{corollary}\label{C:ini-ter}
If a locally monotone endofunctor $H$ on $\Kl\pow_{\fs}$ or $\Kl\pow_{\ufs}$ has an initial
algebra $(\mu H, \iota)$, then $(\mu H, \iota^{-1})$ is its terminal
coalgebra.
\end{corollary}
\noindent
This is a consequence of~\autoref{T:DCPOb} since the composition in
$\Kl\pow_{\fs}$ and $\Kl\pow_{\ufs}$ is easily seen to preserve the bottom
(empty set)
on the left and all joins (unions).
\mysubsec{Extending functors to $\Kl\pow_{\ufs}$.} We now show that
endofunctors arising from a nominal algebraic signature (with one
name and one data sort) have a canonical locally monotone extension
to $\Kl\pow_{\ufs}$. As an instance, we then obtain that the functor $F$
used for RNNAs has a locally monotone extension $\mybar{0.6}{2.5pt}{F}$ on
$\Kl\pow_{\ufs}$.
\begin{definition}
The class of \emph{binding polynomial functors} on $\mathsf{Nom}$ is the smallest
class of functors containing the constant, identity and abstraction
functors and being closed under finite products and coproducts.
\end{definition}
\noindent In other words, binding polynomial functors are formed
according to the following grammar:
\begin{equation}\label{eq:grammar}
\textstyle
F ::= C \mid \mathsf{Id} \mid [\mathbb{A}](-) \mid F \times F \mid \coprod_{i\in
I} F_i,
\end{equation}
where $C$ ranges over all constant functors on $\mathsf{Nom}$ and $I$ is an
arbitrary index set. These functors are precisely the functors
associated to a nominal algebraic signature with one name sort and one data
sort (see Pitts~\cite[Def.~8.12]{Pitts13}).
\begin{proposition}\label{P:comm}\smnote{Aren't there any results known in the literature that the
power object monad on a topos (satisfying s.th.) is commutative?}%
The monads $\pow_{\fs}$ and $\pow_{\ufs}$ are commutative.
\end{proposition}
\begin{proposition}\label{P:abs-dist}
The abstraction functor $[\mathbb{A}](-)$ has a locally monotone
extension on $\Kl \pow_{\ufs}$.
\end{proposition}
\begin{proof}[Sketch]
One uses \autoref{R:Kleisli}\ref{R:Kleisli:3}: the abstraction
functor is a quotient of the functor $FX = \mathbb{A} \times X$ which is
equipped with the canonical distributive law
$\lambda_X\colon \mathbb{A} \times \pow_{\ufs} X \to \pow_{\ufs}(\mathbb{A} \times
X)$ defined as in~\eqref{eq:pstr}. The maps $\rho_X\colon
[\mathbb{A}](\pow_{\ufs} X) \to \pow_{\ufs}([\mathbb{A}] X)$ are defined by
$\rho_X (\braket a S) = \set{\braket a s : s \in S}$.
\qed
\end{proof}
\begin{rem}
\smnote{Das ist Ex.~4.5 aus Üsames Projektarbeit.}%
For the monad $\pow_{\fs}$ our proof does not work. The problem is
that~$\rho_X$ above is not well-defined in general if $S$ is
not uniformly finitely supported. For example, for
$\mathbb{A} \in \pow_{\fs} \mathbb{A}$ we have
$\braket a \mathbb{A} = \braket b \mathbb{A}$ for every pair $a, b$ of
names. However, if $a \neq b$, then the sets
$\set{\braket a c : c \in \mathbb{A}}$ and
$\set{\braket b c : c \in \mathbb{A}}$ differ: $\braket a b$ is
contained in the former but not in the latter set. In fact, since $a \neq b$,
$\braket a b = \braket b c$ can hold only if $a\mathbin{\#}\set{b,c}$ and
$b = (a\, b)\cdot c$ (see Pitts~\cite[Lem.~4.3]{Pitts13}). The
latter means that $c = a$ contradicting freshness of $a$ for it.
\end{rem}
\begin{corollary}\label{cor:extension-pufs}
Every binding polynomial functor has a canonical locally monotone extension to
$\Kl\pow_{\ufs}$.
\end{corollary}
Unsurprisingly, an analogous result holds for polynomial functors and
$\pow_{\fs}$ by the same reasoning applied to a grammar as in~\eqref{eq:grammar}
that does not include the abstraction functor:
\begin{corollary}\label{cor:extension-pfs}
Every polynomial functor has a canonical locally monotone extension to
$\Kl\pow_{\fs}$.
\end{corollary}
\mysubsec{Nominal Coalgebraic Trace Semantics.} From
Pitts~\cite[Thm.~8.15]{Pitts13} we know that every binding polynomial
functor has an initial algebra carried by the nominal set $T_F$ of
terms modulo $\alpha$-equivalence (defined in Def.~8.6 of op.~cit.) of
the nominal algebraic signature associated to $F$. If $F$ is
polynomial, then $\alpha$-equivalence is trivial and $T_F$ the
usual set of terms. By \autoref{C:ini-ter} we have
\begin{corollary}
\begin{enumerate}
\item For every polynomial functor $F$ the terminal coalgebra of its canonical extension $\mybar{0.6}{2.5pt}{F}$ on $\Kl\pow_{\fs}$ is carried by the nominal set $T_F$.
\item For every binding polynomial functor $F$ the terminal coalgebra of
its canonical extension $\mybar{0.6}{2.5pt}{F}$ on $\Kl\pow_{\ufs}$ is carried by the
nominal set $T_F$.
\end{enumerate}
\end{corollary}
\noindent
According to \autoref{D:tr} we can thus define a coalgebraic trace
semantics for every coalgebra $X \to \pow_{\fs} FX$ with $F$ a polynomial functor, as well as for every coalgebra $X\to \pow_{\ufs} FX$ with $F$ a binding
polynomial functor. We now instantiate this to the two types of nominal automata introduced in
\autoref{sec:nom-aut}.
\mysubsec{Coalgebraic Trace Semantics of NOFAs.} Recall from
\autoref{rem:nofa-as-coalgebras} that NOFAs are coalgebras
$X\to \pow_{\fs} F X$ where $FX=1+\mathbb{A}\times X$ on $\mathsf{Nom}$.
\begin{proposition}\label{prop:ini-nofa}
The initial algebra for $F$ is the nominal set $\mathbb{A}^*$ with
structure $\iota\colon 1+\mathbb{A}\times \mathbb{A}^* \to \mathbb{A}^*$ defined
by $\iota(\ast)=\epsilon$ and $\iota(a,w)=aw$.
\end{proposition}
Indeed, the functor $F$ arises from from the algebraic signature with
a constant $\epsilon$ and unary operations $a(-)$ for every
$a \in \mathbb{A}$, and clearly the corresponding term algebra is
isomorphic to the algebra $\mathbb{A}^*$.
\begin{corollary}\label{C:ini}
The terminal coalgebra for the extension
$\mybar{0.6}{2.5pt}{F}\colon \Kl\pow_{\fs} \to \Kl\pow_{\fs}$ is $(\mathbb{A}^*, J\iota^{-1})$
for $\iota$ from~\autoref{prop:ini-nofa}.
\end{corollary}
\begin{theorem}\label{T:NOFA-Kl}
For every NOFA $c\colon X \to \pow_{\fs} FX$ its coalgebraic trace map
$\mathsf{tr}_c\colon X \to \pow_{\fs}(\mathbb{A}^*)$ assigns to every state of $X$
its accepted data language.
\end{theorem}
\mysubsec{Coalgebraic Trace Semantics of RNNAs.} Recall from
\autoref{rem:rnna-as-coalgebras} that RNNAs are coalgebras
$X \to \pow_{\ufs} FX$ where $FX = 1 + \mathbb{A} \times X + [\mathbb{A}] X$ on
$\mathsf{Nom}$.
\begin{proposition}\label{prop:ini}
The initial algebra for $F\colon \mathsf{Nom} \to \mathsf{Nom}$ is the nominal set
$\barA^*/\mathord{=_\alpha}$ of all bar strings modulo $\alpha$-equivalence with the
algebra structure $\iota\colon 1 +\mathbb{A} \times (\barA^*/\mathord{=_\alpha}) +
[\mathbb{A}](\barA^*/\mathord{=_\alpha}) \to \barA^*/\mathord{=_\alpha}$ defined by
\begin{equation}\label{eq:iniF}
\iota(*)= [\varepsilon]_\alpha,
\qquad
\iota(a,[w]_\alpha) = [aw]_\alpha,
\qquad
\iota(\braket a [w]_\alpha) = [|aw]_\alpha.
\end{equation}
\end{proposition}
\noindent
Indeed, the functor $F$ arises from a nominal algebraic signature with
a constant~$\varepsilon$, unary operations $a(-)$ for every $a \in \mathbb{A}$
and one unary name binding operation $\newletter{}$. Terms over this
signature are obviously the same as bar strings. Moreover, it is not
difficult to show that Pitts' notion of $\alpha$-equivalence for
terms~\cite[Def.~8.6]{Pitts13} is equivalent to $\alpha$-equivalence
for bar strings in~\autoref{def:alpha-fin}. Finally, the algebra
structure in~\eqref{eq:iniF} above corresponds to the one given by term formation by
Pitts~\cite[Thm.~8.15]{Pitts13}. Using \autoref{T:Kl} we thus
obtain the following result.
\begin{corollary}
The terminal coalgebra for the extension
$\mybar{0.6}{2.5pt}{F}\colon \Kl\pow_{\ufs} \to \Kl\pow_{\ufs}$ is $(\barA^*/\mathord{=_\alpha}, J\iota^{-1})$
for $\iota$ from~\eqref{eq:iniF}.\smnote{The next overfull goes away
if we switch the document from `draft' to `final'!}%
\end{corollary}
\begin{theorem}\label{T:RNNA-Kl}
For every RNNA $c\colon X \to \pow_{\ufs} FX$ its coalgebraic trace map
$\mathsf{tr}_c\colon X \to \pow_{\ufs}(\barA^*/\mathord{=_\alpha})$ assigns to every state of $X$
its accepted bar language.
\end{theorem}
\section{Coalgebraic Language Semantics}
\label{S:lang}
In this section we shall see that the language semantics of NOFAs
and RNNAs is an instance of coalgebraic language
semantics~\cite{bms13}. The latter is based on the generalized
determinization construction by Silva et al.~\cite{SilvaEA13}. Here
one considers coalgebras for a functor $GT$, where $T$ models a
branching type and $G$ models the type of transition of a system
(similarly as before in the coalgebraic trace semantics, but this time
the order of composition is reversed). Again, we will apply this to
coalgebras in $\mathsf{Nom}$ for functors $GT$, where $T
= \pow_{\fs}$ and $G$ is functor composed of products and exponentials, or to $T= \pow_{\ufs}$ and $G$ composed of products, exponentials and binding functors. Specifically, we obtain the two desired types
of nominal automata as instances.
\subsection{A Recap of General Coalgebraic Language Semantics}
\label{S:lan}
We begin by recalling a few fact about liftings of functors to
Eilenberg-Moore categories.
\begin{rem}\label{R:lift}
Let $G$ be a functor and $(T,\eta,\mu)$ be a monad
on the category $\mathscr{C}$.
\begin{enumerate}
\item The \emph{Eilenberg-Moore} category $\EM T$ consists of
algebras $(A,a)$ for $T$, that is, pairs formed by an object $A$ and a
morphism $a\colon TA \to A$ such that $a\cdot \eta_A=\mathit{id}_A$ and $a \cdot \mu_A = a
\cdot Ta$. A morphism in $\EM T$ from $(A,a)$ to $(B,b)$ is a
morphism $h\colon A \to B$ of $\mathscr{C}$ such that $h \cdot a = b \cdot
Th$. We write $U\colon \EM T \to \mathscr{C}$ for the forgetful functor
mapping an algebra $(A,a)$ to its underlying object $A$.
\item A \emph{lifting} of $G$ is an endofunctor $\widehat{G} \colon \EM T \to \EM
T$ such that $GU = U\widehat{G}$. As shown by Applegate~\cite{Applegate65} (see
also Johnstone~\cite{Johnstone75}), liftings of $G$ to $\EM T$ are in
bijective correspondence with distributive laws of $T$ over
$F$. The latter are natural transformations $\lambda\colon TG \to
GT$ compatible with the monad structure:
\[
G\eta = \lambda \cdot \eta G,
\qquad
\lambda \cdot \mu G = G\mu \cdot \lambda T \cdot T\lambda.
\]
\item\label{R:lift:3} Suppose that $G$ has the lifting $\widehat{G}$ on $\EM T$ via the
distributive law $\lambda$. It
follows from the work of Turi and Plotkin~\cite{TuriP97} (see also
Bartels~\cite[Thm.~3.2.3]{Bartels04}) that the terminal coalgebra for $G$ lifts to
a terminal coalgebra for $\widehat{G}$. In fact, one obtains a
canonical structure of a $T$-algebra on $\nu G$ by
taking the unique coalgebra homomorphism
$\alpha$ in the diagram below:
\[
\begin{tikzcd}
T(\nu G)
\ar{r}{T\tau}
\ar{d}[swap]{\alpha}
&
TG(\nu G)
\ar{r}{\lambda_{\nu G}}
&
GT(\nu G)
\ar{d}{G\alpha}
\\
\nu G
\ar{rr}{\tau}
&&
G(\nu G)
\end{tikzcd}
\]
It is then easy to prove that $\alpha$ is indeed the structure of an
algebra for $T$ and that $\tau\colon \nu G \to G(\nu G)$ is a
homomorphism of Eilenberg-Moore algebras (in fact, this is
expressed by the commutativity of the above diagram). Moreover,
$(\nu G, \tau)$ is the terminal $\widehat{G}$-coalgebra.
\end{enumerate}
\end{rem}
\begin{proposition}\label{P:adj-trans}
Let $T\colon \mathscr{C} \to \mathscr{C}$ be a monad and $L \dashv R\colon \mathscr{C} \to \mathscr{C}$
an adjunction with the counit $\varepsilon\colon LR \to \mathsf{Id}$. Given a distributive law
$\lambda\colon LT \to TL$, we obtain a
distributive law $\rho\colon TR \to RT$ as the adjoint
transpose of
\mbox{\(
LTR \xra{\lambda R} TLR \xra{T\varepsilon} T.
\)}
\end{proposition}
\begin{expl}\label{E:lift}
\begin{enumerate}
\item The identity functor on $\mathscr{C}$ obviously
lifts to $\EM T$, and so does a constant functor on the carrier object
of an Eilenberg-Moore algebra for~$T$.
\item Suppose that $\mathscr{C}$ has products. Then for a product $F \times
G$ of functors one uses that $U$ preserves products. Given
liftings $\widehat{F}$ and $\widehat{G}$, it is clear that $\widehat{F} \times
\widehat{G}$ is a lifting of $F\times G$. This works similarly for
arbitrary products.
\item Suppose that $\mathscr{C}$ is cartesian closed and that the monad $T$
is strong (cf.~\autoref{E:ext}\ref{E:ext:3}). Then the
exponentiation functor $(-)^A$ lifts to $\EM T$ for every object
$A$ of $\mathscr{C}$. In fact, we apply \autoref{P:adj-trans} to the
adjunction $A \times (-) \dashv (-)^A$ and use that two of the
axioms of the strength $A \times TX \to T(A \times X)$ state that
it is a distributive law of $A\times (-)$ over $T$.
\takeout
it is an easy exercise
(see~\cite[Exercise~5.2.16]{Jacobs16}) to prove that one obtains a
distributive law $\lambda$ with the component at an object $X$
given by currying the following morphisms
\[
Y \times T(X^Y) \xra{s_{Y,X^Y}} T(Y \times X^Y) \xra{T\mathsf{ev}} TX,
\]
where $s$ is the strength of $T$ and $\mathsf{ev}\colon Y \times X^\mathscr{Y} \to
X$ is the evaluation morphism (a component of the counit of the
adjunction $Y \times (-) \dashv (-)^Y$.
\end{enumerate}
\end{expl}
\begin{rem}\label{R:hom-ext}
Recall that, for every monad $(T,\eta,\mu)$ on $\mathscr{C}$, the pair
$(TX,\mu_X)$ is the free algebra for $T$ on $X$ with the
universal morphism $\eta_X\colon X \to TX$. Given an Eilenberg-Moore
algebra $(A,a)$ for $T$ and a morphism $f\colon X \to A$ in
$\mathscr{C}$, we have a unique morphism $f^\sharp\colon (TX,\mu_X) \to
(A,a)$ in $\EM T$ such that $f^\sharp \cdot \eta_X
= f$. We call $f^\sharp$ the \emph{homomorphic extension} of $f$
\end{rem}
\begin{construction}[Generalized Determinization~\cite{SilvaEA13}]\label{C:gen-det}
Let $T$ be a monad on the category $\mathscr{C}$ and $G$ an endofunctor on
$\mathscr{C}$ having a lifting $\widehat{G}$ on $\EM T$. Given a coalgebra
$c\colon X \to GTX$ its \emph{(generalized) determinization} is the
$G$-coalgebra obtained by taking the homomorphic extension
$c^\sharp\colon TX \to GTX$ using that $\mybar{0.6}{2pt}{G}(TX, \mu_X)$ is an
algebra for $T$ carried by $GTX$.
\end{construction}
\takeout
\begin{rem}\label{R:gen-det}
It is straightforward to establish that for every homomorphism
$h\colon (X,c) \to (Y,d)$ we obtain that $Th\colon (TX,c^\sharp) \to
(TY,d^\sharp)$ is a homomorphism of coalgebras for $\widehat{G}$. It
follows that generalized determinization
is the object assigment of a functor $D\colon \Coalg TF \to \Coalg
\widehat{G}$.
\end{rem}
\noindent
Among the instances of this construction are the well-known power-set construction of
deterministic automata~\cite{SilvaEA13} as well as the non-determinization of alternating
automata and that of Simple Segala systems~\cite{JacobsEA15}.
\begin{defn}[Coalgebraic Language Semantics~\cite{bms13}]\label{D:coalg-lan-sem}
Given $T$, $G$ and a coalgebra $c\colon X \to GTX$ as in \autoref{C:gen-det}, the
\emph{coalgebraic language morphism} $\ddagger c\colon X \to \nu G$ is the
composite of the unique coalgebra homomorphism $h$ from the
determinization of $(X,c)$ to $\nu G$ with the unit $\eta_X$ of the
monad $T$, which is summarized in the diagram below:
\[
\begin{tikzcd}
X
\ar{d}[swap]{c}
\ar{r}{\eta_X}
\ar[shiftarr = {yshift=15}]{rr}{\ddagger c}
&
TX
\ar{r}{h}
\ar{dl}[swap]{c^\sharp}
&
\nu G
\ar{d}{\tau}
\\
GTX
\ar{rr}{Gh}
&
&
G(\nu G)
\end{tikzcd}
\]
\end{defn}
\noindent
Among the instances of coalgebraic language semantics are, of course,
the language semantics of non-deterministic~\cite{SilvaEA13,JacobsEA15}, weighted and
probabiblistic automata, but also the languages generated by
context-free grammars~\cite{WinterEA13,mpw20}, constructively
$\mathds{S}$-algebraic formal power-series for a semiring $\mathds{S}$ (the
`context-free' weighted languages)~\cite{WinterEA15,mpw20}. Less
direct instances are the languages accepted by machines with extra
memory such as (deterministic) push-down automata and Turing
machines~\cite{gms20}.%
\smnote{Note that weighted and probabilistic automata do not seem to
appear in~\cite{SilvaEA13,JacobsEA15}; so the only source would be
our book.}
\mysubsec{Relation of Coalgebraic Trace and Language Semantics.}
Jacobs et al.~\cite{JacobsEA15} show how the coalgebraic trace
semantics and coalgebraic language semantics are connected in cases
where both are applicable. We give a terse review of this including a
proof (see appendix) of the result of op.~cit.~that we use here.
\begin{assumption}
We assume that $T$ is a monad and $F, G$ are endofunctors, all on
the category $\mathscr{C}$, such that $F$ has the extension $\mybar{0.6}{2.5pt}{F}$ on
$\Kl T$ via the distributive law $\lambda\colon FT \to TF$ and $G$
has the lifting $\widehat{G}$ on $\EM T$ via the distributive law
$\rho\colon TG \to GT$. Moreover, we assume that we have an
\emph{extension} natural transformation $\varepsilon\colon TF \to GT$
compatible with the two distributive laws:
\begin{equation}\label{diag:eps}
\begin{tikzcd}
TFT
\ar{r}{T\lambda}
\ar{d}[swap]{\varepsilon T}
&
TTF
\ar{r}{\mu F}
&
TF
\ar{d}{\varepsilon}
\\
GTT
\ar{rr}{G\mu}
&&
GT
\end{tikzcd}
\qquad\quad
\begin{tikzcd}
TTF
\ar{rr}{\mu F}
\ar{d}[swap]{T\varepsilon}
&&
TF
\ar{d}{\varepsilon}
\\
TGT
\ar{r}{\rho T}
&
GTT
\ar{r}{G \mu}
&
GT
\end{tikzcd}
\end{equation}
\end{assumption}
\begin{rem}\label{R:eps}
\begin{enumerate}
\item\label{R:eps:1} For every object $X$ of $\mathscr{C}$ the morphism $\varepsilon_X$ is
a homomorphism of Eilenberg-Moore algebras for $T$ from
$(TFX, \mu_{FX})$ to $\widehat{G}(TX, \mu_X)$. Indeed, this is precisely
what the commutativity of the diagram on the right
in~\eqref{diag:eps} expresses.
\item\label{R:eps:2} For every coalgebra $c\colon X \to TFX$ the
extension natural transformation yields a coalgebra
$\varepsilon_X \cdot c\colon X \to GTX$, and we take its determinization
$(TX, (\varepsilon_X \cdot c)^\sharp)$. This is the object assignment of
the functor $E\colon \Coalg \mybar{0.6}{2.5pt}{F} \to \Coalg \widehat{G}$ which maps an
$\mybar{0.6}{2.5pt}{F}$-coalgebra homomorphism $h\colon (X,c) \to (Y,d)$ to
$Eh = h^\sharp\colon TX \to TY$, the homomorphic extension of
$h\colon X \to TY$ (in $\mathscr{C}$). One readily proves that $h^\sharp$
is a $\widehat{G}$-coalgebra homomorphism using the naturality of $\varepsilon$
as well as the laws in~\eqref{diag:eps}. Functoriality follows
since $E$ is clearly a lifting of the canonical comparison functor
$\Kl T \to \EM T$; see Jacobs et al.~\cite[Thm.~2]{JacobsEA15} for
the proof, and we include a proof in the appendix for the
convenience of the reader.
\item\label{R:eps:3} We obtain a canonical morphism
$e\colon T(\mu F) \to \nu G$ by applying the functor $E$ to the
coalgebra $J\iota^{-1}\colon \mu F \to TF(\mu F)$
(cf.~\autoref{P:ini}) and taking the unique coalgebra homomorphism
from it to the terminal $\widehat{G}$-coalgebra
(\autoref{R:lift}\ref{R:lift:3}).
\end{enumerate}
\end{rem}
Now recall the coalgebraic trace semantics from \autoref{D:tr}. The
following result follows from Jacobs et al.'s
result~\cite[Prop.~5]{JacobsEA15}.
\begin{proposition}\label{P:relation}
For every coalgebra $c\colon X \to TFX$ we have
\[
\ddagger(\varepsilon_X\cdot c) = \big(X \xra{\mathsf{tr}_c} T(\mu F) \xra{e} \nu G \big).
\]
\end{proposition}
\subsection{Coalgebraic Language Semantics of Nominal Systems}
We will now work towards that the language semantics of nominal
automata is an instance of coalgebraic language semantics. To this end
we will instantiate the results of \autoref{S:lan} to $\mathscr{C}= \mathsf{Nom}$,
$GX = 2 \times X^\mathbb{A}$ and $T = \pow_{\fs}$ (for NOFAs), or to
$GX = 2 \times X^\mathbb{A} \times [\mathbb{A}]X$ and $T= \pow_{\ufs}$ (for
RNNAs). More generally, in the former case we show that certain
polynomial functors $G$ with exponentiation lift to $\EM\pow_{\fs}$, and in the latter
case, certain binding polynomial functors with exponentation lift to
$\EM\pow_{\ufs}$. For our specific instances of interest we show that
the terminal coalgebra $\nu G$ is given by (data or bar)
languages. The desired end result than follows by an application of
\autoref{P:relation}.
The class of functors $G$ we consider are formed according
to the grammar
\begin{equation}\label{eq:grammar-2}
G ::= A \mid \mathsf{Id} \mid [\mathbb{A}](-) \mid \prod_{i \in I} G_i \mid G^N,
\end{equation}
where $A$ ranges over all nominal sets equipped with the structure
$a\colon \pow_{\ufs} A \to A$ of an algebra for the monad $\pow_{\ufs}$, $I$
is an arbitrary index set, and $N$ ranges over all nominal sets.
Every such functor $G$ has a canonical lifting to $\EM \pow_{\ufs}$.
This can be proved by induction over the grammar using
\autoref{E:lift} and
\begin{proposition}\label{P:lift-abst}
The abstraction functor has a canonical lifting to $\EM \pow_{\ufs}$.
\end{proposition}
\begin{proof}
The abstraction functor $[\mathbb{A}](-)$ has a left-adjoint $\mathbb{A} *
(-)$, where $*$ denotes the \emph{fresh product} defined for two
nominal sets $X$ and $Y$ by
\[
X * Y = \set{(x,y) : x \in X,\, y\in Y,\, \supp(x) \cap\supp(y) = \emptyset},
\]
see \cite[Thm 4.12]{Pitts13}. The strength of $\pow_{\ufs}$ restricts to the fresh product; we
have
\[
s_{X,Y}\colon X * \pow_{\ufs} Y \to \pow_{\ufs}(X * Y)
\qquad
(x,S) \mapsto \set{(x,s) : s \in S}.
\]
Indeed, if $\supp x \cap \supp S = \emptyset$, then $\supp x \cap
\supp s = \emptyset$ for every $s\in S$ because $S$ is uniformly finitely supported and thus $\supp s \subseteq
\supp S$. It follows that
$s_{\mathbb{A}, X}\colon \mathbb{A} * \pow_{\ufs} X \to \pow_{\ufs} (\mathbb{A} * X)$
yields a distributive law of $\mathbb{A} *(-)$ over $\pow_{\ufs}$. By
\autoref{P:adj-trans} we thus obtain a distributive law of $\pow_{\ufs}$
over $[\mathbb{A}] (-)$.
\qed
\end{proof}
\begin{corollary}\label{C:lift-nu}
For every functor $G$ according to the grammar in
\eqref{eq:grammar-2} the terminal coalgebra $\nu G$ lifts to a
terminal coalgebra of $\widehat{G}$ on $\EM\pow_{\ufs}$.
\end{corollary}
\noindent
The terminal coalgebra $\nu G$ exists since every such $G$ is an
accessible functor on $\mathsf{Nom}$. This can be shown by induction on the
structure of $G$; for exponention in the induction step one argues
similarly as Wißmann~\cite[Cor.~3.7.4]{Wissmann20} has done for
orbit-finite sets: an exponentiation functor $(-)^N$ is
$\lambda$-accessible iff the set of orbits of $N$ has cardinality less than $\lambda$.
\smnote{Or is there a better reference for this?}
Now use \autoref{R:lift}\ref{R:lift:3}.%
Consequently, one can define a coalgebraic language semantics for
every functor $G$ according to the grammar~\eqref{eq:grammar-2}.
\begin{rem}
\begin{enumerate}
\item For $T = \pow_{\fs}$ one has the same results for functors $G$ on
$\mathsf{Nom}$ according to the reduced grammar obtained from the one
in~\eqref{eq:grammar-2} by dropping the abstraction functor
$[\mathbb{A}](-)$. In fact, a functor according to the reduced grammar
has a canonical lifting to $\EM T$ whenever $T$ is a strong monad
on a cartesian closed category (by \autoref{E:lift}).
\item We have dropped the abstraction functor in the previous item
because our proof of \autoref{P:lift-abst} does not work for
$\pow_{\fs}$. The problem is that the strength in~\eqref{eq:pstr} does
not restrict to the fresh product for all finitely supported
subsets. Indeed, even if $\supp(x)$ and $\supp(S)$ are disjoint,
the support of $x$ may not be disjoint from that of every element
$s\in S$, whence $(x,s)$ does not lie in $X * Y$. For example,
take $X = Y = \mathbb{A}$ and $S = \mathbb{A} \setminus \set {a}$ for some
$a \in \mathbb{A}$. Clearly, $\supp(S) = \set{a}$. Thus, for every
$b \neq a$, we see that $(b,S)$ lies in
$\mathbb{A} * \pow_{\fs}\mathbb{A}$. However, while $b \in S$ we do not
have that
$(b,b) \in \mathbb{A} * \mathbb{A} = \set{(a,a') : a,a' \in \mathbb{A},
a\neq a'}$, which means that $s_{\mathbb{A},\mathbb{A}}(b, S)$ does not
lie in $\pow_{\fs}(\mathbb{A} * \mathbb{A})$.
%
\takeout{
%
For the monad $\pow_{\fs}$ the above proof does not work. The problem
is that the isomorphism $\psi_X$ is not a distributive law because
the diagram
\[
\begin{tikzcd}
\pow_{\fs}\powfs({[\mathbb{A}]}X) \ar{rr}{\mu_{[\mathbb{A}]X}}
\ar{d}[swap]{\pow_{\fs}\psi_X}
& &
\pow_{\fs}({[\mathbb{A}]}X) \ar{d}{\psi_X}
\\
\pow_{\fs}({[\mathbb{A}]}(\pow_{\fs} X)) \ar{r}{\psi_{\pow_{\fs} X}}
&
{[\mathbb{A}]}(\pow_{\fs}\powfs X) \ar{r}{[\mathbb{A}]\mu_X}
&
{[\mathbb{A}]}\pow_{\fs} X
\end{tikzcd}
\]
does not commute. Indeed, fix $a \in \mathbb{A}$, then $\mathscr{S} = \set{\set{\braket{a}b}:
b \in \mathbb{A}} \in \pow_{\fs}\powfs({[\mathbb{A}]}\mathbb{A})$ with support $\set{a}$,
while every element of $\mathscr{S}$ has support $\set{b} \setminus \set{a}$.
If the diagram above commuted, the equality
\[
\braket{c}\set{x: \braket{c}x \in S \text{ for some } S \in \mathscr{S}}
=
\braket{d}\set{x: \braket{e}x \in S \text{ for some } S \in \mathscr{S},\ e \mathbin{\#} S}
\]
would need to hold, for any $c$ that is fresh for $\set{\braket{a}b: b \in \mathbb{A}}$
and $d$ that is fresh for $\pow_{\fs}\psi_X\mathscr{S}$. Because of Pitts'
Choose-a-Fresh-Name-Principle~\cite[p.~49]{Pitts13}, we can assume $d = c$,
and $d \neq a$, because $a$ supports $\set{\braket{a}b: b \in \mathbb{A}}$.
But then the equality cannot hold, because the set on left side does not
contain $a \in \mathbb{A}$: Since $d \neq a$, $\braket{d}a = \braket{a}b$ can
hold only if $d \mathbin{\#} \set{a,b}$ and $a = (d\,a)\cdot b$ (see
Pitts~\cite[Lem.~4.3]{Pitts13}). The latter means that $b = d$ contradicting
freshness of $d$ for it. However, the set of the right side does contain
$a \in \mathbb{A}$, since $a \mathbin{\#} \set{\braket{a}a}$.
\end{enumerate}
\end{rem}
\mysubsec{Coalgebraic Language Semantics of NOFAs} We now apply the
previous results to $T = \pow_{\fs}$ and $GX = 2 \times X^\mathbb{A}$.
\begin{rem}\label{R:exp}
We have a canonical isomorphism $\pow_{\fs}(\mathbb{A}
\times X) \cong (\pow_{\fs} X)^\mathbb{A}$ given by $S \mapsto (a \mapsto
\set{x: (a,x) \in S})$. This follows from the fact that
$\pow_{\fs}$ is the power object functor on the topos $\mathsf{Nom}$ and so we
have $\pow_{\fs} X \cong 2^X$.
\end{rem}
Consequently, a NOFA may be regarded as a coalgebra for $G\pow_{\fs}$:
\[
X\to \pow_{\fs}(1+\mathbb{A}\times X)\cong 2\times (\pow_{\fs} X)^A =
G\pow_{\fs} X.
\]
\begin{proposition}\label{prop:ter-nofa}
The terminal coalgebra for $G$ is the nominal set $\pow_{\fs}(\names^*)$ of all
data languages with the structure
\[
\pow_{\fs}(\names^*) \xra{\tau} 2 \times \pow_{\fs}(\names^*)^\mathbb{A},\quad
L \mapsto (b, a \mapsto a^{-1}L),
\]
where $b = 1$ if
$\epsilon\in L$ and $0$ else, and $a^{-1}L=\{w\in \mathbb{A}^* : aw\in L \}$.
\end{proposition}
The proof is analogous to the one that for every alphabet $A$ the set
functor $X\to 2\times X^A$ has the terminal coalgebra $\mathcal{P} (A^*)$,
see e.g.~Rutten~\cite{rutten00}.
We may thus define the coalgebraic language semantics for NOFAs as in
\autoref{D:coalg-lan-sem}.
\begin{rem}
We take $FX = 1 + \mathbb{A} \times X $ as in
\autoref{T:NOFA-Kl} and obtain $\mu F = \mathbb{A}^*$
(\autoref{prop:ini-nofa}) and $\nu G = \pow_{\fs}(\names^*)$
(\autoref{prop:ter-nofa}).
%
Moreover, analogous to ordinary non-deterministic
automata~\cite[Sec.~7.1]{JacobsEA15}, we have an extension natural
transformation
$\varepsilon_X\colon \pow_{\fs}(1 + \mathbb{A} \times X) \to 2\times (\pow_{\fs}
X)^\mathbb{A}$ given by
\[
\varepsilon_X(S) = (b, a \mapsto S_a),
\]
where $b = 1$ iff the element $*$ of $1$ lies $S$ and
$S_a = \set{x : (a,x) \in S}$. The ensuing canonical morphism
$e\colon \pow_{\fs}(\mu F) \to \nu G$ from \autoref{R:eps}\ref{R:eps:3}
is then easily seen to be just the identity map on $\pow_{\fs}(\names^*)$.
\end{rem}
\begin{corollary}\label{C:NOFA-EM}
The coalgebraic language semantics assigns to each state of a NOFA
the data language it accepts.
\end{corollary}
\noindent
Indeed, this follows from \autoref{T:NOFA-Kl} and \autoref{P:relation}
using that in the latter result
$e$ is the identity map on $\pow_{\fs}(\names^*)$.
\mysubsec{Coalgebraic Language Semantics of RNNAs} We now apply the
previous results to $T = \pow_{\ufs}$ and $GX = 2 \times X^\mathbb{A} \times
[\mathbb{A}]X$.
\begin{rem}
\begin{enumerate}
\item The canonical isomorphism from \autoref{R:exp}
restricts to an injection
$i\colon \pow_{\ufs}(\mathbb{A} \times X) \rightarrowtail (\pow_{\ufs}
X)^\mathbb{A}$. Indeed, take a uniformly finitely supported subset
$S \subseteq \mathbb{A} \times X$. Then for every $a \in \mathbb{A}$, every
element $x$ of the set $i(S)(a) = \set{x : (a,x) \in S}$ satisfies
$\supp x \subseteq \set{a} \cup \supp x = \supp (a,x) \subseteq \supp S$
and therefore that set lies in $\pow_{\ufs} X$. However, note that the
inverse of the isomorphism from \autoref{R:exp} does not restrict to
uniformly finitely supported subsets.
\item The components
$\rho_X\colon [\mathbb{A}]\pow_{\ufs} X \to \pow_{\ufs}([\mathbb{A}] X)$ of the distributive law from the
proof of \autoref{P:abs-dist} are in fact isomorphisms with
inverses $\psi_X\colon \pow_{\ufs}([\mathbb{A}] X) \to [\mathbb{A}]\pow_{\ufs} X$
defined by $\psi_X(S) = \braket a \set{x : \braket a x \in S}$,
where $a$ is fresh for $S$. These inverses can also be gleaned
from Pitts' result~\cite[Prop.~4.14]{Pitts13} which shows that the
abstraction functor preserves exponentials specializing to
$\pow_{\fs}([\mathbb{A}] X) \cong[\mathbb{A}]\pow_{\fs} X$. However, note that
$\rho_X$ has a more involved description in the case
of $\pow_{\fs}$.
\end{enumerate}
\end{rem}
It follows that for every nominal set $X$ we have an injection
\begin{equation}\label{eq:inj}
m_X\colon 2 \times \pow_{\ufs}(\mathbb{A} \times X) \times
\pow_{\ufs}([\mathbb{A}] X)
\rightarrowtail
2 \times (\pow_{\ufs} X)^\mathbb{A} \times [\mathbb{A}] (\pow_{\ufs} X).
\end{equation}
Thus every RNNA (\autoref{rem:rnna-as-coalgebras}) may be regarded as
a coalgebra for $G\pow_{\ufs}$.
A description of the terminal coalgebra for $G$ has previously been
given by Kozen et al.~\cite[Thm.~4.10]{KozenEA15}. We provide a
different (or course, isomorphic) description as a final ingredient
for our desired result.
\begin{proposition}\label{prop:ter}
The terminal coalgebra for $G$ is the nominal set $\pow_{\fs}(\barstr)$ of all
bar languages with the structure
\[
\pow_{\fs}(\barstr) \xra{\tau} 2 \times (\pow_{\fs}(\barstr))^\mathbb{A} \times
[\mathbb{A}]\pow_{\fs}(\barstr),\quad
S \mapsto (b, a \mapsto S_a, S_{\scriptnew a}),
\]
where $b = 1$ if
$[\varepsilon]_\alpha \in S$ and $0$ else,
$S_a = \set{[w]_\alpha : [aw]_\alpha \in S}$ and
$S_{\scriptnew a} = \braket a \set{[w]_\alpha : [\newletter a
w]_\alpha \in S}$ for any $a$ which is fresh for $S$.%
\smnote{Is the latter set really correct like this?}
\end{proposition}
We may thus define the coalgebraic language semantics for RNNAs as in
\autoref{D:coalg-lan-sem}.
\begin{rem}\label{R:epsX}
We take $FX = 1 + \mathbb{A} \times X + [\mathbb{A}] X$ as in
\autoref{T:RNNA-Kl} and obtain $\mu F = \barA^*/\mathord{=_\alpha}$
(\autoref{prop:ini}) and $\nu G = \pow_{\fs}(\barstr)$
(\autoref{prop:ter}). We also define a natural
transformation $\varepsilon\colon \pow_{\ufs} F \to G \pow_{\ufs}$ by composing the
canonical isomorphism $\pow_{\ufs}(1 + \mathbb{A} \times X + [\mathbb{A}] X)
\cong 2 \times \pow_{\ufs}(\mathbb{A} \times X) \times \pow_{\ufs}([\mathbb{A}] X)$
with the injection $m_X$ from~\eqref{eq:inj}.
For every uniformly finitely supported subset $S \subseteq 1 +
\mathbb{A} \times X + [\mathbb{A}] X$ we have
\(
\varepsilon_X(S) = (b, a \mapsto S_a, S_{\scriptnew a}),
\)
where $b = 1$ iff the element $*$ of $1$ lies in $S$, $S_a = \set{s :
(a,s) \in S}$ and $S_{\scriptnew a} = \braket a \set{s : \braket a
s \in S}$, where $a$ is fresh for (all elements $\braket b s$ in)
$S$.
\end{rem}
\begin{lemma}\label{L:eps-ext}
The natural transformation $\varepsilon\colon \pow_{\ufs} F \to G \pow_{\ufs}$ is
an extension.
\end{lemma}
\begin{lemma}\label{L:incl}
The canonical morphism $e\colon \pow_{\ufs}(\mu F) \to \nu G$ from
\autoref{R:eps}\ref{R:eps:3} is the inclusion map
$\pow_{\ufs}(\barA^*/\mathord{=_\alpha}) \hookto \pow_{\fs}(\barstr)$.
\end{lemma}
\begin{corollary}\label{C:RNNA-EM}
The coalgebraic language semantics assigns to each state of an RNNA
the bar language it accepts.
\end{corollary}
\noindent
Indeed, this follows from \autoref{T:RNNA-Kl} and \autoref{P:relation}
using that in the latter result
$e\colon\pow_{\ufs}(\barA^*/\mathord{=_\alpha}) \hookto \pow_{\fs}(\barstr)$ is the inclusion map by \autoref{L:incl}.
\section{Conclusions and Future Work}
We have worked out coalgebraic semantics for two species of
non-deterministic automata for data languages:
NOFAs~\cite{BojanczykEA14} and RNNAs~\cite{SchroderEA17}. We have seen
that their semantics arises both as an instance of the Kleisli style
coalgebraic trace semantics and from the Eilenberg-Moore style
coalgebraic language semantics, which is based on generalized
determinization. To see that both semantics coincide we have employed
the results by Jacobs et al.~\cite{JacobsEA15}.
We have also revisited coalgebraic trace semantics in general and
given a new compact proof of the main extension result
for initial algebras in that theory. Our proof avoids assumptions on
the convergence of the initial algebra chain; mere existence of an
initial algebra suffices.
Having provided coalgebraic semantics for non-deterministic nominal
systems makes the powerful toolbox of coalgebraic methods fully
available to those systems. For example, generic constructions like
coalgebraic $\varepsilon$-elimination~\cite{SilvaW13,bmsz15} can be
instantiated to them. Or coalgebraic up-to techniques
starting with the work by Rot et al.~\cite{RotEA13} might lead to new
proof principles and algorithms, cf.~\cite{BonchiPous13}.
Our general extension and lifting results for nominal systems may be
applied to related kinds of systems, e.g.~nominal transition
systems and the coalgebraic study of equivalences for them. Going a
step beyond the standard coalgebraic trace and language
semantics, graded semantics~\cite{DorschEA19} should lead to a nominal spectrum
of equivalences generalizing van Glabbeek's famous linear time -- branching time
spectrum~\cite{Glabbeek01}.
\smnote[inline]{Is there other future work we can think of? Didn't we
discuss something last week?}
\bibliographystyle{splncs04}
|
{'timestamp': '2022-02-15T02:38:35', 'yymm': '2202', 'arxiv_id': '2202.06546', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06546'}
|
arxiv
|
\subsection{Notation}
\paragraph{\emph{Notation}}
We denote by ${\mathbb{R}}$ and ${\mathbb{N}}$ the set of real numbers and non-negative integers, respectively. These symbols are annotated with subscripts to restrict them in
the usual way. We use notations $\mathcal{K}$ and $\mathcal{K}_{\infty}$ to denote the different classes of comparison functions, as follows: $\mathcal{K} = \{\gamma:\mathbb R_{\ge 0}\rightarrow\mathbb R_{\ge 0} : \gamma \text{ is continuous, strictly increasing and }$ $ \gamma(0)=0\}$; $\mathcal{K}_{\infty} = \{\gamma \in \mathcal{K} : \lim_{r\rightarrow \infty}\gamma(r) =\infty\}$.
Given $N\in{\mathbb{N}}_{\ge1}$ vectors $\nu_i\in{\mathbb{R}}^{n_i}$, $n_i\in{\mathbb{N}}_{\ge1}$, and $i\in[1;N]$, we
write $\nu=(\nu_1,\ldots,\nu_N)$ to denote the corresponding concatenated vector in ${\mathbb{R}}^n$ with
$n=\sum_i n_i$.
Given a vector $x \in \mathbb R^{n}$, we denote the infinity norm of $x$ by $\Vert x\Vert$. We denote by $\mathrm{id}$ the identity function over $\mathbb{R}$, i.e., $\mathrm{id}(r) = r$ for all $r \in \mathbb{R}$.
The complement of set $X$ w.r.t. $Y$ is defined as $Y \backslash X = \{x : x \in Y, x \notin X\}.$
For any set \mbox{$S\subseteq{\mathbb{R}}^n$} of the form of finite union of boxes, e.g., $S=\bigcup_{j=1}^MS_j$ for some $M\in{\mathbb{N}}$, where $S_j=\prod_{i=1}^{n} [c_i^j,d_i^j]\subseteq {\mathbb{R}}^{n}$ with $c^j_i<d^j_i$, we define $\emph{span}(S)=\min_{j=1,\ldots,M}\eta_{S_j}$ and $\eta_{S_j}=\min\{|d_1^j-c_1^j|,\ldots,|d_{n}^j-c_{n}^j|\}$. Moreover, for a set in the form of $X= \prod_{i=1}^N X_i$, where $X_i \subseteq {\mathbb{R}}^{n_i}$ are of the form of finite union of boxes, and any positive (component-wise) vector $\eta = (\eta_1,\dots,\eta_N)$ with $\eta_i \leq \emph{span}(X_i)$, $\forall i\in [1;N]$, we define $[X]_\eta= \prod_{i=1}^N [X_i]_{\eta_i}$, where $[X_i]_{\eta_i} = [{\mathbb{R}}^{n_i}]_{\eta_i}\cap{X_i}$ and $[{\mathbb{R}}^{n_i}]_{\eta_i}=\{a\in {\mathbb{R}}^{n_i}: a_{j}=k_{j}\eta_i,k_{j}\in\mathbb{Z},j=1,\ldots,n_i\}$.
For a set $A$, we write $A^*$ for the set of finite sequences from $A$ and $A^\omega$ for the set of (infinite) $\omega$-sequences. We write $A^\infty = A^* \cup A^\omega$.
\begin{tcolorbox}
\begin{definition}\upshape(\textbf{System Model})
A system $\Sigma$ in this paper is described by a quadruple
\begin{equation}
\Sigma=(X,X_0,U,\rTo),
\end{equation}
where
$X$ is a (possibly infinite) set of states,
$X_0\subseteq X$ is a (possibly infinite) set of initial states,
$U$ is a (possibly infinite) set of inputs, and
$\rTo\subseteq X\times U\times X$ is a transition relation.
We call a system \textit{finite} (or \textit{symbolic}), if $X$ and $U$ are finite sets. \end{definition}
\end{tcolorbox}
A transition \mbox{$(x,u,x')\in\rTo$} is also denoted by $x\rTo^ux'$.
For a transition $x\rTo^ux'$, state $x'$ is called a \mbox{$u$-successor}, or simply a successor, of state $x$; state $x$ is called a \mbox{$u$-predecessor}, or simply a predecessor, of state $x'$. We denote by $\mathbf{Post}_{u}(x)$ the set of all \mbox{$u$-successors} of state $x$
and by $\mathbf{Pre}_{u}(x)$ the set of all \mbox{$u$-predecessors} of state $x$.
For a set of states $q\in 2^X$, we write
\[
\mathbf{Post}_{u}(q)=\cup_{x\in q}\mathbf{Post}_{u}(x) \text{ and } \mathbf{Pre}_{u}(q)=\cup_{x\in q}\mathbf{Pre}_{u}(x).
\]
We call a system \textit{deterministic}, if for any state $x\in{X}$ and any input $u\in{U}$, $\mathbf{Post}_{u}(x)$ is singleton; otherwise we call it \textit{non-deterministic}.
A system $\Sigma$ from an initial state $x_0\in X_0$ and input sequence $u_1u_2\cdots u_n\in U^*$, induces a finite state \emph{run}
\begin{align}\label{run}
x_0\rTo^{u_1}x_1\rTo^{u_2}\cdots\rTo^{u_{n-1}}x_{n-1}\rTo^{u_{n}}x_n,
\end{align}
such that $x_i\rTo^{u_{i+1}}x_{i+1}$ for all $0\leq i<n$.
Note that the run induced by an input sequence may not be unique because the system may be non-deterministic.
We call a finite sequence of states $x_0x_1\cdots x_n\in X^*$ a \emph{finite path} of the system $\Sigma$ and denote by $\texttt{Path}(\Sigma,x_0)$ the set of all finite paths generated by $\Sigma$ starting from $x_0$ with $\texttt{Path}(\Sigma)=\cup_{x_0\in X_0}\texttt{Path}(\Sigma,x_0)$.
Similarly, an infinite path $x_0x_1\dots \in X^\omega$ is an $\omega$-sequence defined analogously and we denote by
$\texttt{Path}^\omega(\Sigma,x_0)$ the set of all infinite paths of $\Sigma$ from $x_0$ with $\texttt{Path}^\omega(\Sigma)=\cup_{x_0\in X_0}\texttt{Path}^\omega(\Sigma,x_0)$.
\paragraph{\emph{Behaviors}}
A primary concern is whether the behaviors of system $\Sigma$ satisfy some desired specification.
Formally, let $\mathcal{AP}$ be a finite set of features, or \emph{(atomic) propositions}, of the state space.
We view the states with the lenses of atomic propositions, and to do so, we define a \emph{labeling function} $L: X\to 2^\mathcal{AP}$
that assigns to each state $x\in X$ in $\Sigma$ a set of propositions $L(x)$ true at the state $x$.
The labeling function can naturally be extended from states to path: we call such labeling of a path a \emph{trace}.
For any finite or infinite path $\mathbf{x}=x_0x_1\cdots \in X^\infty$, its trace is $L(\mathbf{x})=L(x_0)L(x_1)\cdots \in (2^{\mathcal{AP}})^\infty$.
The set of all finite traces and the set of all infinite traces are denoted by $\texttt{Trace}(\Sigma)$ and $\texttt{Trace}^\omega(\Sigma)$, respectively.
\paragraph{\emph{Observations}}
The system releases information to the external world during its execution.
The external world often may not observe the internal states $X$ or their atomic propositions directly but rather their properties over some observation symbols.
Let $Y$ be such set of observations.
Let the \emph{output function} $H: X\to Y$
determine the external observation of each internal state $x\in X$.
It can naturally be extended to finite or infinite paths, i.e., for a path $\mathbf{x}=x_0x_1\cdots \in X^\infty$,
its \emph{output} corresponds to a sequence
$H(\mathbf{x})=H(x_0)H(x_1)\cdots \in Y^\infty$.
The system $\Sigma$ is said to be \textit{metric} if the observation set $Y$ is equipped with a metric
$\mathbf{d}:Y\times Y\rightarrow\mathbb R_{\ge 0}$.
For any two paths $\mathbf{x}=x_0x_1\cdots $ and $\mathbf{x}'=x_0'x_1'\cdots $,
we say the outputs of $\mathbf{x}$ and $\mathbf{x}'$ are
\emph{(exactly) output equivalent}, denoted by $H(\mathbf{x})=H(\mathbf{x}')$, if $H(x_i)=H(x_i')$ for all $i \geq 0$;
on the other hand, we say that they are
\emph{$\delta$-approximately output equivalent}, and write $H(\mathbf{x}){\approx_\delta} H(\mathbf{x}')$, if $\sup_{i\geq 0} \mathbf{d}( H(x_i),H(x_i'))\leq \delta$.
To emphasize the labeling $L: X\to 2^\mathcal{AP}$ and output functions $H: X\to Y$ of a system $\Sigma$, we rewrite the tuple describing the system as
\[
\Sigma=(X,X_0,U,\rTo,\mathcal{AP}, L, Y, H).
\]
When it is clear from the context, we may drop some of the elements in the tuple for the sake of simple presentation.
\begin{remark}
In the DES literature, it is customary to model a system as a finite state machine
$G=(X,E,\delta,X_0)$, where $X$ is a set of states, $E$ is a set of events, $\delta:X\times E \to 2^X$ is a transition function and $X_0\subseteq X$ is a set of initial states \cite{cassandras2021introduction}.
In such treatments, both inputs and properties are captured by events $E$. Furthermore, it is also assumed that the observation mapping is also event-based captured by a natural projection $P:E\to E_o$.
\end{remark}
Our modeling framework is general enough to capture treatment in DES literature and capable of expressing more general scenarios posed in the reactive control systems settings.
\subsection{Infinite-Step Opacity-Preserving Simulation Function}
\section{Introduction}
\input{1_Introduction/Intro}
\section{Preliminaries}\label{sec: pre}
\input{2_Preliminary/preliminary}
\section{Security of CPS}
Security requirements, in the DES \cite{lin2011opacity,Wu2013ComparativeAnalysisOpacity,yin2017AutoTW,lafortune2018history} and control theory communities,
are often expressed using the notion of opacity, while in the realm of computer science security
requirements are expressed using closely related, but subtly different, concepts of non-interference \cite{milushev2012noninterference,DBLP:conf/icse/nilizadeh,wu2018eliminating}, K-safety \cite{sousa2016cartesian,pasareanu2016multi}, language-based secrecy \cite{ACZ06}, and their generalizations using HyperLTL properties \cite{Clark10,Clark14}.
We review these notions in this section.
\subsection{Security Notions for Finite Systems: Opacity}
\
\input{3_Privacy_of_CPS/DES-privacy}
\subsection{Security Notions for CPS: Approximate Opacity}
\input{3_Privacy_of_CPS/Approximate-Opacity}
\subsection{Safety \& Security in Formal Methods: Temporal Logic}
\input{3_Privacy_of_CPS/cs-privacy}
\section{Security-Aware Verification}
In the previous section, we have introduced various security formulations that are commonly used from the literature. A natural question to answer is: how to determine whether a given system preserves certain security property? Furthermore, if the system does not preserve the desired security property, how can one design proper controllers to enforce security properties on it? We proceed with the following sections to address these questions.
In this section, we investigate the verification problem.
\begin{tcolorbox}
\begin{problem}[\textbf{Security-Aware Verification}]\label{prob:verif}\upshape
Given a mission requirement (as an LTL formula) $\varphi$ and a security property $\alpha$, the security-aware verification problem is to decide whether $\Sigma \models (\varphi, \alpha)$, i.e., $\Sigma$ satisfies the property $\varphi$ and is $\alpha$-opaque.
\end{problem}
\end{tcolorbox}
Note that the above problem is formulated in a very general setting by considering an arbitrary mission requirement $\varphi$ and an arbitrary security requirement $\alpha$. Throughout the paper, we will mainly consider approximated initial-state opacity as a specified $\alpha$ to present our result.
To this end, we first overview the standard model checking approaches for verifying LTL formulae.
Then, for the verification of security, we will first discuss the typical schemes on verifying opacity for finite systems, and then present some recent results which are potential to deal with complex continuous-space CPS.
\input{4_Verification/Finite_Systems/Verifying_Privacy_CS}
\subsection{Finite Systems} \label{sec:ver}
\input{4_Verification/Finite_Systems/Verifying_Privacy_DES}
\subsection{CPS: Abstraction-Based Approach}\label{Sec:veri_abs}
\input{4_Verification/Infinite_Systems/Discretization_based}
\subsection{CPS: Deductive Approach via Barrier Certificates}\label{sec:veri_bc}
\input{4_Verification/Infinite_Systems/Discretization_free}
\subsection{Ongoing \& Open Problems}
So far, we discussed the basic security verification procedures for general CPS using abstractions and barrier certificates. In the followings, we further discuss some ongoing research topics and open problems.
\paragraph{\emph{Verification of General Notion of Opacity for CPS}} Existing works for opacity verification of general CPS mainly focus on particular types of opacity such as initial-state opacity or infinite-step one. For finite systems, the general notion of $\alpha$-opacity as defined in Definition~\ref{def:op-general} can be verified using the observer-like structures when the security properties can be realized by $\omega$-automata. However, for general CPS with infinite states, how to verify the general notion of $\alpha$-opacity still needs developments. In particular, for the abstraction-based approach, one needs to identify suitable relation that preserves $\alpha$-opacity. For the barrier-based approach, appropriate conditions for barrier certificates of $\alpha$-opacity also need to be identified.
\paragraph{\emph{Quantitative Verification of Opacity}}
The opacity verification problem discussed in this section is \emph{binary} in the sense that the system is either opaque or not. In some cases, when the verification result is negative, one may be further interested in how insecure the system is. This motivates the research of \emph{quantifying} the level of information leakage. For finite systems, one popular approach is to consider systems modeled by probabilistic finite-state automata, Markov chains or Markov decision processes. Then one can quantify opacity in terms of probability \cite{saboori2014current,berard2015probabilistic,berard2015quantifying,keroglou2018probabilistic,yin2019infinite,lefebvre2021exposure}.
For example, one may require that the intruder can never know that the system is currently at a secret-state with more than $\epsilon$ probability, or the system has less than $\epsilon$ probability to reveal its secret.
However, all existing works on quantifying opacity consider finite systems, although their belief spaces may be infinite. How to leverage opacity quantification techniques for general CPS, using either abstraction-based approaches or barrier certificates, still need to be developed. The recent result in \cite{liu2020notion} has made some initial steps towards this objective using the abstraction-based technique.
\paragraph{\emph{Opacity Verification for Larger Classes of CPS}}
The aforementioned abstraction-based approaches for opacity verification of general CPS crucially depends on incremental ISS assumption. However, this assumption is rather restrictive for many practical systems. How to relax the stability assumption so that the verification techniques can be applied to more general classes of CPS is an interesting and important future direction.
Also, in the problem formulation of opacity, the attacker is assumed to be able to access partial information-flow of the plant. However, for networked control systems, the information transmission between controllers and plants in the feedback loops may also be released to the intruder. There are some very recent works on the verification of opacity for networked control systems using finite-state models; see, e.g., \cite{yin2018verification,yang2021opacity,zhang2021networked,lin2020information,yangjk2021opacity}. However,
existing works on formal verification of networked control system mainly focus on the mission requirements \cite{zamani2018symbolic,hashimoto2019symbolic,pola2019control,borri2019design} and to the best of our knowledge, there is no result on formal verification of opacity for general networked CPS.
\section{Secure-by-Construction Controller Synthesis}
In the previous section, we investigated the security verification problem for open-loop systems. However, the original system $\Sigma$ may not be opaque.
Therefore, it is desired to \emph{enforce} opacity for the system via the feedback control mechanism.
In the realm of control theory, one of the most popular approaches for
enforcing certain property of the system is through a feedback controller.
A {\it supervisor} or a controller for $\Sigma$ is a function
$C:\texttt{Path}(\Sigma)\to 2^U$ that determines a set of possible control inputs based on the executed state sequences.
We denote by $\Sigma_C$ the closed-loop system under control.
Specifically, a state run $x_0\rTo^{u_1}x_1\rTo^{u_2}\cdots\rTo^{u_{n-1}}x_{n-1}\rTo^{u_{n}}x_n$ is feasible in the closed-loop system if it is a run in the open-loop system $\Sigma$ and $u_i\in C(x_0x_1\cdots x_{i-1})$ for any $i\geq 1$.
Similarly, we denote by $\texttt{Path}^{(\omega)}(\Sigma_C)$ and $\texttt{Trace}^{(\omega)}(\Sigma_C)$ the set of paths and the set of traces of the controlled system $\Sigma_C$, respectively.
The goal of the control synthesis problem is to synthesize a feedback controller
$C$ such that the closed-loop system $\Sigma_C$ satisfies both the mission requirement, e.g., an LTL formula $\varphi$,
and/or, the security requirement, e.g., opacity.
Specifically, we investigate the following control synthesis problem.
\begin{tcolorbox}
\begin{problem}[\textbf{Secure-by-construction Controller Synthesis}]\label{prob:synthesis}\upshape
Given a mission requirement (as an LTL formula) $\varphi$ and a security property $\alpha$, the secure-by-construction controller synthesis problem is to design a supervisor $C$ such that $\Sigma_C \models(\varphi, \alpha)$.
\end{problem}
\end{tcolorbox}
The foundations for the {\it correct-by-construction} approach were laid by
Church in~\cite{Church1963} where he stated his famous {\it synthesis problem}:
{\it given a requirement which a circuit is to satisfy, find a circuit that
satisfies the given requirement (or alternatively, to determine that there
is no such circuit)}.
The landmark paper by B\"uchi and Landweber~\cite{BL69} gave the first solution of
Church's synthesis problem for specification given in Monadic second-order logic.
Pnueli and Rosner~\cite{PR89} studied the synthesis problem for specifications
given as LTL~\cite{katoen08} and showed the problem
to be complete with $\textsc{2Exptime}$ complexity. Ramadge and Wonham~\cite{ramadge} studied the synthesis problem---as a mechanism
for supervisory controller synthesis of discrete event systems---for simple {\it
safety specifications} and gave an efficient linear-time algorithm for
computing maximally permissive controller for this fragment.
The relation between reactive synthesis and supervisory control has been thoroughly
discussed in a serious of recent works; see, e.g., \cite{ehlers2017supervisory,ramezani2019comparative,partovi2019reactive,schmuck2020relation,majumdar2022supervisory,sakakibara2022finite}.
The goal of this thrust is to study decidability and complexity of the synthesis
problems for LTL specification (and their efficiently solvable sub-classes) with
security requirements and propose efficient algorithms to solve synthesis
problems.
\subsection{Finite Systems}
In opacity enforcement using supervisory control, the objective is to synthesize a supervisor $C$ that avoids executing those ``secret-revealing" paths and at the same time, satisfies the desired mission requirement described as an LTL formula.
Note that in Problem~\ref{prob:synthesis}, the meaning of mission satisfaction, i.e., $\Sigma_C\models\varphi$, is relatively clear. However, there may have different interpretations for security for the closed-loop system, i.e., $\Sigma_C\models \alpha$.
In particular, the synthesis problem can be categorized as policy-aware synthesis and policy-unaware synthesis.
Here, we still use initial-state opacity as the concrete security property to illustrate the differences.
\paragraph{\emph{Basic Opacity-Enforcing Controller Synthesis Problem}}
The most basic setting for opacity enforcing control is to assume that the intruder is \emph{not aware} of the presence of the controller $C$.
In this setting, we say controller $C$ enforces initial-state opacity for system $\Sigma$ if
for any path $\mathbf{x}=x_0x_1\cdots x_n\in \texttt{Path}(\Sigma_C)$, where $x_0\in X_S$,
there exists a path $\mathbf{x}'=x_0'x_1'\cdots x_n'\in \texttt{Path}(\Sigma)$, where $x_0'\notin X_S$, such that $H(\mathbf{x})=H(\mathbf{x}')$.
Note that, here, the first secret path $\mathbf{x}$ belongs to the closed-loop system $\Sigma_C$ since we consider those secret paths that can actually happen.
However, the second non-secret path $\mathbf{x}'$ belongs to the open-loop system $\Sigma$ as we assume that the intruder is unaware of control $C$.
The basic idea for solving the basic synthesis problem is to construct the corresponding (initial, current or delayed) state-estimator $Obs(\Sigma)$ based on the open-loop system $\Sigma$. Then we compose the system $\Sigma$, the state-estimator $Obs(\Sigma)$ and the deterministic Rabin automata for $\varphi$ to obtain a new system $\Sigma'$. Then controller $C$ can be synthesized by solving a Rabin game over $\Sigma'$ for the Rabin acceptance condition \cite{gradel2002automata} and at the same time avoiding reaching those secret-revealing estimator states in $Obs(\Sigma)$. Complete solution for this problem can be found in \cite{takai2008formula,tong2018current,xie2021secure,ma2021verification}; some of them do not consider the LTL mission requirement, which can be addressed easily by combining with the standard LTL synthesis procedures.
\paragraph{\emph{Policy-Awareness and Imperfect Information}}
The above basic synthesis problem is based on the assumptions that (i) the controller has full state information; and (ii) the intruder is unaware of the implementation of the controller. In particular, the latter assumption is reflected by the fact that we choose non-secret path $\mathbf{x}'$ from the original open-loop system $\texttt{Path}(\Sigma)$ rather than the closed-loop one $\texttt{Path}(\Sigma_C)$.
However, in practice, the control policy may become a public information, which is also available to the intruder.
Then the intruder may further use the knowledge of the controller to improve its state estimator, e.g., it can exclude some paths that have already been disabled by the controller during the state estimation process.
In order to ensure opacity for this general case, one needs to further investigate how control affects estimation in the synthesis phase. That is, the state estimate of the intruder cannot be constructed solely based on the original open-loop system but should also based on the synthesized control policy. Interested readers are referred to \cite{dubreil2010supervisory,saboori2011opacity,yin2016uniform,xie2021opacity} for the complete solution to this general case for finite systems.
Another practical design consideration is the imperfect information of the controller.
In practice, the controller also may not be able to access the full state information of the system.
Instead, the controller may have its own observation specified by a new output mapping $H_C: X \to O$ and a controller with imperfect information is a function of the form $C:O^*\to 2^U$, which determines the control input based on its own observation.
Systematic procedures for synthesizing controllers under imperfect information can be found in \cite{arnold,raskin2007algorithms,thistle2009effective,yin2016tac}.
In the context of opacity-enforcing synthesis, the main difficulty here is that the information of the intruder and the information of the controller may be \emph{incomparable}, i.e., the equivalent classes induced by mappings $H$ and $H_C$ are incomparable. Interested readers are referred to \cite{dubreil2008opacity,dubreil2010supervisory} for more discussions on this issue.
\paragraph{\emph{Opacity-Preserving Path Planning}}
The complexity of the basic opacity-enforcing controller synthesis problem is exponential in the size of $\Sigma$ due to the subset construction used in the state estimators
and double-exponential in the length of the LTL formula $\varphi$ due to the construction of the deterministic Rabin automaton.
Note that one has to use deterministic $\omega$-automata to realize the LTL formulae because the plant under control is non-deterministic in general.
However, when system $\Sigma$ is deterministic, the basic synthesis problem becomes a \emph{planning problem} for which the computational complexity can be significantly improved.
In particular, when system $\Sigma$ is deterministic, a deterministic controller is also referred to as a \emph{plan} because the trajectory of the system can be completely determined without any uncertainty. Therefore, for planning problem, one just needs to find an infinite path satisfying both the mission and the security requirements.
The results in \cite{hadjicostis2018trajectory} investigate the problem of planning a trajectory towards a target state under current-state opacity constraints.
The results in \cite{yang2020secure} consider the security-aware path planning problem together with LTL mission requirements. The idea is to construct the so-called twin-system, whose size is polynomial with respect to the size of $\Sigma$, to capture the security requirements without building the exponentially large state estimator. Furthermore, since system $\Sigma$ is already deterministic, one can further use non-deterministic B\"{u}chi automata, whose size is single-exponential in the length of formula $\varphi$, to capture the LTL specification. In this case, the complexity of the opacity synthesis can be reduced to polynomial in the size of the system and to single-exponential in the length of $\varphi$.
\paragraph{\emph{Other Opacity Enforcement Mechanisms}}
In the above paragraphs, we discussed the enforcement of opacity using feedback controllers.
In some applications, however, one cannot change the actual behavior of the system directly.
Therefore, many different alternative enforcement mechanisms have also been developed by changing the information-flow available to the intruder to ensure security of the systems.
For example, in \cite{wu2014synthesis,ji2019enforcing,wubo2018synthesis}, \emph{insertion functions} were used to ``confuse" the intruder by adding factitious symbols to the output sequences.
Insertion functions have been further generalized to \emph{edit functions} that allow not only event insertions, but also event erasures and replacements \cite{wu2018synthesis,ji2019opacity}.
Another widely used approach is to synthesize \emph{dynamic masks} \cite{cassez2012synthesis,zhang2015maximum,behinaein2019optimal,yin2019general,yin2020synthesis} that determine which information to be released to the outside world under the security constraints.
Other approaches for enforcing opacity include using run-time techniques \cite{falcone2015enforcement} and event shuffles \cite{barcelos2021enforcing}.
\subsection{Secure-by-Construction Controller Synthesis for CPS}
The above discussed controller synthesis techniques are developed for finite systems.
Those techniques, in general, are not appropriate for CPS with continuous-space dynamics such as systems in the form of equation~\eqref{def:sys1}. Unfortunately, there are only very few recent works on the enforcement of opacity for CPS, which are discussed as follows.
\paragraph{\emph{Abstraction-Based Synthesis}}
\begin{figure}
\centering
\includegraphics[width=0.45\textwidth]{Figure/abstraction_framework.pdf}
\caption{Pipeline of standard discretization-based synthesis technique.}\label{fig:abs_synthesis_pipeline}
\end{figure}
The basic pipeline of abstraction-based or discretization-based controller synthesis is shown in Figure~\ref{fig:abs_synthesis_pipeline}.
Similar to the abstraction-based verification,
in abstraction-based synthesis, one needs to first build the finite abstraction of the concrete CPS, and then synthesize a controller based on the finite abstraction, and finally, refine the synthesized discrete controller back as a hybrid controller to the original CPS.
Then the key question is still to find appropriate relations between concrete systems and their finite abstractions such that properties of interest can be preserved under controller refinement.
It is well-known that the (bi)simulation relation is not suitable for the purpose of controller synthesis because it does not take the effect of control non-determinism into account \cite{pola2009symbolic}. To address this issue, one needs to extend the (approximate) (bi)simulation relations to the (approximate) \emph{alternating} (bi)simulation relations \cite{alur1998alternating,tab09}. However, although the standard alternating simulation relations preserve the LTL mission requirements, they do not preserve security requirements. In \cite{hou2019abstraction}, two notions of \emph{opacity-preserving} alternating simulation relations are proposed, one for initial-state opacity and one for infinite-step opacity.
Based on these notions, one can synthesize opacity-enforcing controllers directly by applying existing synthesis algorithms to the finite abstractions that \emph{opacity-preserving alternatively simulate} the concrete systems.
In \cite{mizoguchi2021abstraction}, the authors propose a two-stage approach for enforcing opacity for CPS. First, a controller ensuring the LTL mission requirement is synthesized based on the standard alternating simulation relations without considering opacity. Then those actions violating opacity are eliminated by a symbolic control barrier function such that security requirement is fulfilled.
\paragraph{\emph{Abstraction-Free Synthesis}}
In the context of discretization-free approaches, to the best our knowledge, only the results in \cite{an2019opacity} investigated the opacity enforcement problem for restricted classes of CPS and security notions.
Specifically, they considered CPS modeled by linear time-invariant (LTI) systems and the security requirement is to make sure that the interference attenuation capacity of the system is opaque. Then the opacity enforcement problem is formulated as an $\mathcal{L}_2$-gain optimization problem for LTI systems. An approximated-based adaptive dynamic-programming (ADP) algorithm was proposed to design an opacity-enforcing controller.
\subsection{Ongoing \& Open Problems}
In the following, we mention some ongoing research directions and open problems regarding secure-by-construction controller synthesis. Compared with security-aware verification, secure-by-construction synthesis is less tackled in the literature.
\paragraph{\emph{Synthesis for Finite Systems}}
The opacity-enforcing control problem for finite systems has already been studied for about fifteen years. However, all existing solutions are either based on the assumption that the knowledge of the supervisor and the intruder are comparable \cite{dubreil2010supervisory,saboori2011opacity,yin2016uniform}, or based on the assumption that the intruder is unaware of the presence of the supervisor \cite{takai2008formula,tong2018current}. The general opacity-enforcing control problem without any assumption, to the best of our knowledge, is still open even for finite systems. Also, for networked control systems with both control and observation channel information leakages,
how to synthesize opacity-enforcing controllers is still an open problem; so far, only the verification problem is solved for finite systems \cite{yin2018verification,yang2021opacity}. Furthermore, existing works on opacity-enforcing control mainly consider centralized control architectures. In general, the plant may be controlled by a set of \emph{local controllers} with or without communications, which leads to the distributed \cite{barrett2000decentralized,kalyon2014symbolic} or the decentralized control architectures \cite{yoo2002general,pola2018decentralized}. How to synthesize opacity-enforcing controllers under those general information structures is still an open problem.
The high complexity or even undecidability are the major obstacles towards automated controller synthesis of opacity. To overcome this challenge, a potential future direction is to develop {\it bounded-synthesis}~\cite{Schewe07} that reduces the search for a bounded size
implementation satisfying the synthesis objective to a SAT problem. The key
advantage of the bounded synthesis over traditional synthesis is that it constructs minimal size supervisors.
Therefore, it is a promising direction to extend the bounded synthesis approach to solve controller synthesis problem for generalized
language-based opacity by implicitly encoding the self-composition of the abstract model.
Another premising direction is to investigate security-aware synthesis for
well-behaved sub-classes of LTL such as Generalized reactivity(1) (GR(1))~\cite{PPS06,bloem2012synthesis}.
These are sub-classes of the form
\[
(\always \eventually
p_1 \wedge \ldots \wedge \always \eventually p_m) \implies (\eventually \always
q_1 \wedge \ldots \wedge \eventually \always q_n),
\]where $p_i,q_j$, $i\in\{1,\ldots,m\}$, $j\in\{1,\ldots,n\}$, are some predicates.
For GR(1) formulae, Piterman et al.~\cite{PPS06} showed that
synthesis can be performed in (singly) exponential time. Moreover, authors
argued that GR(1) formulas are sufficiently expressive to provide complete
specifications of many designs.
It is promising to develop an analogous result for security-aware controller-synthesis
w.r.t generalized language-based opacity properties.
\paragraph{\emph{Abstraction-Based Synthesis for CPS}}
The notions of opacity-preserving alternating simulation relations (ASR) proposed in \cite{hou2019abstraction}
made the first step towards abstraction-based opacity synthesis for CPS. However, it has many limitations that need to be addressed in the future.
First, the results in \cite{hou2019abstraction} are developed for particular types of state-based opacity. Similar to the verification problem, we also need to extend the results, particularly the underlying simulation relations, to the general case of $\alpha$-opacity.
Second, the opacity-preserving ASR belongs to the category of exact simulation. This condition, in general, is too strong for general CPS with continuous state-space. It is likely that there does not exist a finite symbolic model simulating the concrete system exactly. One possible direction to address this issue is to enforce approximate opacity rather than the exact version. To this end, one needs to consider the approximate ASR \cite{pola2009symbolic,zamani2012symbolic} rather than the exact ASR.
Third, existing results only support state-feedback controllers, i.e., the controller knows the current-state of the system precisely. As we discussed, an opacity-enforcing controller is observation-based in general.
To address this issue, a possible solution is to use the output-feedback refinement relation (OFRR) \cite{reissig2017feedback,khaled2020output} instead of the ASR. How to suitably generalize the OFRR to preserve opacity is still an open problem.
Finally, although opacity-preserving relations have been identified, there is no abstraction algorithm available so far for building finite abstractions based on the concrete systems with continuous-space dynamics that satisfy those relations.
When the concrete system is $\delta$-ISS, the abstraction can be done analogous to the case of verification. The major open problem is how to build opacity-preserving finite abstractions for the purpose of control without the stability assumption.
\paragraph{\emph{Abstraction-Free Synthesis for CPS}}
As we have already mentioned, there are very few results for abstraction-free opacity synthesis. One important direction is to extend the barrier-certificates techniques for opacity verification to opacity synthesis. To this end, one may borrow the idea of control barrier functions \cite{ames2017control,santoyo2021barrier} that generalize the idea of barrier certificates to control systems by explicitly taking the effect of control choices into account.
Another widely used abstraction-free technique for formal synthesis is the sampling-based approaches \cite{vasile2013sampling,kantaros2019sampling,luo2021abstraction}.
In this approach, one can use the concrete models of CPS to randomly generate sample paths until a satisfiable path is found. This avoids discretizing the state-space explicitly and under certain conditions, can provide probabilistic complete solutions.
However, existing sampling-based planning techniques can only handle LTL mission requirements. How to incorporate the security requirements into the sampling-based process needs further developments.
\section{Compositional Reasoning for Scalability}
In the previous sections, we presented various discretization-based and discretization-free approaches in verifying or enforcing opacity and mission requirements for CPS.
Though promising, when confronted with large-scale interconnected systems, the aforementioned results in general suffer from the so-called the \emph{curse of dimensionality}.
This prevents current techniques from providing automated verification or synthesis for large-scale interconnected
CPS. This is not just a theoretical concern, many safety-critical applications, such as traffic network, automated
highway driving, building management systems, power networks, air traffic management, uninhabited
aerial vehicles, and so on, consist of many subsystems interacting with each other.
One way to address the inherent difficulty in analyzing or controlling complex, large-scale, interconnected systems,
is to apply a ``divide and conquer” strategy, namely, compositional approaches.
In the past decades, many potential compositionality results have been proposed to tackle the acute computational bottlenecks in the analysis of safety properties for large-scale continuous-space systems \cite{tazaki1,pola16,kim2,kim2018constructing,boskos2015decentralized,rungger2016compositional,swikir2018dissipativity,swikir2019compositional,lavaei2020compositional,liu2021symbolic}.
However, in the context of analyzing security properties, compositional approaches have been explored only recently for modular verification and synthesis of DES in \cite{saboori2010reduced,noori2018compositional,mohajerani2019transforming,tong2019current,yang2021current,zinck2020enforcing}
and for continuous-space systems in \cite{liu2021compositional,liu2021verification,kalat2021modular}.
\subsection{Modular Approaches for Finite Systems}\label{subsec:modular}
Formally, an interconnected large-scale system $\Sigma$ consists of a set of subsystems or local modules $\{\Sigma_1,\dots,\Sigma_n\}$ whose connectivities are specified by an interconnection mapping $\mathcal{I}$.
In the context of finite systems or discrete-event systems, the interconnection mapping is usually simplified as the synchronization product $\otimes$ over shared events. That is, the monolithic system is $\Sigma=\Sigma_1\otimes \cdots \otimes\Sigma_n$.
\paragraph{\emph{General Complexity Results}}
In the context of opacity verification,
it was first shown by \cite{yin2017verification2} that verifying opacity for modular systems in the form of $\otimes_{i=1}^n\Sigma_i$ is PSPACE-hard.
This complexity result was then further improved by \cite{masopust2019complexity} to EXPSPACE-complete, which says that the time-complexity for verifying opacity for modular systems grows \emph{double-exponentially} fast when the number of subsystems increases. Therefore, verifying opacity directly by computing the entire monolithic model is computationally intractable in general. Since the opacity synthesis problem is even more difficult than the verification one, its complexity is at least EXPSPACE-hard.
\paragraph{\emph{Modular Verification}}
The first modular approach for opacity verification was provided in \cite{saboori2010reduced}. Specifically, it identified a structural sufficient condition such that events shared by each pair of subsystems are pairwise observable. With this structural condition, the verification of opacity for system $\otimes_{i=1}^n\Sigma_i$ can be divided as $n$ local verification problems for subsystems $\Sigma_i$,
which reduces the double-exponential complexity $2^{|X|^n}$ to single-exponential complexity $n2^{|X|}$, where $|X|=\max_{i=1,\dots, n}|X_i|$.
More recently, the results in \cite{tong2019current,yang2021current} follow the similar line of reasoning by identifying sufficient conditions under which current-state opacity can be verified efficiently using modular approach without building the monolithic system. In \cite{noori2018compositional}, a compositional abstraction technique was developed based on a notion of visible bisimulation relation. This approach was applied to opacity verification of modular systems by incrementally building the monolithic system while avoiding irrelevant components for the purpose of verification. Finally, the results in \cite{mohajerani2019transforming} investigated how to transform the opacity verification problem for modular systems to a non-blockingness verification problem, for which mature modular verification algorithms have been developed already \cite{mohajerani2016framework}.
\paragraph{\emph{Modular Synthesis}}
Similar to the verification problem, the existing opacity enforcing synthesis algorithms also need the monolithic model of the system.
The results in~\cite{zinck2020enforcing} investigated the opacity enforcing controller synthesis for modular systems under the assumption that the attacker can observe the
interface between each local module. Under this assumption, opacity-enforcing controllers $C_i$ can be synthesized for subsystems $\Sigma_i$ individually and the overall control system $\otimes_{i=1}^n \Sigma_{i,C_i}$ is guaranteed to be opaque. In \cite{mohajerani2020compositional}, a
compositional and abstraction-based approach is proposed for synthesis of edit functions for opacity enforcement. The idea is similar to \cite{mohajerani2019transforming} and is based on transforming the opacity synthesis problem to an existing supervisor synthesis problem for modular system without security considerations \cite{mohajerani2014framework}. Note that, different from a supervisory controller, an edit function can only change the observation of the system and not the actual behavior of the system.
\subsection{Modular Verification for Large-scale CPS: An Abstraction-based Approach}\label{sec:compo_abs}
\input{6_Compositional_Techniques/System_Model}
\input{6_Compositional_Techniques/Discretization_based}
\subsection{Modular Verification for Large-scale CPS: A Barrier Certificate Approach}
\input{6_Compositional_Techniques/Discretization_free}
\subsection{Ongoing \& Open Problems}
Here, we mention some potential future directions on compositional approaches for opacity verification and synthesis.
\paragraph{\emph{Efficient Models for Concurrent Systems}}
Interconnected systems are inherently concurrent, for which the major computational challenge comes from the issue of state-space explosion. For discrete systems, instead of using labeled transition systems, many alternative models have been proposed to efficiently represent large-scale concurrent
systems without enumerating the composed state space; one of the most widely used models is Petri nets \cite{cassandras2021introduction}.
Using Petri nets as the underlying model for opacity verification goes back to the seminal work of Bryans et al.~\cite{bryans2008opacity}.
Unfortunately, it has been proved that opacity verification is generally undecidable for unbounded Petri nets \cite{tong2017decidability,berard2018complexity,masopust2019deciding}.
On the other hand, for bounded Petri nets, many computationally efficient approaches have been developed recently by utilizing structural properties and modularity of Petri nets to overcome the issue of state-space explosion; see, e.g., \cite{ma2017basis,tong2017verification,cong2018line,saadaoui2020current,lefebvre2020privacy, tommasi2021optimization}. However, all these results can only be applied to finite systems. How to abstract concurrent interconnected CPS using Petri nets while preserving opacity properties is an interesting future direction.
\paragraph{\emph{Leverage Existing Modular Algorithms}}
In the past decades, despite those opacity-related modular techniques already mentioned in Section~\ref{subsec:modular}, there are already numerous different modular verification and synthesis methods developed for other non-security properties in DES and formal methods literature. For example, in the context of supervisory control of DES, researchers have proposed many effective modular controller synthesis approaches using, for example,
state tree structures \cite{ma2006nonblocking,chao2013modular},
hierarchical interfaces
\cite{leduc2005hierarchical,hill2010multi},
multi-level coordinators
\cite{komenda2015coordination}, and equivalence-based abstractions \cite{feng2008supervisory,su2010model}.
There are also numerous recent works exploring the philosophy of compositional reasoning in the context of reactive synthesis; see, e.g.,
\cite{alur2018compositional,majumdar2020assume,bakirtzis2021compositional}.
We believe that many of the aforementioned modular/compositional approaches for non-security properties can be generalized to incorporate the security constraints, which deserve deeper and detailed investigations.
\paragraph{\emph{Distributed Secure-by-Construction Synthesis}}
For large-scale interconnected systems, the abstract interconnection constitutes several relatively smaller
local finite abstractions, as investigated in Section~\ref{sec:compo_abs}, that run synchronously. Since the controller synthesis problem for LTL specifications has severe worst-time complexity (doubly exponential), computing the monolithic product of
all of the finite components makes the synthesis highly impractical. Moreover, often it may be impractical to
assume that subsystems have complete knowledge of the states of other subsystems. To model
these scenarios, one can represent the system as a network of finite abstractions where each subsystem has
a separate mission and opacity requirement. Some of the states of neighbouring local finite abstractions may be
shared with other local abstractions. This gives rise to the distributed reactive synthesis problem \cite{Schewe08} where the system
consists of several independent processes that cooperate based on local information to accomplish a global
specification. Such a setting changes the synthesis problem from a two-player complete-information game
to two-player games of incomplete information \cite{Reif84}. However, even for safety and reachability objective
(sub-classes of LTL), it is well known \cite{PR90,schewe14} that the distributed synthesis problem is undecidable for
general interconnected systems. There are two directions to achieve decidability: the first is to restrict the
network architecture \cite{PR90} and the second is the approach of bounded synthesis \cite{Schewe07} as we have already discussed for the case of monolithic sysnthesis.
\section{Future Directions}
Next, we touch upon some potential directions related to the overall secure-by-construction theme that differ from the parameters of study in this technical introduction.
We believe that these directions may provide impetus to research in security-critical system design.
\subsection{Information-Theoretic Foundations}
The concept of privacy discussed so-far in this paper is binary: either a system leaks information or it does not leak any information.
However, in practice such binary mitigation may not be feasible and may require an information-theoretic prospective on quantifying and minimizing the amount of information leak.
Shannon, in his seminal paper~\cite{shannon1948mathematical}, coined and popularized the notion of \emph{entropy} in measuring information: for a random variable $X$ with values in some domain $\mathcal{X}$, the entropy of (or the uncertainty about) $X$, denoted by $H(X)$, is defined as
\[
H(X) = \sum_{x \in \mathcal{X}} P[X= x] \log_2 \frac{1}{P[X=x]}.
\]
Shannon proved that $H(X)$ is the only function (modulo scaling) that satisfies the natural continuity, monotonicity, and choice decomposition (See~\cite{shannon1948mathematical}, for more details).
Similarly, for jointly distributed random variables $X$ and $Y$, the conditional entropy $H(X\mid Y)$, i.e. uncertainty about $X$ given $Y$, can be defined as
\[
H(X \mid Y) = \sum_{y \in \mathcal{Y}} P[Y= y] H(X \mid Y = y),
\]
where $\mathcal{Y}$ is the domain of $Y$. These definitions provide us a way to measure the \emph{information loss}: if $H(X)$ is the uncertainty about $X$ and if $H(X\mid Y)$ is the uncertainty about $X$ after $Y$ is revealed, the information loss in this process is $I(X; Y) = H(X) - H(X \mid Y)$.
Smith~\cite{smith2009foundations} introduced an alternative notion of entropy called the \emph{guessing entropy} $G(X)$ that corresponds to the number of guesses required to infer the value of $X$: of course a rational strategy in guessing these values will be to guess them in a non-increasing sequence of probability, hence $G(X) = \sum_{i=1}^{n} i p_i$ where $\seq{p_1, p_2 ,\ldots, p_n}$ is the sequence of probabilities of elements of $X$ arranged in an non-increasing fashion.
The notion of opacity discussed in this paper requires that the attacker should deduce nothing about all opacity properties of the system from observing the outputs of the system. However, achieving full opacity may not be possible in general, because oftentimes systems reveal information depending on the secret properties.
To extend the notion of opacity to quantitative opacity, we can use the quantitative notion of information leakage.
We say that two opacity properties $\alpha, \alpha'$ are {\it indistinguishable} in $\Sigma$, and we write $\alpha \equiv_\Sigma \alpha'$, if for any trace $r$ satisfying $\alpha$, there exists another trace $r'$ satisfying $\alpha'$ such that both $r$ and $r'$ have analogous observations, i.e. $h(r)=h(r')$.
Let us generalize the original set of opacity properties from $\set{\alpha, \neg \alpha}$ to $\overline{\alpha}= \set{\alpha_1, \ldots, \alpha_n}$. In this case, the system $\Sigma$ is called {\it opaque}, if every pair of opacity properties in $\overline{\alpha}$ are mutually indistinguishable.
Let $Q= \{Q_1, Q_2, \ldots, Q_k\}$ be the quotient space of $O$
characterized by the indistinguishability relation.
Let $B_Q = \seq{B_1, B_2, \ldots, B_k}$ be the sizes of observational
equivalence classes from $Q$; let $B = \sum_{i=1}^k B_i$.
Assuming uniform distributions on $Q$, K\"opf and Basin~\cite{KB07} characterize expressions for various information-theoretic measures on information leaks which are given below:
\begin{enumerate}[leftmargin=*]
\item {\it Shannon Entropy:}
$SE(\Sigma,\overline{\alpha}) = (\frac{1}{B}) \sum\limits_{1 \leq i \leq k} B_i \log_2(B_i)$,
\item {\it Guessing Entropy:}
$GE(\Sigma,\overline{\alpha}) = (\frac{1}{2B}) \sum\limits_{1 \leq i \leq k} B_i^2 + \frac{1}{2}$,
\item {\it Min-Guess Entropy:}
$MG(\Sigma,\overline{\alpha}) {=} \min\limits_{1 \leq i \leq k} \set{(B_i + 1)/2}$.
\end{enumerate}
This allows us to generalize our opacity requirements in a quantitative fashion.
Given a property $\varphi$ as a mission requirement, and
opacity property tuple $\overline{\alpha} = \{\alpha_1, \ldots, \alpha_k\}$, an entropy bound $K$ and the corresponding entropy criterion $\kappa \in \set{SE, GE, MG}$, the quantitative security-aware
verification $\Sigma \models (\varphi, \overline{\alpha})$ is to decide whether $\Sigma \models \varphi$ and $\kappa(\Sigma,\overline{\alpha}) \leq K$.
Similarly, the quantitative security-aware synthesis is to design a supervisor/controller $C$ such that
$\Sigma_C \models (\varphi, {\overline{\alpha}})$.
Quantitative theory of information have been widely used
for the verification of security properties~\cite{smith2009foundations,KB07,backes2009automatic,heusser2010quantifying} in the context of finite state and software systems.
Moreover, for such systems several
restricted classes of synthesis approaches~\cite{kopf2009provably,askarov2010predictive,zhang2011predictive,zhang2012language,kadloor2012mitigating,schinzel2011efficient,DBLP:conf/cav/Tizpaz-NiariC019} have been proposed that focus on side-channel mitigation techniques by increasing the remaining entropy of secret sets leaked while maintaining the performance.
\subsection{Data-Driven Approaches for CPS Security}
This paper assumed the access to a model of the system and proposed security-aware verification and synthesis approaches.
Oftentimes, a true explicit model of the system is not available or is too large to reason with formally.
Reinforcement learning~\cite{sutton2018reinforcement} (RL) is a sampling-based optimization algorithm that computes optimal policies driven by scalar reward signals.
Recently, RL has been extended to work with formal logic~\cite{LTLBased2,camacho2019ltl,oura2020reinforcement,hasanbeig2019certified,lavaei2020formal}, and automatic structures ($\omega$-automata~\cite{hahn2019omega,mateo21} and reward machines~\cite{RM1}) instead of scalar reward signals.
A promising future direction is to extend RL-based synthesis to reason with security properties of the system.
The controller learned via deep RL will have deep neural networks as the controllers.
Additionally, deep neural networks are often employed in place of cumbersome tabular controllers to minimize the size of the program logic.
In such systems, security verification need to reason with neural networks along with the system dynamics.
There is a large body of work~\cite{huang2017safety,Abate21,hahn2019omega,pulina2012challenging,lomuscio2017approach,xiang2018reachability,lavaei2020formal} in verifying control systems with neural networks using SMT solvers, and will provide a promising avenue of research in developing security verification and synthesis approaches for CPS with neural networks based controllers.
Radical advances in inexpensive sensors, wireless technology, and the Internet of Things (IoT) offer unprecedented opportunities by ubiquitously collecting data at high detail and at large scale. Utilization of data at these scales, however, poses a major challenge for verifying or designing CPS, particularly in view of the additional inherent uncertainty that data-driven signals introduce to systems behavior and their correctness. In
fact, this effect has not been rigorously understood to this date, primarily due to the missing link between
data analytics techniques in machine learning/optimization and the underlying physics of CPS. A future research direction is to
develop scalable data-driven approaches for formal verification and synthesis of CPS with unknown closed form
models (a.k.a. black-box systems) with respect to both mission and security properties. The main novelty is to bypass the model identification phase
and directly verify or synthesize controller for CPS using system behaviors. The main reasons behind the quest to directly work on system behaviors and bypass the identification
phase are: i) Identification can introduce approximation errors and have a large computational complexity; ii) Even when
the model is known, formal verification and synthesis of CPS are computationally challenging.
\subsection{Security for Network Multi-Agent CPS}
This paper mostly discussed a centralized setting for CPS security, i.e., a single CPS plant with global secrets against a single attacker, although the CPS itself may consist of several smaller subsystems.
However, in many modern engineering systems such as connected autonomous vehicles \cite{lu2014connected}, smart micro-grids \cite{yu2016smart} and smart cities \cite{cassandras2016smart}, there may exist no centralized decision-maker.
Instead, each CPS agent interacts and collaborates/competes with each other via information exchanges over networks to make decisions, which leads to the network multi-agent CPS. There is a large body of works~\cite{guo2015multi,tumova2016multi,guo2016communication,kantaros2016distributed,schillinger2018simultaneous,sahin2019multi} in synthesizing coordination strategies for network multi-agent CPS for high-level mission requirements using formal methods. However, the security issue, which is more severe in multi-agent CPS due to large communications and information exchanges, is rarely considered.
In particular, in multi-agent CPS, each agent may have its own security considerations that depend on the time-varying configurations of the entire network. Therefore, how to define formal security notions that are suitable for multi-agent systems is an important but challenging future direction.
Recently, security and privacy considerations over networks have attracted significant attentions in the context of distributed state estimations \cite{mitra2019byzantine,an2022enhancement}, distributed averaging/consensus \cite{mo2017privacy,hadjicostis2020privacy}, distributed optimizations \cite{han2017differentially,lu2018privacy}, and distributed machine learning \cite{huang2020instahide,li2020federated}.
However, those results are mostly developed for distributed computing systems and are not directly applicable for multi-agent CPS with heterogeneous dynamics. Furthermore, most of the existing security-aware protocols for distributed systems are designed for specific tasks and there is still a lack of formal methodologies for security-aware verification and secure-by-construction synthesis of communication protocols and coordination strategies for network multi-agent CPS.
Finally, rather than a single passive attacker, network CPS may suffer from multiple active malicious attackers.
Therefore, one needs to develop effective approaches for characterizing and controlling the evolution of security properties over dynamic networks of multiple players. A promising future direction is to develop a comprehensive framework for multi-agent CPS security by extending formal reasoning with multi-player game-theory.
\section{Conclusion}
This paper may serve as an excursion into some prominent ideas and formalism from three distinct fields of formal methods, discrete-event systems, and control theory to study secure-by-construction synthesis paradigm.
We intentionally kept the technical discussion at a higher-level to expand the readership and aimed to provide necessary background and references, where appropriate.
We synthesized a general setting of security-aware verification and secure-by-construction synthesis integrating various notions of privacy and correctness in a common framework.
While this article is primarily informed by the research interests of the authors, we hope that it provides the basic foundations on which the related questions can be posed and answered.
We shall draw the readers' and potential researchers' attention that, security has been a moving goalpost and more
damaging vulnerabilities are yet unknown. The proposed
approaches in this paper need to be combined with classical fuzzing-based security
research to uncover previously undiscovered security vulnerabilities.
Moreover, most of the existing results on security analysis for CPS remain mainly theoretical.
Over the past few years, several software tools (e.g., \texttt{DESUMA} \cite{ricker2006desuma}, \texttt{SUPREMICA} \cite{akesson2006supremica}, and \texttt{TCT} \cite{feng2006tct}) have been developed for the analysis of DES modeled as finite automata, which are shown to be useful in the verification or synthesis of opacity properties for finite systems.
Our prior research has produced software tools including \texttt{SCOTS} \cite{scots}, \texttt{pFaces} \cite{pfaces}, \texttt{OmegaThreads} \cite{omegathread}, \texttt{DPDebugger} \cite{tizpaz2018differential} and \texttt{Schmit} \cite{DBLP:conf/cav/Tizpaz-NiariC019}, which provides formal, automated
abstractions of complex CPS and of reactive synthesis.
There is a great need to develop efficient toolboxs and proof-of-concept benchmarks to evaluate the practical feasibility of the foundations and algorithms developed for
abstracting, analyzing, or enforcing security properties over complex CPS.
In addition to academic benchmarks, it is important to improve the applicability of theoretical methods to industrial case studies and real-life applications. Designing open access courses that provide an ``end-to-end
view", starting from the foundations of control and discrete systems theory and going into security issues for CPS is also needed to train students, particularly those deciding to pursue research or work
professionally on autonomous systems.
\bibliographystyle{abbrv}
|
{'timestamp': '2022-02-15T02:43:35', 'yymm': '2202', 'arxiv_id': '2202.06677', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06677'}
|
arxiv
|
\section{Introduction}
In this paper, we denote by (resp. $\N$) $\Z$ the set of (resp. non-negative)
integers and by $\Q$ (resp. $\Q_+$), $\R$ and $\mathbb{C}$ the fields of rational (resp. positive rational), real and complex
numbers.
For a complex variable or number $f$, we denote by $\bar{f}$ the
associated conjugate variable or number.
Let $\Hi[z]$ be the set of trigonometric univariate polynomials defined as a subset of Laurent polynomials with complex coefficients and
complex variable $z$ as follows:
\begin{equation}\label{Cfz}
f(z) = f_0+\left(\frac{f_1}{z}+\bar f_1z\right) +\dots+\left(
\frac{f_d}{z^d}+\bar f_dz^d\right),
\end{equation}
with $f_0 \in \R$ and $d \in \N$.
By convention, when $f_d\neq 0$, $d$ is the degree of $f$; the degree of the
zero polynomial is $-\infty$.
In this paper, since we work with base fields of characteristic zero, we see
more polynomials through the evaluation maps they define than as algebraic
objects. Note that for $f \in \Hi[z]$, the restriction of the map $\zeta \mapsto
f(\zeta)$ over the {\em unit circle} $\mathscr{C} := \{\zeta\in\mathbb{C}:|\zeta|=1\}$
coincides with the evaluation map defined by the polynomial
\begin{equation*}
g(z) = f_0 +\left({f_1}{\bar z}+\bar f_1z\right) +\dots+\left(
{f_d}{\bar z}^d+\bar f_dz^d\right),
\end{equation*}
since $\bar \zeta = \zeta^{-1}$ for $\zeta \in \mathscr{C}$.
Note also that for any $\zeta\in \mathscr{C}$, $g(\zeta)\in \R$ so that $g$ is a
{\em Hermitian} polynomial.
Finally, note that for any
Hermitian polynomial $g$, there exists $f \in \Hi[z]$ such that the restrictions
to $\mathscr{C}$ of the maps $\zeta \mapsto g(\zeta)$ and $\zeta \mapsto f(\zeta)$
coincide (this is due to the fact that all points in $\mathscr{C}$ satsify $ \zeta \bar \zeta
= 1$).
For $h(z) = \sum_{k=0}^d h_k z^k\in \mathbb{C}[z]$, we define $h^\star(z) = \sum_{k=0}^d
\bar h_k z^{-k}$.
One says that $f$ is a \textit{sum of Hermitian squares} (SOHS) if there exist
some $r \in \N-\{0\}$ and polynomials $s_1,\dots,s_r $ in $\mathbb{C}[z]$ such that
$$f(z)=\sum_{j=1}^{r} s_j (z) s_j^\star ({z}) \,.$$
This terminology of Hermitian squares comes from the above discussion as $s_j^\star( \zeta) = s_j (\bar \zeta)$ for all $\zeta \in \mathscr{C}$.
By the Riesz-Fej\'{e}z spectral factorization theorem (see, e.g., \cite[Theorem
1.1]{dumi2017}), any trigonometric univariate polynomial which is non-negative over the unit
circle $\mathscr{C}$ can be written as an Hermitian square, i.e., an SOHS with a single term.
Its proof \cite[pp. 3--5]{dumi2017} is constructive but requires to manipulate
exactly all $2d$ complex roots of the associated Laurent polynomial. Usually,
this algorithm is applied with approximate computations, leading to approximate
certificates of non-negativity over $\mathscr{C}$.
The subset of $\Hi[z]$ with \textit{Gaussian integers} coefficients, i.e., all
coefficients $f_i$ lie in $\Z + i \Z$ (where $i$ is the standard imaginary unit)
is denoted by $\Hi(\Z)[z]$. In this paper, we focus on the computation of {\em
exact} certificates of non-negativity of polynomials in $\Hi(\Z)[z]$ by means
of {\em exact} SOHS decompositions.
Our motivation comes from design problems in discrete-time signal processing. In
particular, for the design of finite impulse response (FIR) filters in signal
processing, minimizing the stopband energy is a crucial issue \cite[Chapter
5]{dumi2017}. Computing exact SOHS decompositions of trigonometric univariate polynomials
in this context appears to be a natural computational issue.
\paragraph*{Our contribution}
We design three exact algorithms to compute SOHS decompositions of polynomials
in $\Hi(\Z)[z]$ that are \textit{positive} over the unit circle $\mathscr{C}$.
These algorithms are based on perturbation-compensation or rounding-projection
techniques. We analyze their bit complexities and output size as well.
We use the height of a polynomial with rational coefficients to measure its
\textit{bitsize} that is defined as follows. The bitsize of an integer $b$ is
denoted by $\hht(b):=\lfloor\log_2(|b|)\rfloor+1$ with $\hht(0):= 1$, where
$\log_2$ is the binary logarithm. Given $a\in\Z$ and $b\in\Z$ with $b\neq 0$ and
$\gcd(a,b)=1$, we define $\hht\left ({a} / {b} \right )=\hht(a)+\hht(b)$. We
define the bitsize of a Gaussian rational number as $\hht(a+ib)=\max(\hht(a),
\hht(b) )$, where $a,b\in \Q$. For a non-zero polynomial $f$ with Gaussian
rational coefficients, we define $\hht(f)$ as the maximum bitsize of the
non-zero coefficients of $f$.
For two maps $p,q:\N^m\to \R$, one writes ``$p(v)=O(q(v))$" when there exists
$b\in \N$ such that $p(v)\leq b q(v)$, for all $v\in \N^m$. We use the notation
$p(v)= \widetilde O (q(v))$ when $p(v)=O(q(v)\log^kq(v))$
for some $k\in \N$.
The first algorithm we design, called $\csosone$, is a perturbation-compensation
one in which the numerical step computes an approximate SOHS decomposition for a
well-chosen perturbation of the input polynomial with complex root isolation.
\begin{theorem}\label{thm:bit1} Let $f\in \Hi(\Z)[z]$ be positive on $\mathscr{C}$ of degree $d$ and coefficients of maximum bitsize $\tau$. There exists
an Algorithm $\csosone$ which on input $f$ computes an SOHS decomposition of
$f$ with Gaussian (or Gaussian modulus) coefficients using at most
\[\widetilde{O}\left (d^6(d+\tau) \right )\]
bit operations. In addition, the maximum bitsize of the output coefficients is
bounded from above by $\widetilde{O}(d^5(d+\tau))$.
\end{theorem}
The two other algorithms, called $\csostwo$ and $\csosthree$, are based on
complex \emph{semidefinite programming} (SDP).
SDP consists of minimizing a linear function over a set of matrices constrained to have non-negative eigenvalues; see \cite{wolkowicz2012handbook}.
In $\csostwo$, we compute an
approximate SOHS decomposition for the perturbation by using complex SDP
solving. Algorithm $\csosthree$ is an adaptation of the rounding-projection
algorithm raised by Peyrl and Parrilo \cite{peyrl2008}. These algorithms are
more expensive compared to the first one because we replace complex root
isolation by complex SDP solving. Despite their worse complexity, they allow one
to handle constrained optimization problems and to design filters.
\begin{theorem}\label{thm:bit2}
Let $f\in \Hi(\Z)[z]$ be positive on $\mathscr{C}$ of degree $d$ and
coefficients of maximum bitsize $\tau$. There exist algorithms $\csostwo$ and
or $\csosthree$ which on input $f$ output an SOHS decomposition of $f$ with (modulus) of Gaussian coefficients
using at most
\[\widetilde{O}(d^{13}(d+\tau)^2)\]
bit operations. In addition, the maximal bitsize of the output
coefficients is bounded from above by $\widetilde{O}(d^6(\tau+d))$.
\end{theorem}
These algorithms have been implemented using the {\sc Julia} programming
language \cite{bezanson2017julia}.
We report on practical experiments that Algorithm $\csosone$ runs faster than the other algorithms; that coincides with the obtained complexity.
Furthermore, we rely on $\csosthree$ to design filters in a certified way.
\textit{Related works.} Computation of exact weighted sums of squares decompositions
of a univariate polynomial $f\in\Q[z]$ has been studied in
\cite{schweighofer1999,chevillard2011,univsos}.
Many of the techniques developed
in this paper are borrowed from these previous works.
We also mention \cite{krick2021univariate} which allows to compute certificates of
non-negativity of univariate polynomials sharing common real roots with another
univariate polynomials.
Note that computing sums of squares decompositions of
non-negative univariate polynomials with rational coefficients is easier from a complexity viewpoint, according to
the estimate in \cite[Theorem 4.4]{univsos}.
It should be noted that our SOHS decomposition problems
can be translated into sums of squares decompositions of bivariate polynomials with real
variables, which are positive on $\mathscr{C}$.
This is a topical computational issue popularized by the original
papers of Lasserre and Parrilo \cite{lasserre2001,parrilo2000} allowing to
compute approximate sums of squares decompositions based on semi-definite
programming.
Hybrid symbolic-numeric turning these approximate certificates to
exact ones are given in
\cite{peyrl2008,kaltofen2012,guo2012,magron2021exact,magron2021sum}.
Exact certificates for several special families of polynomials have been given,
for instance SAGE/SONC polynomials \cite{magron2019,wang2020second}, polynomials
lying in the interior of the SOS cone \cite{magron2021exact}, and polynomials
whose gradient ideals are zero-dimensional and radical \cite{magron2021sum}.
Applying those results to the bivariate setting we can reduce our problems to,
\cite[Theorem 16]{magron2021exact} yields bit complexity and output bitsize
estimates which are exponential in the input degree of $f$ and in the maximum
bitsize of its coefficients.
Note that in our case, the degree of the SOHS decomposition is known in advance and we estimate the bit complexity of the coefficients involved in this decomposition.
In the multivariate case, the situation is more delicate and providing degree bounds is already a challenge.
Recent efforts have been pursued for polynomials positive over the \textit{unit sphere} \cite{reznick1995uniform,fang2021sum}, or for more general closed sets of constraints defined by finitely many polynomials \cite{baldi2021moment,mai21}.
Theorem~2 in \cite{fang2021sum} provides us a degree bound that is linear in the number of variables
while Theorem 1.7 in \cite{baldi2021moment} and Corollary 1 in \cite{mai21} give bounds that are polynomial in the input degrees and exponential in the number of variables.
\if
To prove the above estimates on both the running time and bitsize of the coefficients in the SOHS decomposition, we introduce a lower bound for the minimum of $f$ on the unit circle:
$f-\frac{1}{2^{n}}$ is positive over the unit circle
for some $n=\widetilde{O}(d^3(d+\tau))$ (Lemma \ref{lm:epsN}).
\fi
\if{
\paragraph*{Structure of the paper}
In the next section, we provide
preliminary results used in the paper. Sections
\ref{sec:csos1}--\ref{sec:csos3} introduce Algorithms $\csosone$, $\csostwo$, and $\csosthree$, respectively,
and analyze theirs bit complexities. Practical experiments are given in the last section.
}\fi
\section{Auxiliary results} \label{sec:prelim}
For a polynomial $f = f_0+\cdots+ f_dz^d \in \mathbb{C}[z]$ of degree $d$, the
\textit{minimal distance} between the roots $\alpha_1, \ldots, \alpha_d$ of $f$
is defined by
$$\sep(f):=\min\{|\alpha_i-\alpha_j|, \, \alpha_i\neq \alpha_j\}.$$
The \textit{norm} of $f$ is defined as $\|f\|:=\sqrt{|f_d|^2+\dots+|f_0|^2}$.
The following lemma is an immediate consequence of the discussion following the corollary of Theorem 2 from \cite{mahler1964}.
\begin{lemma}\label{lm:sepZ}
Let $f\in \Z[i][z]$ of degree $d$ and $\tau$
be the maximum bitsize of its coefficients. The minimal distance between the roots of $f$ satisfies
\begin{equation}\label{eq:sepZ}
\sep(f) \geq
\frac{\sqrt{3}}{d^{\frac{d}{2}+1}\|f\|^{d-1}}.\end{equation}
Therefore, one needs an accuracy of $\delta = \widetilde{O}(\tau d )$ to compute distinct approximations of the roots of $f$ with complex root isolation.
\end{lemma}
\begin{proof} By \cite[Theorem
2]{mahler1964
, the minimal distance between the roots of $f$ satisfies:
\begin{equation}\label{eq:sepC}
\sep(f) \geq \frac{\sqrt{3|\Disc(f)|}}{d^{\frac{d}{2}+1}\|f\|^{d-1}},
\end{equation}
where $\Disc(f) = f_d^{2d-2} \prod_{j<k} (\alpha_j - \alpha_k)^2$ is the discriminant of $f$.
Note that $\Disc(f)$ can be written as a polynomial in $f_0,\dots,f_d$ with integer coefficients, thus $\Disc(f)\in \Z[i]$.
Now we consider the two following cases.
\textbf{Case 1:} $f$ has no multiple root in $\mathbb{C}$. Then, $\Disc(f)$ is
nonzero. Since $\Disc(f)\in \Z[i]$, one has $|\Disc(f)|\geq 1$ which from
\eqref{eq:sepC}, implies
$$\sep(f) \geq
\frac{\sqrt{3|\Disc(f)|}}{d^{\frac{d}{2}+1}\|f\|^{d-1}} \geq
\frac{\sqrt{3}}{d^{\frac{d}{2}+1}\|f\|^{d-1}}.$$
\textbf{Case 2:} $f$ has a multiple root in $\mathbb{C}$. Let $p$ be the square-free
part
of $f$. From
\cite[Corollary 2.2
]{lang1993}, the coefficients of $p$ lie in $\Z[i]$. Clearly,
$\sep(p)=\sep(f)$ and $\|p\|\leq \|f\|$. Hence, by applying Case 1 for $p$,
where $k=\deg p\leq d$, we have
$$\sep(f)=\sep(p) \geq
\frac{\sqrt{3}}{k^{\frac{k}{2}+1}\|p\|^{k-1}}\geq
\frac{\sqrt{3}}{d^{\frac{d}{2}+1}\|f\|^{d-1}}.$$
\end{proof}
The following lemma provides a lower bound on the minimum of a real bivariate
polynomial over the unit circle in $\R^2$.
\begin{lemma}\label{lm:min}
Let $p\in\Z[x,y]$ be a real bivariate polynomial of degree $d$ and $\tau$ be
the maximum bitsize of its coefficients. Assume that $p$ is positive on the
unit circle $\mathscr{C}$. Then, the minimum of $p$ on $\mathscr{C}$ satisfies the
following inequality:
\begin{equation}\label{eq:min}
p_{\min} := \min\{p(x,y):x^2+y^2=1\} \geq 2^{-\widetilde{O}(d^3(d+\tau))}.
\end{equation}
\end{lemma}
\begin{proof} We consider the following algebraic set:
\begin{equation*}\label{eq:m}
V := \{(x,y,m) \in \mathbb{C}^3 : p(x,y) -m = \ y\frac{\partial p}{\partial x}-
x\frac{\partial p}{\partial y}=0, x^2+y^2=1 \}.
\end{equation*}
Note that the projection of $V$ on the $m$-axis defines the critical values of
the restriction of the evaluation map $z \mapsto p(z)$ to $\mathscr{C}$ which
contains $p_{\min}$.
Assume first that $V$ is finite. By \cite[Corollary 2]{SaSch2018}, there is a
zero-dimensional parametrization of $V$ defined by real univariate polynomials
with bitsizes upper bounded by $\widetilde{O}(d^3(d+\tau))$. Since there exists
$(x_0,y_0)$ on $\mathscr{C}$ such that $(x_0,y_0,p_{\min})$ belongs to $V$,
$p_{\min}$ is a (non-zero) root of a univariate polynomial of degree at most
$O(d^3\tau)$. Hence, the Cauchy bound \cite{Cauchy1830} yields:
$$|p_{\min}| \geq 2^{-\widetilde{O}(d^3(d+\tau))}.$$
Assume now that $V$ is not finite. By Krull's theorem
\cite{krull1929idealtheorie}, this implies that $\mathscr{C}$ is contained in
the complex zero set defined by $y\frac{\partial p}{\partial x}- x\frac{\partial
p}{\partial y}=0$, whence is a factor of this polynomial. This implies that
there exists a factorization $p = p_1p_2$ where $p_1$ is a power of $x^2+y^2-c$
(where $c$ is a constant) and the zero set of the polynomial $y\frac{\partial
p_2}{\partial x}- x\frac{\partial p_2}{\partial y}=0$ has a zero-dimensional
intersection with $\mathscr{C}$. This yields the following analysis.
The set $V$ is the union of a 1-dimensional component containing points $(m, x,
y)$ where $(x, y)$ ranges over $\mathscr{C}$ and $m = c-1$, and a
0-dimensional component containing points $(m, x, y)$ which are solutions to
\[
p(x, y)=m, \, y\frac{\partial p_2}{\partial x}- x\frac{\partial p_2}{\partial
y}=0, \, x^2+y^2=1.
\]
Applying the first paragraph of the proof to the above system ends the proof.
\end{proof}
The upcoming result will be used to estimate bit complexities of the two
algorithms $\csosone$ and $\csostwo$.
\begin{lemma}\label{lm:epsN}
Let $f\in \Hi(\Z)[z]$ be positive on $\mathscr{C}$, of degree $d$ and $\tau$
be the maximum bitsize of its coefficients. Then, there exists a positive
integer $N=\widetilde{O}(d^3(d+\tau))$ such that $f-\frac{1}{2^{N}}$ is
positive on $\mathscr{C}$.
\end{lemma}
\begin{proof}
With $z = x+iy$, let us define $p(x,y) := f(x+iy)$.
Since $f \in \Hi(\Z)[z]$, one has $p \in \Z[x,y]$ with degree $2d$ and bitsize $O(\hht(d)+ \tau)$.
Clearly, $\min\{f(z):|z|=1\}=
\min\{p(x,y):x^2+y^2=1\}=p_{\min}$.
Let us choose a positive integer $N$ such that
$\frac{1}{2^{N}}\leq p_{\min}$. From Lemma~\ref{lm:min},
we conclude that $N=\widetilde{O}(d^3(d+\tau))$.
\end{proof}
The following result, stated in \cite[Lemma 2.1 \& Theorem 3.2]{bai1989floating}, will be used to investigate the bit complexity of the two algorithms $\csostwo$ and $\csosthree$ based on SDP solving.
\begin{lemma}\label{lm:Bai}
Let $Q$ be a Hermitian matrix indexed on $\{-d,\dots,d\}$, with positive eigenvalues and rational entries.
Let $L$ be the factor of $Q$ computed by Cholesky's decomposition with
finite precision $\delta_c$. Then, $LL^T = Q+H$, where
\begin{equation}\label{eq:H}
|H_{ij}|\leq \frac{(d+2)2^{-\delta_c}\sqrt{|Q_{ii}Q_{jj}|}}{1-(d+2)2^{-\delta_c}}.
\end{equation}
In addition, if the smallest eigenvalue $\tilde{\lambda}$ of $Q$ satisfies the inequality
\begin{equation}\label{eq:2deltac}
2^{-\delta_c} < \frac{\tilde{\lambda}}{d^2+d+(d-1)\tilde{\lambda}},
\end{equation}
Cholesky's decomposition returns a rational nonsingular factor $L$.
\end{lemma}
\section{Algorithm based on root isolation}\label{sec:csos1}
In this section, we propose an algorithm, called $\csosone$, to compute an SOHS
decomposition of a polynomial in $\Hi(\Z)[z]$ which is positive on the unit circle
$\mathscr{C}$. It puts into practice a perturbation-compensation procedure based on
complex roots isolation, and can be viewed as the extension of the procedure $\texttt{univsos2}$ (stated in \cite{chevillard2011} and analyzed in \cite[\S~4]{univsos}) to the complex setting.
\subsection{Description}
\textbf{Description.} Algorithm $\csosone$ takes as input a polynomial $f\in
\Hi(\Z)[z]$ of degree $d$ which is positive on $\mathscr{C}$. It outputs two
positive rational numbers $\varepsilon, a$, a rational number $u_0$, and two
lists of Gaussian numbers $[u_1,\dots,u_d]$ and $[\alpha_1,\dots,\alpha_d]$ such
that
\begin{multline}\label{fz}
f(z)= \, \left(\varepsilon-2\sum_{k=1}^{d}|u_k|-u_0\right)
+\sum_{k=1}^{d}|u_k|\left( z^k +\frac{u_k}{|u_k|}\right)
\left( {z}^{-k} +\frac{\bar{u}_k}{|u_k|}\right) \\
+a\prod_{k=1}^d\left( z-\alpha_k \right) \left(
{z}^{-k}-\bar{\alpha}_k\right) \text{ with }
\left(\varepsilon-2\sum_{k=1}^{d}|u_k|-u_0\right) > 0.
\end{multline}
\begin{algorithm}
\caption{$\csosone$}\label{alg:csosone}
\label{alg:sos1}
\begin{algorithmic}[1]
%
\Require $f \in \Hi(\Z)[z]$ positive on $\mathscr{C}$ of degree $d$
\Ensure $\varepsilon, a \in \Q_+$,
$u_0 \in \Q$, two lists $[u_1,\dots,u_d]$ and $[\alpha_1,\dots,\alpha_d]$
in $\Q[i]$ providing an SOHS decomposition for $f$ on $\mathscr{C}$ as
in \eqref{fz}:
\State $\delta \gets 1$, $\varepsilon := 1$ and $p\gets f(x+iy)$\label{line:subs} \Comment{$z = x+iy$}
\While {$\texttt{hasrealrootoncircle}(p-\varepsilon)$} \label{line:while0}
$\varepsilon \gets \frac{\varepsilon}{2}$
\EndWhile\label{line:endwhile0}
\State boo := false
\While {not boo}\label{line:while1}
\State $[\alpha_1,\dots,\alpha_d] \gets
\rootsfun{f-\varepsilon}{\delta}$\label{line:roots}
\State $F:=\prod_{k=1}^d\left(z-
\alpha_k\right)\left( z^{-1} -\bar{\alpha}_k\right) $\label{line:F}
\State $a\gets\texttt{coeffs}(f,0)/\texttt{coeffs}(F,0)$, $u := f-\varepsilon-aF$\label{line:a}
\State $[u_0,u_1,\dots,u_d] \gets \texttt{coeffs}(u)$\label{line:lsu}
\If {$\varepsilon> u_0 + 2\sum_{k=1}^{d}|u_k|$} boo := true\label{line:stop}
\Else $\ \delta := 2 \delta$\label{Line:2delta}
\EndIf
\EndWhile\label{line:endwhile1}
\State \Return $\varepsilon, a, u_0,
[u_1,\dots,u_d],[\alpha_1,\dots,\alpha_d]$
%
\end{algorithmic}
\end{algorithm}
In Line \ref{line:subs} we replace $z$ by $x+iy$ in $f$ where $x,y$ are (real)
variables to obtain a real bivariate polynomial $p$ of degree $2d$. Since, by
assumption, $f$ is positive over $\mathscr{C}$, there exists $\varepsilon>0$ small
enough, such that $p$ is positive on $\mathscr{C}$. The first while loop
from Line \ref{line:while0} to \ref{line:endwhile0} computes such positive
rational number $\varepsilon$. To do so, it uses an auxiliary procedure
$\texttt{hasrealrootoncircle}$, which returns true if $p-\varepsilon$ cancels on the
$\mathscr{C} = \{(x,y)\in\R^2:x^2+y^2-1=0\}$. Such a procedure is easily obtained
with any polynomial system solver for bivariate polynomial systems. In practice
we use the real root solver {\sc msolve} \cite{msolve}.
In the second while loop from Line \ref{line:while1} to \ref{line:endwhile1},
the algorithm computes at Line \ref{line:roots} Gaussian approximations
$\alpha_1,\dots,\alpha_d$ (and their conjugates) of the complex roots of
$f-\varepsilon$ with accuracy $\delta$. This is done using a procedure
\texttt{complexroots} which on input a rational fraction and a required accuracy
$\delta$ returns all the complex roots of the numerator of the fraction at
accuracy $\delta$ (see, e.g., \cite{BiRo14}).
The idea is to obtain (up to proper scaling) an approximate SOHS decomposition
$F$ of $f - \varepsilon$.
The auxiliary $\texttt{coeffs}$ procedure provides the list of coefficients of a polynomial, e.g., $\texttt{coeffs}(f,0)$ returns the constant term of $f$.
We then consider the remainder $u$ at Line \ref{line:a} which is the difference between $f-\varepsilon$ and its approximate SOHS decomposition.
As proved in Section \ref{sec:proofcsos1}, if the precision of root isolation is large enough, the stopping condition $\varepsilon > u_0 +
2\sum_{k=1}^{d}|u_k|$ is fulfilled, otherwise the precision
is increased.
To illustrate $\csosone$, we use the following simple
example.
\begin{example} Let $f = 5 + (1+i) z^{-1}+(1-i)z$ which is positive on
$\mathscr{C}$. We obtain $p=5+2x+2y$. With $\varepsilon = 1$, we check with
$\texttt{hasrealrootoncircle}$ that $p-\varepsilon$ is positive on $\mathscr{C}$.
With precision $\delta = 16$, we compute complex approximation roots $\alpha_1 = -\frac{7}{4} - \frac{7}{4}i$ and $\bar \alpha_1$ of $f-\varepsilon$.
Defining $F=(z-\alpha_1)(z^{-1}-\bar\alpha_1)$, we obtain $a=\frac{32}{57}$, $u=f-\varepsilon-aF=(\frac{1}{57}+ \frac{i}{57}) z^{-1}+(\frac{1}{57} -\frac{i}{57})z$. Clearly, $\varepsilon = 1 > 0 + \frac{2\sqrt{2}}{57}$ so the condition in Line \ref{line:stop} is satisfied. Then, $f$ has an exact SOHS decomposition as follows:
\begin{center}
$f = (1 -\frac{2\sqrt{2}}{57})+\frac{\sqrt{2}}{57}(z+
\frac{1+i}{\sqrt{2}})
(z^{-1} +\frac{1-i}{\sqrt{2}}) + \frac{32}{57}(z+\frac{7}{4}+ \frac{7}{4}i)(z^{-1}+\frac{7}{4} - \frac{7}{4}i)$.
\end{center}
\end{example}
\subsection{Proof of Theorem \ref{thm:bit1}}
\label{sec:proofcsos1}
\begin{proof}[Correctness of Algorithm $\csosone$]
We first prove that \textit{Algorithm $\csosone$ terminates and outputs an SOSH decomposition of $f$.}
By Lemma \ref{lm:epsN}, there exits a positive rational $\varepsilon$ such that
$f - \varepsilon$ is also positive on $\mathscr{C}$. Thus, the first loop
(from Line \ref{line:while0} to Line \ref{line:endwhile0}) of Algorithm
$\csosone$ terminates. The magnitude of the coefficients of the remainder
polynomial $u$ defined in Line \ref{line:lsu} converges to 0 as the precision
$\delta$ of the complex root finder goes to infinity (because of the continuity
of roots w.r.t. coefficients). This implies that the condition of Line
\ref{line:stop} is fulfilled after finitely many iterations, thus the second
loop (from Line \ref{line:while1} to Line \ref{line:endwhile1}) always
terminates. \if{ In Line \ref{line:lsu}, $aF$ is an approximation of
$f-\varepsilon$ that depends on the accuracy $\delta$ of the computation in
Line \ref{line:roots}. The difference $(f-\varepsilon) - aF$ goes to the zero
polynomial when $\delta$ goes to the infinity. Thus, the sum $u_0 +
2\sum_{k=1}^{d}|u_k|$ will go to zero as well.
This implies that the while loop in Lines \ref{line:while1}--\ref{line:endwhile1} will end after finitely many iterations.
\fi
Eventually, we have
\begin{equation*
f=\varepsilon+u_0+\left(u_1 {z}^{-1} +\bar{u}_1z\right)+\dots+\left(
u_d {z}^{-d}+\bar{u}_dz^d\right) +aF.
\end{equation*}
In addition,
\begin{equation}\label{eq:uk}
u_k z^{-k} + \bar{u}_k z^k =|u_k|\left( z^k
+\frac{u_k}{|u_k|}\right) \left( z^{-k}
+\frac{\bar{u}_k}{|u_k|}\right)-2|u_k|,
\end{equation}
yielding \eqref{fz}.
From the proof of the Riesz-Fej\'{e}z theorem (see, e.g., \cite[pp. 3--5]{dumi2017}), $f$ can be decomposed as a single Hermitian square, thus the constant term of $f$ lies in $\Q_+$.
Similarly the constant term $\prod_{k=1}^d |\alpha_k|^2$ of $F$ is also a positive rational number, so $a \in \Q_+$.
Clearly, the polynomial $F$ and the first
term on the right-hand side of \eqref{eq:uk} are SOHS. Hence, as $\varepsilon > u_0 +
2\sum_{k=1}^{d}|u_k|$, the right-hand side of \eqref{fz} is a sum of
$d+2$ Hermitian squares involving Gaussian (or Gaussian modulus) numbers.
\end{proof}
We now analyze the bit complexity of Algorithm $\csosone$.
\begin{proof}[Proof of Theorem~\ref{thm:bit1}] Let us show that \textit{the bitsizes of $u_0,\dots,u_d$, $\alpha_1,\dots,\alpha_d$ and $a$ in \eqref{fz} are bounded from above by $\widetilde{O}(d^5(d+\tau))$.}
The proof is almost the same as in the univariate real setting \cite[Theorem 4.3]{univsos}, thus we only provide the main ingredients and skip some technical details.
From Lemma \ref{lm:epsN}, there exists a positive
integer $N=\widetilde O (d^3(d+\tau))$ such that $f-\varepsilon$ is positive on $\mathscr{C}$, with $\varepsilon =\frac{1}{2^{N}}$.
Define $m:=2d$ and
$g(z) := z^d(f-\varepsilon) = \bar f_d z^{2 d} + \dots + \bar f_1 z^{d+1} +
g_d z^d + f_1 z^{d-1} + \dots + f_d$, with $g_{d}=f_0-\varepsilon$.
Note that $g$ and $f-\varepsilon$ have the same roots. Denote by $\zeta_1,\dots,
\zeta_{m}$ the (exact) complex roots of $g$ and by $\zeta'_1,\dots,\zeta'_{m}$
their approximations with a precision $\delta$, so that
$\zeta'_j=\zeta_j(1+e_j)$, where $|e_j|\leq e := 2^{-\delta}$, for
$j=1,\dots,m$.
Let $g':=\bar f_d(z-\zeta'_1)\dots(z-\zeta'_{m})$. The remainder polynomial $u$
defined in Line \ref{line:a} of Algorithm $\csosone$ satisfies $z^d u = g - g'$.
We now show that if $\delta=N+\log_2((2d+1)^2\|f\|)=\widetilde O (d^3(d+\tau))$,
then the coefficients of $u$ satisfy the condition $\varepsilon > u_0 +
2\sum_{k=1}^{d}|u_k|$. We apply Lemma \ref{lm:sepZ} to the polynomial obtained
by multiplying $z^d(f-\varepsilon)$ with the least common multiple of its
coefficients. Hence, we require an accuracy at least $\widetilde{O}(N d )$
to compute distinct approximations of its roots in the worst case. We will
actually need an accuracy of larger bitsize $\widetilde O (d^4(d+\tau))$ in the
worst case. \if{
\begin{equation}\label{eq:e}
e=2^{-\delta}<
\frac{1}{\delta}<\frac{1}{Cd^3(d+\tau)}<\frac{1}{m(m+1)}.
\end{equation}
}\fi
Let $j \in \{0,1,\dots,d\}$.
Using Vieta's formulas, we have
\begin{equation}\label{eq:Vieta}
\sum_{1\leq i_1<\cdots<i_{j}\leq m}\zeta_{i_1}\cdots
\zeta_{i_{j}} = (-1)^{j}\frac{g_{m-j}}{g_{m}} = (-1)^{j}\frac{g_{m-j}}{\bar f_d} \,.
\end{equation}
Similarly, we have:
\begin{equation}\label{eq:Vietaprime}
\sum_{1\leq i_1<\cdots<i_{j}\leq m}\zeta'_{i_1}\cdots
\zeta'_{i_{j}} = (-1)^{j}\frac{g'_{m-j}}{\bar f_d} \,.
\end{equation}
We estimate an upper bound for the coefficient $\bar u_{d-j}$ of the difference
polynomial $u$. Clearly, $\bar u_{d-j}=g_{m-j}-g'_{m-j}$. From \eqref{eq:Vieta}
and \eqref{eq:Vietaprime}, we see that
\begin{align*}
|\bar u_{d-j}| & =|\bar f_d| \left| \sum_{1\leq i_1<\cdots<i_{d+j}\leq m}(\zeta_{i_1}\cdots
\zeta_{i_{d+j}}-\zeta'_{i_1}\cdots \zeta'_{i_{d+j}}) \right| \\
&=|\bar f_d| \left| \sum_{1\leq i_1<\cdots<i_{d+j}\leq m}\zeta_{i_1}\cdots
\zeta_{i_{d+j}}\left( 1- \prod_{k=1}^{d+j} (1+e_{i_k})\right) \right |.
\end{align*}
Then, exactly as in the proof of \cite[Theorem 4.3]{univsos}, we rely on
\cite[Lemma 3.3]{higham2002accuracy} and the Cauchy bound \cite{Cauchy1830} to
obtain the desired estimates. \if{ As $e<\frac{1}{2m}$, we apply \cite[Lemma
3.3]{higham2002accuracy} and get $(1+e_{i_1})\cdots(1+e_{i_{d+j}})\leq
1+\theta_{d+j}$ with $|\theta_{i_{d+j}}|\leq \frac{i_{d+j}e}{1-i_{d+j}e}\leq
\frac{me}{1-me}$. (\textit{Need to check again}) Since \eqref{eq:e}, we
have $$(m+1)e-\frac{me}{1-me}=\frac{e(1-m(m+1)e)}{1-me}\geq 0.$$ This yields
$\frac{me}{1-me}\leq (m+1)e$. So, we can conclude that
$$\left| 1-(1+e_{i_1})\cdots(1+e_{i_{d+j}})\right|\leq (m+1)e.$$
From the above presentation of $\bar u_j$ and the above results, we obtain the
following estimates:
\begin{equation}\label{eq:ginfty}
|\bar u_{j}|\leq |\bar f_{d}|(j+1)e\leq \|f\|_{\infty}(m+1)e.
\end{equation}
The conclusion holds for
$j=0,\dots, d$, one has
$$u_0+2\sum_{k=1}^{d}|\bar u_k|\leq
e(m+1)^2\|f\|_{\infty}\leq e(m+1)^2\|f\|_{\infty}.$$
It follows from $\delta=N+\log_2\left( (2d+1)^2\|g\|_{\infty}\right)$ that
$e(2d+1)^2\|g\|_{\infty}=\varepsilon$. Therefore,
$\varepsilon>u_0+2\sum_{k=1}^{d}|u_k|$ holds when
$\delta=\widetilde{O}(d^3(d+\tau))$.
We choose $e_j=e=2^{-\delta}$ and $z'_j=z_j(1+2^{-\delta})$. This implies
that
$|\bar u_{j}|= |\bar f_{d}||1-(1+2^{-\delta})^j|,$
for all $j=0,\dots,d$.
It follows from $\hht(\bar f_d)\leq \tau$,
$\hht(\delta)=\widetilde{O}(d^3(d+\tau))$,
and
$\hht(\varepsilon)=\widetilde{O}(d^3(d+\tau))$, that
$$\hht(\bar u_{j})=\widetilde{O}(d^3(d+\tau)+jd^3(d+\tau))\leq \widetilde{O}(d^4(d+\tau)).$$
Hence, the maximal bitsize of the coefficients of $u$ is bounded from above by $\widetilde{O}(d^4(d+\tau))$.
We now estimate the bit complexity of the coefficient $a$ in \eqref{fz}. From Line \ref{line:a} in $\csosone$, one has $a = \frac{f_0}{F_0}$, where $F_0$ is the constant term of $F$. Clearly, $\hht(f_0)\leq \tau$. Because of \eqref{eq:Vieta}, $$F_0=(-1)^d\bar F_d\sum_{1\leq i_1<\cdots<i_{d}\leq m}z'_{i_1}\cdots z'_{i_{d}},$$
where $ z'_{i_j}\in\{\alpha_1,\dots,\alpha_{d},\frac{1}{\bar{\alpha}_1},\dots,\frac{1}{\bar{\alpha}_d}\}$. Since $\bar F_d =1$, $\hht(\alpha_i)\leq\hht(\delta)$, one has
$\hht(F_0)\leq d\hht(\delta)+\log_2\binom{2d}{d}\leq d\hht(\delta)+d\log_2(d+1)=\widetilde{O}(d^4(d+\tau))$.
Finally, the maximal bitsize of $u_k$'s and $a$ is bounded from above by $\widetilde{O}(d^4(d+\tau))$, as claimed.
}\fi
We now prove the remaining assertion in Theorem \ref{thm:bit1}: \textit{Algorithm $\csosone$ runs in $\widetilde{O}(d^6(d+\tau))$ boolean
operations.}
Again the proof scheme is very similar as the one of \cite[Theorem 4.4]{univsos}. The algorithm includes two steps.
We consider the first step checking that $g(z)$ defined in the previous proof has no real root on the unit circle.
Let $\varepsilon$ be given as in Lemma~\ref{lm:epsN} with $\hht(\varepsilon)=\widetilde{O}(d^3(d+\tau))$.
By relying on Sylvester--Habicht sequences \cite[Corollary~5.2]{lick2001}, the check can be performed
using $O((2d)^2\hht(\varepsilon))=\widetilde{O}(d^5(d+\tau))$ boolean operations.
In the second step, we compute approximate complex roots of $g(z)$ and check the condition at Line \ref{line:stop}.
It follows from \cite[Theorem~4]{mehlhorn2015approximate} that isolating disks of radius less than $2^{-\delta}$ for all complex roots of $g(z)$ can be computed in $\widetilde{O}(d^3 + d^2 \hht(\varepsilon) + d \delta)) = \widetilde{O}(d^6(d+\tau))$ boolean operations.
The computation of all $u_k$ has a negligible cost w.r.t. to the computation of the complex roots.
Therefore, we conclude that $\csosone$ runs in $\widetilde{O}(d^6(d+\tau))$
boolean operations.
\end{proof}
\section{Algorithm based on complex SDP}\label{sec:csos2}
This section states and analyzes another perturbation-compensation algorithm,
named $\csostwo$, to compute an SOHS decomposition of a trigonometric polynomial
being positive on $\mathscr{C}$. In the algorithm, the approximate SOHS
decomposition for the perturbation is computed by using complex SDP solving. It
can be viewed as the adaptation of the procedure $\texttt{intsos}$ (stated and
analyzed in \cite[\S~3]{magron2021exact}) to the complex univariate setting. Let
$I$ stands for the identity matrix of size $d+1$. A Hermitian matrix $Q$ is said
to be positive semidefinite (resp. definite) if $Q$ has only non-negative (resp.
positive) eigenvalues, and in this case we use the notation $Q \succeq 0$ (resp.
$Q \succ 0$). Given $f \in \Hi[z]$ of degree $d$, recall that a Hermitian matrix
$Q \in \mathbb{C}^{(d+1) \times (d+1)}$ is called a \emph{Gram} matrix associated with
$f$ if $f= v_d^{\star} \cdot Q \cdot v_d$, where $v_d(z) := (1,z,\dots,z^d)$
contains the canonical basis for polynomials of degree $d$ in $z$. By
\cite[Theorem 2.5]{dumi2017}, $f$ is positive on $\mathscr{C}$ if and only if there
exists a positive definite Gram matrix associated to $f$.
\subsection{Description}
The input of Algorithm $\csostwo$ includes a polynomial $f\in
\Hi(\Z)[z]$ of
degree $d$ which is positive on $\mathscr{C}$.
The outputs are $\varepsilon \in \Q_+$, a list of Gaussian numbers
$[u_0,u_1,\dots,u_d]$, and a list of polynomials $[s_1,\dots,s_d]$ in $\Q[i][z]$ providing an
SOHS decomposition of $f$ as follows
{\small
\begin{equation}\label{eq:fsos2}
f = \Big(\varepsilon-u_0-2\sum_{k=1}^{d}|u_k|\Big)
+\sum_{k=1}^{d}|u_k|\Big(z^k
+\frac{u_k}{|u_k|}\Big)
\Big(z^{-k} +\frac{\bar{u}_k}{|u_k|}\Big)
+\sum_{k=0}^{d}
s_k^\star s_k.
\end{equation}
}
\begin{algorithm}
\caption{$\csostwo$}\label{alg:csos2}
\begin{algorithmic}[1]
\Require $f \in \Hi(\Z)[z]$ positive on $\mathscr{C}$ of degree $d$
\Ensure $\varepsilon\in \Q_+$, $[u_0,u_1,\dots,u_d]$
in $\Q[i]$, $[s_0,\dots,s_d]$ in $\Q[i][z]$ providing an
SOHS decomposition of $f$ as in \eqref{eq:fsos2}.
\State $\delta \gets 1$, $R \gets 1$, $\delta_c = 1$, $\varepsilon := 1$ and $p\gets f(x+iy)$\label{line:sub2}
\While {$\texttt{hasrealrootoncircle}(p-\varepsilon)$} $\varepsilon \gets \frac{\varepsilon}{2}$
\EndWhile
\State boo := false
\While {not boo} \label{line:while4}
\State $(\tilde{Q}, \tilde{\lambda}) \gets
\sdpfun{f-\varepsilon}{ \delta}{R}$ \label{line:sdp}
\State $[s_0,\dots,s_d]
\gets \choleskyfun{\tilde{Q}}{\tilde{\lambda}}{\delta_c}$
\label{line:chol} \Comment{$f_\varepsilon \simeq
\sum_{k=0}^{d} s_k^\star s_k$}
\State $u: = f-\varepsilon - \sum_{k=0}^{d}
s_k^\star s_k$, \ $[u_0,u_1,\dots,u_d] \gets \texttt{coeffs}(u)$\label{line:lsu2}
\If {$\varepsilon> u_0 + 2\sum_{k=1}^{d}|u_k|$}\label{line:condition}
boo := true
\Else \ $\delta:=2\delta, R:=2R, \delta_c:=2\delta_c$
\EndIf
\EndWhile\label{line:endwhile4}
\State \Return $\varepsilon, [u_0,u_1,\dots,u_d], [s_0,\dots,s_d]$
\end{algorithmic}
\end{algorithm}
The first steps of $\csostwo$ (Lines
\ref{line:sub2}--\ref{line:endwhile0}) are exactly the same as $\csosone$ to obtain $\varepsilon \in \Q_+$ such that $f - \varepsilon$ is positive on $\mathscr{C}$.
Then, instead of using root
isolation as in $\csosone$, $\csostwo$ relies on complex SDP (Line \ref{line:sdp}) and Cholesky's decomposition (Line \ref{line:chol}) to compute an approximate SOHS decomposition of the perturbed polynomial.
With $f-\varepsilon$, $\delta$, and $R$, the
$\texttt{sdp}$ function calls an SDP solver to compute a rational approximation
$\tilde{Q}$ of the Gram
matrix associated to $f-\varepsilon$ and a rational approximation
$\tilde{\lambda}$ of its smallest eigenvalue.
\if
Please unify the algorithm statements at your convenience, so that they are
similar (same kind of input/output, etc.).
Note that there is a difference between the Cholesky's decomposition here
which
only needs to be approximate (so with a numerical procedure), and the exact
$L D L^T$ performed in the $\texttt{RoundProject}$ algorithm (so with a symbolic procedure).
\fi
Its outputs are obtained by solving the following complex SDP:
\begin{align}\label{eq:posGram}
\lambda_{\min} = \displaystyle\max_{Q,\lambda} & \ \lambda \nonumber\\
\mbox{s.t.}& \ \trace (\Theta_k Q) = f_k - 1_{k=0} \varepsilon \,, k = -d,\dots,d \,, \\
& \ Q \succeq \lambda I \,, \lambda \geq 0 \,, \ Q \in \mathbb{C}^{(d+1) \times (d+1)} \nonumber\,,
\end{align}
where $\Theta_k$ is the elementary Toeplitz matrix with ones on the $k-$th
diagonal
and zeros elsewhere, $1_{k=0} = 1$ if $k=0$ and $0$ otherwise, $\trace(\cdot)$ stands for the usual matrix trace operator.
The equality constraints of SDP \eqref{eq:posGram} corresponds to the relation $f(z) - \varepsilon= v_d^{\star}(z) \cdot Q \cdot v_d (z) $.
This SDP program (corresponding to SDP (2.14) in \cite{dumi2017}) computes the Gram matrix associated to $f$ with the largest minimal eigenvalue.
The $\texttt{cholesky}$ function computes first an approximate Cholesky's decomposition $L L^T$ of $\tilde{Q}$ with precision $\delta_c$, and provides as output a list of polynomials $[s_0,\dots,s_d] \in \Q[i][z]$, $s_k$ is the inner product of the $(k+1)$-th row of $L$ by $v_d$.
One would expect to have $f-\varepsilon = \sum_{k=0}^d s_k^\star s_k$ after using exact SDP and Cholesky's decomposition.
Since the SDP solver is not exact, we have to consider the remainder $u = f - \varepsilon - \sum_{k=0}^d s_k^\star s_k$ and proceed exactly as in $\csosone$ to obtain an exact SOHS decomposition.
\subsection{Proof of Theorem \ref{thm:bit2}}
The lemma below prepares the bit complexity analysis of $\csostwo$.
\begin{lemma}\label{lm:deltaR}
Let $f\in \Hi(\Z)[z]$ be positive on $\mathscr{C}$
of degree $d$ and bitsize $\tau$. Assume that $Q$ is a positive definite
Gram matrix associated to $f$.
Then, there exist $\varepsilon\in \Q_+$ of bitsize $\widetilde O(d^3(d+\tau))$ such that
$f-\varepsilon$ is positive on $\mathscr{C}$,
$\delta$ of bitsize $\widetilde O(d^3(d+\tau))$ and $R$ of bitsize $O (\hht(d)+\tau)$ such that $Q-\varepsilon/(d+1) I$ is a Gram
matrix associated to $f-\varepsilon$ with $Q-\varepsilon/(d+1) I \succ
2^{-\delta}I$ and $\sqrt{\trace((Q-\varepsilon I)^2)}\leq R$.
\end{lemma}
\begin{proof}
By Lemma \ref{lm:epsN}, there is a positive integer
$N$ and $\varepsilon = 2^{-N} =\widetilde{O}(d^3(d+\tau))$ such that $ f- 3\varepsilon/ 2 > 0$ on $\mathscr{C}$.
Let $\delta:= \lceil N+1 + \log_2(d+1) \rceil =\widetilde{O}(d^3(d+\tau))$ so that $2^{-\delta} \leq \frac{\varepsilon}{2(d+1)}$.
One has $v_d^\star(z) v_d(z) = d+1$, thus $f(z)- \varepsilon = v_d^\star(z) (Q-\varepsilon/(d+1) I) v_d(z)$.
Since $f(z)- \varepsilon - 2^{-\delta} (d+1) > 0$, we obtain $v_d^\star(z) (Q-\varepsilon/(d+1) I - 2^{-\delta}I) v_d(z) > 0$.
Let $R:=\sqrt{(d+1)}f_0$.
Note that the equality constraint of SDP \eqref{eq:posGram} with $k=0$ reads $\trace (Q) = f_0 - \varepsilon \leq f_0$.
The maximal eigenvalue of $Q$ is less than $f_0$ and $\trace((Q-\varepsilon I)^2) \leq \trace(Q^2) \leq (d+1) f_0^2= R^2$.
\end{proof}
\if{
From this pair, we compute an approximate Cholesky's decomposition $L L^T$ of
$\tilde{G}$ with precision $\delta_c$. Again, when the precision
parameters $\delta, \delta_c, R$ go to the infinity together,
$u=(f-\varepsilon) - \sum_{j=0}^{d}s_j^\star s_j$ tends to the zero polynomial.
}\fi
The correctness and bit complexity proofs are very similar to the ones for the
$\texttt{intsos}$ algorithm in \cite[Proposition 10]{magron2021exact}, so we
only provide a sketch with the main ingredients.
\begin{proof}[Proof of correctness for $\csostwo$]
Since $f- \varepsilon$ is positive on $\mathscr{C}$, SDP
\eqref{eq:posGram} has always a strictly feasible solution for precision parameters ($\delta, R$) with bitsizes as in Lemma \ref{lm:deltaR} and
the $\texttt{sdp}$ function returns an approximate Gram matrix $\tilde{Q}$ of
$f-\varepsilon$ such that $\tilde{Q}\succeq 2^{-\delta}I$ and $\trace(Q^2)
\leq R^2$.
In parti\-cular, we obtain a rational approximation
$\tilde{\lambda}\geq 2^{-\delta}$ of the smallest eigenvalue of $\tilde{Q}$.
At Line \ref{line:sdp}, we compute an approximate Cholesky decomposition of $\tilde{Q}$
by using the $\texttt{cholesky}$ procedure; we obtain a rational nonsingular factor if there exists $\delta_c$ satisfying \eqref{eq:2deltac}.
Let $\delta_c$ be the smallest integer such that $2^{-\delta_c} <
\frac{2^{-\delta}}{d^2+d+(d-1)2^{-\delta}}$.
Since the
function $t \mapsto \frac{t}{d^2+d+(d-1)t}$ increases on $[0,+\infty)$ and
$\tilde{\lambda} \geq 2^{-\delta}$, \eqref{eq:2deltac} holds.
We now consider the polynomial $u=f-\varepsilon -
\sum_{k=0}^{d}s_k^\star s_k$. The while loop (Lines \ref{line:while4}--\ref{line:endwhile4}) terminates when $\varepsilon>
u_0 + 2\sum_{k=1}^{d}|u_k|$. This condition holds if $|u_k|\leq
\frac{\varepsilon}{2d+1}$, for all $k=0,\dots,d$.
As in the proof of \cite[Proposition 10]{magron2021exact}, we prove that this holds for large enough $\delta$ and $\delta_c$, with bitsizes $\widetilde{O}(d^3(d+\tau))$.
\if{
We point out that the last
condition holds when $\delta$ and $\delta_c$ are both large
enough. Indeed, we have
\begin{equation*}\label{eq:ukrk}
u_k = f_k - \varepsilon_k- \left( \sum_{j=0}^{d}s_j^\star s_j\right)_k, \
k=-d,\dots,d,
\end{equation*}
where
$\varepsilon_0 = \varepsilon$, $\varepsilon_k = 0$ for $k\neq 0$, and $(\sum_{j=0}^{d}s_j^\star s_j)_k$ is the coefficient of monomial $z^k$ in the involved polynomial.
\if
$u_k= \begin{cases}
f_0 - \varepsilon - (\sum_{j=0}^{d}s_j^\star s_j)_0 &\mbox{if } k = 0, \\
f_k - (\sum_{j=0}^{d}s_j^\star s_j)_k & \mbox{if } k \neq 0.
\end{cases}$
\fi
The positive definite matrix $\tilde{G}$ computed by the SDP solver is an
approximation of the Gram matrix associated to $f-\varepsilon$. With the
precision $\delta$, from \eqref{eq:uk}, we see that $\tilde{G}\succeq
2^{-\delta}I$ and
\begin{equation*}\label{eq:rkTheta}
\rvert f_k - \varepsilon_k- \trace(\Theta_k\tilde{G})\lvert=\rvert f_k - \varepsilon_k- \sum_{i+j=k}\tilde{G}_{ij}\lvert\leq
2^{-\delta}.
\end{equation*}
Furthermore, from \eqref{eq:H}, the approximate Cholesky decomposition
$LL^T$ of $\tilde{G}$
performed at precision $\delta$ satisfies $LL^T = \tilde{G}+H$ and
$$|H_{ij}|\leq\frac{(d+2)2^{-\delta_c}
\sqrt{|\tilde{G}_{ii}\tilde{G}_{jj}|}}{1-(d+2)2^{\delta_c}},$$
for all $i,j$ in $\{-d,\dots,d\}$. Applying the Cauchy-Schwarz inequality
for the trace function, we see that
$$\sum_{k=-d}^d|\tilde{G}_{kk}| = \trace(\tilde{G})\leq
\sqrt{\trace(\tilde{G}^2)}\sqrt{\trace(I)}\leq R\sqrt{d+1}.$$
So, for each $k$ in $\{-d,\dots,d\}$, we have
\begin{equation}\label{eq:Rd1}
\Big|\sum_{i+j=k}\sqrt{\tilde{G}_{ii}\tilde{G}_{jj}}\Big|\leq \sum_{i+j=k} \frac{\tilde{G}_{ii}+\tilde{G}_{jj}}{2}\leq \trace(\tilde{G})\leq R\sqrt{d+1}.
\end{equation}
Therefore, we have
$$\Big|\sum_{i+j=k}\tilde{G}_{ij} - \Big(\sum_{j=0}^{d}s_j^\star s_j\Big)_k\Big| =\Big| \sum_{i+j=k}\tilde{G}_{ij} - \sum_{i+j=k}\big(LL^T\big)_k\Big| = \Big| \sum_{i+j=k}H_{ij}\Big|;$$
it follows from \eqref{eq:H} and \eqref{eq:Rd1} that the last number is bounded by
$$\frac{(d+2)2^{-\delta_c}}{1-(d+2)2^{-\delta_c}}\sum_{i+j=k}\sqrt{|\tilde{G}_{ii}\tilde{G}_{jj}|}\leq \frac{R\sqrt{d+1}(d+2)2^{-\delta_c}}{1-(d+2)2^{-\delta_c}}.$$
Let us take the smallest $\delta$ such that $2^{-\delta}\leq \frac{\varepsilon}{2(2d+1)} = \frac{1}{(2d+1)2^{N+1}}$ as well as the smallest $\delta_c$ such that
$$\frac{R\sqrt{d+1}(d+2)2^{-\delta_c}}{1-(d+2)2^{-\delta_c}}\leq \frac{\varepsilon}{2(2d+1)},$$
i.e., $\delta=\lceil N+1+\log_2(2d+1)\rceil$ and $\delta_c=\lceil\log_2R+\log_2(d+2)+\log_2(2^{N+1}(2d+1)^{3/2}+1)\rceil$.
It implies from above inequalities that
\begin{align*}
|u_k| & \leq \Big|f_k - \varepsilon_k- \sum_{i+j=k}\tilde{G}_{ij}\Big| + \Big|\sum_{i+j=k}\tilde{G}_{ij}-\Big(\sum_{j=0}^{d}s_j^\star s_j\Big)_k\Big|\\
& \leq \frac{\varepsilon}{2(2d+1)} + \frac{\varepsilon}{2(2d+1)}=\frac{\varepsilon}{2d+1}.
\end{align*}
This guarantees that the second while loop terminates.
From Lemma~\ref{lm:deltaR} with $N= \widetilde{O}(d^3(d+\tau))$ and $R =\widetilde{O}(d^4(d+\tau))$, and $\delta,\delta_c$ defined as above, one has $\delta = \widetilde{O}(d^3(d+\tau))=\delta_c$. This number is also a bound of the bitsizes of the coefficients involved in the approximation $\sum_{j=0}^{d}s_j^\star s_j$ as well as the coefficients
of $u$. Thus, look at the constant term in \eqref{eq:fsos2}, namely $\varepsilon-u_0-2\sum_{k=1}^{d}|u_k|$, its maximal bitsize is bounded by $\widetilde{O}(d^3(d+\tau))$.
The proof is complete.
}\fi
\end{proof}
\vspace*{-0.3cm}
\begin{proof}[Bit complexity estimate for $\csostwo$] {We prove now that
Algorithm $\csostwo$ runs in $\widetilde{O}(d^{13}(d+\tau)^2)$ boolean
operations.}
Assume that $\varepsilon,\delta, R$ and $\delta_c$ are given as above so that, before terminating, Algorithm $\csostwo$ performs a single iteration in each while loop.
From above results, the bitsize of each $\varepsilon,\delta,\delta_c$ is upper bounded by $\widetilde{O}(d^3(d+\tau))$ and that of $R$ is $O(\hht(d)+\tau)$.
\if
Mimic/adapt the proof of Proposition 10 and Theorem 11 from
\cite{magron2021exact} to do the bit complexity analysis. As for the intsos
algorithm from \cite{magron2021exact},
\fi
To investigate the computational cost of the call to $\texttt{sdp}$ at
Line~\lineref{line:sdp}, let us note $n_\text{sdp} = d+1$ the size of $\tilde{Q}$ and $m_\text{sdp} = 2d+1$ the number of affine constraints of SDP \eqref{eq:posGram}.
We rely on the bit complexity analysis
of the ellipsoid method
\cite{porkolab1997complexity}.
Solving SDP~\eqref{eq:posGram} is performed in
${O}( n_\text{sdp}^4 \log_2 (2^\tau n_\text{sdp} \, R \, 2^\delta) )$ iterations of the
ellipsoid method, where each iteration requires
${O}(n_\text{sdp}^2(m_\text{sdp}+n_\text{sdp}) )$ arithmetic operations over
$\log_2 (2^\tau n_\text{sdp} \, R \, 2^\delta)$-bit numbers
(see, e.g., \cite{GroetschelLovaszSchrijver93,porkolab1997complexity}).
We obtain the following estimates:
$O(n_\text{sdp}^4 \log_2(2^\tau n_\text{sdp} \, R \, 2^\delta)) = \widetilde{O}(d^7(d+\tau))$,
$O(n_\text{sdp}^2(m_\text{sdp}+n_\text{sdp})) = O(d^{3})$, and $O(\log_2 (2^\tau n_\text{sdp} \, R \,
2^\delta)) = \widetilde{O}(d^3(d+\tau))$.
Therefore, the ellipsoid algorithm runs in boolean time
$\widetilde{O}(d^{13}(d+\tau)^2)$ to compute the approximate Gram matrix
$\tilde{Q}$.
Next, we compute the cost of calling $\texttt{cholesky}$ in Line \ref{line:chol}.
Note that Cholesky's decomposition is performed in $O(n_\text{sdp}^3)$ arithmetic
operations over $\delta_c$-bit numbers. Because of $\delta_c=\widetilde{O}(d^3(d+\tau))$ and $n_\text{sdp}=d+1$, $\texttt{cholesky}$ runs in boolean time $\widetilde{O}(d^{6}(d+\tau))$.
The other elementary arithmetic operations of Algorithm $\csostwo$ have a negligible cost w.r.t. to the $\texttt{sdp}$ procedure. Hence, the algorithm runs in boolean time $\widetilde{O}(d^{13}(d+\tau)^2)$.
\end{proof}
\section{Rounding-projection algorithm}\label{sec:csos3}
Here, we introduce Algorithm $\csosthree$ which is an adaptation of
the rounding-projection algorithm by Peyrl and Parrilo, stated in
\cite{peyrl2008} and analyzed in \cite[\S~3.4]{magron2021exact}, and investigate
its bit complexity.
The input of $\csosthree$ is a polynomial $f \in \Hi(\Z)[z]$ of degree
$d$ which is positive over $\mathscr{C}$.
The outputs consist of a list $[c_0,\dots,c_d] \subset \Q_+$ and a list of
polynomials $[s_0,\dots,s_d]$ in $\Q[i][z]$ that provide an SOHS decomposition of
$f$, namely $f = \sum_{k=0}^d c_k s_k^\star s_k$.
\begin{algorithm}
\caption{{$\csosthree$}}
\label{alg:PP}
\begin{algorithmic}[1]
%
\Require $f \in \Hi(\Z)[z]$ positive on $\mathscr{C}$ of degree $d$
\Ensure lists $[c_0,\dots, c_d] \subset \Q_+$ and $[s_0,\dots,s_d ] \subset \Q[i][z]$ providing an
SOHS decomposition of $f$ as follows: $$f = \sum_{k=0}^d c_k s_k^\star s_k$$
%
\State $\delta \gets 1$, $R \gets 1$, $\delta_c = 1$, $\hat{\delta} := 1$
\State boo := false
\While {not boo}\label{line:3Wh}
\State $(\tilde Q, \tilde \lambda) \gets \sdpfun{f}{\delta}{R}$
\If {$\tilde \lambda > 0$} boo := true
\Else $\ \delta := 2 \delta$, $R := 2 R$
\EndIf
\EndWhile\label{line:3endWh}
\State boo := false
\While {not boo}\label{line:while5}
\State $\hat Q \gets \roundfun{\tilde Q}{\hat \delta}$
\label{line:roundPP}
\For {$j \in \{0, \dots, d \}, k \in \{0,\dots,j \} $}\label{line:forQ}
\State $Q_{j,j-k} := \hat Q_{j,j-k} - \frac{1}{d-k+1} (\sum_{i=k}^d
\hat Q_{i,i-k} - f_k )$ \label{line:projPP}
\State $Q_{j-k,j} := Q_{j,j-k}^\star$
\EndFor\label{line:endforQ}
%
\State $[c_0,\dots, c_d; s_0,\dots,s_d] \gets \ldlfun{Q}$
\label{line:cholPP} \Comment{$f = \sum_{k=0}^d c_k s_k^\star s_k$}
\If {$c_0,\dots,c_d \in \Q_+, s_0,\dots,s_d \in \Q[i][z]$}
boo := true \label{line:LDLok}
\Else $\ \hat \delta \gets 2 \hat \delta$
\EndIf
\EndWhile \label{line:PPf}
\State \Return $[c_0,\dots,c_d]$, $[s_0,\dots,s_d]$
%
\end{algorithmic}
\end{algorithm}
As in $\csostwo$, the first while loop from Lines \ref{line:3Wh}--\ref{line:3endWh} provides an approximate Gram matrix $\tilde Q$ associated to $f$ and an approximation $\tilde \lambda$ of its smallest eigenvalue.
In Line~\ref{line:roundPP}, we round the matrix $\tilde Q$ up to precision $\hat\delta$ to obtain a matrix $\hat Q$, with Gaussian coefficient entries.
The for loop from Line \ref{line:forQ} to Line \ref{line:endforQ} is the projection step to ensure that the equality constraints of SDP \eqref{eq:posGram} hold exactly.
Then we compute the $LDL^T$ decomposition of $Q$.
The list $[c_0,\dots,c_d]$ is the list of coefficients of the diagonal matrix $D$ and each $s_k$ is the inner product of the $(k+1)$-th row of $L$ and the vector $v_d$ of all monomials up to degree $d$.
If all $c_k$'s are positive rationals and all polynomials $s_k$' have Gaussian coefficients, then the second while loop ends, otherwise we increase the precision $\hat \delta$.
\if
Mimic/adapt Section 3.4 in \cite{magron2021exact} to get the bit complexity estimate.
\fi
As emphasized in \cite[\S~3.4]{magron2021exact}, it turns out that $\csostwo$ and $\csosthree$ have the same bit complexity.
We omit any technicalities as the proof is almost the same as \cite[Theorem~12]{magron2021exact}.
\if{
\begin{proposition}\label{prop:deltaR} For $f \in \Hi(\Z)[z]$ positive on $\mathscr{C}$, with degree $d$ and bitsize $\tau$, there exist $\delta$, $\hat\delta$ upper bounded by $\widetilde{O}(d^3(d+\tau))$, and $ R$ upper bounded by $O(\hht(d)+\tau)$ such that Algorithm
$\csosthree$ outputs an SOHS decomposition of $f$.
\end{proposition}
\begin{proof} Suppose that the matrix $Q \succ 0$ obtained after the second while loop (Lines \ref{line:while5}--\ref{line:PPf}) which is associated to $f$ with the smallest eigenvalue $\lambda$. Let $N\in \N$ be the smallest integer satisfying $2^{-N}\leq \lambda$. From Lemma~\ref{lm:deltaR}, the maximal bitsize of $N$ is upper bounded by $\widetilde{O}(d^3(d+\tau))$. By Proposition 8 in \cite{peyrl2008}, Algorithm $\csosthree$ terminates and outputs such a matrix $Q$ together with an SOHS decomposition of $f$ if $2^{-\hat\delta}+2^{-\delta_E}\leq 2^{-N}$, where $\delta_E$ stands for the Euclidean distance between $Q$ and $\hat Q$, yielding $$\sqrt{\sum_{i,j}(Q_{ij}-\hat Q_{ij})^2} = 2^{-\delta_E}.$$
For all index pair $i,j\in \{-d,\dots,d\}$, one has $|\hat Q_{ij}- \tilde Q_{ij}|\leq 2^{-\hat\delta}$.
As in the proof of part $\rm a)$ in Theorem~\ref{thm:bit2}, at the SDP precision $\delta$, one has $\tilde Q \succeq 2^{-\delta}I$ and
$$\big|f_k- \sum_{i+j=k}\tilde Q_{ij}\big| \leq 2^{-\delta}.$$
We denote $e_{ij}:=\big( \sum_{i'+j'=i+j}\hat Q_{i'j'}\big) -f_{i+j}= \sum_{i'+j'=i+j}\big( \hat Q_{i'j'}-Q_{i'j'}\big)$, for $i,j\in \{-d,\dots,d\}$. The cardinal of the set $\{(i',j'):i'+j'=i+j\}$ is $d+1-(i+j)$. Hence, we have the following estimate:
\begin{align*}
|e_{ij}| & \leq \sum_{i'+j'=i+j}\big|\hat Q_{i'j'}-\tilde Q_{i'j'}\big|+ \big|\sum_{i'+j'=i+j}\tilde Q_{i'j'}-f_{i+j}\big| \\
& \leq (d+1-i-j)2^{-\hat\delta} + 2^{-\delta} \leq (d+1-i-j)(2^{-\hat\delta} + 2^{-\delta}).
\end{align*}
It follows that
$$2^{-\delta_E} = \sum_{i,j}\frac{e_{ij}}{d+1-i-j}\leq 2(d+1)^d(2^{-\hat\delta} + 2^{-\delta}).$$
To ensure that $2^{-\hat\delta}+2^{-\delta_E}\leq 2^{-N}$, it is sufficient to have
$$2^{-\hat\delta} +2(d+1)^d(2^{-\hat\delta} + 2^{-\delta})\leq 2^{-N}.$$
Since $\hht(N)=\widetilde{O}(d^3(d+\tau))$, the last inequality is obtained if $\delta$ and $\hat\delta$ are upper bounded by $\widetilde{O}(d^2(d+\tau))$.
Clearly, the $\texttt{sdp}$ function is successful if $R$ is upper bounded by $O(d^4(d+\tau))$ as Lemma \ref{lm:deltaR}.
\end{proof}
}\fi
\vspace*{-0.3cm}
\begin{proof}[Bit complexity estimate for $\csosthree$]
For $f \in \Hi(\Z)[z]$ positive over $\mathscr{C}$ with degree $d$ and maximal
bitsize $\tau$, there exist $\delta$, $\hat\delta$ with bitsizes upper bounded
by $\widetilde{O}(d^3(d+\tau))$, and $ R$ with bitsize upper bounded by
$O(\hht(d)+\tau)$ such that Algorithm $\csosthree$ outputs an SOHS
decomposition of $f$.
The bitsize of the output coefficients is
upper bounded by the output bitsize of the $LDL^T$ decomposition of the matrix
$Q$, that is $O(\hat\delta (d+1)^3) =\widetilde{O}(d^6(d+\tau))$. The running
time is estimated as for $\csostwo$.
\end{proof}
\section{Practical experiments}
This section is dedicated to experimental results obtained by running our three certification algorithms, $\csosone$, $\csostwo$ and $\csosthree$, stated in Section \ref{sec:csos1}, \ref{sec:csos2} and \ref{sec:csos3} respectively.
First, we compare their performance to certify that trigonometric polynomials with Gaussian coefficients are positive on the unit circle $\mathscr{C}$.
Next, we describe how to extend our third algorithm $\csosthree$ to design a finite impulse response (FIR) filter in a certified fashion.
Our code is implemented in {\sc Julia}, freely available online \footnote{\url{https://homepages.laas.fr/vmagron/files/csos.zip}}, and the results are obtained on an Intel Xeon 6244 CPU (3.6GHz) with 1.5 TB of RAM.
In $\csosone$ and $\csostwo$, we compute $\varepsilon$ such
that $f-\varepsilon$ is positive on $\mathscr{C}$ in Lines \ref{line:while0}--\ref{line:endwhile0} by using {\sc msolve} \cite{msolve} within the Julia library $\mathtt{GroebnerBasis.jl}$.
The corresponding running time is denoted by
$t_{\varepsilon}$.
We denote by $t_{u}$ the running time spent to compute the remainder polynomial $u$ and to perform the comparison involving its coefficients and $\varepsilon$.
In $\csosone$, we compute approximate roots of $f-\varepsilon$ with the arbitrary-precision library $\mathtt{PolynomialRoots.jl}$ \cite{skowron2012general}.
In $\csostwo$ and $\csosthree$, we model SDP \eqref{eq:posGram} via {\sc JuMP} \cite{dunning2017jump} and solve it with Mosek \cite{andersen2000mosek}.
Exact arithmetic is performed with the {\sc Calcium} library available in $\mathtt{Nemo.jl}$.
\subsection{Positivity verification}
\if The first family contains polynomials having real coefficients $f_d(z)=1+2d+\sum_{k=1}^{d}( z^k+\frac{1}{z^k}).$
Because of
$z^k+z^{-k}=2 \cos(k\varphi) \geq -2$ for $z \in \mathscr{C}$, $f_d$ is
positive on $\mathscr{C}$.
\fi
We consider a family of trigonometric polynomials having Gaussian integer coefficients $f_d = 10d + \sum_{k=1}^{d}((1-i)z^{-k}+(1+i)z^k)$.
For each $d \in \{50,100,150,200,250\}$, we prove that $f_d$ is positive on $\mathscr{C}$ by computing via $\csosone$, $\csostwo$ and $\csosthree$ exact SOHS decompositions.
Note that each such $f_d$ is positive on $\mathscr{C}$ since $ z^{-k}+z^k \geq -2$.
For $\csosone$, we use a precision $\delta = 64$ (bits) to isolate complex roots.
As a side note, we were not able to use arbitrary-precision SDP solvers (e.g., SDPA-GMP) within $\csostwo$ and $\csosthree$, because {\sc JuMP} only allows us to rely on double floating-point arithmetic at the moment.
The running times (in seconds) of the 3 algorithms are reported in Table \ref{tbl:table}.
As expected from the theoretical bit complexity results from Theorem \ref{thm:bit1} and Theorem \ref{thm:bit2}, Algorithm $\csosone$ performs better than $\csostwo$ and $\csosthree$.
The reason why $\csostwo$ is faster than $\csosthree$ is due to the fact that the latter algorithm requires to perform an exact Cholesky's factorization.
Even though $\csosone$ happens to be the best choice to verify the positivity of polynomials with known coefficients, the use of an SDP solver is mandatory to optimize over positive polynomials with unknown coefficients, as demonstrated in the next subsection.
\vspace*{-0.2cm}
\begin{table}[ht!]
\begin{tabular}{c|ccc|ccc|c|}
\cline{2-8}
& \multicolumn{3}{c|}{$\csosone$} & \multicolumn{3}{c|}{$\csostwo$} & $\csosthree$ \\ \hline
\multicolumn{1}{|c|}{$d$} & \multicolumn{1}{c|}{$t_{\varepsilon}$} & \multicolumn{1}{c|}{$t_{u}$} & total & \multicolumn{1}{c|}{$t_{\varepsilon}$} & \multicolumn{1}{c|}{$t_{u}$} & total & total \\ \hline
\multicolumn{1}{|c|}{50} & \multicolumn{1}{c|}{0.2} & \multicolumn{1}{c|}{0.3} & 0.6 & \multicolumn{1}{c|}{0.2} & \multicolumn{1}{c|}{6.6} & 6.8 & 7.7 \\ \hline
\multicolumn{1}{|c|}{100} & \multicolumn{1}{c|}{1.6} & \multicolumn{1}{c|}{2.9} & 4.5 & \multicolumn{1}{c|}{1.6} & \multicolumn{1}{c|}{128} & 130 & 184 \\ \hline
\multicolumn{1}{|c|}{150} & \multicolumn{1}{c|}{5.2} & \multicolumn{1}{c|}{13} & 19 & \multicolumn{1}{c|}{5.2} & \multicolumn{1}{c|}{830} & 838 & 1460 \\ \hline
\multicolumn{1}{|c|}{200} & \multicolumn{1}{c|}{24} & \multicolumn{1}{c|}{26} & 51 & \multicolumn{1}{c|}{24} & \multicolumn{1}{c|}{3460} & 3485 & 7214 \\ \hline
\multicolumn{1}{|c|}{250} & \multicolumn{1}{c|}{64} & \multicolumn{1}{c|}{55} & 120 & \multicolumn{1}{c|}{64} & \multicolumn{1}{c|}{10553} & 10622 & 24852 \\ \hline
\end{tabular}
\caption{Performance of Algorithms $\csosone$, $\csostwo$, and $\csosthree$}
\label{tbl:table}
\end{table}
\vspace*{-0.6cm}
\subsection{Design of a certified linear-phase FIR filter}\label{subsec:filter}
This section is devoted to the design of a linear-phase finite impulse response (FIR) filter.
This boils down to solving an energy minimization problem.
To obtain a certified filter, we first solve a semidefinite optimization problem (corresponding to SDP (5.12) from \cite{dumi2017}) and transform the numerical output into an exact certificate via a projection procedure similar to the one used in $\csosthree$.
Let $H(z)=\sum_{k=-d}^{d} h_kz^{-k}$ be an FIR filter of order $d$, with real coefficients.
Let $h = [h_0,\dots,h_d]$ be the coefficient vector of $H$.
Since we work on the unit circle, we have $z = \exp(i \omega)$, for $\omega \in \R$, and we abuse notation by writing $H(\omega)$ instead of $H(z)$.
The passband and stopband are respectively $[0,\omega_p]$ and $[\omega_s,\pi]$, where $\omega_p, \omega_s$ are given. The stopband energy of the FIR filter is
$$E_s = \frac{1}{\pi}\int_{\omega_s}^{\pi}|h(\omega)|^2d\omega.$$
To design such a linear-phase filter, we minimize the stopband energy under modulus constraints involving two parameters $\gamma_p,\gamma_s$:
\begin{align*}
\min\limits_{ H\in \Hi[z]} & \ E_s \\
\text{s.t.} \ \ \ & \ |H(\omega)-1|\leq \gamma_p, \ \forall \omega\in[0,\omega_p],\\
& \ | H(\omega)|\leq \gamma_s, \qquad \forall \omega\in[\omega_s,\pi] \,.
\end{align*}
As shown in \cite[\S~5.1.1]{dumi2017}, the above problem can be reformulated as:
\begin{equation}\label{eq:sdp}
\begin{array}{cl}
\min\limits_{h,\, Q_1,\dots,\, Q_7} & \ h^T \tilde{C} h \\
& (1+\gamma_p) 1_{k=0} - {h}_k = L_k(Q1) \,, \\
& {h}_k - (1-\gamma_p)1_{k=0} = L_{k,0,\omega_p}(Q_2,Q_3) \,,\\
\text{s.t.} & \gamma_s 1_{k=0} - {h}_k = L_{k,\omega_s,\pi}(Q_4,Q_5) \,,\\
& \gamma_s 1_{k=0} + \, {h}_k = L_{k,0,\omega_p}(Q_6,Q_7) \,, \quad k = 0,\dots,d \,, \\
& Q_1 \succeq 0,\dots,Q_7 \succeq 0, \\
\end{array}
\end{equation}
where $Q_1,Q_2,Q_4,Q_6$ are real $(d+1)\times(d+1)$-matrices, $Q_3,Q_5,Q_7$ are real $(d-1)\times(d-1)$-matrices; $L_k(A):=\trace (\Theta_k A)$ and
\begin{equation}\label{eq:Lk}
\begin{array}{ll}
L_{k,\alpha,\beta}(A,B): = & \trace (\Theta_k A) + \trace \Big( \big(\frac{a+b}{2} (\Phi_{k-1} + \Phi_{k+1})
\\
& -(ab+\frac{1}{2}) \Phi_k - \frac{1}{4}(\Phi_{k-2} + \Phi_{k+2})\big)B\Big),
\end{array}
\end{equation}
with $a = \cos \alpha, b=\cos \beta$; $\Theta_k\in\R^{(d+1)\times(d+1)}, \Phi_k\in\R^{(d-1)\times(d-1)}$ are the elementary Toeplitz matrices with ones on the $k$-th diagonal and zeros elsewhere (they are zero matrices whenever $k$ is out of range); $C={\rm Toep}(c_0,\dots,c_d)$ is the Toeplitz matrix with the first row $(c_0,\dots,c_d)$, where
$$c_k= \begin{cases}
1-\frac{\omega_s}{\pi}, & \text{ if } \ k=0,\\
-\frac{\sin k\omega_s}{k\pi}, & \text{ if } \ k > 0,
\end{cases}
$$
$$\tilde{C} = P^TCP\succeq 0, \
P=\begin{bmatrix}
0 & J_d \\
1 & 0 \\
0 & I_d
\end{bmatrix} \,,$$
where $J_d$ and $I_d$ denote the counter identity and identity matrices of size $d$, respectively.
By contrast with the unconstrained case (Algorithm $\csosthree$), this program involves 7 Gram real matrix
variables and $d+1$ real variables $h_0, \dots,h_d$, which are the coefficients of the polynomial corresponding to the filter.
After solving \eqref{eq:sdp}, we obtain numerical values for the coefficients of ${h}$ and the entries of $Q_1,\dots,Q_7$, which are further rounded to $\hat{h}$ and $\hat Q_1,\dots, \hat Q_7$, respectively.
To project $\hat Q_1$ to a matrix $Q_1$ satisfying exactly the first set of equality constraints in SDP \eqref{eq:sdp}, we apply the formula in Line \ref{line:projPP} of Algorithm $\csosthree$ after replacing $f_k$ by $p_k:=(1+\gamma_p)1_{k=0} - \hat{h}_k$.
Similarly, we obtain matrices $Q_2$ and $Q_3 := \hat{Q_3}$ satisfying exactly the second set of equality constraints in SDP \eqref{eq:sdp}, after substitution by
\if
Solving \eqref{eq:sdp} yields numerical approximations $\tilde {h}$, $\tilde Q_1,\dots,\tilde Q_7$, which are further rounded to $\hat{h}$, $\hat Q_1,\dots, \hat Q_7$, respectively.
To project $\hat Q_1$ to a matrix $Q_1$ satisfying exactly the first set of equality constraints in \eqref{eq:sdp}, we apply the formula in Line \ref{line:projPP} of Algorithm $\csosthree$ after replacing $f_k$ by $p_k:=(1+\gamma_p)1_{k=0} - \hat{h}_k$.
Similarly, we obtain matrices $Q_2$ and $Q_3 := \hat{Q_3}$ satisfying exactly the second set of equality constraints in SDP \eqref{eq:sdp}, after substitution by
\fi
\begin{equation*}
\begin{array}{ll}
& \hat{h}_k - (1-\gamma_p)1_{k=0} - \trace \Big( \big(\frac{a+b}{2} (\Phi_{k-1} + \Phi_{k+1})
-(ab+\frac{1}{2}) \Phi_k \\
& - \frac{1}{4}(\Phi_{k-2} + \Phi_{k+2})\big){Q}_3\Big),
\end{array}
\end{equation*}
Eventually, similar projection steps provide the remaining matrices $Q_4, \dots, Q_7$ so that all equality constraints in \eqref{eq:sdp} hold exactly.
As in \cite[Example 5.1]{dumi2017}, we design a filter with parameters $d=25$, $\omega_p=\pi/5$, $\omega_s=\pi/4$, $\gamma_p=1/10$ (which corresponds
to a passband ripple of 1.74 dB), and $\gamma_s=0.0158$ (a stopband attenuation of 36 dB).
We first obtain a numerical lower bound of the stopband energy $E'_s = 4.461501\times~10^{-5}$.
However, this bound happens to be inexact as the Gram matrices obtained after the projection step are not positive semidefinite anymore.
To overcome this certification issue, we replace the last constraint in \eqref{eq:sdp} by $Q_7 - 10^{-9}I_{24} \succeq 0$.
Doing so, we can successfully project the approximate Gram matrices into exact ones with positive eigenvalues, and obtain a certified exact lower bound of $E_s = 4.461503\times 10^{-5}$ in $0.74$ seconds.
\input{cunivsos.bbl}
\end{document}
|
{'timestamp': '2022-02-15T02:38:34', 'yymm': '2202', 'arxiv_id': '2202.06544', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06544'}
|
arxiv
|
\section{Introduction}\label{sec1}
Graph neural network (GNN) has aroused great interest in academia due to its capability that is able to handle graph-structure data and fills the vacancy in conventional deep learning field. GNN has become a significant branch of deep learning and been widely used in various fields, e.g., molecules \cite{duvenaud2015convolutional}, biological \cite{fout2017protein}, and recommend systems \cite{ying2018graph}. Many well-developed deep learning methods, for example, convolutional neural networks (CNNs) \cite{krizhevsky2012imagenet,redmon2016you} and recurrent neural networks (RNNs) \cite{ma2019ts,kenton2019bert}, which are designed to process the data with regular structure, cannot be applied directly on graph-structure data. However, the most common form of data, graph-structure data, has incalculable value to our modern society. And the demand of discovering such value has contributed to the vigorous development of GNNs. \par
GNNs can be divided into five main types \cite{zhou2020graph}. In reference \cite{zeng2021rlc}, the authors proposed an improved deep architecture for spatial-based GNNs with an application to fraud detection. The proposed method extends Camouflage-Resistant GNN (CARE-GNN) \cite{dou2020enhancing} to deep model and can divide problem into sub-problems and correct mistakes layer by layer, which forms an incremental learning mechanism. They combine layered-structure \cite{bandinelli2010learning} and residual connection \cite{he2016deep} to achieve above functions. Therefore it is named as Residual Layered CARE-GNN (RLC-GNN). In the previous work, for a given center node in a certain layer, the authors select similar 1-hop neighboring nodes by using similarity measure mechanism and aggregate the neighbors' information to the center node. In the next layer, the authors utilize the updated node representation to select a new set of neighbors. The similarity between selected nodes and the center node is higher than previous layers', which presents the self-correcting mechanism, and therefore each layer is able to focus on solving part of the problem. Since fraud detection task is essentially a node classification task and similar entities always tend to be close (i.e., nodes are directly connected by edges), they only extract information of neighboring nodes within 1-hop. \par
However, we observe that decline of the overall loss of each layer slows down starting from the fourth layer. We argue that this is because only 1-hop neighboring nodes are included during neighborhood selection and the model has made maximum use of existing information. The model cannot learn more knowledge unless new information is introduced. Besides, in the previous work, they perform similarity measure by computing the $l_1$-distance of class scores between two nodes, which has great limitations on the accuracy of similarity measure. And as we have mentioned above, RLC-GNN extends a single-layer model to multi-layer model to benefit from the self-correction mechanism and powerful representation ability of deep model. But the model also suffers from training difficulty of deep models. \par
In this paper, we aim to provide effective approaches to address the mentioned issues, which combines: 1) We improve performance of RLC-GNN by changing the way of similarity measure from computing $l_1$-distance to cosine distance, and we give empirical analyses of why it works; 2) For conventional deep learning methods, normalization techniques are widely used to tackle training difficulty faced by deep models. Some works \cite{li2021training, chen2020learning, zhou2020effective} has applied these useful techniques or their variants on GNNs to help training process. Inspired by these works, we propose partial neighborhood normalization methods which normalize center nodes from batch-wise or node-wise. 3) We propose an intermediate information supplement strategy to solve the problem that the use of information reaches limitation. We conduct experiments on Yelp dataset and Amazon dataset and our approaches lead to considerable performance improvements. \par
\section{Related Work}\label{sec2}
All variants of GNNs are composed of two main components which are aggregator and updater. Aggregator performs propagation operation which is to aggregate information of neighboring nodes. And updater performs transformation operation which is mainly to perform non-linear transformation to extract higher-order features. For instance, the two processes for widely used Graph Convolutional Network (GCN) \cite{Kipf:2016tc} which is a spectral-based GNN can be described as:
\begin{align}
\rm{Aggregator: } \, N &= {\tilde D}^{ - \frac{1}{2}} \tilde A{\tilde D}^{ - \frac{1}{2}}{H^{(l - 1)}} \nonumber \\
\rm{Updater: } \, H^{(l)} &= \sigma (N{W^{(l)}}) \label{eq1}
\end{align}
where ${\tilde A = A + {I_N}}$ is the adjacency matrix of an undirected graph ${\cal G}$ with added self-connections; $I_N$ is identity matrix; ${\tilde D_{ii}} = {\Sigma _j}{\tilde A_{ij}}$ and ${W^{(l)}}$ are layer-specific trainable weight matrices; ${H^{(l - 1)}}$ and ${H^{(l)}}$ denote the input of current layer and output respectively; $\sigma (\cdot)$ denotes an activation function. One other typical method is GraphSAGE \cite{hamilton2017inductive} which is a spatial-based GNN and its process can be formulated as:
\begin{align}
{\rm{Aggregator: }} \, h_{{N_u}}^{(l)} &= AGGREGAT{E^{(l)}}(\{ h_v^{(l - 1)}:\forall v \in {N_u}\} ) \nonumber \\
{\rm{Updater: }} \, h_u^{(l)} &= \sigma ({W^{(l)}}[h_u^{(l - 1)}\parallel h_{{N_u}}^{(l)}]) \label{eq2}
\end{align}
where $AGGREGAT{E^{(l)}}$ is aggregation mechanism that generates features $h_{{N_u}}^{(l)}$ by aggregating features of a set of neighboring nodes ${N_u}$ to center node $v$ at current layer; $h_v^{(l - 1)}$ and $h_u^{(l - 1)}$ denotes input feature at current layer of a neighboring node and the center node respectively; $h_u^{(l)}$ denotes output feature of the center node at current layer; $[\cdot \parallel \cdot]$ is vector concatenating operation. The spatial-based GNNs, represented by GraphSAGE, have great flexibility in the design of aggregation mechanism, which will greatly benefit the performance of downstream tasks. Therefore, RLC-GNN are designed with spatial-based architecture. In this work, we further improve the performance of RLC-GNN by optimizing neighboring nodes selector which is part of aggregator. \par
Recent work \cite{liu2020towards} reveals that although over-smoothing issue contributes to the performance deterioration to deep GNNs, the entanglement of propagation and transformation is the key factor. And Deep Adaptive Graph Neural Network (DAGNN) is proposed to adaptively incorporate information from different size of receptive fields on graphs by decoupling propagation and transformation and applying attention mechanism. And this inspires us to propose the intermediate information supplement to solve the insufficient information problem which blocks the learning process of RLC-GNN. \par
Normalization techniques are critical methods that are widely used in conventional deep learning field to overcome training difficulty of deep neural networks, e.g., Batch Normalization (BatchNorm) \cite{ioffe2015batch} and Layer Normalization (LayerNorm) \cite{ba2016layer}. BatchNorm first computes batch statistics including mean and variance along batch dimension and then normalizes each scalar feature independently. LayerNorm is a variant of BatchNorm. And the difference is that LayerNorm computes statistical information along channel dimension. Some works \cite{chen2020learning, zhou2020effective} introduce existing normalization methods or propose novel ones to train deep GNNs. Work \cite{chen2020learning} investigates existing graph normalization methods and formulates them into four levels: node-wise, adjacency-wise, graph-wise, and batch-wise. Inspired by this work, we combine our similarity measure mechanism and the idea of adjacency-wise normalization with two methods, batch-wise normalization and node-wise. And we propose partial neighborhood normalization on batch-wise and node-wise. \par
Performing fraud detection on graph-structure data is essentially solving a node classification problem. However, fraud detection task has some peculiarities. First, there are far less fraudsters in samples, which makes it hard for models to learn features of fraudsters drown in lots of benign samples. Additionally, smart fraudsters always evade detectors by actively camouflaging their features (e.g., replacing keywords with special symbols but semantics remaining the same) \cite{dou2020enhancing}, which makes it even more difficult for models to recognize features of fraudsters. CARE-GNN performs label-aware similarity measure to confront camouflages. More precisely, it computes $l_1$-distance between a given center nodes and neighboring nodes. However, due to the complex behavior of fraudsters, $l_1$-distance is not accurate enough to describe the characteristics of fraudsters, which limits the recognition ability of models. We propose to use cosine-distance instead of $l_1$-distance to perform similarity measure between a pair of nodes. \par
\section{Methodology}\label{sec3}
In this section, we introduce three methods to solve three issues of RLC-GNN, respectively. Based on the 6-layers RLC-GNN, we improve the original model for fraud detection task. Given a heterogeneous graph ${\cal G} = \{ \mathcal{V}, \mathcal{X},\{ {\mathcal{E}_r}\} \vert_{r = 1}^R\}$, $\mathcal{V}$ is the set of nodes' indices. Each node $v_i$ is represented by a $d$-dimension feature vector ${x_i} \in {\mathbb{R}^d}$ in set $\mathcal{X}$ . Each edge $e_{ij}^r \in {\mathcal{E}_r}$ indicates node $v_i$ and $v_j$ are connected by an edge under relation $r \in \{ 1,2, \cdots ,R\}$.
\subsection{Similarity Measure via Cosine Distance}\label{subsec3-1}
We apply cosine distance instead of $l_1$-distance to perform similarity measure between two given nodes. And we give intuitive analysis for this change. Yelp dataset used in this paper consists of reviews submitted by users on Yelp websites. Given a certain review under a product, the features include its ranking among all reviews under the product, tendency (very high rating or low), the time when it is submitted, uniqueness (whether it is the only review given by the user under the product), length, ratio of competent vocabularies to objective vocabularies, etc. Fraud detection is a semi-supervised node classification task, which means that we let our model to learn the representation of fraudulent samples (i.e., what fraudulent samples themselves look like and what types of topologies they will form with their neighbors) and then to find similar samples based on learned patterns. Intuitively, each person has his own style, even the fraudsters. And the reviews submitted by the same fraudster should have similar features. A fraudster may deliberately change his language style of his reviews, which makes model unable to find common semantic features. But except these local differences, the overall external characteristics (i.e., subconscious behaviors) of fraudsters stay the same, which results in their reviews having similar topological structure on the built graphs. We need to evaluate the overall indication of samples rather than numerical difference between feature vectors. The model will benefit from more comprehensive consideration of features and capturing of similar structure, and a fully connected layer with $tanh$ activation function are applied to extract topological structure features in this work. \par
In mathematics, cosine similarity measures the difference between two vectors by computing the cosine value of the angle between the two vectors. The closer the angle is to zero (i.e., cosine value is close to one), the closer the two vectors are. Cosine distance is usually used to analyze user behavior in practical applications, e.g., recommend systems. In this work, a review or a user is represented by an embedding vector. And we need to measure the similarity between samples from the perspective of user behavior. Thus, we optimize the origin method to use cosine distance instead. For a center node $u$ and any one of its neighboring node $v$' at $l$-th layer, the cosine similarity is formulated as:
\begin{equation}
S^{(l)}{(u,v^{'})} = \frac{\sigma (ml{p^{(l)}}(h_u^{(l - 1)})) \cdot \sigma (ml{p^{(l)}}(h_{v'}^{(l - 1)}))}{{{\left\| {\sigma (ml{p^{(l)}}(h_u^{(l - 1)}))} \right\|}_2}{{\left\| {\sigma (ml{p^{(l)}}(h_{{v'}}^{(l - 1)}))} \right\|}_2}} \label{cosd}
\end{equation}
where $h_u^{(l - 1)}$ and $h_{v'}^{(l - 1)}$ denote the input feature vectors of a center node and a neighboring node respectively. And then we can define the cosine distance between node $v$ and $u$ as:
\begin{equation}
{\mathcal{D}^{(l)}}(u,{v'}) = 1 - {S^{(l)}}(u,{v'}) \label{cossim}
\end{equation}
Each layer has its own similarity measure module.
\subsection{Partial Neighborhood Normalization}\label{subsec3-2}
Original normalization techniques on graph compute statistics without any filtering mechanism. For instance, batch normalization computes mean and variance among batch dimension after the aggregation of all neighbors and node normalization among node dimension. Of particular note is that fraud detection is a node classification task with the problem of severe unbalance in quantitative terms. With that in mind, we consider combine the existing similarity measure and the idea of adjacency normalization with BatchNorm and NodeNorm to avoid feature distortion which is caused by adding too much benign samples' information when performing normalization on fraudsters' features. Because BatchNorm computes along batch dimension, more noise will be introduced, especially on dense graph. The distortion will be amplified, and model will suffer performance deterioration instead of benefitting from applying batch-wise normalization. \par
By combining similarity measure mechanism with normalization, for fraudulent samples, a percentage of dissimilar samples will be discarded before performing normalization, which alleviates the distortion. For a center node $u$ and all its neighboring nodes $N(u)$ at $l$-th layer, we define the node-wise partial neighborhood normalization on heterogenous graph as follows:
\begin{align}
{\mu _u} &= \frac{1}{{d \cdot \vert \mathbb{N}(u)\vert }}\sum\limits_{i = 1}^d {\sum\limits_{r = 1}^R {p_r^{(l)}\sum\limits_{v \in \mathbb{N}(u)} {h_{v,r,i}^{(l)}} } } \nonumber \\
\sigma _u^2 &= \frac{1}{{d \cdot \vert \mathbb{N}(u)\vert }}\sum\limits_{i = 1}^d {[{(\sum\limits_{r = 1}^R {p_r^{(l)}\sum\limits_{v \in \mathbb{N}(u)} {h_{v,r,i}^{(l)}) - {\mu _u}} } ]^2}} \nonumber \\
\hat h_u^{(l)} &= \frac{{h_u^{(l)} - broadcast({\mu _u})}}{{\sqrt {\sigma _u^2 + \varepsilon } }} \label{nodewise}
\end{align}
where ${\mu _u}$ and ${\sigma _u}$ are the mean and variance computed over features of center node $u$ itself; $h_{v,r}^{(l)} = [h_{v,r,1}^{(l)}, \cdots ,h_{v,r,d}^{(l)}]$ is the $d$-dimension node feature vector of a neighboring node $v$ at $l$-th layer; $p_r^{(l)}$ is the threshold for relation $r$; $\mathbb{N}(u) \subseteq N(u)$ denotes neighboring nodes being selected after similarity measure and $\vert \mathbb{N}(u)\vert $ is the number of neighbors; $\hat h_u^{(l)}$ is the normalized feature of center node; $broadcast({\mu _u})$ is broadcast operation which repeats the mean value to form a vector with the same shape as $h_u^{(l)}$. Similarly, the definition of batch-wise partial neighborhood normalization is shown in Eq.\ref{batchwise}:
\begin{align}
{\mu _{B,i}} &= \frac{1}{m}\sum\limits_{j = 1}^m {\frac{1}{{\vert \mathbb{N}({u_j})\vert }}\sum\limits_{r = 1}^R {p_r^{(l)}\sum\limits_{v \in \mathbb{N}({u_j})} {h_{v,r,i,{u_j}}^{(l)}} } } \nonumber \\
\sigma _{B,i}^2 &= \frac{1}{m}\sum\limits_{j = 1}^m {\frac{1}{{\vert \mathbb{N}({u_j})\vert }}[{(\sum\limits_{r = 1}^R {p_r^{(l)}\sum\limits_{v \in \mathbb{N}({u_j})} {h_{v,r,i,{u_j}}^{(l)}) - {\mu _{B,i}}} } ]^2}} \nonumber \\
\hat h_{{u_j},i}^{(l)} &= \frac{{h_{{u_j},i}^{(l)} - {\mu _{B,i}}}}{{\sqrt {\sigma _{B,i}^2 + \varepsilon } }} \label{batchwise}
\end{align}
where ${\mu _{B,i}}$ and ${\sigma _{B,i}}$ are the mean and variance of the $i$-th feature computed over batch dimension; $h_{v,r,i,{u_j}}^{(l)}$ denotes the neighboring node's $i$-th feature of the $j$-th center node in the batch under relation $r$; $m$ is the size of batch; $\hat h_{{u_j},i}^{(l)}$ is the normalized $i$-th feature of the $j$-th center node. It can be noted that, compared with conventional BatchNorm, there is no scaling and shifting operations.
\subsection{Intermediate Information Supplement}\label{subsec3-3}
Given a center node painted red, we show the processes in a layer with 6-layers RLC-GNN in Figure 2\ref{sub@subfig2-1}. One color denotes that a neighboring node is connected to the center node under a relationship corresponding to the color. The heterogeneous graph is converted to three homogeneous sub-graphs. Then we compute the $l_1$-distances between center node and all neighbors under each relation respectively and sort the distances in ascending order. All distances will be fed through a reinforcement learning module to update the thresholds (i.e., preservation ratio of nodes under each relation. See \cite{dou2020enhancing} for more details). And then the nodes which are not similar enough will be discarded. Now, all nodes to be used for aggregation under each relation is determined. \par
The training loss of each layer with 6-layers RLC-GNN decreases notably in the first four layers. However, the descend of overall layer training loss after the fourth layer becomes small (shown in Figure \ref{fig1}). We argue that it is caused by the limited information of 1-hop neighboring nodes. The first four layers have made the maximum use of information. With the incremental learning mechanism, a layer inherits the knowledge learned by its previous layers from graph. Empirically, new information is required for further learning. Otherwise, what the last two layers can do under the original design is simply delivering the knowledge learned by previous layers. To alleviate this issue, we expand the range for extracting information to 2-hop starting from the fourth layer to introduce new information for further learning, for the reason of which we name it as intermediate information supplement (IIS). As we have mentioned before, fraud detection is a node classification task, and similar nodes tend to be close (relationship rather than spatial distance). Therefore, we do not need to consider nodes far away from center node, which is markedly different from graph-level classification tasks that global information needs to be considered. An illustration of intermediate information supplement is provided in Figure 2\ref{sub@subfig2-2}. \par
\begin{figure}
\centering
\includegraphics[width=0.55\textwidth]{layer_loss.pdf}
\caption{Training loss of each layer on Yelp dataset with 6-layers RLC-GNN.}\label{fig1}
\end{figure}
\begin{figure}
\centering
\begin{minipage}{1.0\linewidth}
\subfigure[Overview of layer structure after applying IIS in RLC-GNN. The IIS is added before intra-relation aggregation module only after the third layer. In the original model, all layers only aggregate features from 1-hop neighboring nodes. IIS enables deep layers to extract richer information for further learning.]{
\includegraphics[width=1.0\textwidth]{layer_structure_detail.pdf}
\label{subfig2-1}
}
\end{minipage}
\vfill
\begin{minipage}{1.0\linewidth}
\subfigure[Process of IIS. We take the IIS process of the given center node under relation 1 as example to illustrate how IIS works. In all layers, we get all 1-hop neighboring nodes represented by set $A=\{ v, v\in N{(u)}\}$, where $u$ is the center node and $N{(\cdot)}$ denotes the set of 1-hop neighbors of $u$. Then starting from the fourth layer, we make all nodes in $A$ take turns to be center node temporarily to find neighboring nodes under relation 1 within 1-hop (i.e., we expand the receipt field of center node $u$ to 2-hop, which more information is introduced) and we get an expanded sub-graph under relation 1.]{
\includegraphics[width=1.0\textwidth]{iis.pdf}
\label{subfig2-2}
}
\end{minipage}
\caption{Our proposed intermediate information supplement (IIS). In Figure 2\subref{subfig2-1}, we show the overview of layer structure of RLC-GNN with IIS. And we illustrate the IIS process by taking the example under a relation in Figure 2\subref{subfig2-2}. IIS is an idea that it is not only applicable to RLC-GNN, but also empirically to any GNN that performs information aggregation locally.}
\label{fig2}
\end{figure}
\section{Experiments}\label{sec4}
\subsection{Dataset}\label{subsec4-1}
We conduct experiments on Yelp dataset including hotel and restaurant reviews and Amazon dataset including users under Musical Instruments category, which is the same as that in work \cite{zeng2021rlc}. For Yelp dataset, it consists of 45,954 reviews, of which 14.5\% are fraudulent samples. And Amazon dataset contains 11,944 users, of which 9.5\% are fraudsters. Each review is a node represented by a vector composed of 32 handcraft features for Yelp (25 for Amazon). Three relations are designed for each dataset (i.e., there are three types of edges). If two samples satisfy a relationship, they are connected by a type of edge corresponding to the relation. Yelp: (1) R-U-R: two reviews are submitted by a same user; (2) R-S-R: two reviews give the same star rating under a product; (3) R-T-R: two reviews are submitted in a same month under a product. Amazon: (1) U-P-U: Two users rate at least one same product; (2) U-S-U: Two users give at least one same star rating under a product in a week; (3) U-V-U: The text similarity of mutual reviews between two users reaches the 5\% among all users. In this design, Yelp dataset has 3,846,979 edges in total and Amazon dataset 4,398,392.
\subsection{Implementation and Setup}\label{subsec4-2}
All methods are implemented with Pytorch 1.7.0. Batch size is set to 256 for Amazon and 512 for Yelp. The training set accounts for 40\% on both datasets. And the optimization method is Adam \cite{kingma2015adam}. All experiments are running on Python 3.7.6, AMD Ryzen7 4800H CPU and a single RTX 2060 GPU. \par
We conduct experiments based on RLC-GNN-6. Three methods take turns to be added to the model to verify the effectiveness of each method, and we conduct performance comparison of the model combined with all three proposed methods to various GNNs. To begin with, we verify effectiveness of performing similarity measure via cosine distance. Afterwards we show the results of partial neighborhood normalization methods among node-wise and batch-wise. In the next part, we put intermediate information supplement to the test based on the RLC-GNN with cosine distance measuring module and normalization technique. Finally, we give the performance of RLC-GNN with all methods proposed in this work. \par
With regard to selection of evaluation metrics, we use recall, macro-F1 and AUC \cite{powers2020evaluation} to assess our proposed methods. Recall directly assess the ability of recognizing fraudulent samples. Macro-F1 is picked up to avoid the misleading which our model achieves high recall by simply predicting all samples as frauds. AUC is chosen for its insensitivity on sample distribution. \par
\subsection{Result}\label{subsec4-3}
\subsubsection{Similarity Measure via Cosine Distance}\label{sssec4-3-1}
Given two feature vectors, we first use layer-specific MLP to transform the dimension of features to 8 and then we compute cosine distance (Eq.\ref{cosd}). In Table \ref{tab1}, we show the experiment results of RLC-GNN with similarity measuring via computing cosine distance. We achieve improvements in almost all metrics on both datasets. But macro-F1 on Amazon dataset shows that the performance of our model has been sacrificed somewhere. Macro-F1 is the harmonic average of recall and precision which denotes the percentage of correct predictions on samples whose predictions are positive. The fact that we get higher recall, meanwhile getting lower marco-F1, indicates that the precision of the model decreases. The higher recall suggests that the model can recognize more fraudulent samples by judging samples more comprehensively, which empirically validates the discussion in Section \ref{subsec3-1}. The lower precision denotes that the model becomes more aggressive which we argue that it is relevant to some statistics of the graph and will be discussed in next part.
\begin{table}[h]
\begin{center}
\begin{minipage}{\textwidth}
\caption{Results of RLC-GNN-6 with $l_1$-distance and cosine distance on both datasets. We report best results after training 200 epochs. The \emph{reference} model is RLC-GNN-6 with similarity measure via $l_1$-distance.}\label{tab1}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lcccc@{\extracolsep{\fill}}}
\toprule
\textbf{Dataset} & \textbf{Model} & \textbf{Recall(\%)} & \textbf{AUC(\%)} & \textbf{Macro-F1(\%)} \\
\midrule
\multirow{2}{*}{Yelp}
& \emph{Ref.} & 74.66 & 83.29 & 68.45 \\
& w/ cos distance & \textbf{75.68} & \textbf{84.19} & \textbf{68.81} \\
\midrule
\multirow{2}{*}{Amazon}
& \emph{Ref.} & 89.83 & 96.77 & \textbf{90.08} \\
& w/ cos distance & \textbf{90.62} & \textbf{97.19} & 89.21 \\
\bottomrule
\end{tabular*}
\end{minipage}
\end{center}
\end{table}
\subsubsection{Partial Neighborhood Normalization}\label{sssec4-3-2}
For a given center node, we first perform similarity measure and then select similar neighboring nodes. Next, we aggregate neighboring features to the center node when we have completed all preparations. Finally, we conduct normalization along node-wise or batch-wise. We show the training loss in Figure \ref{fig3}. We notice that normalization methods accelerate the training process, especially on Yelp dataset. For node-wise partial neighborhood normalization, it can make the model converge faster, but not better. And for batch-wise normalization, it accelerates training process even faster, and better weights are found in solution space. However, on Amazon dataset, applying normalization along batch-wise causes some damage to the model which can be seen from macro-F1. We show the experiments results in Table \ref{tab2}. The interesting note is that we significantly accelerate the training with normalization along both wises on Yelp dataset, while the fraud detection task on Amazon dataset suffers applying batch-wise normalization. More specifically, the macro-F1 has significant decline. And because recall and AUC stay roughly the same, which means that the ability of recognizing frauds remains basically the same, we can know that the precision has significant decline according to the computation of macro-F1. We investigate this phenomenon from the perspective of statistics of the graphs and we provide empirical analysis as follows. \par
In Figure \ref{fig4}, we show the average degree of nodes under each relation in both datasets. Except the average degrees under the third relation are close, the degrees under other relations in Amazon is nearly 19 times greater than Yelp, which means graph built upon Amazon is much denser than Yelp. Due to the denseness of graph and high proportion of benign samples, the graph is full of information of benign features and too many benign samples are gathered around fraudulent samples, which leads to the fact that features of fraudulent samples include too many benign samples' information after aggregation. In Section \ref{subsec3-1}, we propose to apply cosine distance to perform similarity measure to capture patterns from the perspective of overall behavior (i.e., the topological structure in graph). However, because of the high density, the topological structures of all nodes become similar. Driven by supervised learning mechanism, the model not only learns normally, but also learns treating benign samples as fraudulent samples. The normalization techniques do not improve models' ability, but only allows models to acquire the ability they should have earlier. We indicate in Section \ref{subsec3-2} that too much noise (i.e., information of benign samples) will amplify the distortion of original features. For the batch-wise normalization, more unrepresentative information is included in the computation, which makes fraudulent samples be more like benign samples. In summary, these reasons make the model perform more radical under the interaction. For the node classification task, in special in category imbalance, we suggest taking the density of graph into consideration when deciding what type of normalization technique to be used. Based on the results in this work, we recommend batch-wise normalization for sparse graph and node-wise for dense. \par
\begin{figure}
\centering
\begin{minipage}{0.49\linewidth}
\subfigure[Training loss on Yelp dataset.]{
\includegraphics[width=1.0\linewidth]{yelp_loss.pdf}
\label{subfig3-1}
}
\end{minipage}
\begin{minipage}{0.49\linewidth}
\subfigure[Traing loss on Amazon dataset.]{
\includegraphics[width=1.0\linewidth]{amz_loss.pdf}
\label{subfig3-2}
}
\end{minipage}
\caption{Training loss of RLC-GNN without normalization and with node-wise normalization or batch-wise. Obviously, both node-wise and batch-wise normalization methods can accelerate training process. And batch-wise normalization can even help optimizer reach much better solutions.}
\label{fig3}
\end{figure}
\begin{table}
\begin{center}
\begin{minipage}{\textwidth}
\caption{Results based on the RLC-GNN with similarity measure via cosine distance which is the \emph{reference} model. We report the best results after training 200 epochs.}\label{tab2}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lcccc@{\extracolsep{\fill}}}
\toprule
\textbf{Dataset} & \textbf{Model} & \textbf{Recall(\%)} & \textbf{AUC(\%)} & \textbf{Macro-F1(\%)} \\
\midrule
\multirow{2}{*}{Yelp}
& \emph{Ref.} & 75.68 & 84.19 & 68.81 \\
& w/ node-wise norm & 76.71 & 85.07 & 68.87 \\
& w/ batch-wise norm & \textbf{78.03} & \textbf{88.53} & \textbf{74.72} \\
\midrule
\multirow{2}{*}{Amazon}
& \emph{Ref.} & 90.62 & \textbf{97.19} & 89.21 \\
& w/ node-wise norm & \textbf{91.48} & 97.06 & \textbf{89.42} \\
& w/ batch-wise norm & 89.70 & 96.53 & 76.47 \\
\bottomrule
\end{tabular*}
\end{minipage}
\end{center}
\end{table}
\begin{figure}
\centering
\includegraphics[width=0.57\textwidth]{graph_stat.pdf}
\caption{The average degree of nodes under each relation in Yelp and Amazon datasets. It is noticeable that the graph built upon Amazon dataset is much denser than Yelp.}
\label{fig4}
\end{figure}
\subsubsection{Intermediate Information Supplement}\label{sssec4-3-3}
Based on the discussion in Section \ref{subsec3-3}, we expand the receipt field to 2-hop starting from the fourth layer. In view of the analysis in Section \ref{sssec4-3-2}, we take the model with cosine similarity measure module and batch-wise partial neighborhood normalization as reference model on Yelp dataset. As for the Amazon dataset, due to its high density, we do not further import more information, which too much benign samples lack of crucial information will actually become noise. We show the experiment results in Table \ref{tab3}. The model applying intermediate information supplement outperforms the reference model in all metrics.
\begin{table}[h]
\begin{center}
\begin{minipage}{\textwidth}
\caption{Experiment results of the model with intermediate information supplement and batch-wise normalization based on the \emph{reference} model on Yelp dataset. We report the best results after training 200 epochs. IIS is abbreviation of intermediate information supplement.}\label{tab3}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lcccc@{\extracolsep{\fill}}}
\toprule
\textbf{Dataset} & \textbf{Model} & \textbf{Recall(\%)} & \textbf{AUC(\%)} & \textbf{Macro-F1(\%)} \\
\midrule
\multirow{2}{*}{Yelp}
& \emph{Ref.} & 78.03 & 88.53 & 74.72 \\
& w/ IIS & \textbf{79.47} & \textbf{89.91} & \textbf{75.26} \\
\bottomrule
\end{tabular*}
\end{minipage}
\end{center}
\end{table}
\subsubsection{Comparison}\label{sssec4-3-4}
In this section, we conduct performance comparison of the model applying all methods proposed in this work to various GNNs on the two datasets. We show the experiments results in Table \ref{tab4}. Note that, on Yelp dataset, the model with all proposed methods significantly outperforms the basic RLC-GNN-6, and it even outperforms 27-layers model a lot, which validates the effectiveness of our methods. As for Amazon dataset, applying proposed methods makes the model outperform the basic 6-layers model in recall and AUC. We have analyzed the causes of the decline of macro-F1 and argue that similarity measure via cosine distance makes the model become more radical on dense graph. In particular, it takes about 13.9 milliseconds for RLC-GNN-6 with cosine similarity measuring module and node-wise normalization to conduct inference for a node and 53.4 milliseconds for RLC-GNN-27. In other words, in order to achieve the performance to that of the 27-layers RLC-GNN in the task of finding out fraudulent samples, the efficiency can be increased by about 4 times. However, if we are very concerned about the misjudgment that labels benign samples as fraudulent, the best way to improve performance is stacking more layers. It is a tradeoff.
\begin{table}
\begin{center}
\begin{minipage}{\textwidth}
\caption{Performance comparison of RLC-GNN-6 with all proposed methods to various GNNs. Other models' results are directly quoted from the works \cite{zeng2021rlc,dou2020enhancing}.}\label{tab4}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lcccc@{\extracolsep{\fill}}}
\toprule
\textbf{Dataset} & \textbf{Model} & \textbf{Recall(\%)} & \textbf{AUC(\%)} & \textbf{Macro-F1(\%)} \\
\midrule
\multirow{2}{*}{Yelp}
& GCN & 50.81 & 54.47 & -- \\
& GraphSAGE & 52.86 & 54.00 & -- \\
& GAT & 54.52 & 56.24 & -- \\
& CARE-GNN & 71.02 & 77.72 & 61.13 \\
& RLC-GNN-6 & 74.66 & 83.29 & 68.45 \\
& RLC-GNN-27 & 76.68 & 85.44 & 70.03 \\
& \makecell{\textbf{\emph{w/ cos distance,}} \\ \textbf{\emph{batch-wise norm \rm{\&} IIS}}} & \textbf{79.47} & \textbf{89.91} & \textbf{75.26} \\
\midrule
\multirow{2}{*}{Amazon}
& GCN & 67.45 & 74.34 & -- \\
& GraphSAGE & 70.16 & 75.27 & -- \\
& GAT & 65.51 & 75.16 & -- \\
& CARE-GNN & 88.17 & 93.21 & 87.81 \\
& RLC-GNN-6 & 89.83 & 96.77 & \textbf{90.08} \\
& RLC-GNN-27 & \textbf{91.83} & \textbf{97.48} & 89.18 \\
& \makecell{\textbf{\emph{w/ cos distance \rm{\&}}} \\ \textbf{\emph{node-wise norm}}} & 91.48 & 97.06 & 89.42 \\
\bottomrule
\end{tabular*}
\end{minipage}
\end{center}
\end{table}
\section{Conclusion}\label{sec5}
In this work, we find three issues, which are the lack of comprehensive consideration about features and neighborhood topological structure, training difficulty of deep models and the use of information reaching limitation, in the previous work which conducts fraud detection via advanced RLC-GNN. We propose three methods to solve each issue respectively. First, we propose to perform similarity measure via cosine distance to learn node features more comprehensively. Then we apply batch-wise or node-wise partial neighborhood normalization to accelerate the training of deep RLC-GNN. And according to the experiments results, we achieve significant improvements on Yelp dataset. We improve the ability of recognizing fraudulent samples. However, we find that the models become more radical after applying proposed methods on Amazon dataset. We provide an empirical analysis and argue that it is mainly caused by high-density of the graph. And we suggest taking the graph density into consideration when we try to apply normalization techniques. If the graph is very dense, it is good to choose node-wise normalization for its not introducing more invalid information, especially when there is a problem of category imbalance. Finally, we use intermediate information supplement to extract more information starting from intermediate layer to help the model learn further. And the effectiveness of all proposed methods is validated by experiments conducted on Yelp and Amazon datasets. \par
\bibliographystyle{unsrt}
|
{'timestamp': '2022-02-15T02:40:11', 'yymm': '2202', 'arxiv_id': '2202.06580', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06580'}
|
arxiv
|
\section{Introduction}
The ability to continually learn numerous tasks and infer them together is critical for deep neural networks (DNNs), which needs to mitigate \emph{catastrophic forgetting} \citep{mccloskey1989catastrophic} of the past.
Memory replay of representative old training samples (referred to as \emph{memory replay}) has been shown as an effective solution, and achieves the state-of-the-art (SOTA) performance \citep{hou2019learning}.
Existing memory replay approaches are mainly built on a small memory buffer containing a few original data, and try to construct and exploit it more effectively. However, due to the low storage efficiency of saving original data, this strategy of building memory buffer will lose a lot of information about the old data distribution. On the other hand, this usually requires huge extra computation to further mitigate catastrophic forgetting, such as by learning additional parameters \citep{liu2021adaptive} or distilling old features \citep{hu2021distilling}.
Different from ``artificial'' memory replay in DNNs, a significant feature of biological memory is to encode the old experiences in a highly compressed form and replay them to overcome catastrophic forgetting \citep{mcclelland2013incorporating, davidson2009hippocampal, carr2011hippocampal}. Thus the learned information can be maintained in a small storage space as comprehensively as possible, and flexibly retrieved. Inspired by the compression feature of biological memory replay, we propose memory replay with data compression, which can largely increase the amount of old training samples that can be stored in the memory buffer by reducing their storage cost in a computationally efficient way.
\begin{figure}[t]
\centering
\vspace{-0.4cm}
\includegraphics[width=0.95\linewidth]{Time_Accuracy_ImageNet-sub}
\vspace{-0.3cm}
\caption{Averaged incremental accuracy and training time on ImageNet-sub. Using JPEG for data compression can achieve comparable or better performance than recent strong approaches with less extra computation (purple arrow), and can further improve their performance (gray arrow).}
\label{Time_Accuracy_ImageNet-sub_Summary}
\vspace{-0.5cm}
\end{figure}
Given a limited storage space, data compression introduces an additional degree of freedom to explicitly balance the quality and quantity for memory replay.
With a properly selected quality, using a naive JPEG compression algorithm \citep{wallace1992jpeg} can achieve comparable or better performance than recent strong approaches with less extra computation (Fig. \ref{Time_Accuracy_ImageNet-sub_Summary}, purple arrow), and can further improve their performance (Fig. \ref{Time_Accuracy_ImageNet-sub_Summary}, gray arrow).
However, to empirically determine the compression quality is usually inefficient and impractical, since it requires learning a task sequence or sub-sequence repeatedly\footnote{A naive grid search approach is to train continual learning processes with different qualities and choose the best one, resulting in huge computational cost. Also, this strategy will be less applicable if the old data cannot be revisited, or the future data cannot be accessed immediately.}. We propose a novel method based on determinantal point processes (DPPs) to efficiently determine it without repetitive training. Further, we demonstrate the advantages of our proposal in realistic applications such as continual learning of object detection for autonomous driving, where the incremental data are extremely large-scale.
Our contributions include: (1) We propose memory replay with data compression, which is both an important baseline and a promising direction for continual learning; (2) We empirically validate that the trade-off between quality and quantity of compressed data is highly nontrivial for memory replay, and provide a novel method to efficiently determine it without repetitive training;
(3) Extensive experiments show that using a naive data compression algorithm with a properly selected quality can largely improve memory replay by saving more compressed data in a limited storage space.
\section{Related Work}
\textbf{Continual learning} needs to overcome catastrophic forgetting of the past when learning a new task. Regularization-based methods \citep{kirkpatrick2017overcoming, wang2021afec} approximated the importance of each parameter to the old tasks and selectively penalized its changes. Architecture-based methods \citep{rusu2016progressive} allocated a dedicated parameter subspace for each task to prevent mutual interference. Replay-based methods \citep{rebuffi2017icarl, shin2017continual} approximated and recovered the old data distribution.
In particular, memory replay of representative old training samples (referred to as \emph{memory replay}) can generally achieve the best performance in class-incremental learning \citep{liu2021adaptive,hu2021distilling} and in numerous other continual learning scenarios, such as audio tasks \citep{ehret2020continual}, few-shot \citep{tao2020few}, semi-supervised \citep{wang2021ordisco}, and unsupervised continual learning \citep{khare2021unsupervised}.
Most of the work in memory replay attempted to more effectively construct and exploit a small memory buffer containing a few original data.
As the pioneer work, iCaRL \citep{rebuffi2017icarl} proposed a general protocol of memory replay for continual learning.
To better construct the memory buffer, Mnemonics \citep{liu2020mnemonics} parameterized the original data and made them optimizable, while TPCIL \citep{tao2020topology} constructed an elastic Hebbian graph by competitive Hebbian learning.
On the other hand, BiC \citep{wu2019large}, LUCIR \citep{hou2019learning}, PODNet \citep{douillard2020podnet}, DDE \citep{hu2021distilling} and AANets \citep{liu2021adaptive} attempted to better exploit the memory buffer, such as by mitigating the data imbalance between old and new classes \citep{hou2019learning,wu2019large,hu2021distilling}.
In contrast to saving original data, some work aimed at improving the efficiency of remembering the old data distribution.
One solution is to continually learn a generative model to replay generated data \citep{shin2017continual,wu2018memory} or compress old training data \citep{caccia2020online}. However, continual learning of such a generative model is extremely challenging, which limits its applications to relatively simple domains, and usually requires a lot of extra computation. Another solution is feature replay: GFR \citep{liu2020generative} learned a feature generator from a feature extractor to replay generated features, but the feature extractor suffered from catastrophic forgetting since it was incrementally updated. REMIND \citep{hayes2020remind} saved the old features and reconstructed the synthesized features for replay, but it froze the majority of feature extractor after learning the initial phase, limiting the learning of representations for incremental tasks.
\textbf{Data compression} aims to improve the storage efficiency of a file, including lossless compression and lossy compression. Lossless compression needs to perfectly reconstruct the original data from the compressed data, which limits its compression rate \citep{shannon1948mathematical}. In contrast, lossy compression can achieve a much higher compression rate by degrading the original data, so it has been broadly used in realistic applications. Representative hand-crafted approaches include JPEG (or JPG) \citep{wallace1992jpeg}, which is the most commonly-used algorithm of lossy compression \citep{mentzer2020high}, WebP \citep{lian2012webp} and JPEG2000 \citep{rabbani2002jpeg2000}. On the other hand, neural compression approaches generally rely on optimizing Shannon's rate-distortion trade-off, through RNNs \citep{toderici2015variable,toderici2017full}, auto-encoders \citep{agustsson2017soft} and GANs \citep{mentzer2020high}.
\section{Continual Learning Preliminaries}
We consider a general setting of continual learning, which needs to incrementally learn numerous tasks $t = 1, 2, 3, ...$ from their task-specific training dataset \(D_{t} = \{(x_{t,i}, y_{t,i})\}_{i=1}^{{N}_{t}} \), where \(D_{t}\) is only available when learning task \(t\), \((x_{t,i}, y_{t,i})\) is a data-label pair and \(N_t\) is the number of such training samples.
For classification tasks, the training samples of each task might be from one or several new classes.
All the classes ever seen are evaluated at test time, and the classes from different tasks need to be distinguished. This setting is also called class-incremental learning \citep{vandeven2019three}.
Suppose a DNN with parameter \(\theta\) has learned \(T\) tasks and attempts to learn a new task. Since the old training datasets \(\bigcup_{t=1}^{T} D_{t}\) are unavailable, the DNN will adapt the learned parameters to fit \(D_{T+1}\), and tend to catastrophically forget the old tasks \citep{mccloskey1989catastrophic}.
An effective solution of overcoming catastrophic forgetting is to select and store representative old training samples \(D_{t}^{mb} = \{(x_{t,i}, y_{t,i})\}_{i=1}^{{N}_{t}^{mb}} \) in a small memory buffer (\(mb\)), and replay them when learning the new task. For classification tasks, mean-of-feature is a widely-used strategy to select \(D_{t}^{mb}\) \citep{rebuffi2017icarl, hou2019learning}.
After learning each task, features of the training data can be obtained by the learned embedding function \(F_{\theta}^{e}(\cdot)\). In each class, several data points nearest to the mean-of-feature are selected into the memory buffer. Then, the training dataset of task \(T+1\) becomes \(D'_{T+1} = D_{T+1} \bigcup {D}_{1:T}^{mb} \), including both new training samples \(D_{T+1} \) and some old training samples \({D}_{1:T}^{mb} = \bigcup_{t=1}^{T} {D}_{t}^{mb}\), so as to prevent forgetting of the old tasks.
However, due to the limited storage space, only a few original data can be saved in the memory buffer, namely, \({N}_{t}^{mb} \ll {N}_{t}\). Although numerous efforts in memory replay attempted to more effectively exploit the memory buffer, such as by alleviating the data imbalance between the old and new classes, this strategy of building memory buffer is less effective for remembering the old data distribution.
\section{Method}
In this section, we first present memory replay with data compression for continual learning. Then, we empirically validate that there is a trade-off between the quality and quantity of compressed data, which is highly nontrivial for memory replay, and propose a novel method to determine it efficiently.
\subsection{Memory Replay with Data Compression}
Inspired by the biological memory replay that is in a highly compressed form \citep{carr2011hippocampal},
we propose an important baseline for memory replay, that is, using data compression to increase the amount of old training samples that can be stored in the memory buffer, so as to more effectively recover the old data distribution. Data compression can be generally defined as a function \(F_{q}^c(\cdot)\) of compressing the original data \(x_{t,i}\) to \(x_{q, t,i} = F_{q}^c(x_{t,i}) \) with a controllable quality \(q\). Due to the smaller storage cost of each \(x_{q, t,i}\) than \(x_{t,i}\), the memory buffer can maintain more old training samples for replay, namely, \(N_{q, t}^{mb} > {N}_{t}^{mb}\) for \(D_{q, t}^{mb} = \{(x_{q,t,i}, y_{t,i})\}_{i=1}^{N_{q,t}^{mb}} \) in \(D_{q, 1:T}^{mb} = \bigcup_{t=1}^{T} D_{q, t}^{mb}\).
For notation clarity, we will use \({D}_{q}^{mb}\) to denote \({D}_{q, t}^{mb}\) without explicitly writing out its task label \(t\), likewise for \(x_{i}\), \(y_i\), \({N}_{q}^{mb}\), \({N}^{mb}\) and \({D}\). The compression rate can be defined as \(r_{q} = N_{q}^{mb} / {N}^{mb} \propto N_{q}^{mb}\).
\begin{figure}[t]
\centering
\vspace{-0.3cm}
\includegraphics[width=1\linewidth]{Accuracy_Tradeoff}
\vspace{-0.6cm}
\caption{Memory replay with data compression on ImageNet-sub. We make a grid search of the JPEG quality in \(\{10, 25, 50, 75, 90\}\). The quality of 100 refers to the original data without compression.}
\vspace{-0.5cm}
\label{Accuracy_Tradeoff}
\end{figure}
In analogy to the learning theory for supervised learning, we argue that continual learning will also benefit from replaying more compressed data, assuming that they approximately follow the original data distribution. However, the assumption is likely to be violated if the compression rate is too high. Intuitively, this leads to a trade-off between quality and quantity: if the storage space is limited, reducing the quality \(q\) of data compression will increase the quantity \(N_{q}^{mb}\) of compressed data that can be stored in the memory buffer, and vice versa.
Here we evaluate the proposed idea by compressing images with JPEG \citep{wallace1992jpeg}, a naive but commonly-used lossy compression algorithm. JPEG can save images with a quality in the range of \([1, 100]\), where reducing the quality results in a smaller file size. Using a memory buffer equivalent to 20 original images per class \citep{hou2019learning}, we make a grid search of the JPEG quality with representative memory replay approaches, such as LUCIR \citep{hou2019learning} and PODNet \citep{douillard2020podnet}.
As shown in Fig. \ref{Accuracy_Tradeoff}, memory replay of compressed data with an appropriate quality can substantially outperform that of original data. However, whether the quality is too large or too small, it will affect the performance. In particular, the quality that achieves the best performance varies with the memory replay approaches, but is consistent for different numbers of splits of incremental phases.
\subsection{Quality-Quantity Trade-off}
Since the trade-off between quality $q$ and quantity $N_q^{mb}$ is highly nontrivial for memory replay, it needs to be carefully determined. Formally, after learning each task from its training dataset \(D\), let's consider several compressed subsets \(D_{q}^{mb} = \{(x_{q, i}, y_{i})\}_{i=1}^{{N}_{q}^{mb}} \), where \(q\) is from a set of finite candidates \(Q= \{q_1, q_2, q_3, ...\}\).
Each \(D_{q}^{mb}\) is constructed by selecting a subset \({D}^{mb *}_q = \{({x}_{i}, y_{i})\}_{i=1}^{{N}_{q}^{mb}} \) of \({N}_{q}^{mb}\) original training samples from \(D\) (following mean-of-feature or other principles). The size \({N}_{q}^{mb}\) is determined as the maximum number such that the compressed version of \({D}^{mb *}_q\) to a quality \(q\) can be stored in the memory buffer (see details in Appendix A). Thereby, a smaller \(q\) enables to save a larger \({N}_{q}^{mb}\), and vice versa. The objective is to select a compressed subset that can best represent \(D\), namely, to determine an appropriate \(q \) for memory replay.
To understand the effects of data compression, which depends on the compression function \(F_{q}^{c}(\cdot)\) and the continually-learned embedding function \(F_{\theta}^{e}(\cdot)\), we focus on analyzing the features of compressed data \(f_{q,i} = F_{\theta}^{e}(F_{q}^{c}(x_{i}))\).
We first calculate the feature matrix \(M_q^c = [\bar{f}_{q, 1}, \bar{f}_{q, 2}, ..., \bar{f}_{q, N_q^{mb}}]\) of each compressed subset \(D_{q}^{mb}\), where each column vector \(\bar{f}_{q, i}\) is obtained by normalizing \(f_{q, i}\) under \(L_2\)-norm to keep \(||\bar{f}_{q, i}||_2 = 1\). Similarly, we obtain the feature matrix \(M_q^{*}= [\bar{f}_{1}, \bar{f}_{2}, ..., \bar{f}_{N_q^{mb}}]\) of each original subset \(D_q^{mb *}\). Then, we can analyze the quality-quantity trade-off from two aspects:
\begin{figure}[th]
\centering
\vspace{-0.2cm}
\includegraphics[width=1\linewidth]{Feature_Manifold_Compressed}
\vspace{-0.6cm}
\caption{t-SNE visualization of features of the original subset (light dots) and its compressed subset (dark dots) after learning 5-phase ImageNet-sub with LUCIR. From left to right, the quantity is increased from 37, 85 to 200, while the JPEG quality is reduced from 90, 50 to 10. We plot five classes out of the latest task and label them in different colors. The crossed area is out-of-distribution. }
\label{Feature_Manifold_Compressed}
\vspace{-0.3cm}
\end{figure}
On the \textbf{empirical} side, in Fig. \ref{Feature_Manifold_Compressed} we use t-SNE \citep{van2008visualizing} to visualize features of the original subset (light dot), which includes different amounts of original data, and its compressed subset (dark dot), which is obtained by compressing the original subset to just fit in the memory buffer. With the increase of quantity and the decrease of quality, the area of compressed subset is initially similar to that of original subset and expands synchronously. However, as a large number of low-quality compressed data occur out-of-distribution, the area of compressed subset becomes much larger than that of its original subset, where the performance also severely declines (see Fig. \ref{Accuracy_Tradeoff}, \ref{Feature_Manifold_Compressed}).
\iffalse
On the \textbf{theoretical} side, given a training dataset $D$, we aim to find the compressed subset \(D_q^{mb}\) that can best represent \(D\) by choosing an appropriate compression quality \(q\) from its range.
To achieve this goal, we introduce $\mathcal{P}_{q} (D_q^{mb}|D)$ to characterize the conditional likelihood of selecting \(D_q^{mb}\) given input \(D\) under parameter $q$. Since the network parameter $\theta$ is fixed during compression, and the feature matrix $M_q^c=F_{\theta}^e(D_q^{mb})$, we rewrite $\mathcal{P}_{q} (D_q^{mb}|D)$ as $\mathcal{P}_{q} (M_q^c|D)$ equivalently. By focusing on maximum likelihood estimation (MLE), we propose to solve
\begin{equation}\label{Compress-obj}
\begin{split}
\max_{q} \ \mathcal{P}_{q} (M_q^c|D).
\end{split}
\end{equation}
We draw inspirations from determinantal point processes (DPPs), which are elegant probabilistic sampling models in data selection fields \citep{kulesza2012determinantal}.
In particular, DPPs specify the probabilities for every possible subset with the volume spanned by all elements in this subset, using determinants.
Depending on the nice properties of DPPs (e.g., high-quality diverse selection), our goal can be modeled as a DPP, i.e., a distribution over all subsets of $D$ with cardinality $N_q^{mb}$ (detailed in Appendix C.2).
Formally, such a DPP formulates the probability $\mathcal{P}_{q} (M_q^c|D)$ as
\fi
On the \textbf{theoretical} side, given a training dataset $D$, we aim to find the compressed subset \(D_q^{mb}\) that can best represent \(D\) by choosing an appropriate compression quality \(q\) from its range.
To achieve this goal, we introduce $\mathcal{P}_{q} (D_q^{mb}|D)$ to characterize the conditional likelihood of selecting \(D_q^{mb}\) given input \(D\) under parameter $q$. The goal of learning is to choose appropriate $q$ based on the training tasks for making accurate predictions on unseen inputs.
While there are a variety of objective functions for learning, here we focus on the widely-used maximum likelihood estimation (MLE), where the goal is to choose $q$ to maximize the conditional likelihood of the observed data:
\begin{equation}\label{Compress-obj}
\begin{split}
\max_{q} \ \mathcal{P}_{q} (D_q^{mb}|D).
\end{split}
\end{equation}
The construction of $D_q^{mb}$ can be essentially viewed as a sampling problem with the cardinality ${N}_q^{mb}$.
Here, we apply Determinantal Point Processes (DPPs) to formulate the conditional likelihood $\mathcal{P}_{q} (D_q^{mb}|D)$, since DPPs are not only elegant probabilistic sampling models \citep{kulesza2012determinantal}, which can characterize the probabilities for every possible subset by determinants, but also provide a geometric interpretation of the probability by the volume spanned by all elements in the subset (detailed in Appendix C.2).
In particular, a conditional DPP is a conditional probabilistic model which assigns a probability $\mathcal{P}_{q} (D_q^{mb}|D)$ to each possible subset $D_q^{mb}$.
Since the network parameter $\theta$ is fixed during compression, and the feature matrix $M_q^c=F_{\theta}^e(D_q^{mb})$, we rewrite $\mathcal{P}_{q} (D_q^{mb}|D)$ as $\mathcal{P}_{q} (M_q^c|D)$ equivalently.
Formally, such a DPP formulates the probability $\mathcal{P}_{q} (D_q^{mb}|D)$ as
\begin{equation}\label{Compress-def}
\begin{split}
\mathcal{P}_{q} (M_q^c|D)
= \frac{\det(L_{M_q^c}(D; q,\theta))}{\sum_{|{M}|=N_q^{mb}}\det(L_{{M}}(D; q, \theta))},
\end{split}
\end{equation}
where $|{M_q^c}|=N_q^{mb}$ and \(L(D; q, \theta) \) is a conditional DPP $|D|\times |D|$ kernel matrix that depends on the input $D$, the parameters $\theta$ and $q$.
$L_{M}(D; q, \theta)$ (resp., $L_{M_q^c}(D; q,\theta)$) is the submatrix sampled from \(L(D; q, \theta) \) using indices from $M$ (resp., $M_q^c$).
The numerator defines the marginal probability of inclusion for the subset ${M_q^c}$, and the denominator serves as a normalizer to enforce the sum of $\mathcal{P}_{q} (M_q^c|D)$ for every possible ${M_q^c}$ to 1. Generally, there are many ways to obtain a positive semi-definite kernel $L$. In this work, we employ the most widely-used dot product kernel function, where $L_{M_q^c}=M_q^{c \top} M_q^{c}$ and $L_{{M}}={M}^{ \top} {M}$.
However, due to the extremely high complexity of calculating the denominator in Eq.~(\ref{Compress-def}) (analyzed in Appendix C.1), it is difficult to optimize \(\mathcal{P}_{q} (M_q^c|D)\). Alternatively, by introducing \(\mathcal{P}_{q} (M_q^*|D) \) to characterize the conditional likelihood of selecting \(M_q^*\) given input \(D\) under parameter $q$, we propose a relaxed optimization program of Eq.~(\ref{Compress-obj}), in which we (1) maximize \(\mathcal{P}_{q} (M_q^*|D) \) since \(\mathcal{P}_{q} (M_q^c|D) \le \mathcal{P}_{q} (M_q^*|D) \) is always satisfied under lossy compression; and meanwhile, (2) constrain that \(\mathcal{P}_{q} (M_q^c|D) \) is consistent with \(\mathcal{P}_{q} (M_q^*|D) \). The relaxed program is solved as follows.
First, by formulating $\mathcal{P}_{q} (M_q^*|D)$ similarly as $\mathcal{P}_{q} (M_q^c|D)$ in Eq.~(\ref{Compress-def}) (detailed in Appendix C.2), we need to maximize
\begin{equation}\label{Uncompess}
\begin{split}
\mathcal{L}_1(q) = \mathcal{P}_{q} (M_q^*|D) =
\frac{\det(L_{M_q^*}(D;\theta))}{\sum_{|M^*|=N_q^{mb}} \det(L_{M^*}(D; \theta))},
\end{split}
\end{equation}
where the conditional DPP kernel matrix \(L(D; \theta) \) only depends on $D$ and $\theta$. For our task, $\mathcal{P}_{q} (M_q^*|D) $ monotonically increases with $N_q^{mb}$. Thus, optimizing $\mathcal{L}_1$ is converted into $\max_q\ {N_q^{mb}}$ equivalently, with significantly reduced complexity (detailed in Proposition~\ref{propo1} of Appendix C.3).
Second, to constrain that $\mathcal{P}_q (M_q^c|D)$ is consistent with $\mathcal{P}_q (M_q^{*}|D)$, we propose to minimize
\begin{equation}
\begin{split}
\mathcal{L}_2(q)& =
\left | \frac{ \mathcal{P}_q (M_q^c|D) }{ \mathcal{P}_q (M_q^{*}|D)} -1 \right |
= \left | \frac{\det(M_q^{c \top} M_q^c)}{\det(M_q^{* \top} M_q^{*})}Z_q -1 \right |
= \left | \left(\frac{\rm{Vol}_q^c}{\rm{Vol}_q^{*}}\right)^2 Z_q -1 \right |
= \left | R_q^{2} Z_q -1 \right |,
\end{split}
\end{equation}
where $Z_q=\frac{\sum_{|M^*|=N_q^{mb}} \det(L_{M^*}(D; \theta))}{\sum_{|M|=N_q^{mb}} \det(L_{M}(D; q, \theta))}$. In particular, $\det(M_q^{* \top} M_q^*)$ has a geometric interpretation that it is equal to the squared volume spanned by $M_q^*$ \citep{kulesza2012determinantal}, denoted as $\rm{Vol}_q^{*}$, likewise for $\det(M_q^{c \top} M_q^c)$ with respect to $\rm{Vol}_q^{c}$. Then we define \(R_q = \frac{\rm{Vol}_q^c}{\rm{Vol}_q^{*}}\) as the ratio of the two feature volumes.
To avoid computing \(Z_q\), we can convert optimizing \(\mathcal{L}_2 \) into minimizing \(|R_q - 1| \) equivalently, since both of them mean maximizing $q$ (detailed in Proposition~\ref{propo2} of Appendix C.4).
Putting $\mathcal{L}_1$ and $\mathcal{L}_2$ together, our method is finally reformulated as
\begin{equation}
\begin{split}
& \max_{q} \ g(q) \\
& s.t., \ q\in Q, \ |R_q - 1| < \epsilon,
\end{split}
\label{Objective}
\end{equation}
where $\epsilon$ is a small positive number to serve as the threshold of \(R_q\).
$g(\cdot): \mathbb{R} \rightarrow \mathbb{N}$ represents the function that outputs the maximum number (i.e., \({N}_{q}^{mb}\)) such that the compressed version of \({D}^{mb *}_q\) to a quality \(q\) can be stored in the memory buffer.
Note that we relax the original restriction of minimizing \(|R_q - 1|\) by enforcing \(|R_q - 1| < \epsilon\), since maximizing \(N_q^{mb}\) for $\mathcal{L}_1$ and maximizing \(q\) for $\mathcal{L}_2$ cannot be achieved simultaneously.
Of note, \(R_q\) is calculated by normalizing the feature volume $\rm{Vol}_q^c$ with $\rm{Vol}_q^{*}$, both of which depend on $q$ (i.e., $N_q^{mb}$). Therefore, $\epsilon$ can largely mitigate the sensitivity of $q$ to various domains and can be empirically set as a constant value (see Sec. 4.3).
Since the function $g(\cdot)$ in Eq.~(\ref{Objective}) is highly non-smooth, gradient-based methods are not applicable. Indeed, we solve it by selecting the best candidate in a finite-size set $Q$. Generally, the candidate values in $Q$ can be equidistantly selected from the range of $q$, such as \([1, 100]\) for JPEG. More candidate values can determine a proper $q$ more accurately, but the complexity will grow linearly. We found that selecting 5 candidate values is a good choice in our experiments. Once we solve Eq.~(\ref{Objective}), a good trade-off is achieved by reducing \(q\) as much as possible to obtain a larger \(N_q^{mb}\), while keeping the feature volume $\rm{Vol}_q^c$ similar to $\rm{Vol}_q^{*}$. This is consistent with our empirical analysis in Fig. \ref{Feature_Manifold_Compressed}.
\subsection{Validate Our Method with Grid Search Results}
\begin{wrapfigure}{r}{0.60\textwidth}
\vspace{-.2cm}
\centering
\includegraphics[width=0.60\columnwidth]{Determine_Compression_Rate.jpg}
\vspace{-.6cm}
\caption{Properly select a quality without repetitive training.}
\label{fig:Determine_Compression_Rate}
\vspace{-.4cm}
\end{wrapfigure}
In essence, the grid search described in Sec.~4.1 can be seen as a naive approach to determine the compression quality, which is similar to selecting other hyperparameters for continual learning (Fig.~\ref{fig:Determine_Compression_Rate}, a).
This strategy is to learn a task sequence or sub-sequence using different qualities and choose the best one (Fig.~\ref{fig:Determine_Compression_Rate}, b), which leads to huge extra computation and will be less applicable if the old data cannot be revisited, or the future data cannot be accessed immediately.
In contrast, our method described in Sec. 4.2 only needs to calculate the feature volumes of each compressed subset \(D_{q}^{mb}\) and original subset \(D_{q}^{mb*}\) (Fig.~\ref{fig:Determine_Compression_Rate}, c), without repetitive training.
\begin{figure}[ht]
\vspace{-.5cm}
\centering
\includegraphics[width=0.85\columnwidth]{5-phase_ImageNet-sub_Rq}
\vspace{-0.3cm}
\caption{For 5-phase ImageNet-sub, we present \(R_q\) in each incremental phase with various compression qualities \(q\), and the averaged \(R_q\) of all incremental phases. }
\label{5phase_ImageNet_Rq}
\vspace{-0.5cm}
\end{figure}
Now we validate the quality determined by our method with the grid search results, where LUCIR and PODNet achieve the best performance at the JPEG quality of 50 and 75 on ImageNet-sub, respectively (see Fig. \ref{Accuracy_Tradeoff}). We present \(R_q\) in each incremental phase and the averaged \(R_q\) of all incremental phases for 5-phase split in Fig. \ref{5phase_ImageNet_Rq} and for 10- and 25-phase splits in Appendix Fig.\ref{Volume_by_Phase_All}. Based on the principle in Eq.~(\ref{Objective}) with \(\epsilon = 0.5\), it can be clearly seen that 50 and 75 are the qualities chosen for LUCIR and PODNet, respectively, since they are the smallest qualities that satisfy \(|R_q - 1| < \epsilon\). Therefore, the quality determined by our method is consistent with the grid search results, but the computational cost is saved by more than 100 times.
Interestingly, for each quality \(q\), whether \(|R_q - 1| < \epsilon\) is generally consistent in each incremental phase and the average of all incremental phases. We further explore the scenarios where \(R_q \) might be more dynamic in Appendix D.4.
\section{Experiment}
In this section, we first evaluate memory replay with data compression in class-incremental learning of large-scale images. Then, we demonstrate the advantages of our proposal in realistic semi-supervised continual learning of large-scale object detection for autonomous driving.\footnote{All experiments are averaged by more than three runs with different random seeds.}
\subsection{Class-Incremental Learning}
\textbf{Benchmark}: We consider three benchmark datasets of large-scale images for continual learning. CUB-200-2011 \citep{wah2011caltech} is a large-scale dataset including 200-class 11,788 colored images of birds with default format of JPG, split as 30 images per class for training while the rest for testing. ImageNet-full \citep{russakovsky2015imagenet} includes 1000-class large-scale natural images with default format of JPEG.
ImageNet-sub \citep{hou2019learning} is a subset derived from ImageNet-full, consisting of randomly selected 100 classes of images. Following \cite{hou2019learning}, we randomly resize, crop and normalize the images to the size of \(224 \times 224\), and randomly split a half of the classes as the initial phase while split the rest into 5, 10 and 25 incremental phases. We report the averaged incremental accuracy with single-head evaluation \citep{chaudhry2018riemannian} in the main text, and further present the averaged forgetting in Appendix E.3.
\textbf{Implementation}:
We follow the implementation of representative memory replay approaches \citep{hou2019learning,douillard2020podnet} (detailed in Appendix B.1), where we focus on constraining a certain storage space of the memory buffer rather than a certain number of images. The storage space is limited to the equivalent of 20 original images per class, if not specified.
We further discuss the effects of different storage space in Fig. \ref{Buffer_Size}, a fixed memory budget in Appendix E.4 and less compressed samples in Appendix E.5. For data compression, we apply a naive but commonly-used JPEG \citep{wallace1992jpeg} algorithm to compress images to a controllable quality in the range of \([1, 100]\).
\iffalse
\renewcommand\arraystretch{1.5}
\begin{table*}[t]
\centering
\vspace{-.4cm}
\caption{Averaged incremental accuracy (\(\%\)) of classification tasks. The memory buffer size is equal to 20 original images per class. For CUB-200-2011, the performance of all baselines is reproduced from their officially-released code (if applicable), while for ImageNet-sub and ImageNet-full we present the reported performance of all baselines and the reproduced results of AANets and DDE, so as to make the comparison as fair as possible. The reproduced results might slightly vary from the reported results due to the usage of different random seeds. \(^1\)With class-balance finetuning \citep{hu2021distilling}. \(^2\)PODNet reproduced by \cite{hu2021distilling} underperforms that in \cite{douillard2020podnet}. }
\smallskip
\resizebox{1\textwidth}{!}{
\begin{tabular}{lcccccccc}
\specialrule{0.01em}{1.2pt}{1.5pt}
\multicolumn{1}{c}{} & \multicolumn{3}{c}{CUB-200-2011} & \multicolumn{3}{c}{ImageNet-sub} & \multicolumn{2}{c}{ImageNet-full} \\
\cmidrule(lllr){2-4} \cmidrule(lllr){5-7} \cmidrule(lllr){8-9}
Method & 5-phase & 10-phase & 25-phase & 5-phase & 10-phase & 25-phase & 5-phase & 10-phase \\
\specialrule{0.01em}{1.2pt}{1.7pt}
LwF \citep{li2017learning} &39.42 &38.53 &36.33 & 53.62 & 47.64 & 44.32 & 44.35 & 38.90 \\
iCaRL \citep{rebuffi2017icarl} &39.49 &39.31 &38.77 & 65.44 & 59.88 & 52.97 & 51.50 & 46.89 \\
BiC \citep{wu2019large} &45.29 &45.25 &45.17 & 70.07 & 64.96 & 57.73 & 62.65 & 58.72 \\
Mnemonics \citep{liu2020mnemonics}& -- & -- & -- & 72.58 & 71.37 & 69.74 & 64.54 & 63.01 \\
TPCIL \citep{tao2020topology} &-- &-- &-- & 76.27 & 74.81 & -- & 64.89 & 62.88 \\
\specialrule{0.01em}{1.2pt}{1.7pt}
LUCIR \citep{hou2019learning}&44.63 &45.58 &45.48 & 70.84 & 68.32 & 61.44 & 64.45 & 61.57 \\
\quad w/ AANets \citep{liu2021adaptive} &-- &-- &-- & 72.55 & 69.22 & 67.60 & 64.94 & 62.39 \\
\quad w/ DDE \citep{hu2021distilling}&-- &-- &-- & 72.34 & 70.20 & -- & 67.51\(^1\) & 65.77\(^1\) \\
\rowcolor{black!15}
\quad w/ \emph{Ours} &46.68 &47.28 &48.01 & 73.56 & 72.70 &70.53 &67.53\(^1\) &65.29\(^1\)\\
\cdashline{1-9}[2pt/2pt]
\quad w/ AANets (Reproduced) &46.87 &47.34 &47.35 &72.91 & 71.93 & 70.70 &63.37 &62.46 \\
\rowcolor{black!15}
\quad w/ AANets + \emph{Ours}& \textbf{49.02} &\textbf{49.84} &\textbf{51.33} &73.79 &73.73 &\textbf{73.47} &64.99 &63.04 \\
\cdashline{1-9}[2pt/2pt]
\quad w/ DDE (Reproduced) & 45.86 &46.48 &46.46 & 73.04 & 70.84 & 66.61 & 66.95\(^1\) & 65.21\(^1\) \\
\rowcolor{black!15}
\quad w/ DDE + \emph{Ours} &47.16 &48.33 &48.37 &75.12 &73.39 &70.83 &67.90\(^1\) &\textbf{66.67}\(^1\)\\
\specialrule{0.01em}{1.2pt}{1.5pt}
PODNet \citep{douillard2020podnet} &44.92 &44.49 &43.79 & 75.54 & 74.33 & 68.31 & 66.95 & 64.13 \\
\quad w/ AANets \citep{liu2021adaptive} &-- &-- &-- & 76.96 & 75.58 & 71.78 & 67.73 & 64.85\\
\quad w/ DDE \citep{hu2021distilling} &-- &-- &-- & 76.71 & 75.41 & -- & 66.42\(^2\) & 64.71 \\
\rowcolor{black!15}
\quad w/ \emph{Ours} &46.00 &46.09 &45.84 & \textbf{78.08} & \textbf{76.02} & 72.72 &\textbf{68.91} &66.31 \\
\specialrule{0.01em}{1.2pt}{1.7pt}
\end{tabular}
}
\label{table:classification_result}
\vspace{-.4cm}
\end{table*}
\fi
\renewcommand\arraystretch{1.5}
\begin{table*}[t]
\centering
\vspace{-.4cm}
\caption{Averaged incremental accuracy (\(\%\)) of classification tasks.
The reproduced results are presented with \(\pm\) standard deviation, while others are reported results. The reproduced results might slightly vary from the reported results due to different random seeds. \(^1\)With class-balance finetuning. \(^2\)PODNet reproduced by \cite{hu2021distilling} underperforms that in \cite{douillard2020podnet}.}
\smallskip
\resizebox{1\textwidth}{!}{
\begin{tabular}{lcccccccc}
\specialrule{0.01em}{1.2pt}{1.5pt}
\multicolumn{1}{c}{} & \multicolumn{3}{c}{CUB-200-2011} & \multicolumn{3}{c}{ImageNet-sub} & \multicolumn{2}{c}{ImageNet-full} \\
\cmidrule(lllr){2-4} \cmidrule(lllr){5-7} \cmidrule(lllr){8-9}
Method & 5-phase & 10-phase & 25-phase & 5-phase & 10-phase & 25-phase & 5-phase & 10-phase \\
\specialrule{0.01em}{1.2pt}{1.7pt}
LwF \citep{li2017learning} &39.42 \tiny{$\pm 0.48$} &38.53 \tiny{$\pm 0.96$}&36.33 \tiny{$\pm 0.74$}& 53.62 & 47.64 & 44.32 & 44.35 & 38.90 \\
iCaRL \citep{rebuffi2017icarl} &39.49 \tiny{$\pm 0.58$}&39.31 \tiny{$\pm 0.66$}&38.77 \tiny{$\pm 0.73$}& 65.44 & 59.88 & 52.97 & 51.50 & 46.89 \\
BiC \citep{wu2019large} &45.29 \tiny{$\pm 0.88$}&45.25 \tiny{$\pm 0.70$}&45.17 \tiny{$\pm 0.27$}& 70.07 & 64.96 & 57.73 & 62.65 & 58.72 \\
Mnemonics \citep{liu2020mnemonics}& -- & -- & -- & 72.58 & 71.37 & 69.74 & 64.54 & 63.01 \\
TPCIL \citep{tao2020topology} &-- &-- &-- & 76.27 & 74.81 & -- & 64.89 & 62.88 \\
\specialrule{0.01em}{1.2pt}{1.7pt}
LUCIR \citep{hou2019learning}&44.63 \tiny{$\pm 0.32$}&45.58 \tiny{$\pm 0.28$}&45.48 \tiny{$\pm 0.66$}& 70.84 & 68.32 & 61.44 & 64.45 & 61.57 \\
\quad w/ AANets \citep{liu2021adaptive} &-- &-- &-- & 72.55 & 69.22 & 67.60 & 64.94 & 62.39 \\
\quad w/ DDE \citep{hu2021distilling}&-- &-- &-- & 72.34 & 70.20 & -- & 67.51\(^1\) & 65.77\(^1\) \\
\rowcolor{black!15}
\quad w/ \emph{Ours} &46.68 \tiny{$\pm 0.60$}&47.28 \tiny{$\pm 0.51$}&48.01 \tiny{$\pm 0.72$}& 73.56 \tiny{$\pm 0.27$}& 72.70 \tiny{$\pm 0.47$}&70.53 \tiny{$\pm 0.57$}&{67.53 \tiny{$\pm 0.08$}}\(^1\)&{65.29 \tiny{$\pm 0.10$}}\(^1\)\\
\cdashline{1-9}[2pt/2pt]
\quad w/ AANets (Reproduced) &46.87 \tiny{$\pm 0.66$}&47.34 \tiny{$\pm $ 0.77}&47.35 \tiny{$\pm 0.95$}&72.91 \tiny{$\pm 0.45$} & 71.93 \tiny{$\pm 0.52$}& 70.70 \tiny{$\pm 0.46$}&63.37 \tiny{$\pm 0.26$}&62.46 \tiny{$\pm 0.14$}\\
\rowcolor{black!15}
\quad w/ AANets + \emph{Ours}& \textbf{49.02} \tiny{$\pm 1.07$}&\textbf{49.84} \tiny{$\pm 0.87$}&\textbf{51.33} \tiny{$\pm 1.42$}&73.79 \tiny{$\pm 0.42$} &73.73 \tiny{$\pm 0.37$}&\textbf{73.47} \tiny{$\pm 0.35$}&64.99 \tiny{$\pm 0.13$}&63.04 \tiny{$\pm 0.11$}\\
\cdashline{1-9}[2pt/2pt]
\quad w/ DDE (Reproduced) & 45.86 \tiny{$\pm 0.65$}&46.48 \tiny{$\pm 0.69$}&46.46 \tiny{$\pm 0.33$}& 73.04 \tiny{$\pm 0.36$}& 70.84 \tiny{$\pm 0.59$}& 66.61 \tiny{$\pm 0.68$}& {66.95 \tiny{$\pm 0.09$}}\(^1\)& {65.21 \tiny{$\pm 0.05$}}\(^1\)\\
\rowcolor{black!15}
\quad w/ DDE + \emph{Ours} &47.16 \tiny{$\pm 0.60$}&48.33 \tiny{$\pm 0.48$}&48.37 \tiny{$\pm 0.34$}&75.12 \tiny{$\pm 0.17$}&73.39 \tiny{$\pm 0.29$}&70.83 \tiny{$\pm 0.34$}&{67.90 \tiny{$\pm 0.05$}}\(^1\)&{\textbf{66.67} \tiny{$\pm 0.23$}}\(^1\)\\
\specialrule{0.01em}{1.2pt}{1.5pt}
PODNet \citep{douillard2020podnet} &44.92 \tiny{$\pm 0.31$}&44.49 \tiny{$\pm 0.65$}&43.79 \tiny{$\pm 0.44$}& 75.54 & 74.33 & 68.31 & 66.95 & 64.13 \\
\quad w/ AANets \citep{liu2021adaptive} &-- &-- &-- & 76.96 & 75.58 & 71.78 & 67.73 & 64.85\\
\quad w/ DDE \citep{hu2021distilling} &-- &-- &-- & 76.71 & 75.41 & -- & 66.42\(^2\) & 64.71 \\
\rowcolor{black!15}
\quad w/ \emph{Ours} &46.00 \tiny{$\pm 0.28$}&46.09 \tiny{$\pm 0.37$}&45.84 \tiny{$\pm 0.43$}& \textbf{78.08} \tiny{$\pm 0.66$}& \textbf{76.02} \tiny{$\pm 0.54$}& 72.72 \tiny{$\pm 0.74$} &\textbf{68.91} \tiny{$\pm 0.16$}&66.31 \tiny{$\pm 0.26$}\\
\specialrule{0.01em}{1.2pt}{1.7pt}
\end{tabular}
}
\label{table:classification_result}
\vspace{-.4cm}
\end{table*}
\textbf{Baseline}:
We evaluate representative memory replay approaches such as LwF \citep{li2017learning}, iCaRL \citep{rebuffi2017icarl}, BiC \citep{wu2019large}, LUCIR \citep{hou2019learning}, Mnemonics \citep{liu2020mnemonics}, TPCIL \citep{tao2020topology}, PODNet \citep{douillard2020podnet}, DDE \citep{hu2021distilling} and AANets \citep{liu2021adaptive}. In particular, AANets and DDE are the \emph{recent strong approaches} implemented on the backbones of LUCIR and PODNet, so we also implement ours on the two backbones. Since both AANets and DDE only release their official implementation on LUCIR, we further reproduce LUCIR w/ AANets and LUCIR w/ DDE for fair comparison.
\textbf{Accuracy:}
We summarize the performance of the above baselines and memory replay with data compression (ours) in Table \ref{table:classification_result}.
Using the same extra storage space, ours achieves comparable or better performance than AANets and DDE on the same backbone approaches, and can further boost their performance by a large margin.
The improvement from ours is due to mitigating the averaged forgetting, detailed in Appendix E.3.
For CUB-200-2011 with only a few training samples, all old data can be saved in the memory buffer with a high JPEG quality of 94. In contrast, for ImageNet-sub/-full, only a part of old training samples can be selected, compressed and saved in the memory buffer, where our method can efficiently determine the compression quality for LUCIR and PODNet (see Sec. 4.3 and Appendix D.2), and for AANets and DDE (see Appendix D.3).
\begin{wrapfigure}{r}{0.60\textwidth}
\centering
\includegraphics[width=0.95\linewidth]{Time+Accuracy_ImageNet-sub}
\vspace{-0.3cm}
\caption{Averaged incremental accuracy (the column, left Y-axis) and computational cost (the triangle, right Y-axis) on ImageNet-sub. We run each baseline with one Tesla V100.}
\vspace{-0.5cm}
\label{Time_Accuracy}
\end{wrapfigure}
\textbf{Computational Cost:}
Limiting the size of memory buffer is not only to save its storage, but also to save the extra computation of learning all old training samples again. Here we evaluate the computational cost of AANets, DDE and memory replay with data compression (ours) on LUCIR (see Fig.~\ref{Time_Accuracy} for ImageNet-sub and Appendix Table \ref{table:time_cost} for CUB-200-2011). Both AANets and DDE require a huge amount of extra computation to improve the performance of continual learning, which is generally \emph{several times} that of the backbone approach. In contrast, ours achieves competing or more performance improvement but only slightly increases the computational cost.
\begin{figure}[h]
\centering
\vspace{-0.1cm}
\includegraphics[width=1\linewidth]{Buffer_Size}
\vspace{-0.5cm}
\caption{The effects of different storage space (equal to 10, 20, 40 and 80 original images per class) on ImageNet-sub. LUCIR (a) and PODNet (b) are reproduced from their officially-released codes.}
\label{Buffer_Size}
\vspace{-0.1cm}
\end{figure}
\textbf{Storage Space:}
The impact of storage space is evaluated in Fig.~\ref{Buffer_Size}.
Limiting the storage space to equivalent of 10, 20, 40 and 80 original images per class, ours can improve the performance of LUCIR and PODNet by a similar margin, where the improvement is generally more significant for more splits of incremental phases. Further, ours can achieve consistent performance improvement when using a fixed memory budget (detailed in Appendix E.4), and can largely save the storage cost without performance decrease when storing less compressed samples (detailed in Appendix E.5).
\subsection{Large-Scale Object Detection}
\begin{wrapfigure}{r}{0.60\textwidth}
\vspace{-.1cm}
\centering
\includegraphics[width=0.60\columnwidth]{SODA10M_Acc_Rq}
\vspace{-.6cm}
\caption{We present the grid search results (left), \(R_q\) in each incremental phase (middle), and the averaged \(R_q\) of all incremental phases (right) for SSCL on SODA10M. The quality determined by our method is 50, which indeed achieves the best performance in the grid search.}
\vspace{-.2cm}
\label{SODA10M_Rq}
\end{wrapfigure}
The advantages of memory replay with data compression are more significant in realistic scenarios such as autonomous driving, where the incremental data are extremely large-scale with huge storage cost. Here we evaluate continual learning on SODA10M \citep{han2021soda10m}, a large-scale object detection benchmark for autonomous driving.
SODA10M contains 10M unlabeled images and 20K labeled images of size \(1920 \times 1080\) with default format of JPEG, which is much larger than the scale of ImageNet. The labeled images are split into 5K, 5K and 10K for training, validation and testing, respectively, annotating 6 classes of road objects for detection.
\begin{wraptable}{r}{8.4 cm}
\centering
\vspace{-.4cm}
\caption{Detection results with \(\pm\) standard deviation (\%) of semi-supervised continual learning on SODA10M. FT: finetuning. MR: memory replay.}
\smallskip
\resizebox{0.60\textwidth}{!}{
\begin{tabular}{ccccc}
\specialrule{0.01em}{1.2pt}{1.5pt}
&Method &$\rm{AP}$ &$\rm{AP}_{50}$ &$\rm{AP}_{75}$ \\
\specialrule{0.01em}{1.2pt}{1.7pt}
\multirow{3}*{\tabincell{c}{Pseudo \\ Labeling}}
&FT &40.36 {\tiny{$\pm 0.34$}}&63.83 {\tiny{$\pm 0.35$}}&43.82 {\tiny{$\pm 0.34$}}\\
&MR &40.75 {\tiny{$\pm 0.30$}} / +0.39&65.11 {\tiny{$\pm 0.64$}} / +1.28&43.53 {\tiny{$\pm 0.20$}} / -0.29 \\
&Ours&\textbf{41.50 {\tiny{$\pm 0.06$}} / +1.14}&\textbf{65.36 {\tiny{$\pm 0.47$}} / +1.53}&\textbf{44.95 {\tiny{$\pm 0.22$}} / +1.13}\\
\specialrule{0.01em}{1.2pt}{1.7pt}
\multirow{3}*{\tabincell{c}{Unbiased \\ Teacher}}
&FT &42.88 {\tiny{$\pm 0.32$}}&66.70 {\tiny{$\pm 0.59$}}&45.99 {\tiny{$\pm 0.32$}}\\
&MR &43.10 {\tiny{$\pm 0.06$}} / +0.22 &66.88 {\tiny{$\pm 0.51$}} / +0.18 &46.62 {\tiny{$\pm 0.02$}} / +0.63 \\
&Ours&\textbf{43.72 {\tiny{$\pm 0.25$}} / +0.84} &\textbf{67.80 {\tiny{$\pm 0.46$}} / +1.10} &\textbf{47.36 {\tiny{$\pm 0.23$}} / +1.37} \\
\specialrule{0.01em}{1.2pt}{1.7pt}
\end{tabular}
}
\label{table:SODA10M}
\vspace{-.2cm}
\end{wraptable}
Since the autonomous driving data are typically partially-labeled, we follow the semi-supervised continual learning (SSCL) proposed by \cite{wang2021ordisco} for object detection. Specifically, we randomly split 5 incremental phases containing 1K labeled data and 20K unlabeled data per phase, and use a memory buffer to replay labeled data. The storage space is limited to the equivalent of 100 original images per phase. Following \cite{han2021soda10m}, we consider Pseudo Labeling and Unbiased Teacher \citep{liu2021unbiased} for semi-supervised object detection (the implementation is detailed in Appendix B.2).
Using the method described in Sec. 4.2 with the same threshold (i.e., \(\epsilon=0.5\)), we can efficiently determine the compression quality for SSCL of object detection, and validate that the determined quality indeed achieves the best performance in grid search (see Fig. \ref{SODA10M_Rq}). Then, compared with memory replay of original data, our proposal can generally achieve \emph{several times} of the performance improvement on finetuning, as shown in Table \ref{table:SODA10M}.
\section{Conclusion}
In this work, we propose that using data compression with a properly selected compression quality can largely improve the efficacy of memory replay by saving more compressed data in a limited storage space.
To efficiently determine the compression quality, we provide a novel method based on determinantal point processes (DPPs) to avoid repetitive training, and validate our method in both class-incremental learning and semi-supervised continual learning of object detection. Our work not only provides an important yet under-explored baseline, but also opens up a promising new avenue for continual learning. Further work could develop adaptive compression algorithms for incremental data to improve the compression rate, or propose new regularization methods to constrain the distribution changes caused by data compression. Meanwhile, the theoretical analysis based on DPPs can be used as a general framework to integrate optimizable variables in memory replay, such as the strategy of selecting prototypes.
In addition, our work suggests how to save a batch of training data in a limited storage space to best describe its distribution, which will motivate broader applications in the fields of data compression and data selection.
\section*{Acknowledgements}
This work was supported by
NSF of China Projects (Nos. 62061136001, 61620106010, 62076145, U19B2034, U181146), Beijing NSF Project (No. JQ19016),
Beijing Outstanding Young Scientist Program NO. BJJWZYJH012019100020098,
Tsinghua-Peking Center for Life Sciences, Beijing Academy of Artificial Intelligence (BAAI), Tsinghua-Huawei Joint Research Program, a grant from Tsinghua Institute for Guo Qiang, and the NVIDIA NVAIL Program with GPU/DGX Acceleration, Major Innovation \& Planning Interdisciplinary Platform for the ``Double-First Class" Initiative, Renmin University of China.
\section*{Ethic Statement}
This work presents memory replay with data compression for continual learning. It can be used to reduce the storage requirement in memory replay and thus may facilitate large-scale applications of such methods to real-world problems (e.g., autonomous driving).
As a fundamental research in machine learning, the negative consequences in the current stage are not obvious.
\section*{Reproducibility Statement }
We ensure the reproducibility of our paper from three aspects.
(1) Experiment: The implementation of our experiment described in Sec. 4.1, Sec. 4.3 and Sec. 5 is further detailed in Appendix B.
(2) Code: Our code is included in supplementary materials.
(3) Theory and Method: A complete proof of the theoretical results described in Sec. 4.2 is included in Appendix C.
\clearpage
|
{'timestamp': '2022-02-15T02:40:40', 'yymm': '2202', 'arxiv_id': '2202.06592', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06592'}
|
arxiv
|
\section{Introduction}\label{sec:intro}
Ensembling methods have been widely used to improve the generalization performance of machine learning methods \cite{dietterich2000ensemble,zhou2012ensemble,caruana2004ensemble,dvzeroski2004combining}. However, they struggle to apply in learning with modern deep neural networks (DNNs). A modern DNN often has millions, even billions, of parameters, see e.g., \cite{beal2022billion}. A direct ensembling of $k$ DNNs leads to a $k$-folded computational overhead in terms of training time, memory requirement, and test-time prediction.
Nevertheless, important advances have been made recently in adapting the idea of ensembling to improve deep learning. For instance, the fast geometric ensembling (FGE) and snapshot ensemble (SNE) methods can train an ensemble of DNNs in the same time as a single model, thus getting around the hurdle of training time \cite{garipov2018loss,huang2017snapshot}. However, their computational overhead of training-time model recording and test-time predictions remain much higher than their single model based counterparts. To reduce the test-time cost of ensembles, \cite{bucilua2006model,hinton2015distilling} propose methods for model compression and knowledge distillation, which aim to train one single model to encompass the ``knowledge" of the ensembles. However, such methods do not consider the computational overhead due to ensemble training.
For the aforementioned methods, the computational overhead remains prohibitively high for many real-life applications with limited budgets for saving and deploying the model ensembles.
In this paper, we present PFGE, a parsimonious version of FGE, which aims to reduce both the training-time and the test-time computational overhead yielded from DNNs ensembling. Compared with state-of-the-art (SOTA) methods, PFGE achieves better generalization performance and satisfactory calibration capability, while the computational overhead of model recording and test-time predictions is significantly reduced. The design of PFGE is inspired by an observation of that running one time of stochastic weight averaging (SWA) procedure can lead to a wider optimum \cite{izmailov2018averaging}, and performing a series of SWA procedures successively could find a set of higher-performing weights than those obtained by stochastic gradient descend (SGD) \cite{guo2022stochastic}. FGE employs an ensemble of models found by SGD. We expect that, by employing an ensemble of higher-performing models found by SWA, PFGE could use much fewer model ensembles to yield a comparable performance with FGE.
As PFGE reduces both the training and test-time computational overhead without a compromise in generalization, we believe that the appearance of PFGE can remove the obstacle to a large extent in applying ensemble methods for diverse DNN applications.
Our contributions can be summarized as follows:
\begin{itemize}
\item We propose a novel, generic, and architecture-agnostic ensemble-based algorithm, referred to as PFGE, for improving DNNs in terms of generalization and calibration. PFGE maintains the full advantage of FGE in high training efficiency and desirable generalization performance, while remarkably reduces its computational overhead of model recording and test-time predictions. To our knowledge, PFGE is by far the only ensemble-based algorithm that targets reducing both the training and test-time computational overhead yielded from DNN ensembling.
\item We empirically demonstrate that employing higher-performing DNNs is an effective strategy for reducing the requirement on the number of models for ensemble-based deep learning.
\item We propose a novel SWA-based approach to generate higher-performing models, in terms of generalization and mode connectivity, for ensemble-based deep learning.
\item We perform extensive experiments to test the performance of our algorithm. Results show a multifaceted advantage of our algorithm over competitors, including a better balance between generalization, calibration and computational overhead, the capability of generating model components with better generalization and mode connectivity.
\end{itemize}
\section{Related Works}\label{sec:related}
\textbf{Optimization algorithms for training DNNs}
SGD is by far the \emph{de facto} optimization approach to train DNNs. A decaying learning rate (LR) is the standard configuration for SGD. A commonly used strategy for improving SGD in terms of generalization is to design better LRs. For instance, the AdaGrad method estimates the LR online from the gradients \cite{duchi2011adaptive}. AdaGrad is further improved in \cite{kingma2014adam}, where the resulting algorithm is referred to as AdaDelta. The Adam algorithm is proposed in \cite{kingma2014adam}, which combines the advantages of AdaGrad and RMSProp \cite{tieleman2012rmsprop}. In \cite{schaul2013no}, the diagonal approximation of the Hessian of the gradients is used for designing adaptive LRs. As the literature on this topic is vast, we could not enumerate due to space limitation. We refer interested readers to \cite{sun2019optimization} and references therein for more details.
The above optimization-based approaches are all single model based. In this paper, we focus on ensemble methods that is featured by the application of multiple models for improving DNN performance in terms of generalization and calibration.
\textbf{Bayesian methods for learning with neural networks}
Since the seminal works of \cite{neal2012bayesian,mackay1992practical}, Bayesian methods have been extensively investigated in neural network based machine learning. Such methods have desirable theoretical properties, especially in terms of uncertainty qualification. However, they are largely computationally intractable when facing modern DNNs, due to an extremely high dimension of the model parameter and a strong non-convexity of the posterior distribution.
\cite{neal2012bayesian} proposes Hamiltonian Monte Carlo (HMC), a powerful iterative sampling method that can handle non-convex posteriors, while it requires full gradients at each iteration, thus is computationally prohibitive for training with massive data points. A common wisdom used for training with large scale datasets is to iteratively train with mini-batch samples, which is scalable and able to discover good solution subspaces \cite{keskar2017large}. Stochastic gradient HMC (SGHMC) extends HMC by using mini-batch sample based stochastic gradients \cite{chen2014stochastic}. \cite{welling2011bayesian} introduces the first order Langevin dynamics into the framework of stochastic gradient based Markov Chain Monte Carlo setting (SG-MCMC). \cite{mandt2017stochastic} provide a theoretical tie that connects SG-MCMC to SGD and its variants, and analyze their approximation errors.
Outside of MCMC, variational inference and sequential Monte Carlo methods are also explored for large scale training, see e.g., \cite{hoffman2013stochastic,graves2011practical,liu2020particle}, while it is quite difficult for balancing computational efficiency with approximation errors when adapting them to modern DNNs.
Our PFGE algorithm acts as a much more computationally efficient subspace-based posterior sampling approach, which is applicable for modern DNNs. Its desirable performance in terms of computational efficiency, generalization, and calibration is due to a novel algorithm design that combines SWA and FGE, which makes full use of recently revealed geometric insights regarding the DNN loss landscape.
\textbf{Ensembling methods adapted to DNNs}
As aforementioned, ensemble methods are often computationally intractable for learning with modern DNNs, due to an extremely high overhead of ensemble training, model recording, and test-time predictions. Nevertheless, notable advances have been made to adapt ensemble methods to DNNs, such as FGE \cite{garipov2018loss}, SNE \cite{huang2017snapshot}, SWA-Gaussian (SWAG) \cite{maddox2019simple}, Monte-Carlo dropout \cite{gal2016dropout}, and deep ensembles \cite{fort2019deep,lakshminarayanan2017simple}. Among these modern approaches, FGE, SNE and SWAG are most related to this work, as they all employ a cyclical LR to generate the model ensembles in the same time as one single model.
Both FGE and SNE build DNN ensembles by sampling network weights from an SGD trajectory corresponding to a cyclical LR \cite{smith2017cyclical}. Running an SGD with a cyclical LR is in principle equivalent to SGD sampling with periodic warm restarts \cite{loshchilov2017sgdr}. \cite{huang2017snapshot,garipov2018loss} demonstrate that the cyclical LR indeed provides a highly efficient way to collect high-quality DNN weights, which define the models for ensembling.
Compared with SNE, FGE is featured by a geometric explanation of its way to generating the ensembles. Specifically, FGE is inspired by one geometric insight about the DNN loss landscape, which says that there exist simple curves that connect local optima of the DNN loss landscape, and over these curves, both the training accuracy and the test accuracy remain approximately constant. FGE provides an efficient way to discover the high-accuracy pathways between local optima.
Inspired by FGE, SWA is proposed, which averages the high-performing network weights yielded by FGE for test-time inference \cite{izmailov2018averaging}. The geometric insight underlying SWA is that averaging weights along an SGD trajectory corresponding to a cyclical or constant LR can find wider optima, and wider optima lead to better generalization. This insight is questioned by \cite{guo2022stochastic}, which shows that the real function of SWA's weight averaging operation lies in reducing the variance of the final output, similarly to tail-averaging \cite{jain2018parallelizing}.
SWAG uses the SWA solution as the center of a Gaussian distribution, which is formed to approximate the posterior of the network weights \cite{maddox2019simple}. SWAG generates the model ensembles by sampling from this Gaussian.
PFGE represents a novel SOTA algorithm for ensemble-based deep learning, featured by its competitive performance, in terms of generalization and calibration, compared with related SOTA methods, and a much-reduced computational overhead of memory and test-time predictions.
\begin{algorithm}[!htb]
\caption{SWA based model training and test-time prediction}
\label{alg:swa}
\textbf{Input}: initial network weights $w_{0}$, cyclical LR schedule $SC$, cycle length $c$, budget (the total number of allowable iterations) $n$, test data $x$\\
\textbf{Output}: predicted label $y$ of $x$
\begin{algorithmic}[1]
\STATE $w\leftarrow w_{0}$; solution set $\mathcal{S}\leftarrow \{\}$.
\STATE $w_{\tiny{\mbox{SWA}}}\leftarrow w$.
\FOR{$i\leftarrow 1,2,\ldots,n$}
\STATE Compute current learning rate $\alpha$ according to $SC$.
\STATE $w\leftarrow w-\alpha\bigtriangledown \mathcal{L}_i(w)$ (stochastic gradient update).
\IF {mod($i$,$c$)=0}
\STATE $n_{\tiny{\mbox{models}}}\leftarrow i/c$ (number of models averaged).
\STATE $w_{\tiny{\mbox{SWA}}}\leftarrow \left(w_{\tiny{\mbox{SWA}}}\cdot n_{\tiny{\mbox{models}}}+w\right)/\left(n_{\tiny{\mbox{models}}}+1\right)$.
\ENDIF
\ENDFOR
\STATE Input $x$ into the DNN with weights $w_{\tiny{\mbox{SWA}}}$, then compute the its softmax output.
\STATE \textbf{return} $y$ that maximizes the above softmax output.
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[!htb]
\caption{FGE based model training and test-time prediction}
\label{alg:fge}
\textbf{Input}: initial network weights $w_{0}$, cyclical LR schedule $SC$, cycle length $c$, budget (the total number of allowable iterations) $n$, test data $x$\\
\textbf{Output}: predicted label $y$ of $x$
\begin{algorithmic}[1]
\STATE $w\leftarrow w_{0}$; solution set $\mathcal{S}\leftarrow \{\}$.
\FOR{$i\leftarrow 1,2,\ldots,n$}
\STATE Compute current learning rate $\alpha$ according to $SC$.
\STATE $w\leftarrow w-\alpha\bigtriangledown \mathcal{L}_i(w)$ (stochastic gradient update).
\IF {mod($i$,$c$)=0}
\STATE Add $w$ into $\mathcal{S}$ (collect weights).
\ENDIF
\ENDFOR
\STATE Given $x$ as the input, compute the average of softmax outputs of models included in $\mathcal{S}$.
\STATE \textbf{return} $y$ that maximizes the above averaged softmax output.
\end{algorithmic}
\end{algorithm}
\textbf{Uncertainty calibration for DNNs}
Uncertainty calibration is crucially important for robust decision-making and model interpretability \cite{guo2017calibration}. It aims to provide a calibrated, more accurate confidence measure for each prediction provided by a DNN model.
Ensemble methods provide a natural mechanism for uncertainty calibration. \cite{maddox2019simple} suggests uncertainty calibration of DNNs via sampling from the Gaussian approximation to the posterior given by SWAG, and then doing Bayesian model averaging over those samples. \cite{lakshminarayanan2016simple} propose incorporating an adversarial loss function into the ensemble for enhanced calibration.
Outside of ensemble methods, the rescaling techniques are commonly used for enhancing calibration. They work by rescaling the logits of DNN outputs \cite{guo2017calibration,kuleshov2018accurate}.
As an ensemble method, PFGE can be naturally used for uncertainty calibration. We test its calibration performance in Section \ref{sec:experiments}.
\section{The Proposed PFGE Algorithm}
Our PFGE algorithm is developed based on SWA and FGE.
We present the pseudo-codes to implement SWA, FGE, and PFGE in Algorithms \ref{alg:swa}, \ref{alg:fge}, and \ref{alg:pfge}, respectively.
They all perform stochastic gradient based weight updating iteratively, starting at a local optimum $w_0$ given by a preceding SGD phase or a pre-trained DNN model.
\begin{algorithm}[!htb]
\caption{PFGE based model training and test-time prediction}
\label{alg:pfge}
\textbf{Input}: initial network weights $w_{0}$, cyclical LR schedule $SC$, cycle length $c$, budget (the total number of allowable iterations) $n$, test data $x$, model recording period $P$ \\
\textbf{Output}: predicted label $y$ of $x$
\begin{algorithmic}[1]
\STATE $w\leftarrow w_{0}$; solution set $\mathcal{S}\leftarrow \{\}$.
\STATE $w_{\tiny{\mbox{SWA}}}\leftarrow w$.
\STATE $n_{\tiny{\mbox{recorded}}}\leftarrow 0$ (number of models recorded in $\mathcal{S}$).
\FOR{$i\leftarrow 1,2,\ldots,n$}
\STATE Compute current learning rate $\alpha$ according to $SC$.
\STATE $w\leftarrow w-\alpha\bigtriangledown \mathcal{L}_i(w)$ (stochastic gradient update).
\STATE $j\leftarrow i-n_{\tiny{\mbox{recorded}}}\times P$ (iterate index for the follow-up SWA procedure).
\IF {mod($j$,$c$)=0}
\STATE $n_{\tiny{\mbox{models}}}\leftarrow j/c$ (number of models that have been averaged within the current SWA procedure).
\STATE $w_{\tiny{\mbox{SWA}}}\leftarrow \left(w_{\tiny{\mbox{SWA}}}\cdot n_{\tiny{\mbox{models}}}+w\right)/\left(n_{\tiny{\mbox{models}}}+1\right)$.
\ENDIF
\IF {mod($i$,$P$)=0}
\STATE Add $w_{\tiny{\mbox{SWA}}}$ into $\mathcal{S}$ (collect weights).
\STATE $w\leftarrow w_{\tiny{\mbox{SWA}}}$ (initialization for the follow-up SWA procedure).
\STATE $n_{\tiny{\mbox{recorded}}}\leftarrow i/P$ (number of models recorded in $\mathcal{S}$).
\ENDIF
\ENDFOR
\STATE Given $x$ as the input, compute the average of softmax outputs of models recorded in $\mathcal{S}$.
\STATE \textbf{return} $y$ that maximizes the above averaged softmax output.
\end{algorithmic}
\end{algorithm}
The iterative weight updating operation employs a cyclical LR for letting the weight trajectory escape from the current optimum, and then discover and converge to novel local optima. A conceptual diagram of the cyclical LR is shown in Figure \ref{fig:lrs}, where $\alpha_1$ and $\alpha_2$ bound the LR values, $c$ denotes the cycle length, $n$ the total number of allowable iterations that define the budget of training time, $P$ the model recording period for PFGE.
\begin{figure}[htbp]
\vskip 0.2in
\begin{center}
\centerline{\includegraphics[width=\columnwidth]{LRS.eps}}
\caption{A conceptual diagram of the cyclical LR used by SWA, FGE and PFGE. The circles mask the time instances for recording the local optima discovered along the SGD trajectory. The real relationship between $c$, $P$, and $n$ is that $P$ is an integer multiple of $c$, and $n$ is an integer multiple of $P$. Here only one example case is plotted, in which $P=2c$ and $n=2P$. See the text for detailed explanations for all parameters involved.}
\label{fig:lrs}
\end{center}
\vskip -0.2in
\end{figure}
As shown in Algorithm \ref{alg:swa}, SWA maintains a running average of the network weights that are recorded at every $c$ iterations, and finally outputs a single model with weight $w_{\tiny{\mbox{SWA}}}$ for test-time prediction. $w_{\tiny{\mbox{SWA}}}$ is in fact the average of $(\frac{n}{c}+1)$ weights traversed along the SGD trajectory.
As shown in Algorithm \ref{alg:fge}, FGE uses the same mechanism as SWA to find $(\frac{n}{c}+1)$ local optima. Different from SWA that uses the average of those local optima for test-time prediction, FGE maintains an ensemble of $(\frac{n}{c}+1)$ models defined by those local optima. Its test-time prediction is made based on the average of the model ensembles' softmax outputs.
Compared with using one single DNN, using FGE requires $(\frac{n}{c}+1)$ times memory for recording the model components, and $(\frac{n}{c}+1)$ times computational overhead of test-time predictions. PFGE reduces the multiple number $(\frac{n}{c}+1)$ to $(\frac{n}{P}+1)$. Note that $P$ is integer multiples of $c$, as exemplifies in Figure \ref{fig:lrs}.
PFGE differentiates with FGE in the way to generate the ensemble models. For FGE, its ensemble models are generated purely by SGD (see operations 4 and 6 in Algorithm \ref{alg:fge}), while PFGE resorts to multiple SWA operations performed in succession (see operations 10 and 13 in Algorithm \ref{alg:pfge}) to generate the models. In the successively performed SWA procedures, the output of an SWA procedure is used to initialize its follow-up SWA procedure (see operation 14 in Algorithm \ref{alg:pfge}).
The recently reported Double SWA (DSWA) and Triple SWA (TSWA) methods also use the strategy of performing multiple SWA procedures successively \cite{guo2022stochastic}. Both DSWA and TSWA output a single model, while PFGE maintains an ensemble of multiple models, for test-time prediction.
As SWA is capable of finding local optima with better generalization \cite{izmailov2018averaging}, we replace the iterative SGD procedure in FGE with a series of successively performed SWA procedures for generating an ensemble of higher-performing models, yielding the PFGE algorithm. In the following section, we present experimental results, which demonstrate the desirable performance of PFGE in terms of generalization and calibration compared with SOTA methods.
\section{Experiments}\label{sec:experiments}
We compare PFGE against SOTA methods FGE \cite{garipov2018loss}, SWA \cite{izmailov2018averaging}, and SWAG \cite{maddox2019simple}, on CIFAR-10 \cite{krizhevsky2009learning}, CIFAR-100 \cite{krizhevsky2009learning}, and ImageNet ILSVRC-2012 \cite{deng2009imagenet,russakovsky2015imagenet}, to test its performance in terms of generalization and uncertainty calibration.
\begin{table*} \tiny
\caption{Test accuracy, NLL, and ECE on CIFAR-10. The best results for each architecture are \textbf{bolded}.}
\label{table:big_table_cifar}
\begin{tabular}{c|c|c|c}
\hline
& Test Accuracy (\%) & NLL (\%) & ECE (\%) \\
\begin{tabular}{c}
Algorithm \\ \hline PFGE \\ FGE \\ SWA \\ SWAG \\ \hline FGE-whole \\ SWAG-whole
\end{tabular}
& \begin{tabular}{ccc}
VGG16 & PreResNet & WideResNet \\ \hline
\textbf{93.41}$_{\pm0.08}$ & 95.70$_{\pm0.05}$ & 96.37$_{\pm0.03}$\\
93.03$_{\pm0.18}$ & 95.52$_{\pm0.08}$ & 96.14$_{\pm0.07}$\\
93.33$_{\pm0.02}$ & \textbf{95.78}$_{\pm0.07}$ & \textbf{96.47}$_{\pm0.04}$\\
93.24$_{\pm0.06}$ & 95.45$_{\pm0.14}$ & 96.36$_{\pm0.04}$\\ \hline
93.40$_{\pm0.08}$ & 95.57$_{\pm0.05}$ & 96.27$_{\pm0.02}$\\
93.37$_{\pm0.07}$ & 95.61$_{\pm0.11}$ & 96.45$_{\pm0.07}$\\
\end{tabular}
& \begin{tabular}{ccc}
VGG16 & PreResNet & WideResNet \\ \hline
26.16$_{\pm0.08}$ & \textbf{13.05}$_{\pm0.10}$ & \textbf{11.04}$_{\pm0.05}$\\
25.25$_{\pm0.60}$ & 13.60$_{\pm0.11}$ & 11.73$_{\pm0.15}$\\
28.06$_{\pm0.20}$ & 13.50$_{\pm0.07}$ & 11.22$_{\pm0.11}$\\
\textbf{24.58}$_{\pm0.06}$ & 13.71$_{\pm0.13}$ & 11.43$_{\pm0.19}$\\ \hline
21.89$_{\pm0.53}$ & 13.07$_{\pm0.10}$ & 11.18$_{\pm0.06}$\\
23.10$_{\pm0.29}$ & 13.12$_{\pm0.08}$ & 11.07$_{\pm0.17}$\\
\end{tabular}
& \begin{tabular}{ccc}
VGG16 & PreResNet & WideResNet \\ \hline
3.80$_{\pm0.08}$ & 0.54$_{\pm0.15}$ & 0.62$_{\pm0.02}$\\
\textbf{3.12}$_{\pm0.09}$ & \textbf{0.49}$_{\pm0.09}$ & \textbf{0.32}$_{\pm0.08}$\\
4.44$_{\pm0.07}$ & 1.21$_{\pm0.09}$ & 11.33$_{\pm0.04}$\\
3.21$_{\pm0.03}$ & 0.75$_{\pm0.12}$ & 1.03$_{\pm0.05}$\\ \hline
2.24$_{\pm0.08}$ & 0.39$_{\pm0.06}$ & 0.30$_{\pm0.08}$\\
3.01$_{\pm0.10}$ & 0.53$_{\pm0.09}$ & 0.78$_{\pm0.05}$\\
\end{tabular}
\\ \hline
\end{tabular}
\end{table*}
\begin{table*} \tiny
\caption{Test accuracy, NLL, and ECE on CIFAR-100. The best results for each architecture are \textbf{bolded}.}
\label{table:big_table_cifar100}
\begin{tabular}{c|c|c|c}
\hline
& Test Accuracy (\%) & NLL (\%) & ECE (\%) \\
\begin{tabular}{c}
Algorithm \\ \hline PFGE \\ FGE \\ SWA \\ SWAG \\ \hline FGE-whole \\ SWAG-whole
\end{tabular}
& \begin{tabular}{ccc}
VGG16 & PreResNet & WideResNet \\ \hline
\textbf{74.17}$_{\pm0.04}$ & \textbf{80.06}$_{\pm0.13}$ & \textbf{81.96}$_{\pm0.01}$\\
73.49$_{\pm0.24}$ & 79.76$_{\pm0.06}$ & 81.09$_{\pm0.25}$\\
73.83$_{\pm0.20}$ & 79.97$_{\pm0.06}$ & 81.92$_{\pm0.02}$\\
73.77$_{\pm0.18}$ & 79.24$_{\pm0.04}$ & 81.55$_{\pm0.06}$\\ \hline
74.34$_{\pm0.05}$ & 80.17$_{\pm0.09}$ & 81.62$_{\pm0.16}$\\
74.15$_{\pm0.17}$ & 80.00$_{\pm0.03}$ & 81.83$_{\pm0.12}$\\
\end{tabular}
& \begin{tabular}{ccc}
VGG16 & PreResNet & WideResNet \\ \hline
132.85$_{\pm0.19}$ & \textbf{72.07}$_{\pm0.34}$ & \textbf{65.00}$_{\pm0.14}$\\
125.77$_{\pm0.20}$ & 72.75$_{\pm0.18}$ & 68.91$_{\pm0.18}$\\
143.23$_{\pm0.57}$ & 76.88$_{\pm0.43}$ & 69.57$_{\pm0.39}$\\
\textbf{122.87}$_{\pm0.88}$ & 74.37$_{\pm0.14}$ & 68.09$_{\pm0.25}$\\ \hline
109.93$_{\pm0.51}$ & 69.26$_{\pm0.23}$ & 63.54$_{\pm0.24}$\\
117.25$_{\pm0.62}$ & 71.07$_{\pm0.15}$ & 66.37$_{\pm0.29}$\\
\end{tabular}
& \begin{tabular}{ccc}
VGG16 & PreResNet & WideResNet \\ \hline
13.95$_{\pm0.07}$ & 5.05$_{\pm0.23}$ & 4.24$_{\pm0.02}$\\
11.80$_{\pm0.19}$ & \textbf{3.41}$_{\pm0.12}$ & \textbf{2.84}$_{\pm0.32}$\\
16.42$_{\pm0.29}$ & 7.56$_{\pm0.14}$ & 6.89$_{\pm0.12}$\\
\textbf{11.20}$_{\pm0.03}$ & 4.74$_{\pm0.03}$ & 5.22$_{\pm0.07}$\\ \hline
8.84$_{\pm0.01}$ & 1.92$_{\pm0.19}$ & 1.15$_{\pm0.04}$\\
10.99$_{\pm0.11}$ & 3.36$_{\pm0.05}$ & 4.65$_{\pm0.11}$\\
\end{tabular}
\\ \hline
\end{tabular}
\end{table*}
\begin{table*} \tiny
\caption{Test accuracy, NLL, and ECE on Imagenet. The best results for each architecture are \textbf{bolded}.}
\label{table:big_table_imagenet}
\begin{tabular}{c|c|c|c}
\hline
& Test Accuracy (\%) & NLL (\%) & ECE (\%)\\
\begin{tabular}{c}
Algorithm \\ \hline PFGE \\ FGE \\ SWA \\ SWAG \\ \hline FGE-whole \\ SWAG-whole
\end{tabular}
& \begin{tabular}{ccc}
ResNet-50 & ResNet-152 & DenseNet-161 \\ \hline
\textbf{77.28} & \textbf{79.10} & \textbf{78.79}\\
76.77 & 78.71 & 78.45\\
77.13 & 78.84 & 78.75\\
76.49 & 78.75 & 78.15\\ \hline
77.25 & 79.08 & 78.84\\
77.09 & 79.04 & 78.66\\
\end{tabular}
& \begin{tabular}{ccc}
ResNet-50 & ResNet-152 & DenseNet-161 \\ \hline
\textbf{81.08} & \textbf{81.08} & \textbf{82.03}\\
90.47 & 81.91 & 82.87\\
90.90 & 83.40 & 83.47\\
92.02 & 82.00 & 84.91\\ \hline
88.62 & 80.21 & 81.31\\
88.94 & 80.19 & 82.85\\
\end{tabular}
& \begin{tabular}{ccc}
ResNet-50 & ResNet-152 & DenseNet-161 \\ \hline
2.00 & 2.61 & 1.84\\
1.59 & \textbf{1.54} & \textbf{1.51}\\
3.43 & 4.10 & 2.46\\
\textbf{1.54} & 1.85 & 3.22\\ \hline
2.19 & 2.43 & 2.54\\
1.73 & 1.65 & 3.35\\
\end{tabular}
\\ \hline
\end{tabular}
\end{table*}
\subsection{Experimental Setting}\label{sec:experiment_setting}
As shown in Algorithms \ref{alg:swa}-\ref{alg:pfge}, SWA, FGE, and PFGE are all initialized with a local optimum $w_{0}$ and an LR schedule. For all architectures and datasets, we initialize all algorithms in comparison with the same $w_{0}$, and the same LR setting. Following \cite{garipov2018loss}, we use a triangle LR schedule, as shown in Figure \ref{fig:lrs}. Specifically, we set $c$ to iteration numbers corresponding to 2 or 4 epochs (following \cite{garipov2018loss}), $P$ to 10 epochs, and $n$ to 40 or 20 epochs. For $\alpha_1$, and $\alpha_2$, we set them in the same way as in \cite{garipov2018loss}. The mini-batch size for model training is fixed at 128.
For CIFAR-$\{10,100\}$, we obtain $w_{0}$ from running a standard SGD with momentum affiliated by the same type of decaying LR schedule as used in \cite{izmailov2018averaging}, to minimize an $L2$-regularization based cross-entropy loss, until convergence. We set the hyperparameters of SGD, e.g., the weight decaying parameter, the momentum factor, in the same way as in \cite{izmailov2018averaging}. For ImageNet, we use pre-trained models ResNet-50, ResNet-152, and DenseNet-161 contained in PyTorch to initialize $w_{0}$ and fixes $n$ to be the iteration number corresponding to 40 epochs.
The considered performance metrics include test accuracy, negative log-likelihood (NLL), and the expected calibration error (ECE) \cite{guo2017calibration}. The latter two are used for evaluating an algorithm's capability for uncertainty calibration \cite{guo2017calibration,maddox2019simple}.
In our experiments, PFGE always employs 4 model components. It uses the average of those 4 models' softmax outputs for test-time prediction. For FGE and SWAG, we compute test-time predictions by averaging softmax outputs of last 4
models that have been added into their ensemble set $\mathcal{S}$. By this, we guarantee that all algorithms have roughly the same overhead of model recording and test-time predictions. For reference, we also present results of FGE-whole and SWAG-whole, corresponding to FGE and SWAG that use the whole ensemble of models for test-time predictions.
\subsection{CIFAR Datasets}\label{sec:cifar}
We experiment with network architectures VGG16 \cite{simonyan2014very}, Preactivation ResNet-164 (PreResNet-164) \cite{he2016identity}, WideResNet-28-10 \cite{zagoruyko2016wide} on CIFAR-$\{10,100\}$.
\textbf{Test accuracy, NLL and ECE}
We run each algorithm at least 3 times independently, and report the averaged results of test accuracy, NLL, and ECE, and the corresponding standard error in Tables \ref{table:big_table_cifar} and \ref{table:big_table_cifar100}. We bold the best-performing approach for all architectures and datasets.
On CIFAR-10, we find that for VGG16, PFGE has the highest test accuracy (93.41\%). For PreResNet-164 and WideResNet-28-10, PFGE beats FGE and SWAG but loses to SWA in terms of test accuracy; SWA achieves the highest accuracy (95.78\% and 96.47\%) with a comparable NLL score, but gives the worst ECE score.
On CIFAR-100, we find that PFGE performs best in terms of test accuracy for all network architectures. It also gives the best NLL results for PreResNet-164 and WideResNet-28-10. SWAG gives the best calibration for VGG16. FGE gives the best calibration for PreResNet-164 and WideResNet-28-10. SWA performs worst on calibration in terms of both NLL and ECE, for all architectures.
We also find from Tables \ref{table:big_table_cifar} and \ref{table:big_table_cifar100} that, even compared with FGE-whole and SWAG-whole, PFGE achieves a comparable even better performance in terms of test accuracy, with only $20\%$ computational overhead of model recording and test-time predictions. The major advantage of FGE-whole and SWAG-whole lies in their capability of uncertainty calibration. They provides better NLL and ECE scores, compared with PFGE and FGE, for all architectures and datasets.
\textbf{Reliability diagrams}
We plot reliability diagrams in Figure \ref{fig:reliability}, in which FGE and SWAG respectively correspond to FGE-whole and SWAG-whole in Tables \ref{table:big_table_cifar} and \ref{table:big_table_cifar100}. The result in Figure \ref{fig:reliability} re-corroborates FGE-whole and SWAG-whole's advantage and SWA's shortage for uncertainty calibration, and that PFGE behaves in between them in terms of calibration, for all datasets and architectures.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.5\linewidth]{fig7.eps}\includegraphics[width=0.5\linewidth]{fig10.eps}\\
\includegraphics[width=0.5\linewidth]{fig8.eps}\includegraphics[width=0.5\linewidth]{fig11.eps}\\
\includegraphics[width=0.5\linewidth]{fig9.eps}\includegraphics[width=0.5\linewidth]{fig12.eps}
\caption{Reliability diagrams. Left column: CIFAR-10. Right column: CIFAR-100. Top row: VGG16. Middle Row: PreResNet-164. Bottom row: WideResNet-28-10}\label{fig:reliability}
\end{figure}
\textbf{Performance of separate models}
We check the ensemble performance of PFGE and FGE as a function of the training iteration index $i$. The results of an example experiment are shown in Figure \ref{fig:separate}.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.5\linewidth]{fig13.eps}\includegraphics[width=0.5\linewidth]{fig16.eps}\\
\includegraphics[width=0.5\linewidth]{fig14.eps}\includegraphics[width=0.5\linewidth]{fig17.eps}\\
\includegraphics[width=0.5\linewidth]{fig15.eps}\includegraphics[width=0.5\linewidth]{fig18.eps}
\caption{Ensemble performance of PFGE and FGE as a function of the training iteration index $i$. Crosses represent the performance of separate ``snapshot" models, and diamonds show the performance of the ensembles composed of all models available at the given iteration. Left column: CIFAR-10. Right column: CIFAR-100. Top row: VGG16. Middle Row: PreResNet-164. Bottom row: WideResNet-28-10.}\label{fig:separate}
\end{figure}
We find that: (1) the separate models that construct PFGE are indeed higher-performing than those for FGE in terms of test accuracy, for all datasets and network architectures; (2) for both PFGE and FGE, the usage of more model components leads to higher test accuracy; (3) PFGE ensemble outperforms FGE ensemble in all but one cases using fewer model components. Note that the term FGE in Figure \ref{fig:separate} corresponds to FGE-whole in Tables \ref{table:big_table_cifar} and \ref{table:big_table_cifar100}. We believe that it is the higher-quality of the separate model components that makes PFGE achieve a generalization performance comparable to FGE, with a reduced computational overhead due to the usage of fewer model components.
\textbf{Mode connectivity}
In \cite{yang2021taxonomizing}, the authors demonstrate that, when ensembles of trained models converge to locally smooth regions of the loss landscape, the best test accuracy is obtained. That means, the mode connectivity of its model components closely relates to the ensemble's generalization performance. We conduct an experiment to test the mode connectivity of PFGE's model components against that of FGE's.
We randomly select a pair of neighboring model components, denoted by $w$ and $w'$, in the ensemble set $\mathcal{S}$.
Given $w$ and $w'$, we first search a low-energy curve $\gamma(t), t\in[0,1]$, for which $\gamma(0)=w, \gamma(1)=w'$, which minimizes $\int_0^1\mathcal{L}(\gamma(t))dt$, where $\mathcal{L}$ denotes the DNN loss function. Following \cite{yang2021taxonomizing,garipov2018loss}, we approximate $\int_0^1\mathcal{L}(\gamma(t))dt$ with $\mathbb{E}_{t\sim U(0,1)}\mathcal{L}(\gamma_{\phi}(t))$, and use the Bezier curve with $k+1$ bends, given by $\gamma_{\phi}(t)=\sum_{j=0}^{k}\binom{k}{j}(1-t)^{k-j}t^jw_j$ for $t\in[0,1]$, where $U(0,1)$ denotes a continuous uniform distribution between 0 and 1, $w_0=w, w_k=w'$, and $\phi=\{w_1,\ldots,w_{k-1}\}$ are parameters of additional models to be trained.
Given the curve $\gamma_{\phi}(t)$, the mode connectivity of the models $w, w'$ is defined to be \cite{yang2021taxonomizing}
\begin{equation}\label{eqn:mc}
\mbox{mc}(w,w')=\frac{1}{2}(\mathcal{L}(w)+\mathcal{L}(w'))-\mathcal{L}(\gamma_{\phi}(t^{\star})),
\end{equation}
where $t^{\star}$ maximizes the function $f(t)\triangleq |\frac{1}{2}(\mathcal{L}(w)+\mathcal{L}(w'))-\mathcal{L}(\gamma_{\phi}(t))|$.
We use the same computational procedure and hyperparameter setting in \cite{yang2021taxonomizing,garipov2018loss} to minimize the loss on the curve. We record the training loss and test error values as a function of $t$, and plot them in Figure \ref{fig:mode_connect}. The related statistics is shown in Tables \ref{table:stat_test} and \ref{table:stat_train}. In Figure \ref{fig:mode_connect}, we find that the training loss curve of PFGE has a consistent lower energy than that of FGE for VGG16 and PreResNet-164. The test error curve of PFGE is below that of FGE for most $t$ values, for all architectures. The results in Tables \ref{table:stat_test} and \ref{table:stat_train} also show a consistent advantage of PFGE over FGE in terms of both test error and training loss.
The corresponding mc values are presented in Table \ref{table:mode_connect}, which shows that the model connectivity of PFGE is greater than that of FGE, for all architectures.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.5\linewidth]{mode_connect_1.eps}\includegraphics[width=0.5\linewidth]{mode_connect_2.eps}\\
\includegraphics[width=0.5\linewidth]{mode_connect_3.eps}
\caption{Test error and training loss on CIFAR-10 corresponding to $\gamma_{\phi}(t)$ as a function of $t$. Top left: VGG16. Top right: PreResNet-164. Bottom: WideResNet-28-10.}\label{fig:mode_connect}
\end{figure}
\begin{table}[htbp] \tiny
\caption{Statistics for test errors (\%) of $\gamma_{\phi}(t)$ on CIFAR-10. The test error values are collected along the changes of the $t$ value from 0 to 1.}
\label{table:stat_test}
\begin{tabular}{c|c|c|c}
\hline
& Max & Min & Mean\\
\begin{tabular}{c}
Architecture \\ \hline VGG16 \\ PreResNet \\ WideResNet
\end{tabular}
& \begin{tabular}{cc}
PFGE & FGE \\ \hline
6.96 & 7.51 \\
4.65 & 5.22 \\
4.14 & 4.53
\end{tabular}
& \begin{tabular}{cc}
PFGE & FGE \\ \hline
6.64 & 6.76 \\
4.30 & 4.61 \\
3.43 & 3.63
\end{tabular}
& \begin{tabular}{cc}
PFGE & FGE \\ \hline
6.76 & 6.99 \\
4.50 & 4.82 \\
3.63 & 3.87
\end{tabular}
\\ \hline
\end{tabular}
\end{table}
\begin{table}[htbp] \tiny
\caption{Statistics for training losses of $\gamma_{\phi}(t)$ on CIFAR-10. The training loss values are collected along the changes of the $t$ value from 0 to 1.}
\label{table:stat_train}
\begin{tabular}{c|c|c|c}
\hline
& Max & Min & Mean\\
\begin{tabular}{c}
Architecture \\ \hline VGG16 \\ PreResNet \\ WideResNet
\end{tabular}
& \begin{tabular}{cc}
PFGE & FGE \\ \hline
0.238 & 0.234 \\
0.241 & 0.272 \\
0.284 & 0.324
\end{tabular}
& \begin{tabular}{cc}
PFGE & FGE \\ \hline
0.193 & 0.186 \\
0.197 & 0.213 \\
0.217 & 0.238
\end{tabular}
& \begin{tabular}{cc}
PFGE & FGE \\ \hline
0.207 & 0.199 \\
0.210 & 0.230 \\
0.238 & 0.266
\end{tabular}
\\ \hline
\end{tabular}
\end{table}
\begin{table}[htbp]
\caption{Mode connectivity test on CIFAR-10. See the definition of $\mbox{mc}$ in Equation (\ref{eqn:mc}). A $\mbox{mc}$ value closer to 0 indicates a better mode connectivity and vice versa. See more details on the relationship between the value of $\mbox{mc}$ and mode connectivity in \cite{yang2021taxonomizing}. The best results for each architecture are \textbf{bolded}.}
\label{table:mode_connect}
\begin{tabular}{c|c}
\hline
& $\mbox{mc}$ value \\
\begin{tabular}{c}
Algorithm \\ \hline PFGE \\ FGE
\end{tabular}
& \begin{tabular}{ccc}
VGG16 & PreResNet & WideResNet \\ \hline
\textbf{0.039} & \textbf{0.044} & \textbf{0.065}\\
0.045 & 0.057 & 0.084\\
\end{tabular}
\\ \hline
\end{tabular}
\end{table}
\subsection{IMAGENET}\label{sec:imagenet}
We experiment with network architectures ResNet-50 \cite{he2016deep}, ResNet-152 \cite{he2016deep}, and DenseNet-161 \cite{huang2017densely} on ImageNet ILSVRC-2012 \cite{deng2009imagenet,russakovsky2015imagenet}. See the experimental setting in subsection \ref{sec:experiment_setting}.
Results in Table \ref{table:big_table_imagenet} show that PFGE outperforms FGE, SWA, and SWAG in terms of both test accuracy and NLL, and performs comparatively to FGE-whole and better than SWAG-whole in terms of test accuracy. The reliability diagrams in the left column of Figure \ref{fig:res_imagenet} show that PFGE performs better than SWA, while worse than FGE-whole and SWAG-whole in terms of calibration. Note that the terms FGE and SWAG in Figure \ref{fig:res_imagenet} respectively correspond to FGE-whole and SWAG-whole in Table \ref{table:big_table_imagenet}. The right column of Figure \ref{fig:res_imagenet} shows that the separate models associated with PFGE are better than those of FGE in terms of test accuracy, for all network architectures.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.5\linewidth]{reliability_r50.eps}\includegraphics[width=0.5\linewidth]{separate_r50.eps}\\
\includegraphics[width=0.5\linewidth]{reliability_r152.eps}\includegraphics[width=0.5\linewidth]{separate_r152.eps}\\
\includegraphics[width=0.5\linewidth]{reliability_d161.eps}\includegraphics[width=0.5\linewidth]{separate_d161.eps}
\caption{Left column: Reliability diagrams on Imagenet. Right column: ensemble performance of PFGE and FGE on Imagenet as a function of the training iteration index $i$. Top Row: ResNet-50. Middle Row: ResNet-152. Bottom Row: DenseNet-161. In subfigures of the left column, crosses represent the performance of separate ``snapshot" models, and diamonds show the performance of the ensembles composed of all models available at the given iteration.}\label{fig:res_imagenet}
\end{figure}
\section{Conclusions}
In this paper, we proposed a generic, architecture-agnostic, and highly computationally efficient ensemble-based algorithm, referred to as PFGE, to improve DNNs in terms of generalization and uncertainty calibration. In this algorithm, we use several successively performed SWA procedures to generate high-performing DNN models within the framework of FGE. We empirically demonstrated that the DNN models yielded by PFGE have better separate generalization performance and mode connectivity, compared with those of FGE. Due to these higher-performing model components, PFGE achieves better generalization performance and satisfactory calibration capability than SOTA methods, while the computational overhead of model recording and test-time predictions is significantly reduced to say 20\%.
\newpage
|
{'timestamp': '2022-02-24T02:09:23', 'yymm': '2202', 'arxiv_id': '2202.06658', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06658'}
|
arxiv
|
\section{Introduction}
\begin{table*}[t]
\centering
\setlength\doublerulesep{0.5pt}
\begin{tabular}{| l | l | l c |}
\hline
\textbf{Abstraction} & \textbf{Operations} & \multicolumn{1}{c|}{\textbf{Upper bound}} & \textbf{Lower bound} \\
\hhline{====}
Asset transfer & transfer & \multicolumn{1}{l|}{$O(n^2)$ \multirow{2}{*}{ \cite{guerraoui2019consensus,auvolat2020money} }} & \multirow{2}{*}{$\Omega(n^2)$ [\Cref{thm:assetTransferMsgComplexity}]} \\
& read & \multicolumn{1}{l|}{$O(1)$ }& \\
\hhline{====}
Bidirectional payment channel & open & \multicolumn{ 2}{c | }{\multirow{3}{*}{Impossible in asynchronous networks [\Cref{cor:bidirectionalAsync}] }} \\
& transfer & & \\
& close & & \\
\hhline{====}
Unidirectional payment channel &open & \multicolumn{ 2}{c | }{\multirow{4}{*}{Impossible in asynchronous networks [\Cref{cor:unidirectionalAsync}] } }\\
with source close &transfer&& \\
& source close && \\
&target close && \\
\hline
Unidirectional payment channel & open & \multicolumn{1}{l|}{$O(n^2)$ \multirow{3}{*}{ [Alg.~\ref{alg:uniPaymentChannelImplementation}] } } & \multirow{3}{*}{$\Omega(n^2)$ [\Cref{lem:uniChannelMessageComplexity}]} \\
& transfer & \multicolumn{1}{l|}{$O(1)$ }& \\
& target close &\multicolumn{1}{l|}{$O(n^2)$ }& \\
\hline
\end{tabular}
\vspace{0.5em}
\caption{Summary of results}
\label{table:intro}
\vspace{-2.5em}
\end{table*}
The rise of \emph{cryptocurrencies}, such as Bitcoin~\cite{nakamoto2008bitcoin}, Ethereum~\cite{wood2014ethereum}, Ripple~\cite{armknecht2015ripple}, Tendermint~\cite{buchman2017tendermint}, and many more, has revolutionized the possibility of using decentralized money systems.
In 2019, Guerraoui et al.~\cite{guerraoui2019consensus} defined the abstraction of \emph{asset transfer} or \emph{money transfer} capturing the original motivation of Bitcoin.
This abstraction is based on a set of known users owning accounts, each account has some initial money, and the users can transfer money between the accounts.
It is well-known that deterministic consensus cannot be solved in an asynchronous network~\cite{fischer1985FLP}, meaning that blockchains that rely on consensus require synchrony to work properly.
Nonetheless, Guerraoui et al. showed that the asset transfer problem is weaker than consensus~\cite{lamport1982byzantine,dwork1988consensus}, i.e., in the Byzantine message-passing model the problem can be solved in an asynchronous network.
They provide a concrete implementation of the abstraction in this model using an asynchronous broadcast service.
Yet, in this solution, each payment requires a message complexity of $O(n^2)$, where $n$ is the number of processes in the system.
If the number of processes grows, this per-payment quadratic message complexity can pose a real challenge in scaling the asset transfer network.
In fact, \emph{scalability} is one of the major limiting factors of blockchains and consensus protocols, and extensive research was done to reduce the message complexity~\cite{naor2020expected,eyal2016bitcoin,keidar2021all,yin2019hotstuff,cohen2020coincidence} in various settings.
A promising approach to scale blockchain payments is by using \emph{payment channels}~\cite{poon2016lightning,lind2019teechain,raiden2020raidenImp} as a second off-chain layer on top of the blockchain.
A payment channel can be \emph{opened} between two blockchain account owners via an on-chain deposit made to fund the channel, after which the two users can \emph{transfer} payments on the channel itself off the blockchain.
At any time, one of the users can decide to \emph{close} the channel, after which the current balance in the channel of each of the users is transferred to their on-chain accounts.
In this scheme, opening or closing a channel requires a blockchain transaction, which incurs a large message complexity, but all the intermediate payments on the channel require message exchange only between the channel users, freeing the blockchain from these payments and messages.
Payment channels have been actively deployed in central blockchains.
For example, Bitcoin's \emph{Lightning Network~(LN)}~\cite{poon2016lightning} is a highly used payment network, with active channels holding a Bitcoin amount equivalent to hundreds of millions of dollars~\cite{1ml}.
One of the downsides of using payment channels such as LN is that the payment channels themselves rely on network synchrony.
For example, in LN, suppose Alice and Bob have an open payment channel between them and Alice acts maliciously and tries to steal money by closing the channel at a stale state.
LN provides a way for Bob to penalize Alice and confiscate all the money in the channel.
But to do so, Bob has to detect Alice's misbehavior on-chain and act within a predetermined time frame, making this method inappropriate with asynchronous users.
In this paper, we explore the possibility of implementing payment channels in asynchronous asset transfer systems.
The results of the paper and prior art are summarized in~\Cref{table:intro}.
We study four abstractions: asset transfer and different types of payment channels.
First, we prove a lower bound on the complexity of asset transfer without channels.
We show that no matter what implementation is provided for the asset transfer abstraction, it still requires $\Omega(n^2)$ messages for a single payment to be made by one party and observed by others.
This means that the upper bound is tight for the algorithm provided in~\cite{guerraoui2019consensus}, in which transferring money has $O(n^2)$ message complexity and reading the balance of an account costs $O(1)$.
This fundamental result shows that while the synchrony requirement can be relaxed for asset transfer, each payment still requires a rather large number of messages.
This means that second-layer solutions such as payment channels are required for scalability.
Next, we consider payment channel abstractions with operations for opening a channel, transferring money in it, and closing the channel.
We first consider a \emph{bidirectional payment channel} as a second-layer atop an asset transfer system, where each side of the channel can make payments to the other.
This is similar to LN~\cite{poon2016lightning}, Teechain~\cite{lind2019teechain}, Sprites~\cite{miller2017sprites}, and more payment channel proposals.
We prove an impossibility result, showing that synchrony is required to create such bidirectional channels, and therefore a bidirectional channel cannot be implemented on top of an asynchronous asset transfer system.
We next look at \emph{unidirectional payment channels}, in which only one user, the channel \emph{source}, can make payments to the other user, the \emph{target}.
We differentiate between two types of unidirectional payment channels:
If we allow both the source and the target to close the channel (the source and target close operations, respectively), we again show that synchrony is required.
But, if we allow only the target to close the channel, we provide a concrete implementation that works in an asynchronous network.
In this implementation, the opening and closure of the channel require a payment using the asset transfer system, incurring $O(n^2)$ message complexity, whereas every payment on the channel itself requires a single message from the source user to the target user.
Finally, we discuss an extension of payment channels to payment chains, in which payments are made across multiple channels atomically.
Like their 2-party counterparts, a chain payment over unidirectional channels with only target close can be implemented using a technique used in LN.
As for other channel types, $k$-hop chains are equivalent to $k$-process consensus, i.e., have a consensus number $k$.
To conclude, in this paper we continue the study of asset transfer systems in asynchronous networks and provide concrete possibility and impossibility results for implementing a key scaling solution.
\subsubsection*{Structure}
The rest of the paper is structured as follows: \Cref{sec:relatedWork} discusses related work; \Cref{sec:model} describes the model; \Cref{sec:assetTransfer} details the asset transfer abstraction and proves a lower bound on message complexity; \Cref{sec:biChannel} discusses bidirectional payment channels and \Cref{sec:uniChannel} discusses unidirectional channels; \Cref{sec:chain} extends the discussion to chain payments; and finally; \Cref{sec:conclusion} concludes the paper.
\section{Related work}
\label{sec:relatedWork}
A few works, some of which predating the blockchain era, identified that a transfer-like system can be implemented under asynchrony~\cite{pedone2002handling,gupta2016non}.
The first definition of the asset transfer abstraction is due to Guerraoui et al.~\cite{guerraoui2019consensus}.
Subsequentially, Auvolat et al.~\cite{auvolat2020money} provide a weaker specification for asset transfer and detailed an implementation that uses a broadcast service that guarantees FIFO order between every two processes.
Astro~\cite{collins2020online} implements and empirically evaluates an asynchronous payment system.
Solving Byzantine consensus in an asynchronous network is possible by using randomization to circumvent the FLP~\cite{fischer1985FLP} result.
Earlier protocols such as~\cite{ben1994power,rabin1983randomized} have exponential message complexity.
Later protocols such as~\cite{miller2016honey,abraham2019asymptotically,guo2020dumbo,keidar2021all} improve the message complexity in various settings, but they still are not deterministic, and therefore their performance can only be measured in the expected case.
There is also extensive research done on scaling cryptocurrencies using payment channels, including the Lightning Network~\cite{poon2016lightning}, Teechain~\cite{lind2019teechain}, Bolt~\cite{green2017bolt}, Sprites~\cite{miller2017sprites}, Perun~\cite{dziembowski2017perun}, Duplex Micropayment Channels~\cite{decker2015fast}, Raiden~\cite{raiden2020raidenImp}, and more.
In Ethereum~\cite{wood2014ethereum}, there are multiple second-layer networks like Arbitrum~\cite{kalodner2018arbitrum}, StarkNet~\cite{ben2018scalable}, and Optimism~\cite{optimismNetwork}.
They all rely on underlying synchronous blockchains to operate.
To the best of our knowledge, we are the first to show a quadratic lower bound for payments in asset transfer systems, as well as to explore second-layer payment channels as a scaling solution for money transfer in the asynchronous setting.
\section{Model and preliminaries}
\label{sec:model}
We study a message-passing distributed system that consists of a set $\Pi = \{p_1, \ldots, p_n\}$ of $n$ processes.
The processes can interact among themselves by sending messages.
An adversary can \emph{corrupt} up to $f < n/3$ processes, where $f \in \Theta(n)$.
If not mentioned explicitly, we assume a corrupt process is \emph{Byzantine}, i.e., it can deviate from the prescribed algorithm and act arbitrarily.
Any non-corrupt process is \emph{correct}.
A \emph{crash-fail} fault is when a process stops participating in the algorithm.
Every two processes share an asynchronous reliable link between them, such that if one correct process sends a message to another correct process, it eventually arrives, and the target can ascertain its source.
We assume the existence of a \emph{Public Key Infrastructure (PKI)}, whereby processes that know a private key can use it to sign messages such that all other processes can verify the signature.
The adversary cannot forge a signature if the private key is owned by a correct process.
We assume each private key is owned by one process.
We further assume \emph{multisignatures}~\cite{bellare2007identity}, whereby in order to produce a valid signature matching a constant-sized public key, more than one private key is used to sign the message.
Note that signing can be sequential.
We study algorithms in the message-passing model that implement abstractions that are defined as \emph{shared-memory objects}.
A shared memory object has a set of \emph{operations}, and processes access the object via these operations.
Each operation starts with an \emph{invocation} event by a process and ends with a subsequent \emph{response} event.
Invocations and responses are discrete events.
An \emph{implementation} or an \emph{algorithm} $\pi$ of a shared-memory object abstraction is a distributed protocol that defines the behaviors of processes as deterministic state machines, where state transitions are associated with \emph{actions}: sending or receiving messages, and operation invocations or responses.
A \emph{global state} of the system is a mapping to states from systems components, i.e., processes and links.
An \emph{initial global state} is when all processes are in initial states and there are no messages on the links between the processes.
A \emph{run}, or an \emph{execution} of an implementation is an alternating series of global states and actions, beginning with some initial global state, such that state transitions occur according to $\pi$.
We assume that the first action of each process is an invocation of an operation and that it does not invoke another operation before receiving a response for its last invoked operation.
Each execution creates a \emph{history} $H$ that consists of a sequence of matching invocations and responses, each with the assigned process that invoked the operation and the matching responses.
A \emph{sub-history $H'$ of $H$} is a subset of $H$'s events.
Denote $H|_p$ as the sub-history of $H$ with process $p$'s events.
A history defines a \emph{partial ordering}: \emph{operation $\textit{op}_1$ precedes $\textit{op}_2$ in history $H$}, labeled $\textit{op}_1 \prec_H \textit{op}_2$, if $\textit{op}_1$'s response event happens before $\textit{op}_2$'s invocation event in $H$.
History $H$ is \emph{sequential} if each invocation, except perhaps the last, is immediately followed by a matching response.
An operation is \emph{pending} in history $H$ if it has an invocation event in $H$ but does not have a matching response.
A history $H'$ is a \emph{completion of history $H$} if it is identical to $H$ except removing zero or more pending operations in $H$ and by adding matching responses for the remaining ones.
A shared-memory abstraction is usually defined in terms of a \emph{sequential specification}.
A \emph{legal} sequential history is a sequential history that preserves the sequential specification.
The correctness criteria we consider is \emph{Byzantine sequential consistency (BSC)}.
This allows to extend sequential consistency~\cite{attiya1994sequential} to runs with Byzantine processes and not only crash-fail, and is an adaptation of the definition of Byzantine linearizability~\cite{cohen2021ByzantineLinea}.
First, we formally define a sequentially consistent history for runs with crash-fail faults:
\begin{definition} [sequentially consistent history]
Let $E$ be an execution of an algorithm and $H$ its matching history.
Then $H$ is sequentially consistent if there exists a completion $\widetilde{H}$ of $H$ and a legal sequential history $S$ such that: (i)~for every process $p$, $S|_p = \widetilde{H}|_p$, and (ii)~for any process $p$ and operations $op_1, op_2$ s.t. $op_1 \prec_{\widetilde{H}|_p} op_2$, then $op_1 \prec_S op_2$.
\end{definition}
An algorithm is sequentially consistent if all its histories are sequentially consistent.
For Byzantine sequential consistency (BSC), let $H|_c$ denote the sub-history of $H$ with all of the operations of correct processes.
We say a history is BSC if $H|_c$ can be augmented with operations of Byzantine processes such that the completed history is sequentially consistent.
Formally:
\begin{definition} [Byzantine sequential consistency (BSC)]
A history $H$ is BSC if there exists a history $H'$ such that $H'|_c = H|_c$, and $H'$ is sequentially consistent.
\end{definition}
Similar to sequential consistency, an algorithm is BSC if all its histories are BSC.
We choose BSC as the correctness criteria and not Byzantine linearizability as it simplifies the implementations we provide below.
We explain in \Cref{sec:uniChanelImplementation:UpperBound} how to change the implementation we provide to satisfy Byzantine linearizability.
The difference of sequential consistency from linearizability~\cite{herlihy1990linearizability} is that linearizability also preserves real-time order.
\section{Unidirectional Payment Channel}
\label{sec:uniChannel}
After proving that a bidirectional payment channel cannot be implemented in asynchronous networks, we explore another type of payment channels, \emph{unidirectional}.
The main difference from bidirectional channels is that unidirectional channels are asymmetric.
There is only one user, the source, that can open and transfer money in the channel.
We show in which cases unidirectional payment channels can be implemented in an asynchronous message-passing network and in which cases they cannot.
This type of payment channel was also proposed for the Bitcoin network~\cite{spilman_2013} a few years before bidirectional channels such as LN were proposed.
We begin by formally defining the unidirectional payment channel abstraction.
\subsection{Definition}
We define a unidirectional payment channel abstraction as a shared memory object $B$.
The formal definition is in Specification~\ref{alg:uniPaymentChannelOps}.
$B$ is defined based on the existence of an asset transfer object $A$.
A payment channel in $B$ is of the form $(a, b)$ where $a, b$ are accounts in $A$.
\begin{specification}[t] \smaller
\caption{\textbf{Unidirectional payment channel abstraction}. Operations for process $p$.}
\SetAlgoNoEnd
\label{alg:uniPaymentChannelOps}
\DontPrintSemicolon
\SetInd{0.4em}{0.4em}
\let\oldnl\n
\newcommand{\renewcommand{\nl}{\let\nl\oldnl}}{\renewcommand{\nl}{\let\nl\oldnl}}
\SetKwBlock{sharedObjects}{Shared Objects:}{}
\SetKwProg{myproc}{Procedure}{:}{}
\SetKwProg{myfunc}{Function}{:}{}
\renewcommand{\nl}{\let\nl\oldnl} \sharedObjects{
\renewcommand{\nl}{\let\nl\oldnl} $A$ - asset transfer object, with initial accounts \;
\renewcommand{\nl}{\let\nl\oldnl} $B$ - unidirectional payment channel object \;
}
\begin{multicols}{2}
\BlankLine \BlankLine
\myproc{$B.\textit{open}((a,b),\ensuremath{\textit{amt}}\xspace)$} {
\If{$p \neq \textit{owner}(a) \vee B(a,b) \neq \bot \vee A(a) < \ensuremath{\textit{amt}}\xspace$ } {
\Return \textit{fail}
}
$A(a) \gets A(a) - \ensuremath{\textit{amt}}\xspace$ \;
$B(a,b) \gets (\ensuremath{\textit{amt}}\xspace, 0)$ \;
\Return \textit{success}
}
\BlankLine
\myproc{$B.\textit{transfer}((a,b),\ensuremath{\textit{amt}}\xspace)$} {
\If{$p \neq \textit{owner}(a) \vee B(a,b) = \bot$} {
\Return
}
$(\ensuremath{\textit{bal}}\xspace_a, \ensuremath{\textit{bal}}\xspace_b) \gets B(a,b)$ \;
\If{$\ensuremath{\textit{bal}}\xspace_a < \ensuremath{\textit{amt}}\xspace$} {
\Return
}
$\textit{new\_bal}_a \gets \ensuremath{\textit{bal}}\xspace_a - \ensuremath{\textit{amt}}\xspace$ \;
$\textit{new\_bal}_b \gets \ensuremath{\textit{bal}}\xspace_b + \ensuremath{\textit{amt}}\xspace$ \;
$B(a,b) \gets (\textit{new\_bal}_a, \textit{new\_bal}_b) $ \;
\Return \textit{success}
}
\BlankLine
\myproc{$B.\textit{target\_close}((a,b),\ensuremath{\textit{bal}}\xspace_b))$} {
\If{$p \neq \textit{owner}(b) \vee B(a,b) = \bot$} {
\Return \textit{fail}
}
$(\textit{curr\_bal}_a, \textit{curr\_bal}_b) \gets B(a,b)$ \;
\If{$\ensuremath{\textit{bal}}\xspace_b > \textit{curr\_bal}_b $}{
\Return \textit{fail}
}
$\ensuremath{\textit{bal}}\xspace_a \gets \textit{curr\_bal}_a + \textit{curr\_bal}_b - \ensuremath{\textit{bal}}\xspace_b$ \;
\Return $\textit{execute\_close}((a,b), (\ensuremath{\textit{bal}}\xspace_a, \ensuremath{\textit{bal}}\xspace_b))$ \;
}
\break
\myproc{$B.\textit{source\_close}((a,b), \ensuremath{\textit{bal}}\xspace_a)$} {
\If{$p \neq \textit{owner}(a) \vee B(a,b) = \bot$} {
\Return \textit{fail}
}
$(\textit{curr\_bal}_a, \textit{curr\_bal}_b) \gets B(a,b)$ \;
\If{$\ensuremath{\textit{bal}}\xspace_a > \textit{curr\_bal}_a $}{
\Return \textit{fail}
}
$\ensuremath{\textit{bal}}\xspace_b \gets \textit{curr\_bal}_a + \textit{curr\_bal}_b - \ensuremath{\textit{bal}}\xspace_a$ \;
\Return $\textit{execute\_close}((a,b), (\ensuremath{\textit{bal}}\xspace_a, \ensuremath{\textit{bal}}\xspace_b))$ \;
}
\BlankLine
\myfunc{$\textit{execute\_close}((a,b), (\ensuremath{\textit{bal}}\xspace_a, \ensuremath{\textit{bal}}\xspace_b))$ }{
$A(a) \gets A(a) + \ensuremath{\textit{bal}}\xspace_a$ \;
$A(b) \gets A(b) + \ensuremath{\textit{bal}}\xspace_b$ \;
$B(a,b) \gets \bot$ \;
\Return \textit{success}
}
\end{multicols}
\end{specification}
The state of a payment channel $B(a,b)$ is ${\{\mathbb{R}_{\geq 0} \times \mathbb{R}_{\geq 0} \} \cup \{\bot \}}$.
Intuitively, a unidirectional payment channel $B(a,b)$ can either be open, and then $B(a,b) = (\ensuremath{\textit{bal}}\xspace_{a}, \ensuremath{\textit{bal}}\xspace_{b})$, or closed, and then $B(a,b) = \bot$.
The initial state is that all the unidirectional payment channels are closed, e.g., for payment channel $(a,b)$, the state is $ B(a,b) = \bot$ at the beginning of the run.
The set of operations is the following:
\begin{itemize}
\item $\textit{open}((a,b),\ensuremath{\textit{amt}}\xspace)$.
A process that owns account $a$ can open a unidirectional payment channel with any other account $b$ with amount $\ensuremath{\textit{amt}}\xspace$, as long as it has enough balance in $A$ and that it does not already have an open payment channel with $b$.
The call returns \textit{success} if the channel is opened successfully, and \textit{fail} otherwise.
\item $\textit{transfer}((a,b),\ensuremath{\textit{amt}}\xspace)$.
A payment in the payment channel $(a,b)$ is possible if the channel is open, if the caller of the operation $a$ is $\textit{owner}(a)$ and $a$ has enough balance in the channel to make the payment.
This call does not return a response.
\item $\textit{source\_close}((a,b), \ensuremath{\textit{bal}}\xspace_a)$.
A source closing of a payment channel $(a,b)$ can be called by $\textit{owner}(a)$.
The call succeeds if the process that invokes the call does not try to close it with balance $\ensuremath{\textit{bal}}\xspace_a$ that exceeds the amount it has in the channel.
After the call ends, the balances in the channel are transferred to accounts $a,b$ in the asset transfer system.
The call returns \textit{success} if the channel is closed successfully, and \textit{fail} otherwise.
\item $\textit{target\_close}((a,b), \ensuremath{\textit{bal}}\xspace_b)$.
A target closure of a payment channel $(a,b)$ is symmetrical to the source\_close call, but is invoked by $\textit{owner}(b)$.
\end{itemize}
We differentiate between two types of unidirectional payment channels, depending on whether the source close call is included in the allowed set of operations of the shared object or not.
Note that without source close, the source depends on the target to close the channel to receive its deposit back after the channel is opened.
However, for the target to receive its balance from the channel in the asset transfer system, it has to eventually close the channel.
When the target closes the channel, the source also receives its respective balance.
\subsection{Impossibility of unidirectional payment channel with source close}
We begin by showing that a unidirectional payment channel that has the source close operation has a consensus number of at least 2, and therefore cannot be implemented in an asynchronous message passing network.
Formally, we prove:
\begin{lemma}
Consensus has a wait-free implementation for $2$ processes in the read-write shared memory model with an instance of a unidirectional payment channel with source close shared memory object and shared registers.
\end{lemma}
\begin{proof}
In \Cref{alg:reductionConsensuswithBidirectionalChannel1}, only process $p_1$ transfers money to $p_2$ using the channel, and they both attempt to close the channel: $p_1$ after the payment is made, and $p_2$ without accepting the payment.
Thus, changing the close call in \Cref{alg:reductionConsensuswithBidirectionalChannel1:p1close} to $B.\textit{source\_close}$ and the call in \Cref{alg:reductionConsensuswithBidirectionalChannel1:p2close} to $B.\textit{target\_close}$ yields a consensus algorithm among 2 processes using a unidirectional payment channel with source and target close operations.
\end{proof}
Based on the above theorem and FLP~\cite{fischer1985FLP}, we get the following result:
\begin{theorem} \label{cor:unidirectionalAsync}
There does not exist an implementation of the unidirectional payment channel abstraction with source close in the asynchronous message-passing model.
\end{theorem}
\subsection{Implementation of unidirectional payment channel without source close}
We now observe the unidirectional payment channel abstraction without the source close operation.
We first prove a lower bound on the message complexity of an implementation, and then prove that this lower bound is tight by providing an implementation for the abstraction in the asynchronous message-passing model.
\subsubsection{Lower bound}
We prove that any algorithm that implements the unidirectional payment channel specification incurs a combined message complexity for open, transfer, and close of $\Omega(n^2)$.
To this end, we prove the following lemma:
\begin{restatable}{lemma}{uniChannelMessageComplexity}
\label{lem:uniChannelMessageComplexity}
Consider an algorithm that implements the unidirectional payment channel abstraction $B$, and an asset transfer $A$.
Then there exists a run with $B.\textit{open}$, $B.\textit{transfer}$, $B.\textit{target\_close}$, and $A.\textit{read}$ calls, in which correct processes send at least $(f/2)^2$ messages.
\end{restatable}
\begin{proof}
Consider all runs with accounts $a,b$ that are owned by a single process, i.e., $\textit{owner}(a) = \textit{owner}(b) = p$, with initial balances $A(a) = 1, A(b) = 0$.
A transfer call $A.\textit{transfer}(a,[(b,1)])$ by $p$ can be implemented using a unidirectional channel $(a,b)$ by having process $p$ invoke $B.\textit{open}((a,b),1)$, $B.\textit{transfer}((a,b),1)$, and lastly, $B.\textit{target\_close}((a,b),1)$.
Then, the proof proceeds in the same manner as the proof of \Cref{thm:assetTransferMsgComplexity}.
\end{proof}
\begin{algorithm*}[t] \smaller
\caption{\textbf{Unidirectional payment channel without source\_close implementation in the asynchronous message-passing model}. Operations for process $p$.}
\SetAlgoNoEnd
\label{alg:uniPaymentChannelImplementation}
\DontPrintSemicolon
\SetInd{0.4em}{0.4em}
\let\oldnl\n
\newcommand{\renewcommand{\nl}{\let\nl\oldnl}}{\renewcommand{\nl}{\let\nl\oldnl}}
\SetKwBlock{sharedObjects}{Shared Objects:}{}
\SetKwBlock{localVariables}{Local variables:}{}
\SetKwProg{myproc}{Procedure}{:}{}
\SetKwProg{myfunc}{Function}{:}{}
\SetKwProg{myupon}{Upon}{:}{}
\renewcommand{\nl}{\let\nl\oldnl} \sharedObjects{
\renewcommand{\nl}{\let\nl\oldnl} $A$ - asset transfer object \;
}
\renewcommand{\nl}{\let\nl\oldnl}\localVariables {
\renewcommand{\nl}{\let\nl\oldnl} $\textit{source}[] $ - a dictionary with the balances of all channels that $p$ is the source, initially $\bot$ for all channels \;
\renewcommand{\nl}{\let\nl\oldnl} $\textit{target}[] $ - a dictionary with asset transfer multisig invocations for all channels $p$ is the target, initially $\bot$ for all channels \;
}
\begin{multicols}{2}
\tcp{\underline{This call can be invoked by $\textit{owner}(a)$}}
\myproc{$\textit{open}((a,b),\ensuremath{\textit{amt}}\xspace)$ \label{alg:uniPaymentChannelImplementation:openCall}} {
\If{$\textit{owner}(a) \neq p \vee \textit{source}[ab] \neq \bot \vee A.\textit{read}(a) < \ensuremath{\textit{amt}}\xspace$ \label{alg:uniPaymentChannelImplementation:openCallIf}} {
\Return \textit{fail}
}
invoke $A.\textit{transfer}(a, [(ab, \ensuremath{\textit{amt}}\xspace)]) $ \label{alg:uniPaymentChannelImplementation:openCallATransfer} \tcp*{$ab$ is a multisig account\phantom{ii}}
create an $A.\textit{transfer}(ab, [(a, \ensuremath{\textit{amt}}\xspace), (b, 0)])$ invocation $tx$ \label{alg:uniPaymentChannelImplementation:createOpenTX}\;
add $p$'s signature to $tx$ \tcp*{$tx$ is still not a valid transaction} \label{alg:uniPaymentChannelImplementation:sendOpenTX}
\textbf{send} $\langle \text{"open"}, tx, \ensuremath{\textit{amt}}\xspace \rangle$ to $\textit{owner}(b)$ \;
$\textit{source}[ab] \gets (\ensuremath{\textit{amt}}\xspace, 0)$ \;
\Return \textit{success}
}
\tcp{\underline{This message is received by $\textit{owner}(b)$}}
\myupon{receiving $\langle \text{"open"}, tx, \ensuremath{\textit{amt}}\xspace \rangle$ and $A.\textit{read}(ab) = \ensuremath{\textit{amt}}\xspace$ \label{alg:uniPaymentChannelImplementation:receiveOpenMsg}} {
let $tx$ be $A.\textit{transfer}(ab, [(a, \ensuremath{\textit{amt}}\xspace), (b, 0)])$ invocation\;
\If{$\textit{owner}(b)\neq p \vee\neg \textit{validate\_tx}(tx, a) \vee \textit{target}[ab] \neq \bot$ } {
\Return
}
$\textit{target}[ab] \gets tx$ \;
}
\end{multicols}
\begin{multicols}{2}
\tcp{\underline{This call can be invoked by $\textit{owner}(a)$}}
\myproc{$\textit{transfer}((a,b),\ensuremath{\textit{amt}}\xspace)$ \label{alg:uniPaymentChannelImplementation:transferCall}} {
\If{$\textit{owner}(a) \neq p \vee \textit{source}[ab] = \bot$ \label{alg:uniPaymentChannelImplementation:transferCall:if1}}
{
\Return
}
$(\ensuremath{\textit{bal}}\xspace_a, \ensuremath{\textit{bal}}\xspace_b) \gets \textit{source}[ab]$ \;
\If{$\ensuremath{\textit{bal}}\xspace_a < \ensuremath{\textit{amt}}\xspace $ \label{alg:uniPaymentChannelImplementation:transferCall:if2}}
{
\Return
}
$(\textit{new\_bal}_a, \textit{new\_bal}_b) \gets (\ensuremath{\textit{bal}}\xspace_a - \ensuremath{\textit{amt}}\xspace, \ensuremath{\textit{bal}}\xspace_b + \ensuremath{\textit{amt}}\xspace)$ \;
create an $A.\textit{transfer}(ab, [(a, \textit{new\_bal}_a), (b,\textit{new\_bal}_b)])$ invocation $tx$ \label{alg:uniPaymentChannelImplementation:createTransferTX}\;
add $p$'s signature to $tx$ \label{alg:uniPaymentChannelImplementation:addSignatureToTransfer}\;
\textbf{send} $\langle \text{"transfer"}, tx, \ensuremath{\textit{amt}}\xspace \rangle$ to $\textit{owner}(b)$ \label{alg:uniPaymentChannelImplementation:transferCallSendTX}\;
$\textit{source}[ab] \gets (\textit{new\_bal}_a, \textit{new\_bal}_b)$ \;
}
\tcp{\underline{This message is received by $\textit{owner}(b)$}}
\myupon{receiving $\langle \text{"transfer"}, tx, \ensuremath{\textit{amt}}\xspace \rangle$} {
let $tx$ be $A.\textit{transfer}(ab, [(a, \ensuremath{\textit{bal}}\xspace_a), (b, \ensuremath{\textit{bal}}\xspace_b)])$ invocation \;
\If{$\textit{owner}(b) \neq p \vee \neg \textit{validate\_tx}(tx, a) \vee \textit{target}[ab] = \bot$ \label{alg:uniPaymentChannelImplementation:transferCallMsg}}
{
\Return
}
get $A.\textit{transfer}(ab, [(a, \textit{curr\_bal}_a), (b, \textit{curr\_bal}_b)])$ invocation from $\textit{target}[ab]$ \tcp*{current stored transaction}
\If{$\textit{curr\_bal}_a \neq \ensuremath{\textit{bal}}\xspace_a - \ensuremath{\textit{amt}}\xspace \vee \textit{curr\_bal}_b \neq \ensuremath{\textit{bal}}\xspace_b + \ensuremath{\textit{amt}}\xspace$} {
\Return
}
$\textit{target}[ab] \gets tx$ \tcp*{store new transaction}
}
\end{multicols}
\begin{multicols}{2}
\tcp{\underline{This call can be invoked by $\textit{owner}(b)$}}
\myproc{$\textit{target\_close}((a,b),\ensuremath{\textit{bal}}\xspace_b)$ \label{alg:uniPaymentChannelImplementation:closeCall}} {
\If{$\textit{owner}(b) \neq p \vee \textit{target}[ab] = \bot $ }
{
\Return \textit{fail}
}
get $A.\textit{transfer}(ab, [(a, \textit{curr\_bal}_a), (b, \textit{curr\_bal}_b)])$ transaction $tx$ from $\textit{target}[ab]$ \;
\If{$\ensuremath{\textit{bal}}\xspace_b \neq \textit{curr\_bal}_b$} {
\Return \textit{fail}
}
add $p$'s signature to $tx$ \tcp*{this completes the multisig}
invoke $tx$ \tcp*{invoke $A$ with closing transaction} \label{alg:uniPaymentChannelImplementation:addSignatureToClose} \label{alg:uniPaymentChannelImplementation:closeCallInvokeA}
$\textit{target}[ab] \gets \bot$ \;
\textbf{send} $\langle \text{"close"}, tx \rangle $ to $\textit{owner}(a)$\;
\Return \textit{success}
}
\tcp{\underline{This message is received by $\textit{owner}(a)$}}
\myupon{receiving $\langle \text{"close"}, tx \rangle$ and $A.\textit{read}(ab) = 0$} {
\If{$\textit{owner}(a) \neq p \vee \neg \textit{validate\_tx}(tx, b) \vee \textit{source}[ab] = \bot$ \label{alg:uniPaymentChannelImplementation:receiveCloseMsg}} {
\Return \;
}
$\textit{source}[ab] \gets \bot$ \label{alg:uniPaymentChannelImplementation:closeSourceBot}\;
}
\end{multicols}
\myfunc{$\textit{validate\_tx}(tx, a)$} {
\Return $tx$ is a valid invocation of $A$ and it contains $\textit{owner}(a)$'s signature \;
}
\end{algorithm*}
\subsubsection{Upper bound} \label{sec:uniChanelImplementation:UpperBound}
We provide an algorithm in the asynchronous message-passing model that implements a unidirectional payment channel without source close.
The algorithm assumes an asset transfer system $A$, implemented as in~\cite{guerraoui2019consensus}, and discussed in~\Cref{sec:assetTransfer:upperBound}.
The algorithm is detailed in \Cref{alg:uniPaymentChannelImplementation}.
We denote an account name with a string $c_1c_2\cdots c_k \in A$ to refer to an account with a public key that is a $k$-of-$k$ multisignature of $\{\textit{owner}(c_1), \ldots, \textit{owner}(c_k)\}$.
For example, to sign an invocation of the asset transfer object $A$ of account $ab$, like transferring money from $ab$ to another account, both
$\textit{owner}(a)$ and $\textit{owner}(b)$ need to sign the message with their respective private keys before the call can be invoked.
The transfer call with an appropriate multisignature can be invoked by any process, in particular, the last process to sign the invocation and complete the signature.
When the algorithm mentions that a process creates an $A.\textit{transfer}$ invocation, e.g., in lines~\ref{alg:uniPaymentChannelImplementation:createOpenTX} and~\ref{alg:uniPaymentChannelImplementation:createTransferTX}, it does not mean the process invokes the transfer operation, but rather that it adds its signature to a multisignature message allowing an invocation of $A$'s operation.
Any invocation of $A.\textit{transfer}$ call is mentioned explicitly (Lines~\ref{alg:uniPaymentChannelImplementation:openCallATransfer}, \ref{alg:uniPaymentChannelImplementation:addSignatureToClose}).
We further assume FIFO order on messages sent between every two processes. This can be easily implemented with sequence numbers.
We explain below the implementation details of the algorithm for each of the abstraction's operations.
\textbf{Open.}
The open procedure of a channel $(a,b)$ (\Cref{alg:uniPaymentChannelImplementation:openCall}) requires $p_1 = \textit{owner}(a)$ to make an initial deposit by invoking the transfer method of $A$ from account $a$ to a multisignature account $ab$ (\Cref{alg:uniPaymentChannelImplementation:openCallATransfer}).
After the transfer is completed, $p_1$ creates a transaction $tx$ that transfers the deposit back to its account and $0$ to $p_2 = \textit{owner}(b)$ and sends it to $p_2$ (\Cref{alg:uniPaymentChannelImplementation:sendOpenTX}).
Note that at this stage, process $p_1$ cannot invoke $A$ with $tx$ since it requires a multisignature, but when $p_2$ receives it, it has the ability to add its signature as well and then invoke $A$ with the $tx$.
When $p_2$ receives $tx$ this transaction message it also waits for the balance in account $ab$ to reflect the deposit (\Cref{alg:uniPaymentChannelImplementation:receiveOpenMsg}) to ensure the money was deposited in account $ab$ using the asset transfer system, after which it considers the account as open.
\textbf{Transfer.}
When $p_1$ wants to transfer money in an open channel $(a,b)$ (\Cref{alg:uniPaymentChannelImplementation:transferCall}) it creates a transaction $tx$ which is an $A.\textit{transfer}$ invocation transferring money from the multisignature account $ab$ to accounts $a$ and $b$ with the last balance of the channel after the payment.
E.g., if the balance of the channel is $(10,1)$, and $p_1$ wants to make a payment of $1$ on the channel, it creates transaction $tx$ required to invoke $A.\textit{transfer}(ab,[(a,9),(b,2)])$, which transfers $9$ money units to $p_1$ and $2$ to $p_2$.
Then, $p_1$ adds its signature to $tx$ (\Cref{alg:uniPaymentChannelImplementation:addSignatureToTransfer}), and sends it to $p_2$ which stores it.
Note that $p_1$ cannot invoke $A$ with $tx$ since it is still missing $p_2$'s signature.
Thus, making a payment on the channel simply requires one message from the source user to the target user containing $tx$, and multiple payments can be done on the channel without invoking $A$'s transfer call.
\textbf{Close.}
When $p_2$ wants to close the channel $(a,b)$ (\Cref{alg:uniPaymentChannelImplementation:closeCall}), it takes the last transaction of account $ab$ it received from $p_1$ and adds its signature to it (\Cref{alg:uniPaymentChannelImplementation:addSignatureToClose}).
$p_2$'s signature completes the multisignature, making it a valid transaction, and allowing $p_2$ to use it to invoke $A$'s transfer operation (\Cref{alg:uniPaymentChannelImplementation:closeCallInvokeA}).
Process $p_2$ then sends $tx$ to $p_1$, which ensures the transaction is also delivered via the broadcast of $A$ by checking that balance in account $ab$ is $0$, after which it considers the channel closed.
Thus, opening and closing of the channel requires invoking an $A.\textit{transfer}$ operation, which incurs $O(n^2)$ messages because of the broadcast, but transferring money on the channel itself requires only one message per transfer.
\subsubsection*{Correctness}
We prove below that the implementation (\Cref{alg:uniPaymentChannelImplementation}) is Byzantine sequentially consistent (BSC) in respect to the sequential specification (Specification~\ref{alg:uniPaymentChannelOps}).
The algorithm can be changed to be Byzantine linearizable by having each message answered with an ack message.
E.g., after the open message is received in \Cref{alg:uniPaymentChannelImplementation:transferCall:if1}, the process sends an ack message back to the original sender.
The linearization point then is when the ack message is received.
This change requires sending more messages as part of the algorithm and also extends the latency, but this change does not affect the overall message complexity.
This is also the reason why we chose BSC as the correctness criteria.
We examine an execution $E$ of the algorithm.
Let $H$ be $E$'s matching history.
Let $\widetilde{H}$ be a completion of $H$ by removing any pending open and close calls that did not reach $A$'s transfer call invocation (Lines \ref{alg:uniPaymentChannelImplementation:openCallATransfer} and \ref{alg:uniPaymentChannelImplementation:closeCallInvokeA}, respectively).
We define $H'$ as an augmentation of $\widetilde{H}|_c$ as follows:
For any correct process $q = \textit{owner}(b)$ that invokes $B.\textit{target\_close}((a,b), \ensuremath{\textit{bal}}\xspace_b)$ s.t. process $p = \textit{owner}(a)$ is a Byzantine process, we add before the target close call the following two Byzantine invocations to $H'$ by $p$:
\begin{itemize}
\item $B.\textit{open}((a,b), \ensuremath{\textit{bal}}\xspace_b)$ with an account $a$ s.t. $A(a) \geq \ensuremath{\textit{bal}}\xspace_b$.
Since account $a$ has enough money to open the channel, the open call succeeds.
\item $B.\textit{transfer}((a,b), \ensuremath{\textit{bal}}\xspace_b)$ which is invoked by process $q$ immediately after the previous open call returns.
\end{itemize}
These two calls ensure that when $q$ invokes the close operation, it succeeds.
Next, we construct a linearization $E'$ of $H'$ by defining the following linearization points:
\begin{itemize}
\item Any open or close call that fails is linearized immediately after its invocation.
\item A transfer call that returns because of the if statements (Lines \ref{alg:uniPaymentChannelImplementation:transferCall:if1}, \ref{alg:uniPaymentChannelImplementation:transferCall:if2}) is linearized immediately after its invocation.
\item Any successful $\textit{open}((a,b), \ensuremath{\textit{amt}}\xspace)$ s.t. $q = \textit{owner}(b)$ is a correct process, then it linearizes after $q$ reaches \Cref{alg:uniPaymentChannelImplementation:receiveOpenMsg}.
If $q$ is Byzantine then the open call linearizes when it ends.
\item Any $\textit{transfer}((a,b), \ensuremath{\textit{amt}}\xspace)$ that reaches \Cref{alg:uniPaymentChannelImplementation:transferCallSendTX} s.t. $q = \textit{owner}(b)$ is a correct process, then it linearizes after $q$ reaches \Cref{alg:uniPaymentChannelImplementation:transferCallMsg}.
If $q$ is Byzantine then the transfer call linearizes when it ends.
\item Any successful $\textit{target\_close}((a,b), \ensuremath{\textit{bal}}\xspace_b)$ s.t. $p = \textit{owner}(a)$ is a correct process, then it linearizes after $p$ reaches \Cref{alg:uniPaymentChannelImplementation:receiveCloseMsg}.
If $p$ is Byzantine then the close call linearizes when it ends.
\end{itemize}
We now prove that $E'$, the linearization of $H'$, satisfies the sequential specification of a unidirectional payment channel without source close.
We assume that for channel $(a,b)$, $p = \textit{owner}(a), q = \textit{owner}(b)$.
\begin{lemma}
A $B.\textit{open}$ call for channel $(a,b)$ succeeds only if the channel is closed when the call is invoked.
\end{lemma}
\begin{proof}
Immediate from the algorithm.
A channel $(a,b)$ opening fails if $\textit{source}[ab] = \bot$ (\Cref{alg:uniPaymentChannelImplementation:openCallIf}).
This is the case for all channels at the beginning of the run, or if the channel was previously closed successfully (\Cref{alg:uniPaymentChannelImplementation:closeSourceBot}).
\end{proof}
\begin{lemma}
For any $B.\textit{transfer}$ call for channel $(a,b)$ there is a preceding open call for the channel in $H'$.
\end{lemma}
\begin{proof}
If the transfer call in $H'$ is invoked by a correct process, then from the algorithm $\textit{source}[ab] \neq \bot$.
This is only possible by the algorithm if $p$ invokes an open call for the channel before the transfer invocation.
If $q$ is correct, then the open and transfer calls linearize when $q$ receives the messages for the corresponding calls (Lines \ref{alg:uniPaymentChannelImplementation:receiveOpenMsg}, \ref{alg:uniPaymentChannelImplementation:transferCallSendTX}).
Since we assume FIFO order on the links between any two processes, then the open call linearizes before the transfer call.
If $q$ is Byzantine, then the open and transfer calls linearize immediately after they successfully return.
If $p$ is Byzantine, then the transfer invocation is in $H'$ because there is some close invocation by a correct process $q$.
Before that, there is also a matching open call by $p$.
The open call linearizes before the transfer call.
\end{proof}
\begin{lemma}
For any successful $B.\textit{target\_close}((a,b), \ensuremath{\textit{bal}}\xspace_b)$ call in $H'$ there is a preceding $B.\textit{open}((a,b), \ensuremath{\textit{amt}}\xspace)$ call for channel $(a,b)$ s.t. $\ensuremath{\textit{amt}}\xspace \geq \ensuremath{\textit{bal}}\xspace_b$, followed by a $B.\textit{transfer}$ call that changes the state of the channel to $(\ensuremath{\textit{bal}}\xspace_a, \ensuremath{\textit{bal}}\xspace_b)$ for $\ensuremath{\textit{bal}}\xspace_{a} = \ensuremath{\textit{amt}}\xspace - \ensuremath{\textit{bal}}\xspace_b$.
\end{lemma}
\begin{proof}
If the close call ends successfully, then $q$ has in $\textit{target}[ab]$ a valid transaction $A.\textit{transfer}(ab,[(a, \ensuremath{\textit{bal}}\xspace_a), (b, \ensuremath{\textit{bal}}\xspace_b)])$, otherwise, the call fails.
Therefore, if $p$ is a correct process, it opens the channel $(a,b)$ with some deposit \ensuremath{\textit{amt}}\xspace, and transfers in the channel s.t. the balances in the channel change to $(\ensuremath{\textit{bal}}\xspace_a, \ensuremath{\textit{bal}}\xspace_b)$.
Both the open and transfer are linearized before the close invocation, otherwise, the close call fails.
If $p$ is Byzantine, then we add the matching open and transfer invocations to $H'$ which are linearized before the close invocation.
\end{proof}
Finally, we prove resiliency to Byzantine processes.
\begin{lemma}
In an infinite execution of \Cref{alg:uniPaymentChannelImplementation} every call invoked by a correct process eventually returns.
\end{lemma}
\begin{proof}
In all cases where an open or close calls returns \textit{fail} it does so immediately, since it is done prior to any invocation of $A$.
Transfer calls that return due to the if statements (Lines \ref{alg:uniPaymentChannelImplementation:transferCall:if1}, \ref{alg:uniPaymentChannelImplementation:transferCall:if2}) also return immediately.
For the open call, the if condition in the channel open call (\Cref{alg:uniPaymentChannelImplementation:openCallIf}) ensures that the process that invokes the call owns account $a$ and that it has enough balance to open the channel.
We also assume that a correct process does not invoke a new call before a previous call has a response event.
Therefore, the conditions checked during the if statement hold when $A$'s transfer call is invoked, and by the asset transfer specification the call succeeds.
A transfer call that does not invoke any of $A$'s calls, nor does it wait for a reply after it sends the transaction in \Cref{alg:uniPaymentChannelImplementation:transferCallSendTX}.
Therefore, this call also returns immediately.
A target\_close call that returns success invokes $A$ with a transfer call that transfers money from account $ab$ (\Cref{alg:uniPaymentChannelImplementation:closeCallInvokeA}).
To reach this line, the process has to first check if the channel is open, and it has the matching transaction in $\textit{target}[ab]$ during the if statement of the call.
Therefore, invoking $A$ will eventually succeed by the asset transfer specification, and the target\_close call returns successfully.
\end{proof}
Thus, we can conclude the above lemmas with the following result:
\begin{theorem}
\Cref{alg:uniPaymentChannelImplementation} implements a Byzantine sequentially consistent unidirectional payment channel without source close abstraction (Specification~\ref{alg:uniPaymentChannelOps}).
\end{theorem}
\section{Conclusion}
\label{sec:conclusion}
In this paper we presented the possibility of using payment channels in asynchronous asset transfer systems as a scaling solution.
We first proved that without such channels, a payment in an asset transfer system requires a quadratic message complexity per payment.
We then proved that bidirectional payment channels cannot be implemented in asynchrony, and moreover, not all unidirectional payment channels can.
\section{Chain payments}
\label{sec:chain}
We can extend the discussion of payment channels to chain payments.
A chain payment system allows making payments off-chain between users who do not share a direct payment channel between them, but do share a route through intermediate users.
For example, suppose Alice wants to make a payment to Bob, but she does not share a direct payment channel with him.
Rather, she has a channel with Charlie, and Charlie has a channel with Bob.
A chain payment allows using the route from Alice to Bob via Charlie to make the payment on all channels atomically.
Chain payments are used extensively as part of the Lightning Network~\cite{poon2016lightning} on Bitcoin.
The intuitive way of defining a chain payment object is with a single operation that makes a payment through a chain $((a_1, a_2), (a_2, a_3), \ldots, (a_{k-1}, a_k))$, and the outcome of the payment affects all channels of the chain in an atomic manner.
For example, suppose the balances of the above channels of the chain are $(\ensuremath{\textit{bal}}\xspace_1, \ensuremath{\textit{bal}}\xspace_2), (\ensuremath{\textit{bal}}\xspace_2, \ensuremath{\textit{bal}}\xspace_3), \ldots, (\ensuremath{\textit{bal}}\xspace_{k-1}, \ensuremath{\textit{bal}}\xspace_k)$, respectively, and a payment of \ensuremath{\textit{amt}}\xspace is made via the chain.
Then, after the linearization point, the balances of the channels are $(\ensuremath{\textit{bal}}\xspace_1-\ensuremath{\textit{amt}}\xspace, \ensuremath{\textit{bal}}\xspace_2+\ensuremath{\textit{amt}}\xspace), (\ensuremath{\textit{bal}}\xspace_2-\ensuremath{\textit{amt}}\xspace, \ensuremath{\textit{bal}}\xspace_3+\ensuremath{\textit{amt}}\xspace), \ldots, (\ensuremath{\textit{bal}}\xspace_{k-1}-\ensuremath{\textit{amt}}\xspace, \ensuremath{\textit{bal}}\xspace_k+\ensuremath{\textit{amt}}\xspace)$, respectively.
In this case, assuming that the channels are bidirectional or unidirectional with source close, it can be proven that the consensus number of such chain payment object is $k$, meaning this object can be used to solve consensus between $k$ processes, in a similar manner to the $2$-consensus we prove in this paper for these channel types.
We also note that even if the channels of the chain are unidirectional without source close, implementing a chain payment is not intuitive and straightforward in asynchronous networks.
A possible solution is to adopt the use of \emph{Hash Time-Locked Contracts (HTLCs)}~\cite{decker2015fast,HTLCwiki} which are in use in the Lightning Network for chain payments.
An HTLC is a special conditioned payment between two users Alice and Bob.
It asserts that Bob receives the payment if he can present a hash pre-image of a specific value before a timeout, otherwise Alice gets the payment.
If we equip the asset transfer system with a Hash Time Contract operation (without the timeout component), we can implement chain payments in asynchronous networks based on the unidirectional channels without source close we presented in \Cref{alg:uniPaymentChannelImplementation}.
We leave as an open research question other possible asynchronous implementations of chain payments for future work.
\section{Asset Transfer}
\label{sec:assetTransfer}
\subsection{Asset transfer abstraction}
Let $A$ be an asset transfer abstraction, which is based on the one defined in~\cite{guerraoui2019consensus}.
$A$ holds a set of accounts.
Each account $a \in A$ is defined by some public key, and there is a mapping $\textit{owner}(a) \colon A \mapsto \Pi$, that matches for each account $a$ the process that can produce a signature corresponding to the public key associated with $a$.
In case of an account $b$ associated with a multisignature, $\textit{owner}(b)$ is the set of processes whose private keys can produce a signature matching $b$'s public key.
The state of each account $a$ is of the form $A(a) \in \mathbb{R}_{\geq 0}$ and represents the balance of the account~$a$.
Each account initially holds its initial balance.
$A$ has two operations:
The first, $A.\textit{read}(a)$, returns the balance of account $a$, i.e., it returns $A(a)$ and can be called by any process.
The second is $A.\textit{transfer}(a,[(b_1,\ensuremath{\textit{amt}}\xspace_1),\ldots,(b_k,\ensuremath{\textit{amt}}\xspace_k)])$, which, for every $1 \leq i \leq k$, transfers from account $a$'s balance $\ensuremath{\textit{amt}}\xspace_i$ and deposits it in $b_i$.
This call succeeds, and returns \textit{success} if it is called by $\textit{owner}(a)$ and if the account has enough balance to make the transfer, i.e., $A(a) \geq \sum_{i=1}^k \ensuremath{\textit{amt}}\xspace_i$.
Otherwise, it returns \textit{fail} and does nothing.
The \textit{transfer} operation is an extension of the one defined in~\cite{guerraoui2019consensus} in that it allows to transfer money from one account to multiple accounts, whereas the original work only allows transferring money from one account to another each time.
In this paper, we consider implementations of the asset transfer abstraction that are Byzantine sequentially consistent.
In particular, this means that for every transfer operation, there exists a time $t$ such that if a correct process invokes the read operation after $t$, then it observes the changes made by the transfer.
We note that in~\cite{guerraoui2019consensus}, the correctness criteria provided for the asset transfer implementation in the message-passing model is stronger than BSC and weaker than Byzantine linearizability.
Informally, successful transfers by correct processes preserve real-time order, but reads can see a ``stale'' state of an account.
\subsection{Message complexity of asset transfer}
\subsubsection{Lower bound}
The asset transfer implementation we discuss in \Cref{sec:assetTransfer:msgComplexity:UpperBound} below has a message complexity of $O(n^2)$ for the \textit{transfer} operation, and $O(1)$ message complexity for the \textit{read} operation.
We show that if $f \in \Theta(n)$ then this is also the lower bound in runs in which money is transferred to some account $b$, and multiple processes read the balance of $b$.
The proof follows the technique used in Dolev-Reischuk's lower bound for Byzantine Broadcast~\cite{dolev1985bounds}.
Formally we prove the following theorem:
\begin{theorem} \label{thm:assetTransferMsgComplexity}
Consider an algorithm that implements the asset transfer abstraction.
Then there exists a run with a single transfer invocation and multiple read invocations in which correct processes send at least $(f/2)^2$ messages.
\end{theorem}
\begin{proof}
Let $\pi$ be an algorithm that implements asset transfer, and assume by contradiction that in all its runs with a single transfer correct processes send less than $(f/2)^2$ messages.
We look at all executions of $\pi$ with two accounts $a, b \in A$ s.t. $\textit{owner}(a) = p$ for some process $p \in \Pi$, and that initially $A(a) = 1, A(b) = 0$.
Consider first an execution $\sigma_0$ in which the adversary, denoted $\textit{adv}_0$, corrupts a set $V$ of processes, not including $p$, such that $|V| = \lceil f/2 \rceil$.
Denote the set of remaining correct processes as $U$.
In $\sigma_0$, process $p$ calls $A.\textit{transfer}(a, [(b, 1)])$.
By the correctness definition of $A$, and since $p$ is correct, there exists a time $t_0$ during the run after which any correct process that invokes $A.\textit{read}(b)$ returns 1.
The adversary $\textit{adv}_0$ causes the corrupt processes in $V$ to simulate the behavior of correct processes that call $A.\textit{read}(b)$ after $t_0$, and follow the algorithm except for the following changes: they ignore the first $f/2$ messages they receive from processes in $U$, and they do not send any message to other processes in $V$.
Note that while $t_0$ is not known to the processes, we construct the runs from the perspective of a global observer and may invoke read after $t_0$.
Because correct processes send, in total, at most $(f/2)^2$ messages and corrupt processes do not send messages to other processes in $V$, then the processes in $V$ together receive at most $(f/2)^2$ messages.
Thus, by the pigeonhole principle, there exists at least one process $q \in V$ that receives at most $f/2$ messages.
Denote the set of processes that send $q$ messages as $U'$, and denote $U'' = U \setminus U'$.
Note that $U'$ may include process $p$, and that $|U'| < f/2$.
Next, we construct a run $\sigma_1$ with an adversary $\textit{adv}_1$ that are the same as $\sigma_0$ and $\textit{adv}_0$, respectively, except for the following changes: $\textit{adv}_1$ corrupts all the processes in $V \setminus \{q\}$, and all the processes in $U'$.
Since $|U'| < f/2$ and $|V| \leq \lceil f/2 \rceil $, the adversary $\textit{adv}_1$ corrupts at most $f$ processes in $\sigma_1$.
$\textit{adv}_1$ prevents the corrupt processes from sending any message to $q$, but causes them to behave correctly to all other correct processes in $U''$.
By definition, the behavior of the corrupt processes in $\sigma_1$, i.e., the processes in $U' \cup (V \setminus \{q\})$, towards the correct processes in $U''$ is the same as in $\sigma_0$.
Since process $q$ simulates a correct process that ignores the first $f/2$ messages in $\sigma_0$, its behavior towards the processes in $U$ is identical in both runs as well.
Thus, runs $\sigma_0$ and $\sigma_1$ are indistinguishable for the correct processes in $U''$, ensuring that they behave the same.
Since process $q$ acts in $\sigma_0$ like a correct process that does not receive any message, both runs are indistinguishable to it as well.
Nonetheless, process $q$ still has to return a value for its $A.\textit{read}(b)$ call.
Denote the time when the call returns as $t_1$.
If it returns a value different than $1$, then we conclude the proof, since it is a violation of the read call specification.
Otherwise, we construct a run $\sigma_2$ with an adversary $\textit{adv}_2$ that are the same as $\sigma_1$ and $\textit{adv}_1$, respectively, except that there is no transfer invocation and all messages to $q$ are delayed until after $t_1$.
For process $q$, runs $\sigma_1$ and $\sigma_2$ are indistinguishable until $t_1$, therefore it returns $1$ for the $A.\textit{read}(b)$ call, violating the read call specification which should return $0$, concluding the proof.
\end{proof}
We proved that the lower bound for the message complexity of an asset transfer object is $\Omega(n^2)$, assuming $f \in \Theta(n)$.
\subsubsection{Upper bound}
\label{sec:assetTransfer:upperBound} \label{sec:assetTransfer:msgComplexity:UpperBound}
In~\cite{guerraoui2019consensus}, an implementation in the message-passing model for the asset transfer abstraction is provided.
It uses a broadcast service defined in~\cite{malkhi1997high} that tolerates up to $f < n/3$ Byzantine failures.
This broadcast has all the guarantees of reliable broadcast~\cite{bracha1987asynchronous} (integrity, agreement, and validity), and also preserves source order, i.e., any two correct processes $p_1$ and $p_2$ that deliver messages $m$ and $m'$ broadcast from the same process $p_3$, do so in the same order.
The read operation is locally computed, and the transfer operation consists of a broadcast of a single message.
There are several protocols that can be used to implement such source-order broadcast service, including a protocol in~\cite{malkhi1997high}.
Bracha's reliable broadcast~\cite{bracha1987asynchronous} can also be used to implement such a service if each correct process adds a sequence number to each message it broadcasts, and each correct process delivers messages from the same process in the order of the sequence numbers.
These protocols have a message complexity of $O(n^2)$ per broadcast, proving that the lower bound message complexity we prove above is tight.
Note that our definition for the \textit{transfer} call of the asset transfer abstraction allows transferring in each invocation money from one account to multiple accounts, while in~\cite{guerraoui2019consensus} the transfer call allows a transfer to a single account for each invocation.
The implementation in~\cite{guerraoui2019consensus} can easily be adjusted to support this change by including in each broadcast message the multiple accounts to which money is transferred.
\section{Related work}
A few works identified that a transfer-like system can be implemented in asynchrony~\cite{pedone2002handling,gupta2016non}.
The first abstraction definition of asset transfer is due to Guerraoui et al.~\cite{guerraoui2019consensus}.
Auvolat et al.~\cite{auvolat2020money} provide a weaker specification for asset transfer and implement using broadcast that guaranteed FIFO order between every two processes.
There is a lot of research done on scaling cryptocurrencies using payment channels, e.g.,~\cite{poon2016lightning,lind2019teechain,green2017bolt,miller2017sprites,dziembowski2017perun}.
They all rely on underlying synchronous blockchains to operate.
Other types proposals for second layer on top of blockchains also exist, e.g.,~\cite{kalodner2018arbitrum,ben2018scalable,garoffolo2020zendoo}.
To the best of our knowledge, we are the first paper to explore second-layer payment channels as a scaling solution for money transfer in the asynchronous setting.
\section{Biderctional payment channel}
\label{sec:biChannel}
We seek to analyze if payment channels that are used in common blockchains as a second layer can also be used in a similar manner on top of an asynchronous asset transfer system.
We discuss bidirectional payment channels, in which a channel is opened between two processes by making a transfer on the asset transfer system.
After the channel is opened, both processes can make bidirectional payments on the same channel.
Either process can close the channel at any time, after which their accounts in the asset transfer system reflect the state of the channel.
This abstraction is similar to payment channels in the Lightning Network~\cite{poon2016lightning} in Bitcoin~\cite{nakamoto2008bitcoin} and Raiden~\cite{raiden2020raidenImp} in Ethereum~\cite{wood2014ethereum}.
First, we formally define this abstraction, and then provide an impossibility result, proving it cannot be implemented in asynchronous networks.
\subsection{Definition}
\begin{specification}[t] \smaller
\caption{\textbf{Bidirectional payment channel abstraction.} Operations for process $p$.}
\SetAlgoNoEnd
\label{alg:bidirectionalChannelAPI}
\DontPrintSemicolon
\SetInd{0.4em}{0.4em}
\let\oldnl\n
\newcommand{\renewcommand{\nl}{\let\nl\oldnl}}{\renewcommand{\nl}{\let\nl\oldnl}}
\SetKwBlock{sharedObjects}{Shared Objects:}{}
\SetKwBlock{localVariables}{Local variables:}{}
\SetKwProg{myproc}{Procedure}{:}{}
\SetKwProg{myfunc}{Function}{:}{}
\renewcommand{\nl}{\let\nl\oldnl} \sharedObjects{
\renewcommand{\nl}{\let\nl\oldnl} $A$ - asset transfer object \;
\renewcommand{\nl}{\let\nl\oldnl} $BC$ - Bidirectional payment channel object
}
\begin{multicols}{2}
\myproc{$BC.\textit{transfer}((a,b),\ensuremath{\textit{amt}}\xspace)$} {
\If{$BC(a,b) = \bot $} {
\Retur
}
$(\ensuremath{\textit{bal}}\xspace_a, \ensuremath{\textit{bal}}\xspace_b) \gets BC(a,b)$ \;
\If{$\textit{owner}(a) = p \wedge \ensuremath{\textit{bal}}\xspace_a \geq \ensuremath{\textit{amt}}\xspace$} {
$\textit{execute\_payment}((a,b), -\ensuremath{\textit{amt}}\xspace, \ensuremath{\textit{amt}}\xspace) $\;
}
\If{$\textit{owner}(b) = p$ and $\ensuremath{\textit{bal}}\xspace_b \geq \ensuremath{\textit{amt}}\xspace$} {
$\textit{execute\_payment}((a,b), \ensuremath{\textit{amt}}\xspace, -\ensuremath{\textit{amt}}\xspace) $\;
}
}
\BlankLine
\myproc{$BC.\textit{close}((a,b), \ensuremath{\textit{bal}}\xspace)$} {
\If{$B(a,b) = \bot$} {
\Return \textit{fail}
}
$(\textit{curr\_bal}_a, \textit{curr\_bal}_b) \gets BC(a,b)$ \;
$\textit{other\_bal} = \textit{curr\_bal}_a+\textit{curr\_bal}_b-\ensuremath{\textit{bal}}\xspace$ \;
\If{$\textit{owner}(a) = p $} {
\If{$\ensuremath{\textit{bal}}\xspace > \textit{curr\_bal}_a $}{
\Return \textit{fail}
}
\Return $\textit{execute\_close}((a,b), \ensuremath{\textit{bal}}\xspace, \textit{\textit{other\_bal}})$
}
\If{$\textit{owner}(b) = p $} {
\If{$\ensuremath{\textit{bal}}\xspace > \textit{curr\_bal}_b $}{
\Return \textit{fail}
}
\Return $\textit{execute\_close}((a,b), \textit{other\_bal}, \ensuremath{\textit{bal}}\xspace)$
}
\Return \textit{fail}
}
\myfunc{$\textit{execute\_payment}((a,b), \ensuremath{\textit{amt}}\xspace_a, \ensuremath{\textit{amt}}\xspace_b) $}
{
$(\ensuremath{\textit{bal}}\xspace_a, \ensuremath{\textit{bal}}\xspace_b) \gets BC(a,b)$ \;
$\textit{new\_bal}_a \gets \ensuremath{\textit{bal}}\xspace_a + \ensuremath{\textit{amt}}\xspace_a$ \;
$\textit{new\_bal}_b \gets \ensuremath{\textit{bal}}\xspace_b + \ensuremath{\textit{amt}}\xspace_b$ \;
$ BC(a,b) \gets (\textit{new\_bal}_a, \textit{new\_bal}_b)$ \;
}
\BlankLine
\myfunc{$\textit{execute\_close}((a,b), \ensuremath{\textit{amt}}\xspace_a, \ensuremath{\textit{amt}}\xspace_b) $} {
$A(a) \gets A(a) + \ensuremath{\textit{amt}}\xspace_a$ \;
$A(b) \gets A(b) + \ensuremath{\textit{amt}}\xspace_b$ \;
$BC(a,b) \gets \bot$ \;
\Return \textit{success}
}
\end{multicols}
\end{specification}
\newcommand{\ensuremath{BC}}{\ensuremath{BC}}
We define a bidirectional payment channel abstraction as a shared memory object $\ensuremath{BC}$.
The formal definition is in Specification~\ref{alg:bidirectionalChannelAPI}.
$\ensuremath{BC}$ is defined based on the existence of an asset transfer object $A$.
A payment channel in $\ensuremath{BC}$ is of the form $(a, b)$, where $a, b$ are accounts in $A$.
The state of a payment channel $\ensuremath{BC}(a,b)$ is ${\{\mathbb{R}_{\geq 0} \times \mathbb{R}_{\geq 0} \} \cup \{\bot \}}$.
The channel $\ensuremath{BC}(a,b)$ can be \emph{open}, and then $\ensuremath{BC}(a,b) = (\ensuremath{\textit{bal}}\xspace_a, \ensuremath{\textit{bal}}\xspace_b)$, which represents the balances $\ensuremath{\textit{bal}}\xspace_a, \ensuremath{\textit{bal}}\xspace_b$ of accounts $a,b$ in the channel $(a,b)$, respectively.
If the channel is \emph{closed}, then its state is $\ensuremath{BC}(a,b) = \bot$.
The set of operations is the following:
\begin{itemize}
\item $\textit{open}$.
We do not provide a detailed specification for this call, as we do not require the full specification to prove that there is no implementation for a bidirectional payment channel in the asynchronous message-passing model.
Instead, we assume that all channels are open at the beginning of the run with some initial balances.
\item $\textit{transfer}((a,b),\ensuremath{\textit{amt}}\xspace)$.
A payment in channel $(a,b)$ is possible if the channel is open, if the caller process is a valid owner of either $a$ or $b$, and the caller's balance in the channel is enough to make the payment. Otherwise, it does nothing.
After the call ends, the state $\ensuremath{BC}(a,b)$ is changed to reflect the payment.
\item $\textit{close}((a,b), \ensuremath{\textit{bal}}\xspace)$.
This call can be invoked if the caller process is a valid owner of either $a$ or $b$.
The close of the channel is successful if the process that invokes the call does not try to close it with balance \ensuremath{\textit{bal}}\xspace that exceeds the amount it has in the channel.
Otherwise, the call fails and does nothing.
The call transfers to accounts $a,b$ their balances from the channel, and then changes its status to $\bot$.
This call returns \textit{success} or \textit{fail} to indicate the outcome of the call.
\end{itemize}
In this paper, we consider a sequentially consistent bidirectional channel.
\subsection{Impossibility result of a bidirectional payment channel object}
\begin{algorithm*}[t] \smaller
\caption{\textbf{Wait-free implementation of consensus among 2 processes using a bidirectional payment channel.} Operations for processes $p_1 = \textit{owner}(a), p_2 = \textit{owner}(b)$}
\SetAlgoNoEnd
\label{alg:reductionConsensuswithBidirectionalChannel1}
\DontPrintSemicolon
\SetInd{0.4em}{0.4em}
\let\oldnl\n
\newcommand{\renewcommand{\nl}{\let\nl\oldnl}}{\renewcommand{\nl}{\let\nl\oldnl}}
\SetKwBlock{sharedObjects}{Shared Objects:}{}
\SetKwProg{myproc}{Procedure}{:}{}
\SetKwProg{myfunc}{Function}{:}{}
\renewcommand{\nl}{\let\nl\oldnl} \sharedObjects{
\renewcommand{\nl}{\let\nl\oldnl} $A$ - asset transfer object, initially two accounts $a, b \in A$ s.t. $A(a) = A(b) = 0$ \;
\renewcommand{\nl}{\let\nl\oldnl} $\ensuremath{BC}$ - Bidirectional payment channel object, initially $\ensuremath{BC}(a,b) = (1,1)$ \;
\renewcommand{\nl}{\let\nl\oldnl} $R_1, R_2$ - shared registers with read write calls, initially $R_1 = R_2 = \bot$ \;
}
\BlankLine \BlankLine
\tcp*[h]{We assume that at the beginning of the run there exists an open payment channel $(a,b)$ s.t. $\ensuremath{BC}(a,b) = (1,1)$} \;
\vspace{-1.5em}
\begin{multicols}{2}
\tcp*[h]{\underline{Algorithm for process $p_1$}:} \;
\myproc{$\textit{propose}(v)$} {
$R_1.\textit{write}(v)$ \label{alg:reductionConsensuswithBidirectionalChannel:r1write}\;
$\ensuremath{BC}.\textit{transfer}((a,b),1) $\;
$\ensuremath{BC}.\textit{close}((a,b), 0)$ \label{alg:reductionConsensuswithBidirectionalChannel1:p1close}\;
\Return $\textit{make\_decision}()$ \;
}
\BlankLine
\tcp*[h]{\underline{Algorithm for process $p_2$:}} \;
\myproc{$\textit{propose}(v)$} {
$R_2 .\textit{write}(v)$ \label{alg:reductionConsensuswithBidirectionalChannel:r2write}\;
$\ensuremath{BC}.\textit{close}((a,b), 1)$ \label{alg:reductionConsensuswithBidirectionalChannel1:p2close} \;
\Return $\textit{make\_decision}()$ \;
}
\break
\BlankLine
\tcp*[h]{\underline{Algorithm for process $p_1$ and $p_2$:}} \;
\myproc{$\textit{make\_decision}()$ } {
\textbf{wait} until $A.\textit{read}(b) \neq 0$ \label{alg:reductionConsensuswithBidirectionalChannel:ARead}\;
\uIf{$A.\textit{read}(b) = 2$} {
\Return $R_1.\textit{read}()$ \;
}
\Else {
\Return $R_2.\textit{read}()$ \;
}
}
\end{multicols}
\end{algorithm*}
We show that implementing a sequentially consistent bidirectional payment channel in the message-passing model requires synchrony.
To this end, we solve wait-free consensus among $2$ processes with shared registers and an instance of $\ensuremath{BC}$.
The consensus abstraction has one call, $\textit{propose}(v)$, which is called with some proposal $v$, and returns a value.
The returned value for any process making the call has to be an input of the call from one of the processes, and it has to be the same value for all invocations, regardless of the caller process.
We assume in this proof \emph{crash-fail} faults, i.e., a process corrupted by the adversary stops participating in the protocol, but does not deviate from it.
Since this is an impossibility result and crash-fail faults are weaker than Byzantine faults, it also applies to runs with Byzantine processes as well.
\begin{lemma} \label{lem:consensusNumBiChannel}
Consensus has a wait-free implementation for $2$ processes in the read-write shared memory model with an instance of a bidirectional payment channel shared-memory object and shared registers.
\end{lemma}
\begin{proof}
The algorithm for solving consensus among two processes using a bidirectional payment channel object is detailed in Alg.~\ref{alg:reductionConsensuswithBidirectionalChannel1}.
We assume that there are two processes $p_1, p_2$ with ownership of accounts $a,b$, respectively, and an open payment channel $(a,b)$ at the beginning of the run with balances $\ensuremath{BC}(a,b) = (1,1)$.
Before either of the processes performs an operation on the payment channel, they write their proposal $v$ in a shared register (Lines~\ref{alg:reductionConsensuswithBidirectionalChannel:r1write} and~\ref{alg:reductionConsensuswithBidirectionalChannel:r2write}).
Then, $p_1$ attempts to make a payment on the channel and then close it, and $p_2$ tries to close the channel without making or accepting any payment.
Because $BC$ is sequentially consistent, the algorithm ensures that eventually after the channel is closed either the payment from $a$ to $b$ on the channel succeeds or not, and the balance in $b$'s account reflects it, i.e., there exists a time $t$ after which invoking $A.\textit{read}(b)$ returns either $1$ or $2$.
If the read call in \Cref{alg:reductionConsensuswithBidirectionalChannel:ARead} returns $2$, then the channel was closed by $p_1$ after it successfully made the payment on the channel.
Since before $p_1$ makes the payment on the channel it writes its proposal to register $R_1$, then its value is already written by the time the channel is closed, and it is returned by the propose call.
If the return value of the read call is~$1$, then process $p_2$ closed the channel.
Since $p_2$ closes the channel after it writes its proposal in $R_2$, then its proposed value is returned.
In either case, when the channel is closed, there is already a proposal written in either $R_1$ or $R_2$, i.e., the returned value is an input to the propose call by either process, and both processes return the same value.
\end{proof}
Based on the above theorem and FLP~\cite{fischer1985FLP}, we get the following result:
\begin{theorem} \label{cor:bidirectionalAsync}
There does not exist an implementation of the bidirectional payment channel abstraction in the asynchronous message-passing model.
\end{theorem}
|
{'timestamp': '2022-02-15T02:44:15', 'yymm': '2202', 'arxiv_id': '2202.06693', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06693'}
|
arxiv
|
\section{Introduction}
Heat monitoring analysis plays an important role in many expensive engineering systems \cite{Yao2011,Zheng2019,Zheng2020}, such as airplanes, satellites, rockets, etc. If the system overheats, it can lead to system failure or even serious disaster. Generally, the heat monitoring analysis is performed using the temperatures measured by many sensors. However, a limited number of temperature monitoring sensors can not provide detailed temperature information at any location of the system, which will result in the heat monitoring analysis results being inaccurate. Therefore, it is essential to reconstruct the temperature field of the whole system based on the temperature measured by sensors.
In recent years, CNN has been applied in many engineering problems \cite{Zhang2020, Zhaoxiaoyu2020, Ronneberger2015} due to its powerful image feature extraction ability. For the TFR, it is a complex image-to-image regression problem. Thus, this paper chooses CNN to reconstruct the temperature field using sensor monitoring temperatures as inputs. It is important to notice that engineers hardly obtain each input's label, i.e., temperature field. However, the training of CNN usually requires a large amount of labeled training data. In order to solve the problem of insufficient labeled data, the physics-informed CNN is used to bearing fault detection \cite{Shen2021}, partial differential equation solution \cite{Fang2021A,Gao2021PhyGeoNet,Gao2021Super}, topology optimization \cite{Zhang2021TONR}. For the TFR, the steady-state temperature field meets the Laplace equation \cite{Gongzq2021,Zhaoxiaoyu2020} and some boundary conditions. Thus, this paper uses physical knowledge to guide the training of CNN.
The training of CNN is essentially extracting model parameters from training data. The trained model is then used to make predictions. Generally, the training data may include data noise which will result in aleatoric uncertainty \cite{Postels2019} in the prediction results. Unlike epistemic uncertainty \cite{Gal2016} can be eliminated by increasing the number of training data, aleatoric uncertainty is inherent to the training data with noise. In recent years, many methods \cite{Kendall2017,Lakshminarayanan2017,Liu2019,Tagasovska2019,Malinin2020} have been studied to quantify aleatoric uncertainty. Given the Gaussian distribution input hypothesis, one common approach of aleatoric uncertainty quantification is that one output of the neural network is used to estimate the conditional variance of the prediction by maximizing likelihood estimation \cite{Kendall2017, Lakshminarayanan2017}. The obvious disadvantage of this approach is that it can only quantify Gaussian random noise. Another approach, simultaneous quantile regression (SQR)\cite{Tagasovska2019}, is to quantify aleatoric uncertainty based on quantile regression \cite{Koenker2004,Takeuchi2006}. In the model training process, this approach randomly samples the quantile level between 0 and 1 for each training data and mini-batch. Compared with the previous approach, SQR can estimate the aleatoric uncertainty in data without Gaussian distribution input assumptions or anything else. Inspired by this approach, this paper proposes a Deep MC-QR method for reconstructing the temperature field and quantifying aleatoric uncertainty caused by data noise.
The main contributions of this paper include the following two points:
\begin{itemize}
\item By physical knowledge to guide the training of CNN, the proposed Deep MC-QR method can reconstruct an accurate TFR surrogate model without any labeled training data;
\item By constructing a quantile level image for each monitoring point temperature image, the proposed Deep MC-QR method can quantify aleatoric uncertainty.
\end{itemize}
\section{Related Work}
\subsection{Quantile Regression}
Suppose that there is a stochastic system $ \bm{Y}=f\left(\bm{X}\right) $ with the random input variable $ \bm{X} $. The cumulative distribution function of the output $ \bm{Y} $ taking the value $ \bm{y} $ is $ F_{\bm{Y}|\bm{X}=\bm{x}}\left(\bm{y}|\bm{x}\right)=P\left(\bm{Y} \le \bm{y}\right) $. Thus, the $\tau$ quantile $Q_{\tau}\left(\bm{Y}|\bm{X}=\bm{x}\right)$ of the output $\bm{Y}$ is
\begin{equation}
Q_{\tau}\left(\bm{Y}|\bm{X}=\bm{x}\right) = F_{\bm{Y}|\bm{X}=\bm{x}}^{-1}\left(\tau\right),
\end{equation}
where $\tau$ ($0 \le \tau \le 1$) is the quantile level. The quantile regression constructs a surrogate model $ \hat{\bm{Y}}=\hat{f}_{\tau}(\bm{X}) $ to approximate the stochastic system $ \bm{Y}=f\left(\bm{X}\right) $. Given $\mathcal{K}$ training data $\left\{\left(\bm{x}_k, \bm{y}_k\right)| k=1,2,\cdots, \mathcal{K}\right\}$, the surrogate model $ \hat{\bm{Y}}=\hat{f}_{\tau}(\bm{X}) $ is trained by minimizing the pinball loss function $ \mathcal{L}\left[ {{w}_{i}},{{{\hat{f}}}_{\tau}}\left( \bm{v}_i \right) \right] $ \cite{Takeuchi2006, Tagasovska2019}, i.e.,
\begin{equation}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
\begin{aligned}
& \mathcal{L}\left[ {{\bm{y}}_{k}},{{{\hat{f}}}_{\tau}}\left( \bm{x}_k \right) \right]=\frac{1}{\mathcal{K}}\sum\limits_{k=1}^{\mathcal{K}}{{{\ell}_{\tau}}\left[ {{\bm{y}}_{k}},{{{\hat{f}}}_{\tau}}\left( {{\bm{x}}_{k}} \right) \right]}, \\
& {{\ell}_{\tau}}\left[ {{\bm{y}}_{k}},{{{\hat{f}}}_{\tau}}\left( {{\bm{x}}_{k}} \right) \right]=\left\{ \begin{matrix}
\tau\left( {{\bm{y}}_{k}}-{{{\hat{\bm{y}}}}_{k}} \right), & {{\bm{y}}_{k}}\ge {{{\hat{\bm{y}}}}_{k}} \\
\left( 1-\tau \right)\left( {{{\hat{\bm{y}}}}_{k}}-{{\bm{y}}_{k}} \right), & {{\bm{y}}_{k}}<{{{\hat{\bm{y}}}}_{k}} \\
\end{matrix} \right.,
\end{aligned}
\end{equation}
where ${{\bm{\hat{y}}}_{k}}={{\hat{f}}_{\tau}}\left( {{\bm{x}}_{k}} \right)$ is the prediction corresponding to the input $ \bm{x}_{k} $.
\subsection{Temperature Field Reconstruction}
As shown in Fig.\ref{TFR}, there is an green rectangular area $\Omega$ with length $ W $ and width $ H $, where the grey areas $ {\Omega}_{HS} $ of circles, capsules and rectangles are heat sources. The yellow rectangle with width $ \delta $ is the position of the heat sink. The diagonal shaded area around $\Omega$ is adiabatic. Besides, the red points are the positions $ {\Omega}_{MP} $ of the temperature monitoring sensors. Supposed that there are $ N_{MP} $ temperature monitoring sensors in the rectangular area $\Omega$.
\begin{figure}[htbp]
\setlength{\abovecaptionskip}{-0.03cm}
\centering
{\includegraphics[scale=0.7]{TFR}}
\caption{A rectangular area heat source system.}
\label{TFR}
\end{figure}
For this green rectangular area $\Omega$, its steady-state temperature field $ \bm{T} $ meets the Laplace equation \cite{Zhaoxiaoyu2020, Gongzq2021}, i.e.,
\begin{equation}\label{laplace}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
\frac{{{\partial }^{2}}\bm{T}\left( u,v \right)}{\partial {{u}^{2}}}+\frac{{{\partial }^{2}}\bm{T}\left( u,v \right)}{\partial {{v}^{2}}}+\bm{\varphi }\left( u,v \right)=0, \quad \left( u,v \right)\in \Omega,
\end{equation}
and the boundary condition
\begin{equation}\label{BC}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
\bm{T}\left( u,v \right)={{T}_{0}},\quad \left( u,v \right)\in {{\Omega }_{BC}},
\end{equation}
where $\left( u,v \right)$ denotes the position coordinate, $T_0$ is a constant temperature, $\bm{\varphi }$ is the heat source intensity distribution depending on the power of heat source, and $ {{\Omega }_{BC}} $ denotes the boundary (red line in Fig.\ref{TFR}). Generally, the heat source intensity distribution $\bm{\varphi }$ is unknown in the TFR problem. Thus, the TFR problem only considers the heat conduction in the area ${\Omega }_{NC}$ without heat sources, i.e.,
\begin{equation}\label{laplace_nmp}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
\frac{{{\partial }^{2}}\bm{T}\left( u,v \right)}{\partial {{u}^{2}}}+\frac{{{\partial }^{2}}\bm{T}\left( u,v \right)}{\partial {{v}^{2}}}=0, \quad \left( u,v \right)\in {{\Omega }_{NC}}.
\end{equation}
For the TFR problem, its objective is to reconstruct the temperature field of the rectangular area $\Omega$ from the temperatures of some monitoring points, as shown in Fig.\ref{TFR_problem}.
\begin{figure}[htbp]
\vspace{-0.2cm}
\setlength{\abovecaptionskip}{-0.005cm}
\centering
{\includegraphics[scale=0.65]{TFR_problem}}
\caption{Temperature Field Reconstruction by monitoring point temperatures.}
\label{TFR_problem}
\end{figure}
\section{Deep Monte Carlo Quantile Regression}
\subsection{Physics-informed Deep MC-QR model}\label{sect31}
In this paper, the rectangular area $\Omega$ is discretized into a $ h \times w $ two-dimensional array. According to the positions $ {\Omega}_{MP} $ of the temperature monitoring sensors, the corresponding element values in the $ h \times w $ two-dimensional array are equal to the the monitoring point temperatures. The rest of element values are set to be zero. Thereby, a monitoring point (MP) temperature image $ \bm{T}_{MP} $ is constructed as shown in Fig.\ref{CNN_input} (left). Besides, this paper also builds a quantile level image $ \bm{\tau} $ as shown in Fig.\ref{CNN_input} (right). Different from the MP temperature image $ \bm{T}_{MP} $, the values of element in the positions $ {\Omega}_{MP} $ are equal to $ \tau $ for the quantile level image $ \bm{\tau} $, where $ \tau $ is randomly sampled from the uniform distribution $ U\left(0, 1\right) $.
\begin{figure}[htbp]
\vspace{-0.26cm}
\setlength{\abovecaptionskip}{-0.03cm}
\centering
{\includegraphics[scale=0.65]{CNN_input}}
\caption{Temperature field reconstruction by monitoring point temperatures.}
\label{CNN_input}
\end{figure}
This paper builds a physics-informed Deep MC-QR model which can use the MP temperature image $ \bm{T}_{MP} $ and the quantile level image $ \bm{\tau} $ to reconstruct the temperature field of the rectangular area $\Omega$, as shown in Fig.\ref{MCQR_CNN}. The physics-informed Deep MC-QR model with two input channels includes two U-net \cite{Ronneberger2015} models, i.e., U-net-1 and U-net-2. Firstly, U-net-1 extracts the feature map of input $\left( {{\bm{T}}_{MP}},\bm{\tau } \right)$. Then, the feature map is flipped diagonally to ensure the reconstruction accuracy of temperature field in the upside and right-side boundaries \cite{Gongzq2021}. Finally, U-net-2 uses the flipped feature map to predict the temperature field $\hat{\bm{T}}$ of the rectangular area $\Omega$.
\begin{figure}[!htbp]
\setlength{\abovecaptionskip}{-0.03cm}
\centering
{\includegraphics[scale=0.35]{MCQR_CNN}}
\caption{The physics-informed Deep MC-QR model.}
\label{MCQR_CNN}
\end{figure}
Supposed that the physics-informed Deep MC-QR model is denoted as $ \mathcal{MQNN}\left(\bm{T}_{MP}, \bm{\tau}; \bm{\theta}\right) $, where $ \bm{\theta} $ denotes the parameters of U-net-1 and U-net-2. Based on the training dataset $\left\{\left(\bm{T}^i_{MP}, \bm{\tau}_i\right)|i=1,2,\cdots,N \right\}$, the parameters $\bm{\theta}$ are learned by minimizing the following proposed physics-informed loss function $\mathcal{L}\left(\theta\right)$.
\begin{itemize}
\item \textbf{Quantile MP temperature loss $ \mathcal{L}_{\tau}\left( \bm{\theta} \right) $}
\end{itemize}
For the $i\text{th}$ MP temperature image $ \bm{T}^{i}_{MP} $, the predicted temperature field $\hat{\bm{T}}$ of the satellite subsystem is $ {\hat{\bm{T}}_i}=\mathcal{M}\left(\bm{T}^{i}_{MP}, \bm{\tau}_{i}; \bm{\theta}\right) $. For $ \left ( u,v \right ) \in {\Omega}_{MP} $, the error $ {{\ell}_{{\tau}_i}}\left( u,v;\bm{\theta} \right) $ is
\begin{equation}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
{{\ell}_{{\tau}_i}}\left( u,v;\bm{\theta} \right) = {\tau}_i\left[ {{\bm{T}^i_{MP}}\left(u,v\right)}-{{\hat{\bm{T}_i}}\left( u,v \right)} \right]
\end{equation}
for the condition $ {{\bm{T}^i_{MP}}\left(u,v\right)}\ge {{\hat{\bm{T}_i}}\left( u,v \right)} $, and
\begin{equation}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
{{\ell}_{{\tau}_i}}\left( u,v;\bm{\theta} \right) = \left( 1-{\tau}_i\right)\left( {{\hat{\bm{T}_i}}\left( u,v \right)}-{{\bm{T}^i_{MP}}\left(u,v\right)} \right)
\end{equation}
for the condition $ {{\bm{T}^i_{MP}}\left(u,v\right)}<{{\hat{\bm{T}_i}}\left( u,v \right)} $, where ${\tau}_i \sim U\left ( 0, 1 \right ) $. Thus, the quantile MP temperature loss $ \mathcal{L}_{\tau}\left( \bm{\theta} \right) $ is
\begin{equation}\label{QMPT_loss}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
\mathcal{L}_{\tau}\left( \bm{\theta} \right)=\frac{1}{N}\frac{1}{N_{MP}}\sum\limits_{i=1}^{N}{\sum_{\left ( u,v \right ) \in {\Omega}_{MP}} {{{\ell}_{{\tau}_i}}\left( u,v;\bm{\theta} \right)}}.
\end{equation}
\begin{itemize}
\item \textbf{Laplace equation loss $ \mathcal{L}_{LE}\left( \bm{\theta} \right) $}
\end{itemize}
Assumed that each discretized MP temperature image $ \bm{T}^{i}_{MP} $ has $N_{NC}$ points for $ \left( u,v \right)\in {{\Omega }_{NC}} $. Discretizing the Laplace equation (\ref{laplace_nmp}), ${{{\partial }^{2}}\hat{\bm{T}}_i\left( u_j,v_k \right)}/{\partial {{u}_j^{2}}}$ and $ {{\partial }^{2}}\hat{\bm{T}}_i\left( u_j,v_k \right)/{\partial {{v}_k^{2}}} $ are transformed respectively to be
\begin{equation}\label{le_X_discre_simple}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
\frac{{{\partial }^{2}}\hat{\bm{T}}_i\left( u_j,v_k \right)}{\partial {{u}_j^{2}}}=\frac{\Delta {{{\hat{\bm{T}}}}^i_{j+1}}\Delta {{u}_{j}}-\Delta {{{\hat{\bm{T}}}}^i_{j}}\Delta {{u}_{j+1}}}{\Delta {{u}_{j+1}}{{\Delta }^{2}}{{u}_{j}}}
\end{equation}
and
\begin{equation}\label{le_Y_discre_simple}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
\frac{{{\partial }^{2}}\hat{\bm{T}}_i\left( {{u}_{j}},{{v}_{k}} \right)}{v_{k}^{2}}=\frac{\Delta {{{\hat{\bm{T}}}}^i_{k+1}}\Delta {{v}_{k}}-\Delta {{{\hat{\bm{T}}}}^i_{k}}\Delta {{v}_{k+1}}}{\Delta {{v}_{k+1}}{{\Delta }^{2}}{{v}_{k}}},
\end{equation}
where $ \Delta {{u}_{j}}={{u}_{j}}-{{u}_{j-1}} $, $ \Delta {{v}_{k}}={{v}_{k}}-{{v}_{k-1}} $, $ \Delta {{\hat{\bm{T}}}^i_{j}}=\hat{\bm{T}}_i\left( {{u}_{j}},{{v}_{k}} \right)-\hat{\bm{T}}_i\left( {{u}_{j-1}},{{v}_{k}} \right) $ and $ \Delta {{\hat{\bm{T}}}^i_{k}}=\hat{\bm{T}}_i\left( {{u}_{j}},{{v}_{k}} \right)-\hat{\bm{T}}_i\left( {{u}_{j}},{{v}_{k-1}} \right) $. Thus, the Laplace equation loss $ \mathcal{L}_{LE}\left( \bm{\theta} \right) $ for $ {\left( u,v \right)\in {{\Omega }_{NC}}} $ is
\begin{equation}\label{LE_loss}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
{{\mathcal{L}}_{LE}}\left( \bm{\theta } \right)=\frac{1}{N}\frac{1}{{{N}_{NC}}}\sum\limits_{i=1}^{N}{\sum\limits_{\left( u,v \right)\in {{\Omega }_{NC}}}{{{\left| \frac{{{\partial }^{2}}\hat{\bm{T}}_i\left( u,v \right)}{\partial {{u}^{2}}}+\frac{{{\partial }^{2}}\hat{\bm{T}}_i\left( u,v \right)}{\partial {{v}^{2}}} \right|}^{2}}}}.
\end{equation}
\begin{itemize}
\item \textbf{Boundary condition loss $ \mathcal{L}_{BC}\left( \bm{\theta} \right) $}
\end{itemize}
According to (\ref{BC}), the boundary condition loss $ \mathcal{L}_{BC}\left( \bm{\theta} \right) $ for $N$ MP temperature images $\left\{ \bm{T}^i_{MP}|i=1,2,\cdots,N \right\}$ is
\begin{equation}\label{bc_loss}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
{{\mathcal{L}}_{BC}}\left( \bm{\theta } \right)=\frac{1}{N}\frac{1}{{{N}_{BC}}}\sum\limits_{i=1}^{N}{\sum\limits_{\left( u,v \right)\in {{\Omega }_{BC}}}{{{\left| {{{\hat{\bm{T}}}}_{i}}\left( u,v \right)-{{T}_{0}} \right|}^{2}}}}.
\end{equation}
where $N_{BC}$ means the number of points $\left(u,v\right)$ in the area ${{\Omega }_{BC}}$ of each discretized MP temperature image $ \bm{T}^{i}_{MP} $.
\begin{itemize}
\item \textbf{TV regularization $ \mathcal{L}_{TV}\left( \bm{\theta} \right) $}
\end{itemize}
TV regularization \cite{Rudin1992, Gongzq2021}, as shown in (\ref{tv}), can maintain the smoothness of the image,
\begin{equation}\label{tv}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
{{\mathcal{R}}_{{{V}^{\beta }}}}=\int_{\Omega }{{{\left\{ {{\left[ \frac{\partial f\left( u,v \right)}{\partial u} \right]}^{2}}+{{\left[ \frac{\partial f\left( u,v \right)}{\partial v} \right]}^{2}} \right\}}^{\frac{\beta }{2}}}}dudv,
\end{equation}
where $ f\left(u,v\right) $ is a continuous function. Due to the property that the steady-state temperature field will not mutate sharply, this paper adopts TV regularization to assist the training of model $ \mathcal{MQNN}\left(\bm{T}_{MP}, \bm{\tau}; \bm{\theta}\right) $. The TV regularization $ \mathcal{L}_{TV}\left( \bm{\theta} \right) $ ($\beta=2$) is transformed to be (\ref{tv_loss}) by the finite-difference approximation, i.e.,
\begin{equation}\label{tv_loss}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
\begin{aligned}
& \mathcal{L}_{TV}^{u}\left( \bm{\theta } \right)=\frac{1}{h\times \left(w-1\right)}\sum\limits_{k=1}^{h}{\sum\limits_{j=1}^{w-1}{{{\left( \Delta\hat{\bm{T}}_{j}^{TV} \right)}^{2}}}}, \\
& \mathcal{L}_{TV}^{v}\left( \bm{\theta } \right)=\frac{1}{\left( h-1 \right)\times w}\sum\limits_{j=1}^{w}{\sum\limits_{k=1}^{h-1}{{{\left( \Delta\hat{\bm{T}}_{k}^{TV} \right)}^{2}}}}, \\
& {{\mathcal{L}}_{TV}}\left( \bm{\theta } \right)=\frac{1}{N}\sum\limits_{i=1}^{N}{\left[ \mathcal{L}_{TV}^{u}\left( \bm{\theta } \right)+\mathcal{L}_{TV}^{v}\left( \bm{\theta } \right) \right]}, \\
\end{aligned}
\end{equation}
where $ \Delta\hat{\bm{T}}_{j}^{TV} = {{{\bm{\hat{T}}}}_{i}}\left( {{u}_{j+1}},{{v}_{k}} \right)-{{{\bm{\hat{T}}}}_{i}}\left( {{u}_{j}},{{v}_{k}} \right) $ and $ \Delta\hat{\bm{T}}_{k}^{TV} = {{{\bm{\hat{T}}}}_{i}}\left( {{u}_{j}},{{v}_{k+1}} \right)-{{{\bm{\hat{T}}}}_{i}}\left( {{u}_{j}},{{v}_{k}} \right) $
Thus, the proposed physics-informed loss function $\mathcal{L}\left(\theta\right)$ for learning the parameters $\bm{\theta}$ of model $\mathcal{MQNN}\left(\bm{T}_{MP}, \bm{\tau}; \bm{\theta}\right)$ is
\begin{equation}\label{PI_Loss}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
\begin{aligned}
& \mathcal{L}\left( \bm{\theta } \right)={\alpha }_{1}{{\mathcal{L}}_{\tau }}\left( \bm{\theta } \right)+{{\alpha }_{2}}{{\mathcal{L}}_{LE}}\left( \bm{\theta } \right)+{{\alpha }_{3}}{{\mathcal{L}}_{BC}}\left( \bm{\theta } \right) \\
& \qquad \quad\; +{{\alpha }_{4}}{{\mathcal{L}}_{TV}}\left( \bm{\theta } \right),
\end{aligned}
\end{equation}
where $ {\alpha }_{1} $, $ {\alpha }_{2} $, $ {\alpha }_{3} $, and $ {\alpha }_{4} $ are hyperparameters.
\subsection{Model Monte Carlo Training Algorithm}
This section proposes the model Monte Carlo training algorithm to learning the parameters $\bm{\theta}$. Different from the general model training methods, the model Monte Carlo training algorithm keeps changing the training data by randomly sampling quantile level images in each epoch. The detailed description is as follows: In the $ep\text{-th}$ epoch, a quantile level image $ \bm{\tau}_i $ ($ i=1,2,\cdots,N $) corresponding to the MP temperature image $ \bm{T}^i_{MP} $ is created by the method in section \ref{sect31}. Then, the quantile level image $ \bm{\tau}_i $ and the MP temperature image $ \bm{T}^i_{MP} $ ($ i=1,2,\cdots,N $) constitute the training dataset $\left\{\left(\bm{T}^i_{MP}, \bm{\tau}_i\right)_{ep}|i=1,2,\cdots,N \right\}$. Set the appropriate batch size, and the training dataset is divided into $N_{batch}$ batches. This paper chooses the Adam algorithm \cite{Kingma2014} to update the parameters $\bm{\theta}$. In summary, the pseudo code of the model Monte Carlo training algorithm is shown in \textbf{Algorithm} \ref{algorithm1}.
\begin{algorithm}[!htbp]
\caption{Model Monte Carlo Training Algorithm.}
\label{algorithm1}
\LinesNumbered
\KwIn{\\ \qquad MP temperature images $\left\{ \bm{T}^i_{MP}|i=1,2,\cdots,N \right\}$.
}
\KwOut{\\ \qquad Trained model $\mathcal{MQNN}\left(\bm{T}_{MP}, \bm{\tau}; \bm{\theta}\right)$.}
Initialize the physics-informed Deep MC-QR model $\mathcal{MQNN}\left(\bm{T}_{MP}, \bm{\tau}; \bm{\theta}\right)$; \\
\For{$ep=1:ep_{max}$}{
\For{$i=1:N$}{
Randomly take a sample ${\tau}_i$ from uniform distribution $U\left ( 0, 1 \right )$; \\
Create a ${h}\times {w}$ two-dimensional array $\bm{\tau}_i$ with all zero elements; \\
Perform $ \bm{\tau}_i\left(u,v\right) = {\tau}_i$ for $ \forall \left( u,v \right) \in {{\Omega}_{MP}} $; \\
Composite training data $ \left( \bm{T}_{MP}^{i},{{\bm{\tau }}_{i}} \right)_{ep} $.
}
Dividing $N$ training data $\left\{\left(\bm{T}^i_{MP}, \bm{\tau}_i\right) \right\}$ to be $ N_{batch} $ batches; \\
\For{$ba=1:N_{batch}$}{
Estimate the reconstructed temperature field ${{\hat{\bm{T}}}_{i}}=\mathcal{MQNN}\left(\bm{T}^i_{MP}, \bm{\tau}_i; \bm{\theta}\right)$;\\
Calculate the proposed loss function $\mathcal{L}\left( \bm{\theta } \right)$; \\
Calculate the gradient of $\mathcal{L}\left( \bm{\theta } \right)$; \\
Update the parameters $ \bm{\theta} $ by the Adam algorithm.
}
}
\end{algorithm}
\subsection{Model Prediction and Aleatoric Uncertainty Quantification}
For a MP temperature image $\bm{T}^{pre}_{MP}$, the reconstructed temperature field $ {{\hat{\bm{T}}}_{pre}} $ and the quantified aleatoric uncertainty $ \hat{\bm{\sigma}}_{pre} $ are calculated as follows. In the predicted stage, $N_{pre}$ quantile level images are generated by the method in section \ref{sect31}. Then, the composited prediction data $ \left\{ \left(\bm{T}^{pre}_{MP},\bm{\tau}_{\mathcal{A} }^{pre}\right)|\mathcal{A}=1,2,\cdots,N_{pre} \right\} $ are obtained for the MP temperature image $\bm{T}^{pre}_{MP}$. For $ \mathcal{A}=1,2,\cdots,N_{pre} $, the temperature field $ \hat{\bm{T}}_{\mathcal{A} }^{pre} $ is predicted by the trained model $\mathcal{MQNN}\left(\bm{T}_{MP}, \bm{\tau}; \bm{\theta}\right)$. Thereby, the reconstructed temperature field's approximation $\hat{\bm{T}}_{pre}$ and the aleatoric uncertainty $\bm{\sigma}_{pre}$ are estimated by calculating the mean and the standard deviation of $ N_{pre} $ results $ \hat{\bm{T}}_{\mathcal{A} }^{pre} $ ($\mathcal{A}=1,2,\cdots,N_{pre}$), respectively, i.e.,
\begin{equation}\label{T_pre}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{1pt}
{{\hat{\bm{T}}}_{pre}}=\frac{1}{N_{pre}}\sum\limits_{\mathcal{A}=1}^{{{N}_{pre}}}{\hat{\bm{T}}_{\mathcal{A}}^{pre}},
\end{equation}
\begin{equation}\label{U_alea}
\setlength{\abovedisplayskip}{1pt}
\setlength{\belowdisplayskip}{3pt}
{{\bm{\sigma }}_{pre}}={{\left[ \frac{1}{N_{pre}}\sum\limits_{\mathcal{A}=1}^{{{N}_{pre}}}{{{\left( \hat{\bm{T}}_{\mathcal{A}}^{pre} \right)}^{2}}-{{\left( {{{\hat{\bm{T}}}}_{pre}} \right)}^{2}}} \right]}^{\frac{1}{2}}}.
\end{equation}
In summary, the pseudo code of the model prediction and aleatoric uncertainty quantification algorithm is shown in \textbf{Algorithm} \ref{algorithm2}.
\begin{algorithm}[!htbp]
\caption{Model prediction and aleatoric uncertainty quantification algorithm.}
\label{algorithm2}
\LinesNumbered
\KwIn{\\
\qquad (1) MP temperature image $\bm{T}^{pre}_{MP}$; \\
\qquad (2) Sampling number $ N_{pre} $ of quantile levels; \\
\qquad (3) Trained model $\mathcal{MQNN}\left(\bm{T}_{MP}, \bm{\tau}; \bm{\theta}\right)$. \\
}
\KwOut{\\
\qquad (1) Reconstructed temperature field $ {{\hat{\bm{T}}}_{pre}} $; \\
\qquad (2) Quantified aleatoric uncertainty $ \hat{\bm{\sigma}}_{pre} $. \\
}
\For{$\mathcal{A}=1:N_{pre}$}{
Randomly take a sample ${\tau}^{pre}_{\mathcal{A}}$ from uniform distribution $U\left ( 0, 1 \right )$; \\
Create a $h\times w$ two-dimensional array $\bm{\tau}^{pre}_{\mathcal{A}}$ with all zero elements; \\
Perform $\bm{\tau}^{pre}_{\mathcal{A}}\left(u,v\right) = {\tau}^{pre}_{\mathcal{A}}$ for $ \forall \left( u,v \right) \in {{\Omega}_{MP}} $; \\
Composite prediction data $ \left( \bm{T}^{pre}_{MP},\bm{\tau}^{pre}_{\mathcal{A}} \right) $;\\
Predict the reconstructed temperature field ${{\hat{\bm{T}}}^{pre}_{\mathcal{A}}}=\mathcal{M}\left(\bm{T}^{pre}_{MP},\bm{\tau}^{pre}_{\mathcal{A}}; \bm{\theta}\right)$.
}
Calculate the mean $ {{\hat{\bm{T}}}_{pre}} $ and the standard deviation $ \hat{\bm{\sigma}}_{pre} $ of $ \left\{{{\hat{\bm{T}}}^{pre}_{\mathcal{A}}}|\mathcal{A}=1,2,\cdots,N_{pre}\right\} $. \\
\end{algorithm}
\section{Experiment}
\subsection{Experimental Setup}\label{sec41}
As shown in Fig.\ref{layout_case}, this paper uses a system ($W=H=0.2 \;\text{m}$) to validate the effectiveness of the proposed Deep MC-QR method. This system has 55 heat sources, and the heat sink with width $ \delta=0.02\;\text{m} $ is in the center of the left boundary of the system. The positions of monitoring points are shown in Fig.\ref{MP_case}. In this experiment, the power of each heat source obeys the normal distribution with a mean of 20000 W and a standard deviation of 1000 W. Besides, the constant temperature $ T_0 $ is 298 K. The parameters $ h $ and $ w $ are set to be 200, i.e., $ h=w=200 $. 15000 MP temperature images $\left\{{\bm{T}}_{MP}^1, {\bm{T}}_{MP}^2, \cdots ,{\bm{T}}_{MP}^{15000}\right\}$ are generated by the recon-data-generator\footnote{https://github.com/shendu-sw/recon-data-generator}, where the training dataset, the validating dataset, and the testing dataset have 10800, 1200 and 3000 MP temperature images, respectively. Especially, the corresponding truth temperature fields (label) of 3000 testing data are also generated by the recon-data-generator. The hyperparameters $ {\alpha }_1 $, $ {\alpha }_2 $, $ {\alpha }_3 $, and $ {\alpha }_4 $ are equal to $1\times10^5$, $1\times10^2$, $1\times10^2$ and $1\times10^4$, respectively. The relevant codes of the Deep MC-QR method by Python are available on this website \footnote{https://github.com/Xiaohu-Zheng/Deep-MC-QR}.
\begin{figure}[!htbp]
\setlength{\belowcaptionskip}{-0.3cm}
\centering
{\includegraphics[scale=0.4]{layout_case}}
\caption{Heat source layout.}
\label{layout_case}
\end{figure}
\begin{figure}[!htbp]
\setlength{\belowcaptionskip}{-0.3cm}
\centering
{\includegraphics[scale=0.4]{MP_case}}
\caption{Monitoring point positions.}
\label{MP_case}
\end{figure}
In this experiment, five kinds of noises are respectively added into temperature values of 15000 MP temperature images $\left\{{\bm{T}}_{MP}^1, {\bm{T}}_{MP}^2, \cdots ,{\bm{T}}_{MP}^{15000}\right\}$ to generate five types of the dataset as follows:
\begin{itemize}
\item Gaussian noise $ {\varepsilon}_1 \sim N\left ( 0, {0.3}^2 \right ) $ for green monitoring points in Fig.\ref{MP_case}.
\item Gaussian noise $ {\varepsilon}_2 \sim N\left ( 0, {0.5}^2 \right ) $ for green monitoring points in Fig.\ref{MP_case}.
\item Uniform noise $ {\varepsilon}_3 \sim U\left ( -0.3, 0.3 \right ) $ for green monitoring points in Fig.\ref{MP_case}.
\item Uniform noise $ {\varepsilon}_4 \sim U\left ( -1, 1 \right ) $ for green monitoring points in Fig.\ref{MP_case}.
\item Gaussian noise $ {\varepsilon}_5 \sim N\left ( 0, {0.3}^2 \right ) $ for monitoring points to the right of the blue dotted line in Fig.\ref{MP_case} (Excluding the five monitoring points on the right boundary).
\end{itemize}
Based on the above five kinds of the dataset, five trained models are denoted as $\mathcal{MQNN}_{{\varepsilon}_1}$, $\mathcal{MQNN}_{{\varepsilon}_2}$, $\mathcal{MQNN}_{{\varepsilon}_3}$, $\mathcal{MQNN}_{{\varepsilon}_4}$, and $\mathcal{MQNN}_{{\varepsilon}_5}$, respectively. Besides, four evaluation criteria for model accuracy are as follows:
a) the average of root mean square error (RMSE)
\begin{equation}\label{e_RMSE}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
\overline{RMSE}=\frac{1}{6\text{e}5}\sum\limits_{t=1}^{3000}{\sqrt{\sum\limits_{\left( x,y \right)\in \Omega }{{{\left[ \bm{T}_{t}\left( x,y \right)-\bm{\hat{T}}_{t}\left( x,y \right) \right]}^{2}}}}},
\end{equation}
b) the average of mean absolute error (MAE)
\begin{equation}\label{e_MAE}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
\overline{MAE}=\frac{1}{1.2\text{e}8}\sum\limits_{t=1}^{3000}{\sum\limits_{\left( x,y \right)\in \Omega }{\left| \bm{T}_{t}\left( x,y \right)-\bm{\hat{T}}_{t}\left( x,y \right) \right|}},
\end{equation}
c) the average of mean relative error (MRE)
\begin{equation}\label{e_MRE}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
\overline{MRE}=\frac{1}{1.2\text{e}8}\sum\limits_{t=1}^{3000}{\sum\limits_{\left( x,y \right)\in \Omega }{\frac{\left| \bm{T}_{t}\left( x,y \right)-\bm{\hat{T}}_{t}\left( x,y \right) \right|}{\bm{T}_{t}\left( x,y \right)}}},
\end{equation}
d) the average of R square ($R^2$)
\begin{equation}\label{R2}
\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}
\begin{aligned}
& \overline{{{R}^{2}}}=\frac{1}{3\text{e}3}\sum\limits_{t=1}^{3000}{\left\{ 1-{\frac{\sum\limits_{\left( x,y \right)\in \Omega }{{\left[ \bm{T}_{t}\left( x,y \right)-\bm{\hat{T}}_{t}\left( x,y \right) \right]}^{2}}} {\sum\limits_{\left( x,y \right)\in \Omega }{{\left[ \bm{T}_{t}\left( x,y \right)-\bm{\bar{T}}_{t}\left( x,y \right) \right]}^{2}}}} \right\}}, \\
& \bm{\bar{T}}_{t}=\frac{1}{3\text{e}3}\sum\limits_{t=1}^{3000}{\bm{\hat{T}}_{t}}.
\end{aligned}
\end{equation}
For the first three evaluation criteria $ \overline{RMSE} $, $ \overline{MAE} $ and $ \overline{MRE} $, the closer their values are to 0, the higher the accuracy of the trained model $\mathcal{M}\left(\bm{T}_{MP}, \bm{\tau}; \bm{\theta}\right)$. ${{R}^{2}}\to 1$ means that the trained model $\mathcal{M}\left(\bm{T}_{MP}, \bm{\tau}; \bm{\theta}\right)$ is accurate.
\subsection{Model accuracy analysis}
The prediction accuracy of five models $\mathcal{MQNN}_{{\varepsilon}_1}$, $\mathcal{MQNN}_{{\varepsilon}_2}$, $\mathcal{MQNN}_{{\varepsilon}_3}$, $\mathcal{MQNN}_{{\varepsilon}_4}$, and $\mathcal{MQNN}_{{\varepsilon}_5}$ are shown in TABLE \ref{model_acc_case1}. Apparently, three kinds of average errors, i.e., $ \overline{RMSE} $, $ \overline{MAE} $ and $ \overline{MRE} $, are sufficiently small for five models. The $\overline{R^2}$ of five models are greater than or equal to 0.99995. Therefore, the proposed Deep MC-QR method can reconstruct the temperature fields accurately.
\begin{table}[!htbp]
\centering
\caption{The prediction accuracy of five models trained by the MP temperature images with five kinds of noises.}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Noise & Model & $ \overline{RMSE} $ & $ \overline{MAE} $ & $ \overline{MRE} $ & $\overline{R^2}$ \\
\hline
$ {\varepsilon}_1 $ & $\mathcal{MQNN}_{{\varepsilon}_1}$ & 0.07370 & 0.04932 & 0.00013 & 0.99996 \\
\hline
$ {\varepsilon}_2 $ & $\mathcal{MQNN}_{{\varepsilon}_2}$ & 0.07959 & 0.05066 & 0.00014 & 0.99996 \\
\hline
$ {\varepsilon}_3 $ & $\mathcal{MQNN}_{{\varepsilon}_3}$ & 0.07094 & 0.04489 & 0.00012 & 0.99996 \\
\hline
$ {\varepsilon}_4 $ & $\mathcal{MQNN}_{{\varepsilon}_4}$ & 0.08173 & 0.05263 & 0.00014 & 0.99995 \\
\hline
$ {\varepsilon}_5 $ & $\mathcal{MQNN}_{{\varepsilon}_5}$ & 0.08921 & 0.06056 & 0.00014 & 0.99995 \\
\hline
\end{tabular}
\label{model_acc_case1}
\end{table}
This experiment randomly chooses a MP temperature image in Fig.\ref{MP1} (adding five kinds of data noises) to show the prediction performance of five models. Fig.\ref{truth} is the truth temperature field of the MP temperature image in Fig.\ref{MP1}. Based on five models $\mathcal{MQNN}_{{\varepsilon}_1}$, $\mathcal{MQNN}_{{\varepsilon}_2}$, $\mathcal{MQNN}_{{\varepsilon}_3}$, $\mathcal{MQNN}_{{\varepsilon}_4}$, and $\mathcal{MQNN}_{{\varepsilon}_5}$, five reconstructed temperature fields are presented in Fig.\ref{prediction_1}, Fig.\ref{prediction_2}, Fig.\ref{prediction_3}, Fig.\ref{prediction_4}, and Fig.\ref{prediction_5}, respectively. Compared with Fig.\ref{truth}, five reconstructed temperature fields are basically consistent with the truth temperature field.
\begin{figure}[!htbp]
\setlength{\belowcaptionskip}{-0.3cm}
\setlength{\belowcaptionskip}{-1cm}
\centering
{\includegraphics[scale=0.56]{MP1}}
\caption{A MP temperature image.}
\label{MP1}
\end{figure}
\begin{figure}[!htbp]
\setlength{\abovecaptionskip}{-0.03cm}
\centering
{\includegraphics[scale=0.56]{TFR_truth}}
\caption{Truth temperature field of the MP temperature image in Fig.\ref{MP1}.}
\label{truth}
\end{figure}
\begin{figure}[!htbp]
\setlength{\abovecaptionskip}{-0.03cm}
\centering
{\includegraphics[scale=0.56]{pre_006}}
\caption{Predicted temperature field by $\mathcal{MQNN}_{{\varepsilon}_1}$.}
\label{prediction_1}
\end{figure}
\begin{figure}[!htbp]
\setlength{\abovecaptionskip}{-0.03cm}
\centering
{\includegraphics[scale=0.56]{pre_01}}
\caption{Predicted temperature field by $\mathcal{MQNN}_{{\varepsilon}_2}$.}
\label{prediction_2}
\end{figure}
\begin{figure}[!htbp]
\setlength{\abovecaptionskip}{-0.03cm}
\centering
{\includegraphics[scale=0.56]{pre_006_uniform}}
\caption{Predicted temperature field by $\mathcal{MQNN}_{{\varepsilon}_3}$.}
\label{prediction_3}
\end{figure}
\begin{figure}[!htbp]
\setlength{\abovecaptionskip}{-0.03cm}
\centering
{\includegraphics[scale=0.56]{pre_02_uniform}}
\caption{Predicted temperature field by $\mathcal{MQNN}_{{\varepsilon}_4}$.}
\label{prediction_4}
\end{figure}
\begin{figure}[!htbp]
\setlength{\abovecaptionskip}{-0.03cm}
\centering
{\includegraphics[scale=0.56]{pre_006_right}}
\caption{Predicted temperature field by $\mathcal{MQNN}_{{\varepsilon}_5}$.}
\label{prediction_5}
\end{figure}
\subsection{Aleatoric uncertainty quantification results analysis}
For the MP temperature image in Fig.\ref{MP1}, the quantified aleatoric uncertainties by four models $\mathcal{MQNN}_{{\varepsilon}_1}$, $\mathcal{MQNN}_{{\varepsilon}_2}$, $\mathcal{MQNN}_{{\varepsilon}_3}$ and $\mathcal{MQNN}_{{\varepsilon}_4}$ are shown in Fig.\ref{alea1}, Fig.\ref{alea2}, Fig.\ref{alea3} and Fig.\ref{alea4}, respectively. According to section \ref{sec41}, these four models are trained by the datasets that include the Gaussian noises ($ {\varepsilon}_1 \sim N\left ( 0, {0.3}^2 \right ) $, $ {\varepsilon}_2 \sim N\left ( 0, {0.50}^2 \right ) $) and uniform noise ($ {\varepsilon}_3 \sim U\left ( -0.3, 0.3 \right ) $, $ {\varepsilon}_4 \sim U\left ( -1, 1 \right ) $) in the green points in Fig.\ref{MP_case}. Referring to Fig.\ref{alea1}, Fig.\ref{alea2}, Fig.\ref{alea3} and Fig.\ref{alea4}, the aleatoric uncertainties of the areas around the green points (Fig.\ref{MP_case}) are much larger than the other areas. Besides, the maximum values of two aleatoric uncertainties in Fig.\ref{alea1} and Fig.\ref{alea2} are approximately equal to 0.3 and 0.5, respectively. For the models $\mathcal{MQNN}_{{\varepsilon}_3}$ $\mathcal{MQNN}_{{\varepsilon}_4}$ trained by data with the uniform noises ($ {\varepsilon}_3$, $ {\varepsilon}_4 $), the quantified aleatoric uncertainties are approximately equal to the standard deviations 0.173 and 0.577 of two uniform noises, respectively. In summary, the proposed Deep MC-QR method can accurately quantify the aleatoric uncertainty caused by data noise.
\begin{figure}[!htbp]
\setlength{\belowcaptionskip}{-0.3cm}
\centering
{\includegraphics[scale=0.56]{alea_006}}
\caption{Quantified aleatoric uncertainty by $\mathcal{MQNN}_{{\varepsilon}_1}$.}
\label{alea1}
\end{figure}
\begin{figure}[!htbp]
\setlength{\belowcaptionskip}{-0.3cm}
\centering
{\includegraphics[scale=0.56]{alea_01}}
\caption{Quantified aleatoric uncertainty by $\mathcal{MQNN}_{{\varepsilon}_2}$.}
\label{alea2}
\end{figure}
\begin{figure}[!htbp]
\setlength{\belowcaptionskip}{-0.3cm}
\centering
{\includegraphics[scale=0.56]{alea_006_uniform}}
\caption{Quantified aleatoric uncertainty by $\mathcal{MQNN}_{{\varepsilon}_3}$.}
\label{alea3}
\end{figure}
\begin{figure}[!htbp]
\setlength{\belowcaptionskip}{-0.3cm}
\centering
{\includegraphics[scale=0.56]{alea_02_uniform}}
\caption{Quantified aleatoric uncertainty by $\mathcal{MQNN}_{{\varepsilon}_4}$.}
\label{alea4}
\end{figure}
\subsection{The effect of aleatoric uncertainty for TFR}
For the model $\mathcal{MQNN}_{{\varepsilon}_5}$, it is trained by the data with the Gaussian noise $ {\varepsilon}_5 \sim N\left ( 0, {0.3}^2 \right ) $ for monitoring points to the right of the blue dotted line in Fig.\ref{MP_case}. The fusion image between the monitoring point positions (Fig.\ref{MP_case}) and the quantified aleatoric uncertainty by $\mathcal{MQNN}_{{\varepsilon}_5}$ is shown in Fig.\ref{noise_effect}.
\begin{figure}[!htbp]
\setlength{\abovecaptionskip}{-0.03cm}
\centering
{\includegraphics[scale=0.56]{alea_MP}}
\caption{The fusion image between the monitoring point positions (Fig.\ref{MP_case}) and the quantified aleatoric uncertainty by $\mathcal{MQNN}_{{\varepsilon}_5}$.}
\label{noise_effect}
\end{figure}
Referring to Fig.\ref{noise_effect}, the aleatoric uncertainty corresponding to the area to the right of the blue dotted line is much larger than the area to the left of the blue dotted line. Besides, there are four especial phenomenons in Fig.\ref{noise_effect} as follows:
a) \textbf{The maximum aleatoric uncertainty (about 0.35) is larger than the actual data noise (0.3).} As shown in Fig.\ref{noise_effect}, the maximum value of quantified aleatoric uncertainty is approximately equal to 0.35, while the value of actual Gaussian noise is equal to 0.3.
b) \textbf{There is also aleatoric uncertainty on the non-monitoring point area to the right of the blue dotted line.} Compared with the non-monitoring point area to the left of the blue dotted line, the aleatoric uncertainty of the non-monitoring point area to the right of the blue dotted line is relatively large as shown in Fig.\ref{noise_effect}. However, the non-monitoring point area to the left of the blue dotted line does not contain data noise.
c) \textbf{The aleatoric uncertainty in the non-monitoring point area to the right of the blue dotted line has large differences.} As shown in Fig.\ref{noise_effect}, the aleatoric uncertainty in the green dashed ellipse is larger than in the red dashed ellipse for the non-monitoring point area. In fact, both non-monitoring point areas do not include data noise.
d) \textbf{The uncertainty around five monitoring points (in the orange circle) on the right boundary is small.}
In fact, the spread of data noise results in the above four especial phenomenons. Firstly, The data noise propagation leads to the accumulation of aleatoric uncertainty. Thereby, the maximum aleatoric uncertainty is larger than the actual Gaussian noise (phenomenon a)). Secondly, the aleatoric uncertainty is transferred to the surrounding area due to noise propagation, which brings about phenomenon b). Thirdly, the data noise may include positive or negative Gaussian noise. Thus, the accumulation of positive or negative Gaussian noise will lead to the phenomenon c). According to section \ref{sec41}, five monitoring points (in the orange circle) on the right boundary do not contain data noise. Therefore, the phenomenon d) appears in Fig.\ref{noise_effect}.
In summary, data noise causes the reconstructed temperature field to have aleatoric uncertainties at and around the monitoring point. Therefore, aleatoric uncertainty quantification is important to ensure the creditability of the reconstructed temperature field.
\section{Conclusions}
This paper proposes the Deep MC-QR method to reconstruct the temperature field and quantify the aleatoric uncertainty caused by data noise. By physical knowledge to guide the training of CNN, the proposed Deep MC-QR method can reconstruct an accurate TFR surrogate model without using any labeled training data. Besides, the proposed Deep MC-QR method can quantify aleatoric uncertainty by constructing a quantile level image for each MP temperature image. This paper adds five kinds of data noise in the MP temperature image. The results show that the proposed Deep MC-QR method can accurately reconstruct the temperature field and quantify the aleatoric uncertainty precisely. Especially, the results also show that data noise causes the reconstructed temperature field to have aleatoric uncertainties at and around the monitoring point. Thus, aleatoric uncertainty quantification is necessary for the TFR problem.
\section*{Acknowledgment}
This work was supported by the Postgraduate Scientific Research Innovation Project of Hunan Province (No.CX20200006) and the National Natural Science Foundation of China (Nos.11725211).
|
{'timestamp': '2022-02-15T02:40:53', 'yymm': '2202', 'arxiv_id': '2202.06596', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06596'}
|
arxiv
|
\section{Introduction}\label{sec:introduction}}
\else
\section{Introduction}
\label{sec:introduction}
\fi
\IEEEPARstart{T}{his} demo file is intended to serve as a ``starter file''
for IEEE Computer Society journal papers produced under \LaTeX\ using
IEEEtran.cls version 1.8b and later.
I wish you the best of success.
\hfill mds
\hfill August 26, 2015
\subsection{Subsection Heading Here}
Subsection text here.
\subsubsection{Subsubsection Heading Here}
Subsubsection text here.
\section{Conclusion}
The conclusion goes here.
\appendices
\section{Proof of the First Zonklar Equation}
Appendix one text goes here.
\section{}
Appendix two text goes here.
\ifCLASSOPTIONcompsoc
\section*{Acknowledgments}
\else
\section*{Acknowledgment}
\fi
The authors would like to thank...
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\section{Introduction}
This demo file is intended to serve as a ``starter file''
for IEEE Computer Society conference papers produced under \LaTeX\ using
IEEEtran.cls version 1.8b and later.
I wish you the best of success.
\hfill mds
\hfill August 26, 2015
\subsection{Subsection Heading Here}
Subsection text here.
\subsubsection{Subsubsection Heading Here}
Subsubsection text here.
\section{Conclusion}
The conclusion goes here.
\ifCLASSOPTIONcompsoc
\section*{Acknowledgments}
\else
\section*{Acknowledgment}
\fi
The authors would like to thank...
\section{Introduction}\label{sec:introduction}}
\IEEEPARstart{T}{his} demo file is intended to serve as a ``starter file''
for IEEE Computer Society journal papers produced under \LaTeX\ using
IEEEtran.cls version 1.8b and later.
I wish you the best of success.
\hfill mds
\hfill August 26, 2015
\subsection{Subsection Heading Here}
Subsection text here.
\subsubsection{Subsubsection Heading Here}
Subsubsection text here.
\section{Conclusion}
The conclusion goes here.
\appendices
\section{Proof of the First Zonklar Equation}
Appendix one text goes here.
\section{}
Appendix two text goes here.
\ifCLASSOPTIONcompsoc
\section*{Acknowledgments}
\else
\section*{Acknowledgment}
\fi
The authors would like to thank...
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\section{Introduction}
\IEEEPARstart{T}{he} goal of data compression is to reduce the number of bits needed to represent useful information. \textit{Neural}, or \textit{learned} compression, is the application of neural networks and related machine learning techniques to this task.
This article aims to serve as an entry point for machine learning researchers interested in compression by reviewing the information theory background as well as the representative methods and techniques in neural compression.
Neural compression draws on a rich history of learning-based approaches to image processing. Indeed, many problems in computational photography can be viewed as lossy image compression; e.g., image super-resolution can be solved by learning a decoder for a fixed encoder (the image downsampling process) \cite{dong2015image}\cite{ledig2017photo}.
In fact, neural networks have been applied to image compression in the late 1980s and 1990s \cite{sonehara1989nn}\cite{sicuranza1990nn}, and even an early review article \cite{jiang1999image} exists. Compared to early work, modern methods differ markedly in their scale, neural architectures, and encoding schemes.
Current research in neural compression is heavily inspired by the advent of deep generative models, such as GANs, VAEs, normalizing flows, and autoregressive models \cite{goodfellow2014gan, kingma2014vae, rezende2015variational, larochelle2011nade}.
While these models allow us to capture complex data distributions from samples (a key to neural compression), the research tends to focus on generating realistic data \cite{vandenoord2016wavenet} or achieving high data log-density \cite{rezende2015variational}, objectives not always aligned with data compression.
Arguably the first work exploring deep generative models for data compression appeared in 2016 \cite{gregor2016towards}, and the topic of neural compression has grown considerably since then. Multiple researchers have identified connections between variational inference and lossless \cite{frey1998bayesian}\cite{mackay2003information} as well as lossy \cite{balle2017end}\cite{theis2017cae} \cite{alemi2018fixing}\cite{yang2020improving} compression.
This article hopes to further facilitate such exchange between these fields, raising awareness of compression as a fruitful application for generative modeling as well as the associated interesting challenges.
Instead of surveying the vast literature, we aim to cover the essential concepts and methods in neural compression, with a reader in mind who is versed in machine learning but not necessarily data compression. We hope to complement existing surveys that have a more applied focus on data compression \cite{balle2021ntc}\cite{ma2019image}\cite{ding2021advances} by highlighting the connections to generative modeling and machine learning in general.
Neural compression offers the potential for automatically constructing compression algorithms from raw data. This can be especially useful for new or domain-specific data types, such as VR content or scientific data, where developing custom codecs could otherwise be expensive.
However, much of this potential remains unexplored,
so we center our discussions around image compression, where most learned compression methods were first developed. Nonetheless, these methods apply more broadly to other types of data. We treat an example of sequential data, video compression, in Section~\ref{sec:video-compression}. Effectively compressing such data requires more elaborate models, but the basic idea of regulating the entropy/bit-rate of learned representations and the associated techniques remain the same.
\begin{figure}[t]
\centering
\includegraphics[trim={0 0 4.2cm 4.51cm},clip,width=4.35cm]{figures/jpeg_sample.png}
\includegraphics[trim={0 0 4.2cm 4.51cm},clip,width=4.3cm]{figures/nibbler_sample.jpg}
\caption{Compression as generative modeling. \textit{Left:} A sample drawn from the probabilistic model underlying JPEG, which betrays an assumption of independence among neighboring 8 by 8 pixel blocks (except for the DC components within each row).
\textit{Right:} A sample generated by a recent neural compression model by Minnen et al. \cite{minnen2020channel}.}
\label{fig:jpeg}
\end{figure}
\textbf{JPEG} \cite{itu1992jpeg} serves as a good motivating example of the lossy compression pipeline (depicted in Fig.~\ref{fig:overview}). First introduced in 1992, it is still one of the most widely used image compression standards \cite{hudson2018jpeg}.
At the heart of JPEG are linear mappings which losslessly transform pixels into coefficients and back.
The coefficients are first quantized to integers, incurring some information loss.
Then they are further compressed losslessly by a combination of run-length encoding and entropy coding (the latter is discussed in Section~\ref{sec:entropy_coding}).
The linear portion of the encoding process consists of several steps. First, each pixel is transformed from RGB to YCC coefficients
consisting of a luma component (Y) and two color components (C). After this color transform, each channel is treated independently, and optional downsampling is applied to the color channels.
Next, each channel is divided into $8 \times 8$ pixel blocks, and each block independently undergoes a \textit{discrete cosine transform} (DCT).
The transform coefficients are then linearly scaled, and rounded to integers.
Given an image $\mathbf{x}$, the encoder thus performs
\begin{align}
\hatz = \lfloor \mathbf{D}\mathbf{A}\mathbf{C}\mathbf{x}\rceil,
\end{align}
where $\mathbf{C}$ is the pixelwise color transform, $\mathbf{A}$ is the block- and channelwise DCT, and $\mathbf{D}$ is a diagonal matrix scaling the coefficients. The decoder applies the transforms in reverse,
\begin{align}
\hatx = \mathbf{C}^{-1}\mathbf{A}^\top\mathbf{D}^{-1} \hatz.
\end{align}
Readers familiar with machine learning will be reminded of autoencoders \cite{bourlard1988auto}\cite{rumelhart1985learning}, and it is natural to consider learned neural networks in place of the linear transforms. As we will see later, there are indeed close connections between lossy compression and variational autoencoders (VAEs) \cite{kingma2014vae}\cite{rezende2014vae}, though other generative models have a role to play as well. What we call ``coefficients'' in the context of compression are often called ``latent variables'' in the context of generative models. Like generative models, JPEG defines a probability distribution over coefficients which represents assumptions about the latent representation. Just as in VAEs, we can use this distribution to draw samples from the model underlying JPEG, with an example shown in Figure~\ref{fig:jpeg}.
\textbf{Overview.} This introduction is organized by two main parts, lossless (Section~\ref{sec:lossless-compression}) and lossy (Section~\ref{sec:lossy-compression}) compression; the latter relies on the former for compressing latent representations of the data (see Fig.~\ref{fig:overview}).
We begin by reviewing basic \textit{coding theory} (Sec.~\ref{sec:lossless-background}), which %
allows us to turn the problem of lossless compression into learning a discrete data distribution.
In practice, we need to decompose the potentially high-dimensional data distribution using tools from generative modeling, including \textit{autoregressive} (Sec.~\ref{sec:autoregressive}), \textit{latent-variable}, (Sec.~\ref{sec:latent-variable-models}), among \textit{other models}
(Sec.~\ref{sec:flow-and-other-models}).
Each model differs in its compatibility with different entropy-codes, and offers a different trade-off between the compression bit-rate and computation efficiency.
\textit{Lossy} compression then introduces additional desiderata, the most common being the \textit{distortion} of reconstructions, based on which the classical theory and algorithms such as VQ and transform coding are reviewed (Sec.~\ref{sec:lossy-background}).
We then introduce \textit{neural methods} as a natural extension of transform coding (Sec.~\ref{sec:neural-lossy-compression}), discuss the techniques necessary for \textit{end-to-end learning of quantized representations} (Sec.~\ref{sec:learning-quantized-representations-and-rate-control}), as well as lossy compression schemes that attempt to \textit{bypass quantization} (Sec.~\ref{sec:compression-without-quantization}). We then explore additional desiderata, such as the \textit{perceptual quality} of reconstructions (Sec.~\ref{sec:perceptual-losses}), and the usefulness of learned representations for \textit{downstream tasks} (Sec.~\ref{sec:feature-compression}), before briefly reviewing \textit{video compression} (Sec.~\ref{sec:video-compression}).
Finally, we conclude in Section~\ref{sec:conclusion} with the challenges and open problems in neural compression that may drive its future advances.
\begin{figure}[t]
\centering
\input{figures/pipeline.tex}
\caption{
A typical pipeline in both neural and classical lossy image compression. An encoder transformation $f$ maps images to coefficients $\mathbf{z}$, which are first quantized to $\hatz$, and then entropy encoded into bits using an entropy model $P$. A reconstruction $\hatx$ is obtained using a decoder $g$ that aims for a small distortion $\rho$ between the data $\mathbf{x}$ and its lossy reconstruction $\hat{\mathbf{x}}$. In addition, neural compression can also involve an adversarial critic $D$, encouraging realism and high perceptual quality.
}
\label{fig:overview}
\end{figure}
\section{Lossless compression}
\label{sec:lossless-compression}
Lossless compression aims to represent data with as few bits as possible such that the data can be reconstructed perfectly.
The basic recipe is to first build a probabilistic model of the data, and then feed its probabilities into a so-called entropy coding scheme which converts data into compact bit-strings.
This precludes non-likelihood-based models such as \textit{generative adversarial networks} GANs \cite{goodfellow2014gan}, from which it is hard to derive probabilities and which would often assign zero probability to data even if we could evaluate them.
\subsection{Background}\label{sec:lossless-background}
In the first few subsections, we review the basic concepts and algorithms for \textit{entropy coding}, which is the core interface between lossless compression and data modeling. Then in Sec.~\ref{sec:dequantization}, we discuss a commonly used modeling technique for representing a discrete distribution with a density.
\subsubsection{Entropy coding}
\label{sec:entropy_coding}
We call a sequence of outcomes of a discrete random variable a \textit{message}, and
\textit{entropy coding} is a way to achieve lossless compression of a message. The basic idea, as embodied by \textit{symbol codes}, is to replace commonly occurring symbols with short codewords and rare symbols with longer codewords, thereby reducing the message's overall length. Morse code implements on this idea and represents the common letter ``e'' with a single so-called \textit{dit} and the less frequent letter ``s'' using 3 \textit{dits}. To be able to distinguish between the message ``eee'' and the message ``s'', Morse code additionally requires pauses between encoded letters. These extra markers can be avoided by instead using a \textit{prefix-free} code where no codeword is the prefix of any other codeword \cite{cover2006elements}.
By Shannon's source coding theorem \cite{Shannon1948}, the codeword length of an optimal prefix-free code is approximately the negative logarithm of the codeword's probability. Shannon also showed that the expected message length of an optimal prefix-free code is close to the \textit{entropy} of the message.
\subsubsection{Entropy and information}
The entropy\footnotemark of a discrete random variable $\mathbf{X}$ is a measure of uncertainty about its outcomes. It is based on the concept of \textit{surprise}, or \textit{information content}, which can be defined as the negative log-probability of an outcome $-\log_2 P(\mathbf{x})$. Entropy, by definition, is the expected value of surprise, %
\begin{align}
H[\mathbf{X}] = \operatorname{\mathbb E}_{P}[-\log_2 P(\mathbf{X})]. \label{eq:entropy-definition}
\end{align}
For example, the entropy of a fair coin flip is 1 bit, and the entropy of a biased coin flip approaches zero bits as the probability of one of the two outcomes approaches one.
\footnotetext{Entropy was originally defined as a thermodynamic concept by Clausius \cite{clausis1850entropy} and later Boltzmann \cite{boltzmann1895vorlesungen}, while the information theoretic entropy was introduced by Shannon~\cite{Shannon1948}.}
When we losslessly compress data with a prefix-code, the entropy is the minimum number of bits required on average. More precisely,
the expected message length $|C(\mathbf{X})|$ of an optimal prefix-free code $C$ is bounded as
\begin{align}
H[\mathbf{X}] \leq \operatorname{\mathbb E}[|C(\mathbf{X})|] \leq H[\mathbf{X}] + 1.
\end{align}
In practice, we typically do not know the data distribution $P$ but need to approximate it with a distribution $Q$.
We usually estimate $Q$ by maximum-likelihood, or equivalently, minimizing the \textit{cross-entropy} between $P$ and $Q$, defined as,
\begin{align}
H[P, Q] = \operatorname{\mathbb E}_P[-\log_2 Q(\mathbf{X})]. \label{eq:cross-entropy}
\end{align}
This is justified from a compression perspective, as the cross-entropy captures the average number of bits needed to code samples from $P$ using a code optimized for $Q$.
The cross-entropy is always at least as large as the entropy, and the gap between the two is called \textit{relative entropy} or Kullback-Leibler (KL) divergence, defined as \begin{align}
\label{eq:rkld}
D_\text{KL}\infdivx{P}{Q} = \operatorname{\mathbb E}_P[- \log_2 Q(\mathbf{X}) + \log_2 P(\mathbf{X})].
\end{align}
It is always positive unless $P = Q$ and serves as an asymmetric distance measure between the two distributions.
Based on these foundational concepts, we will review a few entropy coding schemes next.
\begin{figure}
\centering
\input{figures/huffmantree.tex}
\caption{Visualization of a Huffman tree over five symbols. Purple numbers in boxes denote probabilities, while binary strings above the leaf nodes correspond to the codewords assigned by the Huffman algorithm.}
\label{fig:huffman}
\end{figure}
\subsubsection{Huffman coding}
Perhaps the most well-known prefix-free symbol coding approach is Huffmann coding \cite{huffman1952method}.
In a nutshell, given a distribution over symbols, the algorithm assigns unique binary codewords to every symbol by building a so-called Huffman tree (Fig.~\ref{fig:huffman}). The leaf nodes of the tree are associated with the symbols. A Huffman tree can be recursively grown from the leaves to the root by successively merging two nodes that have the lowest probabilities. By traversing the tree from the root to a leaf, the sequence of branching directions ("0" for left, "1" for right) assigns a unique binary codeword to each symbol, with the more frequent symbols receiving shorter codewords. Encoding and decoding are simple lookup operations linear in the tree depth.
Huffman coding assigns a codeword with length at most $\lceil - \log_2 P(\mathbf{x}) \rceil$ for each symbol $\mathbf{x}$, and can be shown to be optimal among prefix codes \cite{cover2006elements}.
However, as log-probabilities are generally not integers, Huffman coding (as with all so-called \textit{symbol codes}) incurs an overhead of up to 1 bit per symbol, relative to the information content. For example, a heavily biased coin with an entropy close to 0 will still require 1 bit to encode.
When compressing a sequence of symbols, \textit{streaming codes} (see below) allow us to do so more efficiently than symbol codes by limiting the overhead to 1 bit for an entire \textit{message} rather than each symbol.
\subsubsection{Arithmetic coding}
\label{sec:arithmetic_coding}
Arithmetic coding \cite{rissanen1979arithmetic}, also known as range coding \cite{martin1979range}, is our first example of a \textit{streaming code}. Streaming codes differ from symbol codes in that they assign codewords to entire messages and individual symbols do not have unique codewords. Streaming codes amortize the coding cost's overhead across the whole sequence of symbols and are therefore able to get closer to the entropy.
The basic idea of arithmetic coding is to associate each symbol with a subinterval of the interval $[0,1]$ such that the subinterval's length equals the symbol's probability. This procedure can be generalized towards encoding symbols in sequence. For two symbols, the second symbol is no longer considered a subinterval of $[0,1]$ but a subinterval of the previous symbol's interval such that the second subinterval's length equals the two symbols' joint probability. For example, if symbol "a" has probability $1/5$ and is associated with $[0,0.2)$, the sequence "aa" would be encoded as $[0,0.04)$. This procedure can be iterated for sequences of arbitrary length, leading to a sequence of subintervals of decreasing size that contain each other. Any real-valued number contained in the final subinterval allows to uniquely reconstruct the sequence of symbols and therefore encodes the entire sequence. In practice, one picks a representative number which can be represented with the smallest number of bits while still being contained in the interval. By construction, the size of the final sub-interval is the product of all previous symbols' conditional probabilities, hence the probability of the sequence. Intuitively, the interval's length (i.e., the sequence's joint probability) determines the number of relevant digits of the number representing the interval, thus the code length equals the log-probability of the sequence as required for entropy codes.
Various strategies can be used to make decoding unique, e.g., by introducing an end-of-sequence symbol or specifying the sequence length upfront.
The advantage of arithmetic coding over Huffman coding is that the excess bits needed for encoding the message are amortized over the message length, making it more efficient. Notably, it is a first-in-first-out data structure, that is, a queue. As we will see, this makes it a convenient choice for compression with autoregressive models (Section~\ref{sec:autoregressive}).
\subsubsection{Asymmetric numeral systems}\label{sec:ans}
More recent examples of streaming codes are asymmetric numeral systems (ANS) \cite{duda2009asymmetric}. While arithmetic coding implements a queue data structure, ANS operates like a stack. In arithmetic coding, the symbol encoded first is also decoded first (first-in-first-out) while ANS decodes the last symbol first (last-in-first-out).
A detailed description is beyond our scope, and we follow Bamler \cite{bamler2022understanding} in our summary of the main idea (see Townsend \cite{townsend2020tutorial} for a different presentation).
Numeral systems like the decimal or binary system can be interpreted as optimal codes for uniform distributions over a finite alphabet (the ``base'' of the numeral system). They encode a sequence of enumerated symbols into a single integer number, the ``stack''. To encode a symbol, we multiply the stack with the base (e.g., 2 or 10) and add the symbol. To decode, we recover the symbol as the stack modulo its base, while we shorten the stack by dividing it by the base. The stack's length in binary representation is approximately the number of symbols times the logarithm of the base of the numeral system, consistent with entropy coding. Interestingly, the stack's base can be changed from symbol to symbol and it is still possible to recover the sequence as long as the inverted order of bases is used upon decoding.
ANS generalizes numeral systems from uniform probability distributions to non-uniform ones. Similar to arithmetic coding, symbols are first represented as subintervals of the unit interval. In addition, one discretizes the unit interval using a fine discretization grid. Every point on the grid belongs to the subinterval of a symbol and can be used to represent that symbol. The discretization points form a new alphabet of symbols that can be encoded using a numeral system, as described above. Since there are multiple discretization points in each each subinterval, naively encoding one of them leads to a redundant code. However, ANS is able to avoid this redundancy. Bamler \cite{bamler2022understanding} notes that the mechanism by which ANS achieves this can be interpreted as a bits-back coding procedure, which will be discussed in Section \ref{sec:bits-back}. Like arithmetic coding, ANS incures an overhead of up to 1 bit per message.
\subsubsection{Continuous models for discrete data} \label{sec:dequantization}
In this subsection, we show how a model for discrete data can be defined and parameterized by a continuous model, a common technique in generative modeling and neural compression.
Lossless compression generally operates on discrete data. After all, it is infeasible to losslessly encode any real number by a finite number of bits. However, many generative models in machine learning assume continuous data, and model it with a density function. It turns out such continuous models are still useful for lossless compression.
Suppose we have a density model $q$ over $\mathbb{R}^D$, and $\mathbf{x} \in \{0, \dots, 255\}^D$ is an RGB image following the ground truth image distribution $P$.
We can derive a PMF over integers by integrating the density over hypercubes, as follows,
\begin{align}
Q(\mathbf{x}) := \int_{[-.5,.5)^D} q(\mathbf{x} + \mathbf{u}) \, d\mathbf{u}.
\label{eq:discretized-density-model}
\end{align}
Now we add uniform noise $\mathbf{u} \in [-0.5, 0.5)^D$ to the data, so that the noisy data, ${\mathbf y} = \mathbf{x} + \mathbf{u}$, has an induced density $p$.
Then it is not difficult to show that \cite{theis2016note}
\begin{align}
-\int p({\mathbf y}) \log_2 q({\mathbf y}) \, d{\mathbf y} \geq -\sum_\mathbf{x} P(\mathbf{x}) \log_2 Q(\mathbf{x}),
\label{eq:continuou-ll-rate-ub}
\end{align}
i.e., we can minimize an upper bound on the lossless compression cost under the discretized model (RHS) by fitting a density via maximum likelihood (LHS), provided the discrete data is \textit{dequantized} appropriately with noise \cite{uria2013rnade}.
The form of $Q$ as defined in Eq.~\ref{eq:discretized-density-model}, which we call a \textit{discretized density model}, is also useful in itself as a flexible model for discrete data. Examples include PixelCNN++ \cite{salimans2017pixelcnn++}, the prior distribution in a discrete flow \cite{hoogeboom2019integer}, as well as entropy models for neural compression \cite{mentzer2019practical}\cite{balle2018hyper}\cite{minnen2018joint}.
The integral in Eq.~\ref{eq:discretized-density-model} in general is intractable to compute, but it can often be broken down into a series of univariate integrals for the models we discuss.
Therefore let us consider a univariate version of the discretized density model,
\[
Q_\theta(x) := \int_{[-0.5, 0.5)} q_\theta(x + u) d u.
\]
Let $F_\theta$ denote the CDF of $q_\theta$, we can equivalently express the above in terms of a difference of CDF evaluations:
\begin{align}
Q_\theta(x) := F_\theta(x+0.5) - F_\theta(x-0.5) \label{eq:discretized-entropy-model-via-difference-of-CDFs}.
\end{align}
e.g., if $q_\theta$ is the density of a logistic distribution, then $F_\theta$ is the logistic sigmoid function common in deep learning.
\subsection{Autoregressive models}
\label{sec:autoregressive}
Autoregressive models exploit the fact that we can write any probability distribution as a product of conditional distributions using the chain rule of probabilities \cite{bishop2006PRML},
\begin{align}
\textstyle p(\mathbf{x}) = \prod_i p(x_i \mid \mathbf{x}_{< i}).
\end{align}
Here, $x_i$ is the $i$-th entry of the vector $\mathbf{x}$ and $\mathbf{x}_{< i}$ corresponds to all previous entries in an arbitrary order. The autoregressive factorization does not make any assumptions about the data distribution yet still allows us to easily incorporate useful assumptions. For example, a Markov assumption can be implemented by only considering the entries in $\mathbf{x}_{<i}$ which are close to $i$. A stationarity assumption is easily incorporated by using the same conditional distribution $p(x_i\,|\,\mathbf{x}_{< i})$ at every location. These two assumptions are often reasonable and can drastically reduce the amount of parameters of a model.
Autoregressive modeling lends itself to lossless compression in combination with arithmetic coding (Section~\ref{sec:arithmetic_coding}) since both deal with data sequentially, one symbol at a time. Each symbol is encoded using the conditional distribution given the data that has already been encoded. This is in contrast to Markov random fields, for example, where conditional distributions are typically only tractable when conditioning on a larger neighborhood. Entropy coding generally requires the number of symbols in each encoding step to be manageable. Autoregressive models provide an important step towards practical entropy coding by decomposing a high-dimensional distribution into low-dimensional conditional distributions. Arithmetic coding is a better match for autoregressive models than ANS since it operates like a queue. Symbols encoded earlier will also be decoded earlier and therefore will be available as input to conditional distributions.
For data modalities such as audio or text, autoregressive models are an obvious choice due to the signal's sequential nature. Indeed, two of the top performing algorithms in the Large Text Compression Benchmark \cite{ltcb} use recurrent neural networks to predict the next token of a sentence. While \texttt{cmix} \cite{cmix} uses a mixture of long short-term memory networks (LSTMs) \cite{hochreiter1997lstm} and nonparametric models, \texttt{nncp} \cite{bellard2019nncp} relies solely on neural network models.
However, autoregressive models have long also found application in image compression.
For example, JPEG \cite{itu1992jpeg} encodes the difference between neighboring DC coefficients, $z_{ij}^\text{DC} - z_{i(j - 1)}^\text{DC}$, in a raster-scan order, which can be thought of as implementing a first-order Markov model.
\textit{Mixtures of experts} \cite{jacobs1991moe}\cite{hosseini2010cgsm}\cite{theis2012mcgsm} are a class of autoregressive models proven useful for compressing images,
\begin{align}
p(x_{ij} \mid \mathbf{x}_{<ij})
= \sum_{k} \underbrace{p(k \mid \mathbf{x}_{<ij})}_\textsf{Gates} \underbrace{p(x_{ij} \mid \mathbf{x}_{<ij}, k)}_\textsf{Experts}.
\end{align}
The basic idea behind neural network extensions of this approach is to nonlinearly transform the inputs $\mathbf{x}_{<ij}$ before feeding them into the gates and the experts. For instance,
RNADE \cite{uria2013rnade} used a fully connected neural network with a single rectified linear layer to transform the inputs $\mathbf{x}_{<ij}$. Other examples of deep autoregressive models include RIDE \cite{theis2015lstms}, PixelRNN \cite{vandenoord2016pixelcnn}, or PixelCNN++ \cite{salimans2017pixelcnn++}.
More recent autoregressive modeling papers continue to explore different architectures for transforming $\mathbf{x}_{>ij}$. For example, the Image Transformer \cite{parmar2018it} uses an architecture based on self-attention \cite{vaswani2017attention}. PixelSNAIL \cite{chen2018pixelsnail} uses a combination of convolutions and self-attention layers. Glow \cite{kingma2018glow} uses invertible flows.
With the exception of \texttt{nncp} \cite{bellard2019nncp} and \texttt{cmix} \cite{cmix}, all autoregressive models mentioned so far are \textit{static} models. That is, the models' parameters are trained once and then remain fixed during the entire encoding and decoding process. In contrast, a \textit{dynamic} model updates its parameters during the encoding process based on already encoded data. The decoder is then able to apply the same model updates based on the data already received. A simple dynamic autoregressive model for images was proposed by Wu et al. \cite{wu1998p2ar}. Here, the predictors are linear but the predictor's parameters are chosen dynamically. This is done by treating a larger neighborhood of preceding pixels as training data for the predictor. Meyer and Tischer \cite{meyer2001glicbawls} improved on this idea by weighting training points based on their distance to the pixel whose value we are predicting.
Autoregressive models come with the restriction that decoding is an inherently sequential procedure. Each symbol can only be decoded after all the symbols have been decoded on which its prediction depends.
To improve decoding speed, we can restrict the context $\mathbf{x}_{<i}$ to only a small neighborhood around $\mathbf{x}_i$, as for example in JPEG. Furthermore, the degree of parallelism can be increased by grouping coordinates of the data into blocks and only modeling the conditional dependencies between blocks, while treating data coordinates within each block as conditionally independent \cite{stern2018blockwise}.
\subsection{Latent variable models}
\label{sec:latent-variable-models}
Latent variable models represent the data distribution using the sum rule of probability,
\begin{align}
p(\mathbf{x}) = \int p(\mathbf{x}, \mathbf{z}) ~ \text{d}\mathbf{z} = \int p(\mathbf{x} \mid \mathbf{z}) p(\mathbf{z}) ~ \text{d}\mathbf{z},
\label{eq:latent-variable-model}
\end{align}
where $\mathbf{z}$ is a vector of \textit{latent variables} (also called ``latents''), and the joint distribution $p(\mathbf{x}, \mathbf{z})$ factorizes into a \textit{prior} $p(\mathbf{z})$ and a \textit{likelihood} $p(\mathbf{x}\,|\,\mathbf{z})$.
Latent variable models are ubiquitous in machine learning and include hidden Markov models, mixture models \cite{bishop2006PRML}, and more recently variational autoencoders (VAEs) \cite{kingma2014vae}\cite{rezende2014vae}.
By integrating or summing over all possible realizations of the latent vector, latent variable models can capture complex dependencies in the data even when the prior and likelihood take simple forms.
Training a latent variable model by (approximate) maximum-likelihood (see Eq.~\ref{eq:cross-entropy}) comes with a main challenge: unlike in a fully-observed (e.g., autoregressive) model where the data probability $p(\mathbf{x})$ can be readily evaluated, doing so is no longer straightforward since it is defined through an often intractable integral (Eq.~\ref{eq:latent-variable-model}).
Variational inference deals with exactly these complications, and we refer to Zhang et al. \cite{zhang2018advances} for more details on these methods. Here, we instead focus on the compression problem, which faces a similar challenge and uses similar tools.
Given a latent variable model consisting of a prior $p(\mathbf{z})$ and likelihood $p(\mathbf{x}| \mathbf{z})$, our goal is to compress a given data vector $\mathbf{x}$ with a code length close to its information content under the model, $-\log_2 p(\mathbf{x})$. To simplify the discussion below, we assume discrete $\mathbf{z}$ unless specified otherwise.
\subsubsection{Two-part code}
\label{sec:two-part-code}
We start by considering a simple although generally suboptimal \textit{two-part code}~\cite{grunwald2007minimum}. Here, the data $\mathbf{x}$ is transmitted along with a latent vector $\mathbf{z}$ in two steps. First, the sender decides on a (ideally informative) vector $\mathbf{z}$, encodes and transmits it under the prior $p(\mathbf{z})$.
Next, $\mathbf{x}$ is compressed and transmitted under the likelihood model, $p(\mathbf{x}\,|\,\mathbf{z})$. The receiver then decodes $\mathbf{z}$, and finally $\mathbf{x}$ given $\mathbf{z}$, using the same models.
Both the prior and likelihood models are often fully factorized, allowing for coding each dimension of $\mathbf{z}$ or $\mathbf{x}$ in parallel, but can also be autoregressive models used in conjunction with arithmetic coding.
Assuming negligible entropy coding overhead, the combined code length is
\begin{align}
l(\mathbf{x}, \mathbf{z}) = -\log_2 p(\mathbf{z}) - \log_2 p(\mathbf{x}| \mathbf{z}) = -\log_2 p(\mathbf{x}, \mathbf{z}).
\end{align}
Moreover, the sender can (at least in principle) minimize this quantity over all choices of $\mathbf{z}$, resulting in the code length
\begin{align}
l_\text{MTP}(\mathbf{x}) = \min_{\mathbf{z} } \left( -\log_2 p(\mathbf{z}) - \log_2 p(\mathbf{x} \mid \mathbf{z}) \right). \label{eq:minimal-two-part-code}
\end{align}
The minimal two-part code length, $l_\text{MTP}(\mathbf{x})$, is generally still suboptimal\footnote{However, it is possible to directly optimize a neural compression method for the two-part code. e.g., Mentzer et al. \cite{mentzer2019practical} trained a latent variable model with an inference network to minimize the expected coding cost of the two-part code, demonstrating much faster decoding speed than autoregressive models, although at $\sim 20\%$ worse bit-rate.} \cite{frey1998bayesian}\cite{wallace1990classification}\cite{honkela2004variational}. To see this, consider the following bound on the information content $-\log_2 p(\mathbf{x})$,
\begin{align}
-\log_2 p(\mathbf{x})
&\leq -\log_2 p(\mathbf{x}) + D_\text{KL}\infdivx{q(\mathbf{z} \mid \mathbf{x})}{p(\mathbf{z} \mid \mathbf{x})} \\
&= \mathbb{E}_{q(\mathbf{z} \mid \mathbf{x})}[ - \log_2 p(\mathbf{z}, \mathbf{x})] - \mathbb{H}[q(\mathbf{z} \mid \mathbf{x})],
\label{eq:nelbo}
\end{align}
also known as the \textit{negative evidence lower bound} (NELBO) of variational inference~\cite{zhang2018advances}.
Here, $q$ is any distribution over $\mathbf{z}$ which may depend on $\mathbf{x}$. Crucially, the minimal two-part code length (Eq.~\ref{eq:minimal-two-part-code}) is a special case of the NELBO where
\begin{align}
q(\mathbf{z} \mid \mathbf{x}) = \delta_{\mathbf{z}_\text{min}}(\mathbf{z})
\end{align}
is a degenerate distribution centered on $\mathbf{z}_\text{min}$, which achieves the minimum in Eq.~\ref{eq:minimal-two-part-code}. In this case the entropy term vanishes. More generally, the NELBO is minimized when $q(\mathbf{z} \mid \mathbf{x})$ equals the Bayesian \textit{posterior} distribution $p(\mathbf{z} \mid \mathbf{x})$, the target of approximate inference \cite{zhang2018advances}.
One may naturally wonder whether a coding cost equal to the NELBO can be realized for \textit{any choice of} $q(\mathbf{z}\,|\,\mathbf{x})$.
Bits-back coding, to be discussed next, answers this question in the affirmative. It further offers a compression interpretation of variational inference: for a given latent variable model, reducing the KL divergence between the distribution $q$ and the posterior distribution is equivalent to minimizing the code length of $\mathbf{x}$ under bits-back coding.
\subsubsection{Bits-back coding}
\label{sec:bits-back}
While the optimal two-part code chooses a best latent vector $\mathbf{z}$ using deterministic optimization,
bits-back coding \cite{frey1997efficient}\cite{wallace1990classification}\cite{hinton1993keeping}\cite{honkela2004variational} instead uses a \textit{stochastic} latent code in the form of a sample $\mathbf{z}$ from a distribution $q$. Surprisingly, this stochastic code can save bits compared to a deterministic code by allowing auxiliary information to piggyback on the choice of the latent code.
To gain some intuition, consider again the optimization in Eq.~\ref{eq:minimal-two-part-code} for picking the optimal two-part code. When the given data $\mathbf{x}$ is uninformative of what latent variable $\mathbf{z}$ generated it,
the minimization over $\mathbf{z}$ may find multiple candidates that are nearly optimal. In the extreme case, ties need to be broken to settle on one of many equally good candidates.
Instead of choosing a $\mathbf{z}_i$ randomly, the encoder can do so intentionally so as to communicate additional information via the chosen index $i$, provided that the decoder can reverse-engineer the encoding procedure.
Before proceeding, we emphasize a connection between sampling and decoding random bits. Given an entropy code derived from a discrete distribution, using it to \textit{decode} a sequence of uniformly random bits produces a random sample from this distribution. For example, consider decoding a random bit string according to a Huffman tree (Fig.~\ref{fig:huffman}). As we traverse from the root to any leaf node, every edge along the path corresponds to a decision according to a coin flip. The probability of ending up with a particular symbol $\mathbf{x}$ with code length $|C(\mathbf{x})|$ is $2^{-|C(\mathbf{x})|}$, or approximately $2^{\log_2 p(\mathbf{x})} = p(\mathbf{x})$.
In bits-back coding, the sender first generates a sample $\mathbf{z} \sim q(\mathbf{z}\,|\,\mathbf{x})$ by \textit{decoding} a random bit string $\xi$. Next, the sender encodes $\mathbf{x}$ under $p(\mathbf{x}\,|\,\mathbf{z})$, then $\mathbf{z}$ under $p(\mathbf{z})$, and then transmits the resulting bits. The receiver begins by decoding $\mathbf{z}$ and $\mathbf{x}$ from the received bits just as in the two-part code, but then proceeds to recover the exact bit string the sender used to generate $\mathbf{z}$. This can be done by \textit{encoding} $\mathbf{z}$ under the distribution $q(\mathbf{z}\,|\,\mathbf{x})$, which we assume the receiver has access to.
Thus, $-\log_2 q(\mathbf{z}|\mathbf{x})$ bits worth of information are automatically recovered after decoding $\mathbf{x}$ and $\mathbf{z}$, giving the scheme its name ``bits-back''.
Finally, and crucially, we note that the initial bits used to generate $\mathbf{z}$ do not have to be truly random. Indeed, to be useful they should be supplied from a stream of already compressed data or some useful \textit{auxiliary information}. This could be, or example, the bitstring of a small thumbnail image encoded with JPEG.
\begin{figure}[t]
\centering
\includegraphics[width=0.8\columnwidth]{figures/bits-back.pdf}
\caption{An illustration of the encoding (sender) and decoding (receiver) operations of bits-back coding. Auxiliary bits ($\xi$) are colored in blue.}
\label{fig:bb-ans}
\end{figure}
Fig.~\ref{fig:bb-ans} graphically summarizes the algorithm.
Given a bitstring $\xi$ of auxiliary bits and the data $\mathbf{x}$ to transmit, the sender starts by decoding a portion of $\xi$ into a stochastic latent code $\mathbf{z}$ of the data, ultimately sending a total number of bits equal to $|\xi| -\log_2 p(\mathbf{z}) - \log_2 p(\mathbf{x}|\mathbf{z}) + \log_2 q(\mathbf{z}|\mathbf{x})$ to communicate both $\xi$ and $\mathbf{x}$. The net number of bits used for transmitting $\mathbf{x}$ alone is therefore
\begin{align}
-\log_2 p(\mathbf{z}) - \log_2 p(\mathbf{x}|\mathbf{z}) - (- \log_2 q(\mathbf{z}|\mathbf{x}))
\end{align}
which corresponds to a discount of $- \log_2 q(\mathbf{z}\,|\,\mathbf{x})$ bits compared to a two-part code. Since $\mathbf{z}$ was drawn from $q(\mathbf{z}|\mathbf{x})$, the expected coding cost is exactly the NELBO \cite{zhang2018advances}.
As we saw, the sender must be committed to transmit at least $- \log_2 q(\mathbf{z}\,|\,\mathbf{x})$ many auxiliary bits; otherwise the proper bits-back discount cannot be obtained, resulting in a worse coding cost. To get around this \textit{initial bits problem}, bits-back coding is often used to jointly compress a sequence of data points $\mathbf{x}_1, ..., \mathbf{x}_n$. The idea, referred to as \textit{chaining} \cite{townsend2019practical} or ``bits-back with feedback'' \cite{frey1998bayesian}, is that the bit string of previously encoded data points $\mathbf{x}_1, ..., \mathbf{x}_{i-1}$ provides a natural source of auxiliary bits for encoding the next data point $\mathbf{x}_i$.
Chaining poses a requirement on the entropy coder that data is decoded in the exact opposite order in which it is encoded.
Bits-back is therefore naturally combined with ANS coding which operates in stack order (Section~\ref{sec:entropy_coding}), popularized by the BB-ANS algorithm \cite{townsend2019practical}.
\subsubsection{Improvements and extensions}
\textbf{Continuous latents.}
When the latent vector is continuous, bits-back coding can still be applied after discretizing the latent space and associated distributions \cite{mackay2003information}\cite{townsend2019practical}. More finely discretized latents will require more bits to encode, exacerbating the initial bits problem, but allow us to recover an equal amount of bits back. Bits-back coding thus allows us to code continuous latents with arbitrarily high precision.
\textbf{Extension to models with multiple latents.}
Although our discussion focused on a model with a single latent tensor,
Ho et al. \cite{ho2019compression} and Townsend et al. \cite{townsend2019hilloc} extended bits-back coding to hierarchical latent variable models, leveraging their superior expressiveness (in terms of better NELBO)
to improve compression performance.
Bit-Swap \cite{ho2019compression}, in particular, places restrictions on the latent hierarchy (e.g., Markovian) to allow recursive bits-back coding, alleviating the initial-bits problem. Ruan et al. \cite{ruan2021improving} and Townsend et al. \cite{townsend2021lossless} developed bits-back schemes for sequential (e.g., time-series) latent variable models.
\textbf{Iterative inference.}
As discussed in Sec.~\ref{sec:two-part-code}, the overhead of bits-back coding is equal to the KL divergence between $q(\mathbf{z}\,|\,\mathbf{x})$ and the true posterior $p(\mathbf{z}\,|\,\mathbf{x})$.
The parameters of $q$ (e.g., mean of a Gaussian) are typically predicted from $\mathbf{x}$ by an \textit{amortized inference} network, as in a VAE (see, e.g., \cite{kingma2014vae}). Although cheap to compute, the resulting $q$ distribution is generally suboptimal \cite{cremer2018inference}.
Yang et al. \cite{yang2020improving} took a pre-trained model \cite{minnen2018joint} and proposed to directly minimize the KL gap with respect to the $q$ parameters for each given data point $\mathbf{x}$, resulting in improved image compression performance.
\textbf{Extended latent spaces.}
Analogous to the importance-weighted ELBO \cite{burda2015importance}, importance-weighted NELBO provides a tighter variational upper bound on the ideal code length than the NELBO (Eq.~\ref{eq:nelbo}).
Ruan et al. \cite{ruan2021improving} and Theis et al. \cite{theis2021imortance} proposed bits-back coding schemes that operate in an extended latent space and operationalize the coding cost of the importance-weighted NELBO, and demonstrated improved compression performance.
\subsection{Invertible flows and other models}
\label{sec:flow-and-other-models}
\textbf{Normalizing Flows.}
Although \textit{continuous} normalizing flows do not lend themselves directly to lossless compression, local bits-back coding \cite{ho2019compression} allows lossless compression of finely quantized continuous data, with a code length close to the negative log data density up to a constant dependent on the quantization precision. The same method also allows losslessly compressing discrete data using a flow trained on the dequantization objective (e.g., the LHS of Eq.~\ref{eq:continuou-ll-rate-ub}).
By contrast, \textit{discrete normalizing flows} \cite{hoogeboom2019integer}\cite{tran2019discrete} directly model integer-valued data and support lossless compression. Such a flow learns a bijection $f$ to map data to an integer latent space, where a factorized prior is assumed; the given data $\mathbf{x}$ can then be compressed by simply entropy-coding its latent representation $f(\mathbf{x})$, and decompressed using $f^{-1}$. This can be viewed as bits-back coding with a deterministic $q$.
\textbf{Other Models.}
New types of generative models continue to be explored for lossless compression, aiming to achieve greater modeling power (hence better compression rate), while reducing computational demands. Promising recent examples include probabilistic circuits~\cite{liu2021lossless}, which offer fast encoding/decoding time and lightweight models, and discrete diffusion models~\cite{sohl2015deep}\cite{hoogeboom2021autoregressive}, which offer parallel encoding/decoding and improved single-image compression rate.
\section{Lossy compression}
\label{sec:lossy-compression}
In the following we review neural \textit{lossy} compression, that is, compression with imperfect data reconstruction. After a brief introduction, we discuss basic theoretical background (Section~\ref{sec:lossy-background}), neural lossy compression (Section~\ref{sec:neural-lossy-compression}), perceptual losses (Section~\ref{sec:perceptual-losses}), compression without quanization (Section~\ref{sec:compression-without-quantization}), and video compression (Section~\ref{sec:video-compression}).
Frequently, we make reference to the \textit{quantization} operation, denoted by $\Q{\cdot}$. Quantization can be implemented in various ways in neural compression (e.g., by rounding to the nearest integer, denoted by $\round{\cdot}$; we give a detailed treatment in Section~\ref{sec:learning-quantized-representations-and-rate-control}), but at a high level is understood to be any mapping, either deterministic or stochastic, from a (usually continuous) set of input to a \textit{countable} set of output values.
\subsection{Background}
\label{sec:lossy-background}
The main feature distinguishing lossy compression from lossless compression is that the decoder obtains an imperfect, or \textit{distorted}, reconstruction of the original data. This extra flexibility allows for more effective compression.
For example, lossy reconstruction is sufficient and widely used for transmitting digital media such as images and videos. For continuous data, which cannot be perfectly represented by a finite bitstring, lossy compression is also a practical necessity.
We give an overview of the classical theory of lossy compression, the closely related vector quantizer, and its computationally improved version --- transform coding, which is arguably the precursor to neural lossy compression.
\subsubsection{Rate-distortion theory}\label{sec:rd-theory}
We consider a lossy compression algorithm (or a lossy \textit{codec}) to be a 3-tuple consisting of an encoder, decoder, and an entropy code, denoted by $c=(\texttt{e}, \texttt{d}, \gamma)$.
The \textit{encoder} $\texttt{e}: \mathcal{X} \to \mathcal{S}$ maps each data point $\mathbf{x}$ to an element of a discrete set $\mathcal{S}$ (e.g., a subset of natural numbers). The \textit{decoder} $\texttt{d}: \mathcal{S} \to \hat\mathcal{X}$ maps each encoding $s$ to a \textit{reconstruction point} $\hatx \in \hat\mathcal{X}$.
The encoder and decoder further agree to transmit the symbols of $\mathcal{S}$ under an \textit{entropy code} $\gamma$ (see Sec.\ref{sec:entropy_coding}); we write $l(\mathbf{x}):=|\gamma(\texttt{e}(\mathbf{x}))|$ to denote the code length assigned to the encoding of $\mathbf{x}$.
Suppose we are given a \textit{distortion function} $\rho: \mathcal{X} \times \hat\mathcal{X} \to [0, \infty)$ that measures the error caused by representing $\mathbf{x}$ with the lossy reconstruction $\hatx$ (e.g., squared error $\|\mathbf{x} - \hatx\|^2$). Lossy compression is then generally concerned with minimizing
the average \textit{distortion}
\begin{align}
\mathcal{D} = \mathbb{E}[\rho(\mathbf{x}, \hatx)] = \int \rho(\mathbf{x}, \hatx) p_{data}(\mathbf{x}) \text{d}\mathbf{x}, \label{eq:rd-distortion}
\end{align}
and simultaneously, the \textit{rate}
\begin{align}
{\mathcal R} = \mathbb{E}[l(\mathbf{x})] = \int l(\mathbf{x}) p_{data}(\mathbf{x}) \text{d}\mathbf{x},
\end{align}
that is, the average number of bits needed to encode the data. We want to minimize these two quantities with respect to the choice of the encoding and decoding procedures $\texttt{e}$ and $\texttt{d}$, as well as the entropy code $\gamma$.
Rate-distortion (R-D) theory \cite{shannon1959coding} \cite{cover2006elements} establishes limits on the performance of any such algorithm.
Any lossy compression algorithm implements a noisy channel that receives a data input $\mathbf{x}$ and outputs a reconstruction $\hatx$,
described by a conditional distribution $p(\hatx \mid \mathbf{x})$. The mutual information $I[\mathbf{x}, \hatx]$ expresses the information transmitted,
and for a given distortion threshold $D$, the lowest achievable rate is characterized by the information \textit{rate-distortion function} \cite{shannon1959coding},
\begin{align}
{\mathcal R}_I(D) = \inf_{p(\hatx|\mathbf{x}) : \mathbb{E}[\rho(\mathbf{x}, \hatx)] \leq D} I[\mathbf{x}, \hatx], \label{eq:info-rdf}
\end{align}
where $\mathbb{E}[\rho(\mathbf{x}, \hatx)] $ and $I[\mathbf{x}, \hatx]$ are defined with respect to the joint distribution $p_{data}(\mathbf{x}) p(\hatx|\mathbf{x})$.
The (information) R-D function is thus a fundamental quantity that generalizes the Shannon entropy $H$ (Eq.~\ref{eq:entropy-definition}) from lossless compression to lossy compression, but is generally unknown analytically.
It can be estimated by the Blahut-Arimoto algorithm \cite{cover2006elements} when the data and reconstruction spaces are discrete and low-dimensional, and recently Yang and Mandt \cite{yang2022towards} proposed a machine learning approach for estimating the rate-distortion function in a significantly more general setting.
In theory, the optimal rate ${\mathcal R}_I(D)$ is achievable by vector quantization \cite{cover2006elements}, described next (Section~\ref{sec:vector-quantization}), but this approach to compression quickly becomes intractable for high-dimensional data. Rather than trying to achieve the theoretically optimal rate ${\mathcal R}_I(D)$ with any codec at any computational cost, in practice the design of a lossy codec is constrained by practical considerations, such as the computation budget of the target hardware, or the decoding latency acceptable for the application. Denoting the set of all the acceptable codecs under consideration by $\mathcal{C}$, we can instead consider an \textit{operational} rate-distortion tradeoff, formalized by
\begin{align}
{\mathcal R}_O(D) = \inf_{c \in \mathcal{C} : \mathbb{E}[\rho(\mathbf{x}, \hatx)] \leq D} \mathbb{E}[l(\mathbf{x})]. \label{eq:op-rdf}
\end{align}
Compared to Eq.~\ref{eq:info-rdf}, we replaced mutual information by the operational rate and optimize over an actual lossy codec $c$.
We can relax the constrained optimization problem to an uncontrained one, by introducing the Lagrangian \cite{chou1989entropy},
\begin{multline}
L(\lambda, c) = \mathcal{R}(c) + \lambda \mathcal{D}(c) = \mathbb{E}[l(\mathbf{x})] + \lambda \mathbb{E}[\rho(\mathbf{x}, \hatx)]. \label{eq:operational-rd-lagrangian}
\end{multline}
For each fixed $\lambda > 0$, minimizing the above rate-distortion Lagrangian yields a
codec $c^*$ whose operational distortion-rate performance, $(\mathcal{D}(c^*), {\mathcal R}(c^*))$, lies on
the convex hull of the operational R-D curve (see Fig.~\ref{fig:rd-optimization}).
Codecs with different operational rate-distortion trade-offs can be found by minimizing the Lagrangian with various $\lambda$. Most current end-to-end learned lossy compression methods to be discussed in Section~\ref{sec:neural-lossy-compression} follow this approach, training one codec for each $\lambda$.
We note that theoretically, it is not always possible to attain every point on the operational R-D curve with this approach \cite{degrave2021tunable}, and alternative approaches exist \cite{platt1988constrained, vanrozendaal2020lossy}.
\begin{figure}
\centering
\includegraphics[width=0.8\columnwidth]{figures/operational-RD-optimization-crop.pdf}
\caption{
Visualizing the operational R-D optimization problem. We adjust our codec $c$ to minimize the $R$-axis intercept of a straight line (gray) with slope $-\lambda$ and passing through $(\mathcal{D}(c), {\mathcal R}(c))$; an optimum occurs when the line becomes tangent to the operational R-D curve $R_O$ at the point $(\mathcal{D}(c^*), {\mathcal R}(c^*))$. Note that the operational R-D curve (orange) lies above the information R-D curve $R_I$ (red), and is not necessarily convex.
}
\label{fig:rd-optimization}
\end{figure}
\subsubsection{Vector Quantization}
\label{sec:vector-quantization}
Vector quantization (VQ), a classical technique from signal processing, is perhaps the most basic form of a lossy codec.
A quantization scheme in VQ consists of a set $\hat\mathcal{X}$ of quantization points (usually a subset of the data space $\mathcal{X}$), and an assignment rule $\mathbf{x} \to \hatx$, which corresponds precisely to the composition $\texttt{d} \circ \texttt{e}$ in the notation of Sec.~\ref{sec:rd-theory}. The goal is then to determine an optimal quantization scheme for a given data distribution, under some objective. Commonly, the objective is to minimize a reconstruction error (Eq.~\ref{eq:rd-distortion}), as in the $k$-means algorithm, but can also more generally be an operational rate-distortion trade-off (Eq.~\ref{eq:op-rdf}).
For some data source, e.g., the uniform or the Laplace distribution, optimal quantization can be characterized analytically \cite{ziv1985universal}\cite{sullivan1996efficient}.
In most applications, Loyd-Max-style algorithms \cite{lloyd1982least}\cite{chou1989entropy} (including $k$-means) are used instead to estimate a quantization scheme from data samples.
This usually involves minimizing an empirical rate-distortion cost (Eq.~\ref{eq:operational-rd-lagrangian}) over a dataset, which is still a basic ingredient in today's learned compression approaches \cite{balle2021ntc} (see Sec.~\ref{sec:neural-lossy-compression}).
Given unlimited data and compute, VQ can approximate any data distribution arbitrarily well -- in fact, the theoretical limit of lossy compression, the information rate-distortion function ${\mathcal R}_I(D)$, can be shown to be achieved by jointly quantizing multiple data samples together with increasingly long blocks \cite{cover2006elements}.
However, VQ comes with the severe downside of poor scalability and data efficiency \cite{gersho2012vector}.
The computational and storage demand of VQ increases quickly with the data dimensionality.
Moreover, in high dimensions, an exceedingly large number of quantization points and high amounts of training data are needed to approximate the data distribution well. As a result, VQ is typically found in low-rate/high-distortion applications, such as low-rate speech coding \cite{sayood2012vectorq}.
\subsubsection{Transform coding}
\label{sec:transform-coding}
Instead of quantizing the data in its original representation, it is often much easier to do so in a transformed space, where the representation of the data is uncorrelated.
The core idea behind transform coding \cite{goyal2001theoretical} is therefore to divide the task of lossy compression into decorrelation and quantization: first, the sender applies an \textit{analysis transform} $f$ to data $\mathbf{x}$, resulting in a vector $\mathbf{z}=f(\mathbf{x})$ which ideally follows a factorized distribution; and second,
coordinate-wise scalar quantization $\Q{\cdot}$ is applied to obtain a discretized representation $\hatz = \Q{\mathbf{z}}$.
The symbols representing $\hatz$ can then be converted to a bitstring by entropy coding under an entropy model $P(\hatz)$. The receiver, upon receiving the bitstring, decodes it to recover $\hatz$, and computes a reconstruction $\hatx = g(\hatz)$ using a \textit{synthesis transform} $g$.
In the terminology of Section~\ref{sec:rd-theory}, the encoder $\texttt{e} = \Q{\cdot} \circ f$ is the composition of the analysis transform $f$ followed by quantization, and the decoder $\texttt{d}$ is implemented by the synthesis transform $g$.
Unlike vector quantization, which effectively optimizes over all possible choices of encoder $\texttt{e}: \mathcal{X} \to \mathcal{S}$ and decoder $\texttt{d}: \mathcal{S} \to \hat\mathcal{X}$, transform coding implicitly restricts the solution space of allowable codecs, e.g., the set of quantization points must be in the range of $g$, and therefore generally cannot achieve the unconstrained optimal performance of VQ.
The lack of theoretical optimality of transform coding is more than made up for by its vastly superior scalability over VQ, as evidenced by its wide-spread use in the compression of digital media, such as images and videos \cite{goyal2001theoretical}.
\subsection{Neural lossy compression}
\label{sec:neural-lossy-compression}
Most current neural lossy compression methods are based on the paradigm of \textit{nonlinear transform coding} \cite{balle2021ntc} and use learned functions to encode data into a discrete representation, typically by quantizing a continuous representation. As follows, we review basic concepts and architectures, deferring a full discussion on model training to Section~\ref{sec:learning-quantized-representations-and-rate-control}.
\subsubsection{Overview}
Building on transform coding (Section~\ref{sec:transform-coding}), a neural compression algorithm implements the analysis transform $f$ and synthesis transform $g$ using neural networks.
The transformed representation $\mathbf{z} = f(\mathbf{x})$ is often referred to as a latent representation, or simply ``latents'', due to the connection to latent variable modeling.
As in transform coding,
we need a probability model $P$ of the discretized representation $\hatz = \Q{\mathbf{z}}$,
called an \textit{entropy model}, in order to entropy code $\hatz$ into a short bit string and back (Section~\ref{sec:entropy_coding}). The entropy models are often based on powerful models from neural lossless compression (Section~\ref{sec:lossless-compression}).
Most commonly, the objective is to simultaneously minimize the rate,
\begin{align}
{\mathcal R} := \operatorname{\mathbb E}[ - \log_2 \pent(\Q{f(\mathbf{x})})], \label{eq:ntc-rate-loss}
\end{align}
and the distortion,
\[
\mathcal{D} := \mathbb{E}[\rho(\mathbf{x}, g( \Q{f(\mathbf{x})} )]. \label{eq:ntc-distortion-loss}
\]
The expectations are taken w.r.t. the data distribution $p_{data}$ and are estimated with data samples.
Unlike in Section~\ref{sec:rd-theory},
here we no longer concern ourselves with an entropy code $\gamma$. Instead, we directly optimize with the information content in place of a code length in Eq.~\ref{eq:ntc-rate-loss}, knowing that an entropy code can (in principle) always be derived from $P$ such that $-\log_2 P(\cdot) \approx |\gamma(\cdot)|$ (see Section~\ref{sec:entropy_coding}).
If we denote the true marginal distribution of $\hatz$ by $\pent^* (\hatz)$ (which is induced by $p_{data}$ and the encoding procedure in a complex way), then the rate loss can be equivalently written as the cross entropy,
\begin{align}
\rate = \operatorname{\mathbb E}_{\pent^*(\hatz)}[ - \log_2 \pent(\hatz)],
\label{eq:ntc-rate-loss-ce}
\end{align}
which precisely captures the cost of entropy coding $\hatz \sim \pent^*(\hatz)$ under our model $\pent(\hatz)$, and serves as an upper bound to the entropy $\mathbb{H}[\pent^*(\hatz)]$.
Analogous to Eq.~\ref{eq:operational-rd-lagrangian}, we can form a Lagrangian objective by a linear combination of rate and distortion, with $\lambda > 0$:
\begin{align}
\mathbb{E}[-\log_2 \pent( \Q{f(\mathbf{x})} )] + \lambda \mathbb{E}[\rho(\mathbf{x}, g( \Q{f(\mathbf{x})} )]. \label{eq:ntc-lagrangian}
\end{align}
Denoting the reconstruction again by $\hatx = g( \Q{f(\mathbf{x})} )$, the objective bears a close resemblance to that of a regularized autoencoder \cite{bourlard1988auto}\cite{rumelhart1985learning}, where the analysis and synthesis transforms $f$ and $g$ correspond to the encoder \footnote{Unfortunately, this use of the term ``encoder'' for the function $f$ of an autoencoder clashes with our definition of encoders $\texttt{e}$ in Section~\ref{sec:lossy-compression}. The ``encoder'' can also mean more abstractly the party initiating the data communication (and similarly, ``decoder'' can refer to the party receiving the data). The meaning is usually clear from the context.} and decoder of an autoencoder, the distortion term $\lambda \mathbb{E}[\rho(\mathbf{x}, \hatx)]$ corresponds to a reconstruction error, and the rate term can be seen as a regularizer imposed on the representation $\hatz$. Unlike in traditional autoencoders, where some form of compression is achieved by requiring the representation to have low dimensionality or sparsity \cite{goodfellow2016deep}, learned compression instead aims to reduce the bits-per-sample information cost of data compression, as measured by the rate term.
\subsubsection{Neural Transform Architectures}
\textbf{Feedforward neural networks} are most often used for the encoding and decoding transforms $(f,g)$ in lossy compression, as in traditional autoencoders.
For compressing unstructured data, fully-connected neural networks have been used \cite{balle2021ntc, yang2022towards}.
In image compression, the networks are typically convolutional neural networks (CNNs), with $f$ implementing downsampled convolutions, and $g$ typically implementing upsampled convolutions
\cite{balle2016end} or sub-pixel convolutions \cite{theis2017cae}\cite{toderici2017full}.
From the perspective of transform coding, it is not yet clear if these CNN architectures borrowed from computer vision research are most effective at decorrelating the input, and some techniques, such as Generalized Divisive Normalization \cite{balle2016end}, have been proposed to improve the transforms in this regard.
We refer to \cite{balle2021ntc, johnston2019computationally} for discussions on network capacity and its effect on computation and compression performance, but note that in the low-distortion regime, higher capacity transforms (e.g., by increasing the number of filters in a CNN) are generally needed to maximize the rate-distortion performance \cite{balle2017end}.
\textbf{Recurrent architectures.} Instead of encoding data $\mathbf{x}$ into $\mathbf{z}$ with a single neural network, it can be beneficial to introduce a feedback mechanism to involve the decoder in the encoding process.
We may divide the compression of $\mathbf{x}$ into $T$ stages, each stage generating an incremental representation $\hatz_t$ from the encoder to the decoder, and the final $\hatz$ consisting of the concatenation $\hatz_1, \hatz_2, ..., \hatz_T$.
At the beginning of stage $t$, the decoder has available a tentative data reconstruction $\hatx_{t-1}$ computed from stage $t-1$, using the already received $\hatz_1, \hatz_2, ..., \hatz_{t-1}$. Crucially, the encoder is equipped with a copy of the decoder, so having computed the same $\hatx_{t-1}$, the encoder only encodes the information in $\mathbf{x}$ that is not present in $\hatx_{t-1}$ (e.g., by encoding the \textit{residual}, $\mathbf{x} - \hatx_{t-1}$, in image compression). The resulting representation $\hatz_{t}$ is sent to the decoder, which then uses $\hatz_{t}$ to compute an improved tentative reconstruction $\hatx_t$. This process continues, with $\hatx_T$ declared the final data reconstruction $\hatx$. Here, $f:\mathbf{x} \to \hatz$ (similarly, $g$) is no longer implemented by a feedforward architecture, but rather a recurrent one, with $\hatx_t$ being the recurrent state.
Such an approach embodies the idea of ``analysis-by-synthesis'', a classic model of perception and comprehension \cite{bever2010analysis}, and enables progressive compression whereby the data reconstruction $\hatx_t$ improves as more information in $\hatz_t$ is transmitted.
Moreover, many video compression methods in Section~\ref{sec:video-compression} follow the same predictive coding paradigm, with $\mathbf{x}=[\mathbf{x}_1,...,\mathbf{x}_T]$ being a sequence of video frames, and $\hatz_t$ carrying the information in the reconstucted frame $\hatx_t$.
We give a concrete example by Toderici et al. \cite{toderici2016rnn}\cite{toderici2017full}, who proposed some of the first recurrent neural architectures for progressive and variable-rate image compression.
Here, the computation at each stage can be summarized as
\begin{align*}
\hatz_t = \Q{ f_t(\mathbf{r}_{t -1}) }, \ & \mathbf{r}_t = \mathbf{x} - \hatx_t, \hatx_t = g_t(\hatz_t) + \alpha \hatx_{t-1} ; \\
& \mathbf{r}_0 = \mathbf{x}, \hatx_0 = \mathbf{0} ,
\end{align*}
where $\mathbf{r}_t$, $f_t$, and $g_t$ denote the residual vector, encoding transform, and decoding transform at time $t$, respectively, and $\alpha \in \{0, 1\}$ allows two different modes of operation. With $\alpha=1$ (``additive reconstruction'' mode), $f_t$ and $g_t$ can simply be a pair of CNNs (with a separate pair for each $t$), and are trained to additively correct the cumulative reconstruction at each stage. With $\alpha=0$ (``one-shot reconstruction'' mode), $f_t$ and $g_t$ are chosen to be stateful, and typically LSTM architectures, which are trained to directly predict the entire original image at each stage.
Progressive and variable-rate image compression can then be achieved by controlling the number of steps $T$ of the recursive computation.
\subsection{Learned quantization and rate control}\label{sec:learning-quantized-representations-and-rate-control}
Neural networks have been used in image compression since before 1990 \cite{sonehara1989nn}\cite{jiang1999image}, but techniques were only recently developed to allow end-to-end training directly on a rate-distortion objective \cite{toderici2016rnn}\cite{balle2016end}\cite{theis2017cae}. The main stumbling block has been the fact that the quantization operation and the discrete rate loss are not differentiable.
As quantization maps (usually continuous) input to a discrete set, its derivative is zero almost everywhere and undefined at points of discontinuity.
By the chain rule, the parameters of the encoder transform also receive zero gradient almost everywhere. Moreover,
the rate loss, defined via the PMF $P(\hatz)$, also has no derivative w.r.t. the discrete representation $\hatz$.
Below we survey the major approaches developed over the years for dealing with the non-differentiability problem, organized by how quantization is done. Since the issue of model training under quantization is intimately connected with minimizing or controlling the bit-rate (Eq.~\ref{eq:ntc-rate-loss-ce}) of the encoder output $\hatz$, we discuss both issues jointly.
We note that although most of these techniques are developed for lossy compression, they are equally useful in lossless compression methods that make use of quantization \cite{hoogeboom2019integer,mentzer2019practical}.
\subsubsection{Binarization}
Some of the earlier work quantized $\hatz$ by element-wise binarization and used ad hoc approaches for rate estimation and control.
Based on techniques for training binarized neural networks \cite{williams1992simple},
Toderici et al. \cite{toderici2016rnn, toderici2017full} proposed stochastic binarization: each scalar element $z$ of $\mathbf{z}$ is preprocessed to lie within $[-1, 1]$ (e.g., using point-wise $\operatorname{tanh}$ as the last layer of $f$), and then stochastically rounded to $-1$ or $1$ based on how close $z$ is to either value:
\[
\Q{z} := \operatorname{B}(z) = z + \epsilon, \quad \mathbb{P}(\epsilon) = \begin{cases} \frac{1+z}{2} \ , \ \epsilon = 1-z \\ \frac{1-z}{2} \ , \ \epsilon = -1-z \end{cases}
\]
To backpropagate through stochasitic binarization, they used a Straight-through Estimator (STE) \cite{bengio2013straight} and defined the gradient to be that of the identity function,
\[
\frac{d }{d z} \operatorname{B}(z) := \frac{d }{d z} \operatorname{\mathbb E}[\operatorname{B}(z)] = \frac{d }{d z} z = 1.
\]
Toderici et al. \cite{toderici2016rnn, toderici2017full} trained the neural network model $(f,g)$ to only minimize the distortion loss, relying on constraints on the dimension of the binary $\hatz$ to implicitly control the rate. After training, a separate autoregressive entropy model (similar to a PixelRNN) is learned on the empirical distribution of $\hatz$ to further reduce the bit-rate \cite{toderici2017full}.
Li et al. \cite{li2017learning} deterministically binarized $\mathbf{z}$ to $\{0, 1\}$ and used STE for backpropagation, optimizing a surrogate rate-distortion objective. For rate control, they introduced a learned masking mechanism to the encoder network to encourage sparsity in $\hatz$, and optimized a surrogate rate loss defined in terms of the soft count of non-zeroed-out elements of $\hatz$. After training, they fit a separate PixelCNN-style entropy model to further reduce rate, similar to \cite{toderici2017full}.
\subsubsection{Soft-to-Hard Vector Quantization}
Agustsson et al. \cite{agustsson2017soft} proposed to use vector quantization with learned codebook values and introduced associated techniques for differentiable quantization and rate control. They considered the typical (hard) quantization operation in VQ (Sec.~\ref{sec:vector-quantization}), mapping $\mathbf{z}$ to its closest codebook vector,
\[
\Q{\mathbf{z}} := \operatorname{VQ}(\mathbf{z}, \mathcal{C}) = \mathbf{c}_j, \quad \text{ with } j = \arg \min_i \| \mathbf{z} - \mathbf{c}_i \|,
\]
where $\mathcal{C} = \{\mathbf{c}_i | i=1,2,.., M\} $ is a finite set of codebook vectors in $\mathbb{R}^N$ learned alongside the model.
Agustsson et al. \cite{agustsson2017soft} proposed to approximate hard quantization by a differentiable \textit{soft} quantization, via a linear combination of the codebook vectors weighted by how close they are to $\mathbf{z}$:
\[
\operatorname{VQ}(\mathbf{z}, \mathcal{C}) \approx \operatorname{SoftQ}(\mathbf{z}, \mathcal{C}) := \sum_i \phi_i \mathbf{c}_i .
\]
Here $\phi \in \Delta^{N-1}$ is a probability vector computed as the softmax of weighted distances, $\phi = \phi(\mathbf{z}, \mathcal{C}) := \operatorname{softmax}( -\sigma [\|\mathbf{z} - \mathbf{c}_1\|^2, ..., \|\mathbf{z} - \mathbf{c}_M\|^2] )$, with $\sigma >0$ a hyperparameter.
In practice, due to the prohibitive computation cost of VQ, the proposed method is only applied independently to small blocks of $\mathbf{z}$.
By annealing $\sigma \to \infty$ throughout training, soft quantization gradually approaches hard quantization, and a proper annealing schedule is needed to ensure effective training.
For rate control, Agustsson et al. \cite{agustsson2017soft} essentially built an entropy model based on the empirical distribution of soft assignment probabilities.
Mentzer et al. \cite{mentzer2018conditional} simplified the above technique
by performing only scalar quantization and dispensing with the annealing procedure. They fixed $\sigma$ at a constant (usually 1), and applied STE to differentiate through (hard) quantization using the gradient of soft quantization, \[
\frac{\partial}{{\partial z}} \operatorname{VQ}(z, \mathcal{C}):= \frac{\partial}{{\partial z}} \operatorname{SoftQ}(z, \mathcal{C}).
\]
Mentzer et al. \cite{mentzer2018conditional} furthermore trained a PixelCNN-style autoregressive entropy model end-to-end.
To soften the non-differentiable discrete rate loss, they used the learned masking technique of Li et al. \cite{li2017learning}, but formed the surrogate rate loss based on the code length of non-zeroed-out elements of $\hatz$ under the concurrently trained autogressive entropy model, instead of naive counts as used by Li et al. \cite{li2017learning}.
\subsubsection{Uniform Quantization (UQ)}\label{sec:approaches-based-on-rounding}
Popularized by Ballé and Theis et al. \cite{balle2016end, theis2017cae},
uniform quantization rounds each element of $\mathbf{z}$ to the closest integer,
\[
\Q{\mathbf{z}} := \round{\mathbf{z}}.
\]
This can be viewed as a scalar version of
the VQ approach, but with a fixed quantization grid equal to the set of integers.
The assumption of a uniform quantization grid with width 1 can generally be justified by using a sufficiently flexible pair of transforms $(f,g)$, which can
warp the quantization grid in arbitrary ways if needed
\cite{balle2016end}\cite{balle2021ntc}.
Compared to VQ, uniform quantization is cheap to compute. Moreover, by embedding the integer-valued discrete representation $\hatz$ in $\mathbb{R}^{N}$, an entropy model can be conveniently specified in terms of a continuous density model, allowing for simpler differentiable rate surrogates than in approaches based on categorically distributed entropy models (e.g., \cite{agustsson2017soft}\cite{li2017learning, mentzer2018conditional}).
Such an entropy model $P$ is defined by an underlying density $p$, exactly as in a discretized density model (Eq.~\ref{eq:discretized-density-model}),
\begin{align}
\pent(\hatz) := \int_{\hatz + [-0.5, 0.5)^N} p(\mathbf{v}) d \mathbf{v}, \quad \forall \hatz \in \mathbb{Z}^N. \label{eq:integer-entropy-model}
\end{align}
We defer details on the choice of $p$ to Section~\ref{sec:entropy-models}, and now discuss a few representative neural compression approaches based on this form of entropy model and integer-valued $\hatz$. In the rest of this sub-section, $\mathbf{u} \sim \mathcal{U} \left([-0.5, 0.5)^N \right)$ is a r.v. with the uniform density $\mathcal{U}$ on the hypercube $[-0.5, 0.5)^N$.
\textbf{UQ + STE.}
Theis et al. \cite{theis2017cae} proposed to train with uniform quantization and approximately differentiate through it by STE, using the identity gradient on the backward pass. For rate control, they optimized the same rate upper bound as on the LHS of Eq.~\ref{eq:continuou-ll-rate-ub}, replacing the code length $- \log_2 \pent(\hatz)$ by the differentiable upper bound $ \operatorname{\mathbb E}_\mathbf{u}[ -\log_2 p(\hatz + \mathbf{u})]$.
\textbf{Additive Uniform Noise.} Ballé et al. \cite{balle2016end} replace rounding with additive uniform noise for model training, i.e.,
\[
\round{\mathbf{z}} \approx \mathbf{z} + \mathbf{u}, \; \mathbf{u} \sim \mathcal{U} \left([-0.5, 0.5)^N \right).
\]
Naively, one might simply substitute the above into the Lagrangian Eq.~\ref{eq:ntc-lagrangian} and hope to obtain a reasonable training objective.
However, the resulting code length, $-\log_2 \pent( f(\mathbf{x}) + \mathbf{u} )$, does not yet make sense, as our entropy model $\pent$ has only been defined over integers. It turns out the form of $\pent$ (Eq.~\ref{eq:integer-entropy-model}) offers a convenient solution:
we can simply extend $\pent$ from $\mathbb{Z}^N$ to all of $\mathbb{R}^N$, by convolving the underlying density $p$ with the uniform noise $\mathbf{u}$, i.e.,
\begin{align}
\tilde{p} := p * \mathcal{U} \left([-0.5, 0.5)^N \right). \label{eq:noisy-latent-density}
\end{align}
It's easy to see that $\tilde p$ agrees with $\pent$ on all integer points, and serves as a smoothed relaxation of $\pent$ which defines a surrogate gradient with respect to its input.
Replacing $P$ by $\tilde p$ in Eq.~\ref{eq:ntc-lagrangian}, and taking expectation with respect to the uniform noise $\mathbf{u}$, we obtain the surrogate training objective,
\begin{align}
\mathbb{E}_{\mathbf{x} \sim p_{data}, \mathbf{u}}[-\log_2 \tilde p( f(\mathbf{x}) + \mathbf{u} ) + \lambda \rho(\mathbf{x}, g( f(\mathbf{x}) + \mathbf{u} ))], \label{eq:unoise-lagrangian}
\end{align}
which is now differentiable with respect to all components of the model, and can be simply estimated by sampling. Although motivated as an approximation to the rate-distortion cost under uniform quantization (Eq.~\ref{eq:ntc-lagrangian}),
Eq.~\ref{eq:unoise-lagrangian} can be shown \cite{balle2021ntc}\cite{agustsson2020uq} to exactly equal the rate-distortion cost of compression with dithered quantization (i.e., quantization with a random offset, $\Q{\mathbf{z}} := \round{\mathbf{z} - \mathbf{u}} + \mathbf{u}$); see Section~\ref{sec:compression-without-quantization}.
It is instructive to consider
the density model $p$ as approximating the distribution
of the \textit{continuous} representation $\mathbf{z} = f(\mathbf{x})$ as induced by $\mathbf{x} \sim \pdata$ and the analysis transform $f$. Indeed, suppose $\mathbf{z}$ is distributed according to $p$, then the distribution of $\hat \mathbf{z} = \round{\mathbf{z}}$ is exactly captured by the entropy model $P$ defined by Eq.~\ref{eq:integer-entropy-model}. Moreover, if we define the ``noisy quantization'' by the random variable $\tilde \mathbf{z} := \mathbf{z} + \mathbf{u}$, then its induced density (given $\mathbf{z} \sim p$) is precisely $\tilde{p}$ from Eq.~\ref{eq:noisy-latent-density}.
It turns out under this perspective, the surrogate Lagrangian based on additive noise (Eq.~\ref{eq:unoise-lagrangian}) bears a close relation to the NELBO objective of a particular type of VAE, where $\tilde \mathbf{z}$ is the latent variable.
Consider, for simplicity, that $\rho$ is the squared difference, $\rho(\mathbf{x}_1, \mathbf{x}_2) = \|\mathbf{x}_1 - \mathbf{x}_2\|^2$. Then Eq.~\ref{eq:unoise-lagrangian} can be shown \cite{balle2016end, theis2017cae} to be equal to an NELBO,
\[
\operatorname{\mathbb E}_{\mathbf{x} \sim \pdata} \operatorname{\mathbb E}_{q(\tilde \mathbf{z}|\mathbf{x})} [ -\log_2 \tilde p(\tilde \mathbf{z}) + \log_2 q(\tilde \mathbf{z}|\mathbf{x}) - \log_2 p(\mathbf{x}|\tilde \mathbf{z} )] + \operatorname{const},
\]
where $\tilde p(\tilde \mathbf{z})$ plays the role of a prior, $q(\tilde \mathbf{z} | \mathbf{x})$ is a fully factorized uniform posterior density centered at $\mathbf{z}= f(\mathbf{x})$, and $p(\mathbf{x}|\tilde \mathbf{z})$ is a Gaussian likelihood model with mean equal to the reconstruction $\hatx = g(\tilde \mathbf{z})$, and diagonal covariance controlled by $\lambda$. With this choice of distributions, sampling from the uniform posterior $q$ via the reparameterization trick is precisely equivalent to adding uniform noise to the encoding; the prior term of the NELBO then equals the expected rate loss in Eq.~\ref{eq:unoise-lagrangian}, the posterior entropy term is constant (in fact, 0), and the log-likelihood term equals a squared distortion loss.
\textbf{Discrete Latents and Stochastic Gumbel Annealing.}
There is an alternative
perspective on neural lossy compression that also connects optimizing an expected rate-distortion loss to training a probabilistic autoencoder with \textit{discrete} latent variables \cite{habibian2019video, yang2020improving}.
Under this perspective, given data sample $\mathbf{x}$, we use a stochastic encoder to compute a distribution over the discrete encoding, denoted by $q(\hatz|\mathbf{x})$.
We then randomly sample a $\hatz$ value from this distribution and transmit it losslessly to the receiver.
The expected rate-distortion cost of this compression procedure is then
\begin{align}
\operatorname{\mathbb E}_{\mathbf{x} \sim p_{data}} \operatorname{\mathbb E}_{\hatz \sim q(\hatz|\mathbf{x})} [ -\log_2 \pent(\hatz) + \lambda \rho (\mathbf{x}, g(\hatz)) ].
\label{eq:disc-vae-rd-obj}
\end{align}
As before, we can interpret the distortion term to correspond to a suitably chosen negative log-likelihood, i.e., $ \lambda \rho (\mathbf{x}, g(\hatz)) = - \log_2 p(\mathbf{x}|\hatz) + \text{const}$. Then the above loss function has the form the NELBO of a VAE, but without the usual posterior entropy term; and unlike the VAE obtained from additive uniform noise (see previous paragraph), the latent variable $\hatz$ here is discrete.
As pointed out by Habibian et al. \cite{habibian2019video},
this loss is in fact an upper bound on the usual NELBO: for each $\mathbf{x}$, the expected rate, a cross-entropy, $\operatorname{\mathbb E}_{q(\hatz|\mathbf{x})} [ -\log_2 \pent(\hatz)]$, upper bounds the usual $KL(q(\hatz|\mathbf{x}) \| P(\hatz))$,
with the gap equal to the entropy $\mathbb{H}[q(\hatz|\mathbf{x})]$.
The upper bound becomes tight for an optimal encoder, which deterministically places all the mass of $q(\hatz|\mathbf{x})$ on the $\hatz$ value that minimizes Eq.~\ref{eq:disc-vae-rd-obj} for each $\mathbf{x}$. Note that generally, the divergence $KL(q(\hatz|\mathbf{x}) \| P(\hatz))$ is only an ideal rate that is achieved asymptotically by a likelihood encoder (see Section \ref{sec:importance-sampling}).
Based on this perspective, Yang et al. \cite{yang2020improving} considered a variational distribution $q(\hatz|\mathbf{x})$ parameterized by a continuous vector
$\boldsymbol{\mu} \in \mathbb{R}^N$ (optionally predicted by the inference network),
such that the distribution is concentrated on a small number of integer vectors near $\boldsymbol{\mu}$. The probability for each integer configuration of $q(\hatz|\mathbf{x})$ depends inversely on its distance to $\boldsymbol{\mu}$, similarly to the softmax formulation of Agustsson et al. \cite{agustsson2017soft}; a similar temperature hyperparameter is annealed throughout optimization to make $q$ become increasingly deterministic, such that sampling from $q$ mimics hard rounding. To optimize w.r.t. the parameter $\boldsymbol{\mu}$, the Gumbel-softmax trick \cite{jang2016categorical, maddison2016concrete} is used to differentiate through samples of $q$.
The discrete entropy model $P$ is replaced by its continuous extension $\tilde p$ (Eq.~\ref{eq:noisy-latent-density}) for gradient-based optimization, as in the uniform noise approach.
The resulting method, Stochastic Gumbel Annealing (SGA), is applied to improve the compression performance of pre-trained models at test time \cite{yang2020improving}.
Tsubota et al. \cite{tsubota2021comprehensive} further applied a version of SGA for end-to-end training, using STE instead of the Gumbel-softmax trick to differentiate through sampling $\hatz \sim q$ (which we refer to as SGA+STE), and obtained improved R-D performance compared to the UQ+STE approach.
\textbf{Comparisons.}
Empirical results \cite{Lee2019Context, minnen2020channel, agustsson2020scale} suggest that it is beneficial to train with different approximations for optimizing the distortion v.s. the rate terms of the R-D loss (Eq.~\ref{eq:ntc-lagrangian}
). A recent empirical comparison of combinations of various approaches \cite{tsubota2021comprehensive} confirms this, showing that it is best to combine a rounding-based approximation (SGA+STE, UQ+STE) for the distortion term, and a uniform-noise-based approximation (additive uniform noise, dithered quantization \cite{choi2019uq}) for the rate term.
\subsubsection{Entropy models}\label{sec:entropy-models}
Various entropy models have been proposed to reduce the bit-rate and improve the rate-distortion performance of neural lossy compression, using largely the same modeling ideas as for lossless compression.
In most approaches before uniform quantization, such as binarization or VQ with learned codebooks, an autoregressive entropy model (a.k.a., ``context model'') is most often used, either with a PixelCNN-like neural model \cite{li2017learning, toderici2017full, mentzer2018conditional}, or an off-the-shelf adaptive entropy coder \cite{agustsson2017soft}.
More possibilities have been explored in approaches based on uniform quantization, where the entropy model can be conveniently parameterized in terms of a density model $p$ (``prior density'') as in Eq.~\ref{eq:integer-entropy-model}.
Perhaps the simplest choice is a fully-factorized $p$, resulting in a factorized entropy model. Each marginal of $p$ is typically parameterized as a mixture distribution \cite{theis2017cae}, or indirectly as the derivative of a deep CDF model \cite{balle2018hyper} (exploiting the relation in Eq.~\ref{eq:discretized-entropy-model-via-difference-of-CDFs}).
Going beyond factorized entropy models, recent research has explored latent-variable modeling, autoregressive modeling, and their combination, to increase the flexibility of the prior density $p$ and improve the compression rate \cite{balle2018hyper, minnen2018joint, minnen2020channel}.
The basic latent variable model approach, commonly referred to as the \textit{hyperprior} approach \cite{balle2018hyper}, expresses the entropy model's underlying density through an additional hierarchy of latent variables $\mathbf{h}$ (``hyper-latents''),
\begin{align*}
\mathbf{h} \sim p(\mathbf{h})&, \hath = \round{\mathbf{h}}; \\
\mathbf{z} | \hath \sim p(\mathbf{z} | \hath)&, \hatz = \round{\mathbf{z}}.
\end{align*}
The hyperprior density, $p(\mathbf{h})$, is typically parameterized as in a factorized entropy model, while $p(\mathbf{z}|\hath)$ is a density (e.g., factorized Gaussian) whose parameters are predicted from $\hath$ by a neural network (``hyper-decoder'').
Crucially, note that the prior density of $\mathbf{z}$ is conditioned on the discrete $\hath$, as the hyper-latents must be discretized and entropy-coded first at compression time.
The information transmitted in the hyper-latents is known as \textit{side information} in traditional data compression, and lets the sender and receiver dynamically select an entropy model based on the content of the input data.
To train such an entropy model, the rate loss (Eq.~\ref{eq:ntc-rate-loss-ce}) is modified to account for the side-information, replacing $- \log_2 \pent(\hatz)$ by the joint information content $- \log_2 \pent(\hatz, \hath) = - \log_2 \pent(\hath) - \log_2 \pent(\hatz| \hath)$; the same techniques from Section~\ref{sec:approaches-based-on-rounding} can then be used to differentiate through quantization and rate loss.
Empirically, the hyperprior considerably reduces the overall bit-rate of a factorized entropy model, with the side-information comprising a small percentage of the overall rate \cite{balle2018hyper}.
The bit-rate can be further improved by additionally modeling $\hatz$ autoregressively similarly to a PixelCNN~\cite{minnen2018joint}, but results in serial and hence slower decoding. To address this, Minnen et al. \cite{minnen2020channel} proposed to instead use channelwise (instead of spatial) autoregressive conditioning, significantly speeding up (de)compression without harming the rate-distortion performance. Compared to an autoregressive model, a latent-variable entropy model has the advantage of parallel encoding/decoding via (conditionally) factorized distributions, but entails transmitting side-information, similar to the two-part code in lossless compression (Section~\ref{sec:two-part-code}). Yang et al. \cite{yang2020improving} applied bits-back coding to reduce the transmission of side-information in a hyperprior model.
Regardless of the choice of an entropy model, the sender and receiver must agree on the exact same probabilities for entropy coding (such as AC) to operate correctly. This can be a stringent requirement when the entropy models (e.g., the conditional model $P(\hatz|\hath)$) are computed dynamically, especially in the face of round-off errors from floating point arithmetics, and/or non-determinstic GPU operations. We refer readers to Ballé et al. \cite{balle2018integer} for more details on this issue, and a potential solution based on integer arithmetics.
\subsection{Compression without quantization}
\label{sec:compression-without-quantization}
The non-differentiability of quantization has hindered end-to-end training of lossy compression models, and the various methods in Section~\ref{sec:learning-quantized-representations-and-rate-control} replace quantization by a differentiable surrogate at training time. The mismatch between ``soft'' quantization during training and ``hard'' quantization at test time generally results in sub-optimal performance \cite{yang2020improving}.
Annealing can alleviate the problem \cite{agustsson2017soft}\cite{yang2020improving}\cite{agustsson2020uq}, but may suffer high-variance gradients as the approximation approaches quantization, or require tuning.
Researchers have therefore explored alternative compression approaches that do not entail quantization during training.
Yang et al. \cite{yang2020variational} considered quantizing the mode of the variational posterior $q(\mathbf{z}|\mathbf{x})$ in a Bayesian statistical model, in both data and model compression settings. Their method exploits posterior variance to reduce the bit-rate cost for more ``uncertain'' latent dimensions (a feature shared with bits-back coding). By decoupling model training and quantization, the method also naturally lends to variable-rate compression, but is generally out-performed by end-to-end trained image compression methods at lower bit-rates.
Quantization can, in fact, be avoided entirely, if we do not insist on transmitting a fixed value of continuous representation $\mathbf{z}$. Instead, we may transmit a random sample of $\mathbf{z}$ that is nonetheless informative about the data $\mathbf{x}$. Recent research has investigated efficient communication of a continuous but stochastic representation $\mathbf{z} \sim q(\mathbf{z} \mid \mathbf{x})$ directly over a digital channel \cite{bennett2002reverse}, a problem more generally recognized as \textit{channel simulation} \cite{zamir2014book}\cite{li2017strong}, \textit{reverse channel coding} \cite{bennett2002reverse}\cite{agustsson2020uq}, or \textit{relative entropy coding} \cite{flamich2020cwq}.
Bits-back coding (Section~\ref{sec:bits-back}) seems like a natural candidate for this problem as it also uses a stochastic encoder. Unfortunately, it requires the exact data $\mathbf{x}$ to be eventually available to the decoder to achieve full ``bits-back'' efficiency, and therefore is only directly applicable to lossless compression, and not a general solution to reverse channel coding.
Li \& El Gamal \cite{li2017strong} showed that is is possible to communicate $\mathbf{z}$ at an average coding cost of at most
\[
I[\mathbf{x}, \mathbf{z}] + \log_2(I[\mathbf{x}, \mathbf{z}] + 1) + 5
\]
bits. That is, the coding cost is close to the information contained in $\mathbf{z}$. However, they also showed that in general it is not possible to significantly reduce the coding cost. Even for optimal encoders and decoders we may therefore have to pay an overhead which is logarithmic in the mutual information. However, this overhead is relatively small if the mutual information is large.
One way to increase the mutual information (and thus reduce the relative overhead) is to communicate more information at once (for example, by bundling multiple frames of a video). Unfortunately, it can be computationally very expensive to do so. Agustsson \& Theis \cite{agustsson2020uq} showed that there is no general reverse channel coding algorithm whose computational cost is polynomial in the information content. If we want to transmit large amounts of information at once using as few bits as possible, then this may only be possible by spending a lot of computation. Nevertheless, some distributions can be communicated efficiently, both computationally and with low overhead.
In the following, we will review two strategies for communicating stochastic information. One is a simple and efficient approach for simulating channels with additive uniform noise, and one is a general approach for communicating samples of arbitrary distributions. For a more thorough introduction to reverse channel coding, see Theis \& Yosri \cite{theis2021algorithms}.
\subsubsection{Dithered quantization}
Consider a latent representation $\mathbf{z}$ which is the output of a neural network followed by additive uniform noise, i.e.,
\begin{align}
{\mathbf y} &:= f(\mathbf{x}), & \mathbf{z} &:= {\mathbf y} + \mathbf{u},
\end{align}
where $\mathbf{u}$ is a vector of uniform noise with values between $-0.5$ and $0.5$.
It turns out that we can efficiently communicate an instance of $\mathbf{z}$ using an old technique called \textit{dithered} or \textit{universal quantization} \cite{roberts1962noise}\cite{ziv1985universal}.
The key insight is that
\begin{align}
\label{eq:uq}
\mathbf{k}:= \round{{\mathbf y} - \mathbf{u}'} \quad \implies \quad
\mathbf{k} + \mathbf{u}' \stackrel d= {\mathbf y} + \mathbf{u},
\end{align}
where $\mathbf{u}'$ is another vector of independent uniform noise. That is, subtracting uniform noise, rounding, and then adding uniform noise back is distributionally equivalent to adding noise directly. We can exploit this for the communication of a sample of $\mathbf{z}$ as follows. The encoder computes $\mathbf{k}$ and entropy encodes it. The decoder
receives $\mathbf{k}$ and simply adds $\mathbf{u}'$. This assumes that both the encoder and decoder have access to the same $\mathbf{u}'$, e.g., by sharing a random seed.
The entropy of $\mathbf{k}$ turns out to be exactly $I[{\mathbf y}, \mathbf{z}]$ \cite{zamir1992universal}.
The coding cost thus has two very useful properties. First, it is equal to the amount of information transmitted. That is, entropy coding $\mathbf{k}$ is a statistically efficient strategy for communicating an instance of $\mathbf{z}$. Second, the mutual information is the expectation of a differentiable function in ${\mathbf y}$ so that we can easily optimize encoders using backpropagation \cite{agustsson2020uq}.
\subsubsection{Minimal random coding} \label{sec:importance-sampling}
While dithered quantization can be computationally and statistically efficient, it is only able to communicate certain simple distributions. Several general algorithms have been developed to communicate a sample from arbitrary distributions \cite{harsha2007}\cite{cuff2008}\cite{cuff2013}\cite{li2017strong}\cite{havasi2018miracle}\cite{theis2021algorithms}. Here we are describing one algorithm based on importance sampling. In information theory, it is known as the \textit{likelihood encoder} \cite{cuff2013}\cite{song2016}. In machine learning, it has recently been introduced as \textit{minimal random coding} \cite{havasi2018miracle}\cite{flamich2020cwq}.
Assume both the encoder and decoder have access to $p(\mathbf{z})$. The encoder generates $N$ examples $\mathbf{z}_n \sim p(\mathbf{z})$ and forms importance weights $w_n = q(\mathbf{z}_n \mid \mathbf{x}) / p(\mathbf{z}_n)$ for a target distribution $q(\mathbf{z} \mid \mathbf{x})$.
It then randomly samples an index $k$ using the normalized importance weights,
\begin{align}
P(n) = \frac{w_n}{\sum_m w_m}, \quad k \sim P.
\end{align}
The index is uniformly distributed and encoded using $\log_2 N$ bits. The decoder receives $k$ and reconstructs $\mathbf{z}_k$. It can do this if the encoder used a pseudorandom number generator to generate the candidates, and the seed is known to the decoder. Havasi et al. \cite{havasi2018miracle} showed that if the number of samples is
\begin{align}
N = 2^{D_\text{KL}\infdivx{q(\mathbf{z} \mid \mathbf{x})}{p(\mathbf{z})} + t},
\end{align}
then under reasonable assumptions, estimates based on $\mathbf{z}_k$ will be similar to estimates based on $\mathbf{z}$ for $t > 0$. Havasi et al. \cite{havasi2018miracle} applied minimal random coding to model compression, while Flamich et al. \cite{flamich2020cwq} used it for image compression. Theis \& Yosri \cite{theis2021algorithms} showed that the coding cost of minimal random coding can be further reduced without any loss in quality.
\subsubsection{Stochastic versus deterministic coding}
Communication of information without any quantization requires a certain level of noise to be present. Without noise or quantization, there would be no limit to the amount of information we could send through the bottleneck of an autoencoder. This raises the question of whether a deterministic encoder with quantization or a stochastic encoder is better. Ballé et al.~\cite{balle2021ntc} argue that we can always improve on dithered quantization with a deterministic encoder when performance is measured by a rate-distortion trade-off. Theis \& Agustsson \cite{theis2021stochastic} extended this argument to arbitrary stochastic encoders. That is, when we care about a rate-distortion trade-off, the best stochastic encoder is likely to perform worse than the best deterministic encoder. However, Theis \& Agustsson \cite{theis2021stochastic} also showed by example that when we additionally care about the realism of reconstructions (discussed in Section~\ref{sec:perceptual-losses}), stochastic encoders can perform significantly better than deterministic ones. Which one is better therefore depends on the setting of interest.
\subsection{Perceptual losses}
\label{sec:perceptual-losses}
Neural networks are only as good as the losses they are trained for. While in lossless compression the objective is clear -- namely to minimize the required number of bits to represent the data -- the story is a lot more complicated when we turn to lossy compression. Here we need to make decisions about which information to sacrifice in order to save additional bits.
In typical forms of media compression, however, the goal is to make any reconstruction errors as imperceptible as possible. This raises complicated questions about how our brains perceive differences between signals.
\subsubsection{Background}
We can distinguish between two types of distortions, namely \textit{full-reference metrics} and \textit{no-reference metrics}. The former is a function which takes an image and its reconstruction as input while the latter only looks at the reconstruction to make a judgement about its quality. These can be motivated by two corresponding types of quality measures involving humans. \textit{Mean-opinion scores} (MOS) \cite{itu2016mos} are measured by having raters judge reconstructions on a scale from 1 (bad) to 5 (excellent). Since raters are only provided with the reconstructions, their judgments can be viewed as the output of a no-reference metric. Many other \textit{image quality assessments} (IQAs) evaluate perceptual quality without reference to the original data \cite{storrs2018apc}, but MOS is the most widely used measure due to its simplicity. In contrast, \textit{degradation MOS} (DMOS) asks raters for a judgment based on both the unprocessed and the reconstructed data \cite{itu2016mos}, and thus is more akin to a full-reference metric.
In addition to distortions, we may consider \textit{divergences} which depend on the probability distribution of the data and the marginal distribution of reconstructions. Driven by the success of \textit{generative adversarial networks} (GANs) \cite{goodfellow2014gan} in producing realistic looking images, divergence optimization has become an important topic in neural compression.
\subsubsection{Perceptual distortions}
In this section we explore some of the metrics that are most likely to be encountered in the current literature on neural compression.
However, there is a much larger body of potentially relevant work on IQAs and more broadly on perception that we will have to ignore here. For example, \textit{VMAF} \cite{liu2013fvqa}\cite{netflix2016vmaf} is a full-reference metric which is frequently used to evaluate the quality of video in industry but it has not yet found widespread use in the neural compression community.
Mean-squared error (MSE) and peak signal-to-noise ratio (PSNR) are frequently used in neural compression but do not predict perceived quality well \cite{eskicioglu1995iqa}. Another criterion widely used in machine learning and beyond is the structural similarity index (SSIM) \cite{wang2004ssim}. SSIM has been shown to correlate better with human perception and has been extensively studied and extended. The extension most commonly found in neural compression papers is the multi-scale SSIM (MSSSIM) \cite{wang2003msssim} which evaluates SSIM at multiple resolutions and combines them multiplicatively.
While MSE and PSNR are computed pixel-wise, SSIM is computed from small image patches. Let $\mathbf{x}$ and ${\mathbf y}$ be two aligned grayscale image patches extracted from an image and its reconstruction, respectively. Further, let $\mu_\mathbf{x}, \sigma_\mathbf{x},$ and $\sigma_{\mathbf{x}{\mathbf y}}$ represent the average pixel value, the standard deviation and the covariance of pixel values as measured from these patches. Using these quantities, we define
\begin{align*}
l(\mathbf{x}, {\mathbf y}) = \frac{2 \mu_\mathbf{x} \mu_{\mathbf y}}{\mu_\mathbf{x}^2 + \mu_{\mathbf y}^2}; \;
c(\mathbf{x}, {\mathbf y}) = \frac{2 \sigma_\mathbf{x} \sigma_{\mathbf y}}{\sigma_\mathbf{x}^2 + \sigma_{\mathbf y}^2}; \;
s(\mathbf{x}, {\mathbf y}) = \frac{\sigma_{\mathbf{x}{\mathbf y}}}{\sigma_\mathbf{x} \sigma_{\mathbf y}}.
\end{align*} (Small positive constants are added to the numerator and denominator of each expression for numerical stability.)
The structural similarity function $s$ measures correlation,
while the luminance function $l$ and contrast function $c$ are chosen to respond to \textit{relative} changes in luminance or contrast.
These functions will not change much if, for example, both $\mu_\mathbf{x}$ and $\mu_{\mathbf y}$ are scaled by the same factor. This is consistent with Weber's law of how the human visual system perceives changes in these parameters \cite{wang2003msssim}.
SSIM is defined as
\begin{align*}
\text{SSIM}(\mathbf{x}, {\mathbf y}) = l(\mathbf{x}, {\mathbf y})^\alpha c(\mathbf{x}, {\mathbf y})^\beta s(\mathbf{x}, {\mathbf y})^\gamma,
\end{align*}
where $\alpha, \beta, \gamma$ are additional parameters which control the relative importance of the factors (typically set to 1). Note that $\text{SSIM}(\mathbf{x}, \mathbf{x}) = 1$.
To compute a single value for an entire image, one approach is to use a sliding window (e.g., $8 \times 8$ pixels) and then to average SSIM values. MS-SSIM instead uses a smooth windowing approach to compute local statistics in order to avoid blocking artifacts \cite{wang2003msssim}. SSIM is defined for grayscale images. In the neural compression literature, SSIM is typically applied separately to RGB channels and the resulting values averaged to evaluate color images.
SSIM has been shown to perform significantly better at predicting human judgments than MSE on common distortions such as blurriness, noise or blocking artifacts \cite{wang2004ssim}. However, its limitations are also well documented and it tends to fail for reconstructions produced by generative compression approaches \cite{ledig2017srgan}\cite{mentzer2020hific}.
``When a measure becomes a target, it ceases to be a good measure'' \cite{strathern1997goodhart}. In line with this adage, directly optimizing neural networks for MS-SSIM offers mixed results when compared to MSE in terms of perceptual quality \cite{balle2018hyper}. Unlike many applications of IQA, a metric has to make meaningful predictions for all conceivable distortions to be useful as a target in neural compression and cannot have any blind spots. Ding et al. \cite{ding2021iqa} recently compared a large number of IQA methods and found that many were unsuitable for direct optimization.
A common approach to the design of more sophisticated distortions is to rely on deep neural networks which perform well in some other vision task. Typically, these distortions take the form
\begin{align}
\rho_\Phi(\mathbf{x}, {\mathbf y}) = \rho(\Phi(\mathbf{x}), \Phi({\mathbf y})),
\end{align}
where $\Phi$ is some representation derived from the hidden activations of a neural network and $d$ is typically the MSE. Gatys et al. \cite{gatys2016style} compellingly demonstrated the ability of such metrics to capture semantic content at different levels of abstraction in their seminal paper on neural style transfer. Bruna et al. \cite{bruna2016superres} used distortions derived from VGG \cite{simonyan2015vgg} and scattering networks \cite{bruna2013scatter} and applied them to the task of super-resolution, which can be viewed as a simpler form of neural compression with a fixed encoder. They found that these distortions lead to sharper reconstructions than MSE but can also cause artifacts.
Zhang et al. \cite{zhang2018lpips} further investigated the efficacy of distortions based on VGG and found that they can significantly outperform SSIM on a range of artifacts including those generated by neural networks. They further proposed the \textit{learned perceptual image patch similarity} (LPIPS). LPIPS uses pretrained classifiers such as AlexNet \cite{krizhevsky2012alexnet} or VGG \cite{simonyan2015vgg} but its parameters are finetuned in a supervised manner to match human responses. As an alternative, Bardwaj et al. \cite{bhardwaj2020pim} recently showed that representations learned in a completely unsupervised manner can be as effective as LPIPS and proposed the \textit{perceptual information metric} (PIM). Here, $\Phi$ was learned using a contrastive loss.
\subsubsection{No-reference metrics}
\label{sec:noreference}
While no-reference metrics are rarely used as training targets in the current neural compression literature, they are sometimes used for evaluation \cite{mentzer2020hific}. The \textit{natural image quality evaluator} (NIQE) \cite{mittal2013niqe}, for example, extracts nonlinear features from image patches sampled from a test image. It then fits a Gaussian distribution to these features and compares it to a Gaussian distribution fitted to features extracted from natural images. Many extensions of NIQE have been proposed and used in the IQA literature \cite{zhang2015ilniqe}.
\textit{Deep IQA} \cite{bosse2016deepiqa} samples 32x32 image patches from a test image and uses a convolutional neural network to predict perceptual quality judgments. The predictions for different patches are averaged to yield a single score for an image. The parameters of the network were trained in a supervised manner on the LIVE dataset \cite{sheikh2006live} which only contains 981 distorted versions of 29 reference images.
To augment this dataset and to reduce overfitting, Kim et al. \cite{kim2019diqa} pretrained a neural network to predict pixel-wise distortions before training on the LIVE dataset.
\subsubsection{Divergences and adversarial networks}
An image compressor which always outputs a fixed image of high perceptual quality would score high in terms of any no-reference metric and consume zero bits. However, for a useful compressor of natural images, we expect a \textit{diverse} distribution of reconstructions. Such properties can be assessed with \textit{divergences}, measuring the deviation between the data distribution and the distribution of reconstructions. Requirements on a divergence $d$ are $d[p, q] \geq 0$ and $d[p, q] = 0 \iff p=q$ for all distributions $p$, $q$, and a divergence need not be symmetric. Examples include the Kullback-Leibler divergence (KLD), the Jensen-Shannon divergence (JSD), or the total variation distance (TVD).
Divergences are sometimes described as either \textit{zero-avoiding} or \textit{zero-forcing} \cite{minka2005divergences}. Zero-avoiding divergences assign a high penalty to models which assign zero probability to events ($q(\mathbf{x}) = 0$) which have positive probability under the reference distribution ($p(\mathbf{x}) > 0$). They are also called \textit{mode-covering} divergences since they encourage models to assign probability mass to all modes of a distribution.
Examples include the KLD or the $\chi^2$-divergence. On the other hand, zero-forcing divergences assign a high penalty to model distributions which assign positive probability ($q(\mathbf{x}) > 0$) to events which have zero probability ($p(\mathbf{x}) = 0$). These are also called \textit{mode-seeking} divergences since the resulting models tend to ignore some of the modes of distributions with multiple peaks. An examples is the reverse KLD (Eq.~\ref{eq:rkld} with $P$ and $Q$ switched). Zero-forcing divergences are especially useful for capturing realism since they discourage models from generating implausible reconstructions.
Optimizing divergences of high dimensional distributions is challenging. Nevertheless, approximations optimized by generative adversarial networks (GANs) have proven useful in practice \cite{goodfellow2014gan}\cite{nowozin2016fgan}.
Weighted combinations of distortions and adversarial losses have produced very promising results in neural compression and related image reconstruction tasks \cite{ledig2017srgan}\cite{rippel2017waveone}\cite{santurkar2018generative}\cite{agustsson2019extreme}\cite{mentzer2020hific}.
For example, Agustsson et al. \cite{agustsson2019extreme} were able to train autoencoders achieving much more detailed reconstructions at extremely low bit-rates than advanced classical codecs by targeting a perceptual distortion loss $\mathcal{L}_{\rho}$ and a least-squares adversarial loss (LSGAN) \cite{mao2017lsgan} $\mathcal{L}_D$, using the combined loss function
\begin{align}
\text{sup}_{D \in \mathcal{D}} \, \mathcal{L}_D(f, g) + \beta
\mathcal{L}_{\rho}(f, g),
\end{align}
where $D$ is a discriminator (adversary) network, and
\begin{align}
\mathcal{L}_D(f, g) &:= \mathbb{E}[(D(X) - 1)^2 + D(g(\Q{f(X)}, Z))^2], \\
\mathcal{L}_{\rho}(f, g) &:= \mathbb{E}[||\Phi(X) - \Phi(g(\Q{f(X)}, Z))||^2].
\end{align}
Here, $\Q{\cdot}$ is a quantizer mapping the output of the encoder to a finite number of values. Instead of explicitly optimizing a bit-rate, the bit-rate was controlled by limiting the number of values of the quantizer. In addition to the encoder's outputs, the decoder receives independent noise $Z$ as input. The feature representation $\Phi$ is a combination of pixels and VGG feature activations. Interestingly, the $\chi^2$-divergence approximated by the LSGAN loss exhibits even stronger mode-covering behavior than the KLD. This does not seem to prevent LSGAN from being able to produce sharp images, which may be further evidence that adversarial losses do not always behave like the divergences they target \cite{poole2016gans}.
Divergences are not just used for training but also for evaluating neural compression results. In particular, the Frechet inception distance (FID) \cite{heusel2017fid} measures the squared Wasserstein-2 distance between the data and reconstructions in the feature space of the \textit{inception-v3} network \cite{szegedy2015v3}, approximating both distributions as multivariate Gaussian. Both FID and NIQE (Section~\ref{sec:noreference}) measure the distance between two Gaussian distributions. However, while NIQE estimates the distribution of features \textit{within} a single image, FID measures the distribution of features \textit{across} many different images.
\subsubsection{Perception-distortion trade-off}
An important question for neural compression is whether divergences are needed at all. Could we achieve the same results with just a distortion? Optimizing MSE, SSIM and even neural-network-based losses tend to produce artefacts but perhaps these will disappear as perceptual distortions improve. A strong counterargument to this
hope was given by Blau \& Michaeli \cite{blau2018tradeoff}. They showed that \textit{any} distortion is going to produce artefacts for some data unless the compressed representation allows us to reproduce the inputs perfectly. That is, for any lossy codec, the optimal reconstruction $\hatx$ of $\mathbf{x}$ optimized for the expectation of a given distortion will not preserve the data distribution \cite[Theorem 1]{blau2018tradeoff}.
Note that this limitation does not apply if we are allowed to optimize divergences since then we can achieve perfect realism by requiring that all admissible decoders produce reconstructions such that $d[p_\hatx, p_\mathbf{x}] = 0$ for some divergence $d$, at least in theory.
Blau \& Michaeli \cite{blau2018tradeoff} also showed that the achievable divergence can only increase when we demand lower levels of distortion. This makes sense, as the set of available decoders shrinks as we impose stronger constraints on them. Counterintuitively, however, this means that minimizing distortion can have the effect of reducing the realism of reconstructions.
Blau \& Michaeli \cite{blau2018tradeoff} called this the \textit{perception-distortion trade-off}, that is, a small distortion limits the achievable realism and a low divergence (high realism) limits the achievable distortion.
However, different choices of distortions can affect the distortion-realism differently \cite{dosovitskiy2016invert} \cite{ledig2017srgan} \cite{blau2018tradeoff}.
\subsection{Feature compression}\label{sec:feature-compression}
As more data is communicated and processed by machines, a natural question arises whether we can optimize compression toward a supervised goal, such as classification (rather than optimizing for perceptual quality).
For example, Yang et al. \cite{yang2020acc} studied the effect of JPEG artefacts on classification accuracy, while Singh et al. \cite{singh2020end} studied the trade-off between low bit-rates and classification accuracy using similar models as in learned image compression. Matsubara et al. \cite{matsubara2021supervised} demonstrated the benefits of knowledge distillation in this context. Dubois et al. \cite{dubois2021lossy} introduced a supervised compression framework suitable to a multitude of tasks invariant under a set of transformations.
In addition to accuracy, computational decoding efficiency is a big concern when developing codecs for ML models. Training modern classifiers requires the decoding of millions of images or video frames. For example, instead of decoding JPEG images to pixels, Bulla et al. \cite{bulla2019} only decoded the DCT coefficients and fed them directly to a classifier.
\subsection{Video compression}
\label{sec:video-compression}
While deep generative modeling has impacted image compression early on \cite{gregor2016towards}, its application to \textit{video} compression began more recently (circa 2018), likely due to the additional complexity in modeling and computing with videos.
A typical video codec consists of two steps: motion compensation and residual compression. The idea behind motion compensation is to predict the next frame in a video based on previous frames.
Traditionally, motion compensation relied on block motion estimation (i.e., matching entire patches in videos and memorizing compressed displacement vectors). By contrast, neural approaches typically
directly predict the displacement fields of pixels between adjacent frames. If the predicted displacement field is 'simple', e.g., sparse, it can be efficiently compressed. Since certain aspects in a video can not easily be predicted, the (typically sparse) residual is separately compressed using image compression models (classical or neural).
Recently proposed neural video codecs differ in design choices of the predictive model (e.g., stochastic vs deterministic) and the residual compression scheme (e.g., compression in latent space vs. pixel space). Another fundamental design choice is to either consider the low-latency setup in which a video has to be encoded and decoded on a frame-by-frame level, or the offline setup, in which case the video is encoded as a whole (using knowledge of future frames). For example, the offline setup may be adequate for video streaming services, while the online setup may be more suitable for video conferencing. Another line of research investigates hybridizing classical and neural codecs~\cite{ma2019image}.
One of the earliest approaches to joint prediction and residual compression based on convolutional architectures was \cite{chen2017deepcoder}, which still used a traditional block-based motion estimation approach. For offline compression, \cite{wu2018video}\cite{djelouah2019neural} formulated the video compression problem as a frame interpolation problem. Here, a subset of "key frames" are compressed as images, and the intermediate frames reconstructed based on video interpolation techniques.
Most neural compression approaches currently focus on the low-latency (online) setup \cite{han2019deep}\cite{lu2019dvc}\cite{agustsson2020scale}\cite{golinski2020feedback}\cite{yang2020learning}\cite{lu2020end}. These approaches can be interpreted as generative models for frame sequences. Han et al. \cite{han2019deep} and Habibian et al. \cite{habibian2019video} first adapted the neural image compression framework of Ball{\'e} et al. \cite{balle2017end} to video data, framing it in a variational inference context. While Han et al. \cite{han2019deep} proposed to encode the frame sequence using the predictive next-frame distribution of a stochastic recurrent neural network (eliminating the need to separately compress residuals) and adding a global latent variable that played a similar role as a key frame in traditional compression, Haibibian et al. \cite{habibian2019video} used 3D convolutions and explored structured priors such as PixelCNNs \cite{vandenoord2016pixelcnn} for lower bit-rates at the expense of increased runtime.
In subsequent work, the separation of motion estimation and residual compression dominated and led to improvements over classical video codecs such as HEVC. Lu et al.
\cite{lu2019dvc} adopted a hybrid architecture that combined a pre-trained Flownet \cite{dosovitskiy2015flownet} and residual compression. Rippel et al. \cite{rippel2019learned} proposed a motion estimation approach with long-term memory and adaptive rate control.
Another noteworthy innovation are scale-space flows. Agustsson et al. \cite{agustsson2020scale} used learned optical flows and warping to predict the next frame in sequence, however, it does so by adding a "scale" dimension to the optical flow field. This dimension allows the model to adaptively blur the source based on how well the next frame is predicted.
A general framework for low-latency video compression was recently introduced by Yang et al. \cite{yang2020hierarchical}. The paper also showed that the frame reconstruction for models such as \cite{agustsson2020scale} could be improved by introducing a scale parameter that mediates between the autoregressive prediction and the compressed residual (in a similar way as how RealNVP improves over NICE \cite{dinh2014nice, dinh2016density}), as well as by using non-factorized priors.
\section{Discussion and open problems}\label{sec:conclusion}
Neural compression is a rapidly growing field making significant strides in both lossless and lossy compression. While neural approaches to image compression barely beat JPEG 2000 in 2016 \cite{theis2017cae} \cite{balle2017end}, they already outperformed the best known handcrafted codecs in 2018 \cite{zhou2018tucodec}. And in the \textit{Challenge on Learned Image Compression} of 2021, classical codecs did not even make it into the top 10. Similarly, the leading codec in the \textit{Large Text Compression Benchmark} relied solely on neural networks to predict text \cite{bellard2019nncp}.
Nevertheless, many practical and theoretical challenges remain. Chief among them is the issue of computational complexity. While neural networks offer remarkable compression performance, they demand significantly higher computation than traditional codecs.
Research into more efficient neural architecture and coding schemes will be crucial for the wider deployment of neural compression.
Many open questions also remain in the design of loss functions in lossy compression. For example, it is poorly understood to which extent divergences and adversarial approaches are needed for realism, or whether realism could also be achieved through well crafted distortions and no-reference metrics. Adversarial losses also continue to pose challenges for tuning and optimization and no loss has yet emerged which can be trusted to reliably judge the perceptual quality of reconstructions in training and evaluation.
The use of quantization continues to cause a mismatch between training and test time performance, and how much this affects compression performance is still not clearly understood. Reverse channel coding is a promising alternative which eliminates the need for quantization,
but has only recently been considered in neural compression \cite{theis2021algorithms}.
Open questions include the design of efficient coding schemes and the impact these schemes have on performance when compared to approaches based on quantization.
Finally, all the above issues come to the fore when we apply neural compression to more complex data such as video, VR content, or even non-Euclidean data. Besides making it computationally feasible, effectively compressing such data likely also requires advances in generative modeling, as well as in the design of new distortion or other loss functions.
\section*{Acknowledgment}
We thank Karen Ullrich, Yingzhen Li, Thanasi Bakis, and David Minnen for valuable feedback that helped improve the manuscript.
YY acknowledges support from the Hasso Plattner Institute at UCI. SM acknowledges funding from DARPA (HR001120C0021), DOE (DE-SC0022331), NSF (grants 2047418, 1928718, 2003237, 2007719), Intel, Disney, and Qualcomm.
\bibliographystyle{IEEEtran}
|
{'timestamp': '2022-02-15T02:38:12', 'yymm': '2202', 'arxiv_id': '2202.06533', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06533'}
|
arxiv
|
\section{Introduction}\label{se1}
Software proliferation has induced the development of massively communicating systems with increasing growth in size and complexity.
Well-founded design of such systems can be achieved by component-based techniques, which allow the separation of concerns between computation and coordination \cite{Bl:Al,Br:St,Si:Ri}.
Component-based systems are constructed by multiple individual components which interact according to a software architecture, that
specifies the topology of the components and their interaction patterns \cite{Al:Fo,Be:On,Ma:Co,Si:Ri}. Software architectures place significant importance on the
interactions of the components, captured by the concept of the so called software connectors.
Connectors
regulate the coordination among the components of a system, and hence address all those aspects that lie outside the
role of the components \cite{Br:Ba,Ro:Fo}. Connectors are distinguished in two main categories, namely the stateless and stateful connectors \cite{Br:Ba}. A connector
is called stateless when the interaction constraints that it imposes over the ports
stay the same at each round, and it is called stateful otherwise, i.e., when it supports dynamic interactions.
Applications of connectors occur in cloud and grid computing technologies with several functionalities
including shared variable accesses, buffers, networking protocols, pipes etc. Rigorous formalization of connectors has been proved
crucial for the efficient modeling and analysis of coordinated software systems \cite{Br:Ba,Su:Re}.
Connectors have been studied extensively in systems modeling with alternative frameworks and expressiveness, including
process algebras \cite{Be:On,Br:Ba} and category theory \cite{Br:St,Br:Ba}, while they have been also supported by several architectural description languages (ADLs for short) \cite{Oz:Ar,Sa:Us,Su:Re}.
In this paper, we propose an algebraic formalization of the quantitative aspects of connectors in architectures.
Well-founded design of systems and their communication should incorporate
not only the required qualitative properties but also the related non-functional aspects
(cf. \cite{Dr:Ha,Sa:Us,Si:Ri,Su:Re}). Such features include timing constraints, available
resources, energy consumption, probabilities, etc., for implementing the interactions
among the systems’ components. Existing frameworks have focused mainly on the qualitative setup, while some work on the
probabilistic behavior of connectors can be found in \cite{Sa:Us,Su:Re}. Hence, the novelty of our paper lies in the study of a generic algebraic formal framework for weighted connectors,
that has not been addressed in most of the existing work. A detailed comparison of our contribution with related work can be found in Section \ref{rel}.
Our work extends the results of \cite{Bl:Al} for stateless connectors in the weighted setting. Hence, the
characterization of components' communication through connectors is expressed without incorporating the behavior of connectors. Moreover, our framework does not require knowledge on the underlying behavior of a component-based
system, while the only necessary information lies on the interface, i.e., on the ports of the components and the associated weights. Still we provide a generic description
of a weighted component-based system in order to formalize the
corresponding connectors. Specifically, we model the components of a system with weighted labelled transition systems,
where the weights are values taken from a commutative and idempotent semiring $K$. Communication of components is performed by their set of labels,
called ports, associated with a weight representing the `cost' of its participation
in an interaction. In turn, we propose and study two algebras that encode the weight of the interactions and of connectors in a weighted component-based system.
Specifically, the contributions of the current paper are the following:
(i) We introduce the \emph{weighted Algebra of Interactions over $P$ and $K$} ($wAI(P)$ for short),
where $P$ is the set of all ports in the system. The syntax of the algebra is built over $P$, two distinct
elements namely ``$0$'' and ``$1$'', and allows two operators, namely the weighted union operator ``$\oplus$''
and the weighted synchronization operator ``$\otimes$''. We refer to the elements of the algebra by $wAI(P)$ components,
denoted by $z$, and given a set of interactions we interpret the semantics of $z\in wAI(P)$ as polynomials over $P$ and $K$. We
denote by ``$\equiv$'' the equivalence relation of two $wAI(P)$ components, i.e., components that return the same weight on the same set of interactions over $P$. We define the quotient set $wAI(P)/\equiv$ of ``$\equiv$'' on $wAI(P)$ and for every $z\in wAI(P)$ we denote its equivalent class by $\overline{z}$. Then we show that the structure $(wAI(P)/\equiv,\oplus, \otimes,\bar{0},\bar{1})$ is a commutative and idempotent semiring with the binary operations $\oplus$ and $\otimes$ and constant elements $\bar{0} $ and $\bar{1} $, i.e., the equivalent classes of $0$ and $1$, respectively. In turn, we need this result for several computations occuring in the properties and proofs related to the semantics of our weighted connectors. Moreover, we apply $wAI(P)$ in order to describe several coordination schemes in the weighted setup, and specifically, weighted Rendezvous, Broadcast, Atomic Broadcast and
Causality Chain \cite{Bl:Al}.
(ii) We introduce the \emph{weighted Algebra of Connectors over a set of ports $P$ and $K$} ($wAC(P)$ for short) which extends $wAI(P)$ with two unary typing operators,
\emph{triggers} that can initiate an interaction and \emph{synchrons} which need synchronization with other ports in order to interact. The syntax of $wAC(P)$ allows two unary typing operators,
trigger ``$\left[\cdot\right]'$'' and synchron ``$\left[\cdot\right]$'', and two binary operators ``$\oplus$'' and ``$\otimes$'', called weighted union and weighted
fusion, respectively. Weighted union has the same meaning as in $wAI(P)$, while weighted fusion is a generalization of the weighted synchronization in $wAI(P)$.
We express the semantics of $wAC(P)$ connectors as $wAI(P)$ components and then applying the semantics of $wAI(P)$
we derive the weight of the connectors over a concrete set of interactions in $P$. We obtain several nice properties for $wAC(P)$ and show the expressiveness of $wAC(P)$
by encoding the weight for the connectors of the coordination schemes Rendezvous, Broadcast, Atomic Broadcast
and Causality Chain. Also, we consider two subalgebras of $wAC(P)$, the weighted Algebra of Synchrons $wAS(P)$ and of Triggers $wAT(P)$ over $P$ and $K$,
where the former restricts to synchron elements and the latter to trigger elements, and study their properties.
(iii) We show that due to the weighted fusion operator,
equivalent $wAC(P)$ connectors, i.e., connectors with the same $wAI(P)$ components, are not in general interchangeable in a component-based system. For this, we introduce a notion of weighted congruence relation for connectors
and we derive two theorems that provide conditions for proving congruence of distinct $wAC(P)$ connectors. Our first result
shows that similarly typed equivalent $wAC(P)$ connectors are weighted congruent. Our next theorem shows
that weighted congruence relation between two $wAC(P)$ connectors is ensured when the following three conditions hold:
(i) they are equivalent, (ii) the equivalence is preserved under the weighted fusion with the trigger $[1]'$, and (iii) both the connectors either contain only synchrons or some triggers.
Having methods for proving congruence relation for connectors is important for the modeling process of component-based systems \cite{Be:On,Bl:Al,Br:Ba,Sp:Co},
since it allows the replacement of connectors whenever this is necessary, without affecting the systems' interaction patterns.
\section{Related work}\label{rel}
The concept of connectors has been extensively studied in software engineering by versatile formal frameworks and architectural modeling languages.
Most of the existing work addresses the qualitative aspects of connectors, while there is a few work investigating the quantitative setting.\hide{According to our best knowledge there is lack of a formal framework that models connectors in the weighted setup in general.} In the present
paper, we propose an algebraic formalization of the interactions and (stateless) connectors for weighted component-based systems over a commutative and idempotent semiring. In the sequel, we discuss some of the modeling theories and languages on connectors that are comparable with our methodology.
The work presented below differs with our framework in at least one of the following aspects: (i) they deal with stateful connectors and dynamic interactions,
(ii) the modeling process incorporates both the behavior of components and connectors, and (iii) they do not address the quantitative features of connectors, which is the main
novelty of the current paper.
Representative work in the algebraic formalization of connectors includes process algebras, contracts, and category theory.
Process algebras are algebraic languages which support the compositional description of concurrent and distributed systems whose basic elements are its actions.
In \cite{Be:On} the authors formalized architectural types by a process algebra based on an architectural description language that supported dynamic interactions.
Architectural types were described by components types and stateful connectors. Connectors were defined by a function of their behavior, specified as a family of process algebra terms,
and their interactions, specified as a set of process algebra actions. The process algebra was build over a set of actions and contained a hiding, a relabelling,
a composition and parallel composition operator, while the semantics was given by state transition graphs.
A technique for verifying architectural compatibility and conformity by a weak bisimulation equivalence technique
was also presented.
In \cite{Pa:Co} contracts were used to model components and connectors in UML language. Specifically,
p-calculus was combined with first-order modal reasoning in order to model connectors. The extended calculus was
interpreted in state-based algebraic structures (called objects) and
captured dynamic interactions. Reasoning and refinement was also studied for component composition.
In \cite{Ro:Fo} the authors proposed an architectural metamodel for describing stateful connectors focusing on the communication styles of
message passing and remote procedure call mechanisms, which are common in distributed systems. The semantics of the styles were expressed by finite state machine models.
Then, Alloy was chosen for formalizing those communication styles and verifying conformance of the communication style at the
model level.
In contrast to \cite{Be:On,Pa:Co,Ro:Fo}, our framework studies stateless connectors, and hence does not deal with dynamic interactions.
On the other hand, our algebra models the quantitative aspects of connectors that were not addressed in \cite{Be:On,Pa:Co,Ro:Fo}.
Moreover, in \cite{Be:On,Pa:Co,Ro:Fo}
components and connectors were defined by their actions and their underlying behavior. On the contrary, in our setting
the algebraic formalization in the weighted setup is achieved without considering the behavior of connectors. The investigation of dynamic interactions and stateful connectors can be part of future work.
In the work of \cite{Br:St} the authors developed an algebra for stateless connectors based on category theory.
Their algebra supported symmetry, synchronization, mutual exclusion, hiding and inaction connectors. The authors provided
the operational, observational, and denotational semantics of connectors, and then
showed that the latter two coincide. Finally, a complete normal-form axiomatization was presented for the algebra and the proposed framework
was applied for modeling architectural and coordination connectors in CommUnity and Reo languages, respectively.
In contrast to our weighted algebra, the work of \cite{Br:St} studied the qualitative modeling of connectors.
Also, our algebras encode sufficiently the weight of independent and synchronised actions, though do not involve hiding connectors. On the other hand, in the work of \cite{Br:St} connectors were specified as entities with behavior and interactions.
Extending our weighted framework for incorporating the behavior of components and connectors is part of future work.
In \cite{Sp:Co} the authors introduced connector wrappers in order to repair or augment communication-related properties of a system.
A wrapper was defined as a new code interposed between component interfaces and infrastructure support. The intent of the code was
to modify the behavior of the component with respect to the other components in the system, without actually modifying
the component or the system's infrastructure. Having applied a wrapper to a faulty connector, the authors studied
whether the result was sound and if the wrapper was transparent to the caller role without changing the interface.
The goal of wrappers was to avoid directly modifying the components in a system. In our approach,
we introduce a weighted congruence relation among connectors and provide conditions that allow checking congruence
between two distinct weighted connectors. In contrast to \cite{Sp:Co}, this allows one to interchange directly
a weighted connector with a more efficient one, without affecting the communication patterns of the underlying system.
We point the reader to \cite{Br:Ba} for a nice survey on some well-known theories of connectors. In that paper the authors studied the formal approaches of Reo, BIP, nets with boundaries, the algebra of stateless connectors, the tile model, and wire calculus, for the modeling, composing and analysing connectors. The authors
presented a comparison framework for those methodologies and discussed possible enhancements. In comparison to our work, the presented theories studied connectors
in the qualitative setting.
Apart from the algebraic methods, the modeling of connectors has been supported by several architectural description languages.
In the recent work of \cite{Oz:Ar} can be found an extensive survey on several architectural description languages that support
the modeling of several types of connectors. Among them, a well-known example is Reo, a channel-based coordination model,
that served as a language for coordination of concurrent processes or for compositional construction of connectors among component-based systems \cite{Sil:Reo,Ar:Re}.
In \cite{Sil:Reo,Ar:Re}, components performed input/output operations through connectors that do not have knowledge on the components' behavior.
Coordination of components was achieved through channels, which were
considered as atomic connectors in Reo. Channels were used to transfer data and there were assumed two types of channel ends: sources and sinks.
Complex connectors were compositionally built out of simpler
ones. Hence, a connector was a set of channel ends and their connecting channels organized in a graph.
The topology of connectors in \cite{Sil:Reo,Ar:Re} was inherently dynamic and it allowed mobility in components connections. Plenty of work has also investigated Reo connectors with probabilistic behavior (cf. \cite{Sa:Us,Su:Re}). In \cite{Su:Re}, the authors studied Reo connectors with probabilistic behavior as
timed data distribution streams implemented in Coq. Moreover, in \cite{Sa:Us} the authors formalized Reo connectors with random and probabilistic behavior in PVS.
Reo treats input and output ports separately, while in our setting the components coordinate through bidirectional ports. Moreover,
in the current work we introduce a generic modeling framework in the quantitative setting.
In \cite{Bl:Al} the authors introduced the Algebra of Interactions over a set of ports $P$ ($AI(P)$ for short) for modeling the interactions of components. The syntax of the algebra was build over the set of ports $P$, two special symbols encoding empty interaction and the set of empty interactions, a union operator and a synchronization operator.
In turn, for their second algebra, the Algebra of Connectors ($AC(P)$ for short), each port was characterized by a type
of synchronization, called trigger when initiating an interaction and synchron when
synchronizing with other ports in order to interact.
The authors considered also two subalgebras, where
all of the connectors had the same type (synchron or trigger), and discussed the relation of the presented algebras. In turn, they introduced and studied congruence relation for connectors, expressed as the biggest equivalence relation that
allowed using connectors interchangeably. Finally, the authors presented applications
of their algebras for improving the language and the execution engine of BIP framework.
We also point the reader to \cite{Si:De} and \cite{Si:Mo} for related methodologies on the characterization of connectors.
Our paper is closely related to the work \cite{Bl:Al}, and in particular extends the presented results in the weighted setup. An important difference is that in \cite{Bl:Al} there was a clear distinction between syntactic equality and semantic equivalence. Moreover, most of the presented results
were proved by syntactic equality and in particular by considering several axioms corresponding to important properties for the algebras.
On the contrary, in the weighted framework in general, it is the case that we cannot state results by syntactic equality. For this, in our framework we explain
that the notion of equivalence for the $wAI(P)$ components and $wAC(P)$ connectors
induces an equivalence relation, respectively. In turn, we can obtain the
equivalent classes for each of the two weighted algebras $wAI(P)$ and $wAC(P)$. Then, we
formalize the required properties in the algebras by equalities and we prove or disprove
them using the respective equivalent classes.
\section{Preliminaries}\label{se2}
For every natural number $n \geq 1$ we denote by $[n]$ the set $\{1, \ldots, n \}$. Hence, in the sequel, whenever we use the notation $[n]$ we always assume that $n \geq 1$.
\subsection{Semiring and series}
Next we recall the basic notions and notations on semirings and series \cite{Sa:Ra}.
A monoid $(K,\oplus, \hat{0})$ is a non-empty set $K$ which is equipped with an associative operation $\oplus$
and a neutral element $\hat{0}$ such that $\hat{0}\oplus k = k\oplus \hat{0} = k$ for every $k \in K$. A monoid is called commutative
if $\oplus$ is commutative.
\par A semiring $(K,\oplus,\otimes,\hat{0},\hat{1})$ is a set $K$ together with two binary operations $\oplus$ and $\otimes$ and two constant elements $\hat{0}$ and $\hat{1}$ in $K$, such that:
\begin{enumerate}[label=(\roman*)]
\item $(K,\oplus,\hat{0})$ is a commutative monoid,
\item $(K,\otimes,\hat{1})$ is a monoid,
\item $\otimes$ distributes over $\oplus$, i.e., $(k_{1} \oplus k_{2})\otimes k_{3} = (k_{1} \otimes k_{3}) \oplus (k_{2} \otimes k_{3})$ and $k_{1} \otimes(k_{2} \oplus k_{3}) = (k_{1} \otimes k_{2}) \oplus (k_{1} \otimes k_{3})$ for every $k_{1}, k_{2}, k_{3} \in K$, and
\item $\hat{0} \otimes k = k \otimes \hat{0} = \hat{0}$ for every $k \in K.$
\end{enumerate}
\par A semiring $K$ is called commutative if $(K,\otimes,\hat{1})$ is commutative. The semiring is denoted simply by $K$ if the
operations and the constant elements are understood.\hide{The result of the empty
product as usual equals to $1$.} Further, $K$ is called (additively) idempotent if $(K,\oplus,\hat{0})$ is an idempotent monoid, i.e., $k\oplus k=k$ for every $k\in K$. By the distributivity law, this holds iff $\hat{1} \oplus \hat{1} = \hat{1}$. Next, we call an additively idempotent semiring simply an idempotent semiring. The following algebraic structures are well-known semirings:
\begin{itemize}
\item the semiring $(\mathbb{N},+,\cdot,0,1)$ of natural numbers,
\item the Boolean semiring $B=(\left\lbrace 0,1 \right\rbrace,+,\cdot,0,1 )$,
\item the tropical or $\mathrm{min}$-plus semiring $\mathbb{R}_{\mathrm{min}}=(\mathbb{R}_{+}\cup \left\lbrace \infty \right\rbrace,\mathrm{min},+,\infty,0 )$ where $\mathbb{R}_{+}=\left\lbrace r\in \mathbb{R}\mid r\geqslant 0 \right\rbrace $,
\item the arctical or $\mathrm{max}$-plus semiring $\mathbb{R}_{\mathrm{max}}=(\mathbb{R}_{+}\cup \left\lbrace -\infty \right\rbrace,\mathrm{max},+,-\infty,0 )$,
\item the semiring $(\mathcal{P}(A),\cup, \cap, \emptyset, A)$ for every non-empty set $A$,
\item the Viterbi semiring $(\left[ 0,1 \right],\mathrm{max},\cdot,0,1 )$ used in probability theory, and
\item the fuzzy semiring $F=(\left[ 0,1\right] , \mathrm{max}, \mathrm{min}, 0, 1)$, and in general every bounded distributive lattice with the operations sup and inf.
\end{itemize}
All the above semirings are commutative, and all but the
first one are idempotent.
\hide{\par If the operations and the constant elements of $K$ are understood, then we
denote the semiring simply by $K$.}
\par \hide{Now we recall the basic notions for series and their related operations \cite{Sa:Ra}.}Let $K$ be a semiring and $P$ be a non-empty set. A formal series (or simply series) over $P$ and $K$ is a mapping $s: P\to K$. The support of $s$ is the set $\mathrm{supp}(s)=\left\lbrace p\in P\mid s(p)\neq \hat{0} \right\rbrace $. A series with finite support is called a polynomial. We denote by $K\left\langle P\right\rangle $ the class of all polynomials over $P$ and $K$. Let $s, r\in K\left\langle P\right\rangle $ and $k \in K$. The sum $s \oplus r$, the product with scalars $ks$ and $sk$, and the Hadamard product $s\otimes r$ are polynomials in $K\left\langle P\right\rangle $ and defined elementwise, by $s\oplus r(p)=s(p)\oplus r(p), ks(p)=k\otimes s(p), sk(p)=s(p)\otimes k$ and $s\otimes r(p)=s(p)\otimes r(p)$ for every $p\in P$, respectively.
\hide{
\subsection{Orders}
Let $K$ and $K'$ be two sets. Every subset $R\subseteq K \times K'$ is called \textit{relation} from $K$ to $K'$. If $R\subseteq K\times K$, then $R$ is simply called a relation on $K$ and for every $(k,k')\in R$ we write by $kRk'$. \\ \\
\noindent A relation $R$ on $K$ is called
\begin{itemize}
\renewcommand\labelitemi{--}
\item reflexive, if $kRk$ for every $k\in K$,
\item symmetric, if $kRk' \Rightarrow k'Rk$ for every $k,k' \in K$,
\item antisymmetric, if $kRk'$ and $k'Rk \Rightarrow k=k'$ for every $k,k' \in K$,
\item transitive, if $kRk'$ and $k'Rk'' \Rightarrow kRk''$ for every $k,k',k'' \in K.$
\end{itemize}
\begin{defin}
A relation on $K$ is called an equivalence relation if it is reflexive, symmetric and transitive.
\end{defin}
Whenever $R$ is an equivalence relation on $K$ we write $k\equiv k'(R)$ for every $k,k'$ such that $kRK'$.
\par For every $k\in K$, an \textit{equivalence class} of $K$ in $R$, denoted by $\left[ k\right] _{R}$, is the set of all elements of $K$ that are equivalent with $k$, i.e.,
$$\left[ k\right] _{R}=\left\lbrace k' \in K\mid k \equiv k'(R)\right\rbrace .$$
The element $k$ is called representative of the class $\left[ k\right] _{R}$. It is well known that every element of a particular class can be considered as a representative element of the class.\\ \\
\noindent The set of all equivalence classes of $K$ is called the \textit{quotient set} and is denoted by $K/R$, i.e.,
$$K/R=\left\lbrace \left[ k\right] _{R}\mid k\in K\right\rbrace .$$
The equivalence class $\left[ k\right] _{R}$ is simply denoted by $\overline{k}$, when the relation $R$ is understood. \\
\par Next we recall some well-known results on equivalence classes.
\begin{prop}\label{classes}
Let $R$ be an equivalence relation on the set $K$. For every $k,k'\in K$ it holds that
$$k \equiv k'(R) \ \ \ \text{iff} \ \ \ \overline{k}=\overline{k'}.$$
\end{prop}
\hide{\begin{prof*}
Suppose that $k\equiv k'(R)$, and let $k''\in \overline{k}$. By the latter it holds that $k \equiv k''(R)$, hence $k''\equiv k'(R)$, which in turn implies that $k'' \in \overline{k'}$. Thus, we obtain that $\overline{k} \subseteq \overline{k'}$. The inclusion $\overline{k'} \subseteq \overline{k}$ is proved similarly and we conclude that $\overline{k} = \overline{k'}$.
\par On the other hand, let $\overline{k} =\overline{k'}$. Since $k' \in \overline{k'}$, we have that $k'\in \overline{k}$. Therefore, $k \equiv k'(R)$ and our proof is completed. \qed
\end{prof*}}
\begin{prop}
If $R$ is an equivalence relation on the set $K$, then $K/R$ is a partition on $K$. Inversely, every partition on $K$ is derived from an equivalence relation on $K$.
\end{prop}
\hide{\begin{prof*}
We prove first the left-to-right implication. Let $R$ be an equivalence relation on $K$. By the definition of the quotient set $K/R$ it holds that $\overline{k} \subseteq K$ for every $k \in K$, and hence $\cup_{k\in K} \overline{k}\subseteq K$. Also, let $k\in K$. Every element of $K$ belongs to its equivalence class, i.e., $k\in \overline{k}$, and thus, $k \in \cup_{k\in K} \overline{k}$. Consequently, $K \subseteq \cup_{k\in K} \overline{k}$ which implies that $\cup_{k\in K} \overline{k}=K$. Furthermore, for every $\overline{k}, \overline{k'} \in K/R$ it holds that $\overline{k}= \overline{k'}$ or $\overline{k}\cap \overline{k'}=\emptyset.$
Indeed, assume that $\overline{k}\cap \overline{k'}\neq\emptyset$ and let $k''\in \overline{k}\cap \overline{k'}$. The latter implies that $k''\in \overline{k}$ and $k''\in \overline{k'}$, i.e., $k \equiv k''(R)$ and $k'\equiv k''(R)$. Therefore, $k\equiv k'(R)$ since $R$ is an equivalence relation on $K$. By a direct application of Lemma \ref{classes} we obtain that $\overline{k}=\overline{k'}$. Moreover, it is obvious that every element $\overline{k}$ of $K/R$ is not the empty set since it contains at least $k$. For this, the elements of $K/R$ constitute a partition of $K$.
\par Now we prove the right-to-left implication. Let $(K_{i})_{i\in I}$ be a partition of the set $K$. We define the relation $R$ on $K$ as follows:
$$(k, k')\in R \ \text{iff} \ k,k' \in K_{i} \ \text{for some} \ i\in I.$$
We prove that $R$ is an equivalence relation. Trivially, by definition $R$ is reflexive and symmetric. We show that $R$ is transitive. Let $(k,k')\in R$ and $(k',k'') \in R$. There exist $i,j\in I$ such that $k,k' \in K_{i}$ and $k',k''\in K_{j}$. Then, $k'\in K_{i}\cap K_{j}$, which means that $K_{i}\cap K_{j}\neq \emptyset$. Since $(K_{i})_{i\in I}$ is a partition of $K$ we obtain that $K_{i}=K_{j}$. Therefore, $k, k'' \in K_{i}$ and we get that $(k, k'')\in R$, i.e., $R$ is also transitive, and hence $R$ is an equivalence relation on $K$. We now prove that the equivalence classes of $R$ coincide with the sets of partition $(K_{i})_{i \in I}$. Indeed, let $k$ be an element of $K$ and $i \in I$ such that $k \in K_{i}$. We consider an element $k' \in \overline{k}$. Then, $k\equiv k'(R)$ and consequently $k'\in K_{i}$ which implies that $\overline{k}\subseteq K_{i}$. Inversely, if $k' \in K_{i}$ we obtain that $k\equiv k'(R)$, i.e., $k' \in \overline{k}$, and hence, $K_{i}\subseteq \overline{k}$. Therefore, we conclude that $\overline{k}=K_{i}$ and our proof is completed. \qed
\end{prof*}}
\hide{
\noindent Now we recall the notions of infimum and supremum in a partially ordered set $K$.
\begin{defin}
A partially ordered set is a pair $(K,\leqslant)$ where $K$ is a set and $\leqslant$ is partial order on $K$, i.e., $\leqslant$ is reflexive, antisymmetric, and transitive.
\end{defin}
\begin{defin}
Let $(K,\leqslant)$ be a partially ordered set and $k_{1},k_{2}\in K$. Then an element $k\in K$ is called the supremum of $k_{1}$ and $k_{2}$ if
\begin{itemize}
\renewcommand\labelitemi{--}
\item $k_{1}\leqslant k$ and $k_{2}\leqslant k$, and
\item for every $k' \in K$, if $k_{1}\leqslant k'$ and $k_{2}\leqslant k'$, then $k\leqslant k'$.
\end{itemize}
If the supremum of $k_1$ and $k_{2}$ exists, then it is denoted by $k_{1}\vee k_{2}$.
\end{defin}
\begin{defin}
Let $(K,\leqslant)$ be a partially ordered set and $k_{1},k_{2}\in K$. Then an element $k\in K$ is called the infimum of $k_{1}$ and $k_{2}$ if
\begin{itemize}
\renewcommand\labelitemi{--}
\item $k\leqslant k_{1}$ and $k\leqslant k_{2}$, and
\item for every $k' \in K$, if $k'\leqslant k_{1}$ and $k'\leqslant k_{2}$, then $k'\leqslant k$.
\end{itemize}
If the infimum of $k_{1}$ and $k_{2}$ exists, then it is denoted by $k_{1}\wedge k_{2}$.
\end{defin}
Finally we recall the notions of total and natural order (cf. Chapter 1 from \cite{Dr:Ha}), which we need in our weighted framework.
\begin{defin}
A partially ordered set $(K, \leqslant)$ is called totally ordered if $\leqslant$ is a total order, i.e., $k\leqslant k'$ or $k'\leqslant k$ for every $k, k'\in K$.
\end{defin}
\begin{defin}
A commutative monoid $(K,\oplus,\hat{0})$ is called naturally ordered if for every $k,k''\in K$ the relation $k \leqslant k''$ defined by $k\oplus k'=k''$ where $k'\in K$, is a partial order.
\end{defin}
Observe that when a commutative monoid $(K,\oplus, \hat{0})$ is idempotent, then $(K,\leqslant)$ is a naturally ordered set, and for $k,k'\in K$ we have $k\leqslant k'$ iff $k\oplus k'= k'$. Hence, a commutative and idempotent semiring is naturally ordered. However, the natural order is not always a total order. Consider, for instance, the commutative and idempotent semiring $(\mathcal{P}(A),\cup, \cap, \emptyset, A)$ for every non-empty set $A$, equipped with the order of subsets ``$\subseteq$''. For the sets $A_{1}, A_{2}$ it holds $A_{1}\subseteq A_{2}$ iff $A_{1}\cup A_{2}=A_{2}$. The latter implies that the semiring is naturally ordered. Though, the semiring is not totally ordered, since two arbitrary sets of $\mathcal{P}(A)$ are not necessarily ordered by ``$\subseteq$''.
}
}
\begin{quote}
\noindent \textit{Throughout the paper, $(K,\oplus,\otimes,\hat{0},\hat{1})$ denotes a commutative and idempotent semiring.}
\end{quote}
\subsection{Component-based systems}\label{se3}
In this subsection we present how we model the components of a system in the weighted setting. For this, we use the basic notions and definitions of BIP for the qualitative framework \cite{Bl:Al,Si:Ri}. However, we focus only on the communication patterns of components building a
component-based system. A system in BIP can be described by a labelled transition system. Communication among components is achieved through their
corresponding interfaces. For a labelled transition system, its interface is the associated set of labels, called ports. Then, communication of components is defined by interactions, i.e., non-empty sets of ports.
\begin{defin}
Let $P$ be a finite non-empty set of ports. Then, an interaction $a$ is a non-empty set of ports over $P$, i.e., $a\in 2^{P}\setminus \left\lbrace \emptyset\right\rbrace $.
\end{defin}
\noindent Let $a=\left\lbrace p_1,\ldots ,p_n\right\rbrace \subseteq P$. We often simplify the notation of $\textit{a}$ by writing $p_1 \ldots p_n$ instead of the set $\left\lbrace p_1, \ldots ,p_n\right\rbrace $. Also, we let $I(P)=2^{P}\setminus \left\lbrace \emptyset\right\rbrace $ denote the set of interactions over $P$ and we set $\Gamma(P)=2^{2^{P}}$.
\begin{defin}\label{lts}
A labelled transition system (LTS for short) is a triple $B=(Q,P,R)$, where $Q$ is a finite set of states, $P$ is a finite set of ports, and $R\subseteq Q\times I(P) \times Q$ is a set of transitions, each labelled by an interaction.
\end{defin}
An \emph{atomic component} is an LTS $B$. In the sequel, we call an atomic component $B$ simply a \emph{component}, whenever we deal with several atomic components. For every set $\mathcal{B} = \{B_{i} \mid i \in [n] \} $ of components, with $B_{i}=(Q_{i},P_{i},R_{i})$, for $i \in [n]$, which we consider in the paper, we assume that $\left( Q_{i}\cup P_{i}\right)\cap (Q_{j}\cup P_{j})=\emptyset$ whenever $i\neq j$,
for every $i, j\in \left[ n\right] $. We denote by $Q=\bigcup_{i\in [n]} Q_{i}$ and $P=\bigcup_{i\in [n]} P_{i}$ the set of all states and all ports of $\mathcal{B}$, respectively.
\hide{We can now define component-based systems.
\begin{defin}\label{comp-inter}
A component-based system is a pair $(\mathcal{B}, \gamma)$ where $\mathcal{B} = \left\lbrace B_{i} \mid i \in \left[ n \right]\right\rbrace $ is a
set of components, with $B_{i} = (Q_{i}, P_{i}, R_{i})$ for every $i \in \left[ n\right]$, and $\gamma \in 2^{I(P)} \setminus \left\lbrace \emptyset\right\rbrace $.
\end{defin}
\par Recall from \cite{Bl:Al}, that in BIP the empty interaction $a=\emptyset$, and in turn the empty set of interactions $\gamma=\lbrace \emptyset\rbrace$ were not considered in the description of the interactions of a component-based system. However, $a=\emptyset$ and $\gamma=\lbrace \emptyset\rbrace$ do not actually affect the resulting system. On the other hand, they were necessary for constructing the Algebra of Interactions and Connectors. Similarly, in this work we omit $a=\emptyset$ and $\gamma=\lbrace \emptyset\rbrace$ from the interactions of a (weighted) component-based system, while we include them in the weighted algebras presented in the subsequent two sections.
The set $\gamma$ of interactions of a component-based system $(\mathcal{B},\gamma)$ specifies the communication patterns of the components, relating with the architecture of the system. In the BIP framework, the formalization of $\gamma$ has been achieved with alternative means including logics, that specify the overall architecture of the system (cf. for instance \cite{Ma:Co}) or algebras \cite{Bl:Al}.
\hide{
Interactions can be captured by alternative formalisms. In \cite{Bl:Al} the authors proposed an algebraic characterization and for this, they introduced the Algebra of Interactions over the set of ports $P$ ($AI(P)$ for short) of the involved components. In order to define a component-based system we firstly need to recall the syntax and semantics of $AI(P)$.}
In this paper, we are interested in the algebraic study of interactions, and in turn of connectors. Hence, according to the work of \cite{Bl:Al} we can encode the set of the interactions in a system with the Algebra of Interactions. In turn, for the weighted setup we introduce the weighted counterpart of $AI(P)$ in order to encode the weight of the components' interaction. For this, we recall in the sequel the syntax and semantics of $AI(P)$.
\begin{defin} Consider a set of components $\mathcal{B} = \left\lbrace B_{i} \mid i \in \left[n\right]\right\rbrace $ and let $P=\cup_{i\in \left[ n\right]}P_{i}$ be the set of all ports. The syntax of the Algebra of Interactions over $P$ ($AI(P)$ for short), is defined by
$$x::=0 \mid 1 \mid p \mid x\cdot x\mid x+x\mid (x)$$
where $p\in P$, $0,1 \notin P$, ``$+$'' and $``\cdot$'' are binary operators, called union and synchronization, respectively, and synchronization binds stronger than union.
\end{defin}
Next we shall call $x$ an $AI(P)$ component. The semantics of the $AI(P)$ returns for each component its associated set of interactions.
\begin{defin} Let $x\in AI(P)$. The semantics of $AI(P)$ is given by the function $f: AI(P) \to \Gamma(P)$, defined inductively on $x$ as follows:
\begin{itemize}
\renewcommand\labelitemi{--}
\item $f(0)=\emptyset$,
\item $f(1)=\left\lbrace \emptyset\right\rbrace$,
\item $f(p)=\left\lbrace \left\lbrace p\right\rbrace \right\rbrace $,
\item $f(x_{1}+x_{2})=f(x_{1})\cup f(x_{2})$,
\item $f(x_{1}\cdot x_{2})=\left\lbrace a_{1}\cup a_{2}\mid a_{1}\in f(x_{1}), a_{2}\in f(x_{2}) \right\rbrace $,
\item $f\left( (x)\right) =f(x)$,
\end{itemize}
\end{defin}
Terms of $AI(P)$ represent interactions between the ports of $P$. Consider for instance the $AI(P)$ components $(p), p_{1}+p_{2}, p_{1}\cdot p_{2}$ where $p, p_{1}, p_{2}\in P$. The sets of interactions obtained from the above $AI(P)$ components are $\left\lbrace \left\lbrace p\right\rbrace \right\rbrace$, $\lbrace \lbrace p_1\rbrace, \lbrace p_2\rbrace \rbrace$ and $\left\lbrace \left\lbrace p_{1}, p_{2}\right\rbrace \right\rbrace $, respectively.
The Algebra of Interactions allows to consider an updated version of component-based systems where in comparison to the one in Definition \ref{comp-inter}, we replace the set of interactions $\gamma$ by a component $x\in AI(P)$.
\begin{defin}\label{comp-con}
A component-based system is a pair $(\mathcal{B}, x)$ where $\mathcal{B} = \left\lbrace B_{i} \mid i \in \left[ n \right]\right\rbrace $ is a
set of components, with $B_{i} = (Q_{i}, P_{i}, R_{i})$ for every $i \in \left[ n\right]$, and $x$ is a $AI(P)$ component over $P=\bigcup_{i=1}^{n} P_{i}$.
\end{defin}
\textcolor{blue}{Note that in \cite{Bl:Al} the authors described the components and their composed system in the BIP framework using also the notion of priorities, that restrict multiply enabled interactions to the preferred ones. Priorities in \cite{Bl:Al} returned the interactions involving the maximal
number of ports and allowed the expression of Broadcast scheme. In the weighted framework presented here, the preferred interactions are obtained directly from the structure of semirings. Moreover, in the current paper we are not interested in the underlying structure of components and their composition, but we study the modeling of their coordination schemes and of the related connectors. For this, we simply consider a component-based system as set of components with the related interactions.} }
In the weighted setup we describe components by weighted labelled transition systems. For this, we associate with each port a weight from $K$ that corresponds to its participation `cost' in the respective interactions. Let $P$ be a set of ports. For every $p\in P$, we denote with $ct(p)$ the weight of the port defined by the function $ct:P\rightarrow K$.
\begin{defin}
A weighted labelled transition system (wLTS for short) over $K$ is a triple $wB=(B, ct, wt)$, where $B=(Q,P,R)$ is an atomic component, $ct: P \to K$ assigns a weight to each port $p \in P$, and $wt:R\to K$ assigns a weight to each transition defined by $wt((q,a,q'))=\bigotimes_{p\in a}^{}ct(p)$ for every $(q,a, q')\in R$.
\end{defin}
In the sequel, for simplicity, we identify $ct(p)$ with $k_p\in K$ for every port $p\in P$.
\par A \emph{weighted atomic component} is an wLTS $wB$. In the sequel, we call a weighted atomic component $wB$ a \emph{weighted component}, whenever we deal with several weighted atomic components.
\par Let $w\mathcal{B} = \left\lbrace wB_{i} \mid i \in \left[n\right]\right\rbrace $ be a set of weighted components where $wB_{i} = (B_{i}, ct_{i}, wt_{i})$, for $i \in \left[n \right]$. By definition it holds that $\left( Q_{i}\cup P_{i}\right)\cap (Q_{j}\cup P_{j})=\emptyset$ whenever $i\neq j$, for every $i, j\in \left[ n\right] $. The set of states and ports of $w\mathcal{B}$ are the sets $Q=\bigcup_{i\in [n]} Q_{i}$ and $P=\bigcup_{i\in [n]} P_{i}$, respectively, resulting from the corresponding components $B_i$ for $i\in\left[ n\right] $.
In order to encode the weight of the interactions in $w\mathcal{B}$ we introduce a weighted Algebra of Interactions over a set of ports $P$ and a commutative and idempotent semiring $K$, presented in the next section. The proposed algebra is applied for modeling well-known coordination schemes in the weighted setup, and in turn serves as the basis for constructing our second algebra, the weighted Algebra of Connectors, that formalizes of the concept of weighted connectors.
\par In this work we are interested in the coordination patterns of the systems, and specifically on the algebraic characterization of the concept of connectors in the quantitative setting. For this, we develop no theory about the computation of the semantics of weighted component-based systems. Though, it should
be clear that we specify how we model the components of systems in order to formalize the
corresponding interactions and connectors in the weighted setup.
Recall from \cite{Bl:Al}, that the empty interaction $a=\emptyset$, and in turn the empty set of interactions $\gamma=\lbrace \emptyset\rbrace$ were not considered in the description of a component-based system. However, $a=\emptyset$ and $\gamma=\lbrace \emptyset\rbrace$ do not actually affect the resulting system. On the other hand, they were necessary for constructing the Algebra of Interactions and of Connectors. Similarly, in this work we omitted $a=\emptyset$ and $\gamma=\lbrace \emptyset\rbrace$ from a weighted component-based system, while we include them in the weighted algebras studied in the subsequent two sections.
\section{The Weighted Algebra of Interactions}\label{se4}
In this section we introduce and study the weighted Algebra of Interactions over a set of ports and a commutative and idempotent semiring $K$, in order to address the quantitative aspects of the communications among the components of a weighted system. We prove several nice properties for the algebra and we provide concrete examples of coordination schemes in the weighted setup described by our algebra. \hide{In turn, the weighted Algebra of Interactions serves as the basis for constructing the weighted Algebra of Connectors presented in the next section.}
\hide{
We firstly recall the syntax and semantics of the algebra of interactions from \cite{Bl:Al}. \\ \\
\underline{\textbf{Syntax}}: Consider a system of $n$ components $B_{i}=(Q_{i},P_{i},R_{i})$ for $i\in \left[ n\right] $ and let $P=\cup_{i\in \left[ n\right]} P_{i}$ be the set of ports of the system such that $0,1 \notin P$. The syntax of the algebra of interactions over $P$ ($AI(P)$ for short), is defined by
$$x::=0 \mid 1 \mid p \mid x\cdot x\mid x+x\mid (x)$$
where $p\in P$, ``$+$'' and $``\cdot$'' are binary operators, called union and synchronization, respectively, and synchronization binds stronger than union. \\
\par In this paper we shall call $x$ an $AI(P)$ component. The semantics of the $AI(P)$ returns for each component its associated set of interactions. \\ \\
\noindent \underline{\textbf{Semantics}}: The semantics of $AI(P)$ is given by the function $f: AI(P) \to \Gamma(P)$, defined inductively on $x$ as follows:
\begin{itemize}
\renewcommand\labelitemi{--}
\item $f(0)=\emptyset$,
\item $f(1)=\left\lbrace \emptyset\right\rbrace$,
\item $f(p)=\left\lbrace \left\lbrace p\right\rbrace \right\rbrace $,
\item $f(x_{1}+x_{2})=f(x_{1})\cup f(x_{2})$,
\item $f(x_{1}\cdot x_{2})=\left\lbrace a_{1}\cup a_{2}\mid a_{1}\in f(x_{1}), a_{2}\in f(x_{2}) \right\rbrace $,
\item $f\left( (x)\right) =f(x)$,
\end{itemize}
for $x, x_{1}, x_{2} \in AI(P)$. Terms of $AI(P)$ represent interactions between the ports of $P$. Consider for instance the $AI(P)$ components $(p), p_{1}+p_{2}, p_{1}\cdot p_{2}$ where $p, p_{1}, p_{2}\in P$. The sets of interactions obtained from the above $AI(P)$ components are $\left\lbrace \left\lbrace p\right\rbrace \right\rbrace , \left\lbrace \left\lbrace p_{1}\right\rbrace ,\right.$ $\left.\left\lbrace p_{2}\right\rbrace \right\rbrace $ and $\left\lbrace \left\lbrace p_{1}, p_{2}\right\rbrace \right\rbrace $, respectively.
\par Two components $x_{1}, x_{2}\in AI(P)$ are equivalent, denoted by $x_{1}\simeq x_{2}$, iff they return the same set of interactions, i.e., $x_{1}\simeq x_{2} \Leftrightarrow f(x_{1})=f(x_{2})$.\\ \\
We claim that the relation ``$\simeq$'' defined above is an equivalence relation. Indeed
\begin{itemize}
\item ``$\simeq$'' is reflexive: It holds that $f(x)=f(x)$ for every $x \in AI(P)$, i.e., $x\simeq x$.
\item ``$\simeq$'' is symmetric: If $x_{1}\simeq x_{2}$ for $x_{1}, x_{2}\in AI(P)$, then it holds that $f(x_{1})=f(x_{2})$. Hence, we get that $f(x_{2})=f(x_{1})$, thus $x_{1}\simeq x_{2}\Rightarrow x_{2}\simeq x_{1}$.
\item ``$\simeq$'' is transitive: Let $x_{1}\simeq x_{2}$ and $x_{2}\simeq x_{3}$ where $x_{1}, x_{2}, x_{3} \in AI(P)$. These relations imply that $f(x_{1})=f(x_{2})$ and $f(x_{2})=f(x_{3})$, respectively. Therefore, we get that $f(x_{1})=f(x_{3})$, i.e., $x_{1}\simeq x_{2}$ and $x_{2}\simeq x_{3} \Rightarrow x_{1}\simeq x_{3}$.
\end{itemize}
\noindent Consequently, ``$\simeq$'' is an equivalence relation. \\
\par We define the quotient set $AI(P)/\simeq$ of ``$\simeq$'' on $AI(P)$. We simply denote by $\overline{x}$ the equivalence classes of $AI(P)$ for every $x\in AI(P)$. Furthermore, we define on $AI(P)/\simeq$ the operations
\begin{equation*}\label{o1}
\overline{x_{1}}+\overline{x_{2}}=\overline{x_{1}+x_{2}} \tag{$O1$}
\end{equation*}
and
\begin{equation*}\label{o2}
\overline{x_{1}}\cdot \overline{x_{2}}=\overline{x_{1}\cdot x_{2}} \tag{$O2$}
\end{equation*}
for every $x_{1}, x_{2}\in AI(P)$. We will prove that the results of the operations defined above do not rely on the representatives of the classes that we use, but they are only based on the classes, i.e., they are well-defined. For this, we have to prove that when $\overline{x_{1}}=\overline{x_{3}}$ and $\overline{x_{2}}=\overline{x_{4}}$, then $\overline{x_{1}}+\overline{x_{2}}=\overline{x_{3}}+\overline{x_{4}}$. Similarly, for the second operator, we prove that $\overline{x_{1}}\cdot \overline{x_{2}}=\overline{x_{3}}\cdot \overline{x_{4}}$.
\par We have $f(x_{1})=f(x_{3})$ and $f(x_{2})=f(x_{4})$, and thus
\begin{align*}
\overline{x_{1}}+\overline{x_{2}}=\overline{x_{1}+x_{2}}=&\left\lbrace x\in AI(P) \mid x\simeq x_{1}+x_{2}\right\rbrace \\
=& \left\lbrace x\in AI(P) \mid f(x)=f(x_{1}+x_{2})\right\rbrace \\
=& \left\lbrace x\in AI(P) \mid f(x)=f(x_{1})\cup f(x_{2})\right\rbrace \\
=& \left\lbrace x\in AI(P) \mid f(x)=f(x_{3})\cup f(x_{4})\right\rbrace \\
=& \left\lbrace x\in AI(P) \mid f(x)=f(x_{3}+x_{4})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid x\simeq x_{3}+x_{4}\right\rbrace =\overline{x_{3}+x_{4}}=\overline{x_{3}}+\overline{x_{4}}.
\end{align*}
For the second operator ``$\cdot$'' we get that
\begin{align*}
\overline{x_{1}}\cdot \overline{x_{2}}=\overline{x_{1}\cdot x_{2}}=&\left\lbrace x\in AI(P) \mid x\simeq x_{1}\cdot x_{2}\right\rbrace \\
=& \left\lbrace x\in AI(P) \mid f(x)=f(x_{1}\cdot x_{2})\right\rbrace \\
=& \left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{1}\cup a_{2}\mid a_{1}\in f(x_{1}), a_{2}\in f(x_{2}) \right\rbrace\right\rbrace \\
=& \left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{1}\cup a_{2}\mid a_{1}\in f(x_{3}), a_{2}\in f(x_{4}) \right\rbrace\right\rbrace \\
=& \left\lbrace x\in AI(P) \mid f(x)=f(x_{3}\cdot x_{4})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid x\simeq x_{3}\cdot x_{4}\right\rbrace =\overline{x_{3}\cdot x_{4}}=\overline{x_{3}}\cdot \overline{x_{4}}.
\end{align*}
Hence, we have proved that the operations \eqref{o1} and \eqref{o2} are well-defined.\\
\par The next proposition summarizes the basic properties that hold for the algebra of interactions.
\begin{prop}
Let $\overline{x_{1}}, \overline{x_{2}}, \overline{x_{3}}\in AI(P)/\simeq$. Then
\begin{multicols}{2}
\begin{enumerate}[label=\roman*)]
\item $(\overline{x_{1}} + \overline{x_{2}}) + \overline{x_{3}}= \overline{x_{1}} + (\overline{x_{2}} + \overline{x_{3}})$
\item $\overline{x_{1}}+\overline{x_{2}}= \overline{x_{2}} + \overline{x_{1}}$
\item $\overline{x_{1}} + \overline{x_{1}} = \overline{x_{1}}$
\item $\overline{x_{1}} + \overline{0} =\overline{x_{1}}$
\item $(\overline{x_{1}}\cdot \overline{x_{2}})\cdot \overline{x_{3}}= \overline{x_{1}}\cdot (\overline{x_{2}}\cdot \overline{x_{3}})$
\item $\overline{x_{1}}\cdot \overline{x_{2}}= \overline{x_{2}}\cdot \overline{x_{1}}$
\item $\overline{x_{1}}\cdot \overline{1} = \overline{x_{1}}$
\item $\overline{x_{1}}\cdot \overline{0}= \overline{0}$
\item $\overline{x_{1}}\cdot (\overline{x_{2}} + \overline{x_{3}})= (\overline{x_{1}}\cdot \overline{x_{2}}) + (\overline{x_{1}}\cdot \overline{x_{3}})$
\item $(\overline{x_{1}} + \overline{x_{2}}) \cdot \overline{x_{3}}= (\overline{x_{1}}\cdot \overline{x_{3}}) + (\overline{x_{2}}\cdot \overline{x_{3}}).$
\end{enumerate}
\end{multicols}
\end{prop}
\begin{prof*}
We prove the above equalities as follows:
\begin{enumerate}[label=\roman*)]
\item \begin{align*}
(\overline{x_{1}} + \overline{x_{2}}) + \overline{x_{3}}=&(\overline{x_{1}+x_{2}})+\overline{x_{3}}=\overline{(x_{1}+x_{2})}+\overline{x_{3}}=\overline{(x_{1}+x_{2})+x_{3}}\\
=&\left\lbrace x\in AI(P) \mid x \simeq (x_{1} + x_{2}) +x_{3}\right\rbrace \\
=& \left\lbrace x\in AI(P) \mid f(x)=f((x_{1} + x_{2}) +x_{3})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f((x_{1} + x_{2}))\cup f(x_{3})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f(x_{1} + x_{2})\cup f(x_{3})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=(f(x_{1}) \cup f(x_{2}))\cup f(x_{3})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f(x_{1}) \cup (f(x_{2})\cup f(x_{3}))\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f(x_{1}) \cup f(x_{2}+x_{3})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f(x_{1}) \cup f((x_{2}+x_{3}))\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f(x_{1} +(x_{2}+x_{3}))\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid x \simeq x_{1} + (x_{2} +x_{3})\right\rbrace \\
=&\overline{x_{1}+(x_{2}+x_{3})}\\
=&\overline{x_{1}}+\overline{(x_{2}+x_{3})}\\
=&\overline{x_{1}}+(\overline{x_{2}+x_{3}})\\
=&\overline{x_{1}} + (\overline{x_{2}} + \overline{x_{3}}),
\end{align*}
\item
\begin{align*}
\overline{x_{1}} + \overline{x_{2}}=&\overline{x_{1}+x_{2}}\\
=&\left\lbrace x\in AI(P) \mid x \simeq x_{1} + x_{2} \right\rbrace \\
=& \left\lbrace x\in AI(P) \mid f(x)=f(x_{1} + x_{2})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f(x_{1}) \cup f(x_{2})\right\rbrace\\
=&\left\lbrace x\in AI(P) \mid f(x)=f(x_{2}) \cup f(x_{1})\right\rbrace\\
=& \left\lbrace x\in AI(P) \mid f(x)=f(x_{2} + x_{1})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid x \simeq x_{2} + x_{1} \right\rbrace \\
=&\overline{x_{2}+x_{1}}\\
=&\overline{x_{2}}+\overline{x_{1}},
\end{align*}
\item \begin{align*}
\overline{x_{1}} + \overline{x_{1}}=&\overline{x_{1}+x_{1}}\\
=&\left\lbrace x\in AI(P) \mid x \simeq x_{1} + x_{1} \right\rbrace \\
=& \left\lbrace x\in AI(P) \mid f(x)=f(x_{1} + x_{1})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f(x_{1}) \cup f(x_{1})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f(x_{1}) \right\rbrace\\
=& \left\lbrace x\in AI(P) \mid x \simeq x_{1} \right\rbrace\\
=& \overline{x_{1}},
\end{align*}
\item \begin{align*}
\overline{x_{1}} + \overline{0}=&\overline{x_{1}+0}=\left\lbrace x\in AI(P) \mid x \simeq x_{1} + 0 \right\rbrace \\
=& \left\lbrace x\in AI(P) \mid f(x)=f(x_{1} +0)\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f(x_{1})\cup f(0) \right\rbrace\\
=&\left\lbrace x\in AI(P) \mid f(x)=f(x_{1})\cup \emptyset \right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f(x_{1}) \right\rbrace \\
=& \left\lbrace x\in AI(P) \mid x \simeq x_{1} \right\rbrace \\
=& \overline{x_{1}},
\end{align*}
\item \begin{align*}
&(\overline{x_{1}} \cdot \overline{x_{2}}) \cdot \overline{x_{3}}=(\overline{x_{1}\cdot x_{2}})\cdot\overline{x_{3}}=\overline{(x_{1}\cdot x_{2})}\cdot\overline{x_{3}}=\overline{(x_{1}\cdot x_{2})\cdot x_{3}}\\
=&\left\lbrace x\in AI(P) \mid x\simeq (x_{1}\cdot x_{2})\cdot x_{3}\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f( (x_{1}\cdot x_{2})\cdot x_{3})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a'\cup a_{3}\mid a'\in f((x_{1}\cdot x_{2})), a_{3}\in f(x_{3}) \right\rbrace \right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a'\cup a_{3}\mid a'\in f(x_{1}\cdot x_{2}), a_{3}\in f(x_{3}) \right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a'\cup a_{3}\mid a'\in \left\lbrace a_{1}\cup a_{2} \mid a_{1}\in f(x_{1}), a_{2}\in f(x_{2})\right\rbrace,\right.\right.\\
&\left. \left. a_{3}\in f(x_{3}) \right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace (a_{1}\cup a_{2}) \cup a_{3}\mid a_{1}\in f(x_{1}), a_{2}\in f(x_{2}), a_{3}\in f(x_{3}) \right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{1}\cup (a_{2} \cup a_{3})\mid a_{1}\in f(x_{1}), a_{2}\in f(x_{2}), a_{3}\in f(x_{3}) \right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{1}\cup a''\mid a_{1}\in f(x_{1}) , a'' \in \left\lbrace a_{2} \cup a_{3}\mid a_{2}\in f(x_{2}),\right. \right. \right. \\
& \left. \left. \left. a_{3}\in f(x_{3})\right\rbrace\right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{1}\cup a''\mid a_{1}\in f(x_{1}), a'' \in f(x_{2}\cdot x_{3}) \right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{1}\cup a''\mid a_{1}\in f(x_{1}), a'' \in f((x_{2}\cdot x_{3})) \right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f( x_{1}\cdot (x_{2}\cdot x_{3}))\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid x\simeq x_{1}\cdot (x_{2}\cdot x_{3})\right\rbrace \\
=&\overline{x_{1}\cdot (x_{2}\cdot x_{3})}\\
=& \overline{x_{1}}\cdot \overline{(x_{2}\cdot x_{3})}\\
=&\overline{x_{1}}\cdot (\overline{x_{2}\cdot x_{3}})\\
=& \overline{x_{1}} \cdot (\overline{x_{2}} \cdot \overline{x_{3}}),
\end{align*}
\item \begin{align*}
\overline{x_{1}} \cdot \overline{x_{2}} =&\overline{x_{1}\cdot x_{2}}\\
=&\left\lbrace x\in AI(P) \mid x\simeq x_{1}\cdot x_{2}\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f( x_{1}\cdot x_{2})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{1}\cup a_{2}\mid a_{1}\in f(x_{1}), a_{2}\in f(x_{2}) \right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{2}\cup a_{1}\mid a_{2}\in f(x_{2}), a_{1}\in f(x_{1}) \right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f( x_{2}\cdot x_{1})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid x\simeq x_{2}\cdot x_{1}\right\rbrace \\
=& \overline{x_{2}\cdot x_{1}}\\
=&\overline{x_{2}} \cdot \overline{x_{1}},
\end{align*}
\item \begin{align*}
\overline{x_{1}} \cdot \overline{1} =&\overline{x_{1}\cdot 1}\\
=& \left\lbrace x\in AI(P) \mid x\simeq x_{1}\cdot 1\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f( x_{1}\cdot 1)\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{1}\cup a_{2}\mid a_{1}\in f(x_{1}), a_{2}\in \left\lbrace \emptyset\right\rbrace \right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{1}\cup \emptyset\mid a_{1}\in f(x_{1}), a_{2}=\emptyset \right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{1}\mid a_{1}\in f(x_{1})\right\rbrace \right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f(x_{1})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid x\simeq x_{1}\right\rbrace \\
=& \overline{x_{1}},
\end{align*}
\item \begin{align*}
\overline{x_{1}} \cdot \overline{0} =&\overline{x_{1}\cdot 0}\\
=&\left\lbrace x\in AI(P) \mid x\simeq x_{1}\cdot 0\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f( x_{1}\cdot 0)\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{1}\cup a_{2}\mid a_{1}\in f(x_{1}), a_{2}\in \emptyset \right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)= \emptyset\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)= f(0) \right\rbrace \\
=&\left\lbrace x\in AI(P) \mid x\simeq 0\right\rbrace \\
=& \overline{0},
\end{align*}
\item \label{dist} \begin{align*}\label{dis}
\overline{x_{1}} \cdot (\overline{x_{2}}+ \overline{x_{3}}) =&\overline{x_{1}}\cdot (\overline{x_{2}+x_{3}})=\overline{x_{1}}\cdot \overline{(x_{2}+x_{3})}=\overline{x_{1}\cdot (x_{2}+x_{3})}\\
=&\left\lbrace x\in AI(P) \mid x\simeq x_{1}\cdot (x_{2}+x_{3})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f( x_{1}\cdot (x_{2}+x_{3}))\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{1}\cup a'\mid a_{1}\in f(x_{1}), a'\in f(x_{2}+x_{3}) \right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{1}\cup a'\mid a_{1}\in f(x_{1}), a'\in f(x_{2})\cup f(x_{3}) \right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=\left\lbrace a_{1}\cup a'\mid a_{1}\in f(x_{1}), a'\in f(x_{2})\right\rbrace \cup \right.\\
&\left. \left\lbrace a_{1}\cup a'\mid a_{1}\in f(x_{1}), a'\in f(x_{3}) \right\rbrace\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f(x_{1}\cdot x_{2})\cup f(x_{1}\cdot x_{3})\right\rbrace \\
=&\left\lbrace x\in AI(P) \mid f(x)=f((x_{1}\cdot x_{2})+(x_{1}\cdot x_{3}))\right\rbrace \\
=& \left\lbrace x\in AI(P) \mid x\simeq (x_{1}\cdot x_{2})+ (x_{1}\cdot x_{3})\right\rbrace \\
=&\overline{(x_{1}\cdot x_{2})+(x_{1}\cdot x_{3})}\\
=&\overline{(x_{1} \cdot x_{2})}+ \overline{(x_{1}\cdot x_{3})}\\
=&(\overline{x_{1} \cdot x_{2}})+ (\overline{x_{1}\cdot x_{3}})\\
=&(\overline{x_{1}} \cdot \overline{x_{2}})+ (\overline{x_{1}} \cdot \overline{x_{3}}).
\end{align*}
\item The statement is proved as in case \eqref{dist}. \qed
\end{enumerate}
\end{prof*}
By the above proposition we immediately get that $(AI(P)/\simeq,+,\cdot,\bar{0},\bar{1})$ is a commutative and idempotent semiring.\\
\par It is worth mentioning that the above proposition is proved in \cite{Bl:Al} both by syntactic equality, i.e., independently of the interpretation of the $AI(P)$ syntax, and by semantic equivalence, that is applying the presented semantics. Here we are interested in the latter case since in the sequel we investigate the corresponding weighted framework. For this, we provided an alternative proof for the proposition using the corresponding equivalent classes of $AI(P)$. This method serves for proving the respective result in the weighted setup. We point the reader on Section \ref{disc} for a more detailed discussion regarding this aspect.\\}
\hide{\noindent Next we introduce our weighted Algebra of Interactions over $K$. }
\begin{defin}
Consider a set of weighted components $w\mathcal{B} = \left\lbrace wB_{i} \mid i \in \left[n\right]\right\rbrace $ and let $P=\cup_{i\in \left[ n\right]}P_{i}$, such that $0,1\not \in P$. The syntax of the weighted Algebra of Interactions ($wAI(P)$ for short) over $P$ and $K$ is given by
$$z::=0\mid 1\mid p \mid z\oplus z \mid z \otimes z \mid \left( z \right)$$
where $p\in P$, `` $\oplus$'' is the weighted union operator and `` $\otimes$'' is the weighted synchronization operator that binds stronger than `` $\oplus$''.
\end{defin}
Without abusing notation, we used for simplicity the same symbols for weighted union (resp. weighted synchronization) operator and the first (resp. second) operation of semiring $K$. Moreover, it should be clear that ``$0$'' and ``$1$'' occurring in the syntax of the $wAI(P)$ are distinct from the respective elements $\hat{0}$ and $\hat{1}$ in semiring $K$. Indeed, the former serve to encode the weight on a specific $\gamma\in \Gamma(P)$, as presented in Definition \ref{sem-wAI(P)} below, while the latter correspond to the neutral elements of the operations ``$\oplus$'' and ``$\otimes$'' in $K$, respectively.
\par We call $z$ a $wAI(P)$ component over $P$ and $K$. Whenever the latter are understood we simply refer to $z$ as a $wAI(P)$ component. Moreover, $z$ is called a $wAI(P)$ monomial iff it does not involve any weighted union operator. The semantics of a $wAI(P)$ component $z$ over the set of ports $P$ and the semiring $K$ is defined by the function $\left\| \cdot \right\|: \Gamma(P) \to K$. Therefore, we represent the semantics of $z$ as polynomials $\left\|z\right\| \in K\left\langle \Gamma(P)\right\rangle $.
\begin{defin}\label{sem-wAI(P)}
Let $z$ be a $wAI(P)$ component over $P$ and $K$. The semantics of $z$ is a polynomial $\left\|z\right\| \in K\left\langle \Gamma(P)\right\rangle $. For every set of interactions $\gamma\in \Gamma(P)$, the value $\left\|z\right\|(\gamma)$ is defined inductively on $z$ as follows:
\begin{itemize}
\renewcommand\labelitemi{--}
\item $\left\|0\right\|(\gamma)=\hat{0}$,
\item $\left\|1\right\|(\gamma)=\left\{ \begin{array}{l l}
\hat{1} & \text{if} \quad \emptyset\in\gamma \\
\hat{0} & \text{otherwise}
\end{array} \right.$,
\item $\left\|p\right\|(\gamma)=\left\{ \begin{array}{l l}
k_{p} & \text{if} \quad \exists \ a \in\gamma \ \text{such that} \ p\in a \\
\hat{0} & \text{otherwise}
\end{array} \right.$,
\item $\left\|z_{1}\oplus z_{2}\right\|(\gamma)=
\bigoplus\limits_{a \in \gamma } \big( \left\|z_{1}\right\|(\left\lbrace a\right\rbrace )\oplus\left\|z_{2}\right\|(\left\lbrace a\right\rbrace ) \big)$,
\item $\left\|z_{1}\otimes z_{2}\right\|(\gamma)=
\bigoplus\limits_{a\in \gamma} \Big( \bigoplus\limits_{a=a_{1}\cup a_{2}} \big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace) \otimes \left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace) \big) \Big) $,
\item $\left\| \left( z\right) \right\|(\gamma)=\left\| z \right\|(\gamma).$
\end{itemize}
\end{defin}
\begin{rem}\label{re1}
Observe that if $\gamma=\emptyset$, then by the above definition we get that $\left\|z\right\|(\gamma)=\hat{0}$, for every $z\in wAI(P)$.
\end{rem}
\begin{rem}\label{singl}
In case that $\gamma\in \Gamma(P)$ is a singleton, i.e., $\gamma=\left\lbrace a'\right\rbrace $, then for the semantics of the weighted union operator we have
\begin{align*}
\left\|z_{1}\oplus z_{2}\right\|(\gamma)=&
\bigoplus\limits_{a \in \gamma } \big( \left\|z_{1}\right\|(\left\lbrace a\right\rbrace )\oplus\left\|z_{2}\right\|(\left\lbrace a\right\rbrace ) \big)\\
=& \bigoplus\limits_{a \in \left\lbrace a'\right\rbrace } \big( \left\|z_{1}\right\|(\left\lbrace a\right\rbrace )\oplus\left\|z_{2}\right\|(\left\lbrace a\right\rbrace ) \big)\\
=& \left\|z_{1}\right\|(\left\lbrace a'\right\rbrace ) \oplus \left\|z_{2}\right\|(\left\lbrace a'\right\rbrace ).
\end{align*}
Moreover, for the semantics of the weighted synchronization operator we have
\begin{align*}
\left\|z_{1}\otimes z_{2}\right\|(\gamma)=& \bigoplus\limits_{a \in \gamma } \Big(
\bigoplus\limits_{a =a_{1}\cup a_{2}} \big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes\left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \big)\Big)\\
=& \bigoplus\limits_{a \in \left\lbrace a'\right\rbrace } \Big(
\bigoplus\limits_{a =a_{1}\cup a_{2}} \big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes\left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \big)\Big)\\
=& \bigoplus\limits_{a' =a_{1}\cup a_{2}} \big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace ) \oplus \left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \big).
\end{align*}
Hence, in what follows, when $\gamma$ is a singleton, i.e., $\gamma=\left\lbrace a'\right\rbrace \in \Gamma(P)$ we often write
\begin{itemize}
\item $\left\|z_{1}\oplus z_{2}\right\|(\gamma)=\left\|z_{1}\right\|(\left\lbrace a'\right\rbrace ) \oplus \left\|z_{2}\right\|(\left\lbrace a'\right\rbrace )$, and
\item $\left\|z_{1}\otimes z_{2}\right\|(\gamma)=\bigoplus\limits_{a' =a_{1}\cup a_{2}} \big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace ) \oplus \left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \big)$.
\end{itemize}
\end{rem}
\par We say that $z_{1}, z_{2}\in wAI(P)$ are equivalent and we write $z_{1}\equiv z_{2}$, when they return the same weight on the same set of interactions, i.e., when $ \left\|z_{1}\right\|(\gamma)=\left\|z_{2}\right\|(\gamma)$ for every $\gamma\in \Gamma(P)$.
\hide{\par Obviously the relation ``$\equiv$'' is an equivalence relation. Specifically, for every $\gamma \in \Gamma(P)$ we have that
\begin{itemize}
\item ``$\equiv$'' is reflexive: It holds that $ \left\|z\right\|(\gamma)=\left\|z\right\|(\gamma)$ for every $z \in wAI(P)$, i.e., $z\equiv z$.
\item ``$\equiv$'' is symmetric: We assume that $z_{1}\equiv z_{2}$ for $z_{1}, z_{2}\in wAI(P)$, i.e., $ \left\|z_{1}\right\|(\gamma)=\left\|z_{2}\right\|(\gamma)$. Then obviously $ \left\|z_{2}\right\|(\gamma)=\left\|z_{1}\right\|(\gamma)$, hence $z_{1}\equiv z_{2} \Rightarrow z_{2}\equiv z_{1}$.
\item ``$\equiv$'' is transitive: Let $z_{1}\equiv z_{2}$ and $z_{2}\equiv z_{3}$, where $z_{1}, z_{2}, z_{3} \in wAI(P)$. The first relation implies that $ \left\|z_{1}\right\|(\gamma)=\left\|z_{2}\right\|(\gamma)$ while the latter means that $ \left\|z_{2}\right\|(\gamma)=\left\|z_{3}\right\|(\gamma)$. Therefore, we obtain that $ \left\|z_{1}\right\|(\gamma)=\left\|z_{3}\right\|(\gamma)$, i.e., $z_{1}\equiv z_{2}$ and $z_{2}\equiv z_{3} \Rightarrow z_{1}\equiv z_{3}$.
\end{itemize}
\noindent Hence, ``$\equiv$'' is an equivalence relation on $wAI(P)$.\\}
\par Obviously the relation ``$\equiv$'' is an equivalence relation. We define the quotient set $wAI(P)/\equiv$ of ``$\equiv$'' on $wAI(P)$. For every $z\in wAI(P)$ we simply denote by $\overline{z}$ its equivalent class. We define on $wAI(P)/\equiv$ two operations as follows:
$\overline{z_{1}}\oplus \overline{z_{2}}=\overline{z_{1}\oplus z_{2}}$
and $\overline{z_{1}}\otimes \overline{z_{2}}=\overline{z_{1}\otimes z_{2}}$
for every $z_{1}, z_{2}\in wAI(P)$. It can be easily proved that these operations depend only on the classes and not on their representatives, i.e., they are well-defined. Thus, if $\overline{z_{1}}=\overline{z_{3}}$ and $\overline{z_{2}}=\overline{z_{4}}$, then $\overline{z_{1}}\oplus\overline{z_{2}}=\overline{z_{3}}\oplus\overline{z_{4}}$ and $\overline{z_{1}}\otimes \overline{z_{2}}=\overline{z_{3}}\otimes \overline{z_{4}}$, for $z_{1}, z_{2}, z_{3}, z_{4} \in wAI(P)$.
\hide{\par Let $\overline{z_{1}}=\overline{z_{3}}$ and $\overline{z_{2}}=\overline{z_{4}}$ which imply that $ \left\|z_{1}\right\|(\gamma)=\left\|z_{3}\right\|(\gamma)$ and $ \left\|z_{2}\right\|(\gamma)=\left\|z_{4}\right\|(\gamma)$ for every $\gamma\in \Gamma(P)$, respectively. Then, we have that
\begin{align*}
\overline{z_{1}}\oplus \overline{z_{2}}=\overline{z_{1}\oplus z_{2}}=&\left\lbrace z\in wAI(P) \mid z\equiv z_{1}\oplus z_{2}\right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\|z_{1}\oplus z_{2}\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P)\right\rbrace \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \big(\left\|z_{1}\right\|(\left\lbrace a\right\rbrace )\oplus \left\|z_{2}\right\|(\left\lbrace a\right\rbrace ) \big) \ \text{for every} \\
& \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \big( \left\|z_{3}\right\|(\left\lbrace a\right\rbrace )\oplus \left\|z_{4}\right\|(\left\lbrace a\right\rbrace ) \big) \ \text{for every} \\
& \gamma\in \Gamma(P) \bigg\} \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\|z_{3}\oplus z_{4}\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P)\right\rbrace \\
=&\left\lbrace z\in wAI(P) \mid z\equiv z_{3}\oplus z_{4}\right\rbrace\\
=&\overline{z_{3}\oplus z_{4}}\\
=&\overline{z_{3}}\oplus \overline{z_{4}}.
\end{align*}
For the second operation ``$\otimes$'' we get
\begin{align*}
\overline{z_{1}}\otimes \overline{z_{2}}=\overline{z_{1}\otimes z_{2}}=&\left\lbrace z\in wAI(P) \mid z\equiv z_{1}\otimes z_{2}\right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\|z_{1}\otimes z_{2}\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P)\right\rbrace \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a=a_{1}\cup a_{2} } \big(\left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \Big) \\
& \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a=a_{1}\cup a_{2} } \big(\left\|z_{3}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \left\|z_{4}\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \Big) \\
& \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\|z_{3}\otimes z_{4}\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P)\right\rbrace \\
=&\left\lbrace z\in wAI(P) \mid z\equiv z_{3}\otimes z_{4}\right\rbrace\\
=&\overline{z_{3}\otimes z_{4}}\\
=&\overline{z_{3}} \otimes \overline{z_{4}}.
\end{align*}
Hence, we have proved that the operations \eqref{o3} and \eqref{o4} are well-defined.\\}
\par In the next proposition we prove several properties satisfied by the $wAI(P)$ components over $P$ and $K$. As a consequence we obtain that $(wAI(P)/\equiv,\oplus,\otimes, \bar{0},\bar{1})$ is a commutative and idempotent semiring with two binary operations $\oplus$, i.e., weighted union and $\otimes$, i.e., weighted synchronization, and two constant elements $\bar{0}$ and $\bar{1}$, respectively. In turn, we apply this result in computing the semantics of our weighted connectors, presented in the subsequent sections. Firstly, we need to prove the following lemma.
\begin{lemma}\label{l1}
Let $z\in wAI(P)$. Then, for every $\gamma\in \Gamma(P)$ it holds that
$$\bigoplus\limits_{a \in \gamma } \Big( \left\|z\right\|(\left\lbrace a\right\rbrace) \Big) = \left\|z\right\|(\gamma).$$
\end{lemma}
\begin{prof*}
We prove the lemma by induction on the structure of $z\in wAI(P)$. By Remark \ref{re1}, we assume that $\gamma\in \Gamma(P)\setminus \left\lbrace \emptyset\right\rbrace $.
\begin{itemize}
\item If $z=0$, then $\bigoplus\limits_{a \in \gamma } \Big( \left\|0\right\|(\left\lbrace a\right\rbrace) \Big) =
\bigoplus\limits_{a \in \gamma } \big( \hat{0} \big)
=\hat{0}$ and $\left\|0\right\|(\gamma)=\hat{0}.$
\item If $z=1$ and $\emptyset \in \gamma$, then $\bigoplus\limits_{a\in \gamma} \Big( \left\|1\right\|(\left\lbrace a\right\rbrace )\Big)= \left\|1\right\|(\left\lbrace \emptyset\right\rbrace )\oplus \overset{}{\underset{\substack{a\in \gamma,\\a\neq \emptyset }}{\bigoplus}}\big( \left\|1\right\|(\left\lbrace a\right\rbrace ) \big) = \hat{1} \oplus \overset{}{\underset{\substack{a\in \gamma,\\a\neq \emptyset }}{\bigoplus}}\big( \hat{0} \big)
= \hat{1} \oplus \hat{0} = \hat{1}$ and $\left\|1\right\|(\gamma)=\hat{1}.$ On the other hand, if $z=1$ and $\emptyset \notin \gamma$, then
$\bigoplus\limits_{a\in \gamma} \Big( \left\|1\right\|(\left\lbrace a\right\rbrace )\Big)=\overset{}{\underset{a\in \gamma}{\bigoplus}}\big( \hat{0} \big)=\hat{0}$ and $\left\|1\right\|(\gamma)=\hat{0}.$ Hence, in each case we obtain that $\bigoplus\limits_{a\in \gamma} \Big( \left\|1\right\|(\left\lbrace a\right\rbrace )\Big)=\left\|1\right\|(\gamma).$
\item If $z=p$ and $\exists \ a\in \gamma$ such that $p \in a$, then
$\bigoplus\limits_{a\in \gamma} \Big( \left\|p\right\|(\left\lbrace a\right\rbrace )\Big)=\overset{}{\underset{\substack{a\in \gamma,\\ p\in a}}{\bigoplus}}\big(\left\|p\right\|(\left\lbrace a\right\rbrace ) \big) \oplus \overset{}{\underset{\substack{a\in \gamma,\\ p\notin a}}{\bigoplus}}\big(\left\|p\right\|(\left\lbrace a\right\rbrace ) \big)
= \overset{}{\underset{\substack{a\in \gamma,\\ p\in a}}{\bigoplus}}\big(k_{p} \big) \oplus \overset{}{\underset{\substack{a\in \gamma,\\ p\notin a}}{\bigoplus}}\big(\hat{0} \big) = k_{p}\oplus \hat{0} = k_{p}$ and $\left\|p\right\|(\gamma)=k_{p}.$ On the other hand, if $z=p$ and $\nexists \ a\in \gamma$ such that $p \in a$, then $\bigoplus\limits_{a\in \gamma} \Big( \left\|p\right\|(\left\lbrace a\right\rbrace )\Big)=\overset{}{\underset{\substack{a\in \gamma,\\p\notin a }}{\bigoplus}}\big( \hat{0} \big)=\hat{0} $ and $\left\|p\right\|(\gamma)=\hat{0}.$ Hence, in each case we obtain that $\bigoplus\limits_{a\in \gamma} \Big( \left\|p\right\|(\left\lbrace a\right\rbrace )\Big)=\left\|p\right\|(\gamma).$
\item If $z=z_{1}\oplus z_{2}$, then
\begin{align*}
\bigoplus\limits_{a \in \gamma } \Big( \left\|z_{1}\oplus z_{2}\right\|(\left\lbrace a\right\rbrace) \Big)
=&
\bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a' \in \left\lbrace a\right\rbrace } \big( \left\|z_{1}\right\|(\left\lbrace a'\right\rbrace )\oplus \left\|z_{2}\right\|(\left\lbrace a'\right\rbrace ) \big) \Big) \\
=&\bigoplus\limits_{a \in \gamma } \big( \left\|z_{1}\right\|(\left\lbrace a\right\rbrace )\oplus\left\|z_{2}\right\|(\left\lbrace a\right\rbrace ) \big)\\
=& \left\|z_{1}\oplus z_{2}\right\|(\gamma),
\end{align*}
where the second equality holds since the set $\left\lbrace a\right\rbrace $ contains only the interaction $a$, thus we get that $a'=a$.
\item If $z=z_{1}\otimes z_{2}$, then
\begin{align*}
\bigoplus\limits_{a \in \gamma } \Big( \left\|z_{1}\otimes z_{2}\right\|(\left\lbrace a\right\rbrace) \Big)
=&\bigoplus\limits_{a \in \gamma } \bigg( \bigoplus\limits_{a' \in \left\lbrace a\right\rbrace } \Big( \bigoplus\limits_{a'=a_{1}\cup a_{2}} \big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \Big) \bigg)\\
=&\bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a=a_{1}\cup a_{2}} \big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes\left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \Big)\\
=&\left\|z_{1}\otimes z_{2}\right\|(\gamma),
\end{align*}
where the second equality holds since the set $\left\lbrace a\right\rbrace $ is singleton, and hence $a'=a$.
\item If $z=(z_{1})$, then
\begin{align*}
\bigoplus\limits_{a \in \gamma } \big( \left\|(z_{1})\right\| (\left\lbrace a\right\rbrace) \big)=&\bigoplus\limits_{a \in \gamma } \Big( \left\|z_{1}\right\|(\left\lbrace a\right\rbrace) \Big)\\
=& \left\|z_{1}\right\|(\gamma) \\
=& \left\|(z_{1})\right\|(\gamma),
\end{align*}
where the second equality holds by induction, and our proof is completed.
\end{itemize}
Therefore, for any $z\in wAI(P)$, we proved that $\bigoplus\limits_{a \in \gamma } \Big( \left\|z\right\|(\left\lbrace a\right\rbrace) \Big)=\left\|z\right\|(\gamma)$.\qed
\end{prof*}
\begin{prop}
Let $\overline{z_{1}}, \overline{z_{2}}, \overline{z_{3}}\in wAI(P)/\equiv$. Then
\begin{multicols}{2}
\begin{enumerate}[label=\roman*)]
\item $(\overline{z_{1}}\oplus \overline{z_{2}})\oplus \overline{z_{3}} = \overline{z_{1}}\oplus (\overline{z_{2}}\oplus \overline{z_{3}})$
\item $\overline{z_{1}}\oplus \overline{z_{2}} = \overline{z_{2}}\oplus \overline{z_{1}}$
\item $\overline{z_{1}}\oplus \overline{z_{1}} = \overline{z_{1}}$
\item $\overline{z_{1}}\oplus \overline{0} = \overline{z_{1}}$
\item $(\overline{z_{1}}\otimes \overline{z_{2}})\otimes \overline{z_{3}} = \overline{z_{1}}\otimes (\overline{z_{2}}\otimes \overline{z_{3}})$
\item $\overline{z_{1}}\otimes \overline{z_{2}} = \overline{z_{2}}\otimes \overline{z_{1}}$
\item $\overline{z_{1}}\otimes \overline{1} = \overline{z_{1}}$
\item $\overline{z_{1}}\otimes \overline{0} = \overline{0}$
\item $\overline{z_{1}}\otimes (\overline{z_{2}}\oplus \overline{z_{3}}) = (\overline{z_{1}}\otimes \overline{z_{2}})\oplus (\overline{z_{1}}\otimes \overline{z_{3}})$
\item $(\overline{z_{1}}\oplus \overline{z_{2}})\otimes \overline{z_{3}} = (\overline{z_{1}}\otimes \overline{z_{3}})\oplus (\overline{z_{2}}\otimes \overline{z_{3}}).$
\end{enumerate}
\end{multicols}
\end{prop}
\begin{prof*}
Let $\gamma\in \Gamma(P)$. By Remark \ref{re1}, we prove the above equalities for $\gamma\in \Gamma(P)\setminus\left\lbrace \emptyset\right\rbrace $.
\begin{enumerate}[label=\roman*)]
\item \begin{align*}
&(\overline{z_{1}}\oplus \overline{z_{2}})\oplus \overline{z_{3}}=(\overline{z_{1}\oplus z_{2}}) \oplus \overline{z_{3}}=\overline{(z_{1}\oplus z_{2})} \oplus \overline{z_{3}}=\overline{(z_{1}\oplus z_{2})\oplus z_{3}}\\
=& \left\lbrace z\in wAI(P) \mid z\equiv (z_{1}\oplus z_{2})\oplus z_{3} \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| (z_{1}\oplus z_{2})\oplus z_{3}\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \big(\left\|z_{1}\oplus z_{2}\right\|(\left\lbrace a\right\rbrace )\oplus \left\|z_{3}\right\|(\left\lbrace a\right\rbrace ) \big) \ \text{for every} \\
&\gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a' \in \left\lbrace a\right\rbrace } \big( \left\|z_{1}\right\|(\left\lbrace a'\right\rbrace )\oplus \left\|z_{2}\right\|(\left\lbrace a'\right\rbrace ) \big)\oplus \left\|z_{3}\right\|(\left\lbrace a\right\rbrace ) \Big) \\
& \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Big( \big( \left\|z_{1}\right\|(\left\lbrace a\right\rbrace )\oplus \left\|z_{2}\right\|(\left\lbrace a\right\rbrace ) \big)\oplus \left\|z_{3}\right\|(\left\lbrace a\right\rbrace ) \Big) \\
&\ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Big( \left\|z_{1}\right\|(\left\lbrace a\right\rbrace )\oplus \big( \left\|z_{2}\right\|(\left\lbrace a\right\rbrace ) \oplus \left\|z_{3}\right\|(\left\lbrace a\right\rbrace ) \big) \Big) \\
&\ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \big(\left\|z_{1}\right\|(\left\lbrace a\right\rbrace )\oplus \left\|z_{2}\oplus z_{3}\right\|(\left\lbrace a\right\rbrace ) \big) \ \text{for every} \\
& \gamma\in \Gamma(P) \bigg\} \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| z_{1}\oplus (z_{2}\oplus z_{3})\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid z\equiv z_{1}\oplus (z_{2}\oplus z_{3}) \right\rbrace \\
=&\overline{z_{1}\oplus (z_{2}\oplus z_{3})}\\
=&\overline{z_{1}}\oplus \overline{(z_{2} \oplus z_{3})}\\
=&\overline{z_{1}}\oplus (\overline{z_{2} \oplus z_{3}})\\
=&\overline{z_{1}}\oplus (\overline{z_{2}}\oplus \overline{z_{3}})
\end{align*}
where the eighth equality holds since $\left\lbrace a\right\rbrace$ is a singleton and hence $a'\in \left\lbrace a\right\rbrace $ implies that $a'=a$. The ninth equality holds by the associativity property of `` $\oplus$'' in semiring $K$.
\item \begin{align*}
&\overline{z_{1}}\oplus \overline{z_{2}}=\overline{z_{1}\oplus z_{2}} = \left\lbrace z\in wAI(P) \mid z\equiv z_{1}\oplus z_{2} \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| z_{1}\oplus z_{2}\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \big(\left\|z_{1}\right\|(\left\lbrace a\right\rbrace )\oplus \left\|z_{2}\right\|(\left\lbrace a\right\rbrace ) \big) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \big(\left\|z_{2}\right\|(\left\lbrace a\right\rbrace )\oplus \left\|z_{1}\right\|(\left\lbrace a\right\rbrace ) \big) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| z_{2}\oplus z_{1}\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid z\equiv z_{2}\oplus z_{1} \right\rbrace \\
=&\overline{z_{2}\oplus z_{1}}\\
=&\overline{z_{2}}\oplus \overline{z_{1}}
\end{align*}
where the fifth equality holds by the commutativity property of `` $\oplus$'' in semiring $K$.
\item \begin{align*}
&\overline{z_{1}}\oplus \overline{z_{1}}=\overline{z_{1}\oplus z_{1}} = \left\lbrace z\in wAI(P) \mid z\equiv z_{1}\oplus z_{1} \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| z_{1}\oplus z_{1}\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \big(\left\|z_{1}\right\|(\left\lbrace a\right\rbrace )\oplus \left\|z_{1}\right\|(\left\lbrace a\right\rbrace ) \big) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \big(\left\|z_{1}\right\|(\left\lbrace a\right\rbrace ) \big) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| z_{1}\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid z\equiv z_{1} \right\rbrace\\
=&\overline{z_{1}}
\end{align*}
where the fifth and sixth equalities hold since the semiring $K$ is idempotent and by a direct application of Lemma \ref{l1}, respectively.
\item \begin{align*}
&\overline{z_{1}}\oplus \overline{0}=\overline{z_{1}\oplus 0} = \left\lbrace z\in wAI(P) \mid z\equiv z_{1}\oplus 0 \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| z_{1}\oplus 0\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \big(\left\|z_{1}\right\|(\left\lbrace a\right\rbrace )\oplus \left\|0\right\|(\left\lbrace a\right\rbrace ) \big) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \big(\left\|z_{1}\right\|(\left\lbrace a\right\rbrace ) \oplus \hat{0} \big) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \big(\left\|z_{1}\right\|(\left\lbrace a\right\rbrace ) \big) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| z_{1}\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid z\equiv z_{1} \right\rbrace\\
=&\overline{z_{1}}
\end{align*}
where the sixth and the seventh equalities hold since `` $\hat{0}$'' is the neutral element of `` $\oplus$'' in semiring $K$ and by applying Lemma \ref{l1}, respectively.
\item \begin{align*}
&(\overline{z_{1}}\otimes \overline{z_{2}})\otimes \overline{z_{3}}=(\overline{z_{1}\otimes z_{2}}) \otimes \overline{z_{3}}=\overline{(z_{1}\otimes z_{2})} \otimes \overline{z_{3}}=\overline{(z_{1}\otimes z_{2})\otimes z_{3}}\\
=& \left\lbrace z\in wAI(P) \mid z\equiv (z_{1}\otimes z_{2})\otimes z_{3} \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| (z_{1}\otimes z_{2})\otimes z_{3}\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a=a'\cup a_{3}} \big( \left\|z_{1}\otimes z_{2}\right\|(\left\lbrace a'\right\rbrace )\otimes \left\|z_{3}\right\|(\left\lbrace a_{3}\right\rbrace ) \big) \Big) \\
& \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \Bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a'\cup a_{3}} \bigg( \bigoplus\limits_{a'' \in \left\lbrace a'\right\rbrace } \Big( \bigoplus\limits_{a''=a_{1}\cup a_{2}} \big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \\
& \left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \Big)\otimes \left\|z_{3}\right\|(\left\lbrace a_{3}\right\rbrace ) \bigg) \Bigg) \ \text{for every} \ \gamma\in \Gamma(P) \Bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \bigg( \bigoplus\limits_{a=a'\cup a_{3}} \Big( \bigoplus\limits_{a'=a_{1}\cup a_{2}} \big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace) \otimes \left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \otimes \\
& \left\|z_{3}\right\|(\left\lbrace a_{3}\right\rbrace ) \Big) \bigg) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}\cup a_{3}} \Big( \big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace) \otimes \left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \otimes \\
& \left\|z_{3}\right\|(\left\lbrace a_{3}\right\rbrace ) \Big) \bigg) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}\cup a_{3}} \Big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace) \otimes \big( \left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \otimes \\
& \left\|z_{3}\right\|(\left\lbrace a_{3}\right\rbrace ) \big) \Big) \bigg) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \Bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a_{1}\cup a'''} \bigg( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace) \otimes \Big( \bigoplus\limits_{a'''=a_{2}\cup a_{3}} \big( \left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \otimes \\
& \left\|z_{3}\right\|(\left\lbrace a_{3}\right\rbrace ) \big) \Big) \bigg) \Bigg) \ \text{for every} \ \gamma\in \Gamma(P) \Bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a_{1}\cup a'''} \bigg( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace) \otimes \left\|z_{2}\otimes z_{3}\right\|(\left\lbrace a'''\right\rbrace ) \bigg) \Bigg) \\
& \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| z_{1}\otimes (z_{2}\otimes z_{3})\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid z\equiv z_{1}\otimes (z_{2}\otimes z_{3}) \right\rbrace \\
=&\overline{z_{1}\otimes (z_{2}\otimes z_{3})}\\
=&\overline{z_{1}}\otimes \overline{(z_{2} \otimes z_{3})}\\
=& \overline{z_{1}}\otimes (\overline{z_{2} \otimes z_{3}})\\
=&\overline{z_{1}}\otimes (\overline{z_{2}}\otimes \overline{z_{3}})
\end{align*}
where the eighth equality holds since $a''\in \left\lbrace a'\right\rbrace $ implies that $a''=a'$. The tenth equality holds by the associativity property of `` $\otimes$'' in semiring $K$, and the eleventh equality holds by the distributivity property of `` $\otimes$'' over `` $\oplus$'' in semiring $K$.
\item \begin{align*}
&\overline{z_{1}}\otimes \overline{z_{2}}=\overline{z_{1}\otimes z_{2}} = \left\lbrace z\in wAI(P) \mid z\equiv z_{1}\otimes z_{2} \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| z_{1}\otimes z_{2}\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a=a_{1}\cup a_{2}} \big(\left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \Big) \ \text{for every} \\
& \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a=a_{2}\cup a_{1}} \big(\left\|z_{2}\right\|(\left\lbrace a_{2}\right\rbrace )\otimes \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace ) \big) \Big) \ \text{for every} \\
& \gamma\in \Gamma(P) \bigg\} \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| z_{2}\otimes z_{1}\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid z\equiv z_{2}\otimes z_{1} \right\rbrace\\
=&\overline{z_{2}\otimes z_{1}}\\
=&\overline{z_{2}}\otimes \overline{z_{1}}
\end{align*}
where the fifth equality holds since `` $\otimes$'' is commutative in semiring $K$.
\item \begin{align*}
&\overline{z_{1}}\otimes \overline{1}=\overline{z_{1}\otimes 1} = \left\lbrace z\in wAI(P) \mid z\equiv z_{1}\otimes 1 \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| z_{1}\otimes 1\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a=a_{1}\cup a_{2}} \big(\left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \left\|1\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \Big) \ \text{for every} \\
& \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \big( \left\|z_{1}\right\|(\left\lbrace a\right\rbrace )\otimes \left\|1\right\|(\left\lbrace \emptyset \right\rbrace ) \big) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \big( \left\|z_{1}\right\|(\left\lbrace a\right\rbrace )\otimes \hat{1} \big) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \big( \left\|z_{1}\right\|(\left\lbrace a\right\rbrace ) \big) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| z_{1}\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid z\equiv z_{1} \right\rbrace\\
=&\overline{z_{1}}
\end{align*}
where the fifth equality holds since the only set of interactions with non-zero weight for `` $1$'' is $\left\lbrace a_{2}\right\rbrace = \left\lbrace \emptyset\right\rbrace $. Hence, we obtain that $a_{1}=a$ and $a_{2}=\emptyset$. Also, the seventh equality holds since `` $\hat{1}$'' is the neutral element for `` $\otimes$'' in semiring $K$, while the eighth equality results by an application of Lemma \ref{l1}.
\item \begin{align*}
&\overline{z_{1}}\otimes \overline{0}=\overline{z_{1}\otimes 0} = \left\lbrace z\in wAI(P) \mid z\equiv z_{1}\otimes 0 \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| z_{1}\otimes 0\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a=a_{1}\cup a_{2}} \big(\left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \left\|0\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \Big) \ \text{for every} \\
& \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a=a_{1}\cup a_{2}} \big(\left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \hat{0} \big) \Big) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a=a_{1}\cup a_{2}} \big( \hat{0} \big) \Big) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\hat{0} \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| 0\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid z\equiv 0 \right\rbrace\\
=&\overline{0}
\end{align*}
where the sixth equality holds since `` $\hat{0}$'' is the absorbing element for `` $\otimes$'' in semiring $K$.
\item \label{w-dist} \begin{align*}
&\overline{z_{1}}\otimes (\overline{z_{2}}\oplus \overline{z_{3}})=\overline{z_{1}}\otimes (\overline{z_{2} \oplus z_{3}})=\overline{z_{1}}\otimes \overline{(z_{2} \oplus z_{3})}=\overline{z_{1}\otimes (z_{2}\oplus z_{3})}\\
=& \left\lbrace z\in wAI(P) \mid z\equiv z_{1}\otimes (z_{2} \oplus z_{3}) \right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| z_{1}\otimes (z_{2} \oplus z_{3})\right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P) \right\rbrace \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a=a_{1}\cup a'} \big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \left\|z_{2}\oplus z_{3}\right\|(\left\lbrace a'\right\rbrace ) \big) \Big) \\
& \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \bigg( \bigoplus\limits_{a=a_{1}\cup a'} \Big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \Big( \bigoplus\limits_{a'' \in \left\lbrace a'\right\rbrace } \big( \left\|z_{2}\right\|(\left\lbrace a''\right\rbrace )\oplus \\
& \left\|z_{3}\right\|(\left\lbrace a''\right\rbrace ) \big) \Big) \Big) \bigg)\ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \bigg( \bigoplus\limits_{a=a_{1}\cup a'} \Big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \Big( \left\|z_{2}\right\|(\left\lbrace a'\right\rbrace )\oplus \\
& \left\|z_{3}\right\|(\left\lbrace a'\right\rbrace ) \Big) \Big) \bigg) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \bigg( \bigoplus\limits_{a=a_{1}\cup a'} \Big( \big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \left\|z_{2}\right\|(\left\lbrace a'\right\rbrace ) \big) \oplus \\
& \big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \left\|z_{3}\right\|(\left\lbrace a'\right\rbrace ) \big) \Big) \bigg) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \bigg( \bigoplus\limits_{a=a_{1}\cup a'} \Big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \left\|z_{2}\right\|(\left\lbrace a'\right\rbrace ) \Big) \oplus \\
& \bigoplus\limits_{a=a_{1}\cup a'} \Big( \left\|z_{1}\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \left\|z_{3}\right\|(\left\lbrace a'\right\rbrace ) \Big) \bigg) \ \text{for every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \bigg\{ z\in wAI(P) \mid \left\|z\right\|(\gamma)=\bigoplus\limits_{a \in \gamma } \bigg( \left\|z_{1}\otimes z_{2}\right\|(\left\lbrace a\right\rbrace ) \oplus \left\|z_{1}\otimes z_{3}\right\|(\left\lbrace a\right\rbrace ) \bigg) \ \text{for} \\
& \text{every} \ \gamma\in \Gamma(P) \bigg\} \\
=& \left\lbrace z\in wAI(P) \mid \left\|z\right\|(\gamma)=\left\| (z_{1}\otimes z_{2})\oplus (z_{1}\otimes z_{3}) \right\|(\gamma) \ \text{for every} \ \gamma\in \Gamma(P)\right\rbrace \\
=& \left\lbrace z\in wAI(P) \mid z\equiv (z_{1}\otimes z_{2})\oplus (z_{1}\otimes z_{3}) \right\rbrace \\
=&\overline{(z_{1}\otimes z_{2})\oplus (z_{1}\otimes z_{3})}\\
=&\overline{(z_{1}\otimes z_{2})}\oplus \overline{(z_{1} \otimes z_{3})}\\
=&(\overline{z_{1}\otimes z_{2}})\oplus (\overline{z_{1} \otimes z_{3}})\\
=&(\overline{z_{1}}\otimes \overline{z_{2}}) \oplus (\overline{z_{1}}\otimes \overline{z_{3}})
\end{align*}
where the ninth equality holds by distributivity of `` $\otimes$'' over `` $\oplus$'' in semiring $K$, and the tenth equality results by associativity property of `` $\oplus$'' in semiring $K$.
\item The equality is proved as in case \eqref{w-dist}.
\end{enumerate}
Thus, our proof is completed.\qed
\end{prof*}
\hide{\color{red}\par Next we show that the axiomatization of wAI(P) is sound. For this, we firstly need to define the notion of soundness for the weighted components z of wAI(P). Although soundness has been studied extensively in the unweighted setup this has not been the case for the quantitative setting. In \cite{Pa:We} the authors introduced a notion of soundness for weighted propositional configuration logic formulas. Following the work of \cite{Pa:We} we provide an analogous definition for soundness.
\begin{defin}
Let $z \in wAI(P)$ and $\Sigma=\left\lbrace z_{1},\ldots, z_{n}\right\rbrace $ with $z_{1}, \ldots z_{n} \in wAI(P)$. We say that $\Sigma$ \emph{proves} z and write $\Sigma \vdash z$ if z is derived from weighted components in $\Sigma$. Furthermore, we write $\Sigma \models z$ iff for every $\gamma \in \underset{1\leqslant i\leqslant n}{\cap}supp(z_{i})$ such that $\left\|z_{1}\right\|(\gamma)=\ldots=\left\|z_{n}\right\|(\gamma)$, then $\left\|z\right\|(\gamma)=\ldots=\left\|z_{1}\right\|(\gamma)$. Then we say that wAI(P) is \emph{sound} if $\Sigma\vdash z$ implies $\Sigma\models z$.
\end{defin}
\begin{prop}
The axiomatization of $wAIP)$ is sound, that is, for $z_{1}, z_{2}\in wAI(P)$,
$$z_{1}=z_{2} \Rightarrow \left\|z_{1}\right\|=\left\|z_{2}\right\|.$$
\end{prop}
\begin{prof*}
We have to prove that all the axioms preserve the semantics in any weighted synchronization context. For this, for an axiom $z_{1}=z_{2}$ and an arbitrary $z \in wAI(P)$, we have to verify that $\left\|z_{1}\otimes z\right\|=\left\|z_{2}\otimes z\right\|$. However, it is clear that it is sufficient to verify this property only for weighted monomial z, since by induction it is proved for every wAI(P) term. \\
Let $z_{1}=p, z_{2}=q, z=r$ and we suppose that $z_{1}=z_{2}$. Then $$\left\|z_{1}\otimes z\right\|=\left\|p\otimes r\right\|=\left\|p\right\|\otimes \left\|r\right\|=p\otimes r=q\otimes r=\left\|q\right\|\otimes \left\|r\right\|=\left\|q\otimes r\right\|=\left\|z_{2}\otimes z\right\|.$$
The latter relation is proved by induction for every monomial term and in turn for every wAI(P) term, which completes our proof. \qed
\end{prof*}
\color{black}}
\begin{coro}\label{walg_semi}
The structure $(wAI(P)/\equiv,\oplus,\otimes, \bar{0},\bar{1})$ is a commutative and idempotent semiring.
\end{coro}
Now we can define the concept of weighted component-based systems.
\begin{defin}\label{comp-system-wAI(P)}
A weighted component-based system is a pair $(w\mathcal{B}, z)$ where $w\mathcal{B} = \left\lbrace wB_{i} \mid i \in \left[ n \right]\right\rbrace $ is a set weighted of components and $z$ is a $wAI(P)$ component over $P=\bigcup_{i\in [n]} P_{i}$ and $K$.
\end{defin}
It should be clear that $z$ is defined over the set of ports $P$ of the given system $w\mathcal{B}$. \\
\par Next we present several coordination schemes in the weighted setup and we encode the cost of their implementation by the weighted Algebra of Interactions. Let $z$ be the $wAI(P)$ component describing a scheme in the weighted setup and consider a set of interactions $\gamma \in \Gamma(P)$. In order to derive the semantics of the resulting weighted terms, we usually need to obtain the analyses of every interaction $a$ of the given $\gamma$ when the operators ``$\oplus$'' and ``$\otimes$'' are applied, and in turn the analyses of the obtained interactions etc. We apply these computation steps as many times as needed by the operators comprising the corresponding $wAI(P)$ component $z$.
\par For every interaction $a\in \gamma$ in our examples, we make use of two types of tables, the primary and the auxiliary tables. In the primary tables we derive the overall weight of component $z$ using the corresponding auxiliary tables. Primary and auxiliary tables contain in the first row the $wAI(P)$ component $z$ and the $wAI(P)$ terms of $z$, respectively, whose weight is calculated on a given interaction $a\in \gamma$ as indicated by the label of the tables. The primary tables, referred to as tables, have four columns. The first one includes all the possible analyses of the given $a\in \gamma$, while the second and third column contain the semantics of the respective $wAI(P)$ terms comprising $z$. In the fourth column we compute the weight of the weighted synchronization applied on the derived $wAI(P)$ terms. Then, in the last row of the tables we obtain the overall weight of $z$ on the particular $\lbrace a\rbrace$. The auxiliary tables, are structured as the primary ones with the difference that they return the weight on the $wAI(P)$ terms of $z$ appearing on the third column of the primary tables. The auxiliary tables are also referred to as tables and are identified by their labels.
\par For representation reasons, all the tables used in each of the four coordination schemes can be found in the Appendix \ref{appen}. There, we present firstly the primary tables of the $wAI(P)$ components for every interaction $a\in \gamma$ and then the auxiliary tables which are necessary for our calculations. Also, when a component contains the ``$\oplus$'' operator and its set of interactions is singleton, we compute directly its corresponding weight within its table, without considering further tables.
\par It should be clear that the analysis of $z$ in the respective $wAI(P)$ terms is not unique, and hence it is chosen arbitrarily. In what follows, we usually split $z$ in the terms occurring at the left and right of the first weighted synchronization operator. Obviously, for any other analyses of $z$ we derive the same overall weight on the given set of interactions $\gamma$.
\begin{examp}\label{eq:4}
\begin{figure}[H]
\centering
\includegraphics[scale=1.3]{Figure1_new.png}
\caption{A system with three weighted components.}
\label{f1-geo}
\end{figure}
Consider a system $( w\mathcal{B},z)$ where $w\mathcal{B}=\left\lbrace wS,wR_{1},wR_{2}\right\rbrace $ involves three weighted components, namely a sender $wS$ and two receivers $wR_{1}$ and $wR_{2}$, as shown in Figure \ref{eq:4}. The sender has a port $s$ which is responsible for sending messages and each one of the two receivers has a port $r_{i}$ for receiving the messages from the sender, for $i=1,2$. Hence, the set of the ports of the given system is $P=\left\lbrace s,r_{1}, r_{2}\right\rbrace $. Let $k_{s}, k_{r_{1}}, k_{r_{2}}$, denote the weights of the ports $s, r_{1}, r_{2}$, respectively. We consider four different coordination schemes, namely Rendezvous, Broadcast, Atomic Broadcast and Causality Chain, that can be applied for defining the communication among the three components of the system. In the following examples, we formalize each of the aforementioned schemes in the weighted setup by a $wAI(P)$ component $z$. \\
\noindent \underline{\textbf{Weighted Rendezvous}}: This coordination scheme requires strong synchronization between the sender $wS$ and each of the two receivers $wR_{1}, wR_{2}$. Hence, it consists of a single interaction involving all ports, namely $sr_1r_2$. The $wAI(P)$ component describing the weighted Rendezvous is
$$z=s\otimes r_{1}\otimes r_{2}.$$
We let $\gamma=\left\lbrace \left\lbrace s,r_{1},r_{2}\right\rbrace \right\rbrace \in\Gamma(P)$ and we compute the weight of $z$ on $\gamma$ by applying the semantics of $wAI(P)$.
In Table \ref{tab-re1}, we list in the first column all the possible analyses for $a=\left\lbrace s,r_{1},r_{2}\right\rbrace \in \gamma$ such that $a=a_{1}\cup a_{2}$, in the second and third column we compute the semantics of the components $s$ and $r_{1}\otimes r_{2}$, respectively, and in the last column we derive the cost of the respective weighted synchronization. The analysis and the semantics for the component $r_{1}\otimes r_{2}$ are obtained by the following auxiliary tables, specifically Tables \ref{tab-re2}-\ref{tab-re9}, for each set $a_{2}$ where $a_{2}=a_{2,1}\cup a_{2,2}$. Then, the last row in each table serves for computing the sum of the costs occurring in the last column. Specifically, in Table \ref{tab-re1}, the resulting value $k_{s}\otimes k_{r_{1}}\otimes k_{r_{2}}$ which is highlighted, corresponds to the overall weight of the weighted Rendezvous scheme on the given set $\gamma$. The weight of $z\in wAI(P)$ on $\gamma $ is computed as follows:
\begin{align*}
&\left\|s\otimes r_{1}\otimes r_{2} \right\|(\gamma)\\
=&\bigoplus\limits_{a\in \gamma} \Big( \bigoplus\limits_{a=a_{1}\cup a_{2}} \big( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace) \otimes \left\|r_{1}\otimes r_{2}\right\|(\left\lbrace a_{2}\right\rbrace) \big) \Big)\\
=&\bigoplus\limits_{a\in \gamma} \Bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace) \otimes \bigg( \bigoplus\limits_{a'\in \left\lbrace a_{2}\right\rbrace } \Big( \bigoplus\limits_{a'=a_{2,1}\cup a_{2,2}} \big( \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace)\otimes \left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace) \big) \Big) \bigg) \bigg) \Bigg)\\
=&\bigoplus\limits_{a\in \gamma} \Bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace) \otimes \Big( \bigoplus\limits_{a_{2}=a_{2,1}\cup a_{2,2}} \big( \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace)\otimes \left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace) \big) \Big) \bigg) \Bigg)\\
=&k_{s}\otimes k_{r_{1}}\otimes k_{r_{2}}.
\end{align*}
\hide{as the total cost of weighted Rendezvous on $\gamma=\left\lbrace \left\lbrace s, r_{1}, r_{2}\right\rbrace \right\rbrace $.}
For instance, let us consider the Fuzzy semiring $F=(\left[ 0,1\right] , \mathrm{max}, \mathrm{min}, 0, 1)$. Then, the value
\begin{align*}
&\left\|s\otimes r_{1}\otimes r_{2}\right\|(\gamma) \\
=&\underset{a \in \gamma }{\mathrm{max}} \Bigg( \underset{a=a_{1}\cup a_{2}}{\mathrm{max}} \bigg( \mathrm{min}\Big(\left\|s\right\|(\left\lbrace a_{1}\right\rbrace ), \underset{a_{2}=a_{2,1}\cup a_{2,2} }{\mathrm{max}} \big( \mathrm{min}( \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace ) , \left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) ) \big) \Big) \bigg) \Bigg) \\
=& \underset{a \in \gamma }{\mathrm{max}} \Bigg( \underset{a=a_{1}\cup a_{2}}{\mathrm{max}} \bigg( \underset{a_{2}=a_{2,1}\cup a_{2,2}}{\mathrm{max}} \Big( \mathrm{min}\big(\left\|s\right\|(\left\lbrace a_{1}\right\rbrace ),\mathrm{min}( \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace ) , \left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) ) \big) \Big) \bigg) \Bigg) \\
=& \underset{a \in \gamma }{\mathrm{max}} \bigg( \underset{a=a_{1}\cup a_{2,1}\cup a_{2,2}}{\mathrm{max}} \Big( \mathrm{min}\big(\left\|s\right\|(\left\lbrace a_{1}\right\rbrace ), \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace ) , \left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) \big) \Big) \bigg)
\end{align*}
returns for the Rendezvous scheme the maximum of the minimum weights associated with each port in the system. \\
\noindent \underline{\textbf{Weighted Broadcast}}: This coordination scheme allows executing all interactions involving the sender $wS$ and any subset of receivers $wR_{i}$, possibly the empty one. Hence, each permissible interaction should contain the port $s$. Thus, all the possible interactions are $s, sr_{1}, sr_{2}, sr_{1}r_{2}$. The $wAI(P)$ component $z$ describing weighted Broadcast is
$$z=s\otimes (1\oplus r_{1})\otimes (1\oplus r_{2}) .$$
We set $\gamma=\left\lbrace \left\lbrace s\right\rbrace , \left\lbrace s,r_{1}\right\rbrace , \left\lbrace s,r_{2}\right\rbrace , \left\lbrace s,r_{1},r_{2}\right\rbrace \right\rbrace\in\Gamma(P)$, and we compute the weight of $z$ on $\gamma$. For this, we need to obtain the analyses and the respective weight for each of the four interactions occurring in $\gamma$. We firstly consider the interaction $a=\left\lbrace s\right\rbrace \in \gamma$ for which we obtain Table \ref{tab-bra}. Then, we derive the weight of component $z$ for $a=\left\lbrace s,r_{1}\right\rbrace \in \gamma$ and $a=\left\lbrace s,r_{2}\right\rbrace \in \gamma$, presented in Tables \ref{tab-brb} and \ref{tab-brc}, respectively. Finally, we get the weight of $z$ for $a=\left\lbrace s,r_{1}, r_{2}\right\rbrace \in \gamma$, as shown in Table \ref{tab-brd}. The above weights are derived using also the auxiliary Tables \ref{tab-brd1}-\ref{tab-brd8}. The weight of $z$ on $\gamma$ is computed as follows:
\begin{align*}
&\big\|s\otimes (1\oplus r_{1})\otimes (1\oplus r_{2}) \big\|(\gamma)\\
=& \bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a=a_{1}\cup a_{2}} \big( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \left\| (1\oplus r_{1})\otimes (1\oplus r_{2})\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \Big)\\
=& \bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \bigg( \bigoplus\limits_{a' \in \left\lbrace a_{2}\right\rbrace } \Big( \bigoplus\limits_{a'=a_{2,1}\cup a_{2,2}} \big( \left\| 1\oplus r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace )\otimes \\
& \left\|1\oplus r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) \big) \Big) \bigg) \bigg) \Bigg)\\
=& \bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \Big( \bigoplus\limits_{a_{2}=a_{2,1}\cup a_{2,2}} \big( \left\| 1\oplus r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace )\otimes \left\|1\oplus r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) \big) \Big) \bigg)\Bigg)\\
=& \bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \bigg( \bigoplus\limits_{a_{2}=a_{2,1}\cup a_{2,2}} \Big( \bigoplus\limits_{a'' \in \left\lbrace a_{2,1}\right\rbrace } \big( \left\| 1\right\|(\left\lbrace a_{2,1}\right\rbrace )\oplus \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace ) \big) \otimes \\
& \Big(\bigoplus\limits_{a''' \in \left\lbrace a_{2,2}\right\rbrace } \big( \left\| 1\right\|(\left\lbrace a_{2,2}\right\rbrace )\oplus \left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) \big) \Big) \Big) \bigg) \bigg) \Bigg)\\
=& \bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \bigg( \bigoplus\limits_{a_{2}=a_{2,1}\cup a_{2,2}} \Big( \big( \left\| 1\right\|(\left\lbrace a_{2,1}\right\rbrace )\oplus \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace ) \big) \otimes \\
&\big( \left\| 1\right\|(\left\lbrace a_{2,2}\right\rbrace )\oplus \left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) \big) \Big) \bigg) \bigg) \Bigg)\\
=& k_{s}\oplus \big(k_{s}\oplus (k_{s}\otimes k_{r_{1}})\big)\oplus \big(k_{s} \oplus (k_{s}\otimes k_{r_{2}})\big) \oplus \big(k_{s}\oplus (k_{s}\otimes k_{r_{1}})\oplus (k_{s}\otimes k_{r_{2}}) \oplus \\
& (k_{s}\otimes k_{r_{1}}\otimes k_{r_{2}})\big)\\
=& k_{s} \oplus (k_{s}\otimes k_{r_{1}})\oplus (k_{s}\otimes k_{r_{2}}) \oplus (k_{s}\otimes k_{r_{1}}\otimes k_{r_{2}}).
\end{align*}
\noindent Consider for instance the $\mathbb{R}_{\mathrm{max}}$ semiring. Then the resulting value represents for weighted Broadcast scheme the maximum of the sum of the weights on the corresponding analyses of $\gamma$.
\hide{, computed as follows:
\begin{align*}
&\big\|s\otimes (1\oplus r_{1})\otimes (1\oplus r_{2})\big\|(\gamma)\\
=& \underset{a \in \gamma }{\mathrm{max}} \Bigg( \underset{a=a_{1}\cup a_{2}}{\mathrm{max}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+ \underset{a_{2}=a_{2,1}\cup a_{2,2}}{\mathrm{max}}\Big( \mathrm{max} \big(\left\|1\right\|(\left\lbrace a_{2,1}\right\rbrace ), \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace ) \big) + \\
& \mathrm{max}\big( \left\|1\right\|(\left\lbrace a_{2,2}\right\rbrace ), \left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace )\big)\Big) \bigg) \Bigg)\\
=&\underset{a \in \gamma }{\mathrm{max}} \Bigg( \underset{a=a_{1}\cup a_{2}}{\mathrm{max}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+ \underset{a_{2}=a_{2,1}\cup a_{2,2}}{\mathrm{max}}\Big( \mathrm{max} \big(\left\|1\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|1\right\|(\left\lbrace a_{2,2}\right\rbrace ),\\
& \left\|1\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ), \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace ) +\left\|1\right\|(\left\lbrace a_{2,2}\right\rbrace ), \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace )+\\
&\left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) \big) \Big) \bigg) \Bigg)\\
=&\underset{a \in \gamma }{\mathrm{max}} \Bigg( \underset{a=a_{1}\cup a_{2}}{\mathrm{max}} \bigg( \underset{a_{2}=a_{2,1}\cup a_{2,2}}{\mathrm{max}}\Big( \mathrm{max} \big( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+ \left\|1\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|1\right\|(\left\lbrace a_{2,2}\right\rbrace ),\\
& \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+\left\|1\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ), \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+\left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace ) +\left\|1\right\|(\left\lbrace a_{2,2}\right\rbrace ),\\
& \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+\left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) \big) \Big) \bigg) \Bigg)\\
=&\underset{a \in \gamma }{\mathrm{max}} \bigg( \underset{a=a_{1}\cup a_{2,1}\cup a_{2,2}}{\mathrm{max}} \Big( \mathrm{max} \big( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+ \left\|1\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|1\right\|(\left\lbrace a_{2,2}\right\rbrace ), \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+\\
&\left\|1\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ), \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+\left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace ) +\left\|1\right\|(\left\lbrace a_{2,2}\right\rbrace ), \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+\\
&\left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) \big) \Big) \bigg) .
\end{align*}}
\
\noindent\underline{\textbf{Weighted Atomic Broadcast}}: In the atomic broadcast scheme a message is either received by all receivers $wR_{i}$ or by none, which implies that we have only two interactions. The first interaction is $s$, i.e., when at least one of the receiving ports is not enabled, and the second one is $sr_{1}r_{2}$ where all receiving ports are enabled. The $wAI(P)$ component $z$ describing the weighted Atomic Broadcast is
$$z=s\otimes (1 \oplus r_{1}\otimes r_{2}).$$
We let $\gamma=\lbrace \lbrace s\rbrace, \lbrace s, r_{1},r_{2}\rbrace\rbrace \in \Gamma(P)$. We firstly compute the weight of the above component for $a=\left\lbrace s\right\rbrace\in \gamma$, and hence we derive Table \ref{tab-ata}. Afterwards, we obtain the weight of $z$ for $a=\left\lbrace s,r_{1}, r_{2}\right\rbrace \in \gamma$, as shown in Table \ref{tab-atb}. For this, we also need the auxiliary Tables \ref{tab-re2}-\ref{tab-re9}, that we obtained for the weighted Rendezvous scheme. Then, the weight of the Atomic Broadcast on $\gamma$ is obtained as follows:
\begin{align*}
&\big\|s\otimes (1 \oplus r_{1}\otimes r_{2} )\big\|(\gamma)\\
=& \bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a=a_{1}\cup a_{2}} \big( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \left\| 1\oplus r_{1}\otimes r_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \Big)\\
=& \bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \Big( \bigoplus\limits_{a' \in \left\lbrace a_{2}\right\rbrace } \big( \left\| 1\right\|(\left\lbrace a'\right\rbrace )\oplus \left\|r_{1}\otimes r_{2}\right\|(\left\lbrace a'\right\rbrace ) \big) \Big) \bigg) \Bigg) \\
=& \bigoplus\limits_{a \in \gamma } \bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \Big( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \big( \left\| 1\right\|(\left\lbrace a_{2}\right\rbrace )\oplus \left\|r_{1}\otimes r_{2}\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \Big) \bigg) \\
=& \bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \Big( \left\| 1\right\|(\left\lbrace a_{2}\right\rbrace )\oplus \bigoplus\limits_{a''\in \left\lbrace a_{2}\right\rbrace } \big( \bigoplus\limits_{a''=a_{2,1}\cup a_{2,2}} ( \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace )\otimes \\
& \left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) ) \big) \Big) \bigg) \Bigg) \\
=& \bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \Big( \left\| 1\right\|(\left\lbrace a_{2}\right\rbrace )\oplus \bigoplus\limits_{a_{2}=a_{2,1}\cup a_{2,2}} \big( \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace )\otimes \left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) \big) \Big) \bigg) \Bigg) \\
=& k_{s} \oplus \big(k_{s}\oplus (k_{s}\otimes k_{r_{1}}\otimes k_{r_{2}})\big)\\
=& k_{s}\oplus (k_{s}\otimes k_{r_{1}}\otimes k_{r_{2}}).
\end{align*}
\noindent In the Viterbi semiring for instance, we obtain the maximum weight between $k_{s}$ and $k_{s}\cdot k_{{r_1}}\cdot k_{r_{2}}$ for applying the Atomic Broadcast scheme in the system.
\
\noindent\underline{\textbf{Weighted Causality Chain}}: In a causality chain, if a message is received by receiver $wR_{i}$, then it has to be received by all receivers $wR_{j}$, for $j<i$. Thus, there are three possible interactions, namely $s, sr_{1}, sr_{1}r_{2}$. The $wAI(P)$ component describing the weighted Causality Chain is
$$z=s\otimes (1\oplus r_{1} \otimes (1\oplus r_{2})).$$
We let $\gamma=\left\lbrace \left\lbrace s \right\rbrace ,\left\lbrace s,r_{1}\right\rbrace , \left\lbrace s, r_{1}, r_{2}\right\rbrace \right\rbrace\in\Gamma(P) $. In order to compute the weight of $z$ on $\gamma$ we firstly obtain the weight of $z$ for $a=\left\lbrace s\right\rbrace \in \gamma $, derived in Table \ref{tab-caua}. Then, we compute the weight of $z$ for $a=\left\lbrace s,r_{1}\right\rbrace \in \gamma$, shown in Table \ref{tab-caub}, and finally, in Table \ref{tab-cauc} is derived the resulting weight for $a=\left\lbrace s,r_{1},r_{2}\right\rbrace \in \gamma$. For these computations we make use of the auxiliary Tables \ref{tab-cauc1}-\ref{tab-cauc8}.
\noindent Therefore, the weight for implementing the Causality Chain scheme on $\gamma$ is computed as follows:
\begin{align*}
&\big\|s\otimes \big(1\oplus r_{1} \otimes (1\oplus r_{2})\big)\big\|(\gamma)\\
=& \bigoplus\limits_{a \in \gamma } \Big( \bigoplus\limits_{a=a_{1}\cup a_{2}} \big( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \left\| 1\oplus r_{1} \otimes (1\oplus r_{2})\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \Big)\\
=& \bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \Big( \bigoplus\limits_{a' \in \left\lbrace a_{2}\right\rbrace } \big( \left\| 1\right\|(\left\lbrace a'\right\rbrace )\oplus \left\| r_{1} \otimes (1\oplus r_{2})\right\|(\left\lbrace a'\right\rbrace ) \big) \Big) \bigg) \Bigg)\\
=& \bigoplus\limits_{a \in \gamma } \bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \Big( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \big( \left\| 1\right\|(\left\lbrace a_{2}\right\rbrace )\oplus \left\|r_{1}\otimes (1\oplus r_{2})\right\|(\left\lbrace a_{2}\right\rbrace ) \big) \Big) \bigg) \\
=& \bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \Big( \left\| 1\right\|(\left\lbrace a_{2}\right\rbrace )\oplus \bigoplus\limits_{a'' \in \left\lbrace a_{2}\right\rbrace } \big( \bigoplus\limits_{a''=a_{2,1}\cup a_{2,2}} ( \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace )\otimes \\
& \left\| 1\oplus r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) ) \big) \Big) \bigg) \Bigg) \\
=& \bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \Big( \left\| 1\right\|(\left\lbrace a_{2}\right\rbrace )\oplus \bigoplus\limits_{a_{2}=a_{2,1}\cup a_{2,2}} \big( \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace )\otimes \\
& \left\| 1\oplus r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) \big) \Big) \bigg) \Bigg) \\
=& \bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \bigg( \left\| 1\right\|(\left\lbrace a_{2}\right\rbrace )\oplus \bigoplus\limits_{a_{2}=a_{2,1}\cup a_{2,2}} \Big( \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace )\otimes \\
& \Big(\bigoplus\limits_{a''' \in \left\lbrace a_{2,2}\right\rbrace } ( \left\| 1\right\|(\left\lbrace a'''\right\rbrace )\oplus \left\|r_{2}\right\|(\left\lbrace a'''\right\rbrace ) ) \Big) \Big) \bigg) \bigg) \Bigg)\\
=& \bigoplus\limits_{a \in \gamma } \Bigg( \bigoplus\limits_{a=a_{1}\cup a_{2}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )\otimes \Big( \left\| 1\right\|(\left\lbrace a_{2}\right\rbrace )\oplus \bigoplus\limits_{a_{2}=a_{2,1}\cup a_{2,2}} \big( \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace )\otimes \\
& ( \left\| 1\right\|(\left\lbrace a_{2,2}\right\rbrace )\oplus \left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) ) \big) \Big) \bigg) \Bigg)\\
=&k_{s} \oplus \big( k_{s} \oplus (k_{s} \otimes k_{r_{1}})\big) \oplus \big(k_{s} \oplus (k_{s} \otimes k_{r_{1}}) \oplus (k_{s} \otimes k_{r_{1}} \otimes k_{r_{2}})\big)\\
=& k_{s} \oplus (k_{s} \otimes k_{r_{1}}) \oplus (k_{s} \otimes k_{r_{1}} \otimes k_{r_{2}}).
\end{align*}
Consider for instance the $\mathbb{R}_{\mathrm{min}}$ semiring. Then the above value represents for weighted Causality Chain the minimum of the sum of the weights resulting from the corresponding analyses of $\gamma$.
\end{examp}
\hide{As we have already mentioned in the presented examples we arbitrarily selected the analysis of the derived $wAI(P)$ component $z$ in the corresponding $wAI(P)$ terms. In turn we computed the semantics of $z$ depending on that analysis. It should be clear that for any other analysis the resulting weight of $z$ does not alter. For instance, in the weighted Broadcast scheme formalized by the $wAI(P)$ component $z=s\otimes(1\oplus r_1)\otimes (1\oplus r_2)$ we obtained the semantics of the terms $s$ and $(1\oplus r_1)\otimes (1\oplus r_2)$. Another choice would be to consider the terms
$s\otimes(1\oplus r_1)$ and $(1\oplus r_2)$ or even the single term $s\otimes(1\oplus r_1)\otimes (1\oplus r_2)$. }
\hide{\textcolor{red}{Note that, the choice of $\gamma$ in the presented examples was such that it contained exactly the permissible interactions. Though, it should be clear that for any other choice of $\gamma$ the $wAI(P)$ returns the expected weight. Specifically, if there are faulty interactions $a_{faulty}$ in $\gamma$ the weight of $z$ on $\lbrace a_f\rbrace$ is zero, while if allowed interactions $a_{allowed}$ are also included in $\gamma$ then the weight of $z$ on $\lbrace a_{allowed} \rbrace$ is the required one, which indicates the robustness of the algebra.}}
\section{The Weighted Algebra of Connectors}\label{se5}
In this section, we introduce and investigate the weighted Algebra of Connectors over a set of ports and $K$, in order to formalize and compute the weight of components' coordination that involves triggers and synchrons. Synchronization requires that all of the involved components interact simultaneously. On the other hand, triggers express that a concrete component initiates the interactions with some of the rest components in the system. Synchrons and triggers result to Rendezvous and Broadcast components' coordination, respectively. \hide{For this, we firstly recall the Algebra of Connectors from \cite{Bl:Al}.
\underline{\textbf{Syntax}}: Let $P$ be a set of ports, such that $0,1 \notin P$. The syntax of the Algebra of Connectors over $P$ ($AC(P)$ for short) is defined by
$$s::= [0] \mid [1]\mid [p] \mid [x] \ \ \ (synchron)$$
$$t::= [0]' \mid [1]' \mid [p]' \mid [x]' \ \ \ (trigger)$$
$$x::= s \mid t \mid x\cdot x \mid x+x \mid (x)$$
where $p\in P$, ``+'' and ``$\cdot$'' are the union and fusion binary operators, respectively, and brackets ``$[\cdot]$'' and ``$[\cdot]'$'' are unary typing operators, respectively. \\
\par Union has the same meaning as in $AI(P)$, while fusion is a generalization of the synchronization operator in $AI(P)$. Typing serves to form typed connectors and specifically, ``$[\cdot]'$'' defines triggers which are responsible for initiating an interaction, while ``$[\cdot]$'' defines synchrons which need synchronization with other ports in order to interact. In order to simplify the notation, brackets are omitted from $0$, $1$, and ports $p\in P$, as well as ``$\cdot $'' is omitted for the fusion operator. Also, a term $x\in AC(P)$ is called monomial iff it does not involve any union operator. A typed connector with irrelevant type, synchron or trigger, is denoted by $[x]^{\ast}$.
\hide{\par The algebraic structure on $AC(P)$ inherits most of the axioms from $AI(P)$. However, associativity of fusion does not hold when typing is applied instead of simple grouping, that is, equality does not hold for any pair of $\left[ x_{1}\right] \left[ x_{2}\right] \left[ x_{3}\right] , \left[ x_{1}\right] \big[ \left[ x_{2}\right] \left[ x_{3}\right]\big],$ $ \big[ \left[ x_{1}\right] \left[ x_{2}\right] \big] \left[ x_{3}\right] $ for $x_{1}, x_{2}, x_{3} \in AC(P)$.}
\\
\hide{\begin{prof*}
This is a direct proof of axiom 3.d) by using mathematical induction. \qed
\end{prof*}}
\noindent Next we present the semantics of the Algebra of Connectors $AC(P)$. We recall from \cite{Bl:Al}, that by associativity of union and fusion, and distributivity of fusion over union, any element of $AC(P)$ can be uniquely rewritten in a form without parentheses. Moreover, we recall that fusion operator ``$\cdot$'' is commutative.\\ \\
\underline{\textbf{Semantics}}: Let $x$ be a $AC(P)$ connector over $P$ and $K$. The semantics of $x$ is a $AI(P)$ component defined by the function $g: AC(P) \to AΙ(P)$ as follows:
\begin{itemize}
\item $g(\left[p\right])=p $ for $p\in P\cup \left\lbrace 0,1\right\rbrace $,
\item $g(x_{1}+x_{2})=g(x_{1})+g(x_{2})$,
\item $g\left( \prod\limits_{i=1}^{n}\left[x_{i}\right]\right)=\prod\limits_{i=1}^{n}g(x_{i})$,
\item $g\left( \prod\limits_{i=1}^{n}\left[x_{i}\right]'\cdot \prod\limits_{j=1}^{m}\left[y_{j}\right] \right) =\sum\limits_{i=1}^{n} g(x_{i})\cdot \left( \prod\limits_{k\neq i} \Big(1+g(x_{k})\Big)\cdot \prod\limits_{j=1}^{m}\Big(1+g(y_{j})\Big)\right).$
\end{itemize}
Two connectors $x_{1}, x_{2}\in AC(P)$ are equivalent, denoted by $x_{1}\simeq x_{2}$, whenever they return the same $wAI(P)$ components, i.e., $x_{1}\simeq x_{2} \Leftrightarrow g(x_{1}) = g(x_{2}).$
\par Since the semantics of $AI(P)$ represent sets of interactions, the semantics of connectors also represent sets of interactions. Specifically, the so called interaction semantics of $AC(P)$ are given by $f\circ g: AC(P)\to \Gamma(P)$ which is defined by composing $g: AC(P)\to AI(P)$ and $f: AI(P)\to \Gamma(P)$, and hence represents sets of interactions.
\hide{\begin{prop}\label{unwsum}
Let $x,y\in AC(P)$. Then, the typing operator `` $[x]^{\ast}$'' satisfies the following equivalences, for any $\alpha, \beta \in \left\lbrace0,1 \right\rbrace $:
\begin{enumerate}[label=\alph*)]
\item $[0]\simeq[0]'$
\item $\big[[x]^{\alpha}\big]^{\beta}\simeq[x]^{\beta}$
\item $[x+y]^{\alpha}\simeq[x]^{\alpha}+[y]^{\alpha}$
\item $[x]' [y]'\simeq[x]' [y]+[x] [y]'.$
\end{enumerate}
\end{prop}
\begin{prof*} \hfill
\begin{enumerate}[label=\alph*)]
\item It holds
\begin{align*}
g(\left[ 0\right])=0 \ \text{and} \ g(\left[ 0\right]')=g(0)=0
\end{align*}
and hence we obtain the equivalence of $\left[0\right]$ and $\left[0\right]'$.
\item We consider the following four cases for $\alpha$ and $\beta$:
\begin{itemize}
\item If $\alpha=0$ and $\beta=0$, $g\left( \big[ \left[ x\right] \big] \right)= g\left( \left[ x \right] \right)=g(x) $ and $g\left( \left[ x \right] \right) = g(x) $.
\item If $\alpha=0$ and $\beta=1$, $g \left( \big[ \left[ x \right] \big] ^{'}\right) = g \left( \left[ x \right] \right) = g(x) $ and $g \left( \left[ x \right]^{'} \right) = g(x) $.
\item If $\alpha=1$ and $\beta=0$, $g \left( \big[ \left[ x\right]^{'} \big] \right) = g\left( \left[ x \right]^{'} \right) = g(x) $ and $g \left( \left[ x \right] \right) = g(x) $.
\item If $\alpha=1$ and $\beta=1$, $g \left( \big[ \left[ x\right]^{'} \big] ^{'}\right) = g\left( \left[ x \right]^{'} \right) = g(x) $ and $g \left( \left[ x \right]^{'} \right) = g(x) $.
\end{itemize}
In any case, we have $g\left( \big[ \left[ x\right] ^{\alpha}\big] ^{\beta}\right)=g \left( \left[ x\right] ^{\beta}\right)$ for any $\alpha, \beta\in \left\lbrace 0,1\right\rbrace $.
\item Analogously, we consider the following cases:
\begin{itemize}
\item If $\alpha=0$,
$$g\left( \left[ x+y\right] \right) = g(x+y) =g(x)+g(y)$$
and
$$g\left( \left[ x\right] + \left[y \right] \right) =g\left( \left[ x\right] \right) + g\left( \left[y \right] \right)=g(x)+g(y).$$
\item If $\alpha=1$,
$$g \left( \left[ x+y\right]^{'} \right) = g(x+y) =g(x)+g(y) $$
and
$$g\left( \left[ x\right]^{'} + \left[y \right]^{'} \right) =g\left( \left[x\right]^{'} \right) + g\left( \left[y \right]^{'} \right)=g(x)+g(y).$$
\end{itemize}
\item For this case we apply the result that $(AI(P), +, \cdot, 0,1)$ is a commutative and idempotent semiring. Then we have that
\begin{align*}
g\left( \left[ x\right]^{'} \left[ y\right]^{'}\right)=&g(x)\cdot \Big( 1+g(y)\Big) + g(y)\cdot \Big( 1+g(x)\Big)\\
=& g(x)+g(x)\cdot g(y)+g(y)+g(y)\cdot g(x)\\
=&g(x)+g(y)+g(x)\cdot g(y)
\end{align*}
and
\begin{align*}
g\left( \left[ x\right]^{'} \left[ y \right]+ \left[ x\right] \left[ y\right]^{'}\right) =&g\left( \left[ x\right]^{'} \left[ y \right] \right) + g\left( \left[ x\right] \left[ y\right]^{'} \right)\\
=&g(x)\cdot \Big( 1+g(y)\Big) + g(y)\cdot \Big(1 +g(x)\Big)\\
=& g(x)+g(x)\cdot g(y)+g(y)+g(y)\cdot g(x)\\
=&g(x)+g(y)+g(x)\cdot g(y).
\end{align*}
\end{enumerate}
Thus, our proof is completed. \qed
\end{prof*}}
\hide{
\par Next proposition refers to the application of fusion operator
on multiple trigger terms.
\begin{prop}
For an arbitrary family $\left\lbrace x_{i}\right\rbrace _{i=1}^{n}\in AC(P)$ the following equality holds:
$$\prod _{i=1}^{n}[x_{i}]'\simeq\sum_{i=1}^{n}\left([x_{i}]'\cdot \prod_{{\substack{j=1\\j\neq i}}}^{n} [x_{j}] \right). $$
\end{prop}
\begin{prof*}
It suffices to prove that
$$g\left( \prod _{i=1}^{n}[x_{i}]'\right) =g\left( \sum_{i=1}^{n}\left([x_{i}]'\cdot \prod_{{\substack{j=1\\j\neq i}}}^{n} [x_{j}] \right) \right).$$
For the first connector we have
$$g\left( \prod _{i=1}^{n}[x_{i}]'\right)=\sum\limits_{i=1}^{n} g(x_{i})\cdot \prod\limits_{\substack{j=1\\j\neq i}}^{n}\Big( 1+g(x_{j})\Big).$$
On the other hand,
$$g\left( \sum_{i=1}^{n}\left([x_{i}]'\cdot \prod_{\substack{j=1\\j\neq i}}^{n} [x_{j}] \right) \right)=\sum\limits_{i=1}^{n} g\left( [x_{i}]'\cdot \prod_{\substack{j=1\\j\neq i}}^{n} [x_{j}]\right)=\sum\limits_{i=1}^{n}g(x_{i})\cdot \prod\limits_{\substack{j=1\\j\neq i}}^{n}\Big( 1+g(x_{j})\Big),$$
which concludes our proof.\qed
\end{prof*}}}
\hide{ Next we introduce our weighted Algebra of Connectors over the commutative and idempotent semiring $K$.}
\begin{defin} Let $P$ be a set of ports, such that $0,1 \notin P$. The syntax of the weighted Algebra of Connectors ($wAC(P)$ for short) over $P$ and $K$ is given by
$$ \sigma ::=[0] \mid [1] \mid [p] \mid [\zeta] \ \ \ (synchron)$$
$$ \tau ::=[0]' \mid [1]' \mid [p]' \mid [\zeta]' \ \ \ (trigger)$$
$$ \zeta ::=\sigma \mid \tau \mid \zeta \oplus \zeta \mid \zeta \otimes \zeta $$
where $p\in P$, `` $\oplus$'' denotes the weighted union operator, `` $\otimes$'' denotes the weighted fusion operator, and `` $\left[ \cdot \right]$ '',`` $\left[ \cdot \right]'$ '' are the unary synchron and trigger typing operators, respectively.
\end{defin}
Although weighted union in $wAC(P)$ has the same meaning as weighted union in $wAI(P)$, weighted fusion is a generalization of weighted synchronization defined in $wAI(P)$. Also, typing is used to form typed connectors, specifically triggers, denoted by ``$\left[ \cdot \right]'$'', are responsible for initiating an interaction and synchrons, denoted by ``$\left[ \cdot \right] $'', need synchronization with other ports in order to interact.
\par We call $\zeta$ a $wAC(P)$ connector over $P$ and $K$. Whenever the latter are understood we simply refer to $\zeta$ as a $wAC(P)$ connector. Moreover, $\zeta$ is called a $wAC(P)$ monomial iff it does not involve any weighted union operator. We write $\left[ \zeta\right] ^{\alpha}$ for $\alpha\in \left\lbrace 0,1\right\rbrace $ to denote a typed $wAC(P)$ connector. When $\alpha=0$, the $wAC(P)$ connector is a synchron element, otherwise for $\alpha=1$ it is a trigger element. When the type is irrelevant we write $\left[ \cdot\right] ^{\ast}$. For $\zeta=\left[ \zeta_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes\left[ \zeta_{n}\right]^{\alpha_{n}}$, where $\zeta_{1}, \ldots, \zeta_{n}\in wAC(P)$ we denote by $\#_{T}\zeta$ the number of its trigger elements, which we call the degree of $\zeta$, and we denote by $\#_{S}\zeta$ the number of its synchron elements. Then, for $\zeta = \overset{n}{\underset{i=1}{\bigoplus}} \zeta_{i}$, where all $\zeta_{i}$ are of the above form, we let $\#_{T} \zeta = \mathrm{max} \left\lbrace \#_{T}\zeta_{i} \mid i \in [n]\right\rbrace $. We say that $\zeta$ has a strictly positive degree iff $\mathrm{min} \left\lbrace \#_{T}\zeta_{i} \mid i \in [n]\right\rbrace > 0$.
\par We interpret the semantics of $wAC(P)$ connectors as $wAI(P)$ components. In turn we obtain the weight of a $wAC(P)$ connector through the semantics of $wAI(P)$. The semantics of a $wAC(P)$ connector $\zeta$ over a set of ports $P$ and the semiring $K$ is defined by the function $\left| \cdot \right|: wAC(P) \to wAI(P)$, which is presented below in Definition \ref{connecttointer}.\hide{Therefore, the semantics of $\zeta$ are $wAI(P)$ components. In turn we can obtain the weight of $wAC(P)$ connectors through the semantics of $wAI(P)$.} For every $\zeta\in wAC(P)$ we firstly compute its $wAI(P)$ component $\left| \zeta\right|$ and then, applying the semantics of $wAI(P)$, we compute its weight over a set of interactions $\gamma \in \Gamma(P)$ by the polynomial $\big\| \left| \zeta \right| \big\|\in K \left\langle \Gamma(P)\right\rangle $.
\hide{\par We interpret the semantics of the weighted components $\zeta$ over the set of ports P and semiring K as polynomials $|\zeta| \in K\left\langle AC(P)\right\rangle $. }
\hide{\par Since the syntax of wAC(P) include terms $x\in AC(P)$, associativity of fusion does not hold when typing is applied instead of simple grouping. Namely, when the weighted components include typing terms, the weighted fusion operator is not associative.}
\begin{defin} \label{connecttointer}
Let $\zeta$ be a $wAC(P)$ connector over $P$ and $K$. The semantics of $\zeta$ is a $wAI(P)$ component defined by the function $\left|\cdot \right|: wAC(P) \to wAΙ(P)$ as follows:
\begin{itemize}
\renewcommand\labelitemi{--}
\item $\big|\left[ p\right]\big|=p$, for $p\in P\cup \left\lbrace 0,1\right\rbrace $,
\item $\big|\left[ p\right]'\big|=p$, for $p\in P\cup \left\lbrace 0,1\right\rbrace $,
\item $\left| \left[ \zeta \right] \right|=\left| \zeta \right|$,
\item $\big| \left[ \zeta \right] ' \big|=\left| \zeta \right|$,
\item $\left| \zeta_{1} \oplus \zeta_{2}\right| =\left| \zeta_{1}\right| \oplus \left| \zeta_{2}\right| $,
\item $\big| \left[ \zeta_{1}\right] \otimes \left[ \zeta_{2}\right] \big| = \left|\zeta_{1} \right| \otimes \left|\zeta_{2} \right|$,
\item $\big|\left[ \zeta_{1}\right]' \otimes \left[ \zeta_{2}\right]'\big|=\big(\left| \zeta_{1}\right| \otimes \left( 1\oplus \left|\zeta_{2} \right| \right)\big)\oplus \big(\left| \zeta_{2}\right| \otimes \left( 1\oplus \left|\zeta_{1} \right| \right)\big)$,
\item $\big| \left[ \zeta_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes\left[ \zeta_{n}\right]^{\alpha_{n}} \big| =\overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}}\Big(\left| \zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} \left( 1\oplus \left| \zeta_{k}\right| \right) \otimes \overset{}{\underset{\substack{j\in[n],\\\alpha_{j}=0}}{\bigotimes}} \left( 1\oplus \left| \zeta_{j}\right|\right) \Big) $, where $\#_{T}(\left[ \zeta_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes\left[ \zeta_{n}\right]^{\alpha_{n}})\neq 0$ and $\#_{S}(\left[ \zeta_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes\left[ \zeta_{n}\right]^{\alpha_{n}})\neq 0$.
\end{itemize}
\end{defin}
Obviously, we can extend the application of the weighted fusion operator between synchrons as well as the union operator, for more than two $wAC(P)$ connectors. Specifically for $\zeta_1,\ldots, \zeta_n \in wAC(P)$ it holds that $\Big| \overset{}{\underset{i\in [n]}{\otimes}}\left[ \zeta_{i}\right] \Big| = \overset{}{\underset{i\in [n]}{\otimes}} \left|\zeta_{i} \right| $ and $\Big| \overset{}{\underset{i\in [n]}{\oplus}} \zeta_{i}\Big|=\overset{}{\underset{i\in [n]}{\oplus}} \left|\zeta_{i} \right|$.
\par It should be clear that given a $\zeta\in wAC(P)$ in order to proceed the computations on $\left| \zeta \right| \in wAI(P)$ we need to consider the corresponding equivalent class and apply Corollary \ref{walg_semi}, i.e., the result that $(wAI(P)/\equiv, \oplus, \otimes, \bar{0}, \bar{1})$ is a commutative and idempotent semiring. Though, in order to simplify the notations in the rest of the paper we identify $\overline{\left|\zeta\right|}$ with the representative $\left|\zeta\right| $.
\par Next, for simplicity, brackets are omitted from $0$, $1$, and ports $p\in P$. For instance, we write $q\oplus r$ instead of $\left[ q\right]\oplus \left[ r \right]$, for some $q,r\in P$ which act as synchrons. Moreover, it is clear that in order to apply weighted fusion operation on connectors, a typing operator should be assigned on them. \hide{Next example clarifies the aforementioned remarks.
\begin{examp} Consider the ports $p,q,r\in P$. We apply weighted fusion operator on connectors $p$ and $q\oplus r$. For this, we need to specify a typing operator on them. We choose to synchronize the connectors $p$ and $q\oplus r$. Therefore, the resulting connector is $ \left[p \right]\otimes \left[ q\oplus r \right]$ and its $wAI(P)$ component is computed as follows:
\begin{align*}
\big| \left[p \right]\otimes \left[ q\oplus r \right] \big|=& \left| p\right| \otimes \left| q\oplus r \right|\\
=& \left| p\right| \otimes (\left| q\right| \oplus \left| r \right|)\\
=&p\otimes (q\oplus r).
\end{align*}
On the other hand, if we let $p$ serve as a trigger, then we obtain the connector $ \left[p \right]'\otimes \left[ q\oplus r \right]$. In turn, its $wAI(P)$ component is computed as follows:
\begin{align*}
\big| \left[p \right]'\otimes \left[ q\oplus r \right] \big|=& \left| p\right| \otimes (1\oplus \left| q\oplus r \right|)\\
=& \left| p\right| \otimes \big( 1\oplus (\left| q\right| \oplus \left| r \right|)\big)\\
=&p\otimes \big(1 \oplus (q\oplus r) \big)\\
=&p \otimes (1\oplus q\oplus r).
\end{align*}
\end{examp}}
\par Two connectors $\zeta_{1}, \zeta_{2}\in wAC(P)$ are equivalent, and we write $\zeta_{1}\equiv \zeta_{2}$ when $\left|\zeta_{1}\right| =\left|\zeta_{2}\right|$, i.e., when they return the same $wAI(P)$ components.
Obviously, this in turn implies that $\big\|\left|\zeta_{1}\right|\big\|(\gamma)=\big\|\left|\zeta_{2} \right|\big\|(\gamma)$ for every $\gamma \in \Gamma(P)$, i.e., equivalent connectors return the same weight on the same set of interactions $\gamma$. Clearly ``$\equiv$'' is an equivalence relation.
We define the quotient set $wAC(P) / \equiv$ of ``$\equiv$'' on $wAC(P)$. For every $\zeta\in wAC(P)$ we simply denote by $\overline{\zeta} $ its equivalence class. We define on $wAC(P)/\equiv$ the operations
\begin{equation*}\label{o5}
\overline{\zeta_{1}} \oplus \overline{\zeta_{2}}=\overline{\zeta_{1}\oplus \zeta_{2}} \tag{$O5$}
\end{equation*}
and
\begin{equation*}\label{o6}
\overline{[\zeta_{1}]^{\alpha}} \otimes \overline{[\zeta_{2}]^{\beta}}=\overline{[\zeta_{1}]^{\alpha}\otimes [\zeta_{2}]^{\beta}} \tag{$O6$}
\end{equation*}
for every $\zeta_{1}, \zeta_{2}\in wAC(P)$ and $\alpha, \beta \in \left\lbrace 0,1\right\rbrace $. The above two operations are well-defined. Hence, if $\overline{\zeta_{1}}=\overline{\zeta_{3}}$ and $\overline{\zeta_{2}}=\overline{\zeta_{4}}$, then we get that $\overline{\zeta_{1}} \oplus \overline{\zeta_{2}}=\overline{\zeta_{3}} \oplus \overline{\zeta_{4}}$ and $\overline{[\zeta_{1}]^{\alpha}} \otimes \overline{[\zeta_{2}]^{\beta}}=\overline{[\zeta_{3}]^{\alpha}} \otimes \overline{[\zeta_{4}]^{\beta}}$, for $\zeta_{1}, \zeta_{2}, \zeta_{3}, \zeta_{4} \in wAC(P)$ and $\alpha, \beta\in \left\lbrace 0,1\right\rbrace $.
\hide{
\par Let $\overline{\zeta_{1}}=\overline{\zeta_{3}}$ and $\overline{\zeta_{2}}=\overline{\zeta_{4}}$ which imply that $\left|\zeta_{1}\right|=\left|\zeta_{3}\right|$ and $\left|\zeta_{2}\right|=\left|\zeta_{4}\right|$, respectively. Then, we obtain that
\begin{align*}
\overline{\zeta_{1}}\oplus\overline{\zeta_{2}}=&\overline{\zeta_{1}\oplus \zeta_{2}}\\
=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \zeta_{1}\oplus \zeta_{2}\right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left|\zeta_{1}\oplus\zeta_{2}\right| \right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left|\zeta_{1}\right|\oplus\left|\zeta_{2}\right| \right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left|\zeta_{3}\right|\oplus\left|\zeta_{4}\right| \right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left|\zeta_{3}\oplus\zeta_{4}\right| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \zeta_{3}\oplus \zeta_{4}\right\rbrace\\
=&\overline{\zeta_{3}\oplus \zeta_{4}}\\
=&\overline{\zeta_{3}}\oplus\overline{\zeta_{4}}.
\end{align*}
For the second operation ``$\otimes$'' we have to consider four cases, i.e., for $\alpha=0$ and $\beta=0$, $\alpha=1$ and $\beta=0$, $\alpha=0$ and $\beta=1$, $\alpha=1$ and $\beta=1$. We consider the proof for the last case, whilst the rest of the cases are obtained similarly.
\begin{itemize}
\hide{\item If $\alpha=0$ and $\beta=0$, then \begin{align*}
\overline{[\zeta_{1}]}\otimes\overline{[\zeta_{2}]}=&\overline{[\zeta_{1}]\otimes [\zeta_{2}]}\\
=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv [\zeta_{1}]\otimes [\zeta_{2}]\right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big|[\zeta_{1}]\otimes [\zeta_{2}]\big| \right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left|\zeta_{1}\right|\otimes\left|\zeta_{2}\right| \right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left|\zeta_{3}\right|\otimes\left|\zeta_{4}\right| \right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big|[\zeta_{3}]\otimes[\zeta_{4}]\big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv [\zeta_{3}]\otimes [\zeta_{4}]\right\rbrace\\ =&\overline{[\zeta_{3}]\otimes [\zeta_{4}]}\\
=&\overline{[\zeta_{3}]}\otimes\overline{[\zeta_{4}]}.
\end{align*}
\item If $\alpha=1$ and $\beta=0$, then \begin{align*}
\overline{[\zeta_{1}]'}\otimes\overline{[\zeta_{2}]}=&\overline{[\zeta_{1}]'\otimes [\zeta_{2}]}\\
=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv [\zeta_{1}]'\otimes [\zeta_{2}]\right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big|[\zeta_{1}]'\otimes [\zeta_{2}]\big| \right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left|\zeta_{1}\right|\otimes(1\oplus \left|\zeta_{2}\right| )\right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left|\zeta_{3}\right|\otimes(1\oplus \left|\zeta_{4}\right|) \right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big|[\zeta_{3}]'\otimes[\zeta_{4}]\big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv [\zeta_{3}]'\otimes [\zeta_{4}]\right\rbrace\\
=&\overline{[\zeta_{3}]'\otimes [\zeta_{4}]}\\
=&\overline{[\zeta_{3}]'}\otimes\overline{[\zeta_{4}]}.
\end{align*}
\item If $\alpha=0$ and $\beta=1$, then \begin{align*}
\overline{[\zeta_{1}]}\otimes\overline{[\zeta_{2}]'}=&\overline{[\zeta_{1}]\otimes [\zeta_{2}]'}\\
=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv [\zeta_{1}]\otimes [\zeta_{2}]'\right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big|[\zeta_{1}]\otimes [\zeta_{2}]'\big| \right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left|\zeta_{2}\right|\otimes(1\oplus \left|\zeta_{1}\right|) \right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left|\zeta_{4}\right|\otimes(1\oplus \left|\zeta_{3}\right|) \right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big|[\zeta_{3}]\otimes[\zeta_{4}]'\big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv [\zeta_{3}]\otimes [\zeta_{4}]'\right\rbrace\\
=&\overline{[\zeta_{3}]\otimes [\zeta_{4}]'}\\
=&\overline{[\zeta_{3}]}\otimes\overline{[\zeta_{4}]'}.
\end{align*}}
\item Let $\alpha=1$ and $\beta=1$. Then, \begin{align*}
\overline{[\zeta_{1}]'}\otimes\overline{[\zeta_{2}]'}=&\overline{[\zeta_{1}]'\otimes [\zeta_{2}]'}\\
=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv [\zeta_{1}]'\otimes [\zeta_{2}]'\right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big|[\zeta_{1}]'\otimes [\zeta_{2}]'\big| \right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big(\left|\zeta_{1}\right|\otimes (1\oplus \left|\zeta_{2}\right|)\big)\oplus \big(\left|\zeta_{2}\right|\otimes(1\oplus \left|\zeta_{1}\right|)\big) \right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big(\left|\zeta_{3}\right|\otimes (1\oplus \left|\zeta_{4}\right|)\big)\oplus \big(\left|\zeta_{4}\right|\otimes(1\oplus \left|\zeta_{3}\right|)\big) \right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big|[\zeta_{3}]'\otimes[\zeta_{4}]'\big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv [\zeta_{3}]'\otimes [\zeta_{4}]'\right\rbrace\\
=&\overline{[\zeta_{3}]'\otimes [\zeta_{4}]'}\\
=&\overline{[\zeta_{3}]'}\otimes\overline{[\zeta_{4}]'}.
\end{align*}
\end{itemize}
Thus, we have proved that the operations \eqref{o5} and \eqref{o6} are well-defined. }
\par Next we state that connector $[1]$ is the neutral element of weighted fusion operation ``$\otimes$'' over the quotient set $wAC(P)/ \equiv$. The proof of the proposition is direct.
\begin{prop}
Let $\zeta_{1} \in wAC(P)$ and $\alpha\in \left\lbrace 0,1\right\rbrace $. Then,
$$\overline{\left[\zeta_{1}\right]^{\alpha}} \otimes \overline{\left[ 1\right]} = \overline{\left[\zeta_{1}\right]^{\alpha}}=\overline{\left[ 1\right]}\otimes \overline{\left[\zeta_{1}\right]^{\alpha}}.$$
\end{prop}
\hide{\begin{prof*}
We consider the following cases:
\begin{itemize}
\item[$\bullet$] If $\alpha=0$, then
\begin{itemize}
\renewcommand\labelitemi{--}
\item[--] $\begin{aligned}[t]
\overline{\left[ \zeta_{1} \right]} \otimes \overline{\left[ 1\right]}= \overline{\left[\zeta_{1}\right]\otimes \left[1\right]}=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[\zeta_{1}\right]\otimes \left[1\right]\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \big|\left[\zeta_{1}\right]\otimes \left[1\right]\big|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right|\otimes \left|1\right|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right|\otimes 1\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right|\right\rbrace
\end{aligned}$
\vspace{3mm}
\item[--] $\begin{aligned}[t]
\overline{\left[ \zeta_{1} \right]} =&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[\zeta_{1}\right]\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \big|\left[\zeta_{1}\right] \big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right|\right\rbrace
\end{aligned}$
\vspace{3mm}
\item[--] $\begin{aligned}[t]
\overline{\left[ 1\right]}\otimes\overline{\left[ \zeta_{1} \right]} = \overline{ \left[1\right]\otimes\left[\zeta_{1}\right]}=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[1\right]\otimes\left[\zeta_{1}\right] \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \big|\left[1\right]\otimes \left[\zeta_{1}\right] \big|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left|1\right|\otimes \left|\zeta_{1}\right| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= 1\otimes \left|\zeta_{1}\right|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right|\right\rbrace .
\end{aligned}$
\end{itemize}
\item[$\bullet$] If $\alpha=1$, then
\begin{itemize}
\item[--] $\begin{aligned}[t]
\overline{\left[ \zeta_{1} \right]'} \otimes \overline{\left[ 1\right]}= \overline{\left[\zeta_{1}\right]'\otimes \left[1\right]}=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[\zeta_{1}\right]'\otimes \left[1\right]\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \big|\left[\zeta_{1}\right]'\otimes \left[1\right]\big|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right|\otimes (1 \oplus \left|1\right|)\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right|\otimes (1\oplus 1)\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right|\otimes 1\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right|\right\rbrace
\end{aligned}$
\vspace{3mm}
\item[--] $\begin{aligned}[t]
\overline{\left[ \zeta_{1} \right]'} =&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[\zeta_{1}\right]'\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \big|\left[\zeta_{1}\right]'\big|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right|\right\rbrace
\end{aligned}$
\vspace{3mm}
\item[--] $\begin{aligned}[t]
\overline{\left[ 1\right]}\otimes\overline{\left[ \zeta_{1} \right]'} = \overline{\left[1\right]\otimes \left[\zeta_{1}\right]'}=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[1\right]\otimes\left[\zeta_{1}\right]' \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \big|\left[1\right]\otimes\left[\zeta_{1}\right]' \big|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right|\otimes (1 \oplus \left|1\right|)\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right|\otimes (1\oplus 1)\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right|\otimes 1\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right|\right\rbrace ,
\end{aligned}$
\end{itemize}
\end{itemize}
and we are done. \qed
\end{prof*}}
\noindent In the following proposition we show that $wAC(P)$ satisfies the associativity property of weighted fusion when a specific type, synchron or trigger, is applied for simple grouping.
\begin{prop}\label{assoc}
Let $\zeta_{1}, \zeta_{2}, \zeta_{3}\in wAC(P)$. Then,
\begin{enumerate}[label=\roman*)]
\item $\overline{\big[\left[ \zeta_{1} \right]\otimes \left[ \zeta_{2} \right]\big]}\otimes \overline{\left[ \zeta_{3} \right]} =\overline{\left[ \zeta_{1} \right] }\otimes \overline{\big[\left[ \zeta_{2} \right]\otimes \left[ \zeta_{3} \right]\big]} \label{synch-assoc}$
\item $\overline{\big[\left[ \zeta_{1} \right]'\otimes \left[ \zeta_{2} \right]'\big]'}\otimes \overline{\left[ \zeta_{3} \right]'} =\overline{\left[ \zeta_{1} \right]' }\otimes \overline{\big[\left[ \zeta_{2} \right]'\otimes \left[ \zeta_{3} \right]'\big]'}.\label{trig-assoc}$
\end{enumerate}
\end{prop}
\begin{prof*}
In order to prove the above equalities we apply Corollary \ref{walg_semi}.
\begin{enumerate}[label=\roman*)]
\item We compute the left part of the first equality as follows:
\begin{align*}
&\overline{\big[\left[ \zeta_{1} \right]\otimes \left[ \zeta_{2} \right]\big]}\otimes \overline{\left[ \zeta_{3} \right]} =\overline{\big[\left[\zeta_{1}\right]\otimes\left[\zeta_{2}\right]\big]\otimes \left[\zeta_{3}\right]}\\
=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \big[\left[\zeta_{1}\right]\otimes \left[\zeta_{2}\right]\big]\otimes \left[\zeta_{3}\right]\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \Big|\big[\left[\zeta_{1}\right]\otimes \left[\zeta_{2}\right]\big]\otimes \left[\zeta_{3}\right] \Big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \big| \left[ \zeta_{1}\right] \otimes \left[ \zeta_{2}\right]\big| \otimes \big| \zeta_{3} \big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big( \left| \zeta_{1}\right| \otimes \left| \zeta_{2}\right|\big) \otimes \left| \zeta_{3} \right| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left| \zeta_{1}\right| \otimes \left| \zeta_{2}\right| \otimes \left| \zeta_{3} \right| \right\rbrace
\end{align*}
\noindent Now, we compute the right part of the first equality as follows:
\begin{align*}
&\overline{\left[ \zeta_{1} \right] }\otimes \overline{\big[\left[ \zeta_{2} \right]\otimes \left[ \zeta_{3} \right]\big]} =\overline{\left[\zeta_{1}\right]\otimes\big[\left[\zeta_{2}\right]\otimes \left[\zeta_{3}\right]\big]}\\
=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[\zeta_{1}\right]\otimes \big[\left[\zeta_{2}\right]\otimes \left[\zeta_{3}\right]\big]\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \Big|\left[\zeta_{1}\right]\otimes\big[ \left[\zeta_{2}\right]\otimes \left[\zeta_{3}\right]\big] \Big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left| \zeta_{1}\right| \otimes \big|\left[ \zeta_{2}\right] \otimes \left[ \zeta_{3} \right] \big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left| \zeta_{1}\right| \otimes \big(\left| \zeta_{2}\right| \otimes \left| \zeta_{3} \right|\big) \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left| \zeta_{1}\right| \otimes \left| \zeta_{2}\right| \otimes \left| \zeta_{3} \right| \right\rbrace.
\end{align*}
\noindent Consequently, $\overline{\big[\left[ \zeta_{1} \right]\otimes \left[ \zeta_{2} \right]\big]}\otimes \overline{\left[ \zeta_{3} \right]} $ and $\overline{\left[ \zeta_{1} \right] }\otimes \overline{\big[\left[ \zeta_{2} \right]\otimes \left[ \zeta_{3} \right]\big]} $ are equal.
\item For the leftmost part of the second equality we have:
\begin{align*}
&\overline{\big[\left[ \zeta_{1} \right]'\otimes \left[ \zeta_{2} \right]'\big]'}\otimes \overline{\left[ \zeta_{3} \right]'} =\overline{\big[\left[\zeta_{1}\right]'\otimes\left[\zeta_{2}\right]'\big]'\otimes \left[\zeta_{3}\right]'}\\
=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \big[\left[\zeta_{1}\right]'\otimes \left[\zeta_{2}\right]'\big]'\otimes \left[\zeta_{3}\right]'\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\Big| \big[ \left[ \zeta_{1}\right]'\otimes \left[ \zeta_{2}\right]'\big]' \otimes \left[ \zeta_{3}\right]' \Big|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \Big(\big| \left[ \zeta_{1}\right]'\otimes \left[ \zeta_{2}\right]' \big|\otimes (1\oplus \left| \zeta_{3}\right|) \Big) \oplus \Big( \left| \zeta_{3}\right| \otimes \big( 1\oplus \big| \left[ \zeta_{1}\right]'\otimes \left[ \zeta_{2}\right]' \big| \big)\Big)\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \bigg(\Big(\big( \left| \zeta_{1}\right| \otimes (1 \oplus \left| \zeta_{2}\right| )\big)\oplus \big(\left| \zeta_{2}\right| \otimes (1 \oplus \left| \zeta_{1}\right| ) \big) \Big)\otimes (1\oplus \left| \zeta_{3}\right|)\bigg) \oplus\right.\\
&\left.\bigg( \left|\zeta_{3} \right|\otimes \Big( 1\oplus \big(\left| \zeta_{1}\right| \otimes (1 \oplus \left| \zeta_{2}\right| )\big)\oplus \big(\left| \zeta_{2}\right| \otimes (1 \oplus \left| \zeta_{1}\right| )\big) \Big)\bigg)\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \bigg(\Big( \left|\zeta_{1}\right| \oplus (\left| \zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \oplus \left|\zeta_{2}\right|\oplus (\left| \zeta_{2}\right|\otimes \left|\zeta_{1}\right|) \Big)\otimes (1\oplus \left| \zeta_{3}\right|) \bigg)\oplus \right. \\
&\left. \bigg(\left| \zeta_{3}\right| \otimes \Big( 1\oplus \left|\zeta_{1}\right| \oplus (\left| \zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \oplus \left|\zeta_{2}\right|\oplus (\left| \zeta_{2}\right|\otimes \left|\zeta_{1}\right|) \Big)\bigg)\right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\bigg(\Big( \left|\zeta_{1}\right| \oplus \left| \zeta_{2}\right|\oplus (\left| \zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \Big)\otimes (1\oplus \left| \zeta_{3}\right|)\bigg) \oplus \right.\\
&\left. \bigg(\left| \zeta_{3}\right| \otimes \Big( 1 \oplus \left|\zeta_{1}\right| \oplus \left| \zeta_{2}\right|\oplus (\left| \zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \Big)\bigg)\right\rbrace \\
=& \Big\{ \zeta\in wAC(P) \mid \left|\zeta\right|=\Big(\left|\zeta_{1}\right| \oplus \left| \zeta_{2}\right|\oplus (\left| \zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{3}\right|) \oplus (\left| \zeta_{2}\right|\otimes \left|\zeta_{3}\right|)\oplus \\
& (\left| \zeta_{1}\right| \otimes \left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|) \Big)\oplus \Big( \left|\zeta_{3}\right|\oplus (\left|\zeta_{3}\right|\otimes \left|\zeta_{1}\right|) \oplus (\left|\zeta_{3}\right|\otimes \left|\zeta_{2}\right|) \oplus (\left|\zeta_{3}\right|\otimes \left| \zeta_{1}\right| \otimes \left|\zeta_{2}\right|)\Big)\Big\} \\
=&\big\{ \zeta\in wAC(P) \mid \left|\zeta\right|=\left|\zeta_{1}\right| \oplus \left| \zeta_{2}\right|\oplus \left| \zeta_{3}\right| \oplus (\left| \zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{3}\right|) \oplus \\
& (\left|\zeta_{2}\right| \otimes \left| \zeta_{3}\right|) \oplus (\left| \zeta_{1}\right| \otimes \left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|) \big\}.
\end{align*}
\noindent Finally, for the rightmost part in the second equality we have:
\begin{align*}
&\overline{\left[ \zeta_{1} \right]'} \otimes \overline{\big[\left[ \zeta_{2} \right]'\otimes \left[ \zeta_{3} \right]'\big]'} =\overline{\left[\zeta_{1}\right]'\otimes\big[\left[\zeta_{2}\right]'\otimes \left[\zeta_{3}\right]'\big]'}\\
=&\left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[\zeta_{1}\right]'\otimes\big[\left[\zeta_{2}\right]'\otimes \left[\zeta_{3}\right]'\big]'\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\Big| \left[ \zeta_{1}\right]'\otimes \big[\left[ \zeta_{2}\right]' \otimes \left[ \zeta_{3}\right]'\big]' \Big|\right\rbrace \\
=&\Big\{ \zeta\in wAC(P) \mid \left|\zeta\right|=\Big(\left| \zeta_{1}\right|\otimes \big( 1\oplus \big|\left[ \zeta_{2}\right]' \otimes \left[ \zeta_{3}\right]'\big|\big)\Big) \oplus \Big( \big| \left[ \zeta_{2}\right]' \otimes \left[ \zeta_{3}\right]'\big| \otimes \big( 1\oplus \left|\zeta_{1}\right| \big)\Big)\Big\} \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\bigg(\left| \zeta_{1}\right| \otimes \Big(1 \oplus \big(\left| \zeta_{2}\right|\otimes (1\oplus \left|\zeta_{3}\right|)\big) \oplus \big(\left| \zeta_{3}\right|\otimes (1\oplus \left|\zeta_{2}\right|)\big)\Big) \bigg) \oplus\right.\\
&\left.\bigg( \Big(\big(\left| \zeta_{2}\right|\otimes (1\oplus \left|\zeta_{3}\right|)\big) \oplus \big( \left| \zeta_{3}\right|\otimes (1\oplus \left|\zeta_{2}\right|)\big)\Big) \otimes \big( 1\oplus \left|\zeta_{1}\right| \big)\bigg)\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\bigg( \left|\zeta_{1}\right| \otimes \Big( 1\oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|) \oplus \left|\zeta_{3}\right| \oplus (\left|\zeta_{3}\right|\otimes \left|\zeta_{2}\right|) \Big)\bigg) \oplus\right.\\
&\left. \bigg(\Big( \left|\zeta_{2}\right| \oplus (\left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|) \oplus \left|\zeta_{3}\right| \oplus (\left|\zeta_{3}\right|\otimes \left|\zeta_{2}\right|) \Big) \otimes \big( 1\oplus \left|\zeta_{1}\right| \big)\bigg)\right\rbrace \\
=& \left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\bigg(\left|\zeta_{1}\right| \otimes \Big( 1\oplus \left|\zeta_{2}\right| \oplus \left|\zeta_{3}\right| \oplus (\left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|) \Big)\bigg) \oplus \right.\\
& \left. \bigg(\Big( \left|\zeta_{2}\right| \oplus \left|\zeta_{3}\right| \oplus (\left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|) \Big) \otimes \big( 1\oplus \left|\zeta_{1}\right| \big)\bigg)\right\rbrace \\
=& \Big\{ \zeta\in wAC(P) \mid \left|\zeta\right|=\Big(\left|\zeta_{1}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{3}\right|) \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|)\Big) \oplus \\
&\Big( \left|\zeta_{2}\right| \oplus \left|\zeta_{3}\right| \oplus (\left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|) \oplus (\left|\zeta_{2}\right|\otimes \left|\zeta_{1}\right|) \oplus (\left|\zeta_{3}\right|\otimes \left|\zeta_{1}\right|) \oplus (\left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|\otimes \left|\zeta_{1}\right|)\Big)\Big\} \\
=& \big\{ \zeta\in wAC(P) \mid \left|\zeta\right|= \left|\zeta_{1}\right| \oplus \left| \zeta_{2}\right|\oplus \left| \zeta_{3}\right| \oplus (\left| \zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{3}\right|) \oplus \\
& (\left|\zeta_{2}\right| \otimes \left| \zeta_{3}\right|) \oplus (\left| \zeta_{1}\right| \otimes \left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|)\big\}.
\end{align*}
\end{enumerate}
\noindent Hence, $\overline{\big[\left[ \zeta_{1} \right]'\otimes \left[ \zeta_{2} \right]'\big]'}\otimes \overline{\left[ \zeta_{3} \right]'}$ and $ \overline{\left[ \zeta_{1} \right]' }\otimes \overline{\big[\left[ \zeta_{2} \right]'\otimes \left[ \zeta_{3} \right]'\big]'}$ are equal.\qed
\end{prof*}
\hide{\begin{examp}
Consider three weighted connectors $\zeta_{1}=\left[ p\right]', \zeta_{2}=\left[ q \right]', \zeta_{3}=\left[ r \right]$. We show that the following components
$$\big[\left[ p\right]'\otimes \left[ q \right]'\big]\otimes \left[ r \right] \hspace{10mm}\left[ p\right]'\otimes \left[ q \right]'\otimes \left[ r \right] \hspace{10mm} \left[ p\right]'\otimes \big[\left[ q \right]'\otimes \left[ r \right]\big]$$
are not equivalent, i.e., that they do not satisfy the associativity property of weighted fusion.
Applying the semantics for the first weighted term we obtain
\begin{align*}
\Big| \big[\left[ p\right]'\otimes \left[ q \right]'\big]\otimes \left[ r \right] \Big|=& \Big| \left[ p\right]'\otimes \left[ q \right]'\Big| \otimes \left| r \right|\\
=& \Big( \left|p\right| \otimes (1\oplus \left| q\right|) \oplus \left|q\right| \otimes (1\oplus \left| p\right|)\Big)\otimes \left|r\right|\\
=& \big( p\otimes (1\oplus q) \oplus q \otimes (1\oplus p)\big)\otimes r\\
=& \big( p\oplus p\otimes q\oplus q \oplus q\otimes p \big) \otimes r\\
=& (p\oplus q\oplus p\otimes q) \otimes r\\
=&p\otimes r\oplus q\otimes r\oplus p\otimes q\otimes r
\end{align*}
The semantics for the second weighted connector are computed as follows:
\begin{align*}
\Big|\left[ p\right]'\otimes \left[ q \right]'\otimes \left[ r \right]\Big|=& \left| p\right| \otimes \big( 1\oplus \left| q\right|\big) \otimes \big( 1\oplus \left| r\right| \big) \oplus \left| q\right| \otimes \big( 1\oplus \left| p\right|\big) \otimes \big( 1\oplus \left| r\right| \big)\\
=& p \otimes ( 1\oplus q) \otimes ( 1\oplus r ) \oplus q \otimes ( 1\oplus p) \otimes ( 1\oplus r )\\
=& p\otimes (1\oplus q\oplus r\oplus q\otimes r)\oplus q\otimes (1\oplus p\oplus r\oplus p\otimes r)\\
=& p\oplus p\otimes q\oplus p\otimes r\oplus p\otimes q\otimes r \oplus q\oplus q\otimes p\oplus q\otimes r\oplus q\otimes p\otimes r\\
=& p\oplus q\oplus p\otimes q\oplus p\otimes r\oplus q\otimes r\oplus p\otimes q\otimes r
\end{align*}
For the third weighted component we have
\begin{align*}
\Big| \left[ p\right]'\otimes \big[\left[ q \right]'\otimes \left[ r \right]\big]\Big|=& \left|p\right| \otimes \Big( 1\oplus \big|\left[ q \right]'\otimes \left[ r \right]\big| \Big)\\
=& \left| p\right| \otimes \Big( 1\oplus \left|q\right| \otimes \big( 1\oplus \left| r\right|\big) \Big) \\
=& p \otimes \Big( 1\oplus q \otimes \big( 1\oplus r\big) \Big)\\
=& p\otimes (1\oplus q\oplus q\otimes r)\\
=&p\oplus p\otimes q\oplus p\otimes q\otimes r
\end{align*}
Hence, we get that $\big[\left[ p\right]'\otimes \left[ q \right]'\big]\otimes \left[ r \right] \centernot{\simeq}\left[ p\right]'\otimes \left[ q \right]'\otimes \left[ r \right] \centernot{\simeq} \left[ p\right]'\otimes \big[\left[ q \right]'\otimes \left[ r \right]\big]$.
\end{examp}}
\vspace{5mm} \noindent Next proposition is useful for simplifying the computation of the semantics for some of the $wAC(P)/\equiv$ elements.
\hide{\par In order to prove the following proposition we use the fact that $(wAI(P)/\equiv, \oplus, \otimes, \bar{0}, \bar{1})$ is a commutative and idempotent semiring.}
\begin{prop}\label{propos3}
Let $\zeta_{1}, \zeta_{2} \in wAC(P)$ and $\alpha, \beta\in \left\lbrace 0,1\right\rbrace $. Then,
\begin{enumerate}[label=\alph*)]
\item $\overline{\big[ \left[ \zeta_{1}\right] ^{\alpha}\big] ^{\beta}} = \overline{\left[ \zeta_{1}\right] ^{\beta}}\label{eq-two-types}$ \label{itm:propos3a}
\item $\overline{\left[ \zeta_{1}\oplus \zeta_{2}\right] ^{\alpha}} = \overline{\left[ \zeta_{1}\right] ^{\alpha}}\oplus \overline{\left[ \zeta_{2} \right] ^{\alpha}}$\label{itm:propos3b}
\item \label{com-union}$\overline{\left[ \zeta_{1}\right] ^{\alpha}} \oplus \overline{\left[ \zeta_{2}\right] ^{\beta}} = \overline{\left[ \zeta_{2}\right] ^{\beta}} \oplus \overline{\left[ \zeta_{1}\right] ^{\alpha}}$
\item \label{com-fusion} $\overline{\left[ \zeta_{1}\right] ^{\alpha}} \otimes \overline{\left[ \zeta_{2}\right] ^{\beta}} = \overline{\left[ \zeta_{2}\right] ^{\beta}} \otimes \overline{\left[ \zeta_{1}\right] ^{\alpha}}.$
\end{enumerate}
\end{prop}
\begin{prof*}
We apply Corollary \ref{walg_semi} and we compute the equivalent classes of the involved connectors.
\end{prof*}
Now, we define an updated version of weighted component-based systems where in comparison to the one in Definition \ref{comp-system-wAI(P)}, we replace the $wAI(P)$ component $z$ with the $wAC(P)$ connector $\zeta$.
\begin{defin}
A weighted component-based system is a pair $(w\mathcal{B}, \zeta)$ where $w\mathcal{B} = \left\lbrace wB_{i} \mid i \in \left[ n \right]\right\rbrace $ is a set of weighted components and $\zeta$ is a $wAC(P)$ connector over $P=\bigcup_{i\in [n]} P_{i}$ and $K$.
\end{defin}
\hide{\begin{prof*}
We prove the properties as follows:
\begin{enumerate}[label=\alph*)]
\item We consider the following cases:
\begin{itemize}
\item If $\alpha=0$ and $\beta=0$, then
\begin{align*}
\overline{\big[ \left[ \zeta_{1}\right] \big] }=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \big[ \left[ \zeta_{1}\right] \big]\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left| \big[ \left[ \zeta_{1}\right] \big] \right|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \big| \left[ \zeta_{1} \right] \big|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left| \zeta_{1}\right|\right\rbrace
\end{align*}
and
\begin{align*}
\overline{ \left[ \zeta_{1}\right] }=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[ \zeta_{1}\right] \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left| \left[ \zeta_{1}\right] \right|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left| \zeta_{1}\right|\right\rbrace .
\end{align*}
\item If $\alpha=0$ and $\beta=1$, then
\begin{align*}
\overline{\big[ \left[ \zeta_{1}\right] \big]' }=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \big[ \left[ \zeta_{1}\right] \big]'\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left| \big[ \left[ \zeta_{1}\right] \big]' \right|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \big| \left[ \zeta_{1} \right] \big|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left| \zeta_{1}\right|\right\rbrace
\end{align*}
and
\begin{align*}
\overline{ \left[ \zeta_{1}\right]' }=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[ \zeta_{1}\right]' \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left| \left[ \zeta_{1}\right] ' \right|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left| \zeta_{1}\right|\right\rbrace .
\end{align*}
\item If $\alpha=1$ and $\beta=0$, then \begin{align*}
\overline{\big[ \left[ \zeta_{1}\right]' \big] }=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \big[ \left[ \zeta_{1}\right]' \big]\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left| \big[ \left[ \zeta_{1}\right]' \big] \right|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \big| \left[ \zeta_{1} \right]' \big|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left| \zeta_{1}\right|\right\rbrace
\end{align*}
and
\begin{align*}
\overline{ \left[ \zeta_{1}\right] }=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[ \zeta_{1}\right] \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left| \left[ \zeta_{1}\right] \right|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left| \zeta_{1}\right|\right\rbrace .
\end{align*}
\item If $\alpha=1$ and $\beta=1$, then \begin{align*}
\overline{\big[ \left[ \zeta_{1}\right]' \big]' }=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \big[ \left[ \zeta_{1}\right]' \big]'\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left| \big[ \left[ \zeta_{1}\right]' \big]' \right|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \big| \left[ \zeta_{1} \right]' \big|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left| \zeta_{1}\right|\right\rbrace
\end{align*}
and
\begin{align*}
\overline{ \left[ \zeta_{1}\right]' }=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[ \zeta_{1}\right]' \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left| \left[ \zeta_{1}\right] ' \right|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left| \zeta_{1}\right|\right\rbrace .
\end{align*}
\end{itemize}
Therefore, for any $\alpha, \beta\in \left\lbrace 0,1\right\rbrace $, we proved that $\overline{\big[ \left[ \zeta_{1}\right] ^{\alpha}\big] ^{\beta}} = \overline{\left[ \zeta_{1}\right] ^{\beta}}$.
\item We consider the following two cases:
\begin{itemize}
\item If $\alpha=0$, then
\begin{align*}
\overline{\left[ \zeta_{1}\oplus \zeta_{2}\right]}=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[ \zeta_{1}\oplus \zeta_{2}\right]\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big| \left[ \zeta_{1}\oplus \zeta_{2}\right] \big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left| \zeta_{1} \oplus \zeta_{2} \right| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left| \zeta_{1}\right| \oplus \left| \zeta_{2}\right| \right\rbrace
\end{align*}
and
\begin{align*}
\overline{\left[ \zeta_{1}\right] \oplus \left[\zeta_{2} \right]}=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[ \zeta_{1}\right] \oplus \left[\zeta_{2} \right]\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big| \left[ \zeta_{1}\right] \oplus \left[\zeta_{2} \right] \big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \big| \left[ \zeta_{1}\right] \big| \oplus \big|\left[\zeta_{2} \right] \big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left| \zeta_{1}\right| \oplus \left| \zeta_{2}\right| \right\rbrace.
\end{align*}
\item If $\alpha=1$, then \begin{align*}
\overline{\left[ \zeta_{1}\oplus \zeta_{2}\right]'}=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[ \zeta_{1}\oplus \zeta_{2}\right]'\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big| \left[ \zeta_{1}\oplus \zeta_{2}\right]' \big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \left| \zeta_{1} \oplus \zeta_{2} \right| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left| \zeta_{1}\right| \oplus \left| \zeta_{2}\right| \right\rbrace
\end{align*}
and
\begin{align*}
\overline{\left[ \zeta_{1}\right]' \oplus \left[\zeta_{2} \right]'}=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[ \zeta_{1}\right]' \oplus \left[\zeta_{2} \right]'\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big| \left[ \zeta_{1}\right]' \oplus \left[\zeta_{2} \right]'\big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|= \big| \left[ \zeta_{1}\right]' \big| \oplus \big|\left[\zeta_{2} \right]' \big| \right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left| \zeta_{1}\right| \oplus \left| \zeta_{2}\right| \right\rbrace.
\end{align*}
\end{itemize}
Hence, $\overline{\left[ \zeta_{1}\oplus \zeta_{2}\right] ^{\alpha}} = \overline{\left[ \zeta_{1}\right] ^{\alpha}}\oplus \overline{\left[ \zeta_{2} \right] ^{\alpha}}$ for $\alpha \in \left\lbrace 0,1\right\rbrace .$\qed
\end{enumerate}
\end{prof*}}
\hide{Observe that by Proposition \ref{propos3}.$\ref{eq-two-types}$, when we apply two typing operators successively on a given weighted connector, we maintain only the last one. For instance, if $\alpha=1$ and $\beta=0$, then we have that $\overline{\big[ \left[ \zeta_{1}\right] ^{'}\big]}= \overline{\left[\zeta_{1}\right]} $ which implies that when a synchron is applied to a trigger, we in turn obtain a synchron weighted connector.}
\hide{\begin{prop}
Let $\zeta_{1}, \zeta_{2}, \zeta_{3}\in wAC(P)$. Then
\begin{enumerate}[label=\roman*)]
\item $(\zeta_{1}\oplus \zeta_{2}) \oplus \zeta_{3}\simeq \zeta_{1}\oplus (\zeta_{2}\oplus \zeta_{3})$
\item $\zeta_{1}\oplus \zeta_{2}\simeq \zeta_{2}\oplus \zeta_{1}$
\item $\zeta\oplus \zeta\simeq \zeta$
\item $\zeta\oplus 0\simeq \zeta$
\item $(\zeta_{1}\otimes\zeta_{2})\otimes\zeta_{3}\simeq\zeta_{1}\otimes (\zeta_{2}\otimes \zeta_{3})$
\item $\zeta_{1}\otimes \zeta_{2}\simeq \zeta_{2}\otimes \zeta_{1}$
\item $\zeta\otimes 1\simeq \zeta$
\item $\zeta\otimes 0\simeq 0$
\item $\zeta_{1}\otimes (\zeta_{2}\oplus \zeta_{3})\simeq \zeta_{1}\otimes \zeta_{2}\oplus \zeta_{1}\otimes \zeta_{3}.$
\end{enumerate}
\end{prop}}
\hide{\color{red}\par Next we define the notion of soundness for $wAC(P)$ and we then show that the axiomatization of $wAC(P)$ is sound.
\begin{defin}
Let $\zeta \in wAC(P)$ and $\Sigma=\left\lbrace \zeta_{1},\ldots, \zeta_{n}\right\rbrace $ with $\zeta_{1}, \ldots \zeta_{n} \in wAC(P)$. We say that $\Sigma$ \emph{proves} $\zeta$ and write $\Sigma \vdash \zeta$ if $\zeta$ is derived from the formulas in $\Sigma$. Furthermore, we write $\Sigma \models \zeta$ iff for every $\gamma \in \underset{1\leqslant i\leqslant n}{\cap}supp(\zeta_{i})$ such that $\left|\zeta_{1}\right|(\gamma)=\ldots=\left|\zeta_{n}\right|(\gamma)$, then $\left|\zeta\right|(\gamma)=\ldots=\left|\zeta_{1}\right|(\gamma)$. Then we say that $wAC(P)$ is \emph{sound} if $\Sigma\vdash \zeta$ implies $\Sigma\models \zeta$.
\end{defin}
\begin{prop}
The axiomatization of $wAC(P)$ is sound, that is, for $\zeta_{1}, \zeta_{2}\in wAC(P)$,
$$\zeta_{1}=\zeta_{2} \Rightarrow \left|\zeta_{1}\right|=\left|\zeta_{2}\right|.$$
\end{prop}
\begin{prof*}
For an axiom $\zeta_{1}=\zeta_{2}$ and an arbitrary $\zeta \in wAC(P)$ we have to verify that $\left|\zeta_{1}\otimes\zeta\right|=\left|\zeta_{2}\otimes\zeta\right|$. In order to prove this proposition we have to verify that all of the axioms preserve the semantics in any weighted fusion context. However, it is sufficient to verify this property only for monomial $\zeta$.\\
Let $\zeta_{1}=p, \zeta_{2}=q, \zeta=r$ and we suppose that $\zeta_{1}=\zeta_{2}$. Then $$\left|\zeta_{1}\otimes \zeta\right|=\left|p\otimes r\right|=\left|p\right|\otimes \left|r\right|=p\otimes r=q\otimes r=\left|q\right|\otimes \left|r\right|=\left|q\otimes r\right|=\left|\zeta_{2}\otimes \zeta\right|.$$
The above relation is proved by induction for every monomial term and in turn for every $wAC(P)$ term, which completes our proof. \qed
\end{prof*}
\color{black}}
\par Next we present five examples of weighted connectors formalized in $wAC(P)$ over $K$. We apply the semantics of $wAC(P)$ and in turn, computing the semantics of the respective $wAI(P)$ components, we are able to derive the weight of implementing each $wAC(P)$ connector for a given set of interactions. In the subsequent figures, we use triangles and circles to represent the types triggers and synchrons, respectively.
\par We should note that $wAC(P)$ is defined over an arbitrary set of ports $P$. However, in the following examples, we are interested in applying the algebra on the set of ports $P$ associated with the given set of weighted components.
\par Recall that in the previous section we investigated four coordination schemes in the weighted setup. Now we present the $wAC(P)$ connectors that return the $wAI(P)$ components of those schemes.
\begin{examp}\label{eq2}
\begin{figure}[H]
\begin{minipage}[b]{0.45\linewidth}
\centering
\includegraphics[scale=1.7]{Figure4a.png}
\subcaption{Weighted Rendezvous}
\label{fig:f3a}
\end{minipage}
\begin{minipage}[b]{0.45\linewidth}
\centering
\includegraphics[scale=1.7]{Figure4b.png}
\subcaption{Weighted Broadcast}
\label{fig:f3b}
\end{minipage}
\begin{minipage}[b]{0.45\linewidth}
\centering
\includegraphics[scale=1.7]{Figure4c.png}
\subcaption{Weighted Atomic Broadcast}
\label{fig:f3c}
\end{minipage}
\hspace{11mm}
\begin{minipage}[b]{0.45\linewidth}
\centering
\includegraphics[scale=1.7]{Figure4d.png}
\subcaption{Weighted Causality Chain}
\label{fig:f3d}
\end{minipage}
\caption{The $wAC(P)$ connectors of four coordination schemes.}
\label{fig4}
\end{figure}
We present the $wAC(P)$ connectors of the coordination schemes Rendezvous, Broadcast, Atomic Broadcast and Causality Chain, in the weighted setup, described in Example \ref{eq:4}. Recall that we considered the set $w\mathcal{B}=\left\lbrace wS,wR_{1},wR_{2}\right\rbrace $ of three weighted components, namely a sender $wS$ and two receivers $wR_{1}$ and $wR_{2}$ (see Figure \ref{eq:4}). The ports of the latter were $s, r_1,r_2$, i.e., $P=\left\lbrace s,r_1,r_2\right\rbrace $, and we denoted their weights by $k_{s}, k_{r_{1}}, k_{r_{2}}$, respectively.\\ \\
\noindent\underline{\textbf{Weighted Rendezvous}}: The $wAC(P)$ connector for weighted Rendezvous, shown in Figure \ref{fig:f3a}, is given by
$$[s]\otimes [r_{1}]\otimes [r_{2}].$$ The connector does not involve any trigger typing operator, and we obtain its $wAI(P)$ component as follows:
\begin{align*}
\big| [s]\otimes [r_{1}]\otimes [r_{2}]\big|=&\left|s\right|\otimes\left|r_{1}\right|\otimes\left|r_{2}\right|\\
=&s\otimes r_{1}\otimes r_{2}.
\end{align*}
The weight of the above $wAI(P)$ component was computed in the corresponding part of Example \ref{eq:4}, and we showed that it equals to $k_{s}\otimes k_{r_{1}}\otimes k_{r_{2}}$. \hide{In particular, we derived the cost of implementing the connector over the fuzzy semiring $F$.} \\ \\
\noindent\underline{\textbf{Weighted Broadcast}}: The $wAC(P)$ connector for weighted Broadcast is
$$\left[s\right]'\otimes \left[r_{1}\right]\otimes [r_{2}].$$
The connector is depicted in Figure \ref{fig:f3b} and involves the trigger $\left[s\right]'$ which can initiate the interaction with the synchrons $[r_{1}], [r_{2}]$. We compute the weight of the above connector for a concrete set of interactions by applying the semantics of the $wAC(P)$. For this, we firstly obtain the $wAI(P)$ component computed as follows:
\begin{align*}
\left|\left[s\right]'\otimes \left[r_{1}\right]\otimes [r_{2}]\right|=&\left|s\right|\otimes (1\oplus \left|r_{1}\right|)\otimes (1\oplus \left|r_{2}\right|)\\
=&s\otimes (1\oplus r_{1})\otimes (1\oplus r_{2}).
\end{align*}
Then, the weight of the latter was obtained in the weighted Broadcast scheme of Example \ref{eq:4}, and it was computed equal to $k_{s}\oplus (k_{s}\otimes k_{r_{1}})\oplus (k_{s}\otimes k_{r_{2}})\oplus (k_{s}\otimes k_{r_{1}}\otimes k_{r_{2}})$. \hide{Moreover, we derived the weight of this component in $\mathbb{R}_{\mathrm{max}}$ semiring.}\\ \\
\noindent\underline{\textbf{Weighted Atomic Broadcast}}: We consider the $wAC(P)$ connector
$$[s]'\otimes \big[ [r_{1}]\otimes [r_{2}]\big]$$
shown in Figure \ref{fig:f3c}. The connector involves a trigger $[s]'$ and a synchron $\big[ [r_{1}]\otimes [r_{2}]\big]$. The $wAI(P)$ component of the connector corresponds to the weighted Atomic Broadcast scheme, and is obtained as follows:
\begin{align*}
\big| [s]'\otimes \big[ [r_{1}]\otimes [r_{2}]\big] \big|=& \big|s\big| \otimes \Big(1 \oplus \big| [r_{1}]\otimes [r_{2}] \big|\Big)\\
=& \left|s\right|\otimes \big(1\oplus \left|r_{1}\right|\otimes \left|r_{2}\right|\big)\\
=& s\otimes (1\oplus r_{1}\otimes r_{2}).
\end{align*}
The weight of the above component was computed in the corresponding scheme presented in Example \ref{eq:4}, and equals to $k_{s}\oplus (k_{s}\otimes k_{{r_1}}\otimes k_{r_{2}})$. \hide{Also, we interpreted the resulting cost over the fuzzy semiring $F$.}\\ \\
\noindent\underline{\textbf{Weighted Causality Chain}}: The $wAC(P)$ connector for weighted Causality Chain scheme, shown in Figure \ref{fig:f3d}, is
$$[s]'\otimes \big[ [r_{1}]'\otimes [r_{2}]\big].$$
The $wAI(P)$ component of the above connector is computed as follows:
\begin{align*}
\bigg| [s]'\otimes \big[ [r_{1}]'\otimes [r_{2}]\big] \bigg|=&\left|s\right|\otimes \Big(1 \oplus \big| [r_{1}]'\otimes [r_{2}] \big| \Big)\\
=& \left|s\right|\otimes \big(1 \oplus \left|r_{1}\right|\otimes ( 1\oplus \left| r_{2}\right|) \big)\\
=& s\otimes \big(1 \oplus r_{1}\otimes ( 1\oplus r_{2}) \big).
\end{align*}
The weight of the above $wAI(P)$ component was obtained in Example \ref{eq:4}, and equals to $k_{s}\oplus (k_{s}\otimes k_{r_{1}}) \oplus (k_{s}\otimes k_{r_{1}} \otimes k_{r_{2}})$.\hide{ Also, we computed the weight of the connector over the $\mathbb{R}_{\mathrm{min}}$ semiring.}
\end{examp}
\hide{
\par In the sequel, we provide a further example that shows how we can construct incrementally the weighted Broadcast connector presented in Example \ref{eq2}.
\begin{figure}[H]
\centering
\includegraphics[scale=1.6]{Figure6.png}
\caption{Weighted Broadcast connector.}
\label{f6-geo}
\end{figure}
\begin{examp}\label{eq3}
The weighted Broadcast connector of Example \ref{eq2} can be constructed incrementally in the following way. In particular, we can start from the weighted connector
$$[s]'\otimes [r_{1}]$$
for which we have that
$$\big|[s]'\otimes [r_{1}]\big|=\left|s\right|\otimes (1\oplus \left|r_{1}\right|).$$
By typing this weighted connector as a trigger and adding the synchron $[r_{2}]$, we obtain the weighted connector
$$\big[ [s]'\otimes [r_{1}]\big] ' \otimes [r_{2}]$$
shown in Figure \ref{f6-geo}, and we have
$$\Big| \big[ [s]'\otimes [r_{1}]\big] ' \otimes [r_{2}]\Big| =\big|[s]'\otimes [r_{1}]\big|\otimes (1\oplus \left|r_{2}\right|)=\left|s\right|\otimes (1\oplus \left|r_{1}\right|)\otimes (1\oplus \left|r_{2}\right|).$$
Hence, we obtained the same $wAI(P)$ component as in weighted Broadcast scheme of Example \ref{eq2}, and we conclude that the connectors
\begin{center}
$\left[s\right]'\otimes \left[r_{1}\right]\otimes [r_{2}]$ and $\big[ [s]'\otimes [r_{1}]\big] ' \otimes [r_{2}]$
\end{center}
are equivalent.
\hide{\par We now compute the weight of the Broadcast connector through its $wAI(P)$ component over the semiring $\mathbb{R}_{\mathrm{min}}=(\mathbb{R}_{+}\cup \left\lbrace \infty \right\rbrace,\mathrm{min},+,\infty,0 )$ for a set of interactions $\gamma\in\Gamma(P)$. Then, the resulting value represents for the above connector the minimum weight of the total cost on the corresponding analyses of $\gamma$. In particular, we have
\begin{align*}
&\big\|s\otimes (1\oplus r_{1})\otimes (1\oplus r_{2}) \big\|(\gamma)\\
=& \underset{a \in \gamma }{\mathrm{min}} \Bigg( \underset{a=a_{1}\cup a_{2}}{\mathrm{min}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+ \underset{a_{2}=a_{2,1}\cup a_{2,2}}{\mathrm{min}}\Big( \mathrm{min} \big(\left\|1\right\|(\left\lbrace a_{2,1}\right\rbrace ), \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace ) \big) + \\
& \mathrm{min}\big( \left\|1\right\|(\left\lbrace a_{2,2}\right\rbrace ), \left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace )\big)\Big) \bigg) \Bigg)\\
=&\underset{a \in \gamma }{\mathrm{min}} \Bigg( \underset{a=a_{1}\cup a_{2}}{\mathrm{min}} \bigg( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+ \underset{a_{2}=a_{2,1}\cup a_{2,2}}{\mathrm{min}}\Big( \mathrm{min} \big(\left\|1\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|1\right\|(\left\lbrace a_{2,2}\right\rbrace ),\\
& \left\|1\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ), \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace ) +\left\|1\right\|(\left\lbrace a_{2,2}\right\rbrace ), \left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace )+\\
&\left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) \big) \Big) \bigg) \Bigg)\\
=&\underset{a \in \gamma }{\mathrm{min}} \Bigg( \underset{a=a_{1}\cup a_{2}}{\mathrm{min}} \bigg( \underset{a_{2}=a_{2,1}\cup a_{2,2}}{\mathrm{min}}\Big( \mathrm{min} \big( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+ \left\|1\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|1\right\|(\left\lbrace a_{2,2}\right\rbrace ),\\
& \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+\left\|1\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ), \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+\left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace ) +\left\|1\right\|(\left\lbrace a_{2,2}\right\rbrace ),\\
& \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+\left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) \big) \Big) \bigg) \Bigg)\\
=&\underset{a \in \gamma }{\mathrm{min}} \bigg( \underset{a=a_{1}\cup a_{2,1}\cup a_{2,2}}{\mathrm{min}} \Big( \mathrm{min} \big( \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+ \left\|1\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|1\right\|(\left\lbrace a_{2,2}\right\rbrace ), \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+\\
&\left\|1\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ), \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+\left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace ) +\left\|1\right\|(\left\lbrace a_{2,2}\right\rbrace ), \left\|s\right\|(\left\lbrace a_{1}\right\rbrace )+\\
&\left\|r_{1}\right\|(\left\lbrace a_{2,1}\right\rbrace )+\left\|r_{2}\right\|(\left\lbrace a_{2,2}\right\rbrace ) \big) \Big) \bigg) .
\end{align*}}
\end{examp}
\hide{\noindent Next we present another weighted connector that is equivalent to the connectors of the two previous examples.
\begin{examp}
Consider the weighted connector
$$\big[ [s]'\otimes [r_{1}]\big] '\otimes \big[ [r_{2}]'\otimes [r_{3}]'\big]. $$
The corresponding $wAI(P)$ component is obtained as follows:
\begin{align*}
&\Big| \big[ [s]'\otimes [r_{1}]\big] '\otimes \big[ [r_{2}]'\otimes [r_{3}]'\big]\Big| \\
=& \big|[s]'\otimes [r_{1}]\big|\otimes \big(1\oplus \big| [r_{2}]'\otimes [r_{3}]' \big| \big)\\
=&\left|s\right|\otimes (1\oplus \left|r_{1}\right|)\otimes \big(1\oplus \left|r_{2}\right|\otimes (1\oplus \left|r_{3}\right|) \oplus \left|r_{3}\right|\otimes (1\oplus \left|r_{2}\right|)\big)\\
=&s\otimes (1\oplus r_{1})\otimes (1\oplus r_{2}\otimes (1\oplus r_{3}) \oplus r_{3}\otimes (1\oplus r_{2}))\\
=&s\otimes (1\oplus r_{1})\otimes (1\oplus r_{2} \oplus r_{2}\otimes r_{3} \oplus r_{3} \oplus r_{3}\otimes r_{2})\\
=&s\otimes (1\oplus r_{1})\otimes (1\oplus r_{2} \oplus r_{2}\otimes r_{3} \oplus r_{3} \oplus r_{2}\otimes r_{3})\\
=&s\otimes (1\oplus r_{1})\otimes (1\oplus r_{2} \oplus r_{2}\otimes r_{3} \oplus r_{3})\\
=&s\otimes (1\oplus r_{1})\otimes (1\oplus r_{2})\otimes (1\oplus r_{3})
\end{align*}
where the sixth and the seventh equality hold since $(wAI(P), \oplus, \otimes, 0,1)$ is a commutative and idempotent semiring, respectively. Finally, the last equality results from the fact that $(wAI(P),\oplus, \otimes, 0,1)$ is a semiring and hence weighted synchronization distributes over weighted union.
\par Obviously, the resulting $wAI(P)$ component is identical to the one computed in Examples \ref{eq2} and \ref{eq3}. Hence, we get that the weighted connectors of all the three examples return the same sets of interactions and therefore are equivalent.
\par We consider the fuzzy semiring $F=(\left[ 0,1\right] ,\mathrm{max}, \mathrm{min}, 0,1)$ where $\gamma=\left\lbrace \left\lbrace s\right\rbrace , \left\lbrace s,r_{1}\right\rbrace ,\right.$ $\left. \left\lbrace s,r_{2}\right\rbrace , \left\lbrace s,r_{3}\right\rbrace , \left\lbrace s,r_{1},r_{2}\right\rbrace , \left\lbrace s,r_{1},r_{3}\right\rbrace ,\left\lbrace s,r_{2},r_{3}\right\rbrace ,\left\lbrace s,r_{1}, r_{2},r_{3} \right\rbrace \right\rbrace\in \Gamma(P)$. We compute the minimum weight on the resulting sets of interactions of $\gamma$, presented in Table \ref{tab:tab3} of Example \ref{eq:4}, as follows:
\begin{align*}
&\big\|s\otimes (1\oplus r_{1})\otimes (1\oplus r_{2}) \otimes (1\oplus r_{3})\big\|(\gamma)\\
=& \mathrm{min}\bigg(\left\|s\right\|(\gamma_{1}),\mathrm{max} \Big(\left\|1\right\|(\gamma_{2,1,1}), \left\|r_{1}\right\|(\gamma_{2,1,2})\Big),\mathrm{max}\Big(\left\|1\right\|(\gamma_{2,2,1,1}), \left\|r_{2}\right\|(\gamma_{2,2,1,2})\Big),\\
&\mathrm{max}\Big(\left\|1\right\|(\gamma_{2,2,2,1}), \left\|r_{3}\right\|(\gamma_{2,2,2,2})\Big)\bigg)\\
=& \mathrm{min}\Big(k_{s},\mathrm{max} \big(1, k_{r_{1}}\big),\mathrm{max}\big(1, k_{r_{2}}\big),\mathrm{max}\big(1, k_{r_{3}}\big)\Big)=\mathrm{min} \big(k_{s},1,1,1\big)=k_{s}.
\end{align*}
\end{examp}}}
\section{Weighted subalgebras}\label{se6}
Next we present two subalgebras of $wAC(P)$, namely the weighted Algebra of Synchrons and the weighted Algebra of Triggers over $P$ and $K$, and consider their properties. The former algebra restricts to synchrons, while the latter involves only triggers.\hide{We conclude the section by discussing the relation among the four presented algebras, i.e., among $wAI(P), wAC(P)$, and the two subalgebras.}
\subsection{The Weighted Algebra of Synchrons}\label{se6-1}
Let $P$ be a set of ports. We consider the subalgebra of $wAC(P)$
generated by restricting its syntax to synchrons. The resulting algebra over $P$ and $K$ is called weighted Algebra of Synchrons, and is denoted by
$wAS(P)$.
\begin{defin}
Given a set of ports $P$, the syntax of the weighted Algebra of Synchrons ($wAS(P)$ for short) over $P$ and $K$ is defined by:
$$\sigma::= [0] \mid [1]\mid [p] \mid [\zeta]$$
$$\zeta::=\sigma\mid \zeta \oplus \zeta \mid \zeta \otimes \zeta $$
where $p\in P$, $\sigma$ denotes a synchron element, and $\zeta\in wAS(P)$.
\end{defin}
The weighted operators ``$\oplus$'' and ``$\otimes$'' are the weighted union operator and the weighted fusion operator, respectively, from the syntax of the $wAC(P)$. Obviously, we get that Proposition \ref{assoc}\ref{synch-assoc}, which was proved in the previous section, holds for $wAS(P)$. Hence, the subalgebra satisfies the associativity property of weighted fusion with respect to the synchron typing operator. Furthermore, $wAS(P)$ satisfies Proposition \ref{propos3} for $\alpha=0$ and $\beta=0$.
\hide{\par Observe that by dropping the brackets in the elements of $wAS(P)$ we obtain an isomorphism with $wAI(P)$\hide{, since both algebras of weighted terms satisfy associativity property}. Particularly, the function $\left| \cdot \right|:wAS(P)\to wAI(P)$ where $\big|\left[ \zeta \right]\big|=\left| \zeta\right|$, is obviously a bijection and satisfies the properties of homomorphism function. Specifically, by the definition of semantics of the algebra we have
$$\big| \left[ \zeta_{1}\right]\oplus \left[ \zeta_{2}\right] \big|=\big|\left[\zeta_{1}\right]\big|\oplus \big|\left[ \zeta_{2}\right]\big|$$
and
$$\big| \left[ \zeta_{1}\right]\otimes \left[\zeta_{2}\right] \big|=\left|\zeta_{1}\right|\otimes \left| \zeta_{2}\right|=\big| \left[ \zeta_{1}\right] \big|\otimes \big|\left[ \zeta_{2}\right]\big|$$
for every $\zeta_{1},\zeta_{2}\in wAS(P)$.}
\subsection{The Weighted Algebra of Triggers}\label{se6-2}
Let $P$ be a set of ports. We now consider the subalgebra of $wAC(P)$ generated by restricting its syntax to triggers. The resulting algebra over $P$ and $K$ is called weighted Algebra of Triggers and is denoted by $wAT(P)$.
\begin{defin} Given a set of ports $P$, the syntax of the weighted Algebra of Triggers ($wAT(P)$ for short) over $P$ and $K$ is defined by:
$$\tau::= [0]' \mid [1]'\mid [p]' \mid [\zeta]'$$
$$\zeta::=\tau \mid \zeta \oplus \zeta \mid \zeta \otimes \zeta $$
where $p\in P$, $\tau$ denotes a trigger element, and $\zeta\in wAT(P)$.
\end{defin}
The operators ``$\oplus$'' and ``$\otimes$'' are the weighted union and the weighted fusion operator, respectively, from the syntax of the $wAC(P)$. Moreover, by Proposition \ref{assoc}\ref{trig-assoc} of the previous section we obtain that $wAT(P)$ satisfies the associativity property of weighted fusion with respect to trigger typing operator. Furthermore, $wAT(P)$ satisfies Proposition \ref{propos3} for $\alpha=1$ and $\beta=1$.
\par Assume now that we restrict the equivalence relation ``$\equiv$'' defined in $wAC(P)$ (cf. Section \ref{se5}) only to the trigger elements, i.e., to $\zeta\in wAT(P)$. Hence, we denote by $wAT(P)/\equiv$ the quotient set of ``$\equiv$'' on $wAT(P)$. Then, we obtain that $\overline{ \left[ \zeta\right]' }\otimes \overline{[0'] '}=\overline{\left[ \zeta\right]' }=\overline{ [0']' }\otimes \overline{\left[ \zeta\right] '}$ for $\zeta\in wAT(P)$, i.e., connector $[0']'$ serves as the neutral element for the weighted fusion operator in $wAT(P)$.
\hide{
Indeed, we have
\begin{itemize}
\item $\begin{aligned}[t]
\overline{ \left[ \zeta_{1}\right]' }\otimes \overline{\left[ 0\right] '}=& \overline{\left[ \zeta_{1}\right]' \otimes \left[ 0\right] '}\\
=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[ \zeta_{1}\right]' \otimes \left[ 0\right] '\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big| \left[\zeta_{1}\right]'\otimes [0]'\big|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big(\left|\zeta_{1}\right| \otimes (1\oplus \left|0\right|)\big)\oplus \big(\left|0\right|\otimes (1\oplus \left| \zeta_{1}\right|)\big)\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big(\left|\zeta_{1}\right| \otimes (1\oplus 0)\big)\oplus \big(0\otimes (1\oplus \left| \zeta_{1}\right|)\big)\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left|\zeta_{1}\right|\right\rbrace
\end{aligned}$
\item $\begin{aligned}[t]
\overline{ \left[ 0\right]' }\otimes \overline{\left[ \zeta_{1}\right] '}=& \overline{\left[ 0\right]' \otimes \left[ \zeta_{1}\right] '}\\
=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[ 0\right]' \otimes \left[ \zeta_{1}\right] '\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big| \left[0\right]'\otimes \left[\zeta_{1}\right]'\big|\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big(\left|0\right| \otimes (1\oplus \left|\zeta_{1}\right|)\big)\oplus \big(\left|\zeta_{1}\right|\otimes (1\oplus \left| 0\right|)\big)\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big(0 \otimes (1\oplus \left|\zeta_{1}\right|)\big)\oplus \big(\left|\zeta_{1}\right|\otimes (1\oplus 0)\big)\right\rbrace \\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left|\zeta_{1}\right|\right\rbrace
\end{aligned}$
\item $\begin{aligned}[t]
\overline{\left[ \zeta_{1}\right]' }
=& \left\lbrace \zeta\in wAC(P) \mid \zeta \equiv \left[ \zeta_{1}\right]' \right\rbrace\\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\big|\left[\zeta_{1}\right]'\big|\right\rbrace\\
=&\left\lbrace \zeta\in wAC(P) \mid \left|\zeta\right|=\left|\zeta_{1}\right|\right\rbrace
\end{aligned}$
\end{itemize}
that is, $\overline{ \left[ \zeta_{1}\right]' }\otimes \overline{0'}=\overline{\left[ \zeta_{1}\right]' }=\overline{ 0' }\otimes \overline{\left[ \zeta_{1}\right] '}$ for every $\zeta_{1}\in wAT(P)$. Observe that in the above computations we obtain the required result since $(wAI(P)/ \equiv, \oplus, \otimes, \bar{0}, \bar{1})$ is a commutative and idempotent semiring.}
\hide{\begin{figure}[H]
\centering
\includegraphics[scale=0.7]{Fig3-Geo.png}
\caption{Hierarchy of weighted algebras}
\label{f3-geo}
\end{figure}}
\par Recall that the $wAC(P)$ connector $[1]$ served as the neutral element of weighted fusion in $wAC(P)$. It should be clear though, that by construction, the weighted Algebra of Triggers does not contain $[1]$, and hence weighted fusion loses its neutral element. However, using the equivalent classes defined in $wAC(P)$, $[0']'$ can serve as an alternative neutral element, as we stated above. A similar issue occurred in the work of \cite{Bl:Al}. In turn, the authors introduced a congruence relation for connectors which in contrast to equivalence relation, allowed them to use the connectors interchangeably within a system, without causing undesirable alterations. Congruence relation is important in general because it allows one to use different connectors interchangeably within a system, without causing undesirable alterations. In the next section, we introduce and study a notion of congruence relation for weighted connectors encoded in $wAC(P)$. In turn, we prove two theorems that ensure congruence between two given $wAC(P)$ connectors. \hide{Moreover, by direct application of our second theorem we obtain an alternative way for checking that $[0']'$ is the neutral element for weighted fusion operator in $wAT(P)$.}
\section{Weighted congruence relation}\label{se7}
In Section \ref{se5} we defined the semantics of a connector $\zeta\in wAC(P)$ as a component $z\in wAI(P)$. Then, the semantics of the latter was interpreted as a polynomial $\left\|z\right\|\in K\left\langle \Gamma(P)\right\rangle $. Moreover, we stated that two weighted connectors $\zeta_1,\zeta_2 \in wAC(P)$ are equivalent, i.e., $\zeta_{1}\equiv \zeta_{2}$ when $\left|\zeta_{1}\right| =\left|\zeta_{2}\right|$. By the semantics of $wAI(P)$ this implied that $\big\|\left|\zeta_{1}\right|\big\|(\gamma)=\big\|\left|\zeta_{2} \right|\big\|(\gamma)$ for every $\gamma\in \Gamma(P)$, i.e., equivalent connectors return the same weight on the same set of interactions.
\par However, as we show in the sequel, it occurs that two equivalent $wAC(P)$ connectors are not in general interchangeable in any expression. Therefore, an important question is when we can replace a weighted connector with an alternative one. This actually leads to the notion of weighted congruence relation that we introduce and study in this section. In particular, our first theorem shows that similarly typed equivalent $wAC(P)$ connectors are weighted congruent, and our second theorem provides us with a method for proving weighted congruence relation between two $wAC(P)$ connectors. \hide{Moreover, applying directly the latter theorem we get an alternative proof that $[0']'$ serves as the neutral element for the weighted fusion operator in the subalgebra of triggers $wAT(P)$.}
\par By the following example we show that two equivalent connectors cannot always be substituted for one another.
\begin{examp}
Consider the set of ports $P =\left\lbrace p, q\right\rbrace $ with weights $k_{p}, k_{q}$, respectively. It can be easily verified that the $wAC(P)$ connectors $[p]'$ and $[p]$ are equivalent, i.e., $[p]'\equiv [p]$. In order to prove the equivalence, we compute the $wAI(P)$ components of the above connectors and we have $\big|[p]'\big|=p$ and $\big|[p]\big|=p.$
\par On the other hand, we show that the $wAC(P)$ connectors $\left[p\right]'\otimes \left[ q\right]$ and $\left[p\right]\otimes \left[ q\right]$ are not equivalent. Indeed, the $wAI(P)$ components of the above connectors are $\big| \left[ p \right]'\otimes \left[ q \right] \big|=\left| p \right|\otimes (1\oplus \left| q \right|)=p\otimes (1\oplus q)=p\oplus (p\otimes q)$ and $\big|[p]\otimes [q]\big|=\left| p \right|\otimes \left| q \right|=p\otimes q$, respectively.
We let $\gamma = \left\lbrace \left\lbrace p,q\right\rbrace \right\rbrace\in \Gamma(P) $. Then, we compute the weight of the former $wAI(P)$ component on the above set of interactions $\gamma$ and we get $\left\|p\oplus (p\otimes q)\right\|(\gamma)=k_{p}\oplus (k_{p}\otimes k_{q}).$ On the other hand, the weight for the latter $wAI(P)$ component on $\gamma$ is $\left\|p\otimes q\right\|(\gamma)
=k_{p}\otimes k_{q}.$
Consequently, we infer that $\left[ p \right]' \otimes \left[ q \right]$ and $\left[ p \right] \otimes \left[ q \right]$ are not equivalent.
\end{examp}
By the previous example it occurs that when we apply different typing on equivalent $wAC(P)$ connectors occurring within another connector, then the resulting connectors are not always equivalent. Specifically, the application of the weighted fusion operator does not preserve the equivalence. Hence, equivalent $wAC(P) $ connectors cannot always be substituted for one another and as we say, they are not weighted congruent.
We now define formally the notion of congruence relation on $wAC(P)$.
\begin{defin}\label{de1}
We denote by `` $\cong$'' the largest weighted congruence relation contained in $\equiv$ of $wAC(P)$, that is, the largest relation satisfying the following: For $\zeta_{1}, \zeta_{2}\in wAC(P)$ and $r\notin P$
$$\zeta_{1} \cong \zeta_{2} \Rightarrow \forall E\in wAC\left( P\cup \left\lbrace r\right\rbrace \right), E(\zeta_{1}/r) \equiv E(\zeta_{2}/r),$$
where $E(\zeta /r)$ denotes the expression obtained from $E$ by replacing all occurrences of $wAC(P)$ connector $r$ by $\zeta$.
\end{defin}
In the sequel, we refer to weighted congruence relation simply by congruence relation. Next we provide our first result for congruence relation. Specifically, we show that two equivalent $wAC(P)$ connectors which are similarly typed, they are also congruent.
\begin{theo}\label{eq4}
Let $\zeta_{1}, \zeta_{2}\in wAC(P)$ and $\alpha \in \left\lbrace 0,1\right\rbrace $. Then,
$$\zeta_{1}\equiv \zeta_{2} \Leftrightarrow \left[ \zeta_{1}\right] ^{\alpha}\cong \left[ \zeta_{2}\right] ^{\alpha}.$$
\end{theo}
\begin{prof*}
Firstly we prove the right-to-left implication. Assume that $\left[ \zeta_{1}\right] ^{\alpha}\cong \left[ \zeta_{2}\right] ^{\alpha}$, i.e., for every $E\in wAC\left( P\cup \left\lbrace r\right\rbrace \right) $ we have $E\left( \left[ \zeta_{1}\right] ^{\alpha}/r\right) \equiv E\left( \left[ \zeta_{2}\right] ^{\alpha}/r\right)$, and hence $\Big| E\left( \left[ \zeta_{1}\right] ^{\alpha}/r\right)\Big| =\Big| E\left( \left[ \zeta_{2}\right] ^{\alpha}/r\right)\Big|.$ For $E=[r]\in wAC\left( P\cup \left\lbrace r\right\rbrace \right)$ we get that $E\left( \left[ \zeta_{1}\right] ^{\alpha}/r\right) =\left[ \zeta_{1}\right] ^{\alpha}$ and $E\left( \left[ \zeta_{2}\right] ^{\alpha}/r\right) =\left[ \zeta_{2}\right] ^{\alpha}$. By assumption $\Big| E\left( \left[ \zeta_{1}\right] ^{\alpha}/r\right)\Big| =\Big| E\left( \left[ \zeta_{2}\right] ^{\alpha}/r\right)\Big|$, i.e., $\Big| \left[ \zeta_{1}\right] ^{\alpha}\Big| =\Big| \left[ \zeta_{2}\right] ^{\alpha}\Big|.$ We consider the following cases:
\begin{itemize}
\item For $\alpha=0$ we have that $\big| \left[ \zeta_{1}\right] \big| =\big| \left[ \zeta_{2}\right] \big| \Rightarrow \left|\zeta_{1}\right|=\left|\zeta_{2}\right|$, and
\item For $\alpha=1$ we have that $\big| \left[ \zeta_{1}\right]' \big| =\big| \left[ \zeta_{2}\right]' \big| \Rightarrow \left|\zeta_{1}\right|=\left|\zeta_{2}\right|.$
\end{itemize}
In any case, we conclude that $\left|\zeta_{1}\right|=\left|\zeta_{2}\right|$. \hide{Therefore, we have proved that if $\left[ \zeta_{1}\right] ^{\alpha}\cong \left[ \zeta_{2}\right] ^{\alpha}$, then $\left|\zeta_{1}\right|=\left|\zeta_{2}\right|$.}
\hide{which occurs directly, given that the relation ``$\cong$'' is the largest congruence relation contained in ``$\simeq$''.}
\par Now we prove the left-to-right implication. We assume that $\zeta_{1}\equiv \zeta_{2}$, i.e., for the $wAC(P)$ connectors $\zeta_{1}$ and $\zeta_{2}$ it holds that $\left|\zeta_{1}\right|=\left|\zeta_{2}\right|$. We have to prove that $\left[ \zeta_{1}\right] ^{\alpha}\cong \left[ \zeta_{2}\right] ^{\alpha}$. Therefore, we have to prove that for any expression $E\in wAC\left( P\cup \left\lbrace r\right\rbrace \right) $ it holds that $E(\left[\zeta_{1}\right]^{\alpha}/r) \equiv E(\left[\zeta_{2}\right]^{\alpha}/r)$. Without loss of generality we can assume that $r$ occurs only once in E. Otherwise, we apply the proof iteratively. By our assumption for $r$ it suffices to consider and prove the following equivalences:
\begin{enumerate}
\item $\left[\zeta_{1}\right]^{\alpha} \equiv \left[\zeta_{2}\right]^{\alpha}$. For $\alpha = 0$, we have that $ \big| \left[\zeta_{1}\right] \big| = \left| \zeta_{1} \right|= \left| \zeta_{2} \right|$ and $\big| \left[\zeta_{2}\right] \big| = \left| \zeta_{2} \right|.$ On the other hand, for $\alpha = 1$, we have that $ \big| \left[\zeta_{1}\right]' \big| = \left| \zeta_{1} \right| = \left| \zeta_{2} \right|$ and $\big| \left[\zeta_{2}\right]' \big| = \left| \zeta_{2} \right|.$ Hence, $\left[\zeta_{1}\right]^{\alpha} \equiv \left[\zeta_{2}\right]^{\alpha}$ for $\alpha\in \lbrace 0,1\rbrace$.
\item $\left[\zeta_{1}\right]^{\alpha} \oplus \zeta \equiv \left[\zeta_{2}\right]^{\alpha} \oplus \zeta $ where $\zeta \in wAC(P)$. For $\alpha = 0$, we have that $ \big| \left[\zeta_{1}\right] \oplus \zeta \big| = \big| \left[\zeta_{1}\right] \big| \oplus \left| \zeta \right| = \left| \zeta_{1} \right| \oplus \left| \zeta \right| = \left| \zeta_{2} \right| \oplus \left| \zeta \right| $ and $ \big| \left[\zeta_{2}\right] \oplus \zeta \big| = \big| \left[\zeta_{2}\right] \big| \oplus \left| \zeta \right| = \left| \zeta_{2} \right| \oplus \left| \zeta \right|. $ On the other hand, for $\alpha = 1$, we have that $ \big| \left[\zeta_{1}\right]' \oplus \zeta \big| = \big| \left[\zeta_{1}\right]' \big| \oplus \left| \zeta \right| = \left| \zeta_{1} \right| \oplus \left| \zeta \right| = \left| \zeta_{2} \right| \oplus \left| \zeta \right| $ and $ \big| \left[\zeta_{2}\right]' \oplus \zeta \big| = \big| \left[\zeta_{2}\right]' \big| \oplus \left| \zeta \right| = \left| \zeta_{2} \right| \oplus \left| \zeta \right|.$ Hence, $\left[\zeta_{1}\right]^{\alpha} \oplus \zeta \equiv \left[\zeta_{2}\right]^{\alpha} \oplus \zeta$ for $\alpha\in \lbrace 0,1\rbrace$.
\item $\left[\zeta_{1}\right]^{\alpha} \otimes \left[ \zeta \right] \equiv \left[\zeta_{2}\right]^{\alpha} \otimes \left[ \zeta \right]$ where $\zeta \in wAC(P)$. For $\alpha = 0$, we have that $ \big| \left[\zeta_{1}\right] \otimes \left[ \zeta \right] \big| = \left|\zeta_{1}\right| \otimes \left| \zeta \right| = \left|\zeta_{2}\right| \otimes \left| \zeta \right|$ and $ \big| \left[\zeta_{2}\right] \otimes \left[ \zeta \right] \big| = \left|\zeta_{2}\right| \otimes \left| \zeta \right|. $ On the other hand, for $\alpha = 1$, we have that $ \big| \left[\zeta_{1}\right]' \otimes \left[ \zeta \right] \big| = \left|\zeta_{1}\right| \otimes (1 \oplus \left| \zeta \right|) = \left|\zeta_{2}\right| \otimes (1 \oplus \left| \zeta \right|)$ and $ \big| \left[\zeta_{2}\right]' \otimes \left[ \zeta \right] \big| = \left|\zeta_{2}\right| \otimes (1 \oplus \left| \zeta \right|).$ Hence, $\left[\zeta_{1}\right]^{\alpha} \otimes \zeta \equiv \left[\zeta_{2}\right]^{\alpha} \otimes \zeta$ for $\alpha\in \lbrace 0,1\rbrace$.
\item $\left[\zeta_{1}\right]^{\alpha} \otimes \left[ \zeta \right]' \equiv \left[\zeta_{2}\right]^{\alpha} \otimes \left[ \zeta \right]' $ where $\zeta \in wAC(P)$.
For $\alpha = 0$, we have that $ \big| \left[\zeta_{1}\right] \otimes \left[ \zeta \right]' \big| = \left|\zeta \right| \otimes (1 \oplus \left| \zeta_{1} \right|) = \left|\zeta \right| \otimes (1 \oplus \left| \zeta_{2} \right|) $ and $ \big| \left[\zeta_{2}\right] \otimes \left[ \zeta \right]' \big| = \left|\zeta \right| \otimes (1 \oplus \left| \zeta_{2} \right|). $ On the other hand, for $\alpha = 1$, we have that $\big| \left[\zeta_{1}\right]' \otimes \left[ \zeta \right]' \big| = \big( \left|\zeta_{1}\right| \otimes (1 \oplus \left| \zeta \right|) \big) \oplus \big( \left|\zeta\right| \otimes (1 \oplus \left| \zeta_{1} \right|) \big) =\big( \left|\zeta_{2}\right| \otimes (1 \oplus \left| \zeta \right|) \big) \oplus \big( \left|\zeta\right| \otimes (1 \oplus \left| \zeta_{2} \right|) \big)$ and $ \big| \left[\zeta_{2}\right]' \otimes \left[ \zeta \right]' \big| = \big( \left|\zeta_{2}\right| \otimes (1 \oplus \left| \zeta \right|) \big) \oplus \big( \left|\zeta\right| \otimes (1 \oplus \left| \zeta_{2} \right|) \big).$ Hence, $\left[\zeta_{1}\right]^{\alpha} \otimes \left[ \zeta \right]' \equiv \left[\zeta_{2}\right]^{\alpha} \otimes \left[ \zeta \right]'$ for $\alpha\in \lbrace 0,1\rbrace$.
\item $\left[\zeta_{1}\right]^{\alpha} \otimes \left[ \xi_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes\left[ \xi_{n} \right]^{\alpha_{n}} \equiv \left[\zeta_{2}\right]^{\alpha} \otimes \left[ \xi_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes\left[ \xi_{n} \right]^{\alpha_{n}}$ where $\xi_{1},\ldots, \xi_{n}\in wAC(P)$ and $\alpha, \alpha_1,\ldots, \alpha_n\in \lbrace 0,1\rbrace$.
\begin{itemize}
\item For $\alpha=0$, we have
\begin{align*}
&\big| \left[\zeta_{1}\right] \otimes \left[ \xi_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes\left[ \xi_{n} \right]^{\alpha_{n}} \big| \\
=& \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left| \xi_{i} \right| \otimes \overset{}{\underset{\substack{k \neq i,\\\alpha_{k}=1}}{\bigotimes}} (1 \oplus \left| \xi_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1 \oplus \left| \xi_{j}\right|) \otimes (1\oplus \left|\zeta_{1}\right|) \Big) \\
=& \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left| \xi_{i} \right| \otimes \overset{}{\underset{\substack{k \neq i,\\\alpha_{k}=1}}{\bigotimes}} (1 \oplus \left| \xi_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1 \oplus \left| \xi_{j}\right|) \otimes (1\oplus \left|\zeta_{2}\right|) \Big) \\
\end{align*}
and
\begin{align*}
&\big| \left[\zeta_{2}\right] \otimes \left[ \xi_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes\left[ \xi_{n} \right]^{\alpha_{n}} \big| \\
=& \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left| \xi_{i} \right| \otimes \overset{}{\underset{\substack{k \neq i,\\\alpha_{k}=1}}{\bigotimes}} (1 \oplus \left| \xi_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1 \oplus \left| \xi_{j}\right|) \otimes (1\oplus \left|\zeta_{2}\right|) \Big) .\\
\end{align*}
\item For $\alpha=1$, we get
\begin{align*}
&\big| \left[\zeta_{1}\right]' \otimes \left[ \xi_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes\left[ \xi_{n} \right]^{\alpha_{n}} \big| \\
=& \Big(\left|\zeta_{1}\right| \otimes \overset{}{\underset{l\in[n]}{\bigotimes}} (1\oplus \left| \xi_{l} \right|) \Big) \oplus \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left| \xi_{i} \right| \otimes \overset{}{\underset{\substack{k \neq i,\\\alpha_{k}=1}}{\bigotimes}} (1 \oplus \left| \xi_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1 \oplus \left| \xi_{j}\right|) \otimes (1\oplus \left|\zeta_{1}\right|) \Big) \\
=& \Big(\left|\zeta_{2}\right| \otimes \overset{}{\underset{l\in[n]}{\bigotimes}} (1\oplus \left| \xi_{l} \right|) \Big) \oplus \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left| \xi_{i} \right| \otimes \overset{}{\underset{\substack{k \neq i,\\\alpha_{k}=1}}{\bigotimes}} (1 \oplus \left| \xi_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1 \oplus \left| \xi_{j}\right|) \otimes (1\oplus \left|\zeta_{2}\right|) \Big)\\
\end{align*}
and
\begin{align*}
&\big| \left[\zeta_{2}\right]' \otimes \left[ \xi_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes\left[ \xi_{n} \right]^{\alpha_{n}} \big| \\
=& \Big(\left|\zeta_{2}\right| \otimes \overset{}{\underset{l\in[n]}{\bigotimes}} (1\oplus \left| \xi_{l} \right|) \Big) \oplus \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left| \xi_{i} \right| \otimes \overset{}{\underset{\substack{k \neq i,\\\alpha_{k}=1}}{\bigotimes}} (1 \oplus \left| \xi_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1 \oplus \left| \xi_{j}\right|) \otimes (1\oplus \left|\zeta_{2}\right|) \Big).
\end{align*}
\end{itemize}
\noindent Hence, $\left[\zeta_{1}\right]' \otimes \left[ \xi_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \xi_{n} \right]^{\alpha_{n}} \equiv \left[\zeta_{2}\right]' \otimes \left[ \xi_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \xi_{n} \right]^{\alpha_{n}}$, for $\alpha,\alpha_{1},\ldots, \alpha_{n}\in \lbrace 0,1\rbrace$.
\end{enumerate}
\hide{Hence, for any expression $E\in wAC\left( P\cup \left\lbrace r\right\rbrace \right)$ we concluded that $\big| E\left(\left[\zeta_{1}\right]^{\alpha}/r\right)\big|=\big| E\left(\left[\zeta_{2}\right]^{\alpha}/r\right)\big|$, i.e., $\left[ \zeta_{1}\right] ^{\alpha}\cong \left[ \zeta_{2}\right] ^{\alpha}$.} For the symmetric cases of (1)-(4) and for any other position of $[\zeta_{1}]^{\alpha}$ (resp. $[\zeta_{2}]^{\alpha}$) in (5) the proof is analogous. Finally, for any other form of the expression $E$ we can apply the presented cases iteratively, and our proof is completed. \qed
\end{prof*}
Now we prove our second theorem which provides some conditions in order to obtain congruence between $wAC(P)$ connectors. For this, we need the next proposition.
\begin{prop}\label{induct}
Let $ \zeta_{i} \in wAC(P)$ and $\alpha_{i} \in \left\lbrace 0,1\right\rbrace $, for $i \in [n]$. Then,
$$ \left| \overset{}{\underset{i\in [n]}{\bigotimes}} \left[ \zeta_{i}\right] ^{\alpha_{i}} \right| \oplus \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) = \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) .$$
\end{prop}
\begin{prof*} We prove the above equality by induction on $n$ and applying Corollary \ref{walg_semi}.
\end{prof*}
\hide{\begin{itemize}
\item[$\bullet$] $ \left| \left[ \zeta_{1}\right] ^{\alpha_{1}} \otimes \left[ \zeta_{2}\right] ^{\alpha_{2}} \right| \oplus (1\oplus \left| \zeta_{1} \right|) \otimes (1\oplus \left| \zeta_{2} \right|) = (1\oplus \left| \zeta_{1} \right|) \otimes (1\oplus \left| \zeta_{2} \right|) $
We consider the following cases:
\begin{itemize}
\item[--] $\alpha_{1}=0, \alpha_{2}=0:$
\begin{align*}
& \left| \left[ \zeta_{1}\right] \otimes \left[ \zeta_{2}\right] \right| \oplus (1\oplus \left| \zeta_{1} \right|) \otimes (1\oplus \left| \zeta_{2} \right|) \\
=& (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \oplus 1 \oplus \left|\zeta_{1}\right| \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \\
=& 1 \oplus \left|\zeta_{1}\right| \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \\
=& (1\oplus \left| \zeta_{1} \right|) \otimes (1\oplus \left| \zeta_{2} \right|).
\end{align*}
\item[--] $\alpha_{1}=0, \alpha_{2}=1:$
\begin{align*}
&\left| \left[ \zeta_{1}\right] \otimes \left[ \zeta_{2}\right]' \right| \oplus (1\oplus \left| \zeta_{1} \right|) \otimes (1\oplus \left| \zeta_{2} \right|) \\
=& \big(\left|\zeta_{2}\right| \otimes (1\oplus \left|\zeta_{1}\right|)\big) \oplus 1 \oplus \left|\zeta_{1}\right| \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \\
=& \left| \zeta_{2}\right| \oplus (\left| \zeta_{2} \right| \otimes \left| \zeta_{1} \right|) \oplus 1 \oplus \left|\zeta_{1}\right| \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \\
=& \left| \zeta_{2}\right| \oplus (\left| \zeta_{1} \right| \otimes \left| \zeta_{2} \right|) \oplus 1 \oplus \left|\zeta_{1}\right| \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \\
=& 1 \oplus \left|\zeta_{1}\right| \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \\
=& (1\oplus \left| \zeta_{1} \right|) \otimes (1\oplus \left| \zeta_{2} \right|).
\end{align*}
\item[--] $\alpha_{1}=1, \alpha_{2}=0:$
\begin{align*}
& \left| \left[ \zeta_{1}\right]' \otimes \left[ \zeta_{2}\right] \right| \oplus (1\oplus \left| \zeta_{1} \right|) \otimes (1\oplus \left| \zeta_{2} \right|) \\
=& \big(\left|\zeta_{1}\right| \otimes (1\oplus \left|\zeta_{2}\right|)\big) \oplus 1 \oplus \left|\zeta_{1}\right| \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \\
=& \left| \zeta_{1}\right| \oplus (\left| \zeta_{1} \right| \otimes \left| \zeta_{2} \right|) \oplus 1 \oplus \left|\zeta_{1}\right| \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \\
=& 1 \oplus \left|\zeta_{1}\right| \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \\
=& (1\oplus \left| \zeta_{1} \right|) \otimes (1\oplus \left| \zeta_{2} \right|).
\end{align*}
\item[--] $\alpha_{1}=1, \alpha_{2}=1:$
\begin{align*}
& \left| \left[ \zeta_{1}\right]' \otimes \left[ \zeta_{2}\right]' \right| \oplus (1\oplus \left| \zeta_{1} \right|) \otimes (1\oplus \left| \zeta_{2} \right|) \\
=& \big(\left|\zeta_{1}\right| \otimes (1\oplus \left|\zeta_{2}\right|)\big) \oplus \big(\left|\zeta_{2}\right| \otimes (1\oplus \left|\zeta_{1}\right|)\big) \oplus 1 \oplus \left|\zeta_{1}\right| \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \\
=& \left| \zeta_{1}\right| \oplus (\left| \zeta_{1} \right| \otimes \left| \zeta_{2} \right|) \oplus \left| \zeta_{2}\right| \oplus (\left| \zeta_{2} \right| \otimes \left| \zeta_{1} \right|) \oplus 1 \oplus \left|\zeta_{1}\right| \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \\
=& \left| \zeta_{1}\right| \oplus (\left| \zeta_{1} \right| \otimes \left| \zeta_{2} \right|) \oplus \left| \zeta_{2}\right| \oplus (\left| \zeta_{1} \right| \otimes \left| \zeta_{2} \right|) \oplus 1 \oplus \left|\zeta_{1}\right| \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \\
=& 1 \oplus \left|\zeta_{1}\right| \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \\
=& (1\oplus \left| \zeta_{1} \right|) \otimes (1\oplus \left| \zeta_{2} \right|).
\end{align*}
\end{itemize}
Hence, we proved the equality for $k=2$.
\item[$\bullet$] We assume that it holds for $k=n$, i.e.,
\begin{align*}\label{s1}
& \left| \overset{n}{\underset{i=1}{\bigotimes}} \left[ \zeta_{i}\right] ^{\alpha_{i}} \right| \oplus \overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) = \overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \\
\Rightarrow& \overset{}{\underset{i\in[n]}{\bigotimes}} \Big( \left| \zeta_{i} \right| \otimes \overset{}{\underset{\substack{k \neq i,\\\alpha_{k}=1}}{\bigotimes}} (1 \oplus \left| \zeta_{k} \right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1 \oplus \left| \zeta_{j} \right|) \Big) \oplus \overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) = \overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \tag{$\Sigma_{1}$}
\end{align*}
\item[$\bullet$] We will prove it for $k=n+1$ weighted connectors, considering the following cases for $\alpha_{n+1}$:
\begin{itemize}
\item[--] $\alpha_{n+1}=0$:
\begin{align*}
&\big| \left[ \zeta_{1}\right]^{\alpha_{1}} \otimes \ldots \left[ \zeta_{n} \right]^{\alpha_{n}} \otimes \left[\zeta_{n+1} \right] \big| \oplus \overset{n+1}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \\
=& \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left|\zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} (1\oplus \left|\zeta_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1\oplus \left|\zeta_{j}\right|) \otimes (1\oplus \left|\zeta_{n+1}\right|) \Big) \oplus \overset{n+1}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \\
=& \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left|\zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} (1\oplus \left|\zeta_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1\oplus \left|\zeta_{j}\right|) \Big) \otimes (1\oplus \left|\zeta_{n+1}\right|) \oplus \overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \otimes (1\oplus \left| \zeta_{n+1} \right|) \\
=& \left( \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left|\zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} (1\oplus \left|\zeta_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1\oplus \left|\zeta_{j}\right|) \Big) \oplus \overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \right) \otimes (1\oplus \left| \zeta_{n+1} \right|) \\
\overset{\eqref{s1}}{=} & \overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \otimes (1\oplus \left| \zeta_{n+1} \right|) \\
=& \overset{n+1}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|).
\end{align*}
\item[--] $\alpha_{n+1}=1$:
\begin{align*}
&\big| \left[ \zeta_{1}\right]^{\alpha_{1}} \otimes \ldots \left[ \zeta_{n} \right]^{\alpha_{n}} \otimes \left[\zeta_{n+1} \right]' \big| \oplus \overset{n+1}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \\
=& \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left|\zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} (1\oplus \left|\zeta_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1\oplus \left|\zeta_{j}\right|) \otimes (1\oplus \left|\zeta_{n+1}\right|) \Big) \oplus \left( \left|\zeta_{n+1}\right|\otimes \overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \right) \oplus \\
& \overset{n+1}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \\
=& \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left|\zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} (1\oplus \left|\zeta_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1\oplus \left|\zeta_{j}\right|) \Big) \otimes (1\oplus \left|\zeta_{n+1}\right|) \oplus \left( \left|\zeta_{n+1}\right|\otimes \overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \right) \oplus \\
& \overset{n+1}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \\
=& \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left|\zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} (1\oplus \left|\zeta_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1\oplus \left|\zeta_{j}\right|) \Big) \otimes (1\oplus \left|\zeta_{n+1}\right|) \oplus \left( \left|\zeta_{n+1}\right|\otimes \overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \right) \oplus \\
& \overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \oplus \overset{n+1}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \\
=& \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left|\zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} (1\oplus \left|\zeta_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1\oplus \left|\zeta_{j}\right|) \Big) \otimes (1\oplus \left|\zeta_{n+1}\right|) \oplus \left( \overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|)\otimes (1\oplus \left|\zeta_{n+1}\right|) \right) \oplus \\
& \overset{n+1}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \\
=&\left( \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left|\zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} (1\oplus \left|\zeta_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1\oplus \left|\zeta_{j}\right|) \Big) \oplus \overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \right) \otimes (1\oplus \left|\zeta_{n+1}\right|) \oplus \\
& \overset{n+1}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \\
\overset{\eqref{s1}}{=} & \left( \overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \otimes (1\oplus \left| \zeta_{n+1} \right|) \right) \oplus \overset{n+1}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \\
=& \overset{n+1}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \oplus \overset{n+1}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|) \\
=& \overset{n+1}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|),
\end{align*}
where in case $\alpha_{n+1}=1$ the third equality holds by idempotence property of semiring $(wAI(P)/\equiv, \oplus, \otimes, \bar{0}, \bar{1})$, since the terms occurred from $\overset{n}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|)$ are included in $\overset{n+1}{\underset{i=1}{\bigotimes}} (1\oplus \left| \zeta_{i} \right|)$.
\end{itemize}
\end{itemize}
Hence, we proved the equality for $k=n+1$, and our proof is completed. \qed}
\par Next theorem provides a method for checking whether two $wAC(P)$ connectors are congruent. \hide{\textcolor{blue}{For the reader's convenience, we recall a notation from Section \ref{}. Let $\zeta= \overset{n}{\underset{i=1}{\bigotimes}}\left[ \zeta_{i}\right] ^{\alpha_{i}} \in r-wAC(P)$. Then, we denoted by $T(\zeta)$ the function which returns the number of trigger elements of $\zeta$. Now we extend the notation being used for restricted weighted connectors to those who contain union operator. Specifically, for $\zeta = \overset{n}{\underset{i=1}{\bigoplus}} \zeta_{i}$, where all $\zeta_{i}$ have the above form, we let $T(\zeta) = max \left\lbrace T(\zeta_{i}) \mid i \in [n]\right\rbrace $.}}
\hide{We consider the following notation. Let $\zeta= \overset{n}{\underset{i=1}{\bigotimes}}\left[ \zeta_{i}\right] ^{\alpha_{i}} \in wAC(P)$ and $a_i\in \lbrace 0,1\rbrace$. Then, we denote by $\# \zeta$ the number of triggers in $\zeta$. Also for $\zeta = \overset{n}{\underset{i=1}{\bigoplus}} \zeta_{i}$, where $\zeta_{i}$ have the above form, we let $\# \zeta = max \left\lbrace \# \zeta_{i} \mid i \in [n]\right\rbrace $.}
\begin{theo}\label{th1}
Let $\zeta_{1},\zeta_{2}\in wAC(P)$. Then,
\begin{equation*}
\zeta_{1}\cong \zeta_{2} \Leftrightarrow \begin{cases*}
\zeta_{1}\equiv \zeta_{2} \\
\zeta_{1}\otimes [1]'\equiv \zeta_{2}\otimes [1]'\\
\#_{Τ}\zeta_{1}>0 \Leftrightarrow \#_{Τ}\zeta_{2}>0.
\end{cases*}
\end{equation*}
\end{theo}
\begin{prof*}
We prove the left-to-right implication. We assume that $\zeta_{1}\cong \zeta_{2}$. Hence, for every expression $E\in wAC(P\cup \left\lbrace r\right\rbrace )$ it holds that $E(\zeta_{1}/r) \equiv E(\zeta_{2}/r)$. Let $E_{1}=r\in wAC\left( P\cup \left\lbrace r\right\rbrace \right) $. Then we get that $E_{1}(\zeta_{1}/r)\equiv E_{1}(\zeta_{2}/r)$, i.e., $\zeta_{1}\equiv \zeta_{2}$. Furthermore, for $E_{2}=r\otimes [1]'\in wAC\left( P\cup \left\lbrace r\right\rbrace \right) $, it holds that $E_{2}(\zeta_{1}/r)\equiv E_{2}(\zeta_{2}/r)$ and hence $\zeta_{1}\otimes [1]'\equiv \zeta_{2}\otimes [1]'$. Now let $\xi=\left[ \xi_{1}\right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \xi_{n}\right]^{\alpha_{n}} \in wAC(P)$ for $\alpha_1, \ldots, \alpha_n\in \lbrace 0,1 \rbrace$ and we consider the $wAC(P)$ connectors $\zeta_{1}\otimes \xi$ and $\zeta_{2}\otimes \xi$. Then, we claim that $\#_{T}\zeta_{1}>0 \Leftrightarrow \#_{T}\zeta_{2}>0$. On the contrary, we let $\#_{T}\zeta_{1}>0$ and $\#_{T}\zeta_{2}=0$. Specifically, let $\zeta_{1}=[p]', \zeta_{2}=[p]$ and $\xi=[q]$. Then, it holds that $\left| \zeta_{1}\otimes \xi \right| = \big| [p]' \otimes [q] \big| = \left|p\right| \otimes (1\oplus \left|q\right|) = p\otimes (1\oplus q)=p \oplus (p\otimes q)$ and $\left| \zeta_{2}\otimes \xi\right| = \big| [p]\otimes [q]\big| = \left|p\right| \otimes \left|q\right|=p\otimes q$. That is, for $E_{3}=r \otimes \xi \in wAC(P\cup \left\lbrace r\right\rbrace) $ it does not hold $E(\zeta_{1}/r) \equiv E(\zeta_{2}/r)$, which is a contradiction since $\zeta_{1} \cong \zeta_{2}$. Hence, $\#_{T}\zeta_{1}>0 \Leftrightarrow \#_{T}\zeta_{2} >0$.
\par Now we prove the right-to-left implication. We assume that (i) $\zeta_{1}\equiv \zeta_{2}$, i.e., $\left|\zeta_{1}\right|=\left|\zeta_{2}\right|$, (ii) $ \zeta_{1}\otimes [1]' \equiv \zeta_{2} \otimes [1]'$ which means that $\left| \zeta_{1} \otimes [1]'\right| = \left|\zeta_{2}\otimes [1]'\right|$, and (iii) $\#_{Τ}\zeta_{1} >0 \Leftrightarrow \#_{Τ}\zeta_{2}>0$. We have to prove that $\zeta_{1} \cong \zeta_{2}$, thus we have to prove that for any expression $E\in wAC\left( P\cup \left\lbrace r\right\rbrace \right)$, it holds that $ E(\zeta_{1}/r)\equiv E(\zeta_{2}/r)$. Without loss of generality, we assume that $r$ occurs only once in $E$, and otherwise we apply the proof iteratively. By this assumption it suffices to consider and prove the following:
\begin{enumerate}
\item $\zeta_{1}\equiv \zeta_{2} $, which occurs directly since $\left|\zeta_{1}\right|=\left|\zeta_{2}\right|$.
\item $\zeta_{1} \oplus \zeta \equiv \zeta_{2} \oplus \zeta $ where $\zeta\in wAC(P)$. The equivalence holds since $\left| \zeta_{1}\oplus \zeta \right| = \left|\zeta_{1} \right| \oplus \left|\zeta\right| = \left|\zeta_{2} \right| \oplus \left|\zeta\right| \hide{= \left|\zeta_{2} \right| \oplus \left|\zeta\right|}$ and $\left| \zeta_{2}\oplus \zeta \right| = \left|\zeta_{2} \right| \oplus \left|\zeta\right|.$
\end{enumerate}
\noindent For the rest of the proof we let $\zeta_{1} = \left[ \zeta_{1,1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \zeta_{1,n} \right]^{\alpha_{n}}$ and $\zeta_{2} = \left[ \zeta_{2,1} \right]^{\beta_{1}} \otimes \ldots \otimes \left[ \zeta_{2,m} \right]^{\beta_{m}}$, where $\zeta_{1,i},\zeta_{2,j}\in wAC(P)$ and $\alpha_{i}, \beta_{j}\in \left\lbrace 0,1\right\rbrace $, for $i\in [n]$, $j\in [m]$.
\begin{enumerate}
\setcounter{enumi}{2}
\item We prove that $\zeta_{1} \otimes [\zeta] \equiv \zeta_{2}\otimes [\zeta]$ where $\zeta\in wAC(P)$.
\begin{itemize}
\item[--] \textbf{\underline{Case 1}}: ($\#_{T}\zeta_{1} = 0, \#_{T}\zeta_{2} = 0$)\\
It holds that
\begin{align*}\label{s2}
\left|\zeta_{1}\right| = \left|\zeta_{2}\right| \Rightarrow& \big| \left[ \zeta_{1,1} \right] \otimes \ldots \otimes \left[ \zeta_{1,n} \right] \big| = \big| \left[ \zeta_{2,1} \right] \otimes \ldots \otimes \left[ \zeta_{2,m} \right] \big| \\
\Rightarrow& \left|\zeta_{1,1}\right| \otimes \ldots \otimes \left|\zeta_{1,n}\right| = \left|\zeta_{2,1}\right| \otimes \ldots \otimes \left|\zeta_{2,m}\right|. \tag{$\Sigma_{1}$}
\end{align*}
Then, $\big|\zeta_{1} \otimes \left[ \zeta\right] \big| = \big| \left[ \zeta_{1,1} \right] \otimes \ldots \otimes \left[ \zeta_{1,n} \right] \otimes \left[\zeta \right] \big| =\left|\zeta_{1,1}\right| \otimes \ldots \otimes \left|\zeta_{1,n}\right| \otimes \left| \zeta\right| $
$\overset{\eqref{s2}}{=} \left|\zeta_{2,1}\right| \otimes \ldots \otimes \left|\zeta_{2,m}\right|\otimes$ $ \left| \zeta\right|$ and $\big|\zeta_{2} \otimes \left[ \zeta\right] \big| = \big| \left[ \zeta_{2,1} \right] \otimes \ldots \otimes \left[ \zeta_{2,m} \right] \otimes \left[\zeta \right] \big|
= \left|\zeta_{2,1}\right| \otimes \ldots \otimes \left|\zeta_{2,m}\right| \otimes \left| \zeta\right|.$ \hide{Hence, $ \zeta_{1}\otimes \left[\zeta\right] \equiv \zeta_{2}\otimes \left[\zeta\right]$.}
\item[--] \textbf{\underline{Case 2}}: ($\#_{T}\zeta_{1} > 0, \#_{T}\zeta_{2} > 0$)\\
It holds that
\begin{align*}\label{s3}
\left|\zeta_{1}\right|=\left|\zeta_{2}\right| \Rightarrow& \big| \left[ \zeta_{1,1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \zeta_{1,n} \right]^{\alpha_{n}} \big| = \big| \left[ \zeta_{2,1} \right]^{\beta_{1}} \otimes \ldots \otimes \left[ \zeta_{2,m} \right]^{\beta_{m}} \big| \\
\Rightarrow& \overset{}{\underset{\substack{i_{1}\in[n],\\\alpha_{i_{1}}=1}}{\bigoplus}} \Big( \left|\zeta_{1,i_{1}}\right| \otimes \overset{}{\underset{\substack{k_{1}\neq i_{1},\\\alpha_{k_{1}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{1,k_{1}}\right|) \otimes \overset{}{\underset{\substack{j_{1} \in [n],\\\alpha_{j_{1}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{1,j_{1}}\right|) \Big) \\
& = \overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|) \Big). \tag{$\Sigma_{2}$}
\end{align*}
Then,
\begin{align*}
\big| \zeta_{1} \otimes \left[ \zeta\right] \big| =& \big| \left[ \zeta_{1,1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \zeta_{1,n} \right]^{\alpha_{n}} \otimes \left[\zeta\right] \big| \\
=& \overset{}{\underset{\substack{i_{1}\in[n],\\\alpha_{i_{1}}=1}}{\bigoplus}} \Big( \left|\zeta_{1,i_{1}}\right| \otimes \overset{}{\underset{\substack{k_{1}\neq i_{1},\\\alpha_{k_{1}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{1,k_{1}}\right|) \otimes \overset{}{\underset{\substack{j_{1} \in [n],\\\alpha_{j_{1}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{1,j_{1}}\right|) \otimes (1\oplus \left|\zeta\right|) \Big)\\
=& \Bigg(\overset{}{\underset{\substack{i_{1}\in[n],\\\alpha_{i_{1}}=1}}{\bigoplus}} \Big( \left|\zeta_{1,i_{1}}\right| \otimes \overset{}{\underset{\substack{k_{1}\neq i_{1},\\\alpha_{k_{1}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{1,k_{1}}\right|) \otimes \overset{}{\underset{\substack{j_{1} \in [n],\\\alpha_{j_{1}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{1,j_{1}}\right|)\Big)\Bigg) \otimes (1\oplus \left|\zeta\right|) \\
\overset{\eqref{s3}}{=}&\Bigg(\overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [n],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|)\Big)\Bigg) \otimes (1\oplus \left|\zeta\right|) \\
\end{align*}
and
\begin{align*}
\big| \zeta_{2} \otimes \left[ \zeta\right] \big| =& \big| \left[ \zeta_{2,1} \right]^{\beta_{1}} \otimes \ldots \otimes \left[ \zeta_{2,m} \right]^{\beta_{m}} \otimes \left[\zeta\right] \big| \\
=& \overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|) \otimes (1\oplus \left|\zeta\right|) \Big)\\
=&\Bigg(\overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|) \Big)\Bigg) \otimes (1\oplus \left|\zeta\right|).
\end{align*}
\end{itemize}
Hence, in both cases we get that $\zeta_{1} \otimes \left[ \zeta \right] \equiv \zeta_{2} \otimes \left[ \zeta \right]$.
\item We prove that $\zeta_{1}\otimes \left[\zeta\right]' \equiv \zeta_{2}\otimes \left[\zeta\right]'$ where $\zeta\in wAC(P)$.
\begin{itemize}
\item[--] \textbf{\underline{Case 1}}: ($\#_{T}\zeta_{1} = 0, \#_{T}\zeta_{2} = 0$)\\
It holds that
\begin{align*}\label{s4}
\left|\zeta_{1} \otimes [1]'\right| = \left|\zeta_{2}\otimes [1]'\right| \Rightarrow & \big| \left[ \zeta_{1,1} \right] \otimes \ldots \otimes \left[ \zeta_{1,n} \right] \otimes [1]' \big| = \big| \left[ \zeta_{2,1} \right] \otimes \ldots \otimes \left[ \zeta_{2,m} \right] \otimes [1]' \big|\\
\Rightarrow& \left|1\right| \otimes \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left|\zeta_{1,i}\right|) = \left|1\right| \otimes \overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|)\\
\Rightarrow& \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left|\zeta_{1,i}\right|) = \overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|). \tag{$\Sigma_{3}$}
\end{align*}
Then,
$\big| \zeta_{1}\otimes \left[\zeta\right]'\big| = \big| \left[ \zeta_{1,1} \right] \otimes \ldots \otimes \left[ \zeta_{1,n} \right] \otimes \left[\zeta\right]'\big|
= \left|\zeta\right| \otimes \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left|\zeta_{1,i}\right|)
\overset{\eqref{s4}}{=} \left|\zeta\right| \otimes\overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|)$ and $\big| \zeta_{2}\otimes \left[\zeta\right]'\big| = \big| \left[ \zeta_{2,1} \right] \otimes \ldots \otimes \left[ \zeta_{2,m} \right] \otimes \left[\zeta\right]'\big| = \left|\zeta\right| \otimes\overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|).$
\item[--] \textbf{\underline{Case 2}}: ($\#_{T}\zeta_{1} > 0, \#_{T}\zeta_{2}> 0$)\\
It holds that
\begin{align*}\label{s5}
&\left|\zeta_{1} \otimes [1]'\right| = \left|\zeta_{2}\otimes [1]'\right| \Rightarrow \big| \left[ \zeta_{1,1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \zeta_{1,n} \right]^{\alpha_{n}} \otimes [1]' \big| = \big| \left[ \zeta_{2,1} \right]^{\beta_{1}} \otimes \ldots \otimes \left[ \zeta_{2,m} \right]^{\beta_{m}} \otimes [1]' \big|\\
\Rightarrow& \overset{}{\underset{\substack{i_{1}\in[n],\\\alpha_{i_{1}}=1}}{\bigoplus}} \Big( \left|\zeta_{1,i_{1}}\right| \otimes \overset{}{\underset{\substack{k_{1}\neq i_{1},\\\alpha_{k_{1}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{1,k_{1}}\right|) \otimes \overset{}{\underset{\substack{j_{1} \in [n],\\\alpha_{j_{1}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{1,j_{1}}\right|) \otimes (1\oplus \left|1\right|) \Big) \oplus \left|1\right| \otimes \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left|\zeta_{1,i}\right|) \\
=& \overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|) \otimes (1\oplus \left|1\right|) \Big) \oplus \left|1\right| \otimes \overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|) \\
\Rightarrow & \overset{}{\underset{\substack{i_{1}\in[n],\\\alpha_{i_{1}}=1}}{\bigoplus}} \Big( \left|\zeta_{1,i_{1}}\right| \otimes \overset{}{\underset{\substack{k_{1}\neq i_{1},\\\alpha_{k_{1}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{1,k_{1}}\right|) \otimes \overset{}{\underset{\substack{j_{1} \in [n],\\\alpha_{j_{1}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{1,j_{1}}\right|) \Big) \oplus \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left|\zeta_{1,i}\right|) \\
=& \overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|) \Big) \oplus \overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|) \\
\Rightarrow& \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left|\zeta_{1,i}\right|) = \overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|), \tag{$\Sigma_{4}$}
\end{align*}
where the last step holds by Proposition \ref{induct}. Then,
\begin{align*}
&\big| \zeta_{1} \otimes \left[ \zeta\right]'\big| = \big| \left[ \zeta_{1,1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \zeta_{1,n} \right]^{\alpha_{n}} \otimes \left[\zeta\right]' \big| \\
=& \overset{}{\underset{\substack{i_{1}\in[n],\\\alpha_{i_{1}}=1}}{\bigoplus}} \Big( \left|\zeta_{1,i_{1}}\right| \otimes \overset{}{\underset{\substack{k_{1}\neq i_{1},\\\alpha_{k_{1}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{1,k_{1}}\right|) \otimes \overset{}{\underset{\substack{j_{1} \in [n],\\\alpha_{j_{1}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{1,j_{1}}\right|) \otimes (1\oplus \left|\zeta\right|) \Big) \oplus\left|\zeta\right| \otimes \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left|\zeta_{1,i}\right|)\\
=& \Bigg(\overset{}{\underset{\substack{i_{1}\in[n],\\\alpha_{i_{1}}=1}}{\bigoplus}} \Big( \left|\zeta_{1,i_{1}}\right| \otimes \overset{}{\underset{\substack{k_{1}\neq i_{1},\\\alpha_{k_{1}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{1,k_{1}}\right|) \otimes \overset{}{\underset{\substack{j_{1} \in [n],\\\alpha_{j_{1}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{1,j_{1}}\right|)\Big)\Bigg) \otimes (1\oplus \left|\zeta\right|) \oplus\left|\zeta\right| \otimes \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left|\zeta_{1,i}\right|)\\
\hide{\overset{\eqref{s3}}{\underset{\eqref{s5}}{=}}& \overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|)\Big) \otimes (1\oplus \left|\zeta\right|) \oplus\left|\zeta\right| \otimes \overset{}{\underset{i_{2}\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,i_{2}}\right|)}\\
\overset{\eqref{s3}}{\underset{\eqref{s5}}{=}}& \Bigg(\overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|)\Big)\Bigg) \otimes (1\oplus \left|\zeta\right|) \oplus\left|\zeta\right| \otimes \overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|)
\end{align*}
and
\begin{align*}
&\big| \zeta_{2} \otimes \left[ \zeta\right]'\big| = \big| \left[ \zeta_{2,1} \right]^{\beta_{1}} \otimes \ldots \otimes \left[ \zeta_{2,m} \right]^{\beta_{m}} \otimes \left[\zeta\right]' \big| \\
=& \overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|) \otimes (1\oplus \left|\zeta\right|) \Big) \oplus\left|\zeta\right| \otimes \overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|)\\
=& \Bigg(\overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|)\Big)\Bigg) \otimes (1\oplus \left|\zeta\right|) \oplus\left|\zeta\right| \otimes \overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|).
\end{align*}
\end{itemize}
Hence, in both cases we get that $\zeta_{1} \otimes \left[ \zeta\right]' \equiv \zeta_{2} \otimes \left[ \zeta\right]'$.
\item We prove that $\zeta_{1}\otimes \left[ \xi_{1} \right]^{\delta_{1}} \otimes \ldots \otimes \left[ \xi_{r} \right]^{\delta_{r}} \equiv \zeta_{2}\otimes \left[ \xi_{1} \right]^{\delta_{1}} \otimes \ldots \otimes \left[ \xi_{r} \right]^{\delta_{r}}$ where $\xi = \left[ \xi_{1} \right]^{\delta_{1}} \otimes \ldots \otimes \left[ \xi_{r} \right]^{\delta_{r}}\in wAC(P)$ and $\delta_{1},\ldots, \delta_{r} \in \lbrace 0,1\rbrace$.
\begin{itemize}
\item[--] \textbf{\underline{Case 1}}: ($\#_{T}\zeta_{1} = 0, \#_{T}\zeta_{2} = 0$)\\
\begin{itemize}
\item[$\blacktriangleright$] If $\#_{T}\xi=0$, then we have that
\begin{align*}
\left|\zeta_{1} \otimes \xi\right|=& \big|\left[ \zeta_{1,1} \right] \otimes \ldots \otimes \left[ \zeta_{1,n} \right]\otimes \left[ \xi_{1} \right] \otimes \ldots \otimes \left[ \xi_{r} \right]\big|\\
=& \left| \zeta_{1,1} \right| \otimes \ldots \otimes \left| \zeta_{1,n} \right|\otimes \left| \xi_{1} \right| \otimes \ldots \otimes \left| \xi_{r} \right|\\
\overset{\eqref{s2}}{=}& \left| \zeta_{2,1} \right| \otimes \ldots \otimes \left| \zeta_{2,m} \right|\otimes \left| \xi_{1} \right| \otimes \ldots \otimes \left| \xi_{r} \right|
\end{align*}
and
\begin{align*}
\left|\zeta_{2} \otimes \xi\right|=& \big|\left[ \zeta_{2,1} \right] \otimes \ldots \otimes \left[ \zeta_{2,m} \right]\otimes \left[ \xi_{1} \right] \otimes \ldots \otimes \left[ \xi_{r} \right]\big|\\
=& \left| \zeta_{2,1} \right| \otimes \ldots \otimes \left| \zeta_{2,m} \right|\otimes \left| \xi_{1} \right| \otimes \ldots \otimes \left| \xi_{r} \right|.
\end{align*}
\item[$\blacktriangleright$] If $\#_{T}\xi>0$, then we have that
\begin{align*}
\left|\zeta_{1} \otimes \xi\right|=& \big|\left[ \zeta_{1,1} \right] \otimes \ldots \otimes \left[ \zeta_{1,n} \right]\otimes \left[ \xi_{1} \right]^{\delta_{1}} \otimes \ldots \otimes \left[ \xi_{r} \right]^{\delta_{r}}\big|\\
=& \overset{}{\underset{\substack{\lambda\in[r],\\\delta_{\lambda}=1}}{\bigoplus}} \Big( \left|\xi_{\lambda}\right| \otimes \overset{}{\underset{\substack{\mu\neq \lambda,\\\delta_{\mu}=1}}{\bigotimes}} (1\oplus \left|\xi_{\mu}\right|) \otimes \overset{}{\underset{\substack{\nu \in [r],\\\delta_{\nu}=0}}{\bigotimes}} (1\oplus \left|\xi_{\nu}\right|) \otimes \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left|\zeta_{1,i}\right|)\Big) \\
=&\Bigg( \overset{}{\underset{\substack{\lambda\in[r],\\\delta_{\lambda}=1}}{\bigoplus}} \Big( \left|\xi_{\lambda}\right| \otimes \overset{}{\underset{\substack{\mu\neq \lambda,\\\delta_{\mu}=1}}{\bigotimes}} (1\oplus \left|\xi_{\mu}\right|) \otimes \overset{}{\underset{\substack{\nu \in [r],\\\delta_{\nu}=0}}{\bigotimes}} (1\oplus \left|\xi_{\nu}\right|) \Big)\Bigg) \otimes \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left|\zeta_{1,i}\right|) \\
\overset{\eqref{s4}}{=}& \Bigg( \overset{}{\underset{\substack{\lambda\in[r],\\\delta_{\lambda}=1}}{\bigoplus}} \Big( \left|\xi_{\lambda}\right| \otimes \overset{}{\underset{\substack{\mu\neq \lambda,\\\delta_{\mu}=1}}{\bigotimes}} (1\oplus \left|\xi_{\mu}\right|) \otimes \overset{}{\underset{\substack{\nu \in [r],\\\delta_{\nu}=0}}{\bigotimes}} (1\oplus \left|\xi_{\nu}\right|) \Big)\Bigg) \otimes \overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|)
\end{align*}
and
\begin{align*}
\left|\zeta_{2} \otimes \xi\right|=& \big|\left[ \zeta_{2,1} \right] \otimes \ldots \otimes \left[ \zeta_{2,m} \right]\otimes \left[ \xi_{1} \right]^{\delta_{1}} \otimes \ldots \otimes \left[ \xi_{r} \right]^{\delta_{r}}\big|\\
=& \overset{}{\underset{\substack{\lambda\in[r],\\\delta_{\lambda}=1}}{\bigoplus}} \Big( \left|\xi_{\lambda}\right| \otimes \overset{}{\underset{\substack{\mu\neq \lambda,\\\delta_{\mu}=1}}{\bigotimes}} (1\oplus \left|\xi_{\mu}\right|) \otimes \overset{}{\underset{\substack{\nu \in [r],\\\delta_{\nu}=0}}{\bigotimes}} (1\oplus \left|\xi_{\nu}\right|) \otimes \overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|)\Big) \\
=& \Bigg( \overset{}{\underset{\substack{\lambda\in[r],\\\delta_{\lambda}=1}}{\bigoplus}} \Big( \left|\xi_{\lambda}\right| \otimes \overset{}{\underset{\substack{\mu\neq \lambda,\\\delta_{\mu}=1}}{\bigotimes}} (1\oplus \left|\xi_{\mu}\right|) \otimes \overset{}{\underset{\substack{\nu \in [r],\\\delta_{\nu}=0}}{\bigotimes}} (1\oplus \left|\xi_{\nu}\right|) \Big)\Bigg) \otimes \overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|).
\end{align*} Hence, we obtain that $\zeta_{1}\otimes \left[ \xi_{1} \right]^{\delta_{1}} \otimes \ldots \otimes \left[ \xi_{r} \right]^{\delta_{r}} \equiv \zeta_{2}\otimes \left[ \xi_{1} \right]^{\delta_{1}} \otimes \ldots \otimes \left[ \xi_{r} \right]^{\delta_{r}}$ for Case 1.
\item[--] \textbf{\underline{Case 2}}: ($\#_{T}\zeta_{1} > 0, \#_{T}\zeta_{2} > 0$)\\
\begin{itemize}
\item[$\blacktriangleright$] If $\#_{T}\xi=0$, then we have that
\begin{align*}
\left|\zeta_{1} \otimes \xi\right|=& \big|\left[ \zeta_{1,1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \zeta_{1,n} \right]^{\alpha_{n}}\otimes \left[ \xi_{1} \right] \otimes \ldots \otimes \left[ \xi_{r} \right]\big|\\
=& \overset{}{\underset{\substack{i_{1}\in[n],\\\alpha_{i_{1}}=1}}{\bigoplus}} \Big( \left|\zeta_{1,i_{1}}\right| \otimes \overset{}{\underset{\substack{k_{1}\neq i_{1},\\\alpha_{k_{1}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{1,k_{1}}\right|) \otimes \overset{}{\underset{\substack{j_{1} \in [n],\\\alpha_{j_{1}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{1,j_{1}}\right|) \otimes \overset{}{\underset{l\in [r]}{\bigotimes}} (1\oplus \left|\xi_{l}\right|)\Big)\\
=&\Bigg( \overset{}{\underset{\substack{i_{1}\in[n],\\\alpha_{i_{1}}=1}}{\bigoplus}} \Big( \left|\zeta_{1,i_{1}}\right| \otimes \overset{}{\underset{\substack{k_{1}\neq i_{1},\\\alpha_{k_{1}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{1,k_{1}}\right|) \otimes \overset{}{\underset{\substack{j_{1} \in [n],\\\alpha_{j_{1}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{1,j_{1}}\right|) \Big) \Bigg)\otimes \overset{}{\underset{l\in [r]}{\bigotimes}} (1\oplus \left|\xi_{l}\right|)\\
\overset{\eqref{s3}}{=}& \Bigg( \overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|) \Big) \Bigg)\otimes \overset{}{\underset{l\in [r]}{\bigotimes}} (1\oplus \left|\xi_{l}\right|)
\end{align*}
and
\begin{align*}
\left|\zeta_{2} \otimes \xi\right|=& \big|\left[ \zeta_{2,1} \right]^{\beta_{1}} \otimes \ldots \otimes \left[ \zeta_{2,m} \right]^{\beta_{m}}\otimes \left[ \xi_{1} \right] \otimes \ldots \otimes \left[ \xi_{r} \right]\big|\\
=& \overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|) \otimes \overset{}{\underset{l\in [r]}{\bigotimes}} (1\oplus \left|\xi_{l}\right|)\Big)\\
=&\Bigg( \overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|) \Big) \Bigg)\otimes \overset{}{\underset{l\in [r]}{\bigotimes}} (1\oplus \left|\xi_{l}\right|).
\end{align*}
\item[$\blacktriangleright$] If $\#_{T}\xi>0$, then we have that
\begin{align*}
\left|\zeta_{1} \otimes \xi\right|=& \big|\left[ \zeta_{1,1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \zeta_{1,n} \right]^{\alpha_{n}}\otimes \left[ \xi_{1} \right]^{\delta_{1}} \otimes \ldots \otimes \left[ \xi_{r} \right]^{\delta_{r}}\big|\\
=& \overset{}{\underset{\substack{i_{1}\in[n],\\\alpha_{i_{1}}=1}}{\bigoplus}} \Big( \left|\zeta_{1,i_{1}}\right| \otimes \overset{}{\underset{\substack{k_{1}\neq i_{1},\\\alpha_{k_{1}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{1,k_{1}}\right|) \otimes \overset{}{\underset{\substack{j_{1} \in [n],\\\alpha_{j_{1}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{1,j_{1}}\right|) \otimes \overset{}{\underset{l\in [r]}{\bigotimes}} (1\oplus \left|\xi_{l}\right|)\Big) \oplus\\
& \overset{}{\underset{\substack{\lambda\in[r],\\\delta_{\lambda}=1}}{\bigoplus}} \Big( \left|\xi_{\lambda}\right| \otimes \overset{}{\underset{\substack{\mu\neq \lambda,\\\delta_{\mu}=1}}{\bigotimes}} (1\oplus \left|\xi_{\mu}\right|) \otimes \overset{}{\underset{\substack{\nu \in [r],\\\delta_{\nu}=0}}{\bigotimes}} (1\oplus \left|\xi_{\nu}\right|) \otimes \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left|\zeta_{1,i}\right|)\Big)\\
=& \Bigg(\overset{}{\underset{\substack{i_{1}\in[n],\\\alpha_{i_{1}}=1}}{\bigoplus}} \Big( \left|\zeta_{1,i_{1}}\right| \otimes \overset{}{\underset{\substack{k_{1}\neq i_{1},\\\alpha_{k_{1}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{1,k_{1}}\right|) \otimes \overset{}{\underset{\substack{j_{1} \in [n],\\\alpha_{j_{1}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{1,j_{1}}\right|) \Big)\Bigg) \otimes \overset{}{\underset{l\in [r]}{\bigotimes}} (1\oplus \left|\xi_{l}\right|) \oplus\\
&\Bigg( \overset{}{\underset{\substack{\lambda\in[r],\\\delta_{\lambda}=1}}{\bigoplus}} \Big( \left|\xi_{\lambda}\right| \otimes \overset{}{\underset{\substack{\mu\neq \lambda,\\\delta_{\mu}=1}}{\bigotimes}} (1\oplus \left|\xi_{\mu}\right|) \otimes \overset{}{\underset{\substack{\nu \in [r],\\\delta_{\nu}=0}}{\bigotimes}} (1\oplus \left|\xi_{\nu}\right|) \Big)\Bigg) \otimes \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left|\zeta_{1,i}\right|)\\
\overset{\eqref{s3}}{\underset{\eqref{s5}}{=}}& \Bigg( \overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|) \Big)\Bigg) \otimes \overset{}{\underset{l\in [r]}{\bigotimes}} (1\oplus \left|\xi_{l}\right|) \oplus\\
& \Bigg(\overset{}{\underset{\substack{\lambda\in[r],\\\delta_{\lambda}=1}}{\bigoplus}} \Big( \left|\xi_{\lambda}\right| \otimes \overset{}{\underset{\substack{\mu\neq \lambda,\\\delta_{\mu}=1}}{\bigotimes}} (1\oplus \left|\xi_{\mu}\right|) \otimes \overset{}{\underset{\substack{\nu \in [r],\\\delta_{\nu}=0}}{\bigotimes}} (1\oplus \left|\xi_{\nu}\right|) \Big)\Bigg) \otimes \overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|)
\end{align*}
and
\begin{align*}
\left|\zeta_{2} \otimes \xi\right|=& \big|\left[ \zeta_{2,1} \right]^{\beta_{1}} \otimes \ldots \otimes \left[ \zeta_{2,m} \right]^{\beta_{m}}\otimes \left[ \xi_{1} \right]^{\delta_{1}} \otimes \ldots \otimes \left[ \xi_{r} \right]^{\delta_{r}}\big|\\
=& \overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|) \otimes \overset{}{\underset{l\in [r]}{\bigotimes}} (1\oplus \left|\xi_{l}\right|)\Big) \oplus\\
& \overset{}{\underset{\substack{\lambda\in[r],\\\delta_{\lambda}=1}}{\bigoplus}} \Big( \left|\xi_{\lambda}\right| \otimes \overset{}{\underset{\substack{\mu\neq \lambda,\\\delta_{\mu}=1}}{\bigotimes}} (1\oplus \left|\xi_{\mu}\right|) \otimes \overset{}{\underset{\substack{\nu \in [r],\\\delta_{\nu}=0}}{\bigotimes}} (1\oplus \left|\xi_{\nu}\right|) \otimes \overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|)\Big)\\
=&\Bigg( \overset{}{\underset{\substack{i_{2}\in[m],\\\beta_{i_{2}}=1}}{\bigoplus}} \Big( \left|\zeta_{2,i_{2}}\right| \otimes \overset{}{\underset{\substack{k_{2}\neq i_{2},\\\beta_{k_{2}}=1}}{\bigotimes}} (1\oplus \left|\zeta_{2,k_{2}}\right|) \otimes \overset{}{\underset{\substack{j_{2} \in [m],\\\beta_{j_{2}}=0}}{\bigotimes}} (1\oplus \left|\zeta_{2,j_{2}}\right|) \Big)\Bigg) \otimes \overset{}{\underset{l\in [r]}{\bigotimes}} (1\oplus \left|\xi_{l}\right|) \oplus\\
& \Bigg(\overset{}{\underset{\substack{\lambda\in[r],\\\delta_{\lambda}=1}}{\bigoplus}} \Big( \left|\xi_{\lambda}\right| \otimes \overset{}{\underset{\substack{\mu\neq \lambda,\\\delta_{\mu}=1}}{\bigotimes}} (1\oplus \left|\xi_{\mu}\right|) \otimes \overset{}{\underset{\substack{\nu \in [r],\\\delta_{\nu}=0}}{\bigotimes}} (1\oplus \left|\xi_{\nu}\right|) \Big)\Bigg) \otimes \overset{}{\underset{j\in [m]}{\bigotimes}} (1\oplus \left|\zeta_{2,j}\right|).
\end{align*}
\end{itemize}
\end{itemize}
\end{itemize}
Hence, we get that $\zeta_{1}\otimes \left[ \xi_{1} \right]^{\delta_{1}} \otimes \ldots \otimes \left[ \xi_{r} \right]^{\delta_{r}} \equiv \zeta_{2}\otimes \left[ \xi_{1} \right]^{\delta_{1}} \otimes \ldots \otimes \left[ \xi_{r} \right]^{\delta_{r}}$ in Case 2. Therefore, in any case it holds that $ \zeta_{1}\otimes \left[ \xi_{1} \right]^{\delta_{1}} \otimes \ldots \otimes \left[ \xi_{r} \right]^{\delta_{r}} \equiv \zeta_{2}\otimes \left[ \xi_{1} \right]^{\delta_{1}} \otimes \ldots \otimes \left[ \xi_{r} \right]^{\delta_{r}}$. For the symmetric cases of (1)-(4) and for any other position of $\zeta_{1}$ (resp. $\zeta_{2}$) in (5) the proof is analogous. Finally, for any other form of the expression $E$ we apply the presented cases iteratively, and our proof is completed.\qed
\end{enumerate}\end{prof*}
\hide{Thus, we showed that for any expression $E\in wAC\left( P\cup \left\lbrace r\right\rbrace \right)$ it holds $\left| E(\zeta_{1}/r)\right|=\left| E(\zeta_{2}/r)\right|$, i.e., $\zeta_{1}\cong \zeta_{2}$, and our proof is completed.}
Next result is derived by a direct application of Theorem \ref{th1}.
\begin{coro}\label{new_neutral}
For $\zeta\in wAC(P)$ such that $\#_{T}\zeta>0$ it holds that $\zeta\otimes [0']'\cong \zeta$.
\end{coro}
\begin{prof*}
\hide{For weighted monomials $\zeta\in wAC(P)$ the proof results by a straightforward application of Theorem \ref{th1}. Indeed, one can easily verify that $\zeta\otimes [0']'\equiv \zeta$ and $\zeta\otimes 0'\otimes 1'\equiv \zeta\otimes [1]'$. The condition that the degrees of both sides are simultaneously non-zero is guaranteed by the assumption $\#_{T}\zeta>0$. We now prove the congruence relation for the general case that $\zeta$ is not a monomial.} Let $\zeta=\left[ \zeta_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \zeta_{n} \right]^{\alpha_{n}}\in wAC(P)$ where $\#_{T}\zeta > 0$ and $ \alpha_{i}\in \left\lbrace 0,1\right\rbrace $ for $i\in \left[ n\right]$. We prove that the three conditions in the right hand-side of Theorem \ref{th1} are satisfied. \hide{For the first and the second condition we apply the semantics of the $wAC(P)$, and the last condition is obtained by the assumption of the corollary, and we are done.}Specifically, for the first condition $\zeta\otimes [0']'\equiv \zeta$, we have
\begin{align*}
\big| \left[ \zeta_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \zeta_{n} \right]^{\alpha_{n}}\otimes [0']'\big| =& \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left|\zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} (1\oplus \left|\zeta_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1\oplus \left|\zeta_{j}\right|) \otimes (1\oplus \left|0'\right|)\Big)\\& \oplus \left|0'\right|\otimes \bigotimes_{i\in [n]}\left( 1\oplus \left|\zeta_{i}\right|\right) \\
=& \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left|\zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} (1\oplus \left|\zeta_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1\oplus \left|\zeta_{j}\right|) \Big)\\
=& \left|\zeta\right|.
\end{align*}
\noindent Thus, we get that $\zeta\otimes [0']'\equiv \zeta$.
\noindent For the second condition $\zeta\otimes [0']'\otimes [1]'\equiv \zeta\otimes [1]'$ we prove that
$$\big| \left[ \zeta_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \zeta_{n} \right]^{\alpha_{n}}\otimes [0']'\otimes [1]'\big| = \big| \left[ \zeta_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \zeta_{n} \right]^{\alpha_{n}}\otimes [1]'\big|.$$
\noindent For the left part of the above equality we have
\begin{align*}
&\big| \left[ \zeta_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \zeta_{n} \right]^{\alpha_{n}} \otimes [0']'\otimes [1]' \big|\\ =&\overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left|\zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} (1\oplus \left|\zeta_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1\oplus \left|\zeta_{j}\right|) \otimes (1\oplus \left|0'\right|)\otimes (1\oplus \left|1\right|)\Big)\oplus \\
& \left(\left|0'\right|\otimes \bigotimes_{i\in [n]} (1\oplus \left|\zeta_{i}\right|)\otimes (1\oplus \left|1\right|) \right) \oplus \left(\left|1\right|\otimes \bigotimes_{i\in [n]} (1\oplus \left|\zeta_{i}\right|)\otimes (1\oplus\left|0'\right|) \right)\\
=& \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left|\zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} (1\oplus \left|\zeta_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1\oplus \left|\zeta_{j}\right|) \Big)\oplus \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left|\zeta_{i}\right|) .
\end{align*}
\noindent Similarly, for the right part of the equality we get that
\begin{align*}
&\big| \left[ \zeta_{1} \right]^{\alpha_{1}} \otimes \ldots \otimes \left[ \zeta_{n} \right]^{\alpha_{n}}\otimes [1]' \big| \\
=& \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left|\zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} (1\oplus \left|\zeta_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1\oplus \left|\zeta_{j}\right|) \otimes (1\oplus \left|1\right|)\Big) \oplus \left(\left|1\right|\otimes \bigotimes_{i\in [n]} (1\oplus \left|\zeta_{i}\right|) \right)\\
=& \overset{}{\underset{\substack{i\in[n],\\\alpha_{i}=1}}{\bigoplus}} \Big( \left|\zeta_{i}\right| \otimes \overset{}{\underset{\substack{k\neq i,\\\alpha_{k}=1}}{\bigotimes}} (1\oplus \left|\zeta_{k}\right|) \otimes \overset{}{\underset{\substack{j \in [n],\\\alpha_{j}=0}}{\bigotimes}} (1\oplus \left|\zeta_{j}\right|) \Big)\oplus \overset{}{\underset{i\in [n]}{\bigotimes}} (1\oplus \left|\zeta_{i}\right|).
\end{align*}
Therefore, it holds that $\zeta\otimes [0']'\otimes [1]'\equiv \zeta\otimes [1]'$.
\noindent The last condition of the theorem that requires the degree of both sides to be simultaneously zero or simultaneously non-zero, is obtained by the assumption of the corollary.\qed
\end{prof*}
\hide{It should be clear that in all of the presented proofs of the current section it would have sufficed to obtain the required equivalences of the $wAC(P)$ connectors just by showing the equality of their corresponding $wAI(P)$ components.}
\hide{\begin{examp}
Consider the $wAC(P)$ connectors
$$[p\oplus q]' \otimes r\otimes s$$
and
$$[p\oplus q]' \otimes [r'\otimes s'].$$
We will prove that the $wAC(P)$ connectors are congruent by verifying the three conditions of Theorem \ref{th1}.
\par For the first condition that requires the equivalence of weighted connectors is obtained as follows:
\begin{align*}
\big| [p\oplus q]' \otimes r\otimes s \big| =& \left|p\oplus q\right|\otimes (1\oplus \left|r\right|) \otimes (1\oplus \left|s\right|)\\
=& (\left|p\right|\oplus \left|q\right|)\otimes (1\oplus \left|r\right|) \otimes (1\oplus \left|s\right|) \\
=& (p\oplus q)\otimes (1\oplus r) \otimes (1\oplus s)
\end{align*}
and
\begin{align*}
\big| [p\oplus q]' \otimes [r'\otimes s'] \big| =& \left|p\oplus q\right|\otimes (1\oplus \left| r' \otimes s' \right|)\\
=& (\left|p\right|\oplus \left|q\right|)\otimes \Big( 1\oplus \big(\left|r\right| \otimes (1\oplus \left|s\right|)\big) \oplus \big(\left|s\right| \otimes (1\oplus \left|r\right|)\big) \Big)\\
=& (p\oplus q)\otimes \Big( 1\oplus \big(r \otimes (1\oplus s)\big) \oplus \big(s \otimes (1\oplus r)\big) \Big)\\
=& (p\oplus q)\otimes \big( 1\oplus r \oplus (r\otimes s) \oplus s \oplus (s \otimes r)\big)\\
=& (p\oplus q)\otimes \big( 1\oplus r \oplus s \oplus (r\otimes s) \big) \\
=& (p\oplus q)\otimes (1\oplus r) \otimes (1\oplus s).
\end{align*}
For the second condition of Theorem \ref{th1} we have that
\begin{align*}
&\big| [p\oplus q]' \otimes r\otimes s \otimes 1'\big|\\
=& \big(\left|p\oplus q\right|\otimes (1\oplus \left|1\right|) \otimes (1\oplus \left|r\right|) \otimes (1\oplus \left|s\right|)\big) \oplus \big( \left|1\right| \otimes (1\oplus \left|p\oplus q\right|) \otimes (1\oplus \left|r\right|) \otimes (1\oplus \left|s\right|) \big)\\
=& \big( (\left|p\right|\oplus \left|q\right|)\otimes (1\oplus \left|r\right|) \otimes (1\oplus \left|s\right|) \big) \oplus \Big( \big(1\oplus (\left|p\right|\oplus \left|q\right|) \big) \otimes (1\oplus \left|r\right|) \otimes (1\oplus \left|s\right|)\Big)\\
=& \big( (p\oplus q)\otimes (1\oplus r) \otimes (1\oplus s)\big) \oplus \Big(\big(1 \oplus (p\oplus q) \big)\otimes (1\oplus r) \otimes (1\oplus s)\Big)\\
=& \big( (p\oplus q)\otimes (1\oplus r) \otimes (1\oplus s)\big) \oplus \big( 1\otimes (1\oplus r) \otimes (1\oplus s) \big) \oplus \big((p\oplus q) \otimes (1\oplus r) \otimes (1\oplus s)\big) \\
=& \big((p\oplus q) \otimes (1\oplus r) \otimes (1\oplus s)\big) \oplus \big( (1\oplus r) \otimes (1\oplus s) \big) \\
=& \big(1 \oplus (p\oplus q) \big)\otimes (1\oplus r) \otimes (1\oplus s) \\
=& (1 \oplus p\oplus q) \otimes (1\oplus r) \otimes (1\oplus s)
\end{align*}
and
\begin{align*}
&\big| [p\oplus q]' \otimes [r'\otimes s'] \otimes 1' \big| \\
=& \big( \left|p\oplus q\right| \otimes (1\oplus \left|1\right|)\otimes (1\oplus \left| r' \otimes s' \right|) \big) \oplus \big(\left|1\right| \otimes (1\oplus \left|p\oplus q\right|) \otimes (1\oplus \left| r' \otimes s' \right|) \big)\\
=& (\left|p\right|\oplus \left|q\right|)\otimes \Big( 1\oplus \big(\left|r\right| \otimes (1\oplus \left|s\right|)\big) \oplus \big(\left|s\right| \otimes (1\oplus \left|r\right|)\big) \Big) \oplus \big( (1\oplus \left|p\oplus q\right|) \otimes (1\oplus \left| r' \otimes s' \right|) \big)\\
=& \bigg((p\oplus q)\otimes \Big( 1\oplus \big(r \otimes (1\oplus s)\big) \oplus \big(s \otimes (1\oplus r)\big) \Big) \bigg) \oplus \bigg(\big(1 \oplus (p\oplus q) \big) \otimes \Big(1 \oplus\big(r \otimes (1\oplus s)\big) \oplus \big(s \otimes (1\oplus r)\big) \Big) \bigg)\\
=& \Big( (p\oplus q)\otimes \big( 1\oplus r \oplus (r\otimes s) \oplus s \oplus (s \otimes r) \big) \Big) \oplus \Big( (1 \oplus p\oplus q ) \otimes \big( 1\oplus r \oplus (r\otimes s) \oplus s \oplus (s \otimes r) \big)\Big) \\
=& \Big( (p\oplus q)\otimes \big( 1\oplus r \oplus s \oplus (s \otimes r) \big) \Big) \oplus \Big( (1 \oplus p\oplus q ) \otimes \big( 1\oplus r \oplus s \oplus (s \otimes r) \big)\Big) \\
=& \big( (p\oplus q)\otimes ( 1\oplus r )\otimes (1 \oplus s) \big) \oplus \big( (1 \oplus p\oplus q ) \otimes ( 1\oplus r )\otimes (1 \oplus s) \big) \\
=& \big( (p\oplus q)\otimes (1\oplus r) \otimes (1\oplus s)\big) \oplus \big( 1\otimes (1\oplus r) \otimes (1\oplus s) \big) \oplus \big((p\oplus q) \otimes (1\oplus r) \otimes (1\oplus s)\big) \\
=& \big((p\oplus q) \otimes (1\oplus r) \otimes (1\oplus s)\big) \oplus \big( (1\oplus r) \otimes (1\oplus s) \big) \\
=& \big(1 \oplus (p\oplus q) \big)\otimes (1\oplus r) \otimes (1\oplus s) \\
=& (1 \oplus p\oplus q) \otimes (1\oplus r) \otimes (1\oplus s).
\end{align*}
\end{examp}
\hide{\begin{examp}
Consider the weighted connector
$$[p]'\otimes [q]' \oplus [r_{1}]'\otimes [r_{2}\oplus r_{3}]\otimes [r_{4}].$$
We will prove that the weighted connector $[r_{1}]'\otimes [r_{2}\oplus r_{3}]\otimes [r_{4}]$ is congruent with the connector $[r_{1}]^{'}\otimes \big[ [ r_{2}\oplus r_{3} ]^{'}\otimes [r_{4}]^{'} \big]$ by verifying the three conditions of Theorem \ref{th1}.
\par For the first condition that requires the equivalence of weighted connectors is obtained as follows:
\begin{align*}
&\Big|[r_{1}]'\otimes [r_{2}\oplus r_{3}]\otimes [r_{4}]\Big|=\left| r_{1}\right| \otimes \big( 1\oplus \left| r_{2}\oplus r_{3} \right| \big)\otimes (1\oplus \left|r_{4}\right|)\\
=& \left| r_{1}\right| \otimes \big( 1\oplus \left| r_{2}\right|\oplus \left| r_{3}\right| \big)\otimes (1\oplus \left|r_{4}\right|)\\
=& r_{1} \otimes \left( 1\oplus r_{2}\oplus r_{3} \right)\otimes (1\oplus r_{4})
\end{align*}
and
\begin{align*}
&\Big| [r_{1}]^{'}\otimes \big[ [ r_{2}\oplus r_{3} ]^{'}\otimes [r_{4}]^{'} \big] \Big|= \left| r_{1}\right| \otimes \Big(1 \oplus \big| [ r_{2}\oplus r_{3} ]^{'}\otimes [r_{4}]^{'}\big| \Big) \\
=& \left| r_{1}\right| \otimes \big(1 \oplus \left| r_{2}\oplus r_{3} \right| \otimes (1\oplus \left| r_{4}\right|)\oplus \left| r_{4}\right|\otimes (1\oplus \left| r_{2}\oplus r_{3} \right|) \big)\\
=& \left| r_{1}\right| \otimes \Big(1 \oplus \big(\left| r_{2}\right|\oplus \left| r_{3} \right|\big) \otimes (1\oplus \left| r_{4}\right|)\oplus \left| r_{4}\right|\otimes \big(1\oplus \left| r_{2}\right|\oplus \left| r_{3} \right|\big) \Big)\\
=& r_{1} \otimes \Big(1 \oplus \left(r_{2}\oplus r_{3} \right) \otimes (1\oplus r_{4})\oplus r_{4}\otimes \big(1\oplus \left(r_{2}\oplus r_{3} \right)\big) \Big)
\end{align*}
\end{examp}}}
\hide{\par Obviously, by Corollary \ref{new_neutral} we obtain an alternative proof that $[0']'$ can serve as the neutral element of the weighted fusion operator in the subalgebra of triggers $wAT(P)$.}
\par Next proposition constitutes another application of Theorem \ref{th1} for proving congruence relation of $wAC(P)$ connectors.
\begin{prop}\label{ext}
Let $\zeta_{1}, \zeta_{2}, \zeta_{3} \in wAC(P)$. Then, we have
\begin{enumerate}[label=\roman*)]
\item $\left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right] \otimes \left[ \zeta_{3}\right] \cong \left[ \zeta_{1}\right] '\otimes\left[ \left[ \zeta_{2}\right]' \otimes \left[ \zeta_{3}\right]'\right] $, and
\item $\left[ \zeta_{1} \right] '\otimes \left[ \zeta_{2}\right] ' \cong \left[ \left[ \zeta_{1} \right] '\otimes \left[ \zeta_{2}\right] '\right] '$. \label{as-tr}
\end{enumerate}
\end{prop}
\begin{prof*}
We apply Theorem \ref{th1} and Corollary \ref{walg_semi}, and we are done.
\end{prof*}
\hide{
\begin{prof*}
\begin{enumerate}[label=\roman*)]
In order to prove the above congruence relations we apply Theorem \ref{th1} and use the fact that $(wAI(P)/\equiv, \oplus, \otimes, \bar{0},\bar{1})$ is an idempotent semiring.
\item The $wAI(P)$ component of connector $\left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right] \otimes \left[ \zeta_{3}\right]$ is obtained as follows:
\begin{align*}
\big| \left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right] \otimes \left[ \zeta_{3}\right]\big| =&\left|\zeta_{1}\right|\otimes \left( 1\oplus \left|\zeta_{2}\right|\right) \otimes \left( 1\oplus \left|\zeta_{3}\right|\right) \\
=&\left|\zeta_{1}\right|\otimes \big( 1\oplus \left|\zeta_{2}\right|\oplus \left|\zeta_{3}\right|\oplus (\left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|) \big) \\
=& \left|\zeta_{1}\right|\oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{2}\right|) \oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{3}\right|) \oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|).
\end{align*}
Also, the $wAI(P)$ component of connector $\left[ \zeta_{1}\right] '\otimes\left[ \left[ \zeta_{2}\right]' \otimes \left[ \zeta_{3}\right]'\right]$ is computed as follows:
\begin{align*}
\big| \left[ \zeta_{1}\right] '\otimes\left[ \left[ \zeta_{2}\right]' \otimes \left[ \zeta_{3}\right]'\right] \big| =&\left|\zeta_{1}\right|\otimes \Big( 1\oplus \big| \left[ \zeta_{2}\right]'\otimes \left[ \zeta_{3}\right] '\big| \Big) \\
=&\left|\zeta_{1}\right|\otimes \Big( 1\oplus \big(\left|\zeta_{2}\right|\otimes \left( 1\oplus\left|\zeta_{3}\right|\right) \big) \oplus \big(\left|\zeta_{3}\right|\otimes \left( 1\oplus\left|\zeta_{2}\right|\right) \big) \Big) \\
=&\left|\zeta_{1}\right|\otimes \big( 1\oplus \left|\zeta_{2}\right|\oplus (\left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|)\oplus \left|\zeta_{3}\right|\oplus (\left|\zeta_{3}\right|\otimes \left|\zeta_{2}\right|)\big) \\
=&\left|\zeta_{1}\right|\otimes \big( 1\oplus \left|\zeta_{2}\right|\oplus \left|\zeta_{3}\right|\oplus (\left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|)\big) \\
=& \left|\zeta_{1}\right|\oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{2}\right|)\oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{3}\right|)\oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{2}\right|\otimes \left|\zeta_{3}\right|).
\end{align*}
Hence, it holds $\big|\left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right] \otimes \left[ \zeta_{3}\right] \big| = \big| \left[ \zeta_{1}\right] '\otimes\left[ \left[ \zeta_{2}\right]' \otimes \left[ \zeta_{3}\right]'\right] \big| $. and the first condition of the theorem is satisfied. For the second condition of Theorem \ref{th1} we have:
\begin{align*}
&\big|\left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right] \otimes \left[ \zeta_{3}\right]\otimes 1' \big|\\
=& \big(\left|\zeta_{1}\right|\otimes \left( 1\oplus \left|1\right|\right) \otimes \left( 1\oplus \left|\zeta_{2}\right|\right) \otimes \left( 1\oplus \left|\zeta_{3}\right|\right)\big) \oplus \big(\left|1\right|\otimes \left( 1\oplus \left|\zeta_{1}\right|\right)\otimes \left( 1\oplus \left|\zeta_{2}\right|\right) \otimes \left( 1\oplus \left|\zeta_{3}\right|\right)\big)\\
=&\big(\left|\zeta_{1}\right|\otimes \left( 1\oplus \left|\zeta_{2}\right|\right) \otimes \left( 1\oplus \left|\zeta_{3}\right|\right)\big) \oplus \big( \left( 1\oplus \left|\zeta_{1}\right|\right)\otimes \left( 1\oplus \left|\zeta_{2}\right|\right) \otimes \left(1 \oplus \left|\zeta_{3}\right|\right)\big)\\
=&\big(\left|\zeta_{1}\right|\otimes \left( 1\oplus \left|\zeta_{2}\right|\right) \otimes \left( 1\oplus \left|\zeta_{3}\right|\right)\big) \oplus \big( 1\otimes \left( 1\oplus \left|\zeta_{2}\right|\right) \otimes \left(1 \oplus \left|\zeta_{3}\right|\right) \big) \oplus \\
&\big(\left|\zeta_{1}\right|\otimes \left( 1\oplus \left|\zeta_{2}\right|\right) \otimes \left(1 \oplus \left|\zeta_{3}\right|\right)\big)\\
=&\big(\left|\zeta_{1}\right|\otimes \left( 1\oplus \left|\zeta_{2}\right|\right) \otimes \left( 1\oplus \left|\zeta_{3}\right|\right) \big) \oplus \big( 1\otimes \left( 1\oplus \left|\zeta_{2}\right|\right) \otimes \left(1 \oplus \left|\zeta_{3}\right|\right) \big) \\
=&\left( \left|\zeta_{1}\right|\oplus 1\right) \otimes \left( 1\oplus \left|\zeta_{2}\right|\right) \otimes \left( 1\oplus \left|\zeta_{3}\right|\right) \\
=&\left(1 \oplus \left|\zeta_{1}\right| \right) \otimes \left( 1\oplus \left|\zeta_{2}\right|\right) \otimes \left( 1\oplus \left|\zeta_{3}\right|\right)
\end{align*}
and
\begin{align*}
&\big| \left[ \zeta_{1}\right] '\otimes\left[ \left[ \zeta_{2}\right]' \otimes \left[ \zeta_{3}\right]'\right]\otimes 1' \big|\\
=&\Big(\left|\zeta_{1}\right|\otimes \left( 1\oplus\left|1\right|\right) \otimes \big( 1\oplus \big| \left[ \zeta_{2}\right] '\otimes \left[ \zeta_{3}\right] ' \big| \big) \Big) \oplus \Big( \left|1\right|\otimes \left( 1 \oplus \left|\zeta_{1}\right|\right) \otimes \big( 1\oplus \big| \left[ \zeta_{2}\right] '\otimes \left[ \zeta_{3}\right] ' \big| \big) \Big)\\
=&\bigg( \left|\zeta_{1}\right| \otimes \Big( 1\oplus (\left|\zeta_{2}\right|\otimes \left( 1\oplus \left|\zeta_{3}\right|\right) )\oplus \big(\left|\zeta_{3}\right|\otimes \left( 1\oplus \left|\zeta_{2}\right|\right)\big) \Big) \bigg) \oplus \bigg(\left( 1 \oplus \left|\zeta_{1}\right|\right) \otimes \\
& \Big( 1\oplus \big(\left|\zeta_{2}\right|\otimes \left( 1\oplus \left|\zeta_{3}\right|\right) \big) \oplus \big(\left|\zeta_{3}\right|\otimes \left( 1\oplus \left|\zeta_{2}\right|\right)\big)\Big) \bigg) \\
=& \left|\zeta_{1}\right| \otimes \Big( 1\oplus (\left|\zeta_{2}\right|\otimes \left( 1\oplus \left|\zeta_{3}\right|\right) )\oplus \big(\left|\zeta_{3}\right|\otimes \left( 1\oplus \left|\zeta_{2}\right|\right)\big) \Big) \oplus \left( 1 \oplus \left|\zeta_{1}\right|\right) \otimes \\
& \Big( 1\oplus \big(\left|\zeta_{2}\right|\otimes \left( 1\oplus \left|\zeta_{3}\right|\right) \big) \oplus \big(\left|\zeta_{3}\right|\otimes \left( 1\oplus \left|\zeta_{2}\right|\right)\big)\Big) \\
=& \big( \left|\zeta_{1}\right|\oplus (1\oplus\left| \zeta_{1}\right|)\big) \otimes \Big( 1\oplus \big(\left|\zeta_{2}\right|\otimes \left( 1\oplus \left|\zeta_{3}\right|\right)\big) \oplus \big(\left|\zeta_{3}\right|\otimes \left( 1\oplus \left|\zeta_{2}\right|\right)\big)\Big) \\
=& (1\oplus \left| \zeta_{1}\right|) \otimes \big( 1\oplus \left|\zeta_{2}\right|\oplus (\left|\zeta_{2}\right| \otimes \left| \zeta_{3}\right|) \oplus \left|\zeta_{3}\right|\oplus (\left|\zeta_{3}\right| \otimes \left| \zeta_{2}\right|) \big)\\
=& (1\oplus \left| \zeta_{1}\right|) \otimes \big( 1\oplus \left|\zeta_{2}\right|\oplus \left|\zeta_{3}\right| \oplus (\left|\zeta_{2}\right| \otimes \left| \zeta_{3}\right| )\big)\\
=&(1\oplus \left| \zeta_{1}\right|)\otimes (1\oplus \left| \zeta_{2}\right|)\otimes (1\oplus \left| \zeta_{3}\right|).
\end{align*}
Hence, we showed that $\big|\left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right] \otimes \left[ \zeta_{3}\right]\otimes 1'\big|=\big|\left[ \zeta_{1}\right] '\otimes\left[ \left[ \zeta_{2}\right]' \otimes \left[ \zeta_{3}\right]'\right]\otimes 1' \big|$. The third condition, concerning the degree of these connectors, is obviously satisfied. Consequently, the components $\left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right] \otimes \left[ \zeta_{3}\right]$ and $\left[ \zeta_{1}\right] '\otimes\left[ \left[ \zeta_{2}\right]' \otimes \left[ \zeta_{3}\right]'\right] $ are congruent.
\item We compute the $wAI(P)$ component of the $wAC(P)$ connector $\left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right]'$ and we have that
\begin{align*}
\left| \left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right]' \right| =&\big(\left|\zeta_{1}\right|\otimes \left( 1\oplus \left| \zeta_{2}\right| \right)\big) \oplus \big(\left| \zeta_{2}\right| \otimes \left(1 \oplus \left| \zeta_{1}\right| \right)\big) \\
=&\left|\zeta_{1}\right|\oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{2}\right|\otimes \left|\zeta_{1}\right|) \\
=&\left|\zeta_{1}\right|\oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{2}\right|) \\
=&\left|\zeta_{1}\right|\oplus\left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|).
\end{align*}
For the second connector $\left[ \left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right]'\right] '$ we obtain the respective $wAI(P)$ component as follows:
\begin{align*}
\left|\left[ \left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right]'\right] ' \right|=&\left| \left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right]' \right| \\ =&\big(\left|\zeta_{1}\right|\otimes \left( 1\oplus \left| \zeta_{2}\right| \right) \big) \oplus \big( \left| \zeta_{2}\right| \otimes \left(1 \oplus \left| \zeta_{1}\right| \right)\big) \\
=&\left|\zeta_{1}\right|\oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{2}\right|\otimes \left|\zeta_{1}\right| )\\
=&\left|\zeta_{1}\right|\oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|) \oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{2}\right|) \\
=&\left|\zeta_{1}\right|\oplus\left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right| \otimes \left|\zeta_{2}\right|).
\end{align*}
Thus, we get that $\big| \left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right]' \big|=\Big|\left[ \left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right]'\right] ' \Big|$. For the second condition of Theorem \ref{th1} we have:
\begin{align*}
&\big| \left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right]' \otimes 1'\big|\\
=&\big(\left|\zeta_{1}\right|\otimes \left( 1 \oplus \left|\zeta_{2}\right|\right) \otimes (1\oplus \left|1\right|) \big)\oplus \big( \left|\zeta_{2}\right|\otimes \left( 1\oplus \left|\zeta_{1}\right|\right) \otimes (1\oplus \left|1\right|) \big) \oplus \\
&\big(\left|1\right|\otimes \left( 1 \oplus \left|\zeta_{1}\right|\right) \otimes \left( 1 \oplus \left|\zeta_{2}\right|\right)\big) \\
=&\big(\left|\zeta_{1}\right|\otimes \left( 1 \oplus \left|\zeta_{2}\right|\right)\big) \oplus \big( \left|\zeta_{2}\right|\otimes \left( 1\oplus \left|\zeta_{1}\right|\right) \big) \oplus \big( \left( 1 \oplus \left|\zeta_{1}\right|\right) \otimes \left( 1 \oplus \left|\zeta_{2}\right|\right) \big) \\
=& \left|\zeta_{1}\right|\oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{2}\right|) \oplus \left|\zeta_{2}\right|\oplus (\left|\zeta_{2}\right|\otimes \left|\zeta_{1}\right|) \oplus 1 \oplus \left|\zeta_{1}\right|\oplus \left|\zeta_{2}\right|\oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{2}\right|)\\
=& 1\oplus \left|\zeta_{1}\right|\oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{2}\right|).
\end{align*}
On the other hand, we have
\begin{align*}
&\Big| \left[ \left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right]'\right] '\otimes [1]'\Big|\\
=& \Big(\big| \left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right]' \big| \otimes (1\oplus \left|1\right|) \Big) \oplus \Big(\left|1\right|\otimes \big( 1 \oplus \big| \left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right]' \big|\big)\Big)\\
=& \big| \left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right]' \big| \oplus \Big( 1 \oplus \big| \left[ \zeta_{1}\right] '\otimes \left[ \zeta_{2}\right]' \big|\Big)\\
=& \Big(\big(\left|\zeta_{1}\right|\otimes \left( 1\oplus \left|\zeta_{2}\right|\right)\big) \oplus \big(\left|\zeta_{2}\right|\otimes \left( 1\oplus \left|\zeta_{1}\right|\right)\big)\Big) \oplus \Big(1 \oplus \big(\left|\zeta_{1}\right|\otimes \left( 1\oplus \left|\zeta_{2}\right|\right)\big) \oplus \big(\left|\zeta_{2}\right|\otimes \left( 1\oplus \left|\zeta_{1}\right|\right)\big)\Big) \\
=& 1 \oplus \big(\left|\zeta_{1}\right|\otimes \left( 1\oplus \left|\zeta_{2}\right|\right)\big) \oplus \big(\left|\zeta_{2}\right|\otimes \left( 1\oplus \left|\zeta_{1}\right|\right)\big)\\
=& 1 \oplus \left|\zeta_{1}\right|\oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{2}\right|)\oplus \left|\zeta_{2}\right|\oplus (\left|\zeta_{2}\right|\otimes \left|\zeta_{1}\right|)\\
=& 1\oplus \left|\zeta_{1}\right|\oplus \left|\zeta_{2}\right| \oplus (\left|\zeta_{1}\right|\otimes \left|\zeta_{2}\right|).
\end{align*}
Therefore we obtain that $\big|\left[ \zeta_{1} \right] '\otimes \left[ \zeta_{2}\right] ' \otimes 1'\big|=\Big|\left[ \left[ \zeta_{1} \right] '\otimes \left[ \zeta_{2}\right] '\right] '\otimes 1'\Big|$. Also, the third condition for the degrees of the terms is obviously satisfied. Hence, the connectors $\left[ \zeta_{1} \right] '\otimes \left[ \zeta_{2}\right] '$ and $\left[ \left[ \zeta_{1} \right] '\otimes \left[ \zeta_{2}\right] '\right] '$ are congruent, and our proof is completed.\qed
\end{enumerate}
\end{prof*}
Observe that by a direct application of Proposition \ref{ext}.\ref{as-tr} we can actually obtain the associativity property w.r.t. trigger typing operator, hence we present an alternative proof for Proposition \ref{}.\ref{}.}
\section{Conclusion}\label{se8}
\hide{In this paper we developed an algebraic framework for the formal characterization of the
quantitative aspects of connectors occurring in component-based systems. In particular, we firstly
introduced and studied a weighted Algebra of Interactions, namely $wAI(P)$ over the set $P$ of ports of
a system and semiring $K$, that was interpreted by polynomials in $ K\left\langle
\Gamma(P)\right\rangle $. We proved that the structure $(wAI(P)/\equiv,\oplus,\otimes, 0,1)$ acknowledges the properties of a commutative and idempotent
semiring, and we applied the $wAI(P)$ algebra for describing several well-known coordination schemes with quantitative features.
In turn, we introduced our second algebra $wAC(P)$ that extended $wAI(P)$ by two typing operators, namely
triggers ``$\left[ \cdot \right]' $'' that initiate an interaction and synchrons
``$\left[ \cdot \right] $'' that need synchronization with other ports in order to interact.
We expressed the semantics of $wAC(P)$ connectors as $wAI(P)$ components by the function $\left| \cdot \right|:wAC(P) \to wAI(P) $
and then, applying the semantics of $wAI(P)$, we derived the corresponding weight of the connectors over a concrete set of interactions in $P$.
We proved several nice properties for $wAC(P)$ and we showed the expressiveness of our algebra by modeling several weighted connectors. Moreover,
we studied two subalgebras of $wAC(P)$, the weighted Algebra of Synchrons $wAS(P)$ and Triggers $wAT(P)$ over $P$ and $K$, where the former restricts to synchron
elements and the latter to trigger elements. Finally, we defined a notion of weighted congruence relation for connectors and we proved two theorems that
induced a method for checking congruence of distinct weighted connectors. This is an important result for the modeling process of component-based systems, since it allows the
replacement of connectors, whenever this is necessary, without causing alterations in the systems' interaction patterns.}
There are several directions for future work. Specifically to the results
presented in the paper, recall that by the idempotency property of the semiring
we achieved to restrict computing unnecessarily the weight of identical interactions
resulting by the semantics of $wAI(P)$ and $wAC(P)$. Hence, it would be interesting
to investigate whether we could relax the idempotency property of the semiring $K$.
Another work direction includes studying the concept of weighted connectors over
more general structures than semirings, that are currently used in practical applications,
for instance valuation monoids (cf. \cite{Dr:Re,Ka:We}).
Another problem is developing a theory for modeling not only connectors but also the underlying behavior of component-based systems.
Regarding the BIP framework, in \cite{Bl:No} the authors studied the concept of glue operators
as composition operators, in order to formalize the coordinated behavior in component-based
systems, while in \cite{Bl:Sy} they alternatively expressed glue operators as boolean constraints
between interactions and the state of the coordinated components. Therefore, future
research is also investigating the quantitative behavior of component-based systems, whose connectors are defined by our weighted algebra (cf. also \cite{Br:St,Br:Ba,Sa:Us,Su:Re}).
On the other hand, several theories and languages have modeled connectors as entities that both exhibit behavior and express interactions
which may be modified during the system's operation \cite{Be:On,Pa:Co}.
In other words, it would be interesting to extend our results for stateful connectors and dynamic interactions.
In addition to these theoretical directions, ongoing work includes an implementation of
the current formal framework and experimentation with case studies.
\bibliographystyle{alpha}
|
{'timestamp': '2022-02-18T02:03:23', 'yymm': '2202', 'arxiv_id': '2202.06594', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06594'}
|
arxiv
|
\section{Introduction}
\label{sec:intro}
\begin{figure*}
\includegraphics[width=\linewidth]{pipeline.png}
\centering
\caption{Pipeline of the kernel computation for a polyhedron. At first step, we compute the Axis Aligned Bounding Box (AABB) of the polyhedron; then, we iterate on each face $f$ of the polyhedron (black edges) and cut AABB with the plane induced by $f$ (red edges).}
\label{fig:pipeline}
\end{figure*}
The concept of \emph{geometric kernel} of a polygon, a polyhedron, or more generally of a shape, is a pillar of computational geometry.
Roughly speaking, the kernel of a closed geometric shape $S$ is the locus of the points internal to $S$ from which the whole shape $S$ is visible.
The kernel of a convex shape coincides with the shape itself, while the concept is particularly interesting for non-convex shapes and in particular, polytopes. The kernel of non-convex shapes can also be empty, as in the case of non simply-connected objects for which it is always empty.
In the two-dimensional scenario, that is when the shape is a polygon, the standard way of computing the kernel is by intersecting appropriate half-planes generated from its edges.
This problem has been tackled since the 70s, when \cite{ShamosHoey} presented an algorithm able to perform the kernel computation in $O(e\log e)$ operations, being $e$ the number of edges of a polygon, as the intersection of $e$ half-edges.
After that, an optimal algorithm able to run in $O(n)$ operations over an $n-$sided polygon, has been proposed in \cite{LeePreparata}.
Famous computational tools and libraries like \textit{Boost} \cite{BoostLibrary}, \textit{Geogram} \cite{levy2015geogram}, \textit{CGAL} \cite{fabri2009cgal}, or \textit{Libigl} \cite{jacobson2017libigl} currently implement routines to compute intersections between polygons and planes, which can be used to estimate the kernel.
In the first attempts to solve the volumetric version of the problem, for example in \cite{PreparataShamos}, the natural approach has been to extend the 2D method (which we call \textit{geometric)} to the 3D case from a theoretical point of view, but it was soon dismissed as unattractive for computational reasons.
It was replaced by a new approach (which we call \textit{algebraic)} which makes use of linear algebra and homogeneous coordinates, and that is the state of the art for computing 3D kernels currently implemented by libraries like CGAL.
During years, the polygon kernel computation has become popular to address several problems based on simple polygon analysis, such as star-components decomposition and visibility algorithms that are of interest in robotics, surveillance, geometric modeling, computer vision and, recently, in the emerging field of additive manufacturing \cite{demir2018near}.
Today, the geometric kernel of a polytope is a pivotal information for understanding the geometrical quality of an element in the context of finite elements analysis.
While in the past years finite elements methods were only designed to work on convex elements like triangles/tetrahedra or quadrangles/hexahedra \cite{ciarlet2002finite}, recent and more complex methods like the Mimetic Finite Difference Method \cite{lipnikov2014mimetic}, the Virtual Elements Method \cite{beirao2013basic}, the Discontinuous Galerkin Mehod \cite{cockburn2012discontinuous} or the Hybrid High Order Method \cite{di2019hybrid} are able to deal with non convex polytopes.
This enrichment of the class of admissible elements led researchers to further investigate the concept of the geometric quality of a polytope, and to define quality measures and metrics for the mesh elements, whether they are poligons \cite{attene2021benchmark,sorgente2022role} or polyhedra \cite{sorgente2021polyhedral}.
In this setting, the geometric kernel is often associated with the concepts of \textit{shape regularity} and \textit{star-shapedness} of an element.
For example, as analyzed in \cite{sorgente2021vem}, most of the error estimates regarding the Virtual Elements Method (but the same holds for other polytopal methods) are based on the theory of polynomial approximation in Sobolev spaces, assuming the star-shapedness of the elements \cite{Brenner-Scott:2008,dupont1980polynomial}.
As a consequence there are a number of sufficient geometrical assumptions on the computational domain for the convergence of the method, which require an estimate of the kernel.
When dealing with non-trivial meshes \cite{antonietti2022high, berrone2019parallel}, such quality measures/metrics/indicators require to compute the kernel of thousands of polytopes, each of them with a limited number of faces and vertices, in the shortest possible time.
A preliminary algorithm for the computation of the kernel of a polyhedron using the geometric approach was introduced in \cite{SorgenteKernel}.
There, we experimentally showed how this type of approach in practice can significantly outperform the algebraic one, for instance, when polyhedral elements have a limited number of faces and vertices or several faces are co-planar.
In this paper we optimize the algorithm, for instance preliminary estimating the position of all vertices with respect to the planes induced by the faces, introducing the use of exact geometric predicates \cite{shewchuk1997adaptive} and a random strategy for visiting the faces of a polyhedron and identify more rapidly polyhedra whose kernel is empty.
We also simplify the description of the algorithmic routines and we introduce new scientific results on a larger variety of models that confirm the validity of a geometry-based kernel algorithm.
The paper is organized as follows.
In Section~\ref{sec:preliminary} we introduce some notation and discuss the difference between the geometric and the algebraic approach.
In Section~\ref{sec:kernel} we detail the algorithm for the construction of the kernel of a polyhedron.
In Section~\ref{sec:tests} we exhibit some examples of computed kernels and analyze the performance of the algorithm with comparisons with an implementation of the algebraic approach and with its previous version \cite{SorgenteKernel}.
In Section~\ref{sec:conclusions} we sum up pros and cons of the algorithm and draw some conclusions.
\section{Preliminary concepts}
\label{sec:preliminary}
We introduce some notations and preliminary concepts that we will use in the rest of the paper.
\subsection{Notations}
\label{subsec:notations}
We define a \textit{polyhedron} as a finite set of plane polygons such that every edge of a polygon is shared by exactly one other polygon and no subset of polygons has the same property \cite{PreparataShamos}.
The vertices and the edges of the polygons are the \textit{vertices} and the \textit{edges} of the polyhedron; the polygons are the \textit{faces} of the polyhedron.
In this work we only consider \textit{simple} polyhedra, which means that there is no pair of nonadjacent faces sharing a point.
A polyhedron $P$ is said to be \textit{convex} if, given any two points $p_1$ and $p_2$ in $P$, the line segment connecting $p_1$ and $p_2$ is entirely contained in $P$.
It can be shown that the intersection of convex polyhedra is a convex polyhedron \cite{PreparataShamos}.
Two points $p_1$ and $p_2$ in $P$ are said to be \textit{visible} from each other if the segment $(p_1,p_2)$ does not intersect the boundary of $P$.
The \textit{kernel} of $P$ is the set of points in the interior of $P$ from which all the points in $P$ are visible.
The first obvious consideration is that the kernel of a polyhedron is a convex polyhedron.
If $P$ is convex its kernel coincides with its interior, because any two points inside a convex polyhedron are visible from each other.
A polyhedron may also not have a kernel at all; in this case we say that its kernel is \textit{empty}.
Last, a polyhedron $P$ is called \textit{star-shaped} if there exists a sphere, with non-zero radius, completely contained in its kernel.
A polyhedron is star-shaped if and only if its kernel is not empty, therefore star-shapedness can be thought as an indicator of the existence of a kernel.
Star-shapedness is weaker than convexity, and it is often used in the literature as many theoretical results in the theory of polynomial approximation in Sobolev spaces rely on this condition \cite{dupont1980polynomial, Brenner-Scott:2008}.
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth]{tent.png}
\caption{A sequence of parametric polyhedra whose kernel is progressively shrinking. The kernel is the polyhedron delimited by the red edges.}
\label{fig:tent}
\end{figure}
In order to give a visual example of these concepts, in Fig.~\ref{fig:tent} we present a parametric object shaped like a tent, with the parameter regulating the height of the ``entrance'' from the basis.
This object is not convex, but in the first examples it is star-shaped and it has a proper kernel, delimited by the red edges.
As the parameter increases, the set of points from which the whole polyhedron is visible becomes smaller, and so does the star-shapedness radius.
The last example of Fig.~\ref{fig:tent} is not star-shaped anymore, i.e. the kernel is empty.
\subsection{The algebraic approach to the kernel computation}
As observed in Section~\ref{sec:intro}, the state of the art algorithm for the computation of the kernel of a polygon follows a geometric approach: the kernel is found as the intersection of half-planes originating from its edges.
We use the term ``geometrical'' because the algorithm computes repeatedly a sequence of geometric intersections between polygons and planes.
This idea was afterwards optimized until obtaining an algorithm able to run in $O(n)$ operations, which has been proven to be optimal \cite{LeePreparata}.
When facing the 3D version of the problem, one natural way could be to extend the 2D algorithm, which is well studied and documented, to the higher dimension.
The problem with the 3D case is that, whereas two convex polygons with respectively $n_1$ and $n_2$ vertices can be intersected in time $O(n)$, being $n=n_1+n_2$, two convex polyhedra with the same parameters are intersected in time $O(n\log n)$, thus the generalization of the two-dimensional instance would yield an $O(n\log^2 n)$ algorithm.
This is in contrast with the result shown in \cite{PreparataShamos}, where a lower bound for the intersection of convex polyhedra is established at $O(n\log n)$.
Therefore the geometric approach to the 3D problem was soon dismissed as unattractive, and alternative ways have been explored.
A new algorithm was formulated, based on the so-called ``double duality trick'', which makes use of linear algebra and homogeneous coordinates.
Thanks to this algebraic approach, described in \cite[Section 7.3.2]{PreparataShamos}, it is possible to compute the intersection of $n$ half-spaces in time $O(n\log n)$ \cite{PreparataShamos}.
This algorithm can be implemented inside the framework of the CGAL library, although there is currently not an explicit routine for computing the kernel of a polyhedron and one has to connect the function for the intersection of half-spaces to the polyhedron data structure.
The whole routine implies:
\begin{enumerate}
\item solving a linear problem to find a point in the interior of the polyhedron;
\item translating the polyhedron so that the interior point is the origin;
\item calculating the dual polyhedron, defined as the convex hull of the vertices dual to the original faces in regard to the unit sphere (i.e., halfspaces at distance $d$ from the origin are dual to vertices at distance $1/d$);
\item calculating the resulting polyhedron, which is the dual of the dual polyhedron;
\item translating the origin back to the interior point.
\end{enumerate}
While from a theoretical point of view the cited results are indubitable, we believe that in many practical situations the geometric approach could perform better than the algebraic one.
This is due to the fact that the cost of solving a linear problem cannot fall below a certain bound, while the intersection of half-spaces can become extremely cheap in some circumstances.
For instance if the number of faces and vertices of the polyhedron is low, this method could be more efficient than the algebraic one, and there may be other situations in which one could take advantage of a wise treatment of the geometrical operations.
\subsection{Data structure}
\label{subsec:data}
We adopt the following data structure inherited by the \textit{cinolib} library \cite{livesu2019cinolib}, in which the code has been written:
\begin{itemize}
\item \textit{Points:} array of unordered 3D points.
%
\item \textit{Face:} array of unsigned integers associated to a \textit{Points} array, representing the indices of the vertices of a face ordered counter-clockwise.
%
\item \textit{Polyhedron:} struct composed by a field \textit{verts} of type \textit{Points} containing the vertices and a field \textit{faces} of type \textit{array
$<$Face$>$} containing the faces of a polyhedron.
%
\item \textit{Plane:} class defining a plane in the Hessian form, composed by a 3D point $n$ indicating the unit normal of the plane (i.e. the $a,b,c$ coefficients of the plane equation) and a number $d$ indicating the distance of the plane from the origin (i.e. the $d$ coefficient of the plane equation).
%
The plane class also contains three additional points $p_1,p_2,p_3$ lying on the plane, useful for the Shewchuck exact predicates \cite{shewchuk1997adaptive}.
%
\item \textit{Sign:} array of labels (BELOW, ABOVE or INTER) used to store information on the position of the elements of a polyhedron (points, edges or faces) with respect to an unspecified plane.
\end{itemize}
Given a plane $p$, the elements of a polyhedron are classified as follows:
\begin{itemize}
\item A point $v$ is labelled as BELOW, ABOVE or INTER provided that the function \textit{orient3d}$(p.p_1,p.p_2,p.p_3,v)$ in the Shewchuck exact predicate library \cite{shewchuk1997adaptive} is negative, positive or zero, within a tolerance of $10^{-8}$;
\item An edge $e$ is labelled as BELOW (resp. ABOVE) if both its endpoints are BELOW or INTER (resp. ABOVE or INTER), and as INTER if one point is ABOVE and the other one is BELOW.
\item A face $f$ is labelled as BELOW if all of its points are BELOW, as ABOVE if none of its points is BELOW and as INTER otherwise.
\end{itemize}
The classification of points is computed at the top level of the algorithm with Shewchuck exact predicates, defining the symbol CINOLIB$\_$USES$\_$EXACT$\_$PREDICATES at compilation time.
For edges and faces instead, we define a function \textit{classify(S)} which determines the classification of and edge or a face from an array $S$ of type \textit{Sign} containing the classification of its points.
The introduction of the labels and the points evaluation at the beginning of the process are two main computational novelties with respect to the previous version of the algorithm \cite{SorgenteKernel}.
\section{Polyhedron kernel algorithm}
\label{sec:kernel}
In this section, we illustrate our method for computing the kernel of a polyhedron with a geometric approach.
It has a modular structure composed of four nested algorithms, each one calling the next one in its core part.
It is modular in the sense that each algorithm can be entirely replaced by another one performing the same operation(s).
This property is particularly useful for making comparisons: one could, for instance, use different strategies for computing the intersection between a polygon and a plane and simply replace Algorithm~\ref{alg:polygon-plane}, measuring the efficiency from time to time.
\subsection{Polyhedron Kernel}
\label{subsec:polyhedron_kernel}
With Algorithm~\ref{alg:kernel} we tackle the general problem: given a polyhedron $P$, we want to find the polyhedron $K$ representing its kernel.
In addition to $P$ we also need as input an array containing the outwards normals of its faces, as it is not always possible to determine the orientation of a face only from its vertices (for example with non-convex faces).
We require the face normals explicitly, and not simply a boolean indicating the faces orientation, because these points will be used to define the planes containing the faces of $P$.
We initialize $K$ with the axis aligned bounding box (AABB) of $P$, i.e. the box with the smallest volume within which all the vertices of $P$ lie, aligned with the axes of the coordinate system.
Then we recursively ``slice'' $K$ with a number of planes, generating a sequence of convex polyhedra $K_i$, $i=1,\dots,\#$\textit{P.faces}, such that $K_i\subseteq K_{i-1}$.
For each face $f$ of $P$ we define the plane $p$ containing its vertices and with normal vector given by the opposite of the face normal $N(f)$, that is to say, $p.n:=-N(f)$.
We consider the plane together with the direction indicated by $p.n$, which is equivalent to considering the half-space originating in $p$ and containing its normal vector.
Given this plane, in a \textit{Sign} array $S$ we store the classification of all the points in $K.verts$ according to their position with respect to $p$.
For improving the efficiency, we can set the sign of all points belonging to $f$ to zero without evaluating their position.
In general $p$ will separate $K$ into two polyhedra, and between those two we keep the one containing the vector $p.n$, which therefore points towards the interior of the element.
This operation is performed by the \textit{Polyhedron-Plane Intersection} algorithm detailed in Section \ref{subsec:polygon_plane}, which replaces $K$ with the new polyhedron.
The order in which we consider the faces is not relevant from a theoretical point of view, but turns out to have a huge impact on the performance.
For instance, if we imagine to compute the kernel of a ``ring'', which is obviously empty, visiting the faces in the order they are stored may take a very long time, especially if the tessellation of the object is fine.
This is because, generally, the faces of a tessellated model are numbered somehow coherently with their neighbors.
For this reason, we optionally propose to visit the faces in random order, or \emph{shuffle} $P.faces$, and to return an empty polyhedron if after a ``slice'' $K$ has less than three faces.
In this way, the empty kernel of a ring with thousands of faces could be detected in just three or four iterations.
When this command is turned on, we say the algorithm is run in \textit{shuffle} mode.
We point out that cutting a convex polyhedron with a plane will always generate two convex polyhedra, and since we start from the bounding box (which is convex), we are guaranteed that $K$ will always be a convex polyhedron.
No matter how weird the initial element $P$ is, from this point on we will only be dealing with convex polyhedra and convex faces.
Last, we could as well start with considering the polyhedron's convex hull instead, but it would be less efficient because the convex hull costs in general $O(n\log n)$ while the AABB is only $O(n)$, and we would still need to intersect the polyhedron with each of its faces.
\begin{algorithm}[htbp]
\caption{Polyhedron Kernel}
\label{alg:kernel}
\begin{algorithmic}[1]
\Require Polyhedron $P$, Points $N$ (faces normals);
\Ensure Polyhedron $K$
\State $K$ := AABB of $P$;
\State \textit{[optional]} shuffle $P.faces$;
\For{Face $f$ in $P.faces$}
\State Plane $p$ := plane containing $f$ with normal $-N(f)$;
\State Sign $S$ := orient3d$(p.p_1, p.p_2, p.p_3, K.verts)$;
\State $K$ := Polyhedron-Plane Intersection($K$, $S$, $p$);
\If{size($K.faces$) $<3$} return NULL;
\EndIf
\EndFor
\State \Return $K$;
\end{algorithmic}
\end{algorithm}
\subsection{Polyhedron-Plane Intersection}
\label{subsec:polyhedron_plane}
With the second algorithm we want to intersect a polyhedron $P$ with a plane $p$, given in $S$ the position of the vertices of $P$ with respect to $p$.
The intersection will in general determine two polyhedra, and between these two we are interested in the one containing the normal vector of $p$ (conventionally called the one ``above'' the plane and indicated with $A$).
This algorithm is inspired from \cite{ahn2008geometric}, where the authors define an algorithm for the intersection of a convex polyhedron with an half-space.
\begin{figure}[htbp]
\centering
\begin{tabular}{cc}
\includegraphics[width=.46\linewidth]{clipping.png} &
\includegraphics[width=.46\linewidth]{capping.png}\\
(a) & (b)
\end{tabular}
\caption{Intersection of a polyhedron with a plane: (a) clipping and (b) capping of a cube.}
\label{fig:polyhedron-plane}
\end{figure}
The first part of Algorithm~\ref{alg:polyhedron-plane} is called the ``clipping'' part (recalling the terminology from \cite{ahn2008geometric}) and consists in clipping each face of $P$ with the plane $p$, see Fig.~\ref{fig:polyhedron-plane}(a).
It corresponds to the \textit{for} loop: we iterate on \textit{P.faces}, each time extracting from $S$ the labels $f_s$ of the vertices $f_v$ of the current face and using the \textit{classify} function.
Faces classified as BELOW are discarded, ABOVE faces are added to $A$ together with their vertices, and INTER faces are split by the \textit{Polygon-Plane Intersection} algorithm.
While we visit every face only once, the same does not hold for vertices, therefore we check if a vertex is already in $A.verts$ before adding it.
This simple idea of checking in advance the faces classification resolves several implementation issues and in some cases significantly improves the efficiency of the algorithm.
By doing this, we make sure that only the faces properly intersected by the plane are passed to Algorithm~\ref{alg:polygon-plane}, so that we do not need to implement all the particular cases of intersections in a single point or along an edge or of faces contained in the plane.
In addition, for every face not passed to Algorithm~\ref{alg:polygon-plane} we have an efficiency improvement, and this happens frequently in models with many coplanar faces like the ones considered in Section~\ref{subsec:refinements}.
If, at the end of this step, $A$ contains at least three INTER points, given that $A$ and all its faces are convex, these vertices will define a ``cap'' face of $A$ completely contained in $p$, see Fig.~\ref{fig:polyhedron-plane}(b).
We can optimize the algorithm by storing in a Sign array the classification of the vertices in $A$, updating it with the sign of every vertex added in the switch loop.
Note that in this case we do not need to use \textit{orient3d}: we already know the sign of the old vertices and the new vertices will obviously be of type INTER.
In our data structure, the vertices of the faces are ordered counter-clockwise (CCW): in order to sort the points contained in \textit{capV} we project them onto a plane, drop one coordinate and apply the algorithm proposed in \cite{baeldung} for 2D points.
Note that if the cap face was not convex it would make no sense to order its vertices, but the intersection between a plane and a convex polyhedron will always generate convex faces.
Last, we need to check that this new face is not already present in $A$: for example if $p$ was tangent to $P$ along a face, this face could be added to $A$ both as an ABOVE face and as a cap face.
If this is not the case, we add \textit{capF} to $A.faces$ but we do not need to add any vertex from \textit{capV}, as we can assume they are all already present in $A.verts$.
\begin{algorithm}[htbp]
\caption{Polyhedron-Plane Intersection}
\label{alg:polyhedron-plane}
\begin{algorithmic}[1]
\Require Polyhedron $P$, Sign $S$, Plane $p$
\Ensure Polyhedron $A$
\For{Face $f$ in $P.faces$}
\State Points $f_v:=$ vertices in $P.verts$ relative to $f$;
\State Sign $f_s$ := $S_{|f_v}$
\Switch{classify$(f_s)$}
\Case{BELOW} break;
\EndCase
\Case{ABOVE}
\State $A.verts\leftarrow$ $f_v$, $A.faces\leftarrow f$;
\EndCase
\Case{INTER}
\State (\textit{V},\textit{F}):=Polygon-Plane Intersection$(f_v,f,f_s,p)$;
\State $A.verts\leftarrow$ \textit{V},
$A.faces\leftarrow$ \textit{F};
\EndCase
\EndSwitch
\EndFor
\State Points \textit{capV} := vertices in $A.verts$ which are INTER;
\If{size(\textit{capV}) $<3$} return $A$;
\EndIf
\State Face \textit{capF} := indices of \textit{capV} vertices ordered CCW;
\If{\textit{capF} $\notin$ $A.faces$}
$A.faces\leftarrow$ \textit{capF};
\EndIf
\State \Return $A$;
\end{algorithmic}
\end{algorithm}
\subsection{Polygon-Plane Intersection}
\label{subsec:polygon_plane}
Algorithm~\ref{alg:polygon-plane} describes the intersection of a polygon (representing a face of the polyhedron), defined by an array of 3D points \textit{polyV} and an array of indices \textit{polyF}, with a plane $p$.
As before, we also require as input an array \textit{polyS} containing the position of the vertices of \textit{polyV} with respect to $p$.
In analogy to Algorithm~\ref{alg:polyhedron-plane}, the intersection will in general determine two polygons and we are only interested in the one above the plane, see Fig.~\ref{fig:polygon-line-plane}(a), defined by points \textit{aboveV} and indexes \textit{aboveF}.
We generically say that a vertex $v$ is added to \textit{above} meaning that $v$ is added to \textit{aboveV} and its index $id_v$ is added to \textit{aboveF}.
This time we iterate on the edges of \textit{polyF}, extract the signs $s_1, s_2$ of the edge endpoints and switch between the three possible classifications of the edge.
In order to avoid duplicates, for each couple of consecutive points $v_1, v_2$, we only accept to add to \textit{above} the second point $v_2$ or the intersection point $v$, but never $v_1$.
We are here taking advantage of the fact that all faces are oriented coherently.
If the edge is of type BELOW we ignore it unless $v_2$ is INTER (i.e. it lies exactly on the plane), in which case we add it to \textit{above}.
In case of ABOVE edges we add $v_2$ to \textit{above}.
For edges of type INTER we perform the \textit{Line-Plane Intersection} algorithm and find a new point $v$.
Its index $id_v$ will be equal to the maximum value in \textit{polyF} plus one, just to make sure that we are not using the index of an existing point.
We always add $v$ to \textit{above}, and if $v_1$ is BELOW we also add $v_2$.
As already noted in Section~\ref{subsec:polyhedron_plane}, treating separately the weak intersections (the BELOW and ABOVE cases) makes the code simpler and more efficient.
\begin{figure}[htbp]
\centering
\begin{tabular}{cc}
\includegraphics[width=.35\linewidth]{polygon-plane.png} &
\includegraphics[width=.35\linewidth]{line-plane.png}\\
(a) & (b)
\end{tabular}
\caption{(a) Intersection between a polygon and a plane, with the above part coloured in green. (b) Intersection between a line and a plane.}
\label{fig:polygon-line-plane}
\end{figure}
\begin{algorithm}[htbp]
\caption{Polygon-Plane Intersection}
\label{alg:polygon-plane}
\begin{algorithmic}[1]
\Require Points \textit{polyV}, Face \textit{polyF}, Sign \textit{polyS}, Plane $p$.
\Ensure Points \textit{aboveV}, Face \textit{aboveF}.
\For{$i=1$ : size(\textit{polyF})}
\State $id_1:=$ \textit{polyF}$(i)$,
$id_2:=$ \textit{polyF}$(i+1)$;
\State $v_1:=$ \textit{polyV}$(id_1)$,
$v_2:=$ \textit{polyV}$(id_2)$;
\State $s_1:=$ \textit{polyS}$(id_1)$,
$s_2:=$ \textit{polyS}$(id_2)$;
\Switch{classify($s_1,s_2$)}
\Case{BELOW}
\If{$v_2$ is INTER}
\State \textit{aboveV} $\leftarrow v_2$, \textit{aboveF} $\leftarrow id_2$;
\EndIf
\EndCase
\Case{ABOVE}
\State \textit{aboveV} $\leftarrow v_2$, \textit{aboveF} $\leftarrow id_2$;
\EndCase
\Case{INTER}
\State $v:=$ Line-Plane Intersection$(v_1,v_2,p)$;
\State $id_v:=$ max(\textit{polyF})+1;
\State \textit{aboveV} $\leftarrow v$, \textit{aboveF} $\leftarrow id_v$;
\If{$v_1$ is BELOW}
\State \textit{aboveV} $\leftarrow v_2$, \textit{aboveF} $\leftarrow id_2$;
\EndIf
\EndCase
\EndSwitch
\EndFor
\State \Return \textit{aboveV}, \textit{aboveF};
\end{algorithmic}
\end{algorithm}
\subsection{Line-Plane Intersection}
\label{subsec:line_plane}
This last algorithm computes the intersection point between a line, given as a couple of vertices, and a plane.
It is a very simple and well known procedure, and we report it here only for completeness.
The intersection vertex $v$ is defined as the linear combination of vertices $v_1$ and $v_2$, with a coefficient $t$ which may also fall outside the standard range $[0,1]$.
The coefficient $t$ is found as the negative ratio between two scalar products involving the plane normal $n$ and a generic other point on the plane $s$, other than $v_1$ and $v_2$ see Fig~\ref{fig:polygon-line-plane}(b).
The normal is $p.n$, and for the point $s$ we can use one of the three points on the plane $p.p_1, p.p_2, p.p_3$.
If the denominator $D$ vanishes, it means either that the line is contained in the plane (if $N=0$ as well) or that the line does not intersect the plane.
We treat these exceptions as errors because in Algorithm~\ref{alg:polygon-plane} we only call this algorithm after checking that the edge $(v_1,v_2)$ properly intersects the plane $p$.
\begin{algorithm}[htbp]
\caption{Line-Plane Intersection}
\label{alg:line-plane}
\begin{algorithmic}[1]
\Require vertices $v_1,v_2$, Plane $p$.
\Ensure vertex $v$.
\State $N:=(p.n)\cdot(v_1-p.p_1)$;
\State $D:=(p.n)\cdot(v_2-v_1)$;
\Assert{$D!=0$}
\State $t:=-N/D$;
\State \Return $v:=v_1+t\ (v_2-v_1)$;
\end{algorithmic}
\end{algorithm}
\subsection{Computational complexity}
\label{subsec:computational_complexity}
Making advantage of the modular organisation of our algorithms, we can estimate separately the computational cost of each algorithm and then include them into a single formula.
Let us consider the case of an input polyhedron $P$ with $n_v$ vertices and $n_f$ faces.
In Algorithm~\ref{alg:kernel} we start by computing the polyhedron's AABB, which is $O(n_v)$, then for each face we estimate the position of the vertices of $K$ with respect to a plane with \textit{orient3d}.
Unfortunately, we have to re-compute the signs of all the $n_{kv}$ vertices of $K$ at every iteration, as from one step to the other the plane changes: this means $O(n_{kv} n_f)$ operations.
At step zero we have $n_{kv}=8$, being $K$ the bounding box; then in the worst case, that is if the object is convex, it can grow up to $n_v$ because $K$ coincides with $P$.
If the object is not convex, $n_{kv}$ can remain significantly lower than $n_v$, which translates in a much lower computational cost.
In both cases, the difference between $n_{kv}$ and $n_v$ is also related to the number of coplanar faces of the model, which get agglomerated into a single face in the kernel with a consequent reduction of the number of vertices.
If the kernel is empty, whenever we end up with less than three faces the algorithm stops, therefore we can replace $n_f$ with the number of iterations needed to detect the non star-shapedness.
This number cannot be estimated precisely, but we can drastically reduce it with the shuffle mode.
The good news is that once that we have the sign of all the vertices with respect to all the planes we are essentially done: the computational costs of Algorithms~\ref{alg:polyhedron-plane} and~\ref{alg:polygon-plane} is all about visiting arrays and copying parts of them into other arrays, and Algorithm~\ref{alg:line-plane} only consists of 4 operations.
We point out that navigating and duplicating arrays has a negligible cost in this scenario as the faces of a generic polyhedron hardly contain more than 10 vertices.
The only relevant operation in Algorithm~\ref{alg:polyhedron-plane} is the sorting of the vertices of the cap face, which does not always exist.
This is done with a QuickSort routine which is on average $O(n\log n)$ for a cap face with $n$ vertices.
Since $n$ is much smaller than $n_{kv}$ and the number of cap faces is always smaller than $n_f$, this cost is negligible compared to $O(n_{kv} n_f)$.
In summary, we can set an upper bound to the computational cost of our algorithm at $O(n_v n_f)$, but both $n_v$ and $n_f$ can significantly decrease if the model is not convex or has coplanar faces, and even more if it is not star-shaped.
In the next section we will show how in practice, on small polyhedra or on objects with many co-planar faces, the geometric method works in a computational time which is smaller than the one of the algebraic approach, and it is still competitive on many examples, even complex ones.
\section{Tests and discussions}
\label{sec:tests}
We test our method in different settings, comparing its performance to the results obtained using our implementation of the algebraic method in CGAL. The comparison of the current method, including the shuffle version, and its previous version in \cite{SorgenteKernel} is presented in Section \ref{subsec:comparison}.
Experiments have been performed on a MacBook Pro equipped with a 2,3 GHz Intel Core i5 processor with four CPUs and 16GB of RAM.
Source code is written in C++ and it is accessible at \url{https://github.com/TommasoSorgente/polyhedron_kernel}, together with all datasets.
In the following subsections we will present some plots and tables: we point out here some remarks on the notation adopted.
Regarding plots, we colour the CGAL computational time in blue and our computational time in red, both in logarithmic scale.
On the $x-$axis, depending from the context, we have the number of elements in the mesh or the number of vertices of the single model.
In the several tables presented we first report the number of elements or vertices of the mesh.
Since all the considered objects have genus zero and their surface is purely triangular, Euler's formula states that the number of faces is approximately equal to twice the number of vertices.
Therefore we only indicate the number of vertices, but the number of faces is easily computable.
Then the computational times (in seconds) are shown, and the ratio between CGAL time and ours.
Note that ratios are computed from the original time values while in the tables we indicate truncated times, therefore they do not exactly correspond to the division between the values in the previous columns.
\subsection{Polyhedral meshes}
\label{subsec:meshes}
\begin{figure*}[htbp]
\centering
\includegraphics[width=\linewidth]{meshes.png}
\caption{Polyhedral meshes and time plots from datasets \textit{poly-parallel}, \textit{poly-poisson} and \textit{poly-random}, with non-tetrahedral elements highlighted in blue.}
\label{fig:meshes}
\end{figure*}
First, we test our algorithm in the setting it was developed for, i.e. the computation of the kernels of elements in a 3D tessellation.
To do so, we used the datasets from \cite{sorgente2021polyhedral}, available for download at \url{https://github.com/TommasoSorgente/vem-indicator-3D-dataset}.
The meshes contained in these datasets are typical examples of tessellations which can be found in numerical analysis for the approximation of a PDE.
We focus our attention on the polyhedral datasets: \textit{poly-parallel}, \textit{poly-poisson} and \textit{poly-random}.
Each of them contains five tessellations of the unit cube with decreasing mesh size, from 100 to 100K vertices.
The resulting meshes contain between 100 and 600K elements, most of which are tetrahedra but $20\%$ of them are generic polyhedra (in blue in Fig.~\ref{fig:meshes}), obtained by the union of two tetrahedra.
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth]{elements.png}
\caption{Examples of non-convex elements found in polyhedral meshes from Section~\ref{subsec:meshes} and relative kernels.}
\label{fig:elements}
\end{figure}
Non-tetrahedral elements are generated by the agglomeration of two tetrahedral elements, therefore they may also be non convex, see Fig.~\ref{fig:elements}.
\begin{table}[htbp]
\caption{Computational times for polyhedral meshes.}
\label{table:time:mesh}
\centering
\begin{tabular}{ccccc}
\hline\noalign{\smallskip}
dataset & $\#$elements & our & CGAL & ratio\\
\noalign{\smallskip}\hline\noalign{\smallskip}
\textit{poly-parallel}
& 130 & 0.04 & 0.21 & 4.89 \\
& 1647 & 0.17 & 1.79 & 10.69 \\
& 16200 & 1.68 & 19.4 & 11.55 \\
& 129600 & 13.94 & 142.36 & 10.21 \\
& 530842 & 53.47 & 588.43 & 11 \\
\noalign{\smallskip}\hline
\textit{poly-poisson}
& 140 & 0.04 & 0.3 & 8.05 \\
& 1876 & 0.29 & 2.54 & 8.91 \\
& 16188 & 2.64 & 24.79 & 9.38 \\
& 146283 & 24.24 & 212.23 & 8.75 \\
& 601393 & 86.77 & 770.66 & 8.88 \\
\noalign{\smallskip}\hline
\textit{poly-random}
& 147 & 0.03 & 0.19 & 6.8 \\
& 1883 & 0.28 & 2.62 & 9.41 \\
& 18289 & 2.91 & 27.11 & 9.33 \\
& 161512 & 26.51 & 228.08 & 8.6 \\
& 598699 & 80.15 & 735.55 & 9.18 \\
\noalign{\smallskip}\hline
\end{tabular}
\end{table}
In Table~\ref{table:time:mesh} we report, for each mesh of each dataset, the number of elements, the computational times for both methods and the ratio between the CGAL time and ours.
Moreover, at the bottom of Fig.~\ref{fig:meshes} we plot the times against the number of elements in the mesh.
It is visible how both methods scale linearly with respect to the number of elements, since the kernel of the elements is computed separately and independently for each element.
Our method performs 8 to 11 times faster than CGAL, which approximately means one order of magnitude.
As the elements of these meshes have either 4 faces if they are tetrahedra or 6 faces if they are the union of two tetrahedra, computing their kernel in a geometrical way results much faster than solving a linear problem.
In this case we did not use the shuffle mode, as the number of faces was so small that the visiting order resulted not relevant.
\subsection{Refinements}
\label{subsec:refinements}
As a second setting for our tests, instead of increasing the number of elements we wanted to measure the asymptotic behaviour of the methods as the number of faces and vertices of a single element explodes.
We selected two polyhedra from the dataset \textit{Thingi10K} \cite{zhou2016thingi10k}: the so-called \textit{spiral} (ThingiID: 60246) and \textit{vase} (ThingiID: 85580).
These models are given in the form of a surface triangular mesh but we treat them as single volumetric cell, analyzing the performance of both algorithms as we refine them.
In Table~\ref{table:time:refinements} we report the computational times and the ratio for each refinement.
\begin{figure}[th]
\centering
\includegraphics[width=.8\linewidth]{spiral.png}
\caption{Original \textit{spiral} model and its first refinement, with identical kernels.}
\label{fig:spiral}
\end{figure}
The \textit{spiral} model is refined through a midpoint strategy: each face is subdivided by connecting its barycenter to its other vertices.
As a consequence, the planes induced by its faces remain the same and the kernels of the refined models are all equal (Fig.~\ref{fig:spiral}).
On this example our method performs on average 5.77 times better that the algebraic method (see Table~\ref{table:time:refinements}), and the computational time scales with a constant rate (see the plot in Fig.~\ref{fig:spiral}).
Our implementation takes advantage of the fact that Algorithm~\ref{alg:polyhedron-plane} recognises the several coplanar faces and always performs Algorithm~\ref{alg:polygon-plane} the same number of times, independently of the number of faces.
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth]{vase.png}
\caption{Original \textit{vase} model and its first refinement: small perturbations in the faces lead to slightly different kernels.}
\label{fig:vase}
\end{figure}
The \textit{vase} model is more complex, as it presents a curved surface which generates a lot of different planes defining the kernel.
Moreover, we refined this model using the Loop's algorithm and this generated faces lying on completely new planes.
This explains the difference between the two kernels in Fig.~\ref{fig:vase}: the general shape is similar but the more faces we add to our model the more faces we find on the resulting kernel.
Our geometric method improves the performance of the algebraic one by a factor around 2 in the first refinements, but in the last two meshes the complexity increases drastically and CGAL results faster (see Table.~\ref{table:time:refinements}).
In this case, an efficient treatment of the faces is not sufficient to hide the quadratic nature of the geometric approach.
Even the shuffle mode did not particularly improve the performance, being the object star-shaped.
\begin{table}[htbp]
\caption{Computational times for the \textit{spiral} and \textit{vase} refinements.}
\label{table:time:refinements}
\centering
\begin{tabular}{ccccc}
\hline\noalign{\smallskip}
mesh & $\#$vertices & our & CGAL & ratio \\
\noalign{\smallskip}\hline\noalign{\smallskip}
\textit{spiral}
& 64 & 0.004 & 0.01 & 3.07 \\
& 250 & 0.007 & 0.04 & 6.27 \\
& 994 & 0.02 & 0.14 & 6.56 \\
& 3970 & 0.08 & 0.43 & 5.38 \\
& 15874 & 0.32 & 1.77 & 5.54 \\
& 63490 & 1.05 & 8.24 & 7.86 \\
\hline
\textit{vase}
& 99 & 0.02 & 0.03 & 1.55 \\
& 390 & 0.04 & 0.12 & 2.56 \\
& 1554 & 0.31 & 0.92 & 2.94 \\
& 6210 & 3.24 & 6.1 & 1.88 \\
& 24261 & 47.49 & 37.24 & 0.78 \\
& 36988 & 196.7 & 56.75 & 0.29 \\
\noalign{\smallskip}\hline
\end{tabular}
\end{table}
\subsection{Complex models}
\label{subsec:complex_models}
Last, we try to compute the kernel of some more complex models, taken again from the dataset \textit{Thingi10K} and treated as single volumetric cells.
Even if our method is designed for dealing with polyhedra of relatively small size, as we already saw in Section~\ref{subsec:refinements} our algorithms are still able to compute the kernel of objects with thousands of vertices and faces.
We filtered the \textit{Thingi10K} dataset selecting only ``meaningful'' models: objects with one connected component, genus zero, Euler characteristic greater than zero, closed, not degenerate and of size smaller than 1MB.
Note that, even applying these filters, the majority of the models are not star-shaped, i.e. with empty kernel.
We discarded a few models for computational and stability reasons, for instance because one of the two algorithms failed to process them.
The final collection, which we will call the \textit{Thingi dataset}, contains exactly 1806 distinct volumetric models.
\begin{figure*}[htbp]
\centering
\includegraphics[width=.9\linewidth]{time_thingi.png}
\caption{Thingi dataset times. From left to right: all Thingi dataset, models with empty kernel, models with non-empty kernel.}
\label{fig:time:thingi}
\end{figure*}
In Fig.~\ref{fig:time:thingi} we show the times distribution for the whole Thingi dataset, with a particular focus on the difference between models with empty kernel and models with non-empty kernel.
Globally, the overall cost of computing all kernels is 173 seconds with our method against 518 seconds with CGAL, for an improvement of 3 times.
When the kernel is empty our algorithm is always faster than CGAL: the main reason for this is the usage of the shuffle mode, which makes it extremely cheap to recognise non star-shaped elements.
When the model is star-shaped the distinction between the two methods is not so clear anymore, as the results mainly depend on the shape and size of the object.
\begin{figure*}[ht!]
\centering
\begin{tabular}{cccc}
\includegraphics[width=.2\linewidth]{plus.png} &
\includegraphics[width=.2\linewidth]{star.png} &
\includegraphics[width=.2\linewidth]{flex.png} &
\includegraphics[width=.2\linewidth]{cross.png} \\
\textit{plus} & \textit{star} & \textit{flex} & \textit{cross} \\
\vspace{0.3cm} \\
\includegraphics[width=.2\linewidth]{part.png} &
\includegraphics[height=.2\linewidth]{superellipse.png} &
\includegraphics[width=.2\linewidth]{boteye.png} &
\includegraphics[width=.2\linewidth]{button.png} \\
\textit{part} & \textit{super-ellipse} & \textit{bot-eye} & \textit{button} \\
\vspace{0.3cm} \\
\includegraphics[height=.2\linewidth]{rt4arm.png} &
\includegraphics[width=.2\linewidth]{ball.png} &
\includegraphics[height=.2\linewidth]{acorn.png} &
\includegraphics[width=.2\linewidth]{muffin.png} \\
\textit{rt4-arm} & \textit{ball} & \textit{acorn} & \textit{muffin} \\
\end{tabular}
\caption{Examples of our kernel evaluation for complex models.
In the top row models on which the geometric method is more efficient, in the middle models for which the performance are similar and in the bottom row models on which the algebraic method is preferable.}
\label{fig:complex}
\end{figure*}
To further investigate on this point, in Fig.~\ref{fig:complex} we present the kernel computation of 10 selected star-shaped examples from this dataset.
In the top row we have models on which the geometric method is by far more efficient: \textit{plus} (ThingiID: 1120761), \textit{star} (ThingiID: 313883), \textit{flex} (ThingiID: 827640) and \textit{cross} (ThingiID: 313882).
In the middle row, models for which the performance are similar: \textit{part} (ThingiID: 472063), \textit{super-ellipse} (ThingiID: 40172), \textit{bot-eye} (ThingiID: 37276) and \textit{button} (ThingiID: 1329185).
Then in the bottom row we show models on which the algebraic method is preferable: \textit{rt4-arm} (ThingiID: 39353), \textit{ball} (ThingiID: 58238), \textit{acorn} (ThingiID: 815480), \textit{muffin} (ThingiID: 101636).
The computational times, together with the ones relative to the whole dataset, are reported in Table~\ref{table:time:complex}.
\begin{table}[th]
\caption{Computational times for complex models.
The first number relative to \textit{Thingi} dataset indicates the number of models instead of the number of vertices.}
\label{table:time:complex}
\centering
\begin{tabular}{ccccc}
\hline\noalign{\smallskip}
mesh & $\#$vertices & our-shuffle & CGAL & ratio \\
\noalign{\smallskip}\hline\noalign{\smallskip}
\textit{plus} & 448 & 0.004 & 0.09 & 22.75\\
\textit{star} & 9633 & 0.4 & 5.15 & 12.93\\
\textit{flex} & 834 & 0.02 & 0.27 & 12.76\\
\textit{cross} & 3914 & 0.19 & 2.1 & 11.12\\
\textit{part} & 5382 & 2.58 & 6.94 & 2.69\\
\textit{super-ellipse} & 290 & 0.02 & 0.04 & 2.05\\
\textit{bot-eye} & 453 & 0.03 & 0.03 & 0.96\\
\textit{button} & 1227 & 0.1 & 0.08 & 0.75\\
\textit{rt4-arm} & 655 & 0.13 & 0.09 & 0.67\\
\textit{ball} & 660 & 0.24 & 0.04 & 0.15\\
\textit{acorn} & 4114 & 4.35 & 0.55 & 0.13\\
\textit{muffin} & 8972 & 11.73 & 0.54 & 0.04\\
\textit{\textbf{Thingi dataset}} & 1806 & 172.88 & 518.2 & 2.99\\
\noalign{\smallskip}\hline
\end{tabular}
\end{table}
Once again, we notice that the size of the model impacts on the performance of our method.
Looking at Fig.~\ref{fig:time:thingi} we can see how the models for which our method performs worse than CGAL are all in the right part of the plane, relative to models with a high number of vertices.
At the same time,
the number of vertices of the element, by itself, is not sufficient to justify the supremacy of one method over the other.
For example, models \textit{star} and \textit{flex} have very different sizes and times, but their ratio is quite similar; the same holds for models \textit{parts} and \textit{super-ellipse} or \textit{ball} and \textit{acorn}.
The shape of the object also plays an important role: over models with numerous adjacent co-planar faces like \textit{plus}, \textit{star} (whose bottom is completely flat) and \textit{cross} our method is preferable even when the size grows.
As already seen in Section~\ref{subsec:refinements}, the presence of coplanar faces significantly improves the performance of our method.
Vice-versa, over elements with significant curvatures like \textit{rt4-arm}, \textit{acorn} or \textit{muffin}, the algebraic method performs similarly or better than ours even on relatively small models like \textit{bot-eye}.
Over these models it is still possible to compute a correct kernel with the geometric approach, but the ratio between CGAL time and ours is in the order of $10^{-1}$ or even $10^{-2}$.
\subsection{Comparison with the previous version}
\label{subsec:comparison}
With respect to its introduction in \cite{SorgenteKernel}, we believe that the algorithm is now more easy to read and to understand, thanks to the introduction of labels for storing the position of vertices, edges and faces with respect to a plane.
Another significant difference is that the evaluation of the position of the vertices is now computed once and for all, at the top level (in Algorithm~\ref{alg:kernel}), while in the previous version every algorithm contained some vertices evaluations: this further reduced the computational complexity.
In addition, we switched from the inexact predicates (in \cite{SorgenteKernel} we used the equivalent of \textit{orient3d-fast}) to the exact \textit{orient3d}, which resulted in an increasing precision in the treatment of nearly-coplanar faces, for a small extra cost which was easily compensated by the other improvements.
This switch required a small modification of the \textit{Plane} class: in view of the usage of \textit{orient3d}, for every plane we also store three points on it.
Last, the introduction of the shuffle mode made the computation of the kernels of non star-shaped objects almost immediate, marking a huge difference with respect to the algebraic method and our previous implementation.
In Table~\ref{table:comparison} we report the differences between the old version of the algorithm and the current version in standard and in shuffle mode.
Over the meshes from Section~\ref{subsec:meshes} there is almost no differences between the three versions.
For refined models, there is an improvement of a factor 2 in the computation of the \textit{vase} refinement (we report the sum of the times for all the refinements).
With complex models we have the greatest differences; in these cases we can also appreciate the advantage brought by the shuffle mode, which was not significant in the other tests.
\begin{table}[htbp]
\caption{Performance comparison between the current implementation and the one presented in \cite{SorgenteKernel}.
Only models with significant differences are reported.}
\label{table:comparison}
\centering
\begin{tabular}{cccc}
\hline\noalign{\smallskip}
mesh & our-shuffle & our & our\cite{SorgenteKernel} \\
\noalign{\smallskip}\hline\noalign{\smallskip}
\textit{spiral} (sum) & 1.04 & 1.01 & 1.03\\
\textit{vase} (sum) & 245.61 & 194.91 & 495.63\\
\textit{cross} & 0.19 & 4.15 & 9.14\\
\textit{part} & 2.58 & 5.22 & 12.7\\
\textit{bot-eye} & 0.03 & 0.17 & 0.25\\
\textit{rt4-arm} & 0.13 & 0.14 & 0.21\\
\textit{button} & 0.1 & 0.11 & 0.15\\
\textit{ball} & 0.24 & 0.28 & 0.58\\
\textit{acorn} & 4.35 & 276.13 & 626.72\\
\textit{muffin} & 11.73 & 58.62 & 129.38\\
\noalign{\smallskip}\hline
\end{tabular}
\end{table}
\section{Conclusions}
\label{sec:conclusions}
We presented an algorithm for the computation of the kernel of a polyhedron based on the extension to the 3D case of the geometric approach commonly adopted in two dimensions. With respect to \cite{SorgenteKernel} we have optimized the algorithm in several ways: we now perform all the vertices comparisons in a single, preliminary step; we have introduced the use of exact geometric predicates and a random visiting strategy of the faces that considerably improve the performance of the method over non star-shaped, complex objects.
The algorithm showed up to be robust and reliable, as it computed successfully the kernel of every considered polyhedron.
The efficiency of our algorithm is compared to the CGAL implementation of the algebraic approach to the problem.
From a theoretical point of view, the computational complexity evaluation of Section~\ref{subsec:computational_complexity} suggests that our method is in general quadratic, while the algebraic approach has a lower bound at $n\log(n)$.
Nonetheless, we proved all across Section~\ref{sec:tests} that in several circumstances our approach outperforms the algebraic one.
The geometric approach showed up to be significantly faster than the algebraic one when dealing with models satisfying at least one of the following conditions:
\begin{enumerate}
\item the size of the model is small;
\item the model contains a significant number of co-planar faces;
\item the kernel is empty.
\end{enumerate}
Our method performs significantly better than the algebraic approach over polyhedra with a limited number of vertices and faces, as shown in Section~\ref{subsec:meshes}, making it particularly suitable for the analysis of volumetric tessellations with non-convex elements.
Indeed, we point out that our algorithm is specifically designed to be used with simple polyhedra, possibly composing a bigger and more complex 3D model, rather than with a complete model itself.
This behaviour is particularly evident with model \textit{vase} from Section~\ref{subsec:refinements}.
As long as the size of the model remains reasonable our method is faster than CGAL, then over a certain bound the algebraic method becomes more efficient.
Again, models like \textit{super-ellipse} or \textit{flex} from Section~\ref{subsec:complex_models} have few or zero co-planar faces and a significant kernel, but the size of these meshes is small and the geometric approach offers better performance.
According to Fig.~\ref{fig:time:thingi}, a bound on the number of vertices could be possibly set at around $10^3$.
When the size of the polyhedron increases, our method is still particularly efficient if the model has numerous co-planar faces, due for instance to the presence of flat regions on the surface.
This is a very common situation in models representing mechanical parts.
For instance, models \textit{star} and \textit{part} from Section~\ref{subsec:complex_models} present large flat regions despite having a significant size, and again the geometric approach is faster on these models.
Another scenario in which the geometric approach overperforms the algebraic one is with non star-shaped objects.
The differences in this case are so evident that one could even imagine to use our algorithm to understand, in few iterations in shuffle mode, if a model is actually star-shaped or not, even without computing the proper kernel.
On the other side, the algebraic approach is likely to remain preferable over domains which do not satisfy any of the above conditions: star-shaped objects with thousands of vertices and high surface curvature.
In conclusion, with this work we do not aim at completely replacing the algebraic approach for the kernel computation but instead to give an alternative which can be preferred for specific cases, such as the quality analysis of the elements in a 3D tessellation, in the same way as bubble-sort is to be preferred to optimal sorting algorithms when dealing with very small arrays.
As a future development, we plan to integrate in our algorithm the promising \textit{indirect predicates} introduced in \cite{attene2020indirect}.
Numerical problems remain a critical issue in the computation of geometric constructions like the kernel, independently of the approach adopted.
We believe indirect predicates could enormously help in enhancing the robustness of the algorithm.
Moreover, we plan to include this tool in a suite for the generation and analysis of tessellations of three dimensional domains, aimed at PDE simulations.
The kernel of a polyhedron has a great impact on its geometrical quality, and the geometrical quality of the elements of a mesh determines the accuracy and the efficiency of a numerical method over it.
We are therefore already using this algorithm in works like \cite{sorgente2022role} for better understanding the correlations between the shape of the elements and the performance of the numerical simulations, and be able to adaptively generate, refine or fix a tessellation accordingly to them.
\section*{Acknowledgements}
We would like to thank Dr. M. Manzini for the precious discussions and suggestions, and all the people from IMATI institute involved in the CHANGE project.
Special thanks are also given to the anonymous reviewers for their comments and suggestions.
This work has been partially supported by the ERC Advanced Grant CHANGE contract N.694515.
\bibliographystyle{plain}
\section{Introduction}
\label{sec:intro}
\begin{figure*}
\includegraphics[width=\linewidth]{pipeline.png}
\centering
\caption{Pipeline of the kernel computation for a polyhedron. At first step, we compute the Axis Aligned Bounding Box (AABB) of the polyhedron; then, we iterate on each face $f$ of the polyhedron (black edges) and cut AABB with the plane induced by $f$ (red edges).}
\label{fig:pipeline}
\end{figure*}
The concept of \emph{geometric kernel} of a polygon, a polyhedron, or more generally of a shape, is a pillar of computational geometry.
Roughly speaking, the kernel of a closed geometric shape $S$ is the locus of the points internal to $S$ from which the whole shape $S$ is visible.
The kernel of a convex shape coincides with the shape itself, while the concept is particularly interesting for non-convex shapes and in particular, polytopes. The kernel of non-convex shapes can also be empty, as in the case of non simply-connected objects for which it is always empty.
In the two-dimensional scenario, that is when the shape is a polygon, the standard way of computing the kernel is by intersecting appropriate half-planes generated from its edges.
This problem has been tackled since the 70s, when \cite{ShamosHoey} presented an algorithm able to perform the kernel computation in $O(e\log e)$ operations, being $e$ the number of edges of a polygon, as the intersection of $e$ half-edges.
After that, an optimal algorithm able to run in $O(n)$ operations over an $n-$sided polygon, has been proposed in \cite{LeePreparata}.
Famous computational tools and libraries like \textit{Boost} \cite{BoostLibrary}, \textit{Geogram} \cite{levy2015geogram}, \textit{CGAL} \cite{fabri2009cgal}, or \textit{Libigl} \cite{jacobson2017libigl} currently implement routines to compute intersections between polygons and planes, which can be used to estimate the kernel.
In the first attempts to solve the volumetric version of the problem, for example in \cite{PreparataShamos}, the natural approach has been to extend the 2D method (which we call \textit{geometric)} to the 3D case from a theoretical point of view, but it was soon dismissed as unattractive for computational reasons.
It was replaced by a new approach (which we call \textit{algebraic)} which makes use of linear algebra and homogeneous coordinates, and that is the state of the art for computing 3D kernels currently implemented by libraries like CGAL.
During years, the polygon kernel computation has become popular to address several problems based on simple polygon analysis, such as star-components decomposition and visibility algorithms that are of interest in robotics, surveillance, geometric modeling, computer vision and, recently, in the emerging field of additive manufacturing \cite{demir2018near}.
Today, the geometric kernel of a polytope is a pivotal information for understanding the geometrical quality of an element in the context of finite elements analysis.
While in the past years finite elements methods were only designed to work on convex elements like triangles/tetrahedra or quadrangles/hexahedra \cite{ciarlet2002finite}, recent and more complex methods like the Mimetic Finite Difference Method \cite{lipnikov2014mimetic}, the Virtual Elements Method \cite{beirao2013basic}, the Discontinuous Galerkin Mehod \cite{cockburn2012discontinuous} or the Hybrid High Order Method \cite{di2019hybrid} are able to deal with non convex polytopes.
This enrichment of the class of admissible elements led researchers to further investigate the concept of the geometric quality of a polytope, and to define quality measures and metrics for the mesh elements, whether they are poligons \cite{attene2021benchmark,sorgente2022role} or polyhedra \cite{sorgente2021polyhedral}.
In this setting, the geometric kernel is often associated with the concepts of \textit{shape regularity} and \textit{star-shapedness} of an element.
For example, as analyzed in \cite{sorgente2021vem}, most of the error estimates regarding the Virtual Elements Method (but the same holds for other polytopal methods) are based on the theory of polynomial approximation in Sobolev spaces, assuming the star-shapedness of the elements \cite{Brenner-Scott:2008,dupont1980polynomial}.
As a consequence there are a number of sufficient geometrical assumptions on the computational domain for the convergence of the method, which require an estimate of the kernel.
When dealing with non-trivial meshes \cite{antonietti2022high, berrone2019parallel}, such quality measures/metrics/indicators require to compute the kernel of thousands of polytopes, each of them with a limited number of faces and vertices, in the shortest possible time.
A preliminary algorithm for the computation of the kernel of a polyhedron using the geometric approach was introduced in \cite{SorgenteKernel}.
There, we experimentally showed how this type of approach in practice can significantly outperform the algebraic one, for instance, when polyhedral elements have a limited number of faces and vertices or several faces are co-planar.
In this paper we optimize the algorithm, for instance preliminary estimating the position of all vertices with respect to the planes induced by the faces, introducing the use of exact geometric predicates \cite{shewchuk1997adaptive} and a random strategy for visiting the faces of a polyhedron and identify more rapidly polyhedra whose kernel is empty.
We also simplify the description of the algorithmic routines and we introduce new scientific results on a larger variety of models that confirm the validity of a geometry-based kernel algorithm.
The paper is organized as follows.
In Section~\ref{sec:preliminary} we introduce some notation and discuss the difference between the geometric and the algebraic approach.
In Section~\ref{sec:kernel} we detail the algorithm for the construction of the kernel of a polyhedron.
In Section~\ref{sec:tests} we exhibit some examples of computed kernels and analyze the performance of the algorithm with comparisons with an implementation of the algebraic approach and with its previous version \cite{SorgenteKernel}.
In Section~\ref{sec:conclusions} we sum up pros and cons of the algorithm and draw some conclusions.
\section{Preliminary concepts}
\label{sec:preliminary}
We introduce some notations and preliminary concepts that we will use in the rest of the paper.
\subsection{Notations}
\label{subsec:notations}
We define a \textit{polyhedron} as a finite set of plane polygons such that every edge of a polygon is shared by exactly one other polygon and no subset of polygons has the same property \cite{PreparataShamos}.
The vertices and the edges of the polygons are the \textit{vertices} and the \textit{edges} of the polyhedron; the polygons are the \textit{faces} of the polyhedron.
In this work we only consider \textit{simple} polyhedra, which means that there is no pair of nonadjacent faces sharing a point.
A polyhedron $P$ is said to be \textit{convex} if, given any two points $p_1$ and $p_2$ in $P$, the line segment connecting $p_1$ and $p_2$ is entirely contained in $P$.
It can be shown that the intersection of convex polyhedra is a convex polyhedron \cite{PreparataShamos}.
Two points $p_1$ and $p_2$ in $P$ are said to be \textit{visible} from each other if the segment $(p_1,p_2)$ does not intersect the boundary of $P$.
The \textit{kernel} of $P$ is the set of points in the interior of $P$ from which all the points in $P$ are visible.
The first obvious consideration is that the kernel of a polyhedron is a convex polyhedron.
If $P$ is convex its kernel coincides with its interior, because any two points inside a convex polyhedron are visible from each other.
A polyhedron may also not have a kernel at all; in this case we say that its kernel is \textit{empty}.
Last, a polyhedron $P$ is called \textit{star-shaped} if there exists a sphere, with non-zero radius, completely contained in its kernel.
A polyhedron is star-shaped if and only if its kernel is not empty, therefore star-shapedness can be thought as an indicator of the existence of a kernel.
Star-shapedness is weaker than convexity, and it is often used in the literature as many theoretical results in the theory of polynomial approximation in Sobolev spaces rely on this condition \cite{dupont1980polynomial, Brenner-Scott:2008}.
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth]{tent.png}
\caption{A sequence of parametric polyhedra whose kernel is progressively shrinking. The kernel is the polyhedron delimited by the red edges.}
\label{fig:tent}
\end{figure}
In order to give a visual example of these concepts, in Fig.~\ref{fig:tent} we present a parametric object shaped like a tent, with the parameter regulating the height of the ``entrance'' from the basis.
This object is not convex, but in the first examples it is star-shaped and it has a proper kernel, delimited by the red edges.
As the parameter increases, the set of points from which the whole polyhedron is visible becomes smaller, and so does the star-shapedness radius.
The last example of Fig.~\ref{fig:tent} is not star-shaped anymore, i.e. the kernel is empty.
\subsection{The algebraic approach to the kernel computation}
As observed in Section~\ref{sec:intro}, the state of the art algorithm for the computation of the kernel of a polygon follows a geometric approach: the kernel is found as the intersection of half-planes originating from its edges.
We use the term ``geometrical'' because the algorithm computes repeatedly a sequence of geometric intersections between polygons and planes.
This idea was afterwards optimized until obtaining an algorithm able to run in $O(n)$ operations, which has been proven to be optimal \cite{LeePreparata}.
When facing the 3D version of the problem, one natural way could be to extend the 2D algorithm, which is well studied and documented, to the higher dimension.
The problem with the 3D case is that, whereas two convex polygons with respectively $n_1$ and $n_2$ vertices can be intersected in time $O(n)$, being $n=n_1+n_2$, two convex polyhedra with the same parameters are intersected in time $O(n\log n)$, thus the generalization of the two-dimensional instance would yield an $O(n\log^2 n)$ algorithm.
This is in contrast with the result shown in \cite{PreparataShamos}, where a lower bound for the intersection of convex polyhedra is established at $O(n\log n)$.
Therefore the geometric approach to the 3D problem was soon dismissed as unattractive, and alternative ways have been explored.
A new algorithm was formulated, based on the so-called ``double duality trick'', which makes use of linear algebra and homogeneous coordinates.
Thanks to this algebraic approach, described in \cite[Section 7.3.2]{PreparataShamos}, it is possible to compute the intersection of $n$ half-spaces in time $O(n\log n)$ \cite{PreparataShamos}.
This algorithm can be implemented inside the framework of the CGAL library, although there is currently not an explicit routine for computing the kernel of a polyhedron and one has to connect the function for the intersection of half-spaces to the polyhedron data structure.
The whole routine implies:
\begin{enumerate}
\item solving a linear problem to find a point in the interior of the polyhedron;
\item translating the polyhedron so that the interior point is the origin;
\item calculating the dual polyhedron, defined as the convex hull of the vertices dual to the original faces in regard to the unit sphere (i.e., halfspaces at distance $d$ from the origin are dual to vertices at distance $1/d$);
\item calculating the resulting polyhedron, which is the dual of the dual polyhedron;
\item translating the origin back to the interior point.
\end{enumerate}
While from a theoretical point of view the cited results are indubitable, we believe that in many practical situations the geometric approach could perform better than the algebraic one.
This is due to the fact that the cost of solving a linear problem cannot fall below a certain bound, while the intersection of half-spaces can become extremely cheap in some circumstances.
For instance if the number of faces and vertices of the polyhedron is low, this method could be more efficient than the algebraic one, and there may be other situations in which one could take advantage of a wise treatment of the geometrical operations.
\subsection{Data structure}
\label{subsec:data}
We adopt the following data structure inherited by the \textit{cinolib} library \cite{livesu2019cinolib}, in which the code has been written:
\begin{itemize}
\item \textit{Points:} array of unordered 3D points.
%
\item \textit{Face:} array of unsigned integers associated to a \textit{Points} array, representing the indices of the vertices of a face ordered counter-clockwise.
%
\item \textit{Polyhedron:} struct composed by a field \textit{verts} of type \textit{Points} containing the vertices and a field \textit{faces} of type \textit{array
$<$Face$>$} containing the faces of a polyhedron.
%
\item \textit{Plane:} class defining a plane in the Hessian form, composed by a 3D point $n$ indicating the unit normal of the plane (i.e. the $a,b,c$ coefficients of the plane equation) and a number $d$ indicating the distance of the plane from the origin (i.e. the $d$ coefficient of the plane equation).
%
The plane class also contains three additional points $p_1,p_2,p_3$ lying on the plane, useful for the Shewchuck exact predicates \cite{shewchuk1997adaptive}.
%
\item \textit{Sign:} array of labels (BELOW, ABOVE or INTER) used to store information on the position of the elements of a polyhedron (points, edges or faces) with respect to an unspecified plane.
\end{itemize}
Given a plane $p$, the elements of a polyhedron are classified as follows:
\begin{itemize}
\item A point $v$ is labelled as BELOW, ABOVE or INTER provided that the function \textit{orient3d}$(p.p_1,p.p_2,p.p_3,v)$ in the Shewchuck exact predicate library \cite{shewchuk1997adaptive} is negative, positive or zero, within a tolerance of $10^{-8}$;
\item An edge $e$ is labelled as BELOW (resp. ABOVE) if both its endpoints are BELOW or INTER (resp. ABOVE or INTER), and as INTER if one point is ABOVE and the other one is BELOW.
\item A face $f$ is labelled as BELOW if all of its points are BELOW, as ABOVE if none of its points is BELOW and as INTER otherwise.
\end{itemize}
The classification of points is computed at the top level of the algorithm with Shewchuck exact predicates, defining the symbol CINOLIB$\_$USES$\_$EXACT$\_$PREDICATES at compilation time.
For edges and faces instead, we define a function \textit{classify(S)} which determines the classification of and edge or a face from an array $S$ of type \textit{Sign} containing the classification of its points.
The introduction of the labels and the points evaluation at the beginning of the process are two main computational novelties with respect to the previous version of the algorithm \cite{SorgenteKernel}.
\section{Polyhedron kernel algorithm}
\label{sec:kernel}
In this section, we illustrate our method for computing the kernel of a polyhedron with a geometric approach.
It has a modular structure composed of four nested algorithms, each one calling the next one in its core part.
It is modular in the sense that each algorithm can be entirely replaced by another one performing the same operation(s).
This property is particularly useful for making comparisons: one could, for instance, use different strategies for computing the intersection between a polygon and a plane and simply replace Algorithm~\ref{alg:polygon-plane}, measuring the efficiency from time to time.
\subsection{Polyhedron Kernel}
\label{subsec:polyhedron_kernel}
With Algorithm~\ref{alg:kernel} we tackle the general problem: given a polyhedron $P$, we want to find the polyhedron $K$ representing its kernel.
In addition to $P$ we also need as input an array containing the outwards normals of its faces, as it is not always possible to determine the orientation of a face only from its vertices (for example with non-convex faces).
We require the face normals explicitly, and not simply a boolean indicating the faces orientation, because these points will be used to define the planes containing the faces of $P$.
We initialize $K$ with the axis aligned bounding box (AABB) of $P$, i.e. the box with the smallest volume within which all the vertices of $P$ lie, aligned with the axes of the coordinate system.
Then we recursively ``slice'' $K$ with a number of planes, generating a sequence of convex polyhedra $K_i$, $i=1,\dots,\#$\textit{P.faces}, such that $K_i\subseteq K_{i-1}$.
For each face $f$ of $P$ we define the plane $p$ containing its vertices and with normal vector given by the opposite of the face normal $N(f)$, that is to say, $p.n:=-N(f)$.
We consider the plane together with the direction indicated by $p.n$, which is equivalent to considering the half-space originating in $p$ and containing its normal vector.
Given this plane, in a \textit{Sign} array $S$ we store the classification of all the points in $K.verts$ according to their position with respect to $p$.
For improving the efficiency, we can set the sign of all points belonging to $f$ to zero without evaluating their position.
In general $p$ will separate $K$ into two polyhedra, and between those two we keep the one containing the vector $p.n$, which therefore points towards the interior of the element.
This operation is performed by the \textit{Polyhedron-Plane Intersection} algorithm detailed in Section \ref{subsec:polygon_plane}, which replaces $K$ with the new polyhedron.
The order in which we consider the faces is not relevant from a theoretical point of view, but turns out to have a huge impact on the performance.
For instance, if we imagine to compute the kernel of a ``ring'', which is obviously empty, visiting the faces in the order they are stored may take a very long time, especially if the tessellation of the object is fine.
This is because, generally, the faces of a tessellated model are numbered somehow coherently with their neighbors.
For this reason, we optionally propose to visit the faces in random order, or \emph{shuffle} $P.faces$, and to return an empty polyhedron if after a ``slice'' $K$ has less than three faces.
In this way, the empty kernel of a ring with thousands of faces could be detected in just three or four iterations.
When this command is turned on, we say the algorithm is run in \textit{shuffle} mode.
We point out that cutting a convex polyhedron with a plane will always generate two convex polyhedra, and since we start from the bounding box (which is convex), we are guaranteed that $K$ will always be a convex polyhedron.
No matter how weird the initial element $P$ is, from this point on we will only be dealing with convex polyhedra and convex faces.
Last, we could as well start with considering the polyhedron's convex hull instead, but it would be less efficient because the convex hull costs in general $O(n\log n)$ while the AABB is only $O(n)$, and we would still need to intersect the polyhedron with each of its faces.
\begin{algorithm}[htbp]
\caption{Polyhedron Kernel}
\label{alg:kernel}
\begin{algorithmic}[1]
\Require Polyhedron $P$, Points $N$ (faces normals);
\Ensure Polyhedron $K$
\State $K$ := AABB of $P$;
\State \textit{[optional]} shuffle $P.faces$;
\For{Face $f$ in $P.faces$}
\State Plane $p$ := plane containing $f$ with normal $-N(f)$;
\State Sign $S$ := orient3d$(p.p_1, p.p_2, p.p_3, K.verts)$;
\State $K$ := Polyhedron-Plane Intersection($K$, $S$, $p$);
\If{size($K.faces$) $<3$} return NULL;
\EndIf
\EndFor
\State \Return $K$;
\end{algorithmic}
\end{algorithm}
\subsection{Polyhedron-Plane Intersection}
\label{subsec:polyhedron_plane}
With the second algorithm we want to intersect a polyhedron $P$ with a plane $p$, given in $S$ the position of the vertices of $P$ with respect to $p$.
The intersection will in general determine two polyhedra, and between these two we are interested in the one containing the normal vector of $p$ (conventionally called the one ``above'' the plane and indicated with $A$).
This algorithm is inspired from \cite{ahn2008geometric}, where the authors define an algorithm for the intersection of a convex polyhedron with an half-space.
\begin{figure}[htbp]
\centering
\begin{tabular}{cc}
\includegraphics[width=.46\linewidth]{clipping.png} &
\includegraphics[width=.46\linewidth]{capping.png}\\
(a) & (b)
\end{tabular}
\caption{Intersection of a polyhedron with a plane: (a) clipping and (b) capping of a cube.}
\label{fig:polyhedron-plane}
\end{figure}
The first part of Algorithm~\ref{alg:polyhedron-plane} is called the ``clipping'' part (recalling the terminology from \cite{ahn2008geometric}) and consists in clipping each face of $P$ with the plane $p$, see Fig.~\ref{fig:polyhedron-plane}(a).
It corresponds to the \textit{for} loop: we iterate on \textit{P.faces}, each time extracting from $S$ the labels $f_s$ of the vertices $f_v$ of the current face and using the \textit{classify} function.
Faces classified as BELOW are discarded, ABOVE faces are added to $A$ together with their vertices, and INTER faces are split by the \textit{Polygon-Plane Intersection} algorithm.
While we visit every face only once, the same does not hold for vertices, therefore we check if a vertex is already in $A.verts$ before adding it.
This simple idea of checking in advance the faces classification resolves several implementation issues and in some cases significantly improves the efficiency of the algorithm.
By doing this, we make sure that only the faces properly intersected by the plane are passed to Algorithm~\ref{alg:polygon-plane}, so that we do not need to implement all the particular cases of intersections in a single point or along an edge or of faces contained in the plane.
In addition, for every face not passed to Algorithm~\ref{alg:polygon-plane} we have an efficiency improvement, and this happens frequently in models with many coplanar faces like the ones considered in Section~\ref{subsec:refinements}.
If, at the end of this step, $A$ contains at least three INTER points, given that $A$ and all its faces are convex, these vertices will define a ``cap'' face of $A$ completely contained in $p$, see Fig.~\ref{fig:polyhedron-plane}(b).
We can optimize the algorithm by storing in a Sign array the classification of the vertices in $A$, updating it with the sign of every vertex added in the switch loop.
Note that in this case we do not need to use \textit{orient3d}: we already know the sign of the old vertices and the new vertices will obviously be of type INTER.
In our data structure, the vertices of the faces are ordered counter-clockwise (CCW): in order to sort the points contained in \textit{capV} we project them onto a plane, drop one coordinate and apply the algorithm proposed in \cite{baeldung} for 2D points.
Note that if the cap face was not convex it would make no sense to order its vertices, but the intersection between a plane and a convex polyhedron will always generate convex faces.
Last, we need to check that this new face is not already present in $A$: for example if $p$ was tangent to $P$ along a face, this face could be added to $A$ both as an ABOVE face and as a cap face.
If this is not the case, we add \textit{capF} to $A.faces$ but we do not need to add any vertex from \textit{capV}, as we can assume they are all already present in $A.verts$.
\begin{algorithm}[htbp]
\caption{Polyhedron-Plane Intersection}
\label{alg:polyhedron-plane}
\begin{algorithmic}[1]
\Require Polyhedron $P$, Sign $S$, Plane $p$
\Ensure Polyhedron $A$
\For{Face $f$ in $P.faces$}
\State Points $f_v:=$ vertices in $P.verts$ relative to $f$;
\State Sign $f_s$ := $S_{|f_v}$
\Switch{classify$(f_s)$}
\Case{BELOW} break;
\EndCase
\Case{ABOVE}
\State $A.verts\leftarrow$ $f_v$, $A.faces\leftarrow f$;
\EndCase
\Case{INTER}
\State (\textit{V},\textit{F}):=Polygon-Plane Intersection$(f_v,f,f_s,p)$;
\State $A.verts\leftarrow$ \textit{V},
$A.faces\leftarrow$ \textit{F};
\EndCase
\EndSwitch
\EndFor
\State Points \textit{capV} := vertices in $A.verts$ which are INTER;
\If{size(\textit{capV}) $<3$} return $A$;
\EndIf
\State Face \textit{capF} := indices of \textit{capV} vertices ordered CCW;
\If{\textit{capF} $\notin$ $A.faces$}
$A.faces\leftarrow$ \textit{capF};
\EndIf
\State \Return $A$;
\end{algorithmic}
\end{algorithm}
\subsection{Polygon-Plane Intersection}
\label{subsec:polygon_plane}
Algorithm~\ref{alg:polygon-plane} describes the intersection of a polygon (representing a face of the polyhedron), defined by an array of 3D points \textit{polyV} and an array of indices \textit{polyF}, with a plane $p$.
As before, we also require as input an array \textit{polyS} containing the position of the vertices of \textit{polyV} with respect to $p$.
In analogy to Algorithm~\ref{alg:polyhedron-plane}, the intersection will in general determine two polygons and we are only interested in the one above the plane, see Fig.~\ref{fig:polygon-line-plane}(a), defined by points \textit{aboveV} and indexes \textit{aboveF}.
We generically say that a vertex $v$ is added to \textit{above} meaning that $v$ is added to \textit{aboveV} and its index $id_v$ is added to \textit{aboveF}.
This time we iterate on the edges of \textit{polyF}, extract the signs $s_1, s_2$ of the edge endpoints and switch between the three possible classifications of the edge.
In order to avoid duplicates, for each couple of consecutive points $v_1, v_2$, we only accept to add to \textit{above} the second point $v_2$ or the intersection point $v$, but never $v_1$.
We are here taking advantage of the fact that all faces are oriented coherently.
If the edge is of type BELOW we ignore it unless $v_2$ is INTER (i.e. it lies exactly on the plane), in which case we add it to \textit{above}.
In case of ABOVE edges we add $v_2$ to \textit{above}.
For edges of type INTER we perform the \textit{Line-Plane Intersection} algorithm and find a new point $v$.
Its index $id_v$ will be equal to the maximum value in \textit{polyF} plus one, just to make sure that we are not using the index of an existing point.
We always add $v$ to \textit{above}, and if $v_1$ is BELOW we also add $v_2$.
As already noted in Section~\ref{subsec:polyhedron_plane}, treating separately the weak intersections (the BELOW and ABOVE cases) makes the code simpler and more efficient.
\begin{figure}[htbp]
\centering
\begin{tabular}{cc}
\includegraphics[width=.35\linewidth]{polygon-plane.png} &
\includegraphics[width=.35\linewidth]{line-plane.png}\\
(a) & (b)
\end{tabular}
\caption{(a) Intersection between a polygon and a plane, with the above part coloured in green. (b) Intersection between a line and a plane.}
\label{fig:polygon-line-plane}
\end{figure}
\begin{algorithm}[htbp]
\caption{Polygon-Plane Intersection}
\label{alg:polygon-plane}
\begin{algorithmic}[1]
\Require Points \textit{polyV}, Face \textit{polyF}, Sign \textit{polyS}, Plane $p$.
\Ensure Points \textit{aboveV}, Face \textit{aboveF}.
\For{$i=1$ : size(\textit{polyF})}
\State $id_1:=$ \textit{polyF}$(i)$,
$id_2:=$ \textit{polyF}$(i+1)$;
\State $v_1:=$ \textit{polyV}$(id_1)$,
$v_2:=$ \textit{polyV}$(id_2)$;
\State $s_1:=$ \textit{polyS}$(id_1)$,
$s_2:=$ \textit{polyS}$(id_2)$;
\Switch{classify($s_1,s_2$)}
\Case{BELOW}
\If{$v_2$ is INTER}
\State \textit{aboveV} $\leftarrow v_2$, \textit{aboveF} $\leftarrow id_2$;
\EndIf
\EndCase
\Case{ABOVE}
\State \textit{aboveV} $\leftarrow v_2$, \textit{aboveF} $\leftarrow id_2$;
\EndCase
\Case{INTER}
\State $v:=$ Line-Plane Intersection$(v_1,v_2,p)$;
\State $id_v:=$ max(\textit{polyF})+1;
\State \textit{aboveV} $\leftarrow v$, \textit{aboveF} $\leftarrow id_v$;
\If{$v_1$ is BELOW}
\State \textit{aboveV} $\leftarrow v_2$, \textit{aboveF} $\leftarrow id_2$;
\EndIf
\EndCase
\EndSwitch
\EndFor
\State \Return \textit{aboveV}, \textit{aboveF};
\end{algorithmic}
\end{algorithm}
\subsection{Line-Plane Intersection}
\label{subsec:line_plane}
This last algorithm computes the intersection point between a line, given as a couple of vertices, and a plane.
It is a very simple and well known procedure, and we report it here only for completeness.
The intersection vertex $v$ is defined as the linear combination of vertices $v_1$ and $v_2$, with a coefficient $t$ which may also fall outside the standard range $[0,1]$.
The coefficient $t$ is found as the negative ratio between two scalar products involving the plane normal $n$ and a generic other point on the plane $s$, other than $v_1$ and $v_2$ see Fig~\ref{fig:polygon-line-plane}(b).
The normal is $p.n$, and for the point $s$ we can use one of the three points on the plane $p.p_1, p.p_2, p.p_3$.
If the denominator $D$ vanishes, it means either that the line is contained in the plane (if $N=0$ as well) or that the line does not intersect the plane.
We treat these exceptions as errors because in Algorithm~\ref{alg:polygon-plane} we only call this algorithm after checking that the edge $(v_1,v_2)$ properly intersects the plane $p$.
\begin{algorithm}[htbp]
\caption{Line-Plane Intersection}
\label{alg:line-plane}
\begin{algorithmic}[1]
\Require vertices $v_1,v_2$, Plane $p$.
\Ensure vertex $v$.
\State $N:=(p.n)\cdot(v_1-p.p_1)$;
\State $D:=(p.n)\cdot(v_2-v_1)$;
\Assert{$D!=0$}
\State $t:=-N/D$;
\State \Return $v:=v_1+t\ (v_2-v_1)$;
\end{algorithmic}
\end{algorithm}
\subsection{Computational complexity}
\label{subsec:computational_complexity}
Making advantage of the modular organisation of our algorithms, we can estimate separately the computational cost of each algorithm and then include them into a single formula.
Let us consider the case of an input polyhedron $P$ with $n_v$ vertices and $n_f$ faces.
In Algorithm~\ref{alg:kernel} we start by computing the polyhedron's AABB, which is $O(n_v)$, then for each face we estimate the position of the vertices of $K$ with respect to a plane with \textit{orient3d}.
Unfortunately, we have to re-compute the signs of all the $n_{kv}$ vertices of $K$ at every iteration, as from one step to the other the plane changes: this means $O(n_{kv} n_f)$ operations.
At step zero we have $n_{kv}=8$, being $K$ the bounding box; then in the worst case, that is if the object is convex, it can grow up to $n_v$ because $K$ coincides with $P$.
If the object is not convex, $n_{kv}$ can remain significantly lower than $n_v$, which translates in a much lower computational cost.
In both cases, the difference between $n_{kv}$ and $n_v$ is also related to the number of coplanar faces of the model, which get agglomerated into a single face in the kernel with a consequent reduction of the number of vertices.
If the kernel is empty, whenever we end up with less than three faces the algorithm stops, therefore we can replace $n_f$ with the number of iterations needed to detect the non star-shapedness.
This number cannot be estimated precisely, but we can drastically reduce it with the shuffle mode.
The good news is that once that we have the sign of all the vertices with respect to all the planes we are essentially done: the computational costs of Algorithms~\ref{alg:polyhedron-plane} and~\ref{alg:polygon-plane} is all about visiting arrays and copying parts of them into other arrays, and Algorithm~\ref{alg:line-plane} only consists of 4 operations.
We point out that navigating and duplicating arrays has a negligible cost in this scenario as the faces of a generic polyhedron hardly contain more than 10 vertices.
The only relevant operation in Algorithm~\ref{alg:polyhedron-plane} is the sorting of the vertices of the cap face, which does not always exist.
This is done with a QuickSort routine which is on average $O(n\log n)$ for a cap face with $n$ vertices.
Since $n$ is much smaller than $n_{kv}$ and the number of cap faces is always smaller than $n_f$, this cost is negligible compared to $O(n_{kv} n_f)$.
In summary, we can set an upper bound to the computational cost of our algorithm at $O(n_v n_f)$, but both $n_v$ and $n_f$ can significantly decrease if the model is not convex or has coplanar faces, and even more if it is not star-shaped.
In the next section we will show how in practice, on small polyhedra or on objects with many co-planar faces, the geometric method works in a computational time which is smaller than the one of the algebraic approach, and it is still competitive on many examples, even complex ones.
\section{Tests and discussions}
\label{sec:tests}
We test our method in different settings, comparing its performance to the results obtained using our implementation of the algebraic method in CGAL. The comparison of the current method, including the shuffle version, and its previous version in \cite{SorgenteKernel} is presented in Section \ref{subsec:comparison}.
Experiments have been performed on a MacBook Pro equipped with a 2,3 GHz Intel Core i5 processor with four CPUs and 16GB of RAM.
Source code is written in C++ and it is accessible at \url{https://github.com/TommasoSorgente/polyhedron_kernel}, together with all datasets.
In the following subsections we will present some plots and tables: we point out here some remarks on the notation adopted.
Regarding plots, we colour the CGAL computational time in blue and our computational time in red, both in logarithmic scale.
On the $x-$axis, depending from the context, we have the number of elements in the mesh or the number of vertices of the single model.
In the several tables presented we first report the number of elements or vertices of the mesh.
Since all the considered objects have genus zero and their surface is purely triangular, Euler's formula states that the number of faces is approximately equal to twice the number of vertices.
Therefore we only indicate the number of vertices, but the number of faces is easily computable.
Then the computational times (in seconds) are shown, and the ratio between CGAL time and ours.
Note that ratios are computed from the original time values while in the tables we indicate truncated times, therefore they do not exactly correspond to the division between the values in the previous columns.
\subsection{Polyhedral meshes}
\label{subsec:meshes}
\begin{figure*}[htbp]
\centering
\includegraphics[width=\linewidth]{meshes.png}
\caption{Polyhedral meshes and time plots from datasets \textit{poly-parallel}, \textit{poly-poisson} and \textit{poly-random}, with non-tetrahedral elements highlighted in blue.}
\label{fig:meshes}
\end{figure*}
First, we test our algorithm in the setting it was developed for, i.e. the computation of the kernels of elements in a 3D tessellation.
To do so, we used the datasets from \cite{sorgente2021polyhedral}, available for download at \url{https://github.com/TommasoSorgente/vem-indicator-3D-dataset}.
The meshes contained in these datasets are typical examples of tessellations which can be found in numerical analysis for the approximation of a PDE.
We focus our attention on the polyhedral datasets: \textit{poly-parallel}, \textit{poly-poisson} and \textit{poly-random}.
Each of them contains five tessellations of the unit cube with decreasing mesh size, from 100 to 100K vertices.
The resulting meshes contain between 100 and 600K elements, most of which are tetrahedra but $20\%$ of them are generic polyhedra (in blue in Fig.~\ref{fig:meshes}), obtained by the union of two tetrahedra.
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth]{elements.png}
\caption{Examples of non-convex elements found in polyhedral meshes from Section~\ref{subsec:meshes} and relative kernels.}
\label{fig:elements}
\end{figure}
Non-tetrahedral elements are generated by the agglomeration of two tetrahedral elements, therefore they may also be non convex, see Fig.~\ref{fig:elements}.
\begin{table}[htbp]
\caption{Computational times for polyhedral meshes.}
\label{table:time:mesh}
\centering
\begin{tabular}{ccccc}
\hline\noalign{\smallskip}
dataset & $\#$elements & our & CGAL & ratio\\
\noalign{\smallskip}\hline\noalign{\smallskip}
\textit{poly-parallel}
& 130 & 0.04 & 0.21 & 4.89 \\
& 1647 & 0.17 & 1.79 & 10.69 \\
& 16200 & 1.68 & 19.4 & 11.55 \\
& 129600 & 13.94 & 142.36 & 10.21 \\
& 530842 & 53.47 & 588.43 & 11 \\
\noalign{\smallskip}\hline
\textit{poly-poisson}
& 140 & 0.04 & 0.3 & 8.05 \\
& 1876 & 0.29 & 2.54 & 8.91 \\
& 16188 & 2.64 & 24.79 & 9.38 \\
& 146283 & 24.24 & 212.23 & 8.75 \\
& 601393 & 86.77 & 770.66 & 8.88 \\
\noalign{\smallskip}\hline
\textit{poly-random}
& 147 & 0.03 & 0.19 & 6.8 \\
& 1883 & 0.28 & 2.62 & 9.41 \\
& 18289 & 2.91 & 27.11 & 9.33 \\
& 161512 & 26.51 & 228.08 & 8.6 \\
& 598699 & 80.15 & 735.55 & 9.18 \\
\noalign{\smallskip}\hline
\end{tabular}
\end{table}
In Table~\ref{table:time:mesh} we report, for each mesh of each dataset, the number of elements, the computational times for both methods and the ratio between the CGAL time and ours.
Moreover, at the bottom of Fig.~\ref{fig:meshes} we plot the times against the number of elements in the mesh.
It is visible how both methods scale linearly with respect to the number of elements, since the kernel of the elements is computed separately and independently for each element.
Our method performs 8 to 11 times faster than CGAL, which approximately means one order of magnitude.
As the elements of these meshes have either 4 faces if they are tetrahedra or 6 faces if they are the union of two tetrahedra, computing their kernel in a geometrical way results much faster than solving a linear problem.
In this case we did not use the shuffle mode, as the number of faces was so small that the visiting order resulted not relevant.
\subsection{Refinements}
\label{subsec:refinements}
As a second setting for our tests, instead of increasing the number of elements we wanted to measure the asymptotic behaviour of the methods as the number of faces and vertices of a single element explodes.
We selected two polyhedra from the dataset \textit{Thingi10K} \cite{zhou2016thingi10k}: the so-called \textit{spiral} (ThingiID: 60246) and \textit{vase} (ThingiID: 85580).
These models are given in the form of a surface triangular mesh but we treat them as single volumetric cell, analyzing the performance of both algorithms as we refine them.
In Table~\ref{table:time:refinements} we report the computational times and the ratio for each refinement.
\begin{figure}[th]
\centering
\includegraphics[width=.8\linewidth]{spiral.png}
\caption{Original \textit{spiral} model and its first refinement, with identical kernels.}
\label{fig:spiral}
\end{figure}
The \textit{spiral} model is refined through a midpoint strategy: each face is subdivided by connecting its barycenter to its other vertices.
As a consequence, the planes induced by its faces remain the same and the kernels of the refined models are all equal (Fig.~\ref{fig:spiral}).
On this example our method performs on average 5.77 times better that the algebraic method (see Table~\ref{table:time:refinements}), and the computational time scales with a constant rate (see the plot in Fig.~\ref{fig:spiral}).
Our implementation takes advantage of the fact that Algorithm~\ref{alg:polyhedron-plane} recognises the several coplanar faces and always performs Algorithm~\ref{alg:polygon-plane} the same number of times, independently of the number of faces.
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth]{vase.png}
\caption{Original \textit{vase} model and its first refinement: small perturbations in the faces lead to slightly different kernels.}
\label{fig:vase}
\end{figure}
The \textit{vase} model is more complex, as it presents a curved surface which generates a lot of different planes defining the kernel.
Moreover, we refined this model using the Loop's algorithm and this generated faces lying on completely new planes.
This explains the difference between the two kernels in Fig.~\ref{fig:vase}: the general shape is similar but the more faces we add to our model the more faces we find on the resulting kernel.
Our geometric method improves the performance of the algebraic one by a factor around 2 in the first refinements, but in the last two meshes the complexity increases drastically and CGAL results faster (see Table.~\ref{table:time:refinements}).
In this case, an efficient treatment of the faces is not sufficient to hide the quadratic nature of the geometric approach.
Even the shuffle mode did not particularly improve the performance, being the object star-shaped.
\begin{table}[htbp]
\caption{Computational times for the \textit{spiral} and \textit{vase} refinements.}
\label{table:time:refinements}
\centering
\begin{tabular}{ccccc}
\hline\noalign{\smallskip}
mesh & $\#$vertices & our & CGAL & ratio \\
\noalign{\smallskip}\hline\noalign{\smallskip}
\textit{spiral}
& 64 & 0.004 & 0.01 & 3.07 \\
& 250 & 0.007 & 0.04 & 6.27 \\
& 994 & 0.02 & 0.14 & 6.56 \\
& 3970 & 0.08 & 0.43 & 5.38 \\
& 15874 & 0.32 & 1.77 & 5.54 \\
& 63490 & 1.05 & 8.24 & 7.86 \\
\hline
\textit{vase}
& 99 & 0.02 & 0.03 & 1.55 \\
& 390 & 0.04 & 0.12 & 2.56 \\
& 1554 & 0.31 & 0.92 & 2.94 \\
& 6210 & 3.24 & 6.1 & 1.88 \\
& 24261 & 47.49 & 37.24 & 0.78 \\
& 36988 & 196.7 & 56.75 & 0.29 \\
\noalign{\smallskip}\hline
\end{tabular}
\end{table}
\subsection{Complex models}
\label{subsec:complex_models}
Last, we try to compute the kernel of some more complex models, taken again from the dataset \textit{Thingi10K} and treated as single volumetric cells.
Even if our method is designed for dealing with polyhedra of relatively small size, as we already saw in Section~\ref{subsec:refinements} our algorithms are still able to compute the kernel of objects with thousands of vertices and faces.
We filtered the \textit{Thingi10K} dataset selecting only ``meaningful'' models: objects with one connected component, genus zero, Euler characteristic greater than zero, closed, not degenerate and of size smaller than 1MB.
Note that, even applying these filters, the majority of the models are not star-shaped, i.e. with empty kernel.
We discarded a few models for computational and stability reasons, for instance because one of the two algorithms failed to process them.
The final collection, which we will call the \textit{Thingi dataset}, contains exactly 1806 distinct volumetric models.
\begin{figure*}[htbp]
\centering
\includegraphics[width=.9\linewidth]{time_thingi.png}
\caption{Thingi dataset times. From left to right: all Thingi dataset, models with empty kernel, models with non-empty kernel.}
\label{fig:time:thingi}
\end{figure*}
In Fig.~\ref{fig:time:thingi} we show the times distribution for the whole Thingi dataset, with a particular focus on the difference between models with empty kernel and models with non-empty kernel.
Globally, the overall cost of computing all kernels is 173 seconds with our method against 518 seconds with CGAL, for an improvement of 3 times.
When the kernel is empty our algorithm is always faster than CGAL: the main reason for this is the usage of the shuffle mode, which makes it extremely cheap to recognise non star-shaped elements.
When the model is star-shaped the distinction between the two methods is not so clear anymore, as the results mainly depend on the shape and size of the object.
\begin{figure*}[ht!]
\centering
\begin{tabular}{cccc}
\includegraphics[width=.2\linewidth]{plus.png} &
\includegraphics[width=.2\linewidth]{star.png} &
\includegraphics[width=.2\linewidth]{flex.png} &
\includegraphics[width=.2\linewidth]{cross.png} \\
\textit{plus} & \textit{star} & \textit{flex} & \textit{cross} \\
\vspace{0.3cm} \\
\includegraphics[width=.2\linewidth]{part.png} &
\includegraphics[height=.2\linewidth]{superellipse.png} &
\includegraphics[width=.2\linewidth]{boteye.png} &
\includegraphics[width=.2\linewidth]{button.png} \\
\textit{part} & \textit{super-ellipse} & \textit{bot-eye} & \textit{button} \\
\vspace{0.3cm} \\
\includegraphics[height=.2\linewidth]{rt4arm.png} &
\includegraphics[width=.2\linewidth]{ball.png} &
\includegraphics[height=.2\linewidth]{acorn.png} &
\includegraphics[width=.2\linewidth]{muffin.png} \\
\textit{rt4-arm} & \textit{ball} & \textit{acorn} & \textit{muffin} \\
\end{tabular}
\caption{Examples of our kernel evaluation for complex models.
In the top row models on which the geometric method is more efficient, in the middle models for which the performance are similar and in the bottom row models on which the algebraic method is preferable.}
\label{fig:complex}
\end{figure*}
To further investigate on this point, in Fig.~\ref{fig:complex} we present the kernel computation of 10 selected star-shaped examples from this dataset.
In the top row we have models on which the geometric method is by far more efficient: \textit{plus} (ThingiID: 1120761), \textit{star} (ThingiID: 313883), \textit{flex} (ThingiID: 827640) and \textit{cross} (ThingiID: 313882).
In the middle row, models for which the performance are similar: \textit{part} (ThingiID: 472063), \textit{super-ellipse} (ThingiID: 40172), \textit{bot-eye} (ThingiID: 37276) and \textit{button} (ThingiID: 1329185).
Then in the bottom row we show models on which the algebraic method is preferable: \textit{rt4-arm} (ThingiID: 39353), \textit{ball} (ThingiID: 58238), \textit{acorn} (ThingiID: 815480), \textit{muffin} (ThingiID: 101636).
The computational times, together with the ones relative to the whole dataset, are reported in Table~\ref{table:time:complex}.
\begin{table}[th]
\caption{Computational times for complex models.
The first number relative to \textit{Thingi} dataset indicates the number of models instead of the number of vertices.}
\label{table:time:complex}
\centering
\begin{tabular}{ccccc}
\hline\noalign{\smallskip}
mesh & $\#$vertices & our-shuffle & CGAL & ratio \\
\noalign{\smallskip}\hline\noalign{\smallskip}
\textit{plus} & 448 & 0.004 & 0.09 & 22.75\\
\textit{star} & 9633 & 0.4 & 5.15 & 12.93\\
\textit{flex} & 834 & 0.02 & 0.27 & 12.76\\
\textit{cross} & 3914 & 0.19 & 2.1 & 11.12\\
\textit{part} & 5382 & 2.58 & 6.94 & 2.69\\
\textit{super-ellipse} & 290 & 0.02 & 0.04 & 2.05\\
\textit{bot-eye} & 453 & 0.03 & 0.03 & 0.96\\
\textit{button} & 1227 & 0.1 & 0.08 & 0.75\\
\textit{rt4-arm} & 655 & 0.13 & 0.09 & 0.67\\
\textit{ball} & 660 & 0.24 & 0.04 & 0.15\\
\textit{acorn} & 4114 & 4.35 & 0.55 & 0.13\\
\textit{muffin} & 8972 & 11.73 & 0.54 & 0.04\\
\textit{\textbf{Thingi dataset}} & 1806 & 172.88 & 518.2 & 2.99\\
\noalign{\smallskip}\hline
\end{tabular}
\end{table}
Once again, we notice that the size of the model impacts on the performance of our method.
Looking at Fig.~\ref{fig:time:thingi} we can see how the models for which our method performs worse than CGAL are all in the right part of the plane, relative to models with a high number of vertices.
At the same time,
the number of vertices of the element, by itself, is not sufficient to justify the supremacy of one method over the other.
For example, models \textit{star} and \textit{flex} have very different sizes and times, but their ratio is quite similar; the same holds for models \textit{parts} and \textit{super-ellipse} or \textit{ball} and \textit{acorn}.
The shape of the object also plays an important role: over models with numerous adjacent co-planar faces like \textit{plus}, \textit{star} (whose bottom is completely flat) and \textit{cross} our method is preferable even when the size grows.
As already seen in Section~\ref{subsec:refinements}, the presence of coplanar faces significantly improves the performance of our method.
Vice-versa, over elements with significant curvatures like \textit{rt4-arm}, \textit{acorn} or \textit{muffin}, the algebraic method performs similarly or better than ours even on relatively small models like \textit{bot-eye}.
Over these models it is still possible to compute a correct kernel with the geometric approach, but the ratio between CGAL time and ours is in the order of $10^{-1}$ or even $10^{-2}$.
\subsection{Comparison with the previous version}
\label{subsec:comparison}
With respect to its introduction in \cite{SorgenteKernel}, we believe that the algorithm is now more easy to read and to understand, thanks to the introduction of labels for storing the position of vertices, edges and faces with respect to a plane.
Another significant difference is that the evaluation of the position of the vertices is now computed once and for all, at the top level (in Algorithm~\ref{alg:kernel}), while in the previous version every algorithm contained some vertices evaluations: this further reduced the computational complexity.
In addition, we switched from the inexact predicates (in \cite{SorgenteKernel} we used the equivalent of \textit{orient3d-fast}) to the exact \textit{orient3d}, which resulted in an increasing precision in the treatment of nearly-coplanar faces, for a small extra cost which was easily compensated by the other improvements.
This switch required a small modification of the \textit{Plane} class: in view of the usage of \textit{orient3d}, for every plane we also store three points on it.
Last, the introduction of the shuffle mode made the computation of the kernels of non star-shaped objects almost immediate, marking a huge difference with respect to the algebraic method and our previous implementation.
In Table~\ref{table:comparison} we report the differences between the old version of the algorithm and the current version in standard and in shuffle mode.
Over the meshes from Section~\ref{subsec:meshes} there is almost no differences between the three versions.
For refined models, there is an improvement of a factor 2 in the computation of the \textit{vase} refinement (we report the sum of the times for all the refinements).
With complex models we have the greatest differences; in these cases we can also appreciate the advantage brought by the shuffle mode, which was not significant in the other tests.
\begin{table}[htbp]
\caption{Performance comparison between the current implementation and the one presented in \cite{SorgenteKernel}.
Only models with significant differences are reported.}
\label{table:comparison}
\centering
\begin{tabular}{cccc}
\hline\noalign{\smallskip}
mesh & our-shuffle & our & our\cite{SorgenteKernel} \\
\noalign{\smallskip}\hline\noalign{\smallskip}
\textit{spiral} (sum) & 1.04 & 1.01 & 1.03\\
\textit{vase} (sum) & 245.61 & 194.91 & 495.63\\
\textit{cross} & 0.19 & 4.15 & 9.14\\
\textit{part} & 2.58 & 5.22 & 12.7\\
\textit{bot-eye} & 0.03 & 0.17 & 0.25\\
\textit{rt4-arm} & 0.13 & 0.14 & 0.21\\
\textit{button} & 0.1 & 0.11 & 0.15\\
\textit{ball} & 0.24 & 0.28 & 0.58\\
\textit{acorn} & 4.35 & 276.13 & 626.72\\
\textit{muffin} & 11.73 & 58.62 & 129.38\\
\noalign{\smallskip}\hline
\end{tabular}
\end{table}
\section{Conclusions}
\label{sec:conclusions}
We presented an algorithm for the computation of the kernel of a polyhedron based on the extension to the 3D case of the geometric approach commonly adopted in two dimensions. With respect to \cite{SorgenteKernel} we have optimized the algorithm in several ways: we now perform all the vertices comparisons in a single, preliminary step; we have introduced the use of exact geometric predicates and a random visiting strategy of the faces that considerably improve the performance of the method over non star-shaped, complex objects.
The algorithm showed up to be robust and reliable, as it computed successfully the kernel of every considered polyhedron.
The efficiency of our algorithm is compared to the CGAL implementation of the algebraic approach to the problem.
From a theoretical point of view, the computational complexity evaluation of Section~\ref{subsec:computational_complexity} suggests that our method is in general quadratic, while the algebraic approach has a lower bound at $n\log(n)$.
Nonetheless, we proved all across Section~\ref{sec:tests} that in several circumstances our approach outperforms the algebraic one.
The geometric approach showed up to be significantly faster than the algebraic one when dealing with models satisfying at least one of the following conditions:
\begin{enumerate}
\item the size of the model is small;
\item the model contains a significant number of co-planar faces;
\item the kernel is empty.
\end{enumerate}
Our method performs significantly better than the algebraic approach over polyhedra with a limited number of vertices and faces, as shown in Section~\ref{subsec:meshes}, making it particularly suitable for the analysis of volumetric tessellations with non-convex elements.
Indeed, we point out that our algorithm is specifically designed to be used with simple polyhedra, possibly composing a bigger and more complex 3D model, rather than with a complete model itself.
This behaviour is particularly evident with model \textit{vase} from Section~\ref{subsec:refinements}.
As long as the size of the model remains reasonable our method is faster than CGAL, then over a certain bound the algebraic method becomes more efficient.
Again, models like \textit{super-ellipse} or \textit{flex} from Section~\ref{subsec:complex_models} have few or zero co-planar faces and a significant kernel, but the size of these meshes is small and the geometric approach offers better performance.
According to Fig.~\ref{fig:time:thingi}, a bound on the number of vertices could be possibly set at around $10^3$.
When the size of the polyhedron increases, our method is still particularly efficient if the model has numerous co-planar faces, due for instance to the presence of flat regions on the surface.
This is a very common situation in models representing mechanical parts.
For instance, models \textit{star} and \textit{part} from Section~\ref{subsec:complex_models} present large flat regions despite having a significant size, and again the geometric approach is faster on these models.
Another scenario in which the geometric approach overperforms the algebraic one is with non star-shaped objects.
The differences in this case are so evident that one could even imagine to use our algorithm to understand, in few iterations in shuffle mode, if a model is actually star-shaped or not, even without computing the proper kernel.
On the other side, the algebraic approach is likely to remain preferable over domains which do not satisfy any of the above conditions: star-shaped objects with thousands of vertices and high surface curvature.
In conclusion, with this work we do not aim at completely replacing the algebraic approach for the kernel computation but instead to give an alternative which can be preferred for specific cases, such as the quality analysis of the elements in a 3D tessellation, in the same way as bubble-sort is to be preferred to optimal sorting algorithms when dealing with very small arrays.
As a future development, we plan to integrate in our algorithm the promising \textit{indirect predicates} introduced in \cite{attene2020indirect}.
Numerical problems remain a critical issue in the computation of geometric constructions like the kernel, independently of the approach adopted.
We believe indirect predicates could enormously help in enhancing the robustness of the algorithm.
Moreover, we plan to include this tool in a suite for the generation and analysis of tessellations of three dimensional domains, aimed at PDE simulations.
The kernel of a polyhedron has a great impact on its geometrical quality, and the geometrical quality of the elements of a mesh determines the accuracy and the efficiency of a numerical method over it.
We are therefore already using this algorithm in works like \cite{sorgente2022role} for better understanding the correlations between the shape of the elements and the performance of the numerical simulations, and be able to adaptively generate, refine or fix a tessellation accordingly to them.
\section*{Acknowledgements}
We would like to thank Dr. M. Manzini for the precious discussions and suggestions, and all the people from IMATI institute involved in the CHANGE project.
Special thanks are also given to the anonymous reviewers for their comments and suggestions.
This work has been partially supported by the ERC Advanced Grant CHANGE contract N.694515.
\bibliographystyle{plain}
|
{'timestamp': '2022-02-15T02:41:30', 'yymm': '2202', 'arxiv_id': '2202.06625', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06625'}
|
arxiv
|
\subsection*{Acknowledgement}
This work was partially supported by MEXT KAKENHI (20H00601, 16H06538), JST CREST (JPMJCR21D3), JST Moonshot R\&D (JPMJMS2033-05), JST AIP Acceleration Research (JPMJCR21U2), NEDO (JPNP18002, JPNP20006), RIKEN Center for Advanced Intelligence Project.and RIKEN Junior Research Associate Program.
\section{Experiment} \label{sec:experiment}
In this section, we demonstrate the performance of the proposed method.
\subsection{Methods for Comparison}
We compared our SI-DTW method with the following approaches:
\begin{itemize}
\item SI-DTW-oc: this is our first idea of introducing conditional SI for time-series similarity using the DTW by additionally conditioning on all the operations of the DTW algorithm itself to make the problem tractable.
%
Then, since the selection event of SI-DTW-oc is simply represented as a single polytope in the data space, we can apply the method in the seminal conditional SI paper \cite{lee2016exact} to compute the over-conditioning $p$-value.
%
The details are shown in Appendix \ref{app:si_dtw_oc}.
%
However, such an over-conditioning leads to a loss of statistical power \citep{lee2016exact, fithian2014optimal}.
Later, this drawback was removed by the SI-DTW method in this paper.
\item Data splitting (DS): an approach that divides the dataset in half based on even and odd indices, and uses one for computing the DTW distance and the other for inference.
\item Permutation: the procedure is described as follows ($\bm X$ and $\bm Y$ are required to have the same length, i.e., $n = m$):
\begin{itemize}
\item Compute the observed test statistic $T^{\rm obs}$ based on $\bm X^{\rm obs}$ and $\bm Y^{\rm obs}$
\item For $1 \lA b$ to $B$ ($B$ is the number of permutations which is given by user)
\begin{itemize}
\item Construct $\bm X^{(b)}$ and $\bm Y^{(b)}$ where $(x_i^{(b)}, y_i^{(b)}) \lA {\rm permute}(x_i^{\rm obs}, y_i^{\rm obs})$
\item Compute $T^{(b)}$ based on $\bm X^{(b)}$ and $\bm Y^{(b)}$
\end{itemize}
\item Compute the $p$-value
$
p_{\rm permutation} = \frac{1}{B} \sum_{b = 1}^B \bm 1 \left \{ T^{\rm obs} \leq T^{(b)} \right \},
$
where $\bm 1\{ \cdot \} $ is the indicator function.
\end{itemize}
\end{itemize}
\subsection{Experimental Setup}
We considered the following covariance matrices:
\begin{itemize}
\item Independence: $\Sigma_{\bm X} = I_n$, $\Sigma_{\bm Y} = I_m$.
\item Correlation: $\Sigma_{\bm X} = \left [0.5^{{\rm abs}(i - i^\prime)} \right ]_{ii^\prime} \in \RR^{n \times n}$, $\Sigma_{\bm Y} =\left [0.5^{{\rm abs}(j - j^\prime)} \right ]_{jj^\prime} \in \RR^{m \times m}$.
\end{itemize}
We generated $\bm X$ and $\bm Y$ with $\bm \mu_{\bm X} = \bm 0_n$, $\bm \mu_{\bm Y} = \bm 0_m + \Delta$ (element-wise addition), $\bm \veps_{\bm X} \sim \NN (\bm 0_n, \Sigma_{\bm X})$, and $\bm \veps_{\bm Y} \sim \NN (\bm 0_m, \Sigma_{\bm Y})$.
Regarding the False Positive Rate (FPR) experiments, we set $\Delta = 0$, and ran 120 trials for each $n = m \in \{ 5, 10, 15, 20\} $.
In regard to the True Positive Rate (TPR) experiments, we set $n = m = 10$, and ran 120 trials for each $\Delta \in \{ 1, 2, 3, 4, 5\} $.
The experiments are repeated 10 times.
Respecting the confidence interval experiments, we set $n = m = 10$, and ran 120 trials for each $\Delta \in \{2, 3, 4, 5\} $.
Regarding the computational time experiments, we set $\Delta = 2$ and ran 10 trials for each $n = m \in \{ 5, 10, 15, 20\} $.
The setup of the robustness experiments were similar to the FPR experiments and we considered the following cases:
\begin{itemize}
\item Non-normal noise: the noises $\bm \veps_{\bm X}$ and $\bm \veps_{\bm Y}$ following Laplace distribution, skew normal distribution (skewness coefficient: 10), and $t_{20}$ distribution.
\item Unknown variance: the variances of the noises were estimated from the data.
\end{itemize}
We set the significance level $\alpha = 0.05$ (we additionally set $\alpha = 0.1$ for the robustness experiments).
\subsection{Numerical Result}
\begin{figure}[!t]
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{fpr_comparison_independence.pdf}
\caption{Independence}
\end{subfigure}
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{fpr_comparison_correlation.pdf}
\caption{Correlation}
\end{subfigure}
\caption{False Positive Rate (FPR) comparison.}
\label{fig:fpr_comparison}
\end{figure}
\begin{figure}[!t]
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{tpr_comparison_independence.pdf}
\caption{Independence}
\end{subfigure}
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{tpr_comparison_correlation.pdf}
\caption{Correlation}
\end{subfigure}
\caption{True Positive Rate (TPR) comparison.}
\label{fig:tpr_comparison}
\end{figure}
\begin{figure}[!t]
\begin{subfigure}{.245\textwidth}
\centering
\includegraphics[width=\linewidth]{ci_length_delta_2.pdf}
\caption{$\Delta = 2$}
\end{subfigure}
\begin{subfigure}{.245\textwidth}
\centering
\includegraphics[width=\linewidth]{ci_length_delta_3.pdf}
\caption{$\Delta = 3$}
\end{subfigure}
\begin{subfigure}{.245\textwidth}
\centering
\includegraphics[width=\linewidth]{ci_length_delta_4.pdf}
\caption{$\Delta = 4$}
\end{subfigure}
\begin{subfigure}{.245\textwidth}
\centering
\includegraphics[width=\linewidth]{ci_length_delta_5.pdf}
\caption{$\Delta = 5$}
\end{subfigure}
\caption{Confidence interval (CI) length comparison.}
\label{fig:ci_length_comparison}
\end{figure}
\begin{figure}[!t]
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{fpr_laplace.pdf}
\caption{Laplace distribution}
\end{subfigure}
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{fpr_skew_normal.pdf}
\caption{Skew normal distribution}
\end{subfigure}
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{fpr_t_20.pdf}
\caption{$t_{20}$ distribution}
\end{subfigure}
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{fpr_estimated_sigma.pdf}
\caption{Estimated variance}
\end{subfigure}
\caption{ The robustness of the proposed method in terms of the FPR control.}
\label{fig:robustness}
\end{figure}
The results of the FPR control are shown in Fig. \ref{fig:fpr_comparison}.
The proposed methods (SI-DTW and SI-DTW-oc) successfully control the FPR in both cases of independence and correlation whereas the permutation and DS \emph{could not}.
Because the permutation and DS failed to control the FPR, we no longer considered the TPR.
The result of TPR experiments are shown in Fig. \ref{fig:tpr_comparison}.
The SI-DTW has higher TPR than the SI-DTW-oc in all the cases.
The TPR results are consistent with the confidence interval (CI) results in Fig. \ref{fig:ci_length_comparison}, i.e.,
The SI-DTW has higher TPR than SI-DTW-oc which indicates it has shorter CI.
Additionally, we demonstrate the robustness of the proposed method in terms of the FPR control.
The results are shown in Fig. \ref{fig:robustness}.
Our method still maintains good performance on FPR control.
\subsection{Real-data Examples}
\begin{figure}[!t]
\begin{subfigure}{.323\textwidth}
\centering
\includegraphics[width=\linewidth]{real_data_italy.pdf}
\caption{Italy}
\end{subfigure}
\begin{subfigure}{.323\textwidth}
\centering
\includegraphics[width=\linewidth]{real_data_melbourne.pdf}
\caption{Melbourne}
\end{subfigure}
\begin{subfigure}{.323\textwidth}
\centering
\includegraphics[width=\linewidth]{real_data_smooth_subspace.pdf}
\caption{Smooth Subspace}
\end{subfigure}
\caption{Boxplots of $p$-values.}
\label{fig:boxplot_p_value}
\end{figure}
We evaluate the proposed SI-DTW on three datasets that are available at UCR Time Series Classification Repository:
Italy Power Demand (Class $\tt{C1}$: days from Oct to March, Class $\tt{C2}$: days from April to September),
Melbourne Pedestrian (Class $\tt{C1}$: Bourke Street Mall, Class $\tt{C2}$: Southern Cross Station)
and Smooth Subspace (Class $\tt{C1}$: smooth subspace spanning from time stamp 1 to 5, Class $\tt{C2}$: smooth subspace spanning from time stamp 11 to 15).
The experiments were conducted with the following setting:
\begin{itemize}
\item Given a time-series dataset with two classes $\tt{C1}$ and $\tt{C2}$
\item \textbf{for} $i \lA 1$ to $120$ \textbf{do}
\begin{itemize}
\item We randomly chose one time-series from $\tt{C1}$ and one time-series from $\tt{C2}$
\item Compute $p$-values of the SI-DTW and SI-DTW-oc
\end{itemize}
\item Showing boxplot of $p$-values obtained from each method
\end{itemize}
The results are shown in Fig \ref{fig:boxplot_p_value}. In all the cases, the selective $p$-value of the SI-DTW tended to be smaller than that of SI-DTW-oc, which indicates that the SI-DTW had higher TPR than SI-DTW-oc.
\section{Computational Method for Computing $\cZ$}
In this section, we present our second contribution, that is, introducing novel computational method to compute $\cZ$ which is the main factor to compute the conditional sampling distribution and the selective $p$-value proposed in previous section.
To this end, we introduce a novel computation method called parametric DTW whose basic idea is illustrated in Fig. \ref{fig:sec_4_Z}.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{sec_4_Z.pdf}
\caption{
Schematic illustration of the construction of $\cZ$.
}
\label{fig:sec_4_Z}
\end{figure}
\subsection{Construction of $\cZ_1$ in \eq{eq:cZ_1}}
\subsubsection{Parametrization of time-series data.}
Before discussing the construction of $\cZ_1$, we introduce some important notations that will be used in the rest of the paper.
As mentioned in Lemma \ref{lemma:data_line}, we focus on a set of data $(\bm X ~ \bm Y)^\top = \bm a + \bm b z \in \RR^{n + m}$ parametrized by a scalar parameter $z$.
We denote
\begin{align} \label{eq:Z_z_Y_z}
\bm X (z) = \bm a^{(1)} + \bm b^{(1)} z
\quad
\text{and}
\quad
\bm Y (z) = \bm a^{(2)} + \bm b^{(2)} z,
\end{align}
where
$ \bm a^{(1)} = \bm a_{1:n} \sqsubseteq \bm a$ is a sub-sequence of $\bm a \in \RR^{n + m}$ from positions 1 to $n$,
\begin{align*}
\bm b^{(1)} = \bm b_{1:n},
\quad \bm a^{(2)} = \bm a_{n+1:n + m},
\quad \bm b^{(2)} = \bm b_{n+1:n + m}.
\end{align*}
The cost matrix $C \Big ( \bm X(z), \bm Y(z) \Big )$ is defined as
\begin{align} \label{eq:cost_matrix_parametrized}
C\Big (\bm X (z), \bm Y (z) \Big )
& = \left[
\Big (
\left (
a^{(1)}_i +
b^{(1)}_i z
\right)
-
\left(
a^{(2)}_j +
b^{(2)}_j z
\right )
\Big)^2
\right]_{ij} \in \RR^{n \times m}.
\end{align}
Given $M \in \cM_{n, m}$, $\bm X(z) \in \RR^n$ and $\bm Y(z) \in \RR^m$, the loss function for the optimal alignment problem is a \emph{quadratic function} w.r.t. $z$ and it is written as
\begin{align} \label{eq:cost_parametrized}
L_{n, m} \big (M, z \big )
=
\Big \langle
M, C\big (\bm X (z), \bm Y (z) \big )
\Big \rangle
& =
\sum_{i \in [n], j \in [m]}
M_{ij} C_{ij}\big (\bm X (z), \bm Y (z) \big ) \nonumber \\
& = \omega_0 + \omega_1 z + \omega_2 z^2
\end{align}
where $\omega_0, \omega_1, \omega_2 \in \RR$ and they are defined as
\begin{align*}
\omega_0 &= \sum_{i, j} M_{ij} \left (a^{(1)}_i - a^{(2)}_j\right)^2,
\quad \omega_1 = 2 \sum_{i, j} M_{ij} \left (a^{(1)}_i - a^{(2)}_j\right) \left (b^{(1)}_i - b^{(2)}_j\right), \\
\omega_2 &= \sum_{i, j} M_{ij} \left (b^{(1)}_i - b^{(2)}_j\right)^2.
\end{align*}
The optimal alignment in \eq{eq:optimal_alignment} and the DTW distance on parametrized data $\big ( \bm X(z), \bm Y(z) \big )$ is defined as
\begin{align}
\hat{M}_{n, m} (z) & = \argmin \limits_{M \in \cM_{n, m}} L_{n, m} \big (M, z \big ), \label{eq:optimal_alignment_parametrized} \\
\hat{L}_{n, m}(z) & = \min \limits_{M \in \cM_{n, m}} L_{n, m} \big (M, z \big ). \label{eq:optimal_cost_parametrized}
\end{align}
Note that the scalar notation $z \in \RR$ in the definitions \eq{eq:cost_parametrized}, \eq{eq:optimal_alignment_parametrized} and \eq{eq:optimal_cost_parametrized} indicates that it corresponds to $\big ( \bm X(z), \bm Y(z) \big )$.
\textbf{Construction of $\cZ_1$.} The set $\cZ_1$ in \eq{eq:cZ_1} now can be re-written as
\begin{align*}
\cZ_1 & = \left \{ z \in \RR \mid \cA\big (\bm X(z), \bm Y(z) \big ) = \hat{M}^{\rm obs} \right \} \\
& = \left \{ z \in \RR \mid \hat{M}_{n, m}(z) = \hat{M}^{\rm obs}\right \}.
\end{align*}
To compute $\cZ_1$, we have to deal with the following two computational challenges:
\begin{itemize}
\item Challenge 1: we need to compute the \emph{entire path} of the optimal alignment matrix $\hat{M}_{n, m}(z)$ for all values of $z \in \RR$.
However, it seems intractable because we have to solve \eq{eq:optimal_alignment_parametrized} for \emph{infinitely} many values of $z \in \RR$ to obtain and $\hat{M}_{n, m}(z)$ and check whether it is the same as $\hat{M}^{\rm obs}$ or not.
\item Challenge 2: we have to solve \eq{eq:optimal_alignment_parametrized} on a huge set of all possible alignment matrices $\cM_{n, m}$ whose size is exponentially increasing with $n$ and $m$.
\end{itemize}
In the next Sec 4.1.1, we introduce an efficient approach to resolve the first challenge.
We will show that the set $\cZ_1$ can be computed with a finite number of operations.
Finally, in Sec 4.1.2, we propose a method to address the second challenge based on the concept of dynamic programming in the standard DTW.
\subsubsection{Parametric Optimal Alignment}
\begin{algorithm}[t]
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{footnotesize}
\begin{algorithmic}[1]
\REQUIRE $n, m, \cM_{n, m} \quad \quad \quad \quad $
\vspace{2pt}
\STATE $t \lA 1$, $z_1 \lA -\infty$, \\
\vspace{2pt}
$\hat{M}_t \lA \hat{M}_{n, m} (z_t) = \argmin \limits_{M \in \cM_{n, m}} L \big (M, z_t \big )$
\WHILE { $z_t < +\infty$}
\vspace{2pt}
\STATE Find the next breakpoint $z_{t+1} > z_t$ and the next optimal alignment matrix $\hat{M}_{t+1}$ s.t.
\vspace{2pt}
\begin{center}
$L_{n, m}(\hat{M}_t, z_{t+1}) = L_{n, m}(\hat{M}_{t + 1}, z_{t+1}).$
\end{center}
\vspace{2pt}
\STATE $t \lA t+1$
\vspace{2pt}
\ENDWHILE
\vspace{2pt}
\STATE $\cT \lA t$
\vspace{2pt}
\ENSURE $\big \{\hat{M}_t \big \}_{t=1}^{\cT - 1}$, $\big \{z_t \big \}_{t=1}^{\cT}$
\end{algorithmic}
\end{footnotesize}
\caption{{\tt paraOptAlign}$(n, m, \cM_{n, m})$}
\label{alg:paraOptAlign}
\end{algorithm}
Algorithm~\ref{alg:paraOptAlign} shows the overview of
our parametric optimal alignment method.
Here, we exploit the fact that,
for each alignment matrix $M \in \cM_{n, m}$,
the loss function $L_{n, m}(M, z)$ is written as a quadratic function (QF) of $z$ as we defined in \eq{eq:cost_parametrized}.
Since the number of alignment matrices $M$ in
$\cM_{n, m}$ is finite, the parametric optimal alignment problem \eq{eq:optimal_cost_parametrized} can be characterized by a finite number of these QFs.
Figure \ref{fig:piecewise} illustrates the set of QFs
each of which corresponds to an alignment matrix $M \in \cM_{n, m}$.
Since the minimum loss for each $z \in \RR$ is the point-wise minimum of these QFs, the DTW distance $\hat{L}_{n, m}(z)$ in \eq{eq:optimal_cost_parametrized}
is the lower envelope of the set of QFs,
which is represented as a \emph{piecewise QF} of $z \in \RR$.
Parametric optimal alignment is interpreted as the problem of identifying this piecewise QF.
In Algorithm \ref{alg:paraOptAlign}, multiple
\emph{breakpoints}
$
z_1 < z_2 < \ldots < z_{\cT}
$
are computed one by one.
Each breakpoint $z_t, t \in [\cT],$ indicates a point at which
the optimal alignment matrix changes, where $\cT$ is the number of breakpoints determined by the algorithm as described above.
By finding all these breakpoints $\{z_t\}_{t=1}^{\cT}$
and the optimal alignment matrix
$\{\hat{M}_t\}_{t=1}^{\cT - 1}$,
the piecewise QF $\hat{L}_{n, m}(z)$ in Fig. \ref{fig:piecewise} (the curves in yellow, blue, green and orange) can be identified.
The algorithm is initialized at the optimal alignment matrix
for $z_1 = -\infty$, which can be easily identified based on the coefficients of the QFs.
At step
$t, t \in [\cT],$
the task is to find the next breakpoint
$z_{t + 1}$
and the next optimal alignment matrix
$\hat{M}_{t + 1}$.
This task can be done by finding the smallest $z_{t + 1}$
such that
$z_{t + 1} > z_t$
among the intersections of the current QF
$L_{n, m} \big (\hat{M}_t, z \big )$
and
each of the other QFs
$L_{n, m} (M, z)$
for
$M \in \cM_{n, m} \setminus \big \{\hat{M}_t \big \}$.
This step is repeated until we find the optimal alignment matrix when $z_t = +\infty$.
The algorithm returns the sequences of the optimal alignment matrices $ \{\hat{M}_t \}_{t=1}^{\cT - 1}$ and breakpoints $ \{z_t \}_{t=1}^{\cT}$.
The entire path of optimal alignment matrices for $z \in \RR$
is given by
\begin{align*}
\hat{M}_{i, j}(z)
=
\mycase{
\hat{M}_1 & \text{ if } z \in (z_1 = -\infty, z_2], \\
\hat{M}_2 & \text{ if } z \in [z_2, z_3], \\
~~ \vdots & \\
\hat{M}_{\cT - 1} & \text{ if } z \in [z_{\cT - 1}, z_{\cT} = +\infty).
}
\end{align*}
\begin{figure}[!t]
\centering
\includegraphics[width=.5\linewidth]{piecewise.pdf}
\caption{A set of quadratic functions (QFs) each of which corresponds to an alignment matrix $M \in \cM_{n, m}$.
The dotted grey QFs correspond to alignment matrices that are NOT optimal for any $z \in \RR$. A set $\{\hat{M}_1, \hat{M}_2, \hat{M}_3, \hat{M}_4\}$ contains alignment matrices that are \emph{optimal} for some $z \in \RR$.
Our goal is to introduce an approach to efficiently identify this set of optimal alignment matrices and the lower envelope in yellow, blue, green and orange.}
\label{fig:piecewise}
\end{figure}
\subsubsection{Parametric DTW}
Unfortunately, the parametric optimal alignment in Algorithm \ref{alg:paraOptAlign}
with the inputs $n$, $m$ and $\cM_{n, m}$
in the previous subsection is computationally impractical
because the number of all possible alignment matrices, i.e., the cardinality of the set $\cM_{n, m}$ is exponentially increasing with
$n$ and $m$.
To resolve this computational issue,
we utilize the concept of the standard DTW
and apply it to the parametric case, which we call \emph{parametric DTW}.
The basic idea of the parametric DTW is to exclude the alignment matrices $M \in \cM_{n, m}$ which can never be optimal at any $z \in \RR$.
Specifically, instead of considering a huge set $\cM_{n, m}$, we only construct and consider a much smaller set $\tilde{\cM}_{n, m}$.
Before introducing the technical details of parametric DTW, we briefly review the standard DTW.
\textbf{Standard DTW (for a single value of $z$).}
In the standard DTW with $n$ and $m$, we use $n \times m$ table
whose
$(i, j)^{\rm th}$ element contains $\hat{M}_{i, j}(z)$ that is
the optimal alignment matrix for the sub-sequences
$\bm X(z)_{1:i}$ and $\bm Y(z)_{1:j}$.
The optimal alignment matrix $\hat{M}_{i, j}(z)$ for each of the sub-problem with $i$ and $j$ can be used for efficiently computing the optimal alignment matrix $\hat{M}_{n, m}(z)$ for the original problem with $n$ and $m$.
It is well-known that the following equation, which is often called \emph{Bellman equation}, holds:
\begin{align} \label{eq:bellman_standard_cost}
c_{ij}(z) &= \big (\bm X_i(z) - \bm Y_j(z) \big)^2 \nonumber \\
\hat{L}_{i, j} (z) &= c_{ij}(z) + \min \left \{ \hat{L}_{i - 1, j} (z), ~ \hat{L}_{i, j - 1} (z), ~ \hat{L}_{i - 1, j - 1} (z)\right \}.
\end{align}
Equivalently, we have
\begin{align} \label{eq:bellman_standard_opt_matrix}
\hat{M}_{i, j}(z) = \argmin \limits_{M \in \tilde{\cM}_{i, j}} L_{i, j} \big (M, z \big ),
\end{align}
where
\begin{align*}
\tilde{\cM}_{i, j} =
\left \{
\begin{array}{l}
{\rm vstack} \left (\hat{M}_{i - 1, j}(z), ~ (0, ...,0, 1) \right ) \in \RR^{i \times j}, \\
{\rm hstack} \left (\hat{M}_{i, j - 1}(z), ~ (0, ...,0, 1)^\top \right ) \in \RR^{i \times j}\\
\begin{pmatrix}
\hat{M}_{i - 1, j - 1}(z) & ~ 0 \\
0 & ~ 1 \\
\end{pmatrix}
\in \RR^{i \times j}
\end{array}
\right \},
\end{align*}
$\rm vstack(\cdot, \cdot)$ and $\rm hstack(\cdot, \cdot)$ are vertical stack and horizontal stack operations, respectively.
The Bellman equation \eq{eq:bellman_standard_opt_matrix} enables us to efficiently compute the optimal alignment matrix for the problem with $n$ and $m$ by using the optimal alignment matrices of its sub-problems.
\textbf{Parametric DTW (for all values of $z \in \RR$).} The basic idea for parametric DTW is to similarly construct an
$n \times m$ table whose $(i, j)^{\rm th}$ element contains
\begin{align*}
\hat{\cM}_{i, j}
=
\left\{
M \in \cM_{i, j}
\mid
{\exists}z \in \RR
\text{ s.t. }
\hat{L}_{i, j}(z) = L_{i, j}(M, z)
\right\}
\end{align*}
which is a \emph{set of optimal alignment matrices} that are optimal for some $z \in \RR$.
Because the optimal alignment matrices $\hat{M}(z)$ is fixed between two consecutive breakpoints $z_t$ and $z_{t+1}$ for $t \in [\cT-1]$, it is given as, $ \hat{\cM}_{i, j} = \big \{\hat{M}_t \big \}_{t=1}^{\cT - 1}$ that is returned by Algorithm \ref{alg:paraOptAlign}.
For instance, $\hat{\cM}_{i, j}$ is a set $\big \{\hat{M}_1, \hat{M}_2, \hat{M}_3, \hat{M}_4 \big \}$ in Fig. \ref{fig:piecewise}.
To efficiently identify $\hat{\cM}_{i, j}$, we construct a set $\tilde{\cM}_{i, j} \supseteq \hat{\cM}_{i, j}$, which is a set of alignment matrices having potential to be optimal at some $z \in \RR$.
In the same way as
\eq{eq:bellman_standard_opt_matrix},
we can consider the Bellman equation for constructing $\hat{\cM}_{i, j}$
as described in the following Lemma.
\begin{lemma} \label{lemma:bellman_parametric}
For $i \in [n]$ and $j \in [m]$, the set of optimal alignment matrices $\hat{\cM}_{i, j}$ is defined as
\begin{align} \label{eq:bellman_parametric_opt_matrices}
\hat{\cM}_{i, j} = \argmin \limits_{M \in \tilde{\cM}_{i, j}} L_{i, j} \big (M, z \big ),
\end{align}
where $\tilde{\cM}_{i, j}$ is a set of alignment matrices having potential to be optimal and it is constructed as
\begin{align} \label{eq:potential_optimal_set}
\tilde{\cM}_{i, j} =
\left \{
\begin{array}{l}
{\rm vstack} \Big (\hat{M}, ~ (0, ...,0, 1) \Big ), \quad \forall \hat{M} \in \hat{\cM}_{i - 1, j},\\
{\rm hstack} \Big (\hat{M}, ~ (0, ...,0, 1)^\top \Big ), \quad \forall \hat{M} \in \hat{\cM}_{i, j - 1}, \\
\begin{pmatrix}
\hat{M} & ~ 0 \\
0 & ~ 1 \\
\end{pmatrix},
\quad \forall \hat{M} \in \hat{\cM}_{i - 1, j - 1}
\end{array}
\right \},
\end{align}
\end{lemma}
\begin{proof}
We prove the lemma by showing that any alignment matrix that is NOT in \begin{align*}
\hat{\cM}_{i - 1, j} ~ \bigcup ~ \hat{\cM}_{i, j - 1} ~ \bigcup ~ \hat{\cM}_{i - 1, j - 1}
\end{align*}
will never be a sub-matrix of the optimal alignment matrices in larger problem with $i$ and $j$ for any $z \in \RR$.
Let $\RR^{(i - 1) \times j} \ni M \not \in \hat{\cM}_{i - 1, j}$ be the alignment matrix that is NOT optimal for all
$z \in \RR$,
i.e.,
\begin{align*}
L_{i - 1, j}(M, z) > \hat{L}_{i - 1, j}(z)
~~~
\forall z \in \RR.
\end{align*}
It suggests that, for any $z \in \RR$ and $c_{ij}(z) = \big (\bm X_i(z) - \bm Y_i(z) \big)^2$,
\begin{align*}
L_{i - 1, j}(M, z) + c_{ij}(z)
& > \min \limits_{\hat{M} \in \hat{\cM}_{i - 1, j}} L_{i - 1, j}(\hat{M}, z) + c_{ij}(z) \\
& = \hat{L}_{i - 1, j} (z) + c_{ij}(z)\\
& \geq \hat{L}_{i, j} (z).
\end{align*}
Thus, $M$ cannot be a sub-matrix of the optimal alignment matrices in larger problem with $i$ and $j$ for any $z \in \RR$.
Similar proofs can be applied for $\RR^{i \times (j - 1)} \ni M \not \in \bigcup ~ \hat{\cM}_{i, j - 1}$ and $\RR^{(i - 1) \times (j - 1)} \ni M \not \in \bigcup ~ \hat{\cM}_{i - 1, j - 1}$.
In other words, only the alignment matrices in
$\hat{\cM}_{i - 1, j} ~ \bigcup ~ \hat{\cM}_{i, j - 1} ~ \bigcup ~ \hat{\cM}_{i - 1, j - 1}$ can be used as the sub-matrix of optimal alignment matrices for larger problems with $i$ and $j$.
\end{proof}
From Lemma \ref{lemma:bellman_parametric}, we can efficiently construct $\tilde{\cM}_{i, j}$.
Then, $\tilde{\cM}_{i, j}$ is used to compute $\hat{\cM}_{i, j}$ by calling {\tt paraOptAlignOnSubProblem}$(i, j, \tilde{\cM}_{i, j})$ in Algorithm \ref{alg:paraOptAlignOnSubProblem}.
Here, we note that Algorithm \ref{alg:paraOptAlignOnSubProblem} is similar to Algorithm \ref{alg:paraOptAlign} which is presented in Sec 4.1.1.
The main difference is that we now solving parametric optimal alignment on smaller problem with $i, j$ and $\tilde{\cM}_{i, j}$.
By repeating the recursive procedure and storing
$\hat{\cM}_{i, j}$
in the $(i, j)^{\rm th}$ element of the table
from smaller $i$ and $j$ to larger $i$ and $j$,
we can end up with
$\tilde{\cM}_{n, m} \supseteq \hat{\cM}_{n, m}$.
By using parametric DTW,
the size of
$\tilde{\cM}_{n, m}$
can be much smaller than the size of all possible alignment matrices
$\cM_{n, m}$,
which makes
the computational cost of
${\tt paraOptAlignOnSubProblem}(n, k, \tilde{\cM}_{n, m})$
can be substantially decreased
compared to
${\tt paraOptAlign}(n, k, \cM_{n, m})$ in Algorithm \ref{alg:paraOptAlign} of Sec 4.1.1.
The parametric DTW method is presented in Algorithm~\ref{alg:paraDTW}.
\begin{algorithm}[t]
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{footnotesize}
\begin{algorithmic}[1]
\REQUIRE $i, j, \tilde{\cM}_{i, j} \quad \quad \quad \quad $
\vspace{2pt}
\STATE $t \lA 1$, $z_1 \lA -\infty$, \\
\vspace{2pt}
$\hat{M}_t \lA \hat{M}_{i, j} (z_t) = \argmin \limits_{M \in \cM_{i, j}} L \big (M, z_t \big )$
\WHILE { $z_t < +\infty$}
\vspace{2pt}
\STATE Find the next breakpoint $z_{t+1} > z_t$ and the next optimal alignment matrix $\hat{M}_{t+1}$ s.t.
\vspace{2pt}
\begin{center}
$L_{i, j}(\hat{M}_t, z_{t+1}) = L_{i, j}(\hat{M}_{t + 1}, z_{t+1}).$
\end{center}
\vspace{2pt}
\STATE $t \lA t+1$
\vspace{2pt}
\ENDWHILE
\vspace{2pt}
\STATE $\cT \lA t$
\vspace{2pt}
\ENSURE $\big \{\hat{M}_t \big \}_{t=1}^{\cT - 1}$, $\big \{z_t \big \}_{t=1}^{\cT}$
\end{algorithmic}
\end{footnotesize}
\caption{{\tt paraOptAlignOnSubProblem}$(i, j, \tilde{\cM}_{i, j})$}
\label{alg:paraOptAlignOnSubProblem}
\end{algorithm}
\begin{algorithm}[t]
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{footnotesize}
\begin{algorithmic}[1]
\REQUIRE $\bm X(z)$ and $\bm Y(z)$
\vspace{2pt}\\
\textbf{for} {$i=1$ to $n$}
\vspace{2pt} \\
~~ \textbf{for} {$j=1$ to $m$}
\vspace{2pt}
\STATE ~~~~~ $\tilde{\cM}_{i, j}$ $\lA$ Eq. \eq{eq:potential_optimal_set}
\vspace{2pt}
\STATE ~~~~~ $ \{\hat{M}_t \}_{t=1}^{\cT - 1}$, $ \{z_t \}_{t=1}^{\cT}$ $\lA$ {\tt paraOptAlignOnSubProblem}($i, j, \tilde{\cM}_{i, j}$) $\quad$ // Algorithm \ref{alg:paraOptAlignOnSubProblem}
\vspace{2pt}
\STATE ~~~~~ $\hat{\cM}_{i, j} \lA \{\hat{M}_t \}_{t=1}^{\cT - 1}$
\vspace{2pt}
\STATE ~~ \textbf{end for}
\vspace{2pt}
\STATE \textbf{end for}
\vspace{2pt}
\ENSURE $\hat{\cM}_{n, m}$
\end{algorithmic}
\end{footnotesize}
\caption{{\tt paraDTW}($\bm X(z), \bm Y(z)$)}
\label{alg:paraDTW}
\end{algorithm}
\subsection{Construction of $\cZ_2$ in \eq{eq:cZ_2}}
Now, we present the construction of $\cZ_2$ in the following Lemma.
\begin{lemma} \label{lemma:cZ_2}
The set $\cZ_2$ in \eq{eq:cZ_2} is an interval defined as:
\begin{align*}
\cZ_2 = \left \{ z \in \RR \mid
\max \limits_{j: \nu_j^{(2)} > 0} \frac{ - \nu_j^{(1)}}{\nu_j^{(2)}}
\leq z \leq
\min \limits_{j: \nu_j^{(2)} < 0} \frac{ - \nu_j^{(1)}}{\nu_j^{(2)}}
\right \},
\end{align*}
where $\bm \nu^{(1)} = \hat{\bm s}^{\rm obs} \circ \hat{M}_{\rm vec} \circ \Omega \bm a$
and
$\bm \nu^{(2)} = \hat{\bm s}^{\rm obs} \circ \hat{M}_{\rm vec} \circ \Omega \bm b$.
\end{lemma}
\begin{proof}
Let us first remind that
$
\hat{\bm s} = \cS(\bm X, \bm Y) =
{\rm sign}
\left (
\hat{M}_{\rm vec}
\circ
\left [ \Omega (\bm X ~ \bm Y)^\top \right ]
\right ),
$
which is defined in \eq{eq:test_statistic_first}.
Then, the set $\cZ_2$ can be re-written as follows:
\begin{align*}
\cZ_2
& = \{ z \in \RR \mid \cS(\bm a + \bm b z) = \hat{\bm s}^{\rm {obs}} \} \\
& = \left \{ z \in \RR \mid
{\rm sign}
\left (
\hat{M}_{\rm vec}
\circ
\Omega (\bm a + \bm b z)
\right )
= \hat{\bm s}^{\rm {obs}} \right \} \\
& = \left \{ z \in \RR \mid
\hat{\bm s}^{\rm {obs}}
\circ
\hat{M}_{\rm vec}
\circ
\Omega (\bm a + \bm b z)
\geq \bm 0 \right \}.
\end{align*}
By defining $\bm \nu^{(1)} = \hat{\bm s}^{\rm obs} \circ \hat{M}_{\rm vec} \circ \Omega \bm a$
and
$\bm \nu^{(2)} = \hat{\bm s}^{\rm obs} \circ \hat{M}_{\rm vec} \circ \Omega \bm b$, the result of Lemma \ref{lemma:cZ_2} is straightforward
by solving the above system of linear inequalities.
\end{proof}
After computing $\cZ_2$, we obtain $\cZ = \cZ_1 \cap \cZ_2$ and compute the selective $p$-value in \eq{eq:selective_p_parametrized} for conducting the inference.
The entire proposed SI-DTW method for computing selective $p$-values is summarized in Algorithm~\ref{alg:si_dtw}.
\begin{algorithm}[t]
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{footnotesize}
\begin{algorithmic}[1]
\REQUIRE $\bm X^{\rm obs}$ and $\bm Y^{\rm obs}$
\vspace{2pt}
\STATE $\hat{M}^{\rm obs} \lA \cA(\bm X^{\rm obs}, \bm Y^{\rm obs})$
\vspace{2pt}
\STATE $\bm X(z)$ and $\bm Y(z)$ $\lA$ Eq. \eq{eq:Z_z_Y_z}
\vspace{2pt}
\STATE $\hat{\cM}_{n, m}$ $\lA$ {\tt paraDTW}($\bm X(z)$, $\bm Y(z)$) $\quad$ // Algorithm \ref{alg:paraDTW}
\vspace{2pt}
\STATE $\cZ_1 \lA \mathop{\cup}_{\hat{M}_{n, m}(z) \in \hat{\cM}_{n, m}} \{z: \hat{M}_{n, m}(z) = \hat{M}^{\rm obs}\}$
\vspace{2pt}
\STATE $\cZ_2 \lA$ Lemma \ref{lemma:cZ_2}
\vspace{2pt}
\STATE $\cZ = \cZ_1 \cap \cZ_2$
\vspace{2pt}
\STATE $p_{\rm selective}$ $\lA$ Eq. \eq{eq:selective_p_parametrized}
\vspace{2pt}
\ENSURE $p_{\rm selective}$
\end{algorithmic}
\end{footnotesize}
\caption{Proposed SI Method (SI-DTW)}
\label{alg:si_dtw}
\end{algorithm}
\section{Conclusion} \label{sec:conclusion}
We present an exact (non-asymptotic) inference method for the DTW distance between two time-series obtained by DTW.
We first introduce the characterization of the exact sampling distribution of the test statistic by conditioning on the selection event of selecting the optimal alignment, which is inspired by the concept of conditional SI.
Then, we introduce the valid selective $p$-value for conducting the exact statistical inference.
After that, we introduce new efficient method to address the computational bottleneck of computing the proposed selective $p$-value.
Finally, we conduct the experiments on both synthetic and real-world datasets to evaluate the performance of our method.
We believe this study is an important contribution toward reliable Machine Learning (ML), which is one of the most critical issues in the ML community.
\section{Conditional SI for the DTW Distance}
In this section, we present our first contribution.
To conduct statistical inference on the DTW distance, we employ the conditional SI framework.
Our basic idea comes from the fact that, given the optimal alignment matrix $\hat{M}$, the DTW distance is written in a closed form as in \eq{eq:test_statistic_final}.
By conditioning on the optimal alignment matrix $\hat{M}$ and its sign $\hat{\bm s}$, we can derive the conditional sampling distribution of the test statistic.
\subsection{Conditional Distribution and Selective $p$-value}
We consider the following conditional sampling distribution of the test statistic
\begin{align} \label{eq:conditional_inference}
\bm \eta_{\hat{M}, \hat{\bm s}}^\top {\bm X \choose \bm Y} \mid
\left \{
\cA(\bm X, \bm Y) = \hat{M}^{\rm obs},
\cS(\bm X, \bm Y) = \hat{\bm s}^{\rm obs}
\right \}
\end{align}
where we denote
\begin{align}
& \cA: (\bm X, \bm Y) \rightarrow \hat{M}, \quad
\cS: (\bm X, \bm Y) \rightarrow \hat{\bm s}, \\
& \hat{M}^{\rm obs} = \cA(\bm X^{\rm obs}, \bm Y^{\rm obs}), \quad
\hat{\bm s}^{\rm obs} = \cS(\bm X^{\rm obs}, \bm Y^{\rm obs}). \nonumber
\end{align}
Next, to test the statistical significance of the DTW distance, we introduce the selective $p$-value, which satisfies the following sampling property:
\begin{align} \label{eq:sampling_property_selective_p}
\PP_{{\rm H}_0} \left (p_{\rm selective} \leq \alpha
\mid
\cA(\bm X, \bm Y) = \hat{M}^{\rm obs}, ~
\cS(\bm X, \bm Y) = \hat{\bm s}^{\rm obs}
\right ) = \alpha,
\end{align}
$\forall \alpha \in [0, 1]$, that is, $p_{\rm selective}$ follows a uniform distribution under the null hypothesis, which is a crucial property for a valid $p$-value.
The selective $p$-value is defined as
\begin{align} \label{eq:selective_p}
p_{\rm selective} =
\bP_{\rm H_0}
\left (
\bm \eta_{\hat{M}, \hat{\bm s}}^\top {\bm X \choose \bm Y} \geq
\bm \eta_{\hat{M}, \hat{\bm s}}^\top {\bm X^{\rm obs} \choose \bm Y^{\rm obs}}
\mid
\begin{array}{l}
\cA(\bm X, \bm Y) = \hat{M}^{\rm obs}, \\
\cS(\bm X, \bm Y) = \hat{\bm s}^{\rm obs}, \\
\cQ (\bm X, \bm Y) = \hat{\bm q}^{\rm obs}
\end{array}
\right ),
\end{align}
where $\cQ : (\bm X, \bm Y) \rightarrow \hat{\bm q}$ is the sufficient statistic of the nuisance parameter that needs to be conditioned on in order to tractably conduct the inference and defined as
\begin{align} \label{eq:q_and_b}
\cQ (\bm X, \bm Y) =
\left (
I_{n+m} -
\bm b
\bm \eta_{\hat{M}, \hat{\bm s}}^\top \right )
{ \bm X \choose \bm Y }
%
\quad \text{ where } \quad
%
\bm b = \frac{\Sigma \bm \eta_{\hat{M}, \hat{\bm s}}}
{\bm \eta_{\hat{M}, \hat{\bm s}}^\top \Sigma \bm \eta_{\hat{M}, \hat{\bm s}}}
\end{align}
and
$
\Sigma =
\begin{pmatrix}
\Sigma_{\bm X} & 0 \\
0 & \Sigma_{\bm Y}
\end{pmatrix}.
$
Here, we would like to note that the selective $p$-value depends on $\cQ (\bm X, \bm Y)$, but the sampling property in \eq{eq:sampling_property_selective_p} continues to be satisfied without this additional condition because we can marginalize over all values of $\cQ (\bm X, \bm Y)$.
The $\cQ(\bm X, \bm Y)$ corresponds to the component $\bm z$ in the seminal conditional SI paper \cite{lee2016exact} (see Sec. 5, Eq. 5.2 and Theorem 5.2).
We note that additional conditioning on $\cQ(\bm X, \bm Y)$ is a standard approach in the conditional SI literature and is used in almost all the conditional SI-related studies.
To compute the selective $p$-value in \eq{eq:selective_p}, we need to identify the conditional data space whose characterization will be introduced in the next section.
\subsection{Conditional Data Space Characterization}
We define the set of $(\bm X ~ \bm Y)^\top \in \RR^{n + m}$ that satisfies the conditions in \eq{eq:selective_p} as
\begin{align} \label{eq:conditional_data_space}
\cD =
\left \{
{\bm X \choose \bm Y}
\mid
\begin{array}{l}
\cA(\bm X, \bm Y) = \hat{M}^{\rm obs},
\cS(\bm X, \bm Y) = \hat{\bm s}^{\rm obs},
\cQ(\bm X, \bm Y) = \hat{\bm q}^{\rm obs}
\end{array}
\right \}.
\end{align}
According to the third condition
$\cQ(\bm X, \bm Y) = \hat{\bm q}^{\rm obs}$, the data in $\cD$ is restricted to a line in $\RR^{n + m}$ as stated in the following Lemma.
\begin{lemma} \label{lemma:data_line}
The set $\cD$ in \eq{eq:conditional_data_space} can be rewritten using a scalar parameter $z \in \RR$ as follows:
\begin{align} \label{eq:conditional_data_space_line}
\cD = \Big \{ (\bm X ~ \bm Y)^\top = \bm a + \bm b z \mid z \in \cZ \Big \},
\end{align}
where vector $\bm a = \hat{\bm q}^{\rm obs} = \cQ(\bm X^{\rm obs}, \bm Y^{\rm obs})$, vector $\bm b$ is defined in \eq{eq:q_and_b}, and
\begin{align} \label{eq:cZ}
\cZ = \left \{
z \in \RR ~
\mid
\cA(\bm a + \bm b z) = \hat{M}^{\rm obs}, ~
\cS(\bm a + \bm b z) = \hat{\bm s}^{\rm obs}
\right \}.
\end{align}
Here, with a slight abuse of notation,
$
\cA(\bm a + \bm b z) = \cA \left ((\bm X ~ \bm Y)^\top \right)
$
is equivalent to $\cA(\bm X, \bm Y)$.
This similarly applies to $\cS(\bm a + \bm b z)$.
\end{lemma}
\begin{proof}
According to the third condition in \eq{eq:conditional_data_space}, we have
\begin{align*}
\cQ (\bm X, \bm Y) & = \hat{\bm q}^{\rm obs} \\
\Leftrightarrow
\Big ( I_{n+m} -
\bm b
\bm \eta_{\hat{M}, \hat{\bm s}}^\top \Big )
( \bm X ~ \bm Y )^\top
& =
\hat{\bm q}^{\rm obs}\\
\Leftrightarrow
( \bm X ~ \bm Y )^\top
& =
\hat{\bm q}^{\rm obs}
+ \bm b
\bm \eta_{\hat{M}, \hat{\bm s}}^\top
( \bm X ~ \bm Y )^\top.
\end{align*}
By defining
$\bm a = \hat{\bm q}^{\rm obs}$,
$z = \bm \eta_{\hat{M}, \hat{\bm s}}^\top \Big ( \bm X ~ \bm Y \Big )^\top$, and incorporating the first and second conditions in \eq{eq:conditional_data_space}, we obtain the results in Lemma \ref{lemma:data_line}.
We note that the fact of restricting the data to the line has been already implicitly exploited in the seminal conditional SI work of \cite{lee2016exact}, but explicitly discussed for the first time in Sec. 6 of \cite{liu2018more}.
\end{proof}
Lemma \ref{lemma:data_line} indicates that we need NOT consider the $(n + m)$-dimensional data space.
Instead, we need only consider the \emph{one-dimensional projected} data space $\cZ$ in \eq{eq:cZ}.
Now, let us consider a random variable $Z \in \RR$ and its observation $Z^{\rm obs} \in \RR$ that satisfies $(\bm X ~ \bm Y)^\top = \bm a + \bm b Z$ and $(\bm X^{\rm obs} ~ \bm Y^{\rm obs})^\top = \bm a + \bm b Z^{\rm obs}$.
The selective $p$-value in (\ref{eq:selective_p}) can be rewritten as
\begin{align} \label{eq:selective_p_parametrized}
p_{\rm selective}
& = \mathbb{P}_{\rm H_0}
\left (
\bm \eta_{\hat{M}, \hat{\bm s}}^\top (\bm X ~ \bm Y)^\top \geq
\bm \eta_{\hat{M}, \hat{\bm s}}^\top (\bm X^{\rm obs} ~ \bm Y^{\rm obs})^\top
\mid
(\bm X ~ \bm Y)^\top \in \cD
\right) \nonumber \\
& = \mathbb{P}_{\rm H_0} \left ( Z \geq Z^{\rm obs}
\mid
Z \in \cZ
\right).
\end{align}
Because the variable $Z \sim \NN(0, \bm \eta^\top \Sigma \bm \eta)$ under the null hypothesis, $Z \mid Z \in \cZ$ follows a \emph{truncated} normal distribution.
Once the truncation region $\cZ$ is identified, computation of the selective $p$-value in (\ref{eq:selective_p_parametrized}) is straightforward.
Therefore, the remaining task is to identify the truncation region $\cZ$ in \eq{eq:cZ}, which can be decomposed into two separate sets as
$\cZ = \cZ_1 \cap \cZ_2$, where
\begin{align}
\cZ_1 & = \{ z \in \RR \mid \cA(\bm a + \bm b z) = \hat{M}^{\rm obs}\} \label{eq:cZ_1}\\
~ \text{ and } ~
\cZ_2 & = \{ z \in \RR \mid \cS(\bm a + \bm b z) = \hat{\bm s}^{\rm {obs}} \}. \label{eq:cZ_2}
\end{align}
In the next section, we will present the constructions of $\cZ_1$ and $\cZ_2$.
\section{Problem Statement} \label{sec:problem_statement}
To formulate the problem, we consider two time-series represented as vectors corrupted with Gaussian noise as
\begin{align}
\RR^n \ni
\bm X &= (x_1, ..., x_n)^\top = \bm \mu_{\bm X} + \bm \veps_{\bm X}, \quad \bm \veps_{\bm X} \sim \NN(\bm 0, \Sigma_{\bm X}), \label{eq:random_X}\\
\RR^m \ni
\bm Y &= (y_1, ..., y_m)^\top = \bm \mu_{\bm Y} + \bm \veps_{\bm Y}, \quad \bm \veps_{\bm Y} \sim \NN(\bm 0, \Sigma_{\bm Y}) \label{eq:random_Y},
\end{align}
where $n$ and $m$ are the lengths of time-series,
$\bm \mu_{\bm X}$ and $\bm \mu_{\bm Y}$ are the vectors of true signals,
$\bm \veps_{\bm X}$ and $\bm \veps_{\bm Y}$ are Gaussian noise vectors with covariances matrices $\Sigma_{\bm X}$ and $\Sigma_{\bm Y}$ assumed to be known or estimable from independent data.
\begin{figure}[!t]
\centering
\includegraphics[width=.65\linewidth]{optimal_alignment_matrix.pdf}
\caption{
An example of (binary) optimal alignment matrix $\hat{M}$.
The DTW method calculates an optimal match (blue) between two given time-series with certain rules: monotonicity, continuity, and matching endpoints.
After obtaining the optimal match, we can define the optimal alignment matrix.
}
\label{fig:optimal_alignment_matrix}
\end{figure}
\subsection{Optimal Alignment and Dynamic Time Warping}
Let us denote the cost matrix of pairwise distances between the elements of $\bm X$ and $\bm Y$ as
\begin{align} \label{eq:cost_matrix}
C(\bm X, \bm Y)
& = \big[(x_i - y_j)^2 \big]_{ij} \in \RR^{n \times m}.
\end{align}
Then, the \emph{optimal alignment matrix} $\hat{M}$ between $\bm X$ and $\bm Y$ is defined as
\begin{align} \label{eq:optimal_alignment}
\hat{M} = \argmin \limits_{M \in \cM_{n, m}} \big \langle M, C(\bm X, \bm Y) \big \rangle,
\end{align}
where we write $\cM_{n, m} \subset \{0, 1\}^{n \times m}$ for the set of (binary) alignment matrices that satisfy the monotonicity, continuity, and matching endpoints constraints as illustrated in Figure \ref{fig:optimal_alignment_matrix},
and $\langle \cdot, \cdot \rangle$ is the Frobenius inner product.
We note that the cardinal of $\cM_{n, m}$ is known as the ${\rm delannoy}(n - 1, m - 1)$ number
which is the number of paths on a rectangular grid from (0, 0) to ($n - 1$, $m - 1$) using only single steps to south, southeast, or east direction.
A naive way to solve \eq{eq:optimal_alignment} is to enumerate all possible candidates in $\cM_{n, m}$ and obtain $\hat{M}$.
However, it is computationally impractical because the size of the set $\cM_{n, m}$ is exponentially increasing with $n$ and $m$.
The DTW is well-known as an efficient dynamic programming algorithm to obtain the solution $\hat{M}$ in \eq{eq:optimal_alignment} with a quadratic $(nm)$ cost by using \emph{Bellman recursion}.
We will later review the details of DTW in Sec 4.1.2 and Eq. \eq{eq:bellman_standard_cost}.
\subsection{Closed-form Expression of the DTW Distance}
After obtaining the optimal alignment matrix $\hat{M}$, the DTW distance is written in a closed form as
\begin{align*}
\hat{L}(\bm X, \bm Y)
& = \left \langle \hat{M}, C(\bm X, \bm Y) \right \rangle
= \hat{M}_{\rm vec}^\top C_{\rm vec}(\bm X, \bm Y),
\end{align*}
where $\hat{M}_{\rm vec} = {\rm vec} (\hat{M}) \in \RR^{n m}$,
%
\begin{align}
& \cC_{\rm vec} (\bm X, \bm Y) = {\rm vec} \Big(\cC(\bm X, \bm Y) \Big) =
\left [ \Omega {\bm X \choose \bm Y} \right ]
\circ
\left [ \Omega {\bm X \choose \bm Y} \right ] \in \RR^{n + m},
\label{eq:C_vec} \\
%
& \Omega =
\begin{pmatrix}
\bm 1_m & \bm 0_m & \cdots & \bm 0_m & - I_m \\
\bm 0_m & \bm 1_m & \cdots & \bm 0_m & - I_m \\
\vdots & \vdots & \ddots & \vdots & \vdots \\
\bm 0_m & \bm 0_m & \cdots & \bm 1_m & - I_m
\end{pmatrix}
\in \RR^{nm \times (n + m)}. \nonumber
\end{align}
Here,
${\rm vec}(\cdot)$ is an operator that transforms a matrix into a vector with concatenated rows,
and the operator $\circ$ is element-wise product.
\begin{example} \label{example:M_hat_vec_Omega_C_vec} ($C_{\rm vec}(\bm X, \bm Y)$, $\Omega$ and $\hat{M}_{\rm vec}$) Given $\bm X = (x_1, x_2)^\top$ and $\bm Y = (y_1, y_2)^\top$, the cost matrix is defined as
\begin{align*}
C(\bm X, \bm Y) =
\begin{pmatrix}
(x_1 - y_1)^2 & (x_1 - y_2)^2 \\
(x_2 - y_1)^2 & (x_2 - y_2)^2
\end{pmatrix}.
\end{align*}
Then, we have
\begin{align*}
C_{\rm vec} (\bm X, \bm Y)
=
\begin{pmatrix}
(x_1 - y_1)^2 \\
(x_1 - y_2)^2 \\
(x_2 - y_1)^2 \\
(x_2 - y_2)^2
\end{pmatrix}
=
\Omega
\begin{pmatrix}
x_1 \\
x_2 \\
y_1 \\
y_ 2
\end{pmatrix}
\circ
\Omega
\begin{pmatrix}
x_1 \\
x_2 \\
y_1 \\
y_ 2
\end{pmatrix}
\text{ where }
\Omega =
\begin{pmatrix}
1 & 0 & 1 & 0 \\
1 & 0 & 0 & 1 \\
0 & 1 & 1 & 0 \\
0 & 1 & 0 & 1
\end{pmatrix}.
\end{align*}
Similarly, given
$
\hat{M} =
\begin{pmatrix}
1 & 0 \\
0 & 1
\end{pmatrix}
$,
then
$
\hat{M}_{\rm vec}
=
\begin{pmatrix}
1 & 0 & 0 & 1
\end{pmatrix}^\top
$.
\end{example}
\subsection{Statistical Inference}
Our goal is to conduct statistical inference for the DTW distance, i.e., we want to test if the two time-series signals are same or not.
Specifically, we consider the following null hypothesis
\begin{align*}
{\rm H}_0:
& ~ \hat{M}_{\rm vec}^\top C_{\rm vec}(\bm \mu_{\bm X}, \bm \mu_{\bm Y}) = 0 \\
\Leftrightarrow ~ {\rm H}_0:
& ~ \hat{M}_{\rm vec}^\top
\Bigg (
\left [ \Omega {\bm \mu_{\bm X} \choose \bm \mu_{\bm Y}} \right ]
\circ
\left [ \Omega {\bm \mu_{\bm X} \choose \bm \mu_{\bm Y}} \right ]
\Bigg ) = 0.
\end{align*}
Instead of testing the above null hypothesis, we can test the \emph{equivalent} one which is defined as
\begin{align} \label{eq:hypothesis}
{\rm H}_0: \hat{M}_{\rm vec}^\top
~
{\rm abs}
\Bigg (
\Omega {\bm \mu_{\bm X} \choose \bm \mu_{\bm Y}}
\Bigg ) = 0,
\end{align}
where ${\rm abs} (\cdot)$ denotes the element-wise absolute operation.
For testing \eq{eq:hypothesis}, the test statistic $T$ is defined as
\begin{align} \label{eq:test_statistic_first}
T =
\hat{M}_{\rm vec}^\top
~ {\rm abs}
\Bigg (
\Omega {\bm X \choose \bm Y}
\Bigg )
& = \hat{M}_{\rm vec}^\top
~ {\rm abs}
\Bigg (
\hat{M}_{\rm vec} \circ \Omega {\bm X \choose \bm Y}
\Bigg ) \nonumber \\
& =
\hat{M}_{\rm vec}^\top
{\rm diag} (\hat{\bm s})\Omega {\bm X \choose \bm Y}
\end{align}
where
$
\hat{\bm s} = {\rm sign}
\left (
\hat{M}_{\rm vec}
\circ
\left [ \Omega {\bm X \choose \bm Y} \right ]
\right ) \in \RR^{nm}
$,
${\rm sign}(\cdot)$ is the operator that
returns an element-wise indication of the sign of a number (${\rm sign} (0) = 0$),
and ${\rm diag}(\hat{\bm s})$ is the diagonal matrix whose diagonal entries are the elements of the vector $\hat{\bm s}$.
For notational simplicity, we can re-write the test statistic as
\begin{align} \label{eq:test_statistic_final}
T = \bm \eta_{\hat{M}, \hat{\bm s}}^\top {\bm X \choose \bm Y}
\quad
\text{where}
\quad
\bm \eta_{\hat{M}, \hat{\bm s}} = \left(
\hat{M}_{\rm vec}^\top {\rm diag}(\hat{\bm s}) \Omega
\right)^\top \in \RR^{n + m}
\end{align}
is the direction of the test statistic.
For statistical inference on the DTW distance, we need to characterize the sampling distribution of the test statistic $T$ in \eq{eq:test_statistic_final}.
Unfortunately, since $\bm \eta_{\hat{M}, \hat{\bm s}}$ depends on $\hat{M}$ and $\hat{\bm s}$ which are defined based on the data, characterization of the exact sampling distribution of the test statistic is intrinsically difficult.
In the next section, we introduce a novel approach to resolve the aforementioned challenge inspired by the concept of conditional SI, and propose a valid \emph{selective $p$-value} to conduct an exact (non-asymptotic) statistical inference on the hypothesis defined in \eq{eq:hypothesis}.
\section{Introduction} \label{sec:intro}
Measuring similarity/distance between two time-series is a fundamental task in various problems.
This task is usually formulated as the problem of minimizing the loss of sequence alignment.
Aligning two time-series involves computing the optimal pairwise correspondence between their elements while preserving the alignment orderings.
The Dynamic Time Warping (DTW) \cite{sakoe1978dynamic} is a standard algorithm for finding the optimal alignment between two given time-series.
The DTW distance has been used for high-stake decision making in various signal processing problems.
When the DTW distance of the two time-series is observed under uncertain environment, it is crucially important to quantify its statistical reliability, e.g., in the form of $p$-value or confidence interval.
However, there is no satisfactory statistical inference method for the DTW distance.
The main difficulty is that the sampling distribution of the DTW distance is too complex to derive, i.e., it is difficult to analyze how the uncertainty in the observed two time-series is transmitted to the uncertainty in the DTW distance.
Without quantifying the statistical reliability of the DTW distance, we cannot properly control the risk of incorrect decision making.
Our key idea to circumvent this difficulty is to employ a \emph{conditional sampling distribution} of the DTW distance --- inspired by the recent development of the \emph{conditional Selective Inference (SI)} literature~\cite{lee2016exact}.
The basic concept of conditional SI is to make an inference conditional on a \emph{selection event}.
The inference based on a conditional sampling distribution is still valid in the sense that the false positive rate (FPR) can be properly controlled under a given significance level $\alpha$ (e.g., 0.05).
To develop a valid statistical inference method for the DTW distance, we interpret the optimization problem of selecting (determining) the optimal alignment as the selection event and consider the sampling distribution of the DTW distance conditional on the optimal alignment.
The main technical contribution in this paper is to derive the conditional sampling distribution of the DTW distance in a tractable form and develop a novel computational method to compute the conditional sampling distribution.
To our knowledge, this is the first exact (non-asymptotic) statistical inference method for the DTW distance in the sense that the FPR can be properly controlled at the given significance level $\alpha$ in the statistical test, which is equivalent to having a confidence interval with a proper $100(1-\alpha)\%$ coverage, when the statistical test and the confidence interval is obtained based on the conditional sampling distribution.
\subsection{Contribution}
The main contributions in this study are two-fold.
The first contribution is that we propose to employ a conditional sampling distribution of the DTW distance in order to develop an exact statistical inference method inspired by the recent development of conditional SI literature.
Whereas the \emph{un}conditional sampling distribution of the DTW distance is too complex to characterize, we show that the sampling distribution conditional on the optimal alignment can be characterized in a tractable form.
The second contribution is to develop a computational method to compute the conditional sampling distribution by introducing non-trivial technique called \emph{parametric DTW method}.
These two contributions enable us to develop the first exact statistical test for the DTW distance, which is crucial for the risk control of high-stake decision making in signal processing.
Figure \ref{fig:intro} shows an illustrative example of the problem and the proposed $p$-value.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{intro.pdf}
\caption{
An illustrative example of the problem and the importance of the proposed method.
The blue curves are the true underlying signals.
The green and orange curves are two time-series observed under noisy environment.
Although, these two time-series have the same underlying signal, the DTW distance between them might be falsely large due to the noises.
By using the proposed method to conduct statistical inference on the DTW distance, the proposed selective $p$-value is large indicating that the difference between two time-series are not statistically significant, i.e., we can successfully identify the false positive.
}
\label{fig:intro}
\end{figure}
\subsection{Related work}
The DTW distance is commonly used for quantifying the similarity/distance between two time-series~\cite{sakoe1978dynamic, keogh2001derivative, muller2007dynamic, cuturi2017soft}.
However, due to the complex discrete nature of the DTW algorithm, it is difficult to quantify the uncertainty of the DTW distance, i.e., it is difficult to analyze how the uncertainty in the two observed time-series is transmitted to their DTW distance.
Therefore, to our knowledge, there are neither exact methods nor asymptotic approximation methods for the statistical inference on the DTW distance.
Due to the lack of valid statistical inference method, when decision making is conducted based on DTW distance, it is difficult to properly control the risk of the incorrect decision.
The notion of conditional SI has been known before, but it has been actively studied in the past few years after the seminal work by Lee et al.~\cite{lee2016exact}.
In their work and several following studies, conditional SI is used for statistical inference on the features of linear models which are selected by a feature selection algorithm such as Lasso.
The basic idea of conditional SI is to make inference based on the sampling distribution of the test statistic conditional on a selection event.
In the case of the conditional SI for Lasso, the authors succeeded in deriving the sampling distribution of the test statistic conditional on the selected features and their signs, and proposed a method for computing the conditional sampling distribution.
Statistical inference based on a conditional sampling distribution is still valid in the sense that the FPR can be properly controlled at the specified significance level.
After the seminal work \citep{lee2016exact}, many conditional SI approaches for various feature selection methods were proposed in the literature \citep{loftus2015selective, yang2016selective, tibshirani2016exact, suzumura2017selective}.
Furthermore, theoretical analyses and new computational methods for conditional SI are still being actively studied \citep{fithian2014optimal, le2021parametric, duy2021more, sugiyama2021more}.
Besides, conditional SI has also been applied to various unsupervised learning problems such as change point detection \citep{hyun2018post, duy2020computing, sugiyama2021valid}, outlier detection \citep{chen2019valid, tsukurimichi2021conditional}, image segmentation \citep{tanizaki2020computing, duy2020quantifying}, and the Wasserstein distance \cite{duy2021exact}.
However, to the best of our knowledge, no study to date can utilize the concept of conditional SI to provide an exact (non-asymptotic) statistical inference on the DTW distance which measures the similarity between two time-series.
Figure \ref{fig:connection_si_lasso_dtw} demonstrate the connection between the proposed method and the seminal conditional SI work \cite{lee2016exact}.
\begin{figure}[t]
\centering
\includegraphics[width=.7\linewidth]{connection_si_lasso_dtw.pdf}
\caption{
The connection between the proposed method in this paper and the seminal conditional SI study \cite{lee2016exact}.
}
\label{fig:connection_si_lasso_dtw}
\end{figure}
\section{Derivation of the SI-DTW-oc method mentioned in Sec. 5}\label{app:si_dtw_oc}
This is our first idea of introducing conditional SI for time series similarity using DTW by additionally conditioning on all the operations of the DTW algorithm itself to make the problem tractable.
Then, since the selection event of SI-DTW-oc is simply represented as a single polytope in the data space, we can apply the method in the seminal conditional SI paper \cite{lee2016exact} to compute the over-conditioning $p$-value.
However, such an over-conditioning leads to a loss of statistical power \citep{lee2016exact, fithian2014optimal}, i.e., low TPR.
\textbf{Notation.}
We denote $\cD^{\rm oc}$ as the over-conditioning data space in SI-DTW-oc.
The difference between $\cD$ in \eq{eq:conditional_data_space} and $\cD^{\rm oc}$ is that the latter is characterized with additional constraints on all the operations of the DTW algorithm.
For two time series with lengths $i \in [n]$ and $j \in [m]$, a set of all possible alignment matrices is defined as $\cM_{i, j}$.
Given $\bm X \in \RR^n$ and $\bm Y \in \RR^m$, the loss between theirs sub-sequence $\bm X_{1:i}$ and $\bm Y_{1:j}$ with $M \in \cM_{i, j}$ is written as
\begin{align*}
L_{i, j} (\bm X, \bm Y, M) = \Big \langle
M, C\big (\bm X_{1:i}, \bm Y_{1:j} \big )
\Big \rangle
\end{align*}
Then, the DTW distance and the optimal alignment matrix between $\bm X_{1:i}$ and $\bm Y_{1:j}$ are respectively written as
\begin{align*}
\hat{L}_{i, j} (\bm X, \bm Y) &= \min \limits_{M \in \cM_{i, j}} ~ L_{i, j} (\bm X, \bm Y, M) \\
\hat{M}_{i, j} (\bm X, \bm Y) &= \argmin \limits_{M \in \cM_{i, j}} ~ L_{i, j} (\bm X, \bm Y, M).
\end{align*}
\textbf{Characterization of the over-conditioning conditional data space $\cD^{\rm oc}$.} Since the inference is conducted with additional conditions on all steps of the DTW, the conditional data space $\cD^{\rm oc}$ is written as
\begin{align} \label{eq:oc_conditional_data_space}
\cD^{\rm oc} =
\left \{
{\bm X \choose \bm Y}
\mid
\begin{array}{l}
\bigcap \limits_{i = 1}^n
\bigcap \limits_{j = 1}^m
\hat{M}_{i, j}(\bm X, \bm Y) = \hat{M}_{i, j}^{\rm obs}, \\
\cS(\bm X, \bm Y) = \hat{\bm s}^{\rm obs},
~ \cQ(\bm X, \bm Y) = \hat{\bm q}^{\rm obs}
\end{array}
\right \},
\end{align}
where $\hat{M}_{i, j}^{\rm obs} = \hat{M}_{i, j}(\bm X^{\rm obs}, \bm Y^{\rm obs})$.
The characterization of the third condition $\cQ(\bm X, \bm Y) = \hat{\bm q}^{\rm obs}$ is a line in the data space as presented in Lemma \ref{lemma:data_line}.
The characterization of the second condition $\cS(\bm X, \bm Y) = \hat{\bm s}^{\rm obs}$ is the same as Lemma \ref{lemma:cZ_2}.
Therefore, the remaining task is to characterize the region in which the data satisfies the first condition.
For each value of $i \in [n]$ and $j \in [m]$, $\hat{M}_{i, j}(\bm X, \bm Y) = \hat{M}_{i, j}^{\rm obs}$ if and only if
\begin{align}
\min \limits_{M \in \cM_{i, j}} ~ L_{i, j} (\bm X, \bm Y, M) &= L_{i, j} (\bm X^{\rm obs}, \bm Y^{\rm obs}, M_{i, j}^{\rm obs}) \\
\Leftrightarrow \quad \quad \quad \quad \quad
\hat{L}_{i, j}(\bm X, \bm Y) &= L_{i, j} (\bm X^{\rm obs}, \bm Y^{\rm obs}, M_{i, j}^{\rm obs}). \label{eq:app_1}
\end{align}
Based on the recursive structure of DTW, we have
\begin{align}
\hat{L}_{i, j}(\bm X, \bm Y) = C_{ij}(\bm X, \bm Y) + \min \left \{
\begin{array}{l}
\hat{L}_{i - 1, j} (\bm X, \bm Y), \\
\hat{L}_{i, j - 1} (\bm X, \bm Y), \\
\hat{L}_{i - 1, j - 1} (\bm X, \bm Y)
\end{array}
\right \}. \label{eq:app_2}
\end{align}
Combining \eq{eq:app_1} and \eq{eq:app_2}, we have the following inequalities
\begin{align} \label{eq:app_3}
\begin{aligned}
L_{i, j} (\bm X^{\rm obs}, \bm Y^{\rm obs}, M_{i, j}^{\rm obs}) &\leq C_{ij}(\bm X, \bm Y) + \hat{L}_{i - 1, j} (\bm X, \bm Y), \\
L_{i, j} (\bm X^{\rm obs}, \bm Y^{\rm obs}, M_{i, j}^{\rm obs}) &\leq C_{ij}(\bm X, \bm Y) + \hat{L}_{i, j - 1} (\bm X, \bm Y), \\
L_{i, j} (\bm X^{\rm obs}, \bm Y^{\rm obs}, M_{i, j}^{\rm obs}) &\leq C_{ij}(\bm X, \bm Y) + \hat{L}_{i - 1, j - 1} (\bm X, \bm Y).
\end{aligned}
\end{align}
Since the loss function is in the quadratic form, \eq{eq:app_3} can be easily written in the form of
\begin{align*}
(\bm X ~ \bm Y)^\top A_{i, j}^{(1)} (\bm X ~ \bm Y) \leq 0, \\
(\bm X ~ \bm Y)^\top A_{i, j}^{(2)} (\bm X ~ \bm Y) \leq 0, \\
(\bm X ~ \bm Y)^\top A_{i, j}^{(3)} (\bm X ~ \bm Y) \leq 0.
\end{align*}
where the matrices $A_{i, j}^{(1)}$, $A_{i, j}^{(2)}$ and $A_{i, j}^{(3)}$ depend on $i$ and $j$.
It suggests that the conditional data space in \eq{eq:oc_conditional_data_space} can be finally characterized as
\begin{align*}
\cD^{\rm oc} =
\left \{
{\bm X \choose \bm Y}
\mid
\begin{array}{l}
\bigcap \limits_{i = 1}^n
\bigcap \limits_{j = 1}^m
\bigcap \limits_{k = 1}^3
(\bm X ~ \bm Y)^\top A_{i, j}^{(k)} (\bm X ~ \bm Y) \leq 0 , \\
\cS(\bm X, \bm Y) = \hat{\bm s}^{\rm obs},
~ \cQ(\bm X, \bm Y) = \hat{\bm q}^{\rm obs}
\end{array}
\right \}.
\end{align*}
Now that the conditional data space $\cD^{\rm oc}$ is identified, we can easily compute the truncation region and calculate the over-conditioning selective $p$-value.
\subsection*{Acknowledgement}
This work was partially supported by MEXT KAKENHI (20H00601, 16H06538), JST CREST (JPMJCR21D3), JST Moonshot R\&D (JPMJMS2033-05), JST AIP Acceleration Research (JPMJCR21U2), NEDO (JPNP18002, JPNP20006), RIKEN Center for Advanced Intelligence Project.and RIKEN Junior Research Associate Program.
\section{Derivation of the SI-DTW-oc method mentioned in Sec. 5}\label{app:si_dtw_oc}
This is our first idea of introducing conditional SI for time series similarity using DTW by additionally conditioning on all the operations of the DTW algorithm itself to make the problem tractable.
Then, since the selection event of SI-DTW-oc is simply represented as a single polytope in the data space, we can apply the method in the seminal conditional SI paper \cite{lee2016exact} to compute the over-conditioning $p$-value.
However, such an over-conditioning leads to a loss of statistical power \citep{lee2016exact, fithian2014optimal}, i.e., low TPR.
\textbf{Notation.}
We denote $\cD^{\rm oc}$ as the over-conditioning data space in SI-DTW-oc.
The difference between $\cD$ in \eq{eq:conditional_data_space} and $\cD^{\rm oc}$ is that the latter is characterized with additional constraints on all the operations of the DTW algorithm.
For two time series with lengths $i \in [n]$ and $j \in [m]$, a set of all possible alignment matrices is defined as $\cM_{i, j}$.
Given $\bm X \in \RR^n$ and $\bm Y \in \RR^m$, the loss between theirs sub-sequence $\bm X_{1:i}$ and $\bm Y_{1:j}$ with $M \in \cM_{i, j}$ is written as
\begin{align*}
L_{i, j} (\bm X, \bm Y, M) = \Big \langle
M, C\big (\bm X_{1:i}, \bm Y_{1:j} \big )
\Big \rangle
\end{align*}
Then, the DTW distance and the optimal alignment matrix between $\bm X_{1:i}$ and $\bm Y_{1:j}$ are respectively written as
\begin{align*}
\hat{L}_{i, j} (\bm X, \bm Y) &= \min \limits_{M \in \cM_{i, j}} ~ L_{i, j} (\bm X, \bm Y, M) \\
\hat{M}_{i, j} (\bm X, \bm Y) &= \argmin \limits_{M \in \cM_{i, j}} ~ L_{i, j} (\bm X, \bm Y, M).
\end{align*}
\textbf{Characterization of the over-conditioning conditional data space $\cD^{\rm oc}$.} Since the inference is conducted with additional conditions on all steps of the DTW, the conditional data space $\cD^{\rm oc}$ is written as
\begin{align} \label{eq:oc_conditional_data_space}
\cD^{\rm oc} =
\left \{
{\bm X \choose \bm Y}
\mid
\begin{array}{l}
\bigcap \limits_{i = 1}^n
\bigcap \limits_{j = 1}^m
\hat{M}_{i, j}(\bm X, \bm Y) = \hat{M}_{i, j}^{\rm obs}, \\
\cS(\bm X, \bm Y) = \hat{\bm s}^{\rm obs},
~ \cQ(\bm X, \bm Y) = \hat{\bm q}^{\rm obs}
\end{array}
\right \},
\end{align}
where $\hat{M}_{i, j}^{\rm obs} = \hat{M}_{i, j}(\bm X^{\rm obs}, \bm Y^{\rm obs})$.
The characterization of the third condition $\cQ(\bm X, \bm Y) = \hat{\bm q}^{\rm obs}$ is a line in the data space as presented in Lemma \ref{lemma:data_line}.
The characterization of the second condition $\cS(\bm X, \bm Y) = \hat{\bm s}^{\rm obs}$ is the same as Lemma \ref{lemma:cZ_2}.
Therefore, the remaining task is to characterize the region in which the data satisfies the first condition.
For each value of $i \in [n]$ and $j \in [m]$, $\hat{M}_{i, j}(\bm X, \bm Y) = \hat{M}_{i, j}^{\rm obs}$ if and only if
\begin{align}
\min \limits_{M \in \cM_{i, j}} ~ L_{i, j} (\bm X, \bm Y, M) &= L_{i, j} (\bm X^{\rm obs}, \bm Y^{\rm obs}, M_{i, j}^{\rm obs}) \\
\Leftrightarrow \quad \quad \quad \quad \quad
\hat{L}_{i, j}(\bm X, \bm Y) &= L_{i, j} (\bm X^{\rm obs}, \bm Y^{\rm obs}, M_{i, j}^{\rm obs}). \label{eq:app_1}
\end{align}
Based on the recursive structure of DTW, we have
\begin{align}
\hat{L}_{i, j}(\bm X, \bm Y) = C_{ij}(\bm X, \bm Y) + \min \left \{
\begin{array}{l}
\hat{L}_{i - 1, j} (\bm X, \bm Y), \\
\hat{L}_{i, j - 1} (\bm X, \bm Y), \\
\hat{L}_{i - 1, j - 1} (\bm X, \bm Y)
\end{array}
\right \}. \label{eq:app_2}
\end{align}
Combining \eq{eq:app_1} and \eq{eq:app_2}, we have the following inequalities
\begin{align} \label{eq:app_3}
\begin{aligned}
L_{i, j} (\bm X^{\rm obs}, \bm Y^{\rm obs}, M_{i, j}^{\rm obs}) &\leq C_{ij}(\bm X, \bm Y) + \hat{L}_{i - 1, j} (\bm X, \bm Y), \\
L_{i, j} (\bm X^{\rm obs}, \bm Y^{\rm obs}, M_{i, j}^{\rm obs}) &\leq C_{ij}(\bm X, \bm Y) + \hat{L}_{i, j - 1} (\bm X, \bm Y), \\
L_{i, j} (\bm X^{\rm obs}, \bm Y^{\rm obs}, M_{i, j}^{\rm obs}) &\leq C_{ij}(\bm X, \bm Y) + \hat{L}_{i - 1, j - 1} (\bm X, \bm Y).
\end{aligned}
\end{align}
Since the loss function is in the quadratic form, \eq{eq:app_3} can be easily written in the form of
\begin{align*}
(\bm X ~ \bm Y)^\top A_{i, j}^{(1)} (\bm X ~ \bm Y) \leq 0, \\
(\bm X ~ \bm Y)^\top A_{i, j}^{(2)} (\bm X ~ \bm Y) \leq 0, \\
(\bm X ~ \bm Y)^\top A_{i, j}^{(3)} (\bm X ~ \bm Y) \leq 0.
\end{align*}
where the matrices $A_{i, j}^{(1)}$, $A_{i, j}^{(2)}$ and $A_{i, j}^{(3)}$ depend on $i$ and $j$.
It suggests that the conditional data space in \eq{eq:oc_conditional_data_space} can be finally characterized as
\begin{align*}
\cD^{\rm oc} =
\left \{
{\bm X \choose \bm Y}
\mid
\begin{array}{l}
\bigcap \limits_{i = 1}^n
\bigcap \limits_{j = 1}^m
\bigcap \limits_{k = 1}^3
(\bm X ~ \bm Y)^\top A_{i, j}^{(k)} (\bm X ~ \bm Y) \leq 0 , \\
\cS(\bm X, \bm Y) = \hat{\bm s}^{\rm obs},
~ \cQ(\bm X, \bm Y) = \hat{\bm q}^{\rm obs}
\end{array}
\right \}.
\end{align*}
Now that the conditional data space $\cD^{\rm oc}$ is identified, we can easily compute the truncation region and calculate the over-conditioning selective $p$-value.
\section{Introduction} \label{sec:intro}
Measuring similarity/distance between two time-series is a fundamental task in various problems.
This task is usually formulated as the problem of minimizing the loss of sequence alignment.
Aligning two time-series involves computing the optimal pairwise correspondence between their elements while preserving the alignment orderings.
The Dynamic Time Warping (DTW) \cite{sakoe1978dynamic} is a standard algorithm for finding the optimal alignment between two given time-series.
The DTW distance has been used for high-stake decision making in various signal processing problems.
When the DTW distance of the two time-series is observed under uncertain environment, it is crucially important to quantify its statistical reliability, e.g., in the form of $p$-value or confidence interval.
However, there is no satisfactory statistical inference method for the DTW distance.
The main difficulty is that the sampling distribution of the DTW distance is too complex to derive, i.e., it is difficult to analyze how the uncertainty in the observed two time-series is transmitted to the uncertainty in the DTW distance.
Without quantifying the statistical reliability of the DTW distance, we cannot properly control the risk of incorrect decision making.
Our key idea to circumvent this difficulty is to employ a \emph{conditional sampling distribution} of the DTW distance --- inspired by the recent development of the \emph{conditional Selective Inference (SI)} literature~\cite{lee2016exact}.
The basic concept of conditional SI is to make an inference conditional on a \emph{selection event}.
The inference based on a conditional sampling distribution is still valid in the sense that the false positive rate (FPR) can be properly controlled under a given significance level $\alpha$ (e.g., 0.05).
To develop a valid statistical inference method for the DTW distance, we interpret the optimization problem of selecting (determining) the optimal alignment as the selection event and consider the sampling distribution of the DTW distance conditional on the optimal alignment.
The main technical contribution in this paper is to derive the conditional sampling distribution of the DTW distance in a tractable form and develop a novel computational method to compute the conditional sampling distribution.
To our knowledge, this is the first exact (non-asymptotic) statistical inference method for the DTW distance in the sense that the FPR can be properly controlled at the given significance level $\alpha$ in the statistical test, which is equivalent to having a confidence interval with a proper $100(1-\alpha)\%$ coverage, when the statistical test and the confidence interval is obtained based on the conditional sampling distribution.
\subsection{Contribution}
The main contributions in this study are two-fold.
The first contribution is that we propose to employ a conditional sampling distribution of the DTW distance in order to develop an exact statistical inference method inspired by the recent development of conditional SI literature.
Whereas the \emph{un}conditional sampling distribution of the DTW distance is too complex to characterize, we show that the sampling distribution conditional on the optimal alignment can be characterized in a tractable form.
The second contribution is to develop a computational method to compute the conditional sampling distribution by introducing non-trivial technique called \emph{parametric DTW method}.
These two contributions enable us to develop the first exact statistical test for the DTW distance, which is crucial for the risk control of high-stake decision making in signal processing.
Figure \ref{fig:intro} shows an illustrative example of the problem and the proposed $p$-value.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{intro.pdf}
\caption{
An illustrative example of the problem and the importance of the proposed method.
The blue curves are the true underlying signals.
The green and orange curves are two time-series observed under noisy environment.
Although, these two time-series have the same underlying signal, the DTW distance between them might be falsely large due to the noises.
By using the proposed method to conduct statistical inference on the DTW distance, the proposed selective $p$-value is large indicating that the difference between two time-series are not statistically significant, i.e., we can successfully identify the false positive.
}
\label{fig:intro}
\end{figure}
\subsection{Related work}
The DTW distance is commonly used for quantifying the similarity/distance between two time-series~\cite{sakoe1978dynamic, keogh2001derivative, muller2007dynamic, cuturi2017soft}.
However, due to the complex discrete nature of the DTW algorithm, it is difficult to quantify the uncertainty of the DTW distance, i.e., it is difficult to analyze how the uncertainty in the two observed time-series is transmitted to their DTW distance.
Therefore, to our knowledge, there are neither exact methods nor asymptotic approximation methods for the statistical inference on the DTW distance.
Due to the lack of valid statistical inference method, when decision making is conducted based on DTW distance, it is difficult to properly control the risk of the incorrect decision.
The notion of conditional SI has been known before, but it has been actively studied in the past few years after the seminal work by Lee et al.~\cite{lee2016exact}.
In their work and several following studies, conditional SI is used for statistical inference on the features of linear models which are selected by a feature selection algorithm such as Lasso.
The basic idea of conditional SI is to make inference based on the sampling distribution of the test statistic conditional on a selection event.
In the case of the conditional SI for Lasso, the authors succeeded in deriving the sampling distribution of the test statistic conditional on the selected features and their signs, and proposed a method for computing the conditional sampling distribution.
Statistical inference based on a conditional sampling distribution is still valid in the sense that the FPR can be properly controlled at the specified significance level.
After the seminal work \citep{lee2016exact}, many conditional SI approaches for various feature selection methods were proposed in the literature \citep{loftus2015selective, yang2016selective, tibshirani2016exact, suzumura2017selective}.
Furthermore, theoretical analyses and new computational methods for conditional SI are still being actively studied \citep{fithian2014optimal, le2021parametric, duy2021more, sugiyama2021more}.
Besides, conditional SI has also been applied to various unsupervised learning problems such as change point detection \citep{hyun2018post, duy2020computing, sugiyama2021valid}, outlier detection \citep{chen2019valid, tsukurimichi2021conditional}, image segmentation \citep{tanizaki2020computing, duy2020quantifying}, and the Wasserstein distance \cite{duy2021exact}.
However, to the best of our knowledge, no study to date can utilize the concept of conditional SI to provide an exact (non-asymptotic) statistical inference on the DTW distance which measures the similarity between two time-series.
Figure \ref{fig:connection_si_lasso_dtw} demonstrate the connection between the proposed method and the seminal conditional SI work \cite{lee2016exact}.
\begin{figure}[t]
\centering
\includegraphics[width=.7\linewidth]{connection_si_lasso_dtw.pdf}
\caption{
The connection between the proposed method in this paper and the seminal conditional SI study \cite{lee2016exact}.
}
\label{fig:connection_si_lasso_dtw}
\end{figure}
\section{Problem Statement} \label{sec:problem_statement}
To formulate the problem, we consider two time-series represented as vectors corrupted with Gaussian noise as
\begin{align}
\RR^n \ni
\bm X &= (x_1, ..., x_n)^\top = \bm \mu_{\bm X} + \bm \veps_{\bm X}, \quad \bm \veps_{\bm X} \sim \NN(\bm 0, \Sigma_{\bm X}), \label{eq:random_X}\\
\RR^m \ni
\bm Y &= (y_1, ..., y_m)^\top = \bm \mu_{\bm Y} + \bm \veps_{\bm Y}, \quad \bm \veps_{\bm Y} \sim \NN(\bm 0, \Sigma_{\bm Y}) \label{eq:random_Y},
\end{align}
where $n$ and $m$ are the lengths of time-series,
$\bm \mu_{\bm X}$ and $\bm \mu_{\bm Y}$ are the vectors of true signals,
$\bm \veps_{\bm X}$ and $\bm \veps_{\bm Y}$ are Gaussian noise vectors with covariances matrices $\Sigma_{\bm X}$ and $\Sigma_{\bm Y}$ assumed to be known or estimable from independent data.
\begin{figure}[!t]
\centering
\includegraphics[width=.65\linewidth]{optimal_alignment_matrix.pdf}
\caption{
An example of (binary) optimal alignment matrix $\hat{M}$.
The DTW method calculates an optimal match (blue) between two given time-series with certain rules: monotonicity, continuity, and matching endpoints.
After obtaining the optimal match, we can define the optimal alignment matrix.
}
\label{fig:optimal_alignment_matrix}
\end{figure}
\subsection{Optimal Alignment and Dynamic Time Warping}
Let us denote the cost matrix of pairwise distances between the elements of $\bm X$ and $\bm Y$ as
\begin{align} \label{eq:cost_matrix}
C(\bm X, \bm Y)
& = \big[(x_i - y_j)^2 \big]_{ij} \in \RR^{n \times m}.
\end{align}
Then, the \emph{optimal alignment matrix} $\hat{M}$ between $\bm X$ and $\bm Y$ is defined as
\begin{align} \label{eq:optimal_alignment}
\hat{M} = \argmin \limits_{M \in \cM_{n, m}} \big \langle M, C(\bm X, \bm Y) \big \rangle,
\end{align}
where we write $\cM_{n, m} \subset \{0, 1\}^{n \times m}$ for the set of (binary) alignment matrices that satisfy the monotonicity, continuity, and matching endpoints constraints as illustrated in Figure \ref{fig:optimal_alignment_matrix},
and $\langle \cdot, \cdot \rangle$ is the Frobenius inner product.
We note that the cardinal of $\cM_{n, m}$ is known as the ${\rm delannoy}(n - 1, m - 1)$ number
which is the number of paths on a rectangular grid from (0, 0) to ($n - 1$, $m - 1$) using only single steps to south, southeast, or east direction.
A naive way to solve \eq{eq:optimal_alignment} is to enumerate all possible candidates in $\cM_{n, m}$ and obtain $\hat{M}$.
However, it is computationally impractical because the size of the set $\cM_{n, m}$ is exponentially increasing with $n$ and $m$.
The DTW is well-known as an efficient dynamic programming algorithm to obtain the solution $\hat{M}$ in \eq{eq:optimal_alignment} with a quadratic $(nm)$ cost by using \emph{Bellman recursion}.
We will later review the details of DTW in Sec 4.1.2 and Eq. \eq{eq:bellman_standard_cost}.
\subsection{Closed-form Expression of the DTW Distance}
After obtaining the optimal alignment matrix $\hat{M}$, the DTW distance is written in a closed form as
\begin{align*}
\hat{L}(\bm X, \bm Y)
& = \left \langle \hat{M}, C(\bm X, \bm Y) \right \rangle
= \hat{M}_{\rm vec}^\top C_{\rm vec}(\bm X, \bm Y),
\end{align*}
where $\hat{M}_{\rm vec} = {\rm vec} (\hat{M}) \in \RR^{n m}$,
%
\begin{align}
& \cC_{\rm vec} (\bm X, \bm Y) = {\rm vec} \Big(\cC(\bm X, \bm Y) \Big) =
\left [ \Omega {\bm X \choose \bm Y} \right ]
\circ
\left [ \Omega {\bm X \choose \bm Y} \right ] \in \RR^{n + m},
\label{eq:C_vec} \\
%
& \Omega =
\begin{pmatrix}
\bm 1_m & \bm 0_m & \cdots & \bm 0_m & - I_m \\
\bm 0_m & \bm 1_m & \cdots & \bm 0_m & - I_m \\
\vdots & \vdots & \ddots & \vdots & \vdots \\
\bm 0_m & \bm 0_m & \cdots & \bm 1_m & - I_m
\end{pmatrix}
\in \RR^{nm \times (n + m)}. \nonumber
\end{align}
Here,
${\rm vec}(\cdot)$ is an operator that transforms a matrix into a vector with concatenated rows,
and the operator $\circ$ is element-wise product.
\begin{example} \label{example:M_hat_vec_Omega_C_vec} ($C_{\rm vec}(\bm X, \bm Y)$, $\Omega$ and $\hat{M}_{\rm vec}$) Given $\bm X = (x_1, x_2)^\top$ and $\bm Y = (y_1, y_2)^\top$, the cost matrix is defined as
\begin{align*}
C(\bm X, \bm Y) =
\begin{pmatrix}
(x_1 - y_1)^2 & (x_1 - y_2)^2 \\
(x_2 - y_1)^2 & (x_2 - y_2)^2
\end{pmatrix}.
\end{align*}
Then, we have
\begin{align*}
C_{\rm vec} (\bm X, \bm Y)
=
\begin{pmatrix}
(x_1 - y_1)^2 \\
(x_1 - y_2)^2 \\
(x_2 - y_1)^2 \\
(x_2 - y_2)^2
\end{pmatrix}
=
\Omega
\begin{pmatrix}
x_1 \\
x_2 \\
y_1 \\
y_ 2
\end{pmatrix}
\circ
\Omega
\begin{pmatrix}
x_1 \\
x_2 \\
y_1 \\
y_ 2
\end{pmatrix}
\text{ where }
\Omega =
\begin{pmatrix}
1 & 0 & 1 & 0 \\
1 & 0 & 0 & 1 \\
0 & 1 & 1 & 0 \\
0 & 1 & 0 & 1
\end{pmatrix}.
\end{align*}
Similarly, given
$
\hat{M} =
\begin{pmatrix}
1 & 0 \\
0 & 1
\end{pmatrix}
$,
then
$
\hat{M}_{\rm vec}
=
\begin{pmatrix}
1 & 0 & 0 & 1
\end{pmatrix}^\top
$.
\end{example}
\subsection{Statistical Inference}
Our goal is to conduct statistical inference for the DTW distance, i.e., we want to test if the two time-series signals are same or not.
Specifically, we consider the following null hypothesis
\begin{align*}
{\rm H}_0:
& ~ \hat{M}_{\rm vec}^\top C_{\rm vec}(\bm \mu_{\bm X}, \bm \mu_{\bm Y}) = 0 \\
\Leftrightarrow ~ {\rm H}_0:
& ~ \hat{M}_{\rm vec}^\top
\Bigg (
\left [ \Omega {\bm \mu_{\bm X} \choose \bm \mu_{\bm Y}} \right ]
\circ
\left [ \Omega {\bm \mu_{\bm X} \choose \bm \mu_{\bm Y}} \right ]
\Bigg ) = 0.
\end{align*}
Instead of testing the above null hypothesis, we can test the \emph{equivalent} one which is defined as
\begin{align} \label{eq:hypothesis}
{\rm H}_0: \hat{M}_{\rm vec}^\top
~
{\rm abs}
\Bigg (
\Omega {\bm \mu_{\bm X} \choose \bm \mu_{\bm Y}}
\Bigg ) = 0,
\end{align}
where ${\rm abs} (\cdot)$ denotes the element-wise absolute operation.
For testing \eq{eq:hypothesis}, the test statistic $T$ is defined as
\begin{align} \label{eq:test_statistic_first}
T =
\hat{M}_{\rm vec}^\top
~ {\rm abs}
\Bigg (
\Omega {\bm X \choose \bm Y}
\Bigg )
& = \hat{M}_{\rm vec}^\top
~ {\rm abs}
\Bigg (
\hat{M}_{\rm vec} \circ \Omega {\bm X \choose \bm Y}
\Bigg ) \nonumber \\
& =
\hat{M}_{\rm vec}^\top
{\rm diag} (\hat{\bm s})\Omega {\bm X \choose \bm Y}
\end{align}
where
$
\hat{\bm s} = {\rm sign}
\left (
\hat{M}_{\rm vec}
\circ
\left [ \Omega {\bm X \choose \bm Y} \right ]
\right ) \in \RR^{nm}
$,
${\rm sign}(\cdot)$ is the operator that
returns an element-wise indication of the sign of a number (${\rm sign} (0) = 0$),
and ${\rm diag}(\hat{\bm s})$ is the diagonal matrix whose diagonal entries are the elements of the vector $\hat{\bm s}$.
For notational simplicity, we can re-write the test statistic as
\begin{align} \label{eq:test_statistic_final}
T = \bm \eta_{\hat{M}, \hat{\bm s}}^\top {\bm X \choose \bm Y}
\quad
\text{where}
\quad
\bm \eta_{\hat{M}, \hat{\bm s}} = \left(
\hat{M}_{\rm vec}^\top {\rm diag}(\hat{\bm s}) \Omega
\right)^\top \in \RR^{n + m}
\end{align}
is the direction of the test statistic.
For statistical inference on the DTW distance, we need to characterize the sampling distribution of the test statistic $T$ in \eq{eq:test_statistic_final}.
Unfortunately, since $\bm \eta_{\hat{M}, \hat{\bm s}}$ depends on $\hat{M}$ and $\hat{\bm s}$ which are defined based on the data, characterization of the exact sampling distribution of the test statistic is intrinsically difficult.
In the next section, we introduce a novel approach to resolve the aforementioned challenge inspired by the concept of conditional SI, and propose a valid \emph{selective $p$-value} to conduct an exact (non-asymptotic) statistical inference on the hypothesis defined in \eq{eq:hypothesis}.
\section{Conditional SI for the DTW Distance}
In this section, we present our first contribution.
To conduct statistical inference on the DTW distance, we employ the conditional SI framework.
Our basic idea comes from the fact that, given the optimal alignment matrix $\hat{M}$, the DTW distance is written in a closed form as in \eq{eq:test_statistic_final}.
By conditioning on the optimal alignment matrix $\hat{M}$ and its sign $\hat{\bm s}$, we can derive the conditional sampling distribution of the test statistic.
\subsection{Conditional Distribution and Selective $p$-value}
We consider the following conditional sampling distribution of the test statistic
\begin{align} \label{eq:conditional_inference}
\bm \eta_{\hat{M}, \hat{\bm s}}^\top {\bm X \choose \bm Y} \mid
\left \{
\cA(\bm X, \bm Y) = \hat{M}^{\rm obs},
\cS(\bm X, \bm Y) = \hat{\bm s}^{\rm obs}
\right \}
\end{align}
where we denote
\begin{align}
& \cA: (\bm X, \bm Y) \rightarrow \hat{M}, \quad
\cS: (\bm X, \bm Y) \rightarrow \hat{\bm s}, \\
& \hat{M}^{\rm obs} = \cA(\bm X^{\rm obs}, \bm Y^{\rm obs}), \quad
\hat{\bm s}^{\rm obs} = \cS(\bm X^{\rm obs}, \bm Y^{\rm obs}). \nonumber
\end{align}
Next, to test the statistical significance of the DTW distance, we introduce the selective $p$-value, which satisfies the following sampling property:
\begin{align} \label{eq:sampling_property_selective_p}
\PP_{{\rm H}_0} \left (p_{\rm selective} \leq \alpha
\mid
\cA(\bm X, \bm Y) = \hat{M}^{\rm obs}, ~
\cS(\bm X, \bm Y) = \hat{\bm s}^{\rm obs}
\right ) = \alpha,
\end{align}
$\forall \alpha \in [0, 1]$, that is, $p_{\rm selective}$ follows a uniform distribution under the null hypothesis, which is a crucial property for a valid $p$-value.
The selective $p$-value is defined as
\begin{align} \label{eq:selective_p}
p_{\rm selective} =
\bP_{\rm H_0}
\left (
\bm \eta_{\hat{M}, \hat{\bm s}}^\top {\bm X \choose \bm Y} \geq
\bm \eta_{\hat{M}, \hat{\bm s}}^\top {\bm X^{\rm obs} \choose \bm Y^{\rm obs}}
\mid
\begin{array}{l}
\cA(\bm X, \bm Y) = \hat{M}^{\rm obs}, \\
\cS(\bm X, \bm Y) = \hat{\bm s}^{\rm obs}, \\
\cQ (\bm X, \bm Y) = \hat{\bm q}^{\rm obs}
\end{array}
\right ),
\end{align}
where $\cQ : (\bm X, \bm Y) \rightarrow \hat{\bm q}$ is the sufficient statistic of the nuisance parameter that needs to be conditioned on in order to tractably conduct the inference and defined as
\begin{align} \label{eq:q_and_b}
\cQ (\bm X, \bm Y) =
\left (
I_{n+m} -
\bm b
\bm \eta_{\hat{M}, \hat{\bm s}}^\top \right )
{ \bm X \choose \bm Y }
%
\quad \text{ where } \quad
%
\bm b = \frac{\Sigma \bm \eta_{\hat{M}, \hat{\bm s}}}
{\bm \eta_{\hat{M}, \hat{\bm s}}^\top \Sigma \bm \eta_{\hat{M}, \hat{\bm s}}}
\end{align}
and
$
\Sigma =
\begin{pmatrix}
\Sigma_{\bm X} & 0 \\
0 & \Sigma_{\bm Y}
\end{pmatrix}.
$
Here, we would like to note that the selective $p$-value depends on $\cQ (\bm X, \bm Y)$, but the sampling property in \eq{eq:sampling_property_selective_p} continues to be satisfied without this additional condition because we can marginalize over all values of $\cQ (\bm X, \bm Y)$.
The $\cQ(\bm X, \bm Y)$ corresponds to the component $\bm z$ in the seminal conditional SI paper \cite{lee2016exact} (see Sec. 5, Eq. 5.2 and Theorem 5.2).
We note that additional conditioning on $\cQ(\bm X, \bm Y)$ is a standard approach in the conditional SI literature and is used in almost all the conditional SI-related studies.
To compute the selective $p$-value in \eq{eq:selective_p}, we need to identify the conditional data space whose characterization will be introduced in the next section.
\subsection{Conditional Data Space Characterization}
We define the set of $(\bm X ~ \bm Y)^\top \in \RR^{n + m}$ that satisfies the conditions in \eq{eq:selective_p} as
\begin{align} \label{eq:conditional_data_space}
\cD =
\left \{
{\bm X \choose \bm Y}
\mid
\begin{array}{l}
\cA(\bm X, \bm Y) = \hat{M}^{\rm obs},
\cS(\bm X, \bm Y) = \hat{\bm s}^{\rm obs},
\cQ(\bm X, \bm Y) = \hat{\bm q}^{\rm obs}
\end{array}
\right \}.
\end{align}
According to the third condition
$\cQ(\bm X, \bm Y) = \hat{\bm q}^{\rm obs}$, the data in $\cD$ is restricted to a line in $\RR^{n + m}$ as stated in the following Lemma.
\begin{lemma} \label{lemma:data_line}
The set $\cD$ in \eq{eq:conditional_data_space} can be rewritten using a scalar parameter $z \in \RR$ as follows:
\begin{align} \label{eq:conditional_data_space_line}
\cD = \Big \{ (\bm X ~ \bm Y)^\top = \bm a + \bm b z \mid z \in \cZ \Big \},
\end{align}
where vector $\bm a = \hat{\bm q}^{\rm obs} = \cQ(\bm X^{\rm obs}, \bm Y^{\rm obs})$, vector $\bm b$ is defined in \eq{eq:q_and_b}, and
\begin{align} \label{eq:cZ}
\cZ = \left \{
z \in \RR ~
\mid
\cA(\bm a + \bm b z) = \hat{M}^{\rm obs}, ~
\cS(\bm a + \bm b z) = \hat{\bm s}^{\rm obs}
\right \}.
\end{align}
Here, with a slight abuse of notation,
$
\cA(\bm a + \bm b z) = \cA \left ((\bm X ~ \bm Y)^\top \right)
$
is equivalent to $\cA(\bm X, \bm Y)$.
This similarly applies to $\cS(\bm a + \bm b z)$.
\end{lemma}
\begin{proof}
According to the third condition in \eq{eq:conditional_data_space}, we have
\begin{align*}
\cQ (\bm X, \bm Y) & = \hat{\bm q}^{\rm obs} \\
\Leftrightarrow
\Big ( I_{n+m} -
\bm b
\bm \eta_{\hat{M}, \hat{\bm s}}^\top \Big )
( \bm X ~ \bm Y )^\top
& =
\hat{\bm q}^{\rm obs}\\
\Leftrightarrow
( \bm X ~ \bm Y )^\top
& =
\hat{\bm q}^{\rm obs}
+ \bm b
\bm \eta_{\hat{M}, \hat{\bm s}}^\top
( \bm X ~ \bm Y )^\top.
\end{align*}
By defining
$\bm a = \hat{\bm q}^{\rm obs}$,
$z = \bm \eta_{\hat{M}, \hat{\bm s}}^\top \Big ( \bm X ~ \bm Y \Big )^\top$, and incorporating the first and second conditions in \eq{eq:conditional_data_space}, we obtain the results in Lemma \ref{lemma:data_line}.
We note that the fact of restricting the data to the line has been already implicitly exploited in the seminal conditional SI work of \cite{lee2016exact}, but explicitly discussed for the first time in Sec. 6 of \cite{liu2018more}.
\end{proof}
Lemma \ref{lemma:data_line} indicates that we need NOT consider the $(n + m)$-dimensional data space.
Instead, we need only consider the \emph{one-dimensional projected} data space $\cZ$ in \eq{eq:cZ}.
Now, let us consider a random variable $Z \in \RR$ and its observation $Z^{\rm obs} \in \RR$ that satisfies $(\bm X ~ \bm Y)^\top = \bm a + \bm b Z$ and $(\bm X^{\rm obs} ~ \bm Y^{\rm obs})^\top = \bm a + \bm b Z^{\rm obs}$.
The selective $p$-value in (\ref{eq:selective_p}) can be rewritten as
\begin{align} \label{eq:selective_p_parametrized}
p_{\rm selective}
& = \mathbb{P}_{\rm H_0}
\left (
\bm \eta_{\hat{M}, \hat{\bm s}}^\top (\bm X ~ \bm Y)^\top \geq
\bm \eta_{\hat{M}, \hat{\bm s}}^\top (\bm X^{\rm obs} ~ \bm Y^{\rm obs})^\top
\mid
(\bm X ~ \bm Y)^\top \in \cD
\right) \nonumber \\
& = \mathbb{P}_{\rm H_0} \left ( Z \geq Z^{\rm obs}
\mid
Z \in \cZ
\right).
\end{align}
Because the variable $Z \sim \NN(0, \bm \eta^\top \Sigma \bm \eta)$ under the null hypothesis, $Z \mid Z \in \cZ$ follows a \emph{truncated} normal distribution.
Once the truncation region $\cZ$ is identified, computation of the selective $p$-value in (\ref{eq:selective_p_parametrized}) is straightforward.
Therefore, the remaining task is to identify the truncation region $\cZ$ in \eq{eq:cZ}, which can be decomposed into two separate sets as
$\cZ = \cZ_1 \cap \cZ_2$, where
\begin{align}
\cZ_1 & = \{ z \in \RR \mid \cA(\bm a + \bm b z) = \hat{M}^{\rm obs}\} \label{eq:cZ_1}\\
~ \text{ and } ~
\cZ_2 & = \{ z \in \RR \mid \cS(\bm a + \bm b z) = \hat{\bm s}^{\rm {obs}} \}. \label{eq:cZ_2}
\end{align}
In the next section, we will present the constructions of $\cZ_1$ and $\cZ_2$.
\section{Computational Method for Computing $\cZ$}
In this section, we present our second contribution, that is, introducing novel computational method to compute $\cZ$ which is the main factor to compute the conditional sampling distribution and the selective $p$-value proposed in previous section.
To this end, we introduce a novel computation method called parametric DTW whose basic idea is illustrated in Fig. \ref{fig:sec_4_Z}.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{sec_4_Z.pdf}
\caption{
Schematic illustration of the construction of $\cZ$.
}
\label{fig:sec_4_Z}
\end{figure}
\subsection{Construction of $\cZ_1$ in \eq{eq:cZ_1}}
\subsubsection{Parametrization of time-series data.}
Before discussing the construction of $\cZ_1$, we introduce some important notations that will be used in the rest of the paper.
As mentioned in Lemma \ref{lemma:data_line}, we focus on a set of data $(\bm X ~ \bm Y)^\top = \bm a + \bm b z \in \RR^{n + m}$ parametrized by a scalar parameter $z$.
We denote
\begin{align} \label{eq:Z_z_Y_z}
\bm X (z) = \bm a^{(1)} + \bm b^{(1)} z
\quad
\text{and}
\quad
\bm Y (z) = \bm a^{(2)} + \bm b^{(2)} z,
\end{align}
where
$ \bm a^{(1)} = \bm a_{1:n} \sqsubseteq \bm a$ is a sub-sequence of $\bm a \in \RR^{n + m}$ from positions 1 to $n$,
\begin{align*}
\bm b^{(1)} = \bm b_{1:n},
\quad \bm a^{(2)} = \bm a_{n+1:n + m},
\quad \bm b^{(2)} = \bm b_{n+1:n + m}.
\end{align*}
The cost matrix $C \Big ( \bm X(z), \bm Y(z) \Big )$ is defined as
\begin{align} \label{eq:cost_matrix_parametrized}
C\Big (\bm X (z), \bm Y (z) \Big )
& = \left[
\Big (
\left (
a^{(1)}_i +
b^{(1)}_i z
\right)
-
\left(
a^{(2)}_j +
b^{(2)}_j z
\right )
\Big)^2
\right]_{ij} \in \RR^{n \times m}.
\end{align}
Given $M \in \cM_{n, m}$, $\bm X(z) \in \RR^n$ and $\bm Y(z) \in \RR^m$, the loss function for the optimal alignment problem is a \emph{quadratic function} w.r.t. $z$ and it is written as
\begin{align} \label{eq:cost_parametrized}
L_{n, m} \big (M, z \big )
=
\Big \langle
M, C\big (\bm X (z), \bm Y (z) \big )
\Big \rangle
& =
\sum_{i \in [n], j \in [m]}
M_{ij} C_{ij}\big (\bm X (z), \bm Y (z) \big ) \nonumber \\
& = \omega_0 + \omega_1 z + \omega_2 z^2
\end{align}
where $\omega_0, \omega_1, \omega_2 \in \RR$ and they are defined as
\begin{align*}
\omega_0 &= \sum_{i, j} M_{ij} \left (a^{(1)}_i - a^{(2)}_j\right)^2,
\quad \omega_1 = 2 \sum_{i, j} M_{ij} \left (a^{(1)}_i - a^{(2)}_j\right) \left (b^{(1)}_i - b^{(2)}_j\right), \\
\omega_2 &= \sum_{i, j} M_{ij} \left (b^{(1)}_i - b^{(2)}_j\right)^2.
\end{align*}
The optimal alignment in \eq{eq:optimal_alignment} and the DTW distance on parametrized data $\big ( \bm X(z), \bm Y(z) \big )$ is defined as
\begin{align}
\hat{M}_{n, m} (z) & = \argmin \limits_{M \in \cM_{n, m}} L_{n, m} \big (M, z \big ), \label{eq:optimal_alignment_parametrized} \\
\hat{L}_{n, m}(z) & = \min \limits_{M \in \cM_{n, m}} L_{n, m} \big (M, z \big ). \label{eq:optimal_cost_parametrized}
\end{align}
Note that the scalar notation $z \in \RR$ in the definitions \eq{eq:cost_parametrized}, \eq{eq:optimal_alignment_parametrized} and \eq{eq:optimal_cost_parametrized} indicates that it corresponds to $\big ( \bm X(z), \bm Y(z) \big )$.
\textbf{Construction of $\cZ_1$.} The set $\cZ_1$ in \eq{eq:cZ_1} now can be re-written as
\begin{align*}
\cZ_1 & = \left \{ z \in \RR \mid \cA\big (\bm X(z), \bm Y(z) \big ) = \hat{M}^{\rm obs} \right \} \\
& = \left \{ z \in \RR \mid \hat{M}_{n, m}(z) = \hat{M}^{\rm obs}\right \}.
\end{align*}
To compute $\cZ_1$, we have to deal with the following two computational challenges:
\begin{itemize}
\item Challenge 1: we need to compute the \emph{entire path} of the optimal alignment matrix $\hat{M}_{n, m}(z)$ for all values of $z \in \RR$.
However, it seems intractable because we have to solve \eq{eq:optimal_alignment_parametrized} for \emph{infinitely} many values of $z \in \RR$ to obtain and $\hat{M}_{n, m}(z)$ and check whether it is the same as $\hat{M}^{\rm obs}$ or not.
\item Challenge 2: we have to solve \eq{eq:optimal_alignment_parametrized} on a huge set of all possible alignment matrices $\cM_{n, m}$ whose size is exponentially increasing with $n$ and $m$.
\end{itemize}
In the next Sec 4.1.1, we introduce an efficient approach to resolve the first challenge.
We will show that the set $\cZ_1$ can be computed with a finite number of operations.
Finally, in Sec 4.1.2, we propose a method to address the second challenge based on the concept of dynamic programming in the standard DTW.
\subsubsection{Parametric Optimal Alignment}
\begin{algorithm}[t]
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{footnotesize}
\begin{algorithmic}[1]
\REQUIRE $n, m, \cM_{n, m} \quad \quad \quad \quad $
\vspace{2pt}
\STATE $t \lA 1$, $z_1 \lA -\infty$, \\
\vspace{2pt}
$\hat{M}_t \lA \hat{M}_{n, m} (z_t) = \argmin \limits_{M \in \cM_{n, m}} L \big (M, z_t \big )$
\WHILE { $z_t < +\infty$}
\vspace{2pt}
\STATE Find the next breakpoint $z_{t+1} > z_t$ and the next optimal alignment matrix $\hat{M}_{t+1}$ s.t.
\vspace{2pt}
\begin{center}
$L_{n, m}(\hat{M}_t, z_{t+1}) = L_{n, m}(\hat{M}_{t + 1}, z_{t+1}).$
\end{center}
\vspace{2pt}
\STATE $t \lA t+1$
\vspace{2pt}
\ENDWHILE
\vspace{2pt}
\STATE $\cT \lA t$
\vspace{2pt}
\ENSURE $\big \{\hat{M}_t \big \}_{t=1}^{\cT - 1}$, $\big \{z_t \big \}_{t=1}^{\cT}$
\end{algorithmic}
\end{footnotesize}
\caption{{\tt paraOptAlign}$(n, m, \cM_{n, m})$}
\label{alg:paraOptAlign}
\end{algorithm}
Algorithm~\ref{alg:paraOptAlign} shows the overview of
our parametric optimal alignment method.
Here, we exploit the fact that,
for each alignment matrix $M \in \cM_{n, m}$,
the loss function $L_{n, m}(M, z)$ is written as a quadratic function (QF) of $z$ as we defined in \eq{eq:cost_parametrized}.
Since the number of alignment matrices $M$ in
$\cM_{n, m}$ is finite, the parametric optimal alignment problem \eq{eq:optimal_cost_parametrized} can be characterized by a finite number of these QFs.
Figure \ref{fig:piecewise} illustrates the set of QFs
each of which corresponds to an alignment matrix $M \in \cM_{n, m}$.
Since the minimum loss for each $z \in \RR$ is the point-wise minimum of these QFs, the DTW distance $\hat{L}_{n, m}(z)$ in \eq{eq:optimal_cost_parametrized}
is the lower envelope of the set of QFs,
which is represented as a \emph{piecewise QF} of $z \in \RR$.
Parametric optimal alignment is interpreted as the problem of identifying this piecewise QF.
In Algorithm \ref{alg:paraOptAlign}, multiple
\emph{breakpoints}
$
z_1 < z_2 < \ldots < z_{\cT}
$
are computed one by one.
Each breakpoint $z_t, t \in [\cT],$ indicates a point at which
the optimal alignment matrix changes, where $\cT$ is the number of breakpoints determined by the algorithm as described above.
By finding all these breakpoints $\{z_t\}_{t=1}^{\cT}$
and the optimal alignment matrix
$\{\hat{M}_t\}_{t=1}^{\cT - 1}$,
the piecewise QF $\hat{L}_{n, m}(z)$ in Fig. \ref{fig:piecewise} (the curves in yellow, blue, green and orange) can be identified.
The algorithm is initialized at the optimal alignment matrix
for $z_1 = -\infty$, which can be easily identified based on the coefficients of the QFs.
At step
$t, t \in [\cT],$
the task is to find the next breakpoint
$z_{t + 1}$
and the next optimal alignment matrix
$\hat{M}_{t + 1}$.
This task can be done by finding the smallest $z_{t + 1}$
such that
$z_{t + 1} > z_t$
among the intersections of the current QF
$L_{n, m} \big (\hat{M}_t, z \big )$
and
each of the other QFs
$L_{n, m} (M, z)$
for
$M \in \cM_{n, m} \setminus \big \{\hat{M}_t \big \}$.
This step is repeated until we find the optimal alignment matrix when $z_t = +\infty$.
The algorithm returns the sequences of the optimal alignment matrices $ \{\hat{M}_t \}_{t=1}^{\cT - 1}$ and breakpoints $ \{z_t \}_{t=1}^{\cT}$.
The entire path of optimal alignment matrices for $z \in \RR$
is given by
\begin{align*}
\hat{M}_{i, j}(z)
=
\mycase{
\hat{M}_1 & \text{ if } z \in (z_1 = -\infty, z_2], \\
\hat{M}_2 & \text{ if } z \in [z_2, z_3], \\
~~ \vdots & \\
\hat{M}_{\cT - 1} & \text{ if } z \in [z_{\cT - 1}, z_{\cT} = +\infty).
}
\end{align*}
\begin{figure}[!t]
\centering
\includegraphics[width=.5\linewidth]{piecewise.pdf}
\caption{A set of quadratic functions (QFs) each of which corresponds to an alignment matrix $M \in \cM_{n, m}$.
The dotted grey QFs correspond to alignment matrices that are NOT optimal for any $z \in \RR$. A set $\{\hat{M}_1, \hat{M}_2, \hat{M}_3, \hat{M}_4\}$ contains alignment matrices that are \emph{optimal} for some $z \in \RR$.
Our goal is to introduce an approach to efficiently identify this set of optimal alignment matrices and the lower envelope in yellow, blue, green and orange.}
\label{fig:piecewise}
\end{figure}
\subsubsection{Parametric DTW}
Unfortunately, the parametric optimal alignment in Algorithm \ref{alg:paraOptAlign}
with the inputs $n$, $m$ and $\cM_{n, m}$
in the previous subsection is computationally impractical
because the number of all possible alignment matrices, i.e., the cardinality of the set $\cM_{n, m}$ is exponentially increasing with
$n$ and $m$.
To resolve this computational issue,
we utilize the concept of the standard DTW
and apply it to the parametric case, which we call \emph{parametric DTW}.
The basic idea of the parametric DTW is to exclude the alignment matrices $M \in \cM_{n, m}$ which can never be optimal at any $z \in \RR$.
Specifically, instead of considering a huge set $\cM_{n, m}$, we only construct and consider a much smaller set $\tilde{\cM}_{n, m}$.
Before introducing the technical details of parametric DTW, we briefly review the standard DTW.
\textbf{Standard DTW (for a single value of $z$).}
In the standard DTW with $n$ and $m$, we use $n \times m$ table
whose
$(i, j)^{\rm th}$ element contains $\hat{M}_{i, j}(z)$ that is
the optimal alignment matrix for the sub-sequences
$\bm X(z)_{1:i}$ and $\bm Y(z)_{1:j}$.
The optimal alignment matrix $\hat{M}_{i, j}(z)$ for each of the sub-problem with $i$ and $j$ can be used for efficiently computing the optimal alignment matrix $\hat{M}_{n, m}(z)$ for the original problem with $n$ and $m$.
It is well-known that the following equation, which is often called \emph{Bellman equation}, holds:
\begin{align} \label{eq:bellman_standard_cost}
c_{ij}(z) &= \big (\bm X_i(z) - \bm Y_j(z) \big)^2 \nonumber \\
\hat{L}_{i, j} (z) &= c_{ij}(z) + \min \left \{ \hat{L}_{i - 1, j} (z), ~ \hat{L}_{i, j - 1} (z), ~ \hat{L}_{i - 1, j - 1} (z)\right \}.
\end{align}
Equivalently, we have
\begin{align} \label{eq:bellman_standard_opt_matrix}
\hat{M}_{i, j}(z) = \argmin \limits_{M \in \tilde{\cM}_{i, j}} L_{i, j} \big (M, z \big ),
\end{align}
where
\begin{align*}
\tilde{\cM}_{i, j} =
\left \{
\begin{array}{l}
{\rm vstack} \left (\hat{M}_{i - 1, j}(z), ~ (0, ...,0, 1) \right ) \in \RR^{i \times j}, \\
{\rm hstack} \left (\hat{M}_{i, j - 1}(z), ~ (0, ...,0, 1)^\top \right ) \in \RR^{i \times j}\\
\begin{pmatrix}
\hat{M}_{i - 1, j - 1}(z) & ~ 0 \\
0 & ~ 1 \\
\end{pmatrix}
\in \RR^{i \times j}
\end{array}
\right \},
\end{align*}
$\rm vstack(\cdot, \cdot)$ and $\rm hstack(\cdot, \cdot)$ are vertical stack and horizontal stack operations, respectively.
The Bellman equation \eq{eq:bellman_standard_opt_matrix} enables us to efficiently compute the optimal alignment matrix for the problem with $n$ and $m$ by using the optimal alignment matrices of its sub-problems.
\textbf{Parametric DTW (for all values of $z \in \RR$).} The basic idea for parametric DTW is to similarly construct an
$n \times m$ table whose $(i, j)^{\rm th}$ element contains
\begin{align*}
\hat{\cM}_{i, j}
=
\left\{
M \in \cM_{i, j}
\mid
{\exists}z \in \RR
\text{ s.t. }
\hat{L}_{i, j}(z) = L_{i, j}(M, z)
\right\}
\end{align*}
which is a \emph{set of optimal alignment matrices} that are optimal for some $z \in \RR$.
Because the optimal alignment matrices $\hat{M}(z)$ is fixed between two consecutive breakpoints $z_t$ and $z_{t+1}$ for $t \in [\cT-1]$, it is given as, $ \hat{\cM}_{i, j} = \big \{\hat{M}_t \big \}_{t=1}^{\cT - 1}$ that is returned by Algorithm \ref{alg:paraOptAlign}.
For instance, $\hat{\cM}_{i, j}$ is a set $\big \{\hat{M}_1, \hat{M}_2, \hat{M}_3, \hat{M}_4 \big \}$ in Fig. \ref{fig:piecewise}.
To efficiently identify $\hat{\cM}_{i, j}$, we construct a set $\tilde{\cM}_{i, j} \supseteq \hat{\cM}_{i, j}$, which is a set of alignment matrices having potential to be optimal at some $z \in \RR$.
In the same way as
\eq{eq:bellman_standard_opt_matrix},
we can consider the Bellman equation for constructing $\hat{\cM}_{i, j}$
as described in the following Lemma.
\begin{lemma} \label{lemma:bellman_parametric}
For $i \in [n]$ and $j \in [m]$, the set of optimal alignment matrices $\hat{\cM}_{i, j}$ is defined as
\begin{align} \label{eq:bellman_parametric_opt_matrices}
\hat{\cM}_{i, j} = \argmin \limits_{M \in \tilde{\cM}_{i, j}} L_{i, j} \big (M, z \big ),
\end{align}
where $\tilde{\cM}_{i, j}$ is a set of alignment matrices having potential to be optimal and it is constructed as
\begin{align} \label{eq:potential_optimal_set}
\tilde{\cM}_{i, j} =
\left \{
\begin{array}{l}
{\rm vstack} \Big (\hat{M}, ~ (0, ...,0, 1) \Big ), \quad \forall \hat{M} \in \hat{\cM}_{i - 1, j},\\
{\rm hstack} \Big (\hat{M}, ~ (0, ...,0, 1)^\top \Big ), \quad \forall \hat{M} \in \hat{\cM}_{i, j - 1}, \\
\begin{pmatrix}
\hat{M} & ~ 0 \\
0 & ~ 1 \\
\end{pmatrix},
\quad \forall \hat{M} \in \hat{\cM}_{i - 1, j - 1}
\end{array}
\right \},
\end{align}
\end{lemma}
\begin{proof}
We prove the lemma by showing that any alignment matrix that is NOT in \begin{align*}
\hat{\cM}_{i - 1, j} ~ \bigcup ~ \hat{\cM}_{i, j - 1} ~ \bigcup ~ \hat{\cM}_{i - 1, j - 1}
\end{align*}
will never be a sub-matrix of the optimal alignment matrices in larger problem with $i$ and $j$ for any $z \in \RR$.
Let $\RR^{(i - 1) \times j} \ni M \not \in \hat{\cM}_{i - 1, j}$ be the alignment matrix that is NOT optimal for all
$z \in \RR$,
i.e.,
\begin{align*}
L_{i - 1, j}(M, z) > \hat{L}_{i - 1, j}(z)
~~~
\forall z \in \RR.
\end{align*}
It suggests that, for any $z \in \RR$ and $c_{ij}(z) = \big (\bm X_i(z) - \bm Y_i(z) \big)^2$,
\begin{align*}
L_{i - 1, j}(M, z) + c_{ij}(z)
& > \min \limits_{\hat{M} \in \hat{\cM}_{i - 1, j}} L_{i - 1, j}(\hat{M}, z) + c_{ij}(z) \\
& = \hat{L}_{i - 1, j} (z) + c_{ij}(z)\\
& \geq \hat{L}_{i, j} (z).
\end{align*}
Thus, $M$ cannot be a sub-matrix of the optimal alignment matrices in larger problem with $i$ and $j$ for any $z \in \RR$.
Similar proofs can be applied for $\RR^{i \times (j - 1)} \ni M \not \in \bigcup ~ \hat{\cM}_{i, j - 1}$ and $\RR^{(i - 1) \times (j - 1)} \ni M \not \in \bigcup ~ \hat{\cM}_{i - 1, j - 1}$.
In other words, only the alignment matrices in
$\hat{\cM}_{i - 1, j} ~ \bigcup ~ \hat{\cM}_{i, j - 1} ~ \bigcup ~ \hat{\cM}_{i - 1, j - 1}$ can be used as the sub-matrix of optimal alignment matrices for larger problems with $i$ and $j$.
\end{proof}
From Lemma \ref{lemma:bellman_parametric}, we can efficiently construct $\tilde{\cM}_{i, j}$.
Then, $\tilde{\cM}_{i, j}$ is used to compute $\hat{\cM}_{i, j}$ by calling {\tt paraOptAlignOnSubProblem}$(i, j, \tilde{\cM}_{i, j})$ in Algorithm \ref{alg:paraOptAlignOnSubProblem}.
Here, we note that Algorithm \ref{alg:paraOptAlignOnSubProblem} is similar to Algorithm \ref{alg:paraOptAlign} which is presented in Sec 4.1.1.
The main difference is that we now solving parametric optimal alignment on smaller problem with $i, j$ and $\tilde{\cM}_{i, j}$.
By repeating the recursive procedure and storing
$\hat{\cM}_{i, j}$
in the $(i, j)^{\rm th}$ element of the table
from smaller $i$ and $j$ to larger $i$ and $j$,
we can end up with
$\tilde{\cM}_{n, m} \supseteq \hat{\cM}_{n, m}$.
By using parametric DTW,
the size of
$\tilde{\cM}_{n, m}$
can be much smaller than the size of all possible alignment matrices
$\cM_{n, m}$,
which makes
the computational cost of
${\tt paraOptAlignOnSubProblem}(n, k, \tilde{\cM}_{n, m})$
can be substantially decreased
compared to
${\tt paraOptAlign}(n, k, \cM_{n, m})$ in Algorithm \ref{alg:paraOptAlign} of Sec 4.1.1.
The parametric DTW method is presented in Algorithm~\ref{alg:paraDTW}.
\begin{algorithm}[t]
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{footnotesize}
\begin{algorithmic}[1]
\REQUIRE $i, j, \tilde{\cM}_{i, j} \quad \quad \quad \quad $
\vspace{2pt}
\STATE $t \lA 1$, $z_1 \lA -\infty$, \\
\vspace{2pt}
$\hat{M}_t \lA \hat{M}_{i, j} (z_t) = \argmin \limits_{M \in \cM_{i, j}} L \big (M, z_t \big )$
\WHILE { $z_t < +\infty$}
\vspace{2pt}
\STATE Find the next breakpoint $z_{t+1} > z_t$ and the next optimal alignment matrix $\hat{M}_{t+1}$ s.t.
\vspace{2pt}
\begin{center}
$L_{i, j}(\hat{M}_t, z_{t+1}) = L_{i, j}(\hat{M}_{t + 1}, z_{t+1}).$
\end{center}
\vspace{2pt}
\STATE $t \lA t+1$
\vspace{2pt}
\ENDWHILE
\vspace{2pt}
\STATE $\cT \lA t$
\vspace{2pt}
\ENSURE $\big \{\hat{M}_t \big \}_{t=1}^{\cT - 1}$, $\big \{z_t \big \}_{t=1}^{\cT}$
\end{algorithmic}
\end{footnotesize}
\caption{{\tt paraOptAlignOnSubProblem}$(i, j, \tilde{\cM}_{i, j})$}
\label{alg:paraOptAlignOnSubProblem}
\end{algorithm}
\begin{algorithm}[t]
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{footnotesize}
\begin{algorithmic}[1]
\REQUIRE $\bm X(z)$ and $\bm Y(z)$
\vspace{2pt}\\
\textbf{for} {$i=1$ to $n$}
\vspace{2pt} \\
~~ \textbf{for} {$j=1$ to $m$}
\vspace{2pt}
\STATE ~~~~~ $\tilde{\cM}_{i, j}$ $\lA$ Eq. \eq{eq:potential_optimal_set}
\vspace{2pt}
\STATE ~~~~~ $ \{\hat{M}_t \}_{t=1}^{\cT - 1}$, $ \{z_t \}_{t=1}^{\cT}$ $\lA$ {\tt paraOptAlignOnSubProblem}($i, j, \tilde{\cM}_{i, j}$) $\quad$ // Algorithm \ref{alg:paraOptAlignOnSubProblem}
\vspace{2pt}
\STATE ~~~~~ $\hat{\cM}_{i, j} \lA \{\hat{M}_t \}_{t=1}^{\cT - 1}$
\vspace{2pt}
\STATE ~~ \textbf{end for}
\vspace{2pt}
\STATE \textbf{end for}
\vspace{2pt}
\ENSURE $\hat{\cM}_{n, m}$
\end{algorithmic}
\end{footnotesize}
\caption{{\tt paraDTW}($\bm X(z), \bm Y(z)$)}
\label{alg:paraDTW}
\end{algorithm}
\subsection{Construction of $\cZ_2$ in \eq{eq:cZ_2}}
Now, we present the construction of $\cZ_2$ in the following Lemma.
\begin{lemma} \label{lemma:cZ_2}
The set $\cZ_2$ in \eq{eq:cZ_2} is an interval defined as:
\begin{align*}
\cZ_2 = \left \{ z \in \RR \mid
\max \limits_{j: \nu_j^{(2)} > 0} \frac{ - \nu_j^{(1)}}{\nu_j^{(2)}}
\leq z \leq
\min \limits_{j: \nu_j^{(2)} < 0} \frac{ - \nu_j^{(1)}}{\nu_j^{(2)}}
\right \},
\end{align*}
where $\bm \nu^{(1)} = \hat{\bm s}^{\rm obs} \circ \hat{M}_{\rm vec} \circ \Omega \bm a$
and
$\bm \nu^{(2)} = \hat{\bm s}^{\rm obs} \circ \hat{M}_{\rm vec} \circ \Omega \bm b$.
\end{lemma}
\begin{proof}
Let us first remind that
$
\hat{\bm s} = \cS(\bm X, \bm Y) =
{\rm sign}
\left (
\hat{M}_{\rm vec}
\circ
\left [ \Omega (\bm X ~ \bm Y)^\top \right ]
\right ),
$
which is defined in \eq{eq:test_statistic_first}.
Then, the set $\cZ_2$ can be re-written as follows:
\begin{align*}
\cZ_2
& = \{ z \in \RR \mid \cS(\bm a + \bm b z) = \hat{\bm s}^{\rm {obs}} \} \\
& = \left \{ z \in \RR \mid
{\rm sign}
\left (
\hat{M}_{\rm vec}
\circ
\Omega (\bm a + \bm b z)
\right )
= \hat{\bm s}^{\rm {obs}} \right \} \\
& = \left \{ z \in \RR \mid
\hat{\bm s}^{\rm {obs}}
\circ
\hat{M}_{\rm vec}
\circ
\Omega (\bm a + \bm b z)
\geq \bm 0 \right \}.
\end{align*}
By defining $\bm \nu^{(1)} = \hat{\bm s}^{\rm obs} \circ \hat{M}_{\rm vec} \circ \Omega \bm a$
and
$\bm \nu^{(2)} = \hat{\bm s}^{\rm obs} \circ \hat{M}_{\rm vec} \circ \Omega \bm b$, the result of Lemma \ref{lemma:cZ_2} is straightforward
by solving the above system of linear inequalities.
\end{proof}
After computing $\cZ_2$, we obtain $\cZ = \cZ_1 \cap \cZ_2$ and compute the selective $p$-value in \eq{eq:selective_p_parametrized} for conducting the inference.
The entire proposed SI-DTW method for computing selective $p$-values is summarized in Algorithm~\ref{alg:si_dtw}.
\begin{algorithm}[t]
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{footnotesize}
\begin{algorithmic}[1]
\REQUIRE $\bm X^{\rm obs}$ and $\bm Y^{\rm obs}$
\vspace{2pt}
\STATE $\hat{M}^{\rm obs} \lA \cA(\bm X^{\rm obs}, \bm Y^{\rm obs})$
\vspace{2pt}
\STATE $\bm X(z)$ and $\bm Y(z)$ $\lA$ Eq. \eq{eq:Z_z_Y_z}
\vspace{2pt}
\STATE $\hat{\cM}_{n, m}$ $\lA$ {\tt paraDTW}($\bm X(z)$, $\bm Y(z)$) $\quad$ // Algorithm \ref{alg:paraDTW}
\vspace{2pt}
\STATE $\cZ_1 \lA \mathop{\cup}_{\hat{M}_{n, m}(z) \in \hat{\cM}_{n, m}} \{z: \hat{M}_{n, m}(z) = \hat{M}^{\rm obs}\}$
\vspace{2pt}
\STATE $\cZ_2 \lA$ Lemma \ref{lemma:cZ_2}
\vspace{2pt}
\STATE $\cZ = \cZ_1 \cap \cZ_2$
\vspace{2pt}
\STATE $p_{\rm selective}$ $\lA$ Eq. \eq{eq:selective_p_parametrized}
\vspace{2pt}
\ENSURE $p_{\rm selective}$
\end{algorithmic}
\end{footnotesize}
\caption{Proposed SI Method (SI-DTW)}
\label{alg:si_dtw}
\end{algorithm}
\section{Experiment} \label{sec:experiment}
In this section, we demonstrate the performance of the proposed method.
\subsection{Methods for Comparison}
We compared our SI-DTW method with the following approaches:
\begin{itemize}
\item SI-DTW-oc: this is our first idea of introducing conditional SI for time-series similarity using the DTW by additionally conditioning on all the operations of the DTW algorithm itself to make the problem tractable.
%
Then, since the selection event of SI-DTW-oc is simply represented as a single polytope in the data space, we can apply the method in the seminal conditional SI paper \cite{lee2016exact} to compute the over-conditioning $p$-value.
%
The details are shown in Appendix \ref{app:si_dtw_oc}.
%
However, such an over-conditioning leads to a loss of statistical power \citep{lee2016exact, fithian2014optimal}.
Later, this drawback was removed by the SI-DTW method in this paper.
\item Data splitting (DS): an approach that divides the dataset in half based on even and odd indices, and uses one for computing the DTW distance and the other for inference.
\item Permutation: the procedure is described as follows ($\bm X$ and $\bm Y$ are required to have the same length, i.e., $n = m$):
\begin{itemize}
\item Compute the observed test statistic $T^{\rm obs}$ based on $\bm X^{\rm obs}$ and $\bm Y^{\rm obs}$
\item For $1 \lA b$ to $B$ ($B$ is the number of permutations which is given by user)
\begin{itemize}
\item Construct $\bm X^{(b)}$ and $\bm Y^{(b)}$ where $(x_i^{(b)}, y_i^{(b)}) \lA {\rm permute}(x_i^{\rm obs}, y_i^{\rm obs})$
\item Compute $T^{(b)}$ based on $\bm X^{(b)}$ and $\bm Y^{(b)}$
\end{itemize}
\item Compute the $p$-value
$
p_{\rm permutation} = \frac{1}{B} \sum_{b = 1}^B \bm 1 \left \{ T^{\rm obs} \leq T^{(b)} \right \},
$
where $\bm 1\{ \cdot \} $ is the indicator function.
\end{itemize}
\end{itemize}
\subsection{Experimental Setup}
We considered the following covariance matrices:
\begin{itemize}
\item Independence: $\Sigma_{\bm X} = I_n$, $\Sigma_{\bm Y} = I_m$.
\item Correlation: $\Sigma_{\bm X} = \left [0.5^{{\rm abs}(i - i^\prime)} \right ]_{ii^\prime} \in \RR^{n \times n}$, $\Sigma_{\bm Y} =\left [0.5^{{\rm abs}(j - j^\prime)} \right ]_{jj^\prime} \in \RR^{m \times m}$.
\end{itemize}
We generated $\bm X$ and $\bm Y$ with $\bm \mu_{\bm X} = \bm 0_n$, $\bm \mu_{\bm Y} = \bm 0_m + \Delta$ (element-wise addition), $\bm \veps_{\bm X} \sim \NN (\bm 0_n, \Sigma_{\bm X})$, and $\bm \veps_{\bm Y} \sim \NN (\bm 0_m, \Sigma_{\bm Y})$.
Regarding the False Positive Rate (FPR) experiments, we set $\Delta = 0$, and ran 120 trials for each $n = m \in \{ 5, 10, 15, 20\} $.
In regard to the True Positive Rate (TPR) experiments, we set $n = m = 10$, and ran 120 trials for each $\Delta \in \{ 1, 2, 3, 4, 5\} $.
The experiments are repeated 10 times.
Respecting the confidence interval experiments, we set $n = m = 10$, and ran 120 trials for each $\Delta \in \{2, 3, 4, 5\} $.
Regarding the computational time experiments, we set $\Delta = 2$ and ran 10 trials for each $n = m \in \{ 5, 10, 15, 20\} $.
The setup of the robustness experiments were similar to the FPR experiments and we considered the following cases:
\begin{itemize}
\item Non-normal noise: the noises $\bm \veps_{\bm X}$ and $\bm \veps_{\bm Y}$ following Laplace distribution, skew normal distribution (skewness coefficient: 10), and $t_{20}$ distribution.
\item Unknown variance: the variances of the noises were estimated from the data.
\end{itemize}
We set the significance level $\alpha = 0.05$ (we additionally set $\alpha = 0.1$ for the robustness experiments).
\subsection{Numerical Result}
\begin{figure}[!t]
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{fpr_comparison_independence.pdf}
\caption{Independence}
\end{subfigure}
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{fpr_comparison_correlation.pdf}
\caption{Correlation}
\end{subfigure}
\caption{False Positive Rate (FPR) comparison.}
\label{fig:fpr_comparison}
\end{figure}
\begin{figure}[!t]
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{tpr_comparison_independence.pdf}
\caption{Independence}
\end{subfigure}
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{tpr_comparison_correlation.pdf}
\caption{Correlation}
\end{subfigure}
\caption{True Positive Rate (TPR) comparison.}
\label{fig:tpr_comparison}
\end{figure}
\begin{figure}[!t]
\begin{subfigure}{.245\textwidth}
\centering
\includegraphics[width=\linewidth]{ci_length_delta_2.pdf}
\caption{$\Delta = 2$}
\end{subfigure}
\begin{subfigure}{.245\textwidth}
\centering
\includegraphics[width=\linewidth]{ci_length_delta_3.pdf}
\caption{$\Delta = 3$}
\end{subfigure}
\begin{subfigure}{.245\textwidth}
\centering
\includegraphics[width=\linewidth]{ci_length_delta_4.pdf}
\caption{$\Delta = 4$}
\end{subfigure}
\begin{subfigure}{.245\textwidth}
\centering
\includegraphics[width=\linewidth]{ci_length_delta_5.pdf}
\caption{$\Delta = 5$}
\end{subfigure}
\caption{Confidence interval (CI) length comparison.}
\label{fig:ci_length_comparison}
\end{figure}
\begin{figure}[!t]
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{fpr_laplace.pdf}
\caption{Laplace distribution}
\end{subfigure}
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{fpr_skew_normal.pdf}
\caption{Skew normal distribution}
\end{subfigure}
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{fpr_t_20.pdf}
\caption{$t_{20}$ distribution}
\end{subfigure}
\begin{subfigure}{.48\textwidth}
\centering
\includegraphics[width=.9\linewidth]{fpr_estimated_sigma.pdf}
\caption{Estimated variance}
\end{subfigure}
\caption{ The robustness of the proposed method in terms of the FPR control.}
\label{fig:robustness}
\end{figure}
The results of the FPR control are shown in Fig. \ref{fig:fpr_comparison}.
The proposed methods (SI-DTW and SI-DTW-oc) successfully control the FPR in both cases of independence and correlation whereas the permutation and DS \emph{could not}.
Because the permutation and DS failed to control the FPR, we no longer considered the TPR.
The result of TPR experiments are shown in Fig. \ref{fig:tpr_comparison}.
The SI-DTW has higher TPR than the SI-DTW-oc in all the cases.
The TPR results are consistent with the confidence interval (CI) results in Fig. \ref{fig:ci_length_comparison}, i.e.,
The SI-DTW has higher TPR than SI-DTW-oc which indicates it has shorter CI.
Additionally, we demonstrate the robustness of the proposed method in terms of the FPR control.
The results are shown in Fig. \ref{fig:robustness}.
Our method still maintains good performance on FPR control.
\subsection{Real-data Examples}
\begin{figure}[!t]
\begin{subfigure}{.323\textwidth}
\centering
\includegraphics[width=\linewidth]{real_data_italy.pdf}
\caption{Italy}
\end{subfigure}
\begin{subfigure}{.323\textwidth}
\centering
\includegraphics[width=\linewidth]{real_data_melbourne.pdf}
\caption{Melbourne}
\end{subfigure}
\begin{subfigure}{.323\textwidth}
\centering
\includegraphics[width=\linewidth]{real_data_smooth_subspace.pdf}
\caption{Smooth Subspace}
\end{subfigure}
\caption{Boxplots of $p$-values.}
\label{fig:boxplot_p_value}
\end{figure}
We evaluate the proposed SI-DTW on three datasets that are available at UCR Time Series Classification Repository:
Italy Power Demand (Class $\tt{C1}$: days from Oct to March, Class $\tt{C2}$: days from April to September),
Melbourne Pedestrian (Class $\tt{C1}$: Bourke Street Mall, Class $\tt{C2}$: Southern Cross Station)
and Smooth Subspace (Class $\tt{C1}$: smooth subspace spanning from time stamp 1 to 5, Class $\tt{C2}$: smooth subspace spanning from time stamp 11 to 15).
The experiments were conducted with the following setting:
\begin{itemize}
\item Given a time-series dataset with two classes $\tt{C1}$ and $\tt{C2}$
\item \textbf{for} $i \lA 1$ to $120$ \textbf{do}
\begin{itemize}
\item We randomly chose one time-series from $\tt{C1}$ and one time-series from $\tt{C2}$
\item Compute $p$-values of the SI-DTW and SI-DTW-oc
\end{itemize}
\item Showing boxplot of $p$-values obtained from each method
\end{itemize}
The results are shown in Fig \ref{fig:boxplot_p_value}. In all the cases, the selective $p$-value of the SI-DTW tended to be smaller than that of SI-DTW-oc, which indicates that the SI-DTW had higher TPR than SI-DTW-oc.
\section{Conclusion} \label{sec:conclusion}
We present an exact (non-asymptotic) inference method for the DTW distance between two time-series obtained by DTW.
We first introduce the characterization of the exact sampling distribution of the test statistic by conditioning on the selection event of selecting the optimal alignment, which is inspired by the concept of conditional SI.
Then, we introduce the valid selective $p$-value for conducting the exact statistical inference.
After that, we introduce new efficient method to address the computational bottleneck of computing the proposed selective $p$-value.
Finally, we conduct the experiments on both synthetic and real-world datasets to evaluate the performance of our method.
We believe this study is an important contribution toward reliable Machine Learning (ML), which is one of the most critical issues in the ML community.
|
{'timestamp': '2022-02-15T02:40:45', 'yymm': '2202', 'arxiv_id': '2202.06593', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06593'}
|
arxiv
|
\section{Introduction}
\begin{figure}[b]
\centering
\includegraphics[width=8cm]{Figures/AgentPattern.png}
\caption{
Patterns evolved by CA agents.
}
\label{AgentPattern}
\end{figure}
This paper is an extension of the presentation ``Forming Point Patterns by a Probabilistic Cellular Automata Rule''
given at Summer Solstice Conference on Complex Systems in Dresden, Germany, July 15 -- 17, 2019 (see Appendix).
The introduced novel approach is methodical and will be explained here in more detail.
\COMMENT{
\bibitem{2014-Hoffmann-ACRI-Pattern}
Hoffmann, R.
(2014).
How Agents Can Form a Specific Pattern.
ACRI Conf. 2014, LNCS 8751, pp. 660-669
\bibitem{2016-Hoffmann-Polonia-PathPattern}
Hoffmann, R.
(2016).
Cellular Automata Agents form Path Patterns Effectively.
Acta Physica Polonica B Proceedings Supplement, Vol. 9 (2016) No.1
\bibitem{2016-Hoffmann-D-ACRI-LinePattern}
Hoffmann, R. and D{\'e}s{\'e}rable, D.
(2016).
Line Patterns Formed by Cellular Automata Agents.
ACRI Conf. 2016, LNCS 9863, pp. 424-434
\bibitem{2017-Hoffmann-D-PACT-MaxDomino-Agents}
Hoffmann, R. and D{\'e}s{\'e}rable, D.
(2017).
Generating Maximal Domino Patterns by Cellular Automata Agents.
Lecture Notes in Computer Science, PaCT Conference
}
In previous work
\cite{
2014-Hoffmann-ACRI-Pattern,
2016-Hoffmann-Polonia-PathPattern,
2016-Hoffmann-D-ACRI-LinePattern,
2017-Hoffmann-D-PACT-MaxDomino-Agents}
different patterns were generated by moving Cellular Automata agents.
Such pattern are depicted in Fig. \ref{AgentPattern}.
The behavior of an agent was defined by an embedded finite state machine (FSM).
The agent's FSM was trained offline by a genetic algorithm (GA) to form a specific patterns.
The patterns were locally defined by small pattern templates.
The number of matching templates was used to define the fitness function for the GA.
A population of agents with different FSMs was optimized by testing their performance through simulation:
Agents were favored that produced global patterns best by counting the local pattern matches .
The effort to train such agents is quite high, especially to find agents that work on any field size.
In order to avoid such a computational effort, a novel approach to construct directly the required CA rule
was proposed that is described here.
It has the potential to be applied to more complex pattern formations.
Whereas the local matching templates are hidden in the FSMs of the moving agents in the former work,
now the local matching templates are directly used in the definition of a classical uniform CA rule.
This new approach was successfully applied
to place a maximal number of dominoes in a 2D field
\cite{2019-pact-domino},
to find a sensor point pattern (to cover an area by active sensors)
\cite{2020-HoffmannSeredynski-SensorPoint},
to place a maximal number of dominoes in the diamond
\cite{Hoffmann-2021},
and to cover a space with a minimal number of dominoes
\cite{Hoffmann-2021-MinimalDominoPact}.
The objective is to find a point pattern with a maximal number of points by a CA rule.
The cell's state is $\in\{0,1\}$ where `1' represents a point and `0' some material / space between points.
Points are not allowed to touch each other, they have to be separated by 0-cells, and every
0-cell finds at least one point in its Moore-neighborhood.
To solve this problem we consider it as a tiling problem with overlapping \textit{point tiles}.
A point tile is a $3\times3$ pixel array where the center is `1' and the other pixels are `0'.
The task is to cover the space with overlapping point tiles without gaps.
Our problem is one of the diverse covering problems
\cite{Snyder2011}
and it is related to the NP-complete \textit{vertex cover problem} introduced by Hakimi \cite{Hakimi1965} in 1965.
A vertex cover is a set of nodes in a graph such that every edge of the graph has at least one end point in the set. A minimum cover is a vertex cover which has the smallest number of nodes for a given graph.
Hakimi proposed a solution method based on Boolean functions,
later integer linear programming \cite{Gomesa2006}, branch-and-bound, genetic algorithm, and local search \cite{Richter2007} were used, among others.
Other related problems are
the \textit{Location Set Covering Problem}
\cite{Church1976}
and the
\textit{Central Facilities Location Problem}
\cite{Mehrez2016}.
These problems aim to find the locations for \emph{P} facilities that can be reached within a weighted distance from demand points, minimizing the number of \emph{P}, or minimizing the average distance, or maximizing the coverage.
For covering problems there are a lot of applications, in economy, urban planning, engineering, etc.
\begin{figure}[tb]
\centering
\includegraphics[width=0.32\textwidth]{Figures/Antalya2200.jpg}
\includegraphics[width=0.32\textwidth]{Figures/fish2200.jpg}
\includegraphics[width=0.32\textwidth]{Figures/bh2022-2000.jpg}
\caption{
Everyday's point patterns.
}
\label{Antalya2200}
\end{figure}
Sample applications for maximal point patterns are:
constructing a sieve with a maximum number of holes keeping a high stiffness,
constructing an effective brush,
dense packing of square parcels, or
attracting particles minimizing their total energy.
We can observe point patterns everyday, like the ones depicted in Fig. \ref{Antalya2200}
\begin{figure}[tb]
\centering
\includegraphics[width=7cm]{Figures/4-Automaton.png}
\caption{
Each cell is an Automaton, connected to its neighbors.
C: Center Cell to be modified. N, E, S, W: neighboring cells
}
\label{4-Automaton}
\end{figure}
\begin{figure}[tb]
\centering
\includegraphics[width=7cm]{Figures/3-GlobalPattern-LocalRule.png}
\caption{
A local rule is applied at every site $(x, y)$ of the array (field of cells). The rule is simple but it can induce a complex global pattern.
}
\label{3-GlobalPattern-LocalRule}
\end{figure}
Cellular Automata (CA) is a well known modeling and decentralized computing paradigm
\cite{WolframNewKind}.
A CA is a field / array of cells placed in a grid with local connections
(Fig. \ref{4-Automaton}).
The next cell's state is computed by a local rule $f$ taking the neighboring states into account:
$C\leftarrow f(C,N, E,S,W)$.
Every cell applies the same simple local rule which may result in a complex global pattern / configuration change
(Fig. \ref{3-GlobalPattern-LocalRule}).
\section{The Problem and Solutions for \textit{n $\times$ n} Fields}
\subsection{The Problem}
Given is a field of $n \times n$ cells with cyclic boundary conditions.
The cell's state is $s \in \{0,1\}$ where 0 will be represented by green or white and 1 by blue or black.
Initially we assume a random configuration.
The objective is to find a CA rule that successfully forms a \textit{Point Pattern}.
A point pattern consists of \textit{point} cells ($s=1$) and \textit{zero} cells ($s=0$).
There are two constraints that have to be fulfilled for any cell at site $(x,y)$ of the field.
\begin{enumerate}
\item
The 8 cells surrounding a point at $(x,y)$ in the Moore-neighborhood have to be zero.
So the first constraint is:
$
s(x,y)=1 \wedge
s(x,y\pm1)=0 \wedge
s(x\pm1,y)=0 \wedge
s(x\pm1,y\pm1)=0~.
$
\item
At least one of the 8 cells surrounding a zero cell at $(x,y)$ in the Moore-neighborhood has to be a point.
The second constraint is:
$s(x,y)=0 \wedge \exists s(x',y')=1$
where $(x',y') \in \{ (x,y\pm1),(x\pm1,y),(x\pm1,y\pm1) \}$~.
\end{enumerate}
The two conditions define allowed positions between zeroes and ones.
Simply speaking, points should be near to each other but are not allowed to touch.
We call patterns that fulfill these constraints \textit{valid}.
We aim at valid patterns with a \textit{maximal} number of possible points $p_{max}$,
therefore we call our problem also the \textit{max point pattern problem}:
\vspace{10pt}
$p \rightarrow p_{max}$ where $p$ is the number of points in the pattern.
\vspace{10pt}
\noindent
In addition we favorite a fast CA rule that rapidly produces a valid point pattern.
Note that another problem would be to aim at patterns with a \textit{minimal} number of points,
the \textit{min point pattern problem}.
This problem needs more discussion and will not be treated here further.
\subsection{Optimal Solutions for \textit{n} Even}
\begin{figure}[htb]
\centering
\includegraphics[width=7cm]{Figures/SolutionsEven.png}
\caption{
Optimal patterns for even $n=2,4,6,8$.
}
\label{SolutionsEven}
\end{figure}
First we look at the possible optimal solutions for $n \times n$ fields, where $n$ is even
(Fig. \ref{SolutionsEven}).
We consider solutions as equivalent if they are equal under cyclic shift, rotation and mirroring.
Let $w$ denote the number of different pattern solutions.
For $n=2$ there is only one solution with one point.
For $n=4$ we find $w=2$ solutions with $p=4$ points.
For $n=6$ we have 2 solutions with 9 points.
For $n=8$ we get 4 solutions with 16 points.
In general the \textit{maximal} number of points is $p_{max}=n^2/4$
because the square cell field can be tiled into small non-overlapping blocks / tiles of size $2 \times 2$, each with one black cell / point.
\section{Rule Design Issues}
\subsection{Updating Scheme}
We may use
\textit{synchronous} or \textit{asynchronous} updating
and
a \textit{deterministic} or a \textit{probabilistic} rule.
This makes four options:
\begin{enumerate}
\item
synchronous updating \& deterministic rule
\item
synchronous updating \& probabilistic rule
\item
asynchronous updating \& deterministic rule
\item
asynchronous updating \& probabilistic rule
\end{enumerate}
Our goal is to find a rule that produces valid point patterns and preferably converges to an optimal solution (\textit{max pattern}),
or finds several or even all optimal solutions during its evolution in time.
\textit{Option 1:}
Until now it was not possible to design such a rule.
The problem is that the evolving pattern may get stuck in sub-optimal local fixed or oscillating structures such as we know from the \emph{Game of Life}.
It remains an open questions if it is possible to find such a rule.
\textit{\textit{Options 2 -- 4:}}
These options are related because the computation of a new configuration is stochastic. It seems that they can be transformed into each other to a certain extent.
We decided to use option 4 (\textit{asynchronous updating \& probabilistic rule}).
With asynchronous updating we don't need buffered storage elements and a central clock for synchronization which is closer to the modeling of natural processes.
Basically asynchronous updating can be considered as a sequential process where only one cell of the array is updated at a certain (micro) time-step.
Nevertheless it may be possible to update cells of a subset in parallel if there is no influence between outputs and inputs within the subset. An example is to update odd and even cells alternately.
We want to use the following sequential updating scheme:
\begin{itemize}
\item
A cell is selected by a certain \textit{Selection Strategy}.
\item
The new cell's state-value is computed by the rule and immediately assigned to the cell's state memory
during each micro time-step
$\tau \rightarrow \tau+1$,
i.e. $s^{\tau+1} \leftarrow Rule(s, neighbors' states)^\tau$.
\item
Each time-step $t \rightarrow t +1$ consists of $N = n^2$ micro time-steps.
This means that $n^2$ updates are performed during one time-step.
\item
Configurations are considered / observed (logged, sampled) at time-steps.
\end{itemize}
There are several possible selection strategies:
\begin{enumerate}
\item
\textbf{Pure Random},
also called \textit{random select, pure asynchronous, fully asynchronous, independent random ordering}.
For each new micro time-step, a cell is selected uniformly at random and then immediately updated.
Thereby a cell may not be updated during a time-step, or several times.
\item
\textbf{Random Sequence}, also called \textit{random new sweep}.
The update sequence is given by a random permutation of the cell indexes (defining the order), changed for every new time-step.
Thereby each cell is updated exactly once during one time-step.
\item
\textbf{Deterministic Sequence.}
The permutation of cell indexes is fixed.
Examples: strict index order, first select odd cells then even cells, order in which the distance between cells is large or small on average.
\end{enumerate}
Experiments with the later defined CA rules showed that any of these selection strategies is working well with a relatively small influence on the performance.
Therefore an update strategy can be chosen that is easy to implement or which can work better in parallel. A deeper investigation is necessary to confirm this conclusion.
\begin{figure}[htb]
\centering
\includegraphics[width=9cm]{Figures/UpdateEvents.png}
\caption{
The probability how often a cell is updated during a time-step with $N$
micro time-steps. $N = 16 \times 16$.
}
\label{UpdateEvents}
\end{figure}
\begin{figure}[htb]
\centering
\includegraphics[width=9cm]{Figures/MicroSteps.png}
\caption{
Example of an evolution of a $4 \times 4$ 4-point pattern. The configurations at each micro time-step are shown.
A time-step $t \rightarrow t +1$ consists of $n \times n$ micro time-steps $\tau \rightarrow \tau +1$ .
The update strategy was pure random.
Points are colored in blue, state = 1.
Colors for state = 0 and for cover levels:
0 (white), 1 (yellow), 2 (light green), 3 (green), 4 (dark green).
}
\label{MicroSteps}
\end{figure}
Let us consider the strategy \textit{Pure Random}.
The probability $P(k)$ of $k$ update events for a specific cell during altogether $N$ events ($n^2$ micro-steps during one time-step) is given by the
binomial distribution
\vspace{10pt}
$P(k)=(1-q)^{N-k}q^k \binom{N}{k}$ where $q=1/N$.
\vspace{10pt}
Fig. \ref{UpdateEvents} depicts the probability how often a cell is updated during a time-step, for $N = 16 \times 16$.
For larger fields with $N>16$ cells the graph changes only marginally.
Notice that the probability of updating a cell never or once is $P(0)= P(1)=37\%$, and to update twice is $P(2)=18\%$.
Fig. \ref{MicroSteps} shows a sample evolution of a $4 \times 4$ 4-point pattern, micro step by micro step using
pure random updating.
\subsection{Tiling Problem}
\begin{figure}[htb]
\centering
\includegraphics[width=9cm]{Figures/Tile.png}
\caption{
(a) The used \textit{point tile} with its hull and kernel.
(b) A cyclic $9 \times 9$ field can be tiled by 9 tiles without overlapping, a min pattern.
(c) A cyclic $8 \times 8$ field can be tiled by 16 tiles with maximal overlapping, a max pattern.
Overlapping tile pixels are colored in green (cover level = 2) or dark green (cover level = 4).
}
\label{Tile}
\end{figure}
\begin{figure}[htb]
\centering
\includegraphics[width=9cm]{Figures/CoverLevel.png}
\caption{
Tiles may overlap. The numbers give the cover level $v$, the number of overlapping tiles / pixels.
}
\label{CoverLevel}
\end{figure}
The basic idea is to consider the problem as a tiling problem.
Given is a certain tile, in our case we call it \textit{point tile} (Fig. \ref{Tile}a).
The point tile consists of 9 elements, we call them ``pixels'' and not ``cells''
because we reserve the word ``cell'' for cellular automata cells.
The tile is partitioned into a hull and a kernel.
The hull consists of 9 pixels with the value 0, and the kernel is the center pixel with value 1.
Now we want to cover a given cell field by (potentially) overlapping tiles and thereby find a solution of our problem.
Fig. \ref{Tile}b shows how a $9 \times 9$ field (cyclic boundary condition) can be covered with the minimum of 9 tiles without overlapping.
Fig. \ref{Tile}c shows how a cyclic $8 \times 8$ field can be covered with the maximum of 16 tiles with high overlapping.
In order to find a valid solution we have to allow that the tiles may overlap (Fig. \ref{CoverLevel}).
Gaps (uncovered cells) between tiles are not allowed.
The cover level $v$ gives the number of tiles / tile pixels that overlap at a certain site of the cell field.
The kernel pixel is not allowed to overlap with any other pixel from another tile.
So the cover level for the kernel is fixed to 1.
Only hull pixels may overlap with other hull pixels, up to 4.
By covering each cell by overlapping tile pixels we obtain a \textit{valid} pattern fulfilling the above stated constraints.
We call a pattern \textit{max/min pattern} if the \textit{number of used tiles} (equals the \textit{number of points} $p$) is maximal resp. minimal.
In this paper we focus on the problem how to produce max patterns, the \textit{max point pattern problem}.
Manually a valid pattern can be found by moving tiles around in a given grid field and asserting the constraints.
Also a computer program could find valid patterns by moving tiles around, checking the constraints and
maximizing or minimizing the number of tiles.
But here we want to solve the problem in another way by using so-called \textit{templates} which are shifted tiles
or truncations of them.
\subsection{Templates}
\begin{figure}[htb]
\centering
\includegraphics[width=9cm]{Figures/Templates.png}
\caption{
The 9 templates derived from the point tile. For each pixel (encircled in red) a template is defined. The red marked pixel is called \textit{reference pixel}. The reference pixel serves as the center of a template. The value of the reference pixel is \textit{ref}($A_k$).
}
\label{Templates}
\end{figure}
Now we want to design CA rules.
We define ``templates'', small matching patterns that will be used in the later described CA rules.
They a systematically derived from the point tile
(Fig. \ref{Templates}).
Let the point tile be stored in a $3\times3$ pixel array $[G(i,j) ]$
with $i,j \in \{-1,0,+1\}$ and $G(i,j)\in \{0,1\}$.
We reserve template arrays $[A_k(i,j)]$ $(k=1 ~...~ 9)$,
with $i,j \in \{-2,0,+2\}$ and $A_k(i,j)\in \{\#,0,1\}$.
The pixel value '\#' is used for unfilled ``don't care pixels''.
The size of the array has to be large enough to hold all ``real'' tile pixels $G(i,j) \in \{0,1\}$.
For each pixel $G(i,j)$
a template $[A_k(i,j) ]$ is derived by shifting $G$
in a way that each of the nine tile pixels $G(i,j)$ ends up as the center pixel of the \textit{k-th} template:
$(i,j)_{\textit{of}~G}\rightarrow (0,0)_{\textit{of}~A_k}$.
The \textit{k-th} pixel $(i,j)$ of $G$ is called \textit{reference pixel}
because it defines the center $(0,0)$ of one of the \textit{k} templates $A_k$.
Its value $G(i,j)$ is called \textit{reference value} $\textit{ref}(A_k)=A_k(0,0)$.
For a more precise definition we use the shift operator
$\textit{shift}_{(\Delta x, \Delta y)}(E)$
that
shifts the matrix $E$ in \emph{x}-direction by $\Delta x$
and in \emph{y}-direction (here defined downwards) by $\Delta y$.
The 9 templates are generated by iterating over all tile pixels $(i,j)$:
\vspace{8pt}
\begin{tabular}{lll}
$A_1 \leftarrow \textit{shift}_{(0,0)}(E)$
&
$A_2 \leftarrow \textit{shift}_{(1, 1)}(E)$
&
$A_3 \leftarrow \textit{shift}_{(0, 1)}(E)$\\
$A_4 \leftarrow \textit{shift}_{(-1, 1)}(E)$
&
$A_5 \leftarrow \textit{shift}_{(-1, 0)}(E) $
&
$A_6 \leftarrow \textit{shift}_{(-1, -1)}(E)$\\
$A_7 \leftarrow \textit{shift}_{(0, -1)}(E)$
&
$A_8 \leftarrow \textit{shift}_{(1, -1)}(E) $
&
$A_9 \leftarrow \textit{shift}_{(1, 0)}(E)$
\end{tabular}
\vspace{8pt}
The reference values are `1' for $A_1$, and `0' for $A_2, A_3,\ldots, A_9$.
We have to be aware that the array size for storing templates $A_k$ may be larger than the array size of the point tile because of the shift operation.
An array of size $(3+\textit{Xshift}) \times (3+\textit{Yshift}) $ is sufficient large,
where \textit{Xshift} / \textit{Yshift} is the maximal needed shift count in $x$- / $y$-direction,
i.e. $|i|_{max}$ resp. $|j|_{max}$.
Thus we need a $5 \times 5$ array to store any of the point templates.
The don't care symbol '\#' is used for pixels that are not relevant in order to complete the whole template array.
For example, the templates $A_1, A_2, A_3$ can be encoded and stored as follows
\vspace{9pt}
\renewcommand{\baselinestretch}{.6}\normalsize
\begin{minipage}[h]{.9\textwidth}
\begin{verbatim}
##### ##### #####
#000# ##### #####
A1 = #010# A2 = ##000 A3 = #000#
#000# ##010 #010#
##### ##000 #000# .
\end{verbatim}
\end{minipage}
\renewcommand{\baselinestretch}{1}\normalsize
\vspace{9pt}
By rotation, the templates $A_4, A_6, A_8$ can be generated from $A_2$.
Similarly $A_5, A_7, A_9$ can be generated from $A_3$.
For our later designed CA rule we use also so-called ``\textit{neighborhood templates}''.
We yield the neighborhood template $A_i^*$ from the template $A_i$ by setting the center to '\#'.
Note that this pixel is the reference pixel.
\vspace{9pt}
\renewcommand{\baselinestretch}{.6}\normalsize
\begin{minipage}[h]{.9\textwidth}
\begin{verbatim}
##### ##### #####
#000# ##### #####
A1* = #0#0# A2* = ###00 A3* = #0#0#
#000# ##010 #010#
##### ##000 #000#
\end{verbatim}
\end{minipage}
\renewcommand{\baselinestretch}{1}\normalsize
\vspace{9pt}
\begin{figure}[htb]
\centering
\includegraphics[width=8cm]{Figures/MatchingTemplates.png}
\caption{
For each cell of a valid point pattern exists at least one matching template (a hit).
}
\label{MatchingTemplates}
\end{figure}
Note that for each cell of a valid point pattern there exists at least one matching template, a hit,
see example in Fig. \ref{MatchingTemplates}.
\subsection{Reduced Templates}
It turned out by simulations of the CA rules (following Sect. \ref{RuleDesign})
that the template size of $5 \times 5$ can be reduced to $3 \times 3$.
\vspace{9pt}
\renewcommand{\baselinestretch}{.6}\normalsize
\begin{minipage}[h]{.9\textwidth}
\begin{verbatim}
000 ### ###
A1 = 010 A2 = #00 A3 = 000
000 #01 010
\end{verbatim}
\end{minipage}
\renewcommand{\baselinestretch}{1}\normalsize
\vspace{9pt}
It is even possible to further simplify $A_2$ and $A_3$ (as well as their symmetrical ones).
The reason is that it is sufficient to test for neighboring zeroes where there is a 1 (constraint 1)
and to test for at least one 1-neighbor where there is a 0 (constraint 2).
\renewcommand{\baselinestretch}{.6}\normalsize
\begin{table}[h!]
\begin{verbatim}
### ### ### ###
A2 = #00 -> #0# A3 = 000 -> #0#
#01 ##1 010 #1#
\end{verbatim}
\end{table}
\renewcommand{\baselinestretch}{1}\normalsize
\vspace{-9pt}
\section{The Designed Rules
\label{RuleDesign}
We present now four designed rules that can be applied one after the other in the same time slot.
\begin{itemize}
\item
\textbf{Rule A.}
The current cell state is adjusted to the reference value if a neighborhood template matches.
\item
\textbf{Rule B.}
Noise is injected if there is no hit (match). This rule ensures that no cells remain uncovered.
\item
\textbf{Rule C1.}
In order to maximize the number of points, noise is injected if there is one hit. This rule drives
the evolution to higher cover levels
\item
\textbf{Rule C2.}
This rule drives the evolution to stable max patterns if $n$ is even.
\end{itemize}
\subsection{Basic Rule A: Adjust}
\begin{figure}[htb]
\centering
\includegraphics[width=9cm]{Figures/Adjust.png}
\caption{
Example for Rule A. A CA cell is adjusted if a neighborhood template match.
Otherwise the cell's state remains unchanged.
}
\label{Adjust}
\end{figure}
The templates can be used to test a pattern for validity.
In fact, the templates are defined in such a way that
for each cell $(x,y)$ of a valid pattern there exists at least one matching template
(Fig. \ref{MatchingTemplates}).
The basic idea is to adjust templates, make them complete.
When the tested cells in the neighborhood of cell $(x,y)$ are equal to the template except the center (the reference pixel of the template),
then cell $(x,y)$ is adjusted to the correct value (the reference value).
So we may use the neighborhood templates $A_k^*$ for testing against the corresponding CA neighbors and adjust anyway.
This is performed by the following Rule A (case (a)).
Otherwise the new state is equal to the old state (case (b)).
\[
s'(x,y) =
\left
\{
\begin{array}{lll}
\textit{ref}(A_i) &\textbf{if} ~\exists A_i^*~\textit{that matches with CA neighbors at $(x,y)$} &(a) \\
s(x,y) &\textbf{otherwise} \textit{~no change} &(b) \\
\end{array}
\right. .
\]
This rule evolves very fast stable point patterns.
During the process of the CA rule application the pattern may not be valid or only partially.
In partially valid pattern some tiles are detected through template testing, but there
exist some noisy or uncovered cells.
The number of template matches are called ``hits''.
\begin{figure}[htb]
\centering
\includegraphics[width=9cm]{Figures/SimulationRuleA.png}
\caption{
The evolution of a $3 \times 3$ field under different initial conditions and strict index update order.
}
\label{SimulationRuleA}
\end{figure}
Fig. \ref{SimulationRuleA}
shows simple simulations of a $3 \times 3$ field with strict index update order,
with different initial states: (a) all zero, (b) all one, and (c) random.
\begin{itemize}
\item[(a)]
We observe that a point appears already at micro time-step $\tau=1$.
This happens because already for the first cell the neighborhood template $A_1^*$ is fulfilled, `0's are detected in the whole
Moore-neighborhood (taking cyclic boundary condition into account).
The pattern remains stable, because all other cells match with a template (a `1' is detected in the neighborhood).
\item[(b)]
8 micro time-steps are needed to evolve a stable point pattern (with one point).
At $\tau=0$ the first cell is checked for matching templates.
Since all 8 reduced neighborhood templates $A_{i\geq 1}^*$ match (there exist `1'-neighbors),
the active cells are set to `0', step by step in strict index order until only one `1' (the point) is left over.
\item[(c)]
7 micro time-steps are needed to evolve a stable point pattern, starting with a random configuration.
The number of time-steps depends on the actual initial configuration.
Averaging over 100 random initial configurations we get
$\tau_{average}= 6.5 (2 ~min - 8 ~max)$.
\end{itemize}
\begin{table}[htb]
\caption{
Rule A applied on a field of size $3 \times 3$.
Micro time-steps needed for different update orders, starting with an all one configuration.
All 100 evolved patterns are stable and contain 1 point.}
\begin{center}
\begin{tabular}{ |c | c | c | c | c |}
\hline
$3\times 3$ \textit{init all one} & $\tau_{average}$ & $\tau_{min} - \tau_{max}$ & \textit{time-steps}= \\
& & & $\tau_{average}/9$ \\
\hline
strict index order & 8 & 8 - 8 & 0.89 \\% &100\\
\hline
random sequence & 17.03 & 10 - 32 & 1.89 \\% &100\\
\hline
pure random & 19.90 & 12 - 27 & 2.21 \\% &100\\
\hline
\end{tabular}
\end{center}
\label{TableRuleA3x3}
\end{table}
\begin{table}[htb]
\caption{
Rule A applied on a field of size $4 \times 4$.
Micro time-steps needed for different update orders, starting with different initial configurations.
All 100 evolved patterns are stable and contain 4 points.}
\begin{center}
\begin{tabular}{ |c | c | c | c |}
\hline
$4\times 4$ \textit{init all zero} & $\tau_{average}$ & $\tau_{min} - \tau_{max}$ & \textit{time-steps}= \\
& & & $\tau_{average}/16$ \\
\hline
strict index order & 11 & 11 - 11 & 0.69 \\
\hline
random sequence & 25.64 & 7 - 87 & 1.60 \\
\hline
pure random & 21.67 & 6 - 52 & 2.17 \\
\hline
\hline
\hline
$4\times 4$ \textit{init all one} & $\tau_{average}$ & $\tau_{min} - \tau_{max}$ & \textit{time-steps}=\\
& & & $\tau_{average}/16$ \\
\hline
strict index order & 26 & 26 - 26 & 1.63 \\
\hline
random sequence & 50.23 & 16 - 102 & 3.14 \\
\hline
pure random & 49.68 & 28 - 81 & 3.11 \\
\hline
\hline
\hline
$4\times 4$ \textit{init random } & $\tau_{average}$ & $\tau_{min} - \tau_{max}$ & \textit{time-steps}=\\
& & & $\tau_{average}/16$ \\
\hline
strict index order & 24.06 & 16 - 28 & 1.50 \\
\hline
random sequence & 45.29 & 13 - 136 & 2.83 \\
\hline
pure random & 43.29 & 7 - 126 & 2.71 \\
\hline
\end{tabular}
\end{center}
\label{TableRuleA4x4}
\end{table}
Another test was performed on a $3 \times 3$ field in order to assess the influence of the update order.
Starting with an initial configuration of all ones, we get the results shown in Table \ref{TableRuleA3x3}.
For averaging, 100 runs were performed.
A stable point pattern evolved fastest with strict order updating.
Though this is only a small example it shows that strict sequential updating can perform very well what we can also observe for larger fields.
Nevertheless a deeper analysis is necessary to confirm this observation.
Another test was performed for a $4 \times 4$ field, varying the initial condition (all zero, all one, random) and the update order
(Table \ref{TableRuleA4x4}).
100 runs were performed for averaging.
Starting with a initial all one or a random configuration, random sequence order
and pure random show about the same performance.
We have to notice that the performance results statistically vary if another set of runs is analyzed.
So these results could be evaluated more accurately by increasing the number of runs (e.g., up to 10 000).
Nevertheless we have observed that all theses different sequential updating orders worked well, where strict index order
worked fastest.
Now, by simulation of the Cellular Automata Rule A we want to get an impression of the patterns that can evolve for increasing larger fields.
\subsubsection{4 $\times$ 4 Patterns}
\begin{figure}[htb]
\centering
\includegraphics[width=12cm]{Figures/SimulationRuleA4x4.png}
\caption{
The evolution of a $4 \times 4$ field under different initial conditions and random sequence update order.
}
\label{SimulationRuleA4x4}
\end{figure}
Fig. \ref{SimulationRuleA4x4} shows
the evolution of a $4 \times 4$ field under different initial conditions and random sequence update order.
Similar 4-point patterns evolved. Notice that also similar
symmetric patterns under reflection, shift and rotation may evolve.
\COMMENT{
The following pattern is also a valid outcome.
\begin{verbatim}
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
\end{verbatim}
}
\subsubsection{5 $\times$ 5 Patterns}
\begin{figure}[htb]
\centering
\includegraphics[width=12cm]{Figures/RuleA5x5.png}
\caption{
Some valid $5 \times 5$ patterns evolved by Rule A.
(a) Patterns with $p=4,5$ points.
(b) Quad pattern representation: the (a) patterns are doubled in horizontal and vertical direction.
Quad patterns allow to observe the regularities better.
}
\label{RuleA5x5}
\end{figure}
Now we can observe from
Fig. \ref{RuleA5x5}
that patterns with 4 or 5 points may evolve,
whereas for the size $4 \times 4$ only patterns with 4 points evolve.
We call valid patterns with a minimum number of points \emph{min patterns}
and with a maximum number of points \emph{max patterns}.
The average cover level is
$v_{avrg}(p,n)=9p/n^2$, ~where $p$ is the number of points.
So we get $v_{avrg}(4)=36/25=1.44$ for 4 points
and $v_{avrg}(5)=1.8$ for 5 points.
There are different 4-point patterns with a different layout of the points.
The point layouts of
Fig. \ref{RuleA5x5}a
show a different distribution of the cover level.
The first 4-point pattern has the occurrence/frequency $f(v)$ of
$(4=p)+12, 8, 0, 1$ for $v=1,2,3,4$.
We may use the equivalent notation $1^{4+12} 2^8 3^0 4^1$.
Equivalent pattern under symmetries have the same cover level distribution.
The second 4-point pattern has the distribution $1^{4+12} 2^7 3^2 4^0$.
The third 4-point pattern has the distribution $1^{4+12} 2^9 3^1 4^0$.
The forth 4-point pattern has the distribution $1^{4+12} 2^7 3^2 4^0$.
The second and forth pattern have the same distribution but are not similar under symmetries.
The fifth pattern has 5 points and the distribution $1^{5+0} 2^{20} 3^0 4^0$.
It is the most regular, the distance from any point to its four nearest neighbors is equal ($\Delta x=1, \Delta y=2$).
In order to recognize better the inherent periodic pattern structure we can use the ``quad representation'' (Fig. \ref{RuleA5x5}b),
the pattern is repeated 4 times, twice in horizontal and twice in vertical direction.
This representation allows also to detect equivalent patterns under symmetries.
In general we may repeat the pattern horizontally \emph{U} times and vertically \emph{V} times
because of the periodic boundary condition.
In the following section (Fig. \ref{RuleA6x6}b) we can see a $6 \times 6$ pattern repeated 9 times $(U=V=3)$.
\subsubsection{6 $\times$ 6 Patterns}
\begin{figure}[htb]
\centering
\includegraphics[width=8cm]{Figures/RuleA6x6.png}
\caption{
Some valid $6 \times 6$ patterns evolved by Rule A.
(a) Patterns with $p=4 ~\dots~ 9$ points.
(b) An 8-point pattern repeated 3 times in horizontal and in vertical direction.
}
\label{RuleA6x6}
\end{figure}
Several evolved $6 \times 6$ patterns are shown in
Fig. \ref{RuleA6x6}a.
The range of points lies between 4 and 9.
4-point valid patterns consist of tiles that nowhere overlap, the cover level is $v=1$ everywhere,
and the horizontal and vertical distance between points is 3.
In the most regular 9-point pattern the distance between points is 2, and the cover level distribution is
$1^{9+0} 2^{18} 3^0 4^9$.
The last two 9-point patterns are similar under rotation and shift, and their cover level distribution both is
$1^{9+0} 2^{12} 3^{12} 4^3$.
No cover levels are shown in Fig. \ref{RuleA6x6}b (right) in order to expose the pattern's structure.
\begin{figure}[t!]
\centering
\includegraphics[width=9cm]{Figures/RuleA7x7.png}
\caption{
Some valid $7 \times 7$ patterns evolved by Rule A.
(a) Patterns with $p=7 ~\dots~ 10$ points.
(b) The cover levels $v=1$ and $v=2$ were replaced by dots.
This representation emphasizes the sites with cover levels 3 or 4 allowing to detect easier equivalent patterns,
e.g. the last two patterns are similar under symmetry.
}
\label{RuleA7x7}
\end{figure}
\subsubsection{7 $\times$ 7 Patterns}
\begin{figure}[t!]
\centering
\includegraphics[width=9cm]{Figures/RuleA8x8.png}
\caption{
Some valid $8 \times 8$ patterns evolved by Rule A
with $p=9 ~\dots~ 16$ points.
}
\label{RuleA8x8}
\end{figure}
\begin{figure}[htb]
\centering
\includegraphics[width=10cm]{Figures/minmax.png}
\caption{
Some patterns evolved by Rule A with a \emph{minimal} or \emph{maximal} number of points, \textit{min patterns} resp. \emph{max patterns} for $n=2 \dots 8$.
}
\label{minmax}
\end{figure}
Some evolved $7 \times 7$ patterns are shown in
Fig. \ref{RuleA7x7}a.
The number of points range from 7 to 10.
The first one is the most regular showing the cover level distribution
$1^{7+28} 2^{14} 3^{0} 4^{0} = 1^{p+(n^2-3p)} 2^{2p} 3^{0} 4^{0}$ with $p=n=7$.
In Fig. \ref{RuleA7x7}b only cover levels 3 and 4 are shown.
This representation can help to detect similar patterns more easily, e.g. the last two ones are similar.
In addition sites or local regions with high levels of overlap (3 and 4) are highlighted.
For instance in the five 9-point patterns the overlap levels are varying:
$3^4, 3^6, 3^6, 3^5 4^1, 3^2 4^3$
and in the six 10-point max patterns we find
$3^7, 3^7, 3^7, 3^6, 3^4 4^1, 3^4 4^1$.
\subsubsection{8 $\times$ 8 Patterns}
Fig. \ref{RuleA8x8} depicts evolved $8 \times 8$ patterns with 9 to 16 points.
Some patterns can easily be constructed.
The last one can be composed of 4 rectangles (double lines) of size $2 \times 8$ containing 4 points each.
Patterns with points $p=16-M,(M=0...4)$ can be composed of $M$ rectangles with 3 points and $4-M$ rectangles with 4 points.
Such patterns with a high regularity of construction by a human designer are more difficult to find by the CA rule.
Instead, most probably more irregular patterns are evolved which usually are difficult to construct by hand.
\subsubsection{Min and Max Patterns}
Min and max patterns for fields up to $8 \times 8$ are shown in
Fig. \ref{minmax}.
The min patterns are unique for $n=2,3,4,7$,
and the max patterns are unique for $n=2,3,4$.
\subsection{Additional Rule B: Deleting Gaps}
Rule A works also fine for other tile shapes, like dominoes
\cite{2019-pact-domino,Hoffmann-2021,Hoffmann-2021-MinimalDominoPact}.
Depending on the shape, Rule A may produce patterns with uncovered cells (gaps).
It was not observed during many simulations that the here used point tile can produce gaps.
So the following rule shall be used in the case where gaps may appear, like for dominoes.
The rule injects additional noise at sites where no hits (matching templates) occur.
In an implementation it is useful to use an additional temporary variable $hit$ that stores the number of hits
(template matches).
So we use the cell state $(s, hit)$ where $s\in\{0,1\}$ is the cell's pattern state,
and $hit\in\{0,1,2,3,4\}$.
In our case using the point tile, the hit value needs not to be stored between generations, but for
other tiles and objectives (e.g. minimization the number of tiles) it seems to be necessary that
the cell rule can use the hits in its neighborhood, either the hit just updated during the actual computation
of the new generation, or the hit from the previous generation.
During the process of CA rule application the pattern may not be completely valid but only partially.
In partially valid pattern some tiles are detected
but there exist some noisy or uncovered cells.
The hits approximate the cover level.
The hits will converge to the cover level when the pattern gets valid and stable.
The additional Rule B is
\[
s''(x,y) =
\left
\{
\begin{array}{lll}
random\in\{0,1\} &with ~\textit{prob.} ~\pi_0 ~~\textbf{if} ~hit(x,y)=0 &(c)\\
s'(x,y) &\textbf{otherwise} \textit{~no change} &(d) \\
\end{array}
\right. .
\]
For our simple point tile problem, the influence of the probability $\pi_0$ on the convergence speed and the
resulting patterns is negligible until about $\pi_0=0.20$.
We have used $\pi_0=0.01$ in the further experiments.
\subsection{Additional Rule C1: Maximizing the Number of Points
When Rule A is applied, valid point pattern are evolved with a point number
that lies between the maximum and the minimum, with a peak approximately at $p=(p_{min}+p_{max})/2$.
How can pattern be evolved with a high probability for $p=p_{max}$.
The idea is to inject additional noise when the local cover level $v$ is low,
in expectation to yield a more dense solution.
So noise is injected where $v=1$ and if the cell is a white/green border cell with state zero:
\[
s'''(x,y) =
\left
\{
\begin{array}{lll}
1 &with ~\textit{prob.} ~\pi_1 ~\textbf{if} ~hit(x,y)=1 \wedge s''(x,y) = 0 &(e)\\
s''(x,y) &\textbf{otherwise} \textit{~no change} &(f) \\
\end{array}
\right. .
\]
So we yield the combined rule ABC1
which means that rule A, rule B, and rule C1 are executed sequentially at the current site $(x,y)$.
\subsubsection{Simulation Results Using Rule ABC1}
\begin{table}[htb]
\centering
\caption{
Optimal or near-optimal min point patterns are evolved by rule ABC1.
The time $t_{stable}$ to reach a stable pattern is short.
}
\includegraphics[width=10cm]{Figures/TableRuleABC1.png}
\label{TableRuleABC1}
\end{table}
\begin{figure}[htb]
\centering
\includegraphics[width=10cm]{Figures/Simulation10x10-24points.png}
\caption{
The evolution of a near-optimal pattern with 24 points.
The pattern is stable for $t\geq8$.
Squares 22/22 like the marked one have to be dissolved in order to yield max patterns.
Points are colored in blue, state = 1.
Colors for state = 0 and for cover levels:
0 (white), 1 (yellow), 2 (light green), 3 (green), 4 (dark green).
}
\label{Simulation10x10-24points}
\end{figure}
The performance of rule ABC1 with $\pi_0=0.01$ and $\pi_1=0.25$ was evaluated
under 100 simulation runs, and averages were computed for $n$ even (Table \ref{TableRuleABC1}).
The evolved pattern show a high number of points, they are max patterns or close to them.
For instance, for $10 \times 10$ fields ($n=10$) the maximal number of points is $p_{max}=25$,
and the average number of evolved points is $p_{avrg}=24.71$, so in this case 71\% were max patterns.
One can see that the speed of convergence is high, and $t_{stable}$ to find an optimal or near-optimal min pattern
is low.
Now it was analyzed for $n$ even why not always optimal max point patterns evolve.
In
Fig. \ref{Simulation10x10-24points}
we see the evolution of a near-optimal $10\times 10$ pattern with 24 points, not with the maximum of 25 points
at which we aim at.
We can find in such near-optimal stable patterns $2\times 2$ squares with state 0 and cover level 2 surrounded by 4
cells with state 1.
Such 22/22 squares have to be dissolved in order to yield max patterns.
\subsection{Additional Rule C2 for \textit{n} Even}
\noindent This additional rule is able to dissolve the mentioned 22/22-squares.
Now the evolution converges to stable max patterns for $n$ even.
The rule C2 is:
\[
s''''(x,y) =
\left
\{
\begin{array}{lll}
1 &with ~\textit{prob.} ~\pi_2 ~~\\
&\textbf{if} ~hit(x,y)=2 \wedge \exists ! s'''(x\pm1,y\pm1) = 1 &(g)\\
s'''(x,y) &\textbf{otherwise} \textit{~no change} &(h) \\
\end{array}
\right. .
\]
If the local situation says that the cover level is $v=2$ approximated by \textit{hit}, and
there exists exactly one NESW-neighbor with state $s=1$ (a point), then this situation
corresponds to the one mentioned before (22/22) which will be dissolved by noise injection.
For computing the condition in (g) the following equivalence can be used
$\left( \exists ! s'''(x\pm1,y\pm1) = 1 \right) \equiv \left(1= \sum_{i=-1,+1}\sum_{j=-1,+1} s'''(x+ i,y+ j)\right)$.
\vspace{5pt}
The used rule probabilities are
$\pi_0=0.01, \pi_1=0.25, \pi_2=0.02$.
\begin{figure}[htb]
\centering
\includegraphics[width=10cm]{Figures/Evolution10x10Fast.png}
\caption{
The evolution of a found $10\times10$ max pattern using rule ABC1C2.
}
\label{Evolution10x10Fast}
\end{figure}
\begin{figure}[htb]
\centering
\includegraphics[width=10cm]{Figures/TimeStepsMax.png}
\caption{
The average number of time-steps to reach a stable max pattern for $n$ even.
}
\label{TimeStepsMax}
\end{figure}
\begin{figure}[htb]
\centering
\includegraphics[width=10cm]{Figures/PointsVSTime.png}
\caption{
The average number of points vs time-steps for a $10\times10$ field.
The maximum is reached for time-steps in the range 8 ... 175 approximately.
}
\label{PointsVSTime}
\end{figure}
The evolution of a stable $10\times10$ max pattern is shown in Fig. \ref{Evolution10x10Fast}.
Fig. \ref{TimeStepsMax} shows the needed number of time-steps (average over 100 runs) $t_{max}$ vs $n$.
The update method \textit{pure random} is about 1.6 times slower than \textit{random sequence}.
As expected the computational effort increases exponentially,
for the given range we can find the approximation $t_{max} \approx 0.0894 N^{1.336}$.
Fig. \ref{PointsVSTime}
shows the number of points vs the time-steps for a $10\times10$ field.
We can see that the maximum of points is reached after about 80 time-steps on average.
The fastest observed evolution took only a few time-steps, whereas the slowest took about 180
time-steps with a lot of fluctuations.
\subsection{Does Rule C1 Work Also for \textit{n} Odd?}
\begin{figure}[htb]
\centering
\includegraphics[width=10cm]{Figures/CaseOdd15.png}
\caption{
Found $15\times15$ pattern using rule ABC1. The patterns were not stable.
The first pattern is a constructed one.
The others are evolved samples for a certain number of points.
}
\label{CaseOdd15}
\end{figure}
\begin{figure}[htb]
\centering
\includegraphics[width=12cm]{Figures/Sequence9x9.png}
\caption{
Evolving an optimal $9\times9$ 18-point pattern
using rule ABC1, random sequence updating, $\pi_0=0.01, \pi_1=0.025$.
}
\label{Sequence9x9}
\end{figure}
Now the question arises whether this rule ABC1C2 works also for $n$ odd.
The problem is that optimal max patterns may contain sites with cover levels 1 and 2 besides 3 and 4.
For instance for $n=7$ (Fig. \ref{RuleA7x7}) there is an optimal pattern with a cover level distribution of
$1^{10+5 } 2^{27} 3^7$ and we find there also local 22/22 squares.
Therefore optimal patterns may appear but they are transients (not stable) because noise is injected for $v=1$
by rule C1 and for $v=2$ by rule C2.
Rule ABC1C2 was checked against ABC1 with respect to achieve a higher number of points.
It turned out that C2 is not useful for $n$ odd because many sites with cover levels 2
may be part of optimal patterns and therefore should not be destroyed.
Therefore for $n$ odd it is better to use ABC1 only.
We have to note that max patterns that may appear during the evolution are usually not stable
for $n$ odd.
In Fig. \ref{CaseOdd15} we see some $15\times15$ patterns with 49, 50, 51, 52 points that were evolved using rule ABC1.
100 simulation runs were performed with the time limit $T^{max}=200, 400, 800$.
The frequency $f$ of (49--52)--point pattern is also documented in Fig. \ref{CaseOdd15}.
One can see that the probability to find a max pattern during the evolution increases with the maximal number of simulated time-steps $T^{max}$.
Fig \ref{Sequence9x9} depicts a simulation sequence that evolves an optimal $9\times9$ pattern.
The applied rule is again ABC1.
\section{The Number of Points in Max Patterns and More Patterns}
\begin{figure}[htb]
\centering
\includegraphics[width=8cm]{Figures/Special5x5And7x7.png}
\caption{
Evolved max patterns of size $5\times5$ and $7\times7$.
}
\label{Special5x5And7x7}
\end{figure}
\begin{figure}[htb]
\centering
\includegraphics[width=10cm]{Figures/Special9x9And11x11And13x13.png}
\caption{
Solutions found for $n=9,11,13$.
}
\label{Special9x9And11x11And13x13}
\end{figure}
\begin{figure}[htb]
\centering
\includegraphics[width=10cm]{Figures/SpecialPatterns.png}
\caption{
Solutions found for $n=5,7,9,11,13$. The solutions for
$n=5,9,13, ...$ seem to be unique and stable without cells having cover level 1.
}
\label{SpecialPatterns}
\end{figure}
\begin{figure}[htb]
\centering
\includegraphics[width=10cm]{Figures/Special17x17.png}
\caption{
(R) Points are colored in blue, state = 1.
Colors for state = 0 and for cover levels:
0 (white), 1 (yellow), 2 (light green), 3 (green), 4 (dark green).\\
R(a--c) Evolved $17\times17$ patterns by rule ABC1:
R(a) unstable with 67 points, R(b, c) stable with the maximum of 68 points.
R(d) $21\times 21$ stable max pattern with 105 points.\\
(S) Only points are displayed.
(T) Points and cover level 2 (in light red) are shown. \\
(U) R(b) is displayed using different colors for cover levels.
}
\label{Special17x17}
\end{figure}
Analyzing the evolved max patterns for $n$ odd we constructed the following formula
to be confirmed by a formal proof.
\[
p_{max}(n) =
\left
\{
\begin{array}{lll}
(n(n-1)-2)/4 &\textbf{if} ~n=3, 7, 11, ... = 3+4k, & k=0, 1, 2, 3 ... \\
n(n-1)/4 &\textbf{if} ~n=5, 9, 13, ... = 5+4k, &k=0, 1, 2, 3 ... \\
n^2/4 &\textbf{if} ~n ~\textit{even} \\
\end{array}
\right. .
\]
The following table displays $p_{max}(n)$ for odd $n=3, \ldots,23$.
\vspace{9pt}
\begin{minipage}[h]{.9\textwidth}
\begin{verbatim}
n 3 5 7 9 11 13 15 17 19 21
pmax 1 10 27 52 85 (n(n-1)-2)/4
5 18 39 68 105 n(n-1)/4
\end{verbatim}
\end{minipage}
\vspace{9pt}
Let us have a look at more evolved patterns.
Fig. \ref{Special5x5And7x7}:
There is only one very regular solution for $5\times5$ with 5 points.
Three solutions were found for $7\times7$ that are not very regular.
Fig. \ref{Special9x9And11x11And13x13}:
For $9\times9$ and $13\times13$ we observe a similar regular construction principle.
The found $11\times11$ patterns shows structures that lie between the $9\times9$ and $13\times13$ structures.
Fig. \ref{SpecialPatterns}:
The patterns were arranged in this way in order to find the above formula for the number of points for $n$ odd.
We observe a certain relation between patterns for $n=5,9,13 ...$ and for $n=7, 11, ...$.
Fig. \ref{Special17x17}:
R(a) shows and unstable sub-optimal, and R(b, c) optimal $17\times17$ patterns.
Interesting is that the optimal pattern R(b) does not follow the structure scheme observed for $n=5,9,13$,
but R(c) does.
The $21\times21$ max pattern R(d) shows again the structure scheme of $n=5,9,13$.
Only the points are displayed in the patterns (S).
Points and cover level 2 (in light red) are shown in (T).
The bottom line (U) of patterns show that different structures can be elucidated from R(b) if different colors for the
cover level are used. In fact we may derive different patterns by interpreting not only the state $s$ but also the
cover level $v$.
Therefore we may use such CA rules of pattern generation also to produce intentionally certain ``cover level patterns''.
Patterns with $n=3+4k$ and near-optimal patterns may have some aesthetic value because there structure is not regular
in a simple fashion.
\newpage
\section{Conclusion and Future Work}
The aim was to find a cellular automata rule that can evolve a point pattern with a maximal number of points (max patterns).
The problem was considered as a tiling problem using overlapping point tiles.
Nine templates are systematically derived form the point tile that are used for local matching.
The number of matches defines the number of hits.
Four Rules were designed that supplement each other.
Rule A adjust the cell to the template's center value (reference value) if there is a hit,
otherwise noise is injected.
Rule A is able to evolve stable point patterns very fast, but the number of points is seldom maximal.
Rule B injects noise if no tile covers the cell (cover level zero) in order to avoid gaps.
Rule C1 drives the evolution to a maximal number of points.
Rule C2 drives the evolution to a stable optimum if the field length $n$ is even.
A formula is presented that defines the maximal number of possible points.
The patterns are more interesting if $n$ is odd.
Two different structures for optimal patterns were found for $n=17$.
It would be interesting to find the number and structure of possibly different optimal patterns for $n>17$, especially if $n$ is odd.
The introduced method was already applied to other patterns (domino pattern, sensor point pattern)
and offers a way to generate more complex patterns using more complex tiles.
Future work can address the following problems
\begin{itemize}
\item parallel implementation,
\item synchronous updating instead of asynchronous,
\item using several tiles, more complex tiles, or more colors,
\item using different grid dimensions, different regular grids (triangular, hexagonal, ...), or graphs in general,
\item optimizing time efficiency using for instance a ``divide and conquer'' approach,
\item relating this method to other methods, like constraints satisfaction,
\item relating the problem to physical problems, like the attraction and repulsion of particles,
\item consider the problem in the context of combinatorics,
\item classify the results into the theory and applications of tilings,
\item find interesting applications, like the generation of artistic patterns.
\end{itemize}
\DREIECK{3}
\newpage
\section{Appendix: Presentation 2019}
\begin{figure}[h!]
\centering
\includegraphics[width=2.3cm]{Figures/s_p1.pdf}
\includegraphics[width=2.3cm]{Figures/s_p2.pdf}
\includegraphics[width=2.3cm]{Figures/s_p3.pdf}
\includegraphics[width=2.3cm]{Figures/s_p4.pdf}
\includegraphics[width=2.3cm]{Figures/s_p5.pdf}
\includegraphics[width=2.3cm]{Figures/s_p6.pdf}
\includegraphics[width=2.3cm]{Figures/s_p7.pdf}
\includegraphics[width=2.3cm]{Figures/s_p8.pdf}
\includegraphics[width=2.3cm]{Figures/s_p9.pdf}
\includegraphics[width=2.3cm]{Figures/s_p10.pdf}
\includegraphics[width=2.3cm]{Figures/s_p11.pdf}
\includegraphics[width=2.3cm]{Figures/s_p12.pdf}
\includegraphics[width=2.3cm]{Figures/s_p13.pdf}
\includegraphics[width=2.3cm]{Figures/s_p14.pdf}
\includegraphics[width=2.3cm]{Figures/s_p15.pdf}
\includegraphics[width=2.3cm]{Figures/s_p16.pdf}
\includegraphics[width=2.3cm]{Figures/s_p17.pdf}
\includegraphics[width=2.3cm]{Figures/s_p18.pdf}
\includegraphics[width=2.3cm]{Figures/s_p19.pdf}
\includegraphics[width=2.3cm]{Figures/s_p20.pdf}
\includegraphics[width=2.3cm]{Figures/s_p21.pdf}
\includegraphics[width=2.3cm]{Figures/s_p22.pdf}
\includegraphics[width=2.3cm]{Figures/s_p23.pdf}
\includegraphics[width=2.3cm]{Figures/s_p24.pdf}
\includegraphics[width=2.3cm]{Figures/s_p25.pdf}
\includegraphics[width=2.3cm]{Figures/s_p26.pdf}
\includegraphics[width=2.3cm]{Figures/s_p27.pdf}
\includegraphics[width=2.3cm]{Figures/s_p28.pdf}
\includegraphics[width=2.3cm]{Figures/s_p29.pdf}
\includegraphics[width=2.3cm]{Figures/s_p30.pdf}
\includegraphics[width=2.3cm]{Figures/s_p31.pdf}
\includegraphics[width=2.3cm]{Figures/s_p32.pdf}
\includegraphics[width=2.3cm]{Figures/s_p33.pdf}
\includegraphics[width=2.3cm]{Figures/s_p34.pdf}
\includegraphics[width=2.3cm]{Figures/s_p35.pdf}
\includegraphics[width=2.3cm]{Figures/s_p36.pdf}
\includegraphics[width=2.3cm]{Figures/s_p37.pdf}
\includegraphics[width=2.3cm]{Figures/s_p38.pdf}
\includegraphics[width=2.3cm]{Figures/s_p39.pdf}
\includegraphics[width=2.3cm]{Figures/s_p40.pdf}
\includegraphics[width=2.3cm]{Figures/s_p41.pdf}
\includegraphics[width=2.3cm]{Figures/s_p42.pdf}
\includegraphics[width=2.3cm]{Figures/s_p43.pdf}
\includegraphics[width=2.3cm]{Figures/s_p44.pdf}
\includegraphics[width=2.3cm]{Figures/s_p45.pdf}
\includegraphics[width=2.3cm]{Figures/s_p46.pdf}
\includegraphics[width=2.3cm]{Figures/s_p47.pdf}
\includegraphics[width=2.3cm]{Figures/s_p48.pdf}
\caption{
Slides presented at Summer Solstice Conference on Discrete Models of Complex Systems 2019, Dresden, July 15 - 17, 2019
}
\label{presentation}
\end{figure}
\newpage
|
{'timestamp': '2022-02-15T02:42:57', 'yymm': '2202', 'arxiv_id': '2202.06656', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06656'}
|
arxiv
|
\section{Introduction}
With the fast-growing number of satellites orbiting Earth, the Space Operations field has become a prominent and thriving sector.
As a consequence, the complexity of planning satellite operations is constantly increasing: Ground Stations have to handle communication with multiple satellites simultaneously while frequently engaged in \emph{Launch and Early Orbit Phase} (LEOP) activities; Satellite Operators need to perform routine tasks and promptly react to contingencies while checking the status of the incoming and disseminated satellite's products.
These actions are costly, require time, and are remarkably prone to human errors.
Despite this, Satellite Operators still carry out many of these duties by relying on their technical expertise rather than leveraging modern machine learning tools.
On the other hand, computers, hardware, and flight software are becoming more sophisticated with each passing day.
At the same time, machine learning is blooming, and optimal algorithms are constantly being designed for a variety of heterogeneous problems spanning from foundational \cite{cesa2021nonstochastic,cesari2021sample}, optimization \cite{bouttier2020regret,bachoc2021sample}, cooperation \cite{cesa2020cooperative,della2021efficient,cesa2021cooperative}, or even economics \cite{cesa2019dynamic,cesa2021aRegret,cesa2021bilateral,cesa2021roi}.
Exploiting this growing technology means enhancing the reliability and efficiency of space operations while simultaneously avoiding human error as well as decreasing the workload on Engineers and Operators. From an operational point of view, this entails transferring Ground Segment capabilities to the Space Segment.
As outlined by \citet{7976296}, onboard autonomy implies:
\begin{enumerate}
\item Intelligent sensing: the capability to infer the system's state from environmental sensor data.
\item Mission Planning and execution: the process of decomposing high-level goals into tasks that satisfy temporal and resource constraints and dispatching these tasks while monitoring and being able to react to a contingency.
\item Fault management: the ability to deal with anomalies that occurred inside the system.
\item Distributed decision making: effective cooperation among independent autonomous spacecraft to achieve common goals.
\end{enumerate}
The focal point of our paper is to identify a solution to have autonomous mission planning software onboard that is capable of making decisions, reacting to the external environment, and dealing with anomalies while keeping operability from ground.
Mission planning aims to allocate several tasks considering high-level goals, constraints, and resources.
In recent years, researchers started studying this topic from different angles: using fuzzy neural networks to respond to uncertainty and proposing rescheduling \citep{LI2014678}, exploiting symmetric neural networks to improve heuristic search \citep{sym11111373}, using tabular search algorithms \cite{5608821}. All these methods fall into the category of \emph{Static Scheduling} because of the time they require to gather all the tasks.
To tackle this time issue, \emph{Dynamic Scheduling} builds a mathematical model considering five basic objects: tasks, resources, available opportunities, constraints, and objectives.
In this framework, scientists have been using novel heuristic algorithms to get \emph{close-to-optimal} results \cite{WANG2015110}; reinforcement learning based on neural network and transfer learning to solve decentralized Markov decision processes \citep{WANG2011493}; casting the problem as a stochastic dynamic Knapsack problem, and using deep reinforcement learning techniques to address it \citep{WANG20191011}.
A downside of these approaches is that they require a large training dataset to output a robust decision-maker. Moreover, they often need frequent maintenance activities to be kept in line with the dynamic operational environment of a satellite.
Other proposed solutions consist of hybrid procedures, mixing autonomous onboard capabilities and ground operations.
A concrete example of these kinds of systems is the FireBird mission whose scheduler exploits very simple algorithms maintaining operability from ground \citep{lenzen2014onboard}; another one is The MER's scheduler that uses the concept of ``onboard execution of goal-oriented mission operations'' in addition to minor support from a ground process \citep{https://doi.org/10.1002/rob.20192}.
For an \emph{Earth Observation} (EO) Satellite, all the spacecraft activities are scheduled by the Mission-Planning Engineer weekly.
Then, the tasks are uploaded to the satellite as commands during ground visibility.
New satellites can accept three types of commands:
\begin{itemize}
\item \emph{Multi Repeat Cycle} (MRC) commands, which are executed at the same orbit positions over the cycles.
\item \emph{Single Repeat Cycle} (SRC) commands, which are executed at a specific orbit position for only one cycle.
\item \emph{Mission Time Line} (MTL) commands, which fire at a specific time.
\end{itemize}
In this paper, we present an algorithm capable of deciding when is the most suitable time to schedule the specific request to dump data from the onboard memory of a satellite (during visibility) over a ground station while keeping the system as simple as possible and \emph{with no help from the ground}.
We do this by casting our online decision-making problem into a prediction with expert advice setting \citep[Section 2]{cesa2006prediction} for which we implement a \emph{Follow-The-Leader} strategy \cite{kotlowski2018minimax} targeting SRC commands.
The paper is organized as follows.
In \Cref{s:problem}, we give a high-level presentation of the specifics of the problem.
In \Cref{s:setting}, we provide a formal mathematical model for it.
In \Cref{s:ftl}, we introduce the Follow-The-Leader (FTL) strategy and discuss the theoretical motivations of this choice.
In \Cref{s:experiments}, we present the results of our experiments on real-life data, showing that implementing a simple FTL algorithm increases the performances of the satellites by more than $60\%$.
\section{The problem of optimizing Acquisition and Loss of Signal offsets for spacecraft memory dump}
\label{s:problem}
EO Satellites are designed to perform remote sensing. Most of them operate at \emph{Low Earth Orbit} (LEO) with a period of approximately $120$ minutes.
Depending on the \emph{swath} of the onboard primary mission instrument, which is the device's \emph{areas} imaged on the surface, the satellite will complete a full Earth's coverage after a certain number of orbits.
This means the spacecraft completed a cycle.
Each separate orbit of a cycle is referred to as \emph{Relative Orbit} and is repeated through different cycles.
Motivation-wise, EO satellites play a fundamental role in weather forecast and natural disaster response scenarios, to name a couple.
Spacecraft Operations Centers are in charge of distributing information to the users by commanding the satellites to perform activities over specific portions of the globe. This is done through the \emph{Mission Control Center} (MCC), which is capable of receiving telemetry and sending commands via the \emph{Mission Control System} software.
Customers define the requirements and, or constraints that drive the operations performed during the lifetime of a mission.
In particular, data \emph{timeliness} is a crucial parameter for the users' community: it is defined as the difference between the beginning of the sensing time of an instrument and the reception time of the same data on ground.
Depending on the quality level of the products, data timeliness is categorized with different labels.
For Earth Observation satellites we can divide the delivered data into three main macro-categories:
\begin{itemize}
\item \emph{Near Real Time} (NRT), whose timeliness is lower than, or equal to the orbit period.
\item \emph{Short Time Critical} (STC), whose timeliness can be hours.
\item \emph{Non Time Critical} (NTC), whose timeliness can be days even weeks.
\end{itemize}
In this work, we focus on NRT data.
To respect its requirements, NRT data must be dumped at every orbit without losing telemetry frames.
Failing to do so results in critical data corruption, requiring another dump on the following orbit, therefore exceeding the timeliness.
To protect against data corruption, a Mission Planning Engineer uploads to the onboard computer software two commands sequences for each orbit: start and stop the memory dump during visibility time.
The timing of the two sequences relies on Flight Dynamic prediction of the passes over an antenna that defines the predicted \emph{Acquisition of Signal} (AOS) and \emph{Loss of Signal} (LOS).
There are three notable categories for these pairs of events: AOS0 (resp., LOS0) is when the event occurs at the horizon, with an elevation of 0 degrees;
AOSM (resp., LOSM) denotes the event taking into account the masking of other objects, such as mountains, trees, or other antennas, therefore happening after AOS0 (resp., before LOS0);
AOS5 (resp., LOS5) is when the event takes place 5 degrees above the horizon, therefore it can happen before or after the masking event, depending on the specific conditions.
\begin{figure}
\centering
\begin{tikzpicture}[scale=0.95]
\draw[red] (50:5cm) -- (0,1.7) -- (125:5cm);
\draw[green] (45:5cm) -- (0,1.7) -- (135:5cm);
\draw ([shift=(45:5cm)]0,0) arc (45:135:5cm);
\draw[green] (45:5cm) node[right] {$LOS$}
(135:5cm) node[left] {$AOS$};
\draw[red] (50:5cm) node[above right] {$L_t$}
(125:5cm) node[above left] {$A_t$};
\draw[xshift=2cm, yshift=5.5cm, rotate=-30, scale=0.75, fill=blue!40!white]
(0,0.3) -- (-1,0.2) -- (-1,0.8) -- (0,0.7)
(0.5,0.3) -- (1.5,0.2) -- (1.5,0.8) -- (0.5,0.7)
(0,0) rectangle (0.5,1)
;
\draw[xshift=2cm, yshift=5.5cm, rotate=-30, scale=0.75, gray, thick]
([shift=(250:0.5cm)]0.25,0) arc (250:290:0.5cm)
([shift=(245:0.5cm)]0.25,-0.1) arc (245:295:0.5cm)
([shift=(240:0.5cm)]0.25,-0.2) arc (240:300:0.5cm)
;
\draw[xshift=2cm, yshift=5.5cm, rotate=-30, scale=0.75, fill=blue!40!white]
(0,-0.251) -- (0.5,-0.251) --
([shift=(0:0.25cm)]0.25,-0.25) arc (0:180:0.25cm) -- cycle;
\draw[fill=red!40!yellow, draw=black] (-0.5,0.4) -- (-0.1,1.1) -- (0.1,1.1) -- (0.5,0.4) -- cycle;
\draw[fill=red!40!yellow, draw=black] (-0.5,0.4) rectangle (0.5,0.5);
\draw[fill=red!40!yellow, draw=black] (0.5,1.5) -- (-0.5,1.5) -- ([shift=(180:0.5cm)]0,1.5) arc (180:360:0.5cm) -- cycle;
\draw[fill=red!40!yellow, draw=black] (-0.02,1.5) -- (0,1.7) -- (0.02,1.5) -- cycle;
\end{tikzpicture}
\caption{Pass' events timeline: AOS (resp., LOS) represents the highest events between AOS5 and AOSM (resp., LOS5 and LOSM); $A_t$ and $L_t$ represent the start and the stop of the dump which could be (and usually are) asymmetric with respect to the overall visibility.}
\end{figure}
In Spacecraft operations, the start of the dump is always shifted by a fixed amount of time, or \emph{offset}, with respect to the latest event between AOS5 and AOSM.
The same happens for the end of the dump which is anticipated with respect to the earliest between LOS5 and LOSM.
This is done to guarantee the desired level of robustness against failures.
These offsets are typically set manually and can be changed for each orbit or cycle. Usually, they are initialized with default values that consider the size of the dump and possible errors in the orbit determination and are then kept fixed, but during the early phase of a mission, things can diverge from the preparation phase, and offsets often need to be updated.
In case of issues on the ground side (late acquisition and, or early loss of signal), data will be corrupted either because the satellite started dumping before locking over the antenna's signal or because the onboard computer was still downloading data while suddenly connection was cut off.
The only way to prevent loss of data is to modify the offsets \emph{ad-hoc} for each pass.
This operation is not currently carried on online automatically. Therefore, to recover after an issue of this type, engineers need to manually send a request through the \emph{Mission Control System} (MCS) at the next visibility opportunity.
Changing these values to avoid failure is an error-prone task that puts unneeded pressure on engineers.
There is no benefit in making these predictions manually.
On the contrary, the nature of this problem makes it a perfect candidate for installing machine learning algorithms on onboard computers so that they can automatically learn from experience and predict online how to optimally set these offsets in order to optimize the data exchange with ground stations.
In this paper, we propose an algorithm that selects the best AOL/LOS offsets at each cycle for every orbit. Moreover, we show that implementing this approach would not only avoid the need for operators to intervene manually, but it would save a vastly larger amount of the passes when compared to the currently employed \emph{ad-hoc} techniques.
\section{Formal Mathematical Setting}
\label{s:setting}
In this section we give a brief formal introduction to the online machine learning protocol that we will use to model our offset optimization problem.
We cast our repeated interactions with the environment in the \emph{prediction with expert advice} framework.
In this formulation, each problem instance is characterized by:
\begin{enumerate}
\item A finite set of nonnegative times $\cO_{\mathrm{AOS}}$
---the offsets from the times of Acquisition Of Signal.
\item A finite set of nonnegative times $\cO_{\mathrm{LOS}}$
---the offsets from the times of Loss Of Signal.
\item A family $(p_{a,l})_{a \in \cO_{\mathrm{AOS}}, \, l \in \cO_{\mathrm{LOS}}}$ of numbers in $[0,1]$
---the probabilities of a successful dump when some AOS and LOS offsets are selected.
\end{enumerate}
Only the \emph{action} set $\cO_{\mathrm{AOS}}\times\cO_{\mathrm{LOS}}$ is known to the learner and the best $p_{a,l}$ must be learned through data-collection.
The online protocol proceeds as in Online Protocol \ref{a:protocol}.
{
\makeatletter
\renewcommand{\ALG@name}{Online Protocol}
\makeatother
\begin{algorithm}[tb]
\caption{}
\label{a:protocol}
\begin{algorithmic}
\FOR
{%
each time step $t = 1, 2, \dots$
}
\STATE The learner selects a pair of offsets
$(A_t,L_t) \in \cO_{\mathrm{AOS}}\times\cO_{\mathrm{LOS}}$
\STATE The environment draws samples $B_t(a,l)\in\{0,1\}$ according to Bernoulli distributions with biases $p_{a,l}$, independently of each other and the history so far, for each pair of offsets $(a,l) \in \cO_{\mathrm{AOS}}\times\cO_{\mathrm{LOS}}$\;
\STATE The learner gains the \emph{reward}
$B_t(A_t,L_t) \in \{0,1\}$
\STATE The learner observes as \emph{feedback} the samples
$B_t(a,l)$, for all $(a,l)\in \cO_{\mathrm{AOS}}\times\cO_{\mathrm{LOS}}$
\ENDFOR
\end{algorithmic}
\end{algorithm}
}
The objective of the learner is to collect as much reward as possible in any given time \emph{horizon} $T$.
More precisely, denoting by $\alpha$ the algorithm that generates the sequence of actions $(A_1,L_1)$, $\dots,$ $(A_T,L_T)$, the goal is to minimize the \emph{regret}
\begin{align*}
R_T{(\alpha)}
&
\coloneqq
\max_{(a,l) \in \cO_{\mathrm{AOS}}\times\cO_{\mathrm{LOS}}} \mathbb{E} \lsb{ \sum_{t=1}^T B_t(a,l) - \sum_{t=1}^T B_t(A_t,L_t) }
\\
&
=
T \max_{(a,l)\in \cO_{\mathrm{AOS}}\times\cO_{\mathrm{LOS}}} p_{a,l}
- \mathbb{E}\lsb{ \sum_{t=1}^T B_t(A_t,L_t) } \;.
\end{align*}
In words, we want the total reward accumulated by the learner to be as close as possible to that of an agents with full knowledge of the family of probabilities $(p_{a,l})_{(a,l)\in\cO_{\mathrm{AOS}}\times\cO_{\mathrm{LOS}}}$ that operates optimally by always choosing an action $(a^\star,l^\star)$ that maximizes its expected reward $p_{a^\star,l^\star}$.
\section{Follow the Leader{}}
\label{s:ftl}
In this section, we present the Follow the Leader{} paradigm (\Cref{a:ftl}).
Our choice of applying this strategy to the offset-optimiza\-tion problem was initially motivated by compelling theoretical considerations (see \Cref{s:ftl-theory}).
We then confirmed these theoretical findings empirically, showing that an implementation of a Follow the Leader{} algorithm does lead to dramatic performance improvements when applied to real-life scenarios (\Cref{s:experiments}).
\begin{algorithm}[tb]
\caption{Follow the Leader (FTL)}
\label{a:ftl}
\begin{algorithmic}
\STATE {\bfseries Input:} action set $\cO_{\mathrm{AOS}}\times\cO_{\mathrm{LOS}}$, tie-breaking rule $\tau$
\FOR
{%
each time step $t = 1, 2, \dots$
}
\STATE select action
\[
(A_t,L_t)
\coloneqq
\argmax_{(a,l) \in \cO_{\mathrm{AOS}}\times\cO_{\mathrm{LOS}}} \sum_{s=1}^{t-1} B_s(a,l) \;,
\]
breaking ties according to $\tau$, with the convention that (on time step $t=1$) $\sum_{s=1}^0 B_s(a,l) \coloneqq 0$, for all $(a,l)\in \cO_{\mathrm{AOS}}\times\cO_{\mathrm{LOS}}$\;
\ENDFOR
\end{algorithmic}
\end{algorithm}
In words, a Follow the Leader{} strategy maintains, during time steps $t$, an integer $\sum_{s=1}^{t-1} B_s(a,l)$ for each action $(a,l)$, representing how well the pair of offsets $(a,l)$ performed so far.
It then simply selects an action with the best past performance, breaking ties according to the rule $\tau$ that is passed to the algorithm as an input.
We highlight the role of the tie-breaking rule $\tau$ for two main reasons that are unfortunately often neglected.
Firstly, from a theoretical standpoint, ties have to be broken in a measurable way.\footnote{Although we will not insist excessively on the mathematical formalism, it is important to know that unexpected pathologies may occur if measurability is not guaranteed. In fact, the regret might not even be well-defined without it! For more on this topic, see, e.g., \cite[Section 2.4]{cesari2021nearest}.}
Secondly, depending on the application, some types of tie-breaking rules are typically preferred to others.
For example, in theoretical results, ties are typically broken uniformly at random (for mathematical convenience) but in practice, this is often unacceptable (because no practitioner would change a strategy that is currently working if no changes in the system are detected).
We will elaborate more on this key point in \Cref{s:experiments}.
\subsection{Theoretical Motivations}
\label{s:ftl-theory}
In this section, we give a concise summary of the theoretical results that motivated our choice of adopting a Follow the Leader{} strategy for the offset optimization problem.
A recent paper by \citet[Corollary~4]{kotlowski2018minimax} shows that such a policy is optimal in the following strong sense.
\begin{theorem}
For any time horizon $T$ and any other online learning algorithm $\alpha$, the FTL algorithm with ties broken uniformly at random satisfies
\[
\sup_{p} R_T(\mathrm{FTL})
\le
\sup_{p} R_T(\alpha)
\]
where the supremum is over all possible choices of probabilities $p_{a,l}\in[0,1]$, for $(a,l) \in \cO_{\mathrm{AOS}}\times\cO_{\mathrm{LOS}}$.
\end{theorem}
In words, the previous result states that no algorithm can achieve better performances than FTL in general.
\citet[Corollary~4]{kotlowski2018minimax} goes even further, showing that in addition to the regret, the same optimality holds for expected redundancy and excess risk.
Quantitatively, it is immediate to show that FTL enjoys a \emph{finite} regret, even when the time horizon $T$ approaches infinity, assuming that there is at least an action $(a,l)$ with $p_{a,l}=1$.
Indeed, in this case, for any $T$,
\[
R_T(\mathrm{FTL)}
\le
1 + \babs{ (a,l) \in \cO_{\mathrm{AOS}}\times\cO_{\mathrm{LOS}} : \mu_{a,l}\nu_{a,l} \in (0,1) } \;.
\]
The expression on the right-hand side counts the total number of mistakes that FTL could make: on round $1$, it could accidentally select an action $(a,l)$ with expected reward zero, i.e., a pair of offsets for which it is impossible to dump successfully.
All these ``bad'' actions will be automatically excluded in all future rounds by definition of FTL.
Then, the only way the algorithm could pay some regret on a round $t \ge 2$ is if it selected an arm $(A_t,L_t)$ with expected regret $p_{A_t,L_t}<1$ which happened to have given reward $1$ in \emph{all} previous rounds but returned $0$ on the current one.
Again, by definition of FTL, such an action could only ever be played once and by the nature of the problem, the probability of this happening decreases exponentially with time.
These considerations give a strong theoretical foundation to the credence that FTL strategies outperform all other algorithms designed for this problem.
In the following section, we will show on real data that this is indeed the case.
\section{Implementation and Experimental Results}
\label{s:experiments}
The algorithm has been evaluated by comparing the results of a schedule produced with the autonomous choice of the offsets against a real operating schedule and the real telemetry data gathered from satellites.
\subsection{System Configuration}
The \emph{Mission Planning} (MP) software is a Commercial-Off-The-Shelf (COTS) written in C/C++ and it produces the schedule according to the schedule format from CSSDS standards \citep{schedule2018}. The software for autonomous selection of dump sequences has been written with Python v3.7.
We chose Python for the numerous support packages and modules which allow every user to personalize the tool with their own widgets, depending on their unique needs.
It is also simpler than the commonly used C++ and Java, and its lower code complexity makes it easy for beginners to approach it.
Simulations have been performed on a Windows 10 Pro x64 machine, processor i5-8250U 1.60 GHz, 8.00 GHz of RAM.
The real telemetry data is provided by using SCOS-2000, a generic MCS software developed by the European Space Agency (ESA).
It provides the means for satellite operators to monitor and control one or more satellites.
The MCS is connected to the Antenna that the satellite is downloading over, and as soon as the spacecraft and antenna signals get \emph{on lock}, live telemetry is received and SCOS displays the first timestamp of the first telemetry frame received, doing the same when the pass is over and the last frame's timestamp is displayed.
These two pieces of information are then saved in a \emph{csv} file together with the relative orbit number and the cycle and passed to MP software.
This task has been performed by Spacecraft Controllers who were recording the time of the first and last TM frame ---but not regularly, leading to a partially filled set of data that required some pre-processing.
All the test data set: telemetry, flight dynamic events, and schedule, are kind courtesy of Eumetsat.
These data recordings begin at cycle 6 of the mission because in the first cycles
the satellite was not on the reference orbit, thus revolutions were not cyclic.
Regarding the flight dynamic data, these are generated by a COTS software that takes telemetry data as input and generates a file, according to CCSDS standards \citep{orbitmsg2009}, which contains the propagation of the orbit of the satellite and its events (e.g. when the spacecraft is flying over a certain place at a certain time it save it as an event).
The file is then passed to the Mission Planning software as well.
After receiving all these files, the Mission Planning engineer can generate a schedule which is an \emph{xml} file that is then sent back to MCS to generate the commands.
\subsection{Scenario Configuration}
The satellite considered for our tests is Copernicus Sentinel-6 and belongs to the European Earth Monitoring program.
It works in an LEO orbit with an altitude of $1336$ km, inclination $i$ of $66$ deg, and 127 orbits per cycle \citep{enwiki:1057089658}.
Each cycle lasts about 9.9 days. The average data dump is of 14 minutes.
A default pair of values of offsets for both AOS and LOS is evaluated according to the memory dump size; in this case, we started with $A_1=30s$ and $L_1=10s$.
\paragraph{Tie-breaking rule}
We break ties among leading AOS/LOS offsets by optimizing for both robustness and maximal usage of Station visibility.
To do so, we first compute the smallest possible AOS and LOS offsets that could guarantee a successful dump given the historic data.
Instead of selecting these offsets directly ---this could be prone to failures in early rounds--- we then compute a \emph{safe} pair of offsets, that would guarantee a successful dump that starts and ends at a maximal distance from the smallest possible AOS and LOS offsets computed above.
\subsection{Baselines}
The FTL algorithm has been compared against data coming from real telemetry: an initial schedule has been generated with offsets set as per an operational scenario, then the schedule has been uploaded to the satellite.
All the issues that occurred during the mission have been recorded together with the start and stop time of the real telemetry. This information has been compared against our FTL software.
\subsection{Performances}
The algorithm was run for 6 cycles of 127 orbits each.
During the first 6 life cycles of the baseline mission, a total of 762 passes occurred, and 67 of them contained corrupted data due to late/early AOS/LOS.
When this happens, passes need to be re-dumped the next orbit, losing timeliness.
With our FTL algorithm, we were able to save more than $62\%$ of the corrupted passes, leading to a dramatic improvement in timeliness.
This was done without the need for any manual intervention.
The few passes that were still lost occurred ad the very early stages of the process, where the choices of \emph{any} decision-maker are doomed by the variance.
For a pictorial example of the behavior of FTL, see \Cref{fig:ron125}.
\begin{figure}[ht!]
\centering
\begin{tikzpicture}[scale=0.8]
\begin{axis} [ybar, height=7cm, width=11cm, xmin=0, xmax=7,ymin=0,ymax=42]
\addplot coordinates {
(1,30)
(2,30)
(3,0)
(4,30)
(5,30)
(6,30)
};
\addplot coordinates {
(1,13)
(2,13)
(3,0)
(4,16)
(5,16)
(6,16)
};
\legend {AOS Offset [s], LOS Offset [s]};
\end{axis}
\node[above,font=\large] at (current bounding box.north) {RON 125};
\end{tikzpicture}
\caption{The LOS offset for orbit $125$, initialized as $10s$, is updated to $13s$ after time step 1, and again to $16s$ after time step 4.
Overall, only $1$ pass was lost after the initialization step.
As a reference, all $5$ recorded passes were lost in the baseline mission (time step 3 was not recorded).}
\label{fig:ron125}
\end{figure}
\section{Conclusions}
We presented a lightweight algorithm capable of updating the spacecraft command sequences online, autonomously, and considerably improving user requirements for data timeliness.
More precisely, we manage to reach two competing goalposts simultaneously. First, \emph{simplicity}: the Python implementation we provide consists of a relatively minute number of instructions, and intrinsically simple routines are quick to explain to engineers used to different system practices while requiring effectively no maintenance.
Second, \emph{high performances}: our algorithm vastly outperforms the existing \emph{ad hoc} methods, as our testing showed that switching to our FTL routine would save an enormous amount of otherwise lost data.
\section*{Aacknowledgements}
The authors gratefully acknowledge the support of the Eumetsat Mission Planning team where Jonathan is working.
This work started during Tommaso's Post-Doc at the Institut de Mathématiques de Toulouse, France, and benefited from the support of the project BOLD from the French
national research agency (ANR).
\bibliographystyle{plainnat}
|
{'timestamp': '2022-02-15T02:41:19', 'yymm': '2202', 'arxiv_id': '2202.06617', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06617'}
|
arxiv
|
\section{Introduction}
Achieving high software quality is a challenge, as witnessed for example by regular reports of economic loss caused by poor software quality~\cite{krasner2021cost}. Software testing is an essential factor for achieving high software quality~\cite{DBLP:conf/esem/SantosMCSCS17}, but unfortunately, many developers are not highly motivated to include thorough testing in their everyday work. The reasons for this are manifold, and include the low recognition of software testing in their company, testing being perceived as dull and monotonous, and tests not making a visible impact on the progress of software projects~\cite{DBLP:journals/software/WeyukerOBP00,DBLP:journals/corr/WaychalC16,DBLP:journals/infsof/DeakSS16}.
Motivation in software engineering is a common problem addressed by various approaches in the last years \cite{8370133, ryan2000self}. One promising solution to motivate developers is the concept of \emph{gamification}, which generally consists of adding game elements to non-game related tools and contexts. These game elements can be everything that is characteristic for games like the competition aspects with points, teams and leaderboards~\cite{DBLP:conf/mindtrek/DeterdingDKN11}. Gamification has been successfully applied to various parts of software engineering, including software construction and requirements, as well as in software enigneering process and management \cite{DBLP:conf/icse/BarretoF21}. We introduce \textsc{Gamekins}\xspace, a tool that applies gamification to software testing.
\textsc{Gamekins}\xspace aims to motivate developers to write more tests by integrating
gamification in \textsc{Jenkins}\xspace, one of the most popular CI environments in
industry. At the end of each build process of a software project with \textsc{Jenkins}\xspace
the source code and test results are analysed, and tasks tailored to each
developer are generated. These tasks vary from writing new tests to improving
existing code, and by solving them developers improve the quality of the test
suite.
Developers are incentivised to complete these tasks using various gamification
elements, such as points for solving tasks, being rewarded for good testing
with achievements, and competing with other developers and development teams
through a leaderboard.
The integration into \textsc{Jenkins}\xspace makes the gamification accessible to developers, who are likely already familiar with the usage of \textsc{Jenkins}\xspace and thus require no training to use \textsc{Gamekins}\xspace. This is an important point, because software projects tend to be deadline driven and developers may not have the time to explore and learn a new environment. A further advantage of implementing the gamification as a CI plugin is that source code as well as test results are readily available, and the challenges can be focused on the aspects of the code a developer is currently working on.
\section{Gamification elements}
\textsc{Gamekins}\xspace provides a variety of gamification elements, in particular challenges, quests, leaderboards and achievements.
\subsection{Challenges}
\begin{figure}
\includegraphics[width=\linewidth]{challenges}
\caption{Overview of current challenges, showing a Line-, Method- and Class Coverage-Challenge as well as a Mutation Test Challenge. The Line Coverage Challenge is expanded with the relevant code snippet for the challenge displayed.}
\label{fig:challenges}
\end{figure}
\textsc{Gamekins}\xspace provides a total of six different types of challenges, where each challenge gives the developer a specific task to solve. The following types of challenges are supported:
\begin{itemize}
%
\item \textbf{Build Challenge}: This basic challenge tasks the developer with fixing a build when it fails. Solving this challenge leads to a reward of 1 point. Currently, this kind of challenge is generated every time the build fails. We are planning to investigate alternative strategies like limiting the number of generated challenges by number or time.
%
\item \textbf{Test Challenge}: This is a generic testing challenge, which tasks the developer to write at least one more test, without narrowing down which part of the code to target with that test. Solving this challenge leads to a reward of 1 point.
%
\item \textbf{Class Coverage Challenge}: This challenge requires the developer to cover more lines of code in a chosen target class. The points awarded for this type of challenge depend on the current level of coverage: If the coverage exceeds a certain threshold (e.g., 80 \%) then the developer can gain 2 points, otherwise only 1 point.
%
\item \textbf{Method Coverage Challenge}: This challenge tasks the
developer to improve the coverage of a target method. The points awarded depend
on the current level of coverage, with 2 points awarded if coverage on the
class is already high and 1 point awarded otherwise.
%
\item \textbf{Line Coverage Challenge}: This challenge picks a specific line of code that is not fully covered, and the task is to improve coverage (i.e., either to cover the line, or to increase the branch coverage of the line). The points for a line coverage challenge again depend on the overall coverage on the class, with 3 points being awarded if coverage is already high, and otherwise 2 points.
%
\item \textbf{Mutation Test Challenge}: This challenge requires the developer to kill a specific mutant by adding or modifying a test. Since mutation challenges are the most difficult type of challenge, they are rewarded with 4 points.
%
\item \textbf{Smell Challenge}: This challenge is created by analysing the target class with \textsc{SonarLint}\xspace\footnote{\url{https://www.sonarlint.org/}} and choosing one of the found smells. Smells can be detected in both source and test files, and removing these code \cite{DBLP:books/daglib/0019908} or test \cite{van2001refactoring} smells leads to a reward of 1 to 4 points, based on the severity of the smell.
%
\end{itemize}
Clicking on a challenge in the overview (\cref{fig:challenges}) reveals additional information about the challenge, such as the code snippet mentioned in the description, as well as an explanation what to do. This is especially important for mutation challenges, where the modified source code and the original one are shown.
\subsection{Quests}
\begin{figure}
\includegraphics[width=\linewidth]{quests}
\caption{Example quest consisting of three Method Coverage Challenges, with the active one highlighted.}
\label{fig:quests}
\end{figure}
Multiple challenges can be grouped into quests, which are sequences of
individual challenges that have to be solved one after the other. The current
challenge to be solved as next step in the quest is enabled and can be expanded
to reveal more details as can be seen in \cref{fig:quests}. Successor steps
are disabled and cannot be viewed until it is their turn to be solved. The
points of the whole quest, i.e., the sum of the points of the constituent
challenges and one additional point for each step, are only added to
the score of the participant if all steps are solved successively. The
following types of quests are supported by \textsc{Gamekins}\xspace:
\begin{itemize}
%
\item \textbf{Test Quests} consist of three test challenges.
%
\item \textbf{Package Quests} consist of three different challenges in the same package.
%
\item \textbf{Class Quests} consist of three Class Coverage Challenges for the same class.
%
\item \textbf{Method Quests} consist of three Method Coverage Challenges for the same class.
%
\item \textbf{Line Quests} consist of three Line Coverage Challenges for the same class.
%
\item \textbf{Expanding Quests} consist of a Line Coverage Challenge, a Method Coverage Challenge, and a Class Coverage Challenge for the same class in this order.
%
\item \textbf{Decreasing Quests} consist of a Class Coverage Challenge, a Method Coverage Challenge, and a Line Coverage Challenge for the same class in this order.
%
\item \textbf{Mutation Quests} consist of three Mutation Challenges for the same class.
\item \textbf{Smell Quests} consist of three Smell Challenges for the same class.
%
\end{itemize}
\subsection{Leaderboards}
\begin{figure}
\includegraphics[width=\linewidth]{leaderboard}
\caption{The leaderboard for a project shows the completed challenges and achievements as well as the score of each user. In addition, each user has its own avatar and the link on the name leads to the achievements of them.}
\label{fig:leaderboard}
\end{figure}
By completing challenges and quests users gain points, and all users are ranked
on a project leaderboard as shown in \cref{fig:leaderboard}. Besides the
points, the leaderboard also shows the total number of completed challenges and
achievements to increase competition between developers. In addition to the
project leaderboard, a team leaderboard displays the overall points, challenges
and achievements gained by different teams.
\textsc{Jenkins}\xspace allows grouping projects in folders, and \textsc{Gamekins}\xspace also displays
leaderboards for folders, which enables \textsc{Gamekins}\xspace to be used beyond the
confines of an individual project. Each participant can individualize their
experience by choosing one of 50 avatars for themselves to be displayed on the
leaderboard.
\subsection{Achievements}
\begin{figure}
\includegraphics[width=0.9\linewidth]{achievements}
\caption{The list of achievements distinguishes completed, unsolved and secret achievements. Each achievement consists of a title, a description, a date when it was solved and an icon, which is coloured after the achievement is solved.}
\label{fig:achievements}
\end{figure}
Developers are rewarded for their test-achievements, i.e., when they exhibit
certain behavior or perform certain actions independent of specific
challenges. Achievements have incremental difficulty, ranging from easy tasks,
like having a test in a project, to difficult ones like achieving 100\%
coverage. \textsc{Gamekins}\xspace currently implements 63 achievements; developers get to see
a list of obtained and open achievements (\cref{fig:achievements}), but some
achievements are secret and only revealed when they are completed. Achievements
are always solved by actions of individual participants (e.g., adding new
tests). There are two types of achievements: Individual ones, like solving a
certain number of challenges, or achievements at the project level like having
a specific coverage in the project. While project level achievements are
satisfied by a commit from an individual user, every participant in the project
receives the achievement.
\section{How Gamekins works} \label{sec:workflow}
Developers commit their code changes to a version control system, which then
triggers a job in the \textsc{Jenkins}\xspace CI environment. \textsc{Jenkins}\xspace executes a build of the
job together with the tests of the project, and then invokes \textsc{Gamekins}\xspace.
\textsc{Gamekins}\xspace takes the information of the run and the version control system to
update the challenges, quests, and achievements, as well as the leaderboard.
If a developer already has open challenges or quests, \textsc{Gamekins}\xspace checks whether
these are solved and generates new ones if necessary. In addition, all
remaining unsolved achievements are checked for completion. \textsc{Gamekins}\xspace also
checks whether all currently open challenges and quests are still solvable and,
for example, the specific code fragment has not been deleted.
Whenever challenges are solved, new challenges are generated such that there is
always the same (configurable) number of open challenges. When generating a new
challenge, \textsc{Gamekins}\xspace considers only recently changed classes by the specific
developer according to the commit history. This has the advantages that it
takes less time and resources for generation as well that the developers are
already familiar with the class used for a challenge, since they changed
something in there recently. To generate a challenge, \textsc{Gamekins}\xspace first ranks all
classes of the project under test based on the current code coverage, then
probabilistically selects a class such that those with lower coverage have a
higher chance of being selected; finally, a challenge type is randomly
selected, and a random instance for this type is generated.
Mutation Test Challenges are based on information that \textsc{Gamekins}\xspace produces using
\textsc{Moco}\footnote{\url{https://github.com/phantran/moco}}, a Maven-plugin
for mutation analysis. We developed \textsc{Moco} independently of \textsc{Gamekins}\xspace
for better interchangeability and the need of the instrumented code during test
execution. \textsc{Gamekins}\xspace generates candidate Mutation Test Challenges for all live
mutants reported by \textsc{Moco}.
Quests are generated by checking the prerequisites of the possible quests (e.g., if a sufficient number of required challenges can be generated) and choosing one of them randomly. The different steps or challenges are generated as they would be stand-alone, but depending on the quest type with already chosen classes.
Developers can reject challenges and quests with the indication of a reason to
further improve \textsc{Gamekins}\xspace. Reasons may vary from difficulties to unsolvable
ones up to code fragments, which should not be tested. Already rejected
challenges will not be used again as challenges and the classes of rejected challenges
on class level will not be considered for new challenges either.
\section{Setting up Gamekins}
\begin{figure}
\includegraphics[width=\linewidth]{job_configuration}
\caption{The Configuration section of a job in \textsc{Jenkins}\xspace allows enabling \textsc{Gamekins}\xspace, the leaderboard, and the statistics, as well as management of developer teams.}
\label{fig:jobconfig}
\end{figure}
\begin{lstlisting}[float, caption=Example Jenkinsfile to configure \textsc{Gamekins}\xspace., label=lst:jenkinsfile]
pipeline {
agent any
stages {
stage('Test') {
steps {
sh 'mvn -B clean test'
}
}
stage('Mutation') {
steps {
sh 'mvn -B m0c0:moco'
}
}
}
post {
always {
gamekins jacocoCSVPath: '**/target/site/jacoco/jacoco.csv', jacocoResultsPath: '**/target/site/jacoco', mocoJSONPath: '**/target/moco/mutation/moco.json', searchCommitCount: 50
}
}
}
\end{lstlisting}
\textsc{Gamekins}\xspace can easily be added to an existing instance of \textsc{Jenkins}\xspace by using the
already compiled plugin from
the git repository\footnote{\href{http://gamekins.org}{https://gamekins.org}} or by compiling it from
source. The plugin adds a new section to the configuration of different jobs in
\textsc{Jenkins}\xspace with the purpose to enable \textsc{Gamekins}\xspace for this particular job, as shown
in \cref{fig:jobconfig}. This is the activation point of \textsc{Gamekins}\xspace and also
allows to enable different options, such as showing and hiding the leaderboard
as well as the statistics, which contains the project in an anonymized data
dump for evaluation purposes. In addition, new teams can be created and members
can be added to them. There is also a reset option, which deletes all
information collected by \textsc{Gamekins}\xspace for the project. An advanced section
contains the options to adjust the number of current challenges and quests,
which are set to three and one by default. The configuration is also available
in a stripped-down version for folders in \textsc{Jenkins}\xspace, which allows to group
projects together and therefore compete against each other across projects.
\textsc{Jenkins}\xspace provides so called \emph{Post-build Actions} or \emph{Publishers}, which are executed after the build itself, including tests, are finished. That is where \textsc{Gamekins}\xspace is triggered and therefore the publisher for \textsc{Gamekins}\xspace has to be added to the configuration in order to get it to work.
This adds four additional options to the configuration with paths to specific files in the project as well as the number of commits to be searched (see \cref{sec:workflow}). This publisher is replaced by a call to \textsc{Gamekins}\xspace if the project is configured as a \emph{Pipeline} in \textsc{Jenkins}\xspace as shown in \cref{lst:jenkinsfile}. This so called Jenkinsfile shows the workflow of the execution of a job in \textsc{Jenkins}\xspace. At first, the project itself is built and tested (Lines 4--8), with the generation of mutants afterwards (Lines 9--13). Only in the end, \textsc{Gamekins}\xspace is started with the option in lines 15--19.
A new section is also added to the configuration of each user, with a text
field containing the git names, which link commits with \textsc{Jenkins}\xspace users. In our
experience, the main reason why no challenges or quests are generated, are
wrong or missing git names. Users can also change their avatars here and
decide, whether they want to receive e-mail notifications from \textsc{Gamekins}\xspace.
Each email includes all events that happened during the last execution of
\textsc{Gamekins}\xspace, like the generation of challenges, or the completing of
achievements. Useful links are also provided to give the developer a fast and
simple opportunity to check his current progress in \textsc{Gamekins}\xspace.
\section{Conclusions}
\textsc{Gamekins}\xspace currently provides challenges regarding build failures, numbers of tests, coverage improvements and killing mutants. \textsc{Gamekins}\xspace can be integrated with both, pipeline and non-pipeline projects, in \textsc{Jenkins}\xspace for projects using Java or Kotlin with JUnit and JaCoCo. It includes various gamification elements like challenges and quests with points as rewards, achievements and leaderboards. We plan to continuously extend the challenges and other game-mechanics in \textsc{Gamekins}\xspace.
A first evaluation of \textsc{Gamekins}\xspace in an internal software project gave promising results: Over a period of five weeks, the coverage of the project increased by 7 \%, and the number of tests by almost 20 \%. The motivation of most participants to write tests increased during the evaluation phase. They also wrote more tests than usual and every participant found at least one bug in the project.
We invite researchers and practitioners to try out \textsc{Gamekins}\xspace, and to share their experience with us:\\
\centerline{\href{http://gamekins.org}{https://gamekins.org}}
\begin{acks}
This work is supported by the DFG under grant FR 2955/2-1.
\end{acks}
\newpage
\bibliographystyle{ACM-Reference-Format}
|
{'timestamp': '2022-02-15T02:39:08', 'yymm': '2202', 'arxiv_id': '2202.06562', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06562'}
|
arxiv
|
\section{Introduction}\label{sec1}
Object detection is a basic and challenging task in computer vision. CNN algorithms are required to obtain each instance of interest in an image, as well as bounding boxes with category labels. Currently, object detection algorithms have shifted from conventional methods to deep learning-based algorithms, such as YOLO\cite{redmon2016you}, SSD\cite{liu2016ssd}, and Fast RCNN\cite{girshick2015fast}. These algorithms have achieved significant success in the detection of horizontal objects. However, if an object inclines significantly, as shown in Figure \ref{fig1} (a), the bounding box detected by these horizontal detectors contains a lot of background, which decreases the accuracy when describing the object information. Moreover, when multiple objects of the same category are very close, the horizontal bounding box will include parts of multiple objects, which may be misjudged as the same object in the later processing stage of the model, leading to misdetection. To overcome these problems, existing studies\cite{jiang2017r2cnn,ma2018arbitrary,liao2017textboxes,liao2018textboxes++,zhou2020arbitrary,2021Oriented} have modified the mainstream horizontal object detector to detect oriented objects, including by increasing predictions of angle or position of four corner points directly to represent oriented objects. Although better results have been achieved, some issues remain. These issues can be caused either by the horizontal object detector or by defects in the model design. The detection performance of an anchor-based detector\cite{ma2018arbitrary,liao2017textboxes,xu2020gliding} has certain requirements regarding the size, aspect ratio, and quantity of anchors. Further, although the ratio and aspect ratio of the anchors remain unchanged after initialisation, even with elaborate design, it is difficult to deal with candidates with large shape changes, specifically for targets in oriented objects. Moreover, a predefined positioning framework can hinder the generalisation ability of the detector. For example, the YOLOv3\cite{redmon2018yolov3} anchor clustering based on different data cannot be applied to objects with large sizes or reduced aspect ratios. To achieve a higher average precision rate, the anchor-based detector RRPN was established\cite{ma2018arbitrary}. Due to differences in angles, anchors must be placed densely on the input image, providing many parameters for model calculation. However, these anchors increase the number of negative samples, which leads to an imbalance between the positive and negative samples for training. Although in other methods\cite{zhou2020arbitrary,2021Oriented,zhou2017east} the directly predicted angle reached a high mAP, they still have the problem of inaccurate angle prediction. More specifically, the angle difference between the predicted and real values should be minimal. Although the slant border based on this angle can locate an object, as shown in Figure \ref{fig1} (a), the accuracy of the final model is reduced.
In this study, we developed a single-stage rotating object detector via two points with a solar corona heatmap (ROTP). Traditional detectors use an anchor-based mechanism based on the regression angle, object size, and corner coordinates. In contrast to the two modes of most popular oriented detectors, our proposed ROTP adopts two key points to detect targets. As shown in Figure \ref{fig1} (b), by locating the two key points of the vertex and the centre, as well as predicting the size of the target, a simple mapping function can be used to generate a slanted rectangular border of the oriented objects. To achieve this, the ROTP outputs five feature maps, including a heatmap of the centre point and vertex, and predicts the target centre and vertex positions using keypoint detection. The other feature maps indicate the long and short sides of a target, the offsets of the key points, and the direction of the vertex relative to the central point.
Our contributions in this paper can be summarized as follows:
\begin{enumerate}
\item We propose a single-stage rotating object detector via two points with a solar corona heatmap (ROTP). ROTP uses the predicted vertex and centre points to describe the oriented object, which avoids the regression error caused by direct prediction of the angle. It also replaces angle prediction with prediction of the relative direction, thus improving the accuracy to describe the orientation of objects.
\item We designed a solar corona heatmap (SCH) based on the spatial position relationship to predict the centre point more accurately for slender objects. This method considers the large aspect ratio of remote sensing objects, which has a more robust performance than Gaussian heatmaps.
\item Our method obtains preferable precision with more semantic design and fewer hyperparametric designs compared with other classical-oriented object detection methods based on deep learning.
\end{enumerate}
The rest of this paper is organised as follows: Section 2 reviews related work in the field of horizontal object detection and oriented object detection. Section 3 presents the overall framework of the proposed ROTP model in detail, as well as the function design. Implementation details, comparison experiments, and ablation studies are presented in Section 4, then conclusions are drawn in Section 5.
\begin{figure}[H]
\includegraphics[scale=0.6]{intro1.pdf}
\centering
\caption{(a) Deviation that inevitably occurs when only the angle is predicted in rotating target detection. (b) Addition of predicted top position, which enhances accuracy of bounding boxes.
}
\label{fig1}
\end{figure}
\section{Related Work}\label{sec2}
Many excellent oriented object detectors are based on horizontal object detectors. In this section, we first introduce horizontal object detection methods and then introduce oriented object detection methods.
\noindent\textbf{Horizontal object detection.}
Object detection aims to detect each object in natural scene images with a rectangular border. Deep learning, which has a broad range of applications \cite{DBLPXing,9565320,IJCAI20Fanzhen}, has already been successfully applied in object detection. Current classical deep learning-based methods can be summarised as single-stage and two-stage methods. The single-stage method directly predicts all objects, whereas the two-stage method is subdivided based on preliminary predictions. Therefore, although the two-stage method is more accurate, it is also slower. These methods can be further categorised into anchor-based and anchor-free methods. Specifically, the anchor-based two-stage model represented by RCNN\cite{2014}, Fast RCNN\cite{girshick2015fast} and faster RCNN\cite{2016Faster} set multiscale anchor boxes in advance, which can be understood as a series of candidate regions of scales and sizes. First, they generate ROIs and then use features of the ROI to predict object categories. SSD\cite{liu2016ssd}, YOLOv2\cite{redmon2017yolo9000} and its variants\cite{redmon2018yolov3} are representative single-stage anchor-based methods. There is no candidate ROI area, and the classification and regression results are regressed in the final stage. Specifically, SSD\cite{liu2016ssd} combines the advantages of two-stage and single-junction segments to achieve a balance between speed and precision. Subsequently, Retinanet\cite{lin2017focal} and DSSD\cite{2017DSSD} are used to fuse multiscale features in the model to further improve the detection accuracy. In addition, anchor-free methods are becoming popular, including FoveaBox\cite{2019FoveaBox}, RepPoints\cite{2019RepPoints} and FCOS\cite{tian2019fcos}based on per-pixel detection, while heatmaps were introduced in \cite{law2018cornernet} and Centernet\cite{zhou2019objects} for object detection to achieve object-to-key mapping. These detection methods simplify the network structure by removing the anchors and improving the detection speed, and provide a new research direction to detect objects. Nevertheless, the abovementioned object detection methods only generate position information in the horizontal or vertical directions, which limits their universality. For example, in scene text and other rotating object images, the aspect ratio of the instance is relatively large, the arrangement is dense, and the direction is arbitrary, which requires more accurate position information to describe these objects. Therefore, oriented object detection has gradually become a popular research direction.
\noindent\textbf{Oriented object detection.}
Owing to the huge scale changes and arbitrary directions, detecting oriented targets is challenging. Extensive research has been devoted to this task. Many oriented object detectors have been proposed based on horizontal object detectors. RRPN\cite{ma2018arbitrary} and $ R^2CNN $\cite{jiang2017r2cnn} are the classical methods. Based on Fast RCNN\cite{girshick2015fast}, $ R^2CNN $ \cite{jiang2017r2cnn} raises two pooling sizes and an output branch to predict the corner positions. RRPN\cite{ma2018arbitrary} achieved better prediction results by adding rotating anchors at different angles. Based on
SSD\cite{liu2016ssd}, textboxes\cite{liao2017textboxes} and textboxes++\cite{liao2018textboxes++} have been proposed. According to the characteristics of slender text lines, a rectangular convolution kernel was proposed, and the results of the instance are regressed by the vortices. RRD\cite{2018Rotation} predicts a rotating object based on the invariance property of rotation features, improving the accuracy of regression of long text. EAST\cite{zhou2017east} had a U-shaped network\cite{2015U} and predicted the border with angle and the four corner positions of the instance simultaneously. The above methods are applicable to the field of scene text detection, whereas aerial remote sensing target detection is more difficult. Compared with text lines, remote sensing targets have many categories, such as complex background, multiscale, and a large number of dense small targets. Many robust oriented target detectors have emerged based on horizontal detectors. For example, ROI-Transformer\cite{ding2018learning} extracts rotation-invariant features on the ROI, which increases the accuracy of the next step of classification and regression. ICN\cite{azimi2018towards} combines pyramid and feature pyramid modules and achieves good results on remote sensing datasets. The glide vertex\cite{xu2020gliding} predicts the deviation of the four angled corner points at the horizontal border to obtain a more accurate direction bounding box. P-RSDet\cite{zhou2020arbitrary} and BBVector\cite{2021Oriented} introduced the anchor free heatmap detection method into oriented target detection to achieve a fast and accurate detection effect.
The above anchor free rotation detector still uses the method of horizontal target mapping heatmap, and does not take into account the problem that Gaussian heatmap is prone to position perception deviation on high aspect ratio targets.
\begin{figure}[H]
\includegraphics[scale=0.6]{arch.pdf}
\centering
\caption{ROTP architecture. The ROTP is divided into three parts: backbone, neck, and head. When an image with the size of WxHx3 is input into our model, it will output five feature maps, among which two are heatmaps for predicting the centre points and vertices, and the other three are regression for the targets’ size, coordinates bias, and direction, respectively. Finally, all key points are matched to obtain the final output.
}
\label{fig2}
\end{figure}
\section{Proposed Method}\label{sec3}
Herein, we first elaborate on the instance representation of our method and then describe the SCH generation. Finally, we present details of the proposed ROTP and its loss function.
\begin{figure}[H]
\includegraphics[scale=0.6]{relate.pdf}
\centering
\caption{Current work only considers the angle of the boundary box relative to the image coordinate system, as shown in (a) and (b), but does not consider the real orientation of the object. The red border in (c) represents the groundtruth, and the purple border is the predicted. The predicted border covers the whole target, but the IOU between it and the groundtruth seems large. As shown in (d), a coordinate system was established for each target. The centre point of the target is coordinate point zero, and the angle represents the included angle of the vector between the vertex and the centre point relative to the positive direction of the X-axis.
}
\label{fig3}
\end{figure}
\subsection{Instance Representation}\label{subsec1}
Oriented objects can generally be expressed by two patterns, which can be used interchangeably. The first type of pattern is represented by $ (x_1, y_1) $ , $ (x_2, y_2) $ , $ (x_3, y_3) $ , and $ (x_4, y_4) $ in the order of four clockwise corners, and the second type is $ (x, y, w, h, \alpha) $, where $ (x, y) $ represents the center point, w and h are the width and height of the target, $ \alpha $ represents the rotation angle of the target.In this study, oriented objects are modelled with two key points: $ (\sum_{i=1}^{4}{x_i/4,}\sum_{i=1}^{4}{y_i/4}) $ , which is the centre point $ (x_c, y_c) $ , and $ (\sum_{i=1}^{2}{x_i/2,}\sum_{i=1}^{2}{y_i/2}) $ , which is the vertex $ (x_t, y_t) $.
From the introduction in the previous section, we use the vertex, centre point, and length and width to represent a target. First, $ (x_c^i, y_c^i) $ , which represents the coordinate of the centre point from the heatmap, is extracted. Here, $ i $ represents the index of the targets. Thereafter, $ (x_t^i, y_t^i) $, which represents the positions of all vertices, is extracted. Because datasets are labelled with the problem of inaccuracy, the vertex label is occasionally marked on the background area, and the training input for the vertex coordinates is 0.9 times the coordinates along the centre point. To combine the centre point and the corresponding vertices, we added a prediction head in order to predict the direction of the vertices relative to the centre point, as shown in Figure \ref{fig3} (a) and (b). Previous studies only focused on the target bounding box angle in the image coordinate system and but ignored the targets; although this approach decreases the predicted angle range, the value of angle loss value may suddenly increase during the calculation, \cite{2019Learning}. In this paper, we propose a relative direction that is not based on an image coordinate system but is rather based on our well-designed coordinate system of the centre of the object. As shown in Figure \ref{fig3} (d), the relative direction can be expressed as the included angle between the vector from the vertex to the centre and with respect to the positive X-axis. The relative direction is calculated using the following formula:
\begin{small}
\begin{equation}
\theta_i=\left\{\begin{matrix}
\frac{180}{\pi}\arccos\frac{{x_t}^i-{x_c}^i}{\sqrt{({x_t}^i-{x_c}^i)^2 + ({y_t}^i-{y_c}^i})^2}&{x_t}^i-{x_c}^i\geq 0,{y_t}^i-{y_c}^i\geq 0 \\
\frac{180}{\pi}\arccos\frac{{x_t}^i-{x_c}^i}{\sqrt{({x_t}^i-{x_c}^i)^2 + ({y_t}^i-{y_c}^i})^2}&{x_t}^i-{x_c}^i > 0,{y_t}^i-{y_c}^i > 0 \\
360 - \frac{180}{\pi}\arccos\frac{{x_t}^i-{x_c}^i}{\sqrt{({x_t}^i-{x_c}^i)^2 + ({y_t}^i-{y_c}^i})^2}&{x_t}^i-{x_c}^i\leq 0,{y_t}^i-{y_c}^i\leq 0 \\
360 - \frac{180}{\pi}\arccos\frac{{x_t}^i-{x_c}^i}{\sqrt{({x_t}^i-{x_c}^i)^2 + ({y_t}^i-{y_c}^i})^2}&{x_t}^i-{x_c}^i > 0,{y_t}^i-{y_c}^i < 0 \\
\end{matrix}\right.
\end{equation}
\end{small}
The relative direction $ \theta_i $ is defined as ranging from 0 to 360. We first establish the vector from the centre point $ (x_c,y_c) $ to the vertex $ (x_t,y_t) $, and then calculate the cosine of the positive angle $ \alpha $ between the vector and the X-axis according to Eq\ref{eqcosa}. We then obtain the radian through the inverse trig function . Finally, according to the position of the vertex relative to the central point, the vertex is mapped to the four quadrants with the central point as the origin, and the relative direction is determined. The advantage of this method is that the angle is regarded as a constant with the same scale as that of the target, and the regression prediction can be directly performed without additional processing.
\begin{equation}
\cos\alpha=\frac{{x_t}-{x_c}}{\sqrt{({x_t}-{x_c})^2 + ({y_t}-{y_c}})^2}
\label{eqcosa}
\end{equation}
In the training stage, the direction of the tagets was optimized with a smooth $ L_1 $ loss as follows:
\begin{equation}
L_{D} = \frac{1}{N}\sum_{i=1}^NSmooth_{L_1}(\theta_i - \acute{\theta_i})
\end{equation}
Where $ N $ is the number of whole peak elements, $ \theta_i $ refers to the direction of instance, $ \acute{\theta_i} $ denotes the prediction of direction, and i denotes the index of all objects in a batch. The smooth $ L_1 $ loss is represented as follows:
\begin{equation}
f(x) = \left\{\begin{matrix}
0.5x^2&|x|<1 \\
|x| - 0.5 & otherwise\\
\end{matrix}\right.
\end{equation}
\begin{figure}[H]
\includegraphics[scale=0.6]{hm.pdf}
\centering
\caption{Large quantities of edge feature information are lost in the Gaussian heatmap when describing a rotating target with a large aspect ratio, as shown in (b) and (d). When the object is very narrow, the model can only learn a small amount of information available near the centre point. Our heatmap method, as shown in (a) and (c), enables the model to learn information at the edges of objects while learning information around the centre point. Panels (e) and (f) show the heatmap with colours.}
\label{fig4}
\end{figure}
\subsection{Solar Corona Heatmap}\label{subsec2}
Existing studies on key point detections have mostly used the Gaussian kernel function, $ Y_{hm}=\exp^{-\frac{(x-x_p)^2+(y-y_p)^2}{2\delta^2}} $ to mapping objects into heatmap $ Y\in {[0,1]}^{\frac{W}{d}\times\frac{H}{d}\times C} $, where $ (x_c, y_c) $ represents the coordinates of the centre point, $ (x_p,y_p) $ is an element on heatmap, and $ \sigma $ is the radius of the Gaussian kernel. When mapping a remote-sensing object into a Gaussian heatmap, as shown in Figure \ref{fig4} (b) and (d), the heatmap area only accounts for a small part of the ground truth bounding box when the target is extremely slender (for example, large trucks, bridges, and some designated ships). In the case of a large aspect ratio, the radius of the heatmap is small, and the resulting area would be small. For long and block objects without obvious texture changes, the detector may miscalculate the peak value at the top or tail during reasoning, which is detrimental to oriented object detection. Such defects are also reflected in the horizontal heatmap detector; thus, the detector should be able to better learn the peak value of the heatmap. Centernet\cite{zhou2019objects} performs many data enhancement operations, such as cutting, reversing, and translating, to ensure the accuracy of the detector. For remote sensing images, as the objects are small and dense, such data enhancement operations will lower the accuracy of the detector. Therefore, this study proposes a spatial perception heatmap to address this problem, as shown in Figure \ref{fig4} (a). As shown in Figure \ref{fig4} (c), the heatmap radius based on half of the longer side can include all objects. In the scenario of dense objects, this method judges the peak value of the surrounding objects into a low confidence level area. Thus, our solar corona heatmap is based on both the short and long sides; therefore, it retains the weights of the surrounding area of the centre point and perceives the area of the head and tail. The formula used is as follows:
\begin{equation}
H_c = \frac{1}{2}(e^{-\frac{(x_p-x_c)^2+(y_p-y_c)^2}{\mu_1 \times h}}+e^{-\frac{(x_p-x_c)^2+(y_p-y_c)^2}{\mu_1 \times w}})\ (x_p,y_p)\in T
\end{equation}
\begin{equation}
H_t = e^{-\frac{(x_p-x_t)^2+(y_p-y_t)^2}{\mu_1 \times h}}
\end{equation}
Where $ H_c $ is the heatmap of center point, $ H_t $ means the heatmap of vertex point, $ w $ is the side length with the smallest difference from the value of twice the distance from the vertex to the centre point, and $ h $ is another side length. $ T $ represents the entire point-group of an instance. In this study, we used $ \mu = 0.125 $ in all the experiments. In the training stage, only the peak points were positive. All other points, including those in the Gaussian bulge, were negative. The model learns only one point, and the loss function does not usually converge because the number of positive samples is not sufficient compared with the number of background samples. To deal with this issue, Eq\ref{eqhml} is used. The closer the target is to the peak point, the higher the confidence is, and the points beyond a certain range are, the lower the confidence is ; thus, the gap between the peak point and other points can be measured effectively. The variant focal loss is used to calculate the ground truth and prediction.
\begin{equation}
L_{hm}=-\frac{1}{N_{pos}}\sum_{ps}\left\{\begin{matrix}
(1-\rho_{ps})^\alpha\log(\rho_{ps})&\acute{\rho_{ps}} = 1 \\
(1-\acute{\rho_{ps}})^\beta(\rho_{ps})^\alpha\log(1 - \rho_{ps})&\acute{\rho_{ps}} \neq 1 \\
\end{matrix}\right.
\label{eqhml}
\end{equation}
where $ N_{pos} $ represents the number of pixels covered by the heatmap, $ \rho_{ps} $ represents the predicted confidence, $ \acute{\rho_{ps}} $ represents the ground truth, $ \alpha $ and $ \beta $ are adjustable parameters that are used to ensure that the model can better learn the pixels with different confidence levels; their values are set to 2 and 4, respectively, in this study.
\subsection{Offset}\label{subsec3}
When in the inference stage, the position of the maximum confidence points from the centre heatmaps is extracted as the central position of the objects, and the position of the maximum confidence points from vertex heatmaps is extracted as the vertex of the objects. However, the difference between the sizes of the output heatmaps and the input images is four times larger . Because the coordinate position can only be an integer, floating point deviation loss will occur in the mapping process, which affects the positioning of slender oriented objects. To compensate for the floating point bias loss, we predict the offset map $ O\in {R}^{4\times\frac{W}{d}\times\frac{H}{d}\times C} $. Given the peak point $ \widetilde{c}=(\widetilde{c_x},\widetilde{c_y}) $ and $ \widetilde{t}=(\widetilde{t_x},\widetilde{t_y}) $ in each input image, the floating point deviation value $ O $ is calculated using the following formula:
\begin{equation}
O = [ \frac{\widetilde{c_x}}{d} - \lfloor\frac{\widetilde{c_x}}{d}\rfloor,\frac{\widetilde{c_y}}{d} - \lfloor\frac{\widetilde{c_y}}{d}\rfloor,\frac{\widetilde{t_x}}{d} - \lfloor\frac{\widetilde{t_x}}{d}\rfloor,\frac{\widetilde{t_y}}{d} - \lfloor\frac{\widetilde{t_y}}{d}\rfloor ]
\end{equation}
In this study, targets of the same category share one vertex float offset and one centre float offset. In the training stage, the offset is optimised with a smooth $ L_1 $ loss as follows.
\begin{equation}
L_{offsets} = \frac{1}{N}\sum_{i=1}^NSmooth_{L_1}(O_i - \acute{O_i})
\end{equation}
\subsection{Framework}\label{subsec4}
Figure \ref{fig2} illustrates the overarching pipeline of the proposed ROTP. The network architecture is divided into three parts: the backbone, neck, and output heads. In addition, the formulation of the input image size is $ I\in {R}^{H \times W \times 3} $, where $ W $ and $ H $ are the width and height, respectively, of the input image. The input image is first sent to the backbone for the convolution operation to obtain feature maps’ these feature maps are then sent to the neck. In the present study, ResNet101\cite{he2016deep} was selected as the ROTP encoder-decoder. The neck is a deformed FPN structure. The FPN extracts different feature maps of the receptive field. To ensure that the detector detects large and small targets simultaneously, the feature maps are combined with up-sampling before being sent to the heads. ROTP outputs five feature maps of size $ F\in {R}^{\frac{W}{d}\times\frac{H}{d}\times S} $, where $ S $ is the degree of depth of the corresponding prediction of outputs, and $ d $ is the output step size, which was set to four in this study. Of the five output maps, one is the vertex predicted in the form of a heatmap $ (T\in {R}^{\frac{W}{d}\times\frac{H}{d}\times cls}) $, and the other$ (C\in {R}^{\frac{W}{d}\times\frac{H}{d}\times cls}) $ is the centre point predicted by the heatmap form; the other three are the length and width of the regression target $ (Reg\in {R}^{\frac{W}{d}\times\frac{H}{d}\times 2}) $, the offsets of the peaks$ (O\in {R}^{\frac{W}{d}\times\frac{H}{d}\times 4}) $, and the direction of the vertex $ (D\in {R}^{\frac{W}{d}\times\frac{H}{d}\times 1}) $ relative to the centre point.
\subsection{Loss Function}\label{subsec5}
In the training stage, the regress loss $ L_{Reg} $ of the width and height of the objects is also optimised with a smooth $ L_1 $ loss. The loss function of the proposed method is defined as follows:
\begin{equation}
L={\lambda_0L}_{ht}+\lambda_1L_{hc}+\lambda_2L_{Reg}+{\lambda_3L}_{offsets}+{\lambda_4L}_{D}
\end{equation}
$ \lambda_0 $, $ \lambda_1 $ , $ \lambda_2 $ , $ \lambda_3 $ , and $ \lambda_4 $ are the hyperparameters that balance all loss functions, where the inner $ \lambda_3 $ is 0.1, and the rest are set to 1.0; all losses except for $ L_{ht} $ and $ L_{hc} $ are calculated only when $ \rho^\prime $ is 1.0.
\section{Experiment}\label{sec4}
\subsection{Datasets}\label{subsec1}
The HRSC2016 dataset was used in the present study. In the annotation attribute of HRSC2016, there are annotations for vertex and centre point positions, and we directly use this information for training, whereas in the UCAS-AOD dataset, the marks in some images were not marked according to the four points clockwise from the top left corner of the bounding box, which misled our method. We marked the vertex first, then marked the centre point, and remarked these targets in terms of the long and short sides of the original objects. We used the DOTA datasets to verify the effectiveness of our method in various categories.
\noindent\textbf{HRSC2016}\cite{liu2016ship}
The dataset is a remote ship detection dataset, containing 1061 images marked with a rotating bounding box, ranging in size from $ 300 \times 300 $ to $ 1500 \times 900 $. The standard mAP evaluation protocol was used to evaluate the HRSC2016 dataset.
\noindent\textbf{UCAS-AOD}\cite{zhu2015orientation}
The dataset comprises 1000 aircraft images with 7482 instances and 510 car images with 7114 instances. The resolution of the UCASAOD is approximately $ 1280 \times 700 $, which is composed of a horizontal label box and a slanted label box. We used only the slanted label box for the training.
\noindent\textbf{DOTA}\cite{xia2018dota}
The dataset contains 2806 aerial images in 15 categories. In this dataset, the smallest image is $ 800 \times 800 $ and the largest is $ 4000 \times 4000 $. The training, validation, and test sets were divided into a $ 3:1:2 $ ratio. We cut the image to $ 1024 \times 1024 $ and the gap was set 200 pixels as the step size.
\subsection{Implementation Details}\label{subsec2}
In the training stage, ROTP used Resnet101\cite{he2016deep} as the backbone, the image input resolution is set to $ 800 \times 800 $ , and the size of the output feature map is $ 200\times200 $ . The image sizes of the training data differed in the present study. Ensuring that the target would not be deformed during the process of image scaling, we scaled the image without changing its aspect ratio, and zero filling was carried out for the rest. For the UCASAOD dataset, $ 70\% $ of the data were shuffled as the training set and $ 30\% $ as the test set. For the DOTA dataset, direct scaling would cause object loss owing to the high image resolution; we therefore cut the DOTA image to a $ 1024\times1024 $ size and gap set to 200. For all the data, we used random rotation, random flip, pixel transformation, and other processing methods to enhance the data. Adam\cite{kingma2014adam} acted as an optimiser for our network and uses a warmup policy, with batch size set to 4, and training to loss convergence. In the testing stage, the test images were scaled in the same way as the train images scaled in the training stage. The first 200 key points were selected, and the confidence was set to 0.25. For other datasets, we calculated AP with the default IOU parameter in PASCAL VOC\cite{everingham2010pascal}, that is, 0.5. The accuracy is used for performance evaluation, which is well sued in other data mining and machine learning tasks \cite{IJCAT2012,6729567}. All experiments were trained with Pytorch on an Nvidia RTX 2080TI GPU.
\begin{figure}[H]%
\centering
\includegraphics[width=0.8\textwidth]{result.pdf}
\caption{Visualization of the detection results of DOTA, UCAS-AOD and HRSC2016.
}
\label{fig6}
\end{figure}
\subsection{Comparisons with STATE-OF-THE-ART}\label{subsec3}
\begin{table}[h]
\begin{center}
\caption{Comparisons on DOTA between ROPT and some classcial oriented detection methods.}\label{tab1}%
\resizebox{\textwidth}{!}{
\begin{tabular}{@{}lllllllllllllllll@{}}
\toprule
Method & Pl & Bd &Br &Gft &Sv &Lv &Sh &Tc &Bc &St &Sbf &Ra &Ha &Sp &He &mAP \\
\midrule
R2CNN\cite{jiang2017r2cnn} &80.94 &65.67 &35.34 &67.44 &59.92 &50.91 &55.81 &90.67 &66.92 &72.39 &55.06 &52.23 &55.14 &53.35 &48.22 &60.67 \\
R2CNN\cite{jiang2017r2cnn} &80.94 &65.67 &35.34 &67.44 &59.92 &50.91 &55.81 &90.67 &66.92 &72.39 &55.06 &52.23 &55.14 &53.35 &48.22 &60.67 \\
ICN\cite{azimi2018towards} &81.40 &74.30 &47.70 &70.30 &64.90 &67.80 &70.00 &90.80 &79.10 &78.20 &53.60 &62.90 &67.00 &64.20 &50.20 &68.20 \\
RRPN\cite{ma2018arbitrary} &88.52 &71.20 &31.66 &59.30 &51.85 &56.19 &57.25 &90.81 &72.84 &67.38 &56.69 &52.84 &53.08 &51.94 &53.58 &61.01 \\
R-DFPN\cite{yang2018automatic} &80.92 &65.82 &33.77 &58.94 &55.77& 50.94 &54.78 &90.33 &66.34 &68.66 &48.73 &51.76 &55.10 &51.32 &35.88 &57.94 \\
RoI-Transformer\cite{ding2018learning} &\textbf{88.64} &78.52 &43.44 &\textbf{75.92} &68.81 &73.68 &\textbf{83.59} &90.74 &77.27 &81.46 &\textbf{58.39} &53.54 &62.83 &58.93 &47.67 &69.56 \\
P-RSDet\cite{zhou2020arbitrary} &88.58 &77.84 &\textbf{50.44} &69.29 &71.10 &\textbf{75.79} &78.66 &\textbf{90.88} &80.10 &81.71 &57.92 &\textbf{63.03} &66.30 &\textbf{69.77} &\textbf{63.13} &\textbf{72.30} \\
ROPT &81.17 &\textbf{84.34} &47.33 &62.65 &\textbf{71.42} &71.04 &78.09 &89.93 &\textbf{80.34} &\textbf{84.78} &44.74 &60.81 &\textbf{66.43} &69.14 &62.15 &70.29 \\
\botrule
\end{tabular}}
\end{center}
\end{table}
The results of the comparison of the performance of ROTP and some famous one-stage or two-stage oriented object detection methods on DOTA are illustrated in Table \ref{tab1}. The accuracy of our method for Bd, Sv, Bc,St, and Ha was $ 5.82\% $,$ 0.32\% $, $ 0.24\% $ , $ 3.07\% $ and $ 0.13\% $ higher, respectively, than those of the second method. The total mAP was $ 2.01\% $ lower than that of P-RSDET which is also based on the anchor free heatmap mothed. This is because the AP value of our model was very low when detecting Br and Sbf categories, resulting in a decline in overall accuracy. In addition, the accuracy of the category is competitive with that of other methods.
\begin{table}[h]
\begin{center}
\begin{minipage}{174pt}
\caption{meanAveragePrecision (\%). Comparison results between ROTP and other classical oriented object detectors on UCAS-AOD. During calculating mAP, we set IOU in 0.5 and confidence in 0.25.}\label{tab2}%
\begin{tabular}{@{}llll@{}}
\toprule
Method & Plane & Car &mAP \\
\midrule
RRPN\cite{ma2018arbitrary} & 88.04 & 74.36 & 81.2\\
$ R^2CNN $\cite{jiang2017r2cnn} &89.76 &78.89 &84.32 \\
R-DFPN\cite{yang2018automatic} &88.91 &81.27 &85.09 \\
X-LineNet\cite{wei2020x} &91.3 &- &- \\
P-RSDet\cite{zhou2020arbitrary} &92.69 &\textbf{87.38} &90.03 \\
ROPT &\textbf{95.42} &84.76 &\textbf{90.09} \\
\botrule
\end{tabular}
\end{minipage}
\end{center}
\end{table}
The results of the comparison of the performance of ROTP and other classical-oriented object detectors on the UCAS-AOD dataset are shown in Table \ref{tab2}. ROTP demonstrated a certain degree of improvement over other methods in mAP. P-RSDet also used a single-stage heatmap method to detect rotating targets and achieved a $ 90.3\% $mAP; ROTP was $ 2.73\% $ higher than P-RSDET in the aircraft category, but $ 2.62\% $ lower in the car category. We assume this to be because P-RSDET cuts the image to $ 512\times512 $ , while we scaled the image at equal proportions. Our method will make the small target size smaller, reducing the detection accuracy of the automobile category.
\begin{table}[h]
\begin{center}
\caption{Comparisons on HRSC2016 with oriented bounding boxes. Work used the VOC07 method to calculate mAP(\%)}\label{tab3}%
\begin{tabular}{@{}lllllll@{}}
\toprule
Method & $ R^2CNN $\cite{jiang2017r2cnn} & RC1\&RC2\cite{inproceedings} & Axis Learning\cite{xiao2020axis} & RRPN\cite{ma2018arbitrary} &TOSO\cite{feng2020toso} &ROTP \\
\midrule
mAP & 73.03 & 75.7 & 78.15 & 79.08 & 79.29 & \textbf{80.6} \\
\botrule
\end{tabular}
\end{center}
\end{table}
The results of the comparison of performance for HRSC2016 of ROTP and other mainstream deep-learning-based methods are shown in Table \ref{tab3}. R2CNN adds multi-scale ROI pooling and inclined frame detection based on FastRCNN, achieving an AP of 73.07. The RRPN introduced several tilted anchors and reached 79.08 AP, while our model reached 80.6 AP, representing a certain improvement over the above algorithm. However, shortcomings are also present that require many data enhancement strategies to ensure the uptake of positive samples.
\subsection{Ablation Studies}\label{subsec3}
We examine the availability of the proposed method from three perspectives: the separate use of angles or angles with key points, different encoder-decoders, and different heatmap generation methods.
\begin{table}[h]
\begin{center}
\begin{minipage}{174pt}
\caption{Comparison on different Encoder-Decoder.}\label{tab4}%
\begin{tabular}{@{}llll@{}}
\toprule
Encoder-Decoder & Plane & Car &mAP \\
\midrule
Unet\cite{2015U} & 93.69 &86.15 &89.92\\
104-Hourglass\cite{2016Stacked} & 96.34&88.56 \\
ROPT &95.42 &84.76 &90.09 \\
\botrule
\end{tabular}
\end{minipage}
\end{center}
\end{table}
\noindent\textbf{Different encoders and decoders:}
In ROTP, we used the improved Restnet101 with FPN as the encoders and decoders, as shown in Table \ref{tab4}. To test the impact of different encoders and decoders on our model, we replaced the previous Heads architecture with the network architecture of Unet and 104-Hourglass. We conducted experiments using the UCASAOD dataset. As shown in the table, the AP of our codec is $ 1.73\% $ higher than that of Unet in the aircraft category, but that of Unet is $ 1.43\% $ higher than that of our codec in the automobile category. This result is caused by the network structure. To keep the ROTP robust in the detection of targets at different scales, the network structure is built by combining different feature maps from the FPN; this is well reflected in the airplane image. However, in the car image, the change in the size of the car target is small, which can be understood to be a small target. After resizing, the car image becomes smaller, and a feature image with a large receptive field will lose information for the small target, which will cause little interference to the feature image after combination. However, unit-smooth convolution processing does not involve this shortcoming. In addition, using hourglass as the backbone improves the mAP by $ 2.36\% $ over that of Resnet101. The experiments show that the proposed improved network structure is effective.
\begin{figure}[H]
\includegraphics[scale=0.6]{ablation.pdf}
\centering
\caption{Comparison of KeyPoints Match.(a) the direction is predicted without matching the corresponding vertices;(b) predict direction and match vertices}
\label{fig7}
\end{figure}
\begin{table}[h]
\begin{center}
\begin{minipage}{174pt}
\caption{Comparison between angles and keypoints with angles}\label{tab5}%
\begin{tabular}{@{}llll@{}}
\toprule
KeyPoints Match & Plane & Car &mAP \\
\midrule
Angles & 93.69 &86.15 &89.92\\
Angles and Keypoints &95.42 &84.76 &90.09\\
\botrule
\end{tabular}
\end{minipage}
\end{center}
\end{table}
\noindent\textbf{KeyPoints Match:}
In this study, we added the top prediction to the direction prediction. To demonstrate the advanced nature of our proposed method, various experiments were carried out on the UCAS-AOD. As shown in Table \ref{tab5}, when the keypoint matching method was adopted, the mAP value was $ 8.97\% $ higher than that of the angle prediction method alone. As shown in Figure \ref{fig7}, the direction prediction was not accurate for some objects, leading to failure of prediction. Therefore, the keypoint matching method is effective for ROTP.
\begin{table}[h]
\begin{center}
\begin{minipage}{174pt}
\caption{Comparison between Gauss Heatmap and Ours}\label{tab6}%
\begin{tabular}{@{}llll@{}}
\toprule
Heatmap Generation & Plane & Car &mAP \\
\midrule
Gauss Heatmap &92.26 &79.62 &85.94\\
Ours &95.42 &84.76 &90.09\\
\botrule
\end{tabular}
\end{minipage}
\end{center}
\end{table}
\noindent\textbf{Difference in Heatmaps:}
A comparison of the Solar Coron and Gaussian heatmaps is shown in Table \ref{tab6}. In the comparison experiment, a directed target detection experiment was carried out on the UCASAOD dataset. based on different heatmap generation schemes. Owing to the high aspect ratio and the differing sizes of the directed targets, Gaussian heatmaps have a low AP when treating small targets, as shown in Figure \ref{fig4}. It may also be that the original small target becomes smaller upon resizing the input images. Finally, using the Solar Corona heatmap improves the mAP by $ 4.15\% $ over that of the Gaussian heatmap, thus proving the effectiveness of our heatmap generation method.
\section{Conclusion}\label{sec5}
In the present study, an instance generation method is proposed for rotating target representation and solar corona heatmap (SCH) generation for multi-object-oriented perception. A single-stage rotating object detector via two points with a solar corona heatmap ROTP was proposed for rotating object detection. Via simultaneous vertex and centre point detection, ROTP can avoid the position offset caused by the direct prediction angle, and the model can achieve good results without complex pre-design without using anchors and can detect key points. This method enables ROTP to quickly detect densely arranged objects of different sizes , such as cars, boats, and small planes. Experimental results on multiple datasets indicate that the modelling of rotation detectors based on vertices and centre points is effective. However, this study also has shortcomings. If the central area of the target to be detected is covered, ROTP will not be able to capture the real central position of the instance, resulting in detection failure. In addition, our attempted to use ROTP to detect scene text images\cite{2015ICDAR2015,karatzas2013icdar} did not have a satisfactory result. The real centre point of a text sentence cannot be captured based on a single central heatmap. In fact, detection targeting of a single character is the correct way to use a single-stage heatmap to detect scene text. In future work, researchers are encouraged to mark the vertices of the rotating target or other useful key points, and we hope to extend this work to the field of 3D detection and tracking.
|
{'timestamp': '2022-02-15T02:39:19', 'yymm': '2202', 'arxiv_id': '2202.06565', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06565'}
|
arxiv
|
\section{Network Architecture Details}
\subsection{Geometric Structure Embedding}
\label{supp:rge}
First, we provide the detailed computation for our geometric structure embedding.
The geometric structure embedding encodes distances in superpoint pairs and angles in superpoint triplets.
Due to the continuity of the sinusoidal embedding function~\cite{vaswani2017attention}, we use it instead of learned embedding vectors to compute the pair-wise distance embedding and the triplet-wise angular embedding.
Given the distance $\rho_{i, j} \tight{=} \lVert \hat{\textbf{p}}_i - \hat{\textbf{p}}_j \rVert_2$ between $\hat{\textbf{p}}_i$ and $\hat{\textbf{p}}_j$, the pair-wise distance embedding $\textbf{r}^D_{i, j}$ is computed as:
\begin{equation}
\left\{
\begin{aligned}
r^D_{i, j, 2k} & = \sin(\frac{d_{i, j} / \sigma_d}{10000^{2k / d_t}}) \\
r^D_{i, j, 2k+1} & = \cos(\frac{d_{i, j} / \sigma_d}{10000^{2k / d_t}})
\end{aligned},
\right.
\end{equation}
where $d_t$ is the feature dimension, and $\sigma_d$ is a temperature which controls the sensitivity to distance variations.
The triplet-wise angular embedding can be computed in the same way.
Given the angle $\alpha^k_{i, j}$, the triplet-wise angular embedding $\textbf{r}^A_{i, j, k}$ is computed as:
\begin{equation}
\left\{
\begin{aligned}
r^A_{i, j, k, 2x} & = \sin(\frac{\alpha^k_{i, j} / \sigma_a}{10000^{2x / d_t}}) \\
r^A_{i, j, k, 2x+1} & = \cos(\frac{\alpha^k_{i, j} / \sigma_a}{10000^{2x / d_t}})
\end{aligned},
\right.
\end{equation}
where $\sigma_a$ is another temperature to control the sensitivity to angular variantions.
\subsection{Point Matching Module}
For completeness, we then provide the details of the optimal transport layer~\cite{sarlin2020superglue} in the point matching module.
For each superpoint correspondence $(\hat{\textbf{p}}_{x_i}, \hat{\textbf{q}}_{y_i})$, its local point correspondences are extracted from their local patches $\mathcal{G}^{\mathcal{P}}_{x_i}$ and $\mathcal{G}^{\mathcal{Q}}_{y_i}$.
We first compute a cost matrix $\textbf{C}_i \tight{\in} \mathbb{R}^{n_i \times m_i}$ using the feature matrices of the two patches:
\begin{equation}
\textbf{C}_i = \textbf{F}^{\mathcal{P}}_{x_i} (\textbf{F}^{\mathcal{Q}}_{y_i})^T / \sqrt{\tilde{d}},
\end{equation}
where $n_i = \lvert \mathcal{G}^{\mathcal{P}}_{x_i} \rvert$, $m_i = \lvert \mathcal{G}^{\mathcal{Q}}_{y_i} \rvert$.
The cost matrix $\textbf{C}_i$ is then augmented to $\bar{\textbf{C}}_i \medium{\in} \mathcal{R}^{(n_i + 1) \times (m_i + 1)}$ by appending a new row and a new column filled with a learnable dustbin parameter $\alpha$ as in~\cite{sarlin2020superglue}.
The point matching problem can then be formulated as an optimal transport problem which maximizes $\sum_{j, k} \bar{\textbf{C}}_i \cdot \bar{\textbf{Z}}_i$, where $\bar{\textbf{Z}}_i \medium{\in} \mathcal{R}^{(n_i + 1) \times (m_i + 1)}$ is the soft assignment matrix satisfying:
\begin{align}
\sum_{k=1}^{m_i + 1} \bar{z}^i_{j, k} = \begin{cases}
1, & 1 \leq j \leq n_i \\
m_i, & j = n_i + 1
\end{cases}, \\
\sum_{j=1}^{n_i + 1} \bar{z}^i_{j, k} = \begin{cases}
1, & 1 \leq k \leq m_i \\
n_i, & k = m_i + 1
\end{cases}.
\end{align}
Here $\bar{\textbf{Z}}_i$ can be solved by the differentiable Sinkhorn algorithm~\cite{sinkhorn1967concerning} with doubly-normalization iterations:
\begin{align}
{}^{(t)}u^i_j & = \log \alpha^i_j - \log \sum_{k=1}^{m_i+1} \exp(\bar{c}^{\hspace{1pt}i}_{j, k} + {}^{(t-1)}v^i_k), \\
{}^{(t)}v^i_k & = \log \beta^i_k - \log \sum_{j=1}^{n_i+1} \exp(\bar{c}^{\hspace{1pt}i}_{j, k} + {}^{(t)}u^i_j),
\end{align}
where
\begin{align}
\alpha^i_j & = \begin{cases}
\frac{1}{n_i + m_i}, & 1 \leq j \leq n_i \\
\frac{m_i}{n_i + m_i}, & j = n_i + 1
\end{cases}, \\
\beta^i_k & = \begin{cases}
\frac{1}{n_i + m_i}, & 1 \leq k \leq m_i \\
\frac{n_i}{n_i + m_i}, & k = m_i + 1
\end{cases}.
\end{align}
The algorithm starts with ${}^{(0)}\textbf{u} \medium{=} \textbf{0}^{n_i + 1}$ and ${}^{(0)}\textbf{v} \medium{=} \textbf{0}^{m_i + 1}$. The assignment matrix $\bar{\textbf{Z}}_i$ is then computed as:
\begin{equation}
\bar{z}^{\hspace{1pt}i}_{j, k} \medium{=} \exp(\bar{c}^{\hspace{1pt}i}_{j, k} + u^i_j + v^i_k) \medium{\cdot} (n_i \tight{+} m_i).
\end{equation}
We run $t_0 \medium{=} 100$ Sinkhorn iterations following~\cite{sarlin2020superglue}.
$\bar{\textbf{Z}}_i$ is then recovered to $\textbf{Z}_i \medium{\in} \mathbb{R}^{n_i \times m_i}$ by dropping the last row and the last column, which is used as the confidence matrix of the candidate matches.
The local point correspondences are extracted by mutual top-$k$ selection on $\textbf{Z}_i$.
We ignore the matches whose confidence scores are too small (\ie, $z^i_{x_j, y_j} \tight{<} 0.05$).
The hyper-parameter $k$ controls the number of point correspondences as described in~\cref{supp:details}.
At last, the final global dense point correspondences are generated by combining the local point correspondences from all superpoint correspondences together.
\subsection{Network Configurations}
\label{supp:details}
\paragraph{Backbone.}
We use a KPConv-FPN backbone for feature extraction.
The grid subsampling scheme~\cite{thomas2019kpconv} is used to downsample the point clouds.
Before being fed into the backbone, the input point clouds are first downsampled with a voxel size of $2.5\text{cm}$ on 3DMatch and $30\text{cm}$ on KITTI.
The voxel size is then doubled in each downsampling operation.
We use a 4-stage backbone for 3DMatch and a 5-stage backbone for KITTI because the point clouds in KITTI are much larger than those in 3DMatch.
The configurations of KPConv are the same as in~\cite{huang2021predator}.
And we use group normalization~\cite{wu2018group} with $8$ groups after the KPConv layers.
The detailed network configurations are shown in \cref{table:architecture}.
\begin{table}[!t]
\scriptsize
\setlength{\tabcolsep}{5pt}
\centering
\begin{tabular}{c|c|c}
\toprule
Stage & 3DMatch & KITTI \\
\midrule
\multicolumn{3}{c}{\emph{Backbone}} \\
\midrule
\multirow{2}{*}{1} & KPConv($1 \tight{\rightarrow} 64$) & KPConv($1 \tight{\rightarrow} 64$) \\
& ResBlock($64 \rightarrow 128$) & ResBlock($64 \rightarrow 128$) \\
\midrule
\multirow{3}{*}{2} & ResBlock($64 \rightarrow 128$, strided) & ResBlock($64 \rightarrow 128$, strided) \\
& ResBlock($128 \rightarrow 256$) & ResBlock($128 \rightarrow 256$) \\
& ResBlock($256 \rightarrow 256$) & ResBlock($256 \rightarrow 256$) \\
\midrule
\multirow{3}{*}{3} & ResBlock($256 \rightarrow 256$, strided) & ResBlock($256 \rightarrow 256$, strided) \\
& ResBlock($256 \rightarrow 512$) & ResBlock($256 \rightarrow 512$) \\
& ResBlock($512 \rightarrow 512$) & ResBlock($512 \rightarrow 512$) \\
\midrule
\multirow{3}{*}{4} & ResBlock($512 \rightarrow 512$, strided) & ResBlock($512 \rightarrow 512$, strided) \\
& ResBlock($512 \rightarrow 1024$) & ResBlock($512 \rightarrow 1024$) \\
& ResBlock($1024 \rightarrow 1024$) & ResBlock($1024 \rightarrow 1024$) \\
\midrule
\multirow{3}{*}{5} & \multirow{3}{*}{-} & ResBlock($1024 \rightarrow 1024$, strided) \\
& & ResBlock($1024 \rightarrow 2048$) \\
& & ResBlock($2048 \rightarrow 2048$) \\
\midrule
\multirow{2}{*}{6} & \multirow{2}{*}{-} & NearestUpsampling \\
& & UnaryConv($3072 \rightarrow 1024$) \\
\midrule
\multirow{2}{*}{7} & NearestUpsampling & NearestUpsampling \\
& UnaryConv($1536 \rightarrow 512$) & UnaryConv($1536 \rightarrow 512$) \\
\midrule
\multirow{2}{*}{8} & NearestUpsampling & NearestUpsampling \\
& UnaryConv($768 \rightarrow 256$) & UnaryConv($768 \rightarrow 256$) \\
\midrule
\multicolumn{3}{c}{\emph{Superpoint Matching Module}} \\
\midrule
1 & Linear($1024 \rightarrow 256$) & Linear($2048 \rightarrow 128$) \\
\midrule
\multirow{2}{*}{2} & GeometricSelfAttention(256, 4) & GeometricSelfAttention(128, 4) \\
& FeatureCrossAttention(256, 4) & FeatureCrossAttention(128, 4) \\
\midrule
\multirow{2}{*}{3} & GeometricSelfAttention(256, 4) & GeometricSelfAttention(128, 4) \\
& FeatureCrossAttention(256, 4) & FeatureCrossAttention(128, 4) \\
\midrule
\multirow{2}{*}{4} & GeometricSelfAttention(256, 4) & GeometricSelfAttention(128, 4) \\
& FeatureCrossAttention(256, 4) & FeatureCrossAttention(128, 4) \\
\midrule
5 & Linear($256 \rightarrow 256$) & Linear($128 \rightarrow 256$) \\
\bottomrule
\end{tabular}
\caption{
Network architecture for 3DMatch and KITTI.
}
\label{table:architecture}
\end{table}
\vspace{-10pt}
\paragraph{Superpoint Matching Module.}
At the beginning of the superpoint matching module, a linear projection is used to compress the feature dimension.
For 3DMatch, the feature dimension is $256$.
For KITTI, we halve the feature dimension to $128$ to reduce memory footprint.
We then interleave the geometric self-attention module and the feature-based cross-attention module for $N_t = 3$ times:
\begin{align}
{}^{(1)}\hat{\textbf{F}}{}^{\mathcal{P}}_{\text{self}} & = \mathrm{GeometricSelfAtt}(\hat{\mathcal{P}}, \hat{\textbf{F}}{}^{\mathcal{P}} \textbf{W}_{\text{in}}), \\
{}^{(1)}\hat{\textbf{F}}{}^{\mathcal{Q}}_{\text{self}} & = \mathrm{GeometricSelfAtt}(\hat{\mathcal{Q}}, \hat{\textbf{F}}{}^{\mathcal{Q}} \textbf{W}_{\text{in}}), \\
{}^{(t)}\hat{\textbf{F}}{}^{\mathcal{P}}_{\text{self}} & = \mathrm{GeometricSelfAtt}(\hat{\mathcal{P}}, {}^{(t-1)}\hat{\textbf{F}}{}^{\mathcal{P}}_{\text{cross}}), \\
{}^{(t)}\hat{\textbf{F}}{}^{\mathcal{Q}}_{\text{self}} & = \mathrm{GeometricSelfAtt}(\hat{\mathcal{Q}}, {}^{(t-1)}\hat{\textbf{F}}{}^{\mathcal{Q}}_{\text{cross}}), \\
{}^{(t)}\hat{\textbf{F}}{}^{\mathcal{P}}_{\text{cross}} & = \mathrm{FeatureCrossAtt}({}^{(t)}\hat{\textbf{F}}{}^{\mathcal{P}}_{\text{self}}, {}^{(t)}\hat{\textbf{F}}{}^{\mathcal{Q}}_{\text{self}}), \\
{}^{(t)}\hat{\textbf{F}}{}^{\mathcal{Q}}_{\text{cross}} & = \mathrm{FeatureCrossAtt}({}^{(t)}\hat{\textbf{F}}{}^{\mathcal{Q}}_{\text{self}}, {}^{(t)}\hat{\textbf{F}}{}^{\mathcal{P}}_{\text{cross}}).
\end{align}
All attention modules have $4$ attention heads.
In the geometric structure embedding, we use $\sigma_d \tight{=} 0.2\text{m}$ on 3DMatch and $\sigma_d \tight{=} 4.8\text{m}$ on KITTI (\ie, the voxel size in the coarsest resolution level), while $\sigma_a \tight{=} 15^{\circ}$ on both datasets.
The computation of the feature-based cross-attention for $\hat{\mathcal{P}}$ is shown in \cref{fig:supp-cross-att}.
Afterwards, we use another linear projection to project the features to $256$-d, \ie, the final $\hat{\textbf{H}}{}^{\mathcal{P}}$ and $\hat{\textbf{H}}{}^{\mathcal{Q}}$:
\begin{align}
\hat{\textbf{H}}{}^{\mathcal{P}} & = {}^{(N_t)}\hat{\textbf{F}}{}^{\mathcal{P}}_{\text{cross}} \textbf{W}_{\text{out}}, \\
\hat{\textbf{H}}{}^{\mathcal{Q}} & = {}^{(N_t)}\hat{\textbf{F}}{}^{\mathcal{Q}}_{\text{cross}} \textbf{W}_{\text{out}}.
\end{align}
\input{figures/supp-cross-att}
\vspace{-10pt}
\paragraph{Local-to-Global Registration.}
In the local-to-global registration, we only use the superpoint correspondences with at least $3$ local point correspondences to compute the transformation candidates.
To select the best transformation, the acceptance radius is $\tau_a \tight{=} 10\text{cm}$ on 3DMatch and $\tau_a \tight{=} 60\text{cm}$ on KITTI.
At last, we iteratively recompute the transformation with the surviving inlier matches for $N_r \tight{=} 5$ times, which is similar with the post-refinement process in~\cite{bai2021pointdsc}.
However, we do not change the weights of the correspondences during the refinement.
The impact of the number of iterations in the refinement is studied in \cref{supp:additional-ablation}.
\vspace{-10pt}
\paragraph{Implementation details.}
We implement and evaluate our GeoTransformer with PyTorch~\cite{paszke2019pytorch} on a Xeon Glod 5218 CPU and an NVIDIA RTX 3090 GPU.
The network is trained with Adam optimizer~\cite{kingma2014adam} for $40$ epochs on 3DMatch and $80$ epochs on KITTI.
The batch size is $1$ and the weight decay is $10^{-6}$.
The learning rate starts from $10^{-4}$ and decays exponentially by $0.05$ every epoch on 3DMatch and every $4$ epochs on KITTI.
We use the matching radius of $\tau \tight{=} 5\text{cm}$ for 3DMatch and $\tau \tight{=} 60\text{cm}$ for KITTI (\ie, the voxel size in the resolution level of $\tilde{\mathcal{P}}$ and $\tilde{\mathcal{Q}}$) to determine overlapping during the generation of both superpoint-level and point-level ground-truth matches.
The same data augmentation as in~\cite{huang2021predator} is adopted.
We randomly sample $N_g \tight{=} 128$ ground-truth superpoint matches during training, and use $N_c \tight{=} 256$ putative ones during testing.
\vspace{-10pt}
\paragraph{Correspondences sampling strategy.}
For 3DMatch, we vary the hyper-parameter $k$ in the mutual top-$k$ selection of the point matching module to control the number of the point correspondences for GeoTransformer, \ie, $k \tight{=} 1$ for $250$/$500$/$1000$ matches, $k \tight{=} 2$ for $2500$ matches, and $k \tight{=} 3$ for $5000$ matches.
And we use top-$k$ selection to sample a certain number of the correspondences instead of random sampling as in~\cite{choy2019fully,huang2021predator,yu2021cofinet}, which makes our correspondences deterministic.
For the registration with LGR (Tab.~2(bottom) of our main paper), we use $k \tight{=} 3$ to generate around $6000$ correspondences for each point cloud pair.
For the baselines, we report the results from their original papers or official models in Tab.~1 of our main paper.
For the registration with weighted SVD (Tab.~2(middle) of our main paper), the correspondences of the baselines are extracted in the following manner: we first sample $5000$ keypoints and generate the correspondences with mutual nearest neighbor selection in the feature space, and then the top $250$ correspondences with the smallest feature distances are used to compute the transformation.
The weights of the correspondences are computed as $w_i = \exp(-\lVert \textbf{f}^{\mathcal{P}}_{x_i} - \textbf{f}^{\mathcal{Q}}_{y_i} \rVert^2_2)$, where $\textbf{f}^{\mathcal{P}}_{x_i}$ and $\textbf{f}^{\mathcal{Q}}_{y_i}$ are the respective descriptors of the correspondences.
In the sampling strategies that we have tried, this scheme achieves the best registration results.
For KITTI, we use $k \tight{=} 2$ and select the top $5000$ point correspondences following~\cite{bai2020d3feat,huang2021predator}.
All other hyperparameters are the same as those in 3DMatch.
\section{Metrics}
\label{supp:metrics}
Following common practice~\cite{bai2020d3feat,huang2021predator,choy2019fully}, we use different metrics for 3DMatch and KITTI.
On 3DMatch, we report \emph{Inlier Ratio}, \emph{Feature Matching Recall} and \emph{Registration Recall}.
We also report \emph{Patch Inlier Ratio} to evaluate the superpoint (patch) correspondences.
On KITTI, we report \emph{Relative Rotation Error}, \emph{Relative Translation Error} and \emph{Registration Recall}.
\subsection{3DMatch/3DLoMatch}
\label{supp:metrics-3dmatch}
\emph{Inlier Ratio} (IR) is the fraction of inlier matches among all putative point matches.
A match is considered as an inlier if the distance between the two points is smaller than $\tau_1=10\text{cm}$ under the ground-truth transformation $\bar{\textbf{T}}_{\textbf{P} \rightarrow \textbf{Q}}$:
\begin{equation}
\mathrm{IR} = \frac{1}{\lvert \mathcal{C} \rvert} \sum_{(\textbf{p}_{x_i}, \textbf{q}_{y_i}) \in \mathcal{C}} \llbracket \lVert \bar{\textbf{T}}_{\textbf{P} \rightarrow \textbf{Q}}(\textbf{p}_{x_i}) - \textbf{q}_{y_i} \rVert_2 < \tau_1 \rrbracket,
\end{equation}
where $\llbracket \cdot \rrbracket$ is the Iversion bracket.
\emph{Feature Matching Recall} (FMR) is the fraction of point cloud pairs whose IR is above $\tau_2 = 0.05$.
FMR measures the potential success during the registration:
\begin{equation}
\mathrm{FMR} = \frac{1}{M} \sum_{i=1}^{M} \llbracket \mathrm{IR}_i > \tau_2 \rrbracket,
\end{equation}
where $M$ is the number of all point cloud pairs.
\emph{Registration Recall} (RR) is the fraction of correctly registered point cloud pairs.
Two point clouds are correctly registered if their transformation error is smaller than $0.2\text{m}$.
The transformation error is computed as the root mean square error of the ground-truth correspondences $\mathcal{C}^{*}$ after applying the estimated transformation $\textbf{T}_{\textbf{P} \rightarrow \textbf{Q}}$:
\begin{align}
\mathrm{RMSE} = & \sqrt{\frac{1}{\lvert \mathcal{C}^{*} \rvert} \sum_{(\textbf{p}^*_{x_i}, \textbf{q}^*_{y_i}) \in \mathcal{C}^{*}} \lVert \textbf{T}_{\textbf{P} \rightarrow \textbf{Q}}(\textbf{p}^*_{x_i}) - \textbf{q}^*_{y_i} \rVert_2^2}, \\
\mathrm{RR} = & \frac{1}{M} \sum_{i=1}^{M} \llbracket \mathrm{RMSE}_i < 0.2\text{m} \rrbracket.
\end{align}
\emph{Patch Inlier Ratio} (PIR) is the fraction of superpoint (patch) matches with actual overlap under the ground-truth transformation.
It reflects the quality of the putative superpoint (patch) correspondences:
\begin{equation}
\mathrm{PIR} = \frac{1}{\lvert \hat{\mathcal{C}} \rvert} \sum_{(\hat{\textbf{p}}_{x_i}, \hat{\textbf{q}}_{y_i}) \in \hat{\mathcal{C}}} \llbracket \exists \tilde{\textbf{p}} \in \mathcal{G}^{\mathcal{P}}_{x_i}, \tilde{\textbf{q}} \in \mathcal{G}^{\mathcal{Q}}_{y_i} \mathrm{\ s.t.\ } \lVert \tilde{\textbf{p}} - \tilde{\textbf{q}} \rVert_2 < \tau \rrbracket,
\end{equation}
where the matching radius is $\tau = 5\text{cm}$ as stated in~\ref{supp:details}.
\subsection{KITTI}
\label{supp:metrics-kitti}
\emph{Relative Rotation Error} (RRE) is the geodesic distance in degrees between estimated and ground-truth rotation matrices.
It measures the differences between the predicted and the ground-truth rotation matrices.
\begin{equation}
\mathrm{RRE} = \arccos\left(\frac{\mathrm{trace}(\textbf{R}^T \cdot \bar{\textbf{R}} - 1)}{2}\right).
\end{equation}
\emph{Relative Translation Error} (RTE) is the Euclidean distance between estimated and ground-truth translation vectors.
It measures the differences between the predicted and the ground-truth translation vectors.
\begin{equation}
\mathrm{RTE} = \lVert \textbf{t} - \bar{\textbf{t}} \rVert_2.
\end{equation}
\emph{Registration Recall} (RR) on KITTI is defined as the fraction of the point cloud pairs whose RRE and RTE are both below certain thresholds (\ie, $\mathrm{RRE} \tight{<} 5^\circ$ and $\mathrm{RTE} \tight{<} 2\text{m}$).
\begin{equation}
\mathrm{RR} = \frac{1}{M} \sum_{i=1}^{M} \llbracket \mathrm{RRE}_i < 5^{\circ} \land \mathrm{RTE}_i < 2\text{m} \rrbracket.
\end{equation}
Following~\cite{choy2019fully,bai2020d3feat,huang2021predator,lu2021hregnet,yu2021cofinet}, we compute the mean RRE and the mean RTE only for the correctly registered point cloud pairs in KITTI.
\section{Analysis of Cross-Entropy Loss}
\label{supp:celoss}
In this section, we first give an analysis that adopting the cross-entropy loss in multi-label classification problem could suppress the classes with high confidence scores.
Given the input vector $\textbf{y} \in \mathbb{R}^n$ and the label vector $\textbf{g} \in \{0, 1\}^n$, the confidence vector $\textbf{z}$ is computed by adopting a softmax on $\textbf{y}$:
\begin{equation}
z_i = \frac{\exp(y_i)}{\sum_{j=1}^{n} \exp(y_j)}.
\end{equation}
The cross-entropy loss is computed as:
\begin{equation}
\mathcal{L} = -\sum_{i=1}^n g_i\log(z_i).
\end{equation}
And the gradient vector $\textbf{d}$ of $\textbf{y}$ is computed as:
\begin{equation}
d_i = \frac{\partial \mathcal{L}}{\partial y_i} = (\sum_{j=1}^n g_j)z_i - g_i.
\end{equation}
The zero point of $d_i$ \wrt $z_i$ is $c_i = g_i / \sum_{j=1}^n g_j$.
If there are multiple positive classes, we have $0 < c_i < 1$ for each positive class as $\sum_{j=1}^n g_j > 1$.
Hence $y_i$ will be increased if $z_i < c_i$ ($d_i < 0$), and be reduced if $z_i > c_i$ ($d_i > 0$).
This indicates that the cross-entropy loss will suppress the positive classes with higher confidence scores during training.
Now we go back to context of superpoint matching.
To supervise the superpoint matching, CoFiNet~\cite{yu2021cofinet} adopts a cross-entropy loss with an optimal transport layer, which formulates the superpoint matching as a multi-class classification problem for each superpoint.
The ground-truth superpoint correspondences are determined by whether their neighboring point patches overlap.
In practice, one patch usually overlaps with multiple patches in the other point cloud, so superpoint matching is a multi-class classification problem.
According to the analysis above, the positive matches with higher confidence scores will be suppressed by the cross-entropy loss, which hinders the model from extracting reliable superpoint correspondences.
CoFiNet~\cite{yu2021cofinet} further designs a reweighting method which gives better zero points for the gradients, but the problem cannot be solved completely.
On the contrary, our overlap-aware circle loss supervises the superpoint matching in a metric learning manner, which avoids this issue.
\section{Additional Experiments}
\label{supp:additional-exp}
In this section, we conduct more experiments to evaluate our method.
In \cref{supp:detailed-3dmatch}, we provide more detailed comparison on 3DMatch and 3DLoMatch.
In \cref{supp:deep-robust}, we compare our method with recent deep robust estimators.
In \cref{supp:additional-ablation}, we conduct more ablation studies to better understand our design choices.
\subsection{Detailed Results on 3DMatch}
\label{supp:detailed-3dmatch}
\paragraph{Registration results with different overlaps.}
We first compare the performance of the models with vanilla self-attention and our geometric self-attention under different overlap ratios on 3DMatch and 3DLoMatch.
As shown in \cref{table:overlap-level}, our method consistently outperforms the vanilla self-attention counterpart on all the metrics in all levels of overlap ratio.
The gains are greater when the overlap ratio is below $30\%$, demonstrating our method is more robust in low-overlap scenarios.
\vspace{-10pt}
\paragraph{Scene-wise registration results.}
We present the scene-wise registration results on 3DMatch and 3DLoMatch in \cref{table:scene-wise}.
Following~\cite{choy2019fully,bai2020d3feat,huang2021predator}, we report mean median RRE and RTE for the successfully registered point cloud pairs.
For the registration recall, our method outperforms the baselines in most scenes on 3DMatch, especially the hard scenes such as \texttt{Home\_2} and \texttt{Lab}.
And it surpasses the baselines by a large margin in all scenes on 3DLoMatch.
Moreover, our GeoTransformer also achieves consistently superior results on the rotation and translation errors.
\begin{table}[!t]
\scriptsize
\centering
\begin{tabular}{c|ccc|ccc}
\toprule
\multirow{2}{*}{Overlap} & \multicolumn{3}{c|}{Vanilla Self-attention} & \multicolumn{3}{c}{Geometric Self-attention} \\
& PIR(\%) & IR(\%) & RR(\%) & PIR(\%) & IR(\%) & RR(\%) \\
\midrule
90\%$-$100\% & 0.974 & 0.829 & 1.000 & 0.989 & 0.894 & 1.000 \\
80\%$-$90\% & 0.948 & 0.787 & 1.000 & 0.969 & 0.859 & 1.000 \\
70\%$-$80\% & 0.902 & 0.731 & 0.931 & 0.935 & 0.815 & 0.931 \\
60\%$-$70\% & 0.884 & 0.686 & 0.933 & 0.939 & 0.783 & 0.946 \\
50\%$-$60\% & 0.843 & 0.644 & 0.957 & 0.913 & 0.750 & 0.970 \\
40\%$-$50\% & 0.787 & 0.579 & 0.935 & 0.867 & 0.689 & 0.944 \\
30\%$-$40\% & 0.716 & 0.523 & 0.917 & 0.818 & 0.644 & 0.940 \\
20\%$-$30\% & 0.560 & 0.406 & 0.781 & 0.666 & 0.518 & 0.839 \\
10\%$-$20\% & 0.377 & 0.274 & 0.639 & 0.466 & 0.372 & 0.705 \\
\bottomrule
\end{tabular}
\caption{
Comparison of the models with the vanilla self-attention and the geometric self-attention under different overlap ratios.
The results are reported on the union of 3DMatch and 3DLoMatch.
}
\label{table:overlap-level}
\end{table}
\begin{table}[!t]
\scriptsize
\centering
\begin{tabular}{l|ccc}
\toprule
Model & RTE(cm) & RRE($^{\circ}$) & RR(\%) \\
\midrule
\multicolumn{4}{c}{3DMatch} \\
\midrule
FCGF+3DRegNet~\cite{pais20203dregnet} & 8.13 & 2.74 & 77.8 \\
FCGF+DGR~\cite{choy2020deep} & 7.36 & 2.33 & 86.5 \\
FCGF+PointDSC~\cite{bai2021pointdsc} & \underline{6.55} & \underline{2.06} & \underline{93.3} \\
FCGF+DHVR~\cite{lee2021deep} & 6.61 & 2.08 & 91.4 \\
PCAM~\cite{cao2021pcam} & $\sim$7 & 2.16 & 92.4 \\
GeoTransformer (\emph{ours}, LGR) & \textbf{5.69} & \textbf{1.98} & \textbf{95.0} \\
\midrule
\multicolumn{4}{c}{3DLoMatch} \\
\midrule
FCGF+PointDSC~\cite{bai2021pointdsc} & \underline{10.50} & \underline{3.82} & \underline{56.2} \\
FCGF+DHVR~\cite{lee2021deep} & 11.76 & 3.88 & 55.6 \\
GeoTransformer (\emph{ours}, LGR) & \textbf{8.55} & \textbf{2.98} & \textbf{77.5} \\
\midrule
\multicolumn{4}{c}{KITTI} \\
\midrule
FCGF+DGR~\cite{choy2020deep} & 21.7 & 0.34 & 96.9 \\
FCGF+PointDSC~\cite{bai2021pointdsc} & 20.9 & 0.33 & 98.2 \\
FCGF+DHVR~\cite{lee2021deep} & 19.8 & \underline{0.29} & \underline{99.1} \\
PCAM~\cite{cao2021pcam} & \underline{$\sim$8} & 0.33 & 97.2 \\
GeoTransformer (\emph{ours}, LGR) & \textbf{6.5} & \textbf{0.24} & \textbf{99.5} \\
\bottomrule
\end{tabular}
\caption{
Comparison with deep robust estimators on 3DMatch and KITTI.
The RTE of PCAM is rounded to centimeter in the original paper~\cite{cao2021pcam}.
}
\label{table:supp-direct}
\end{table}
\begin{table*}[!t]
\scriptsize
\setlength{\tabcolsep}{2.5pt}
\centering
\begin{tabular}{l|ccccccccc|ccccccccc}
\toprule
\multirow{2}{*}{Model} & \multicolumn{9}{c|}{3DMatch} & \multicolumn{9}{c}{3DLoMatch} \\
& Kitchen & Home\_1 & Home\_2 & Hotel\_1 & Hotel\_2 & Hotel\_3 & Study & Lab & Mean & Kitchen & Home\_1 & Home\_2 & Hotel\_1 & Hotel\_2 & Hotel\_3 & Study & Lab & Mean \\
\midrule
\multicolumn{19}{c}{\emph{Registration Recall} (\%) $\uparrow$} \\
\midrule
3DSN~\cite{gojcic2019perfect} & 90.6 & 90.6 & 65.4 & 89.6 & 82.1 & 80.8 & 68.4 & 60.0 & 78.4 & 51.4 & 25.9 & 44.1 & 41.1 & 30.7 & 36.6 & 14.0 & 20.3 & 33.0 \\
FCGF~\cite{choy2019fully} & \underline{98.0} & 94.3 & 68.6 & 96.7 & \underline{91.0} & \underline{84.6} & 76.1 & 71.1 & 85.1 & 60.8 & 42.2 & 53.6 & 53.1 & 38.0 & 26.8 & 16.1 & 30.4 & 40.1 \\
D3Feat~\cite{bai2020d3feat} & 96.0 & 86.8 & 67.3 & 90.7 & 88.5 & 80.8 & 78.2 & 64.4 & 81.6 & 49.7 & 37.2 & 47.3 & 47.8 & 36.5 & 31.7 & 15.7 & 31.9 & 37.2 \\
Predator~\cite{huang2021predator} & 97.6 & \underline{97.2} & \underline{74.8} & \textbf{98.9} & \textbf{96.2} & \textbf{88.5} & 85.9 & 73.3 & 89.0 & 71.5 & 58.2 & 60.8 & 77.5 & 64.2 & 61.0 & 45.8 & 39.1 & 59.8 \\
CoFiNet~\cite{yu2021cofinet} & 96.4 & \textbf{99.1} & 73.6 & \underline{95.6} & \underline{91.0} & \underline{84.6} & \textbf{89.7} & \underline{84.4} & \underline{89.3} & \underline{76.7} & \underline{66.7} & \underline{64.0} & \underline{81.3} & \underline{65.0} & \underline{63.4} & \underline{53.4} & \underline{69.6} & \underline{67.5} \\
P2PNet (\emph{ours}) & \textbf{98.9} & \underline{97.2} & \textbf{81.1} & \textbf{98.9} & 89.7 & \textbf{88.5} & \underline{88.9} & \textbf{88.9} & \textbf{91.5} & \textbf{85.9} & \textbf{73.5} & \textbf{72.5} & \textbf{89.5} & \textbf{73.2} & \textbf{66.7} & \textbf{55.3} & \textbf{75.7} & \textbf{74.0} \\
\midrule
\multicolumn{19}{c}{\emph{Relative Rotation Error} ($^{\circ}$) $\downarrow$} \\
\midrule
3DSN~\cite{gojcic2019perfect} & 1.926 & 1.843 & 2.324 & 2.041 & 1.952 & 2.908 & 2.296 & 2.301 & 2.199 & 3.020 & 3.898 & 3.427 & 3.196 & 3.217 & 3.328 & 4.325 & 3.814 & 3.528 \\
FCGF~\cite{choy2019fully} & \textbf{1.767} & 1.849 & \underline{2.210} & 1.867 & 1.667 & 2.417 & \underline{2.024} & \underline{1.792} & \underline{1.949} & \underline{2.904} & 3.229 & 3.277 & 2.768 & \underline{2.801} & \underline{2.822} & 3.372 & 4.006 & 3.147 \\
D3Feat~\cite{bai2020d3feat} & 2.016 & 2.029 & 2.425 & 1.990 & 1.967 & 2.400 & 2.346 & 2.115 & 2.161 & 3.226 & 3.492 & 3.373 & 3.330 & 3.165 & 2.972 & 3.708 & 3.619 & 3.361 \\
Predator~\cite{huang2021predator} & 1.861 & \underline{1.806} & 2.473 & 2.045 & \underline{1.600} & 2.458 & 2.067 & 1.926 & 2.029 & 3.079 & \underline{2.637} & \underline{3.220} & \underline{2.694} & 2.907 & 3.390 & \underline{3.046} & 3.412 & \underline{3.048} \\
CoFiNet~\cite{yu2021cofinet} & 1.910 & 1.835 & 2.316 & \underline{1.767} & 1.753 & \underline{1.639} & 2.527 & 2.345 & 2.011 & 3.213 & 3.119 & 3.711 & 2.842 & 2.897 & 3.194 & 4.126 & \underline{3.138} & 3.280 \\
P2PNet (\emph{ours}) & \underline{1.797} & \textbf{1.353} & \textbf{1.797} & \textbf{1.528} & \textbf{1.328} & \textbf{1.571} & \textbf{1.952} & \textbf{1.678} & \textbf{1.625} & \textbf{2.356} & \textbf{2.305} & \textbf{2.541} & \textbf{2.455} & \textbf{2.490} & \textbf{2.504} & \textbf{3.010} & \textbf{2.716} & \textbf{2.547} \\
\midrule
\multicolumn{19}{c}{\emph{Relative Translation Error} (m) $\downarrow$} \\
\midrule
3DSN~\cite{gojcic2019perfect} & 0.059 & 0.070 & 0.079 & 0.065 & 0.074 & 0.062 & 0.093 & 0.065 & 0.071 & 0.082 & 0.098 & 0.096 & 0.101 & \underline{0.080} & 0.089 & 0.158 & \underline{0.120} & 0.103 \\
FCGF~\cite{choy2019fully} & 0.053 & 0.056 & 0.071 & \underline{0.062} & 0.061 & 0.055 & 0.082 & 0.090 & 0.066 & 0.084 & 0.097 & \underline{0.076} & 0.101 & 0.084 & 0.077 & 0.144 & 0.140 & 0.100 \\
D3Feat~\cite{bai2020d3feat} & 0.055 & 0.065 & 0.080 & 0.064 & 0.078 & \underline{0.049} & 0.083 & 0.064 & 0.067 & 0.088 & 0.101 & 0.086 & \underline{0.099} & 0.092 & \underline{0.075} & 0.146 & 0.135 & 0.103 \\
Predator~\cite{huang2021predator} & 0.048 & \underline{0.055} & 0.070 & 0.073 & 0.060 & 0.065 & \underline{0.080} & \underline{0.063} & 0.064 & 0.081 & 0.080 & 0.084 & \underline{0.099} & 0.096 & 0.077 & \textbf{0.101} & 0.130 & \underline{0.093} \\
CoFiNet~\cite{yu2021cofinet} & \underline{0.047} & 0.059 & \underline{0.063} & 0.063 & \underline{0.058} & \textbf{0.044} & 0.087 & 0.075 & \underline{0.062} & \underline{0.080} & \underline{0.078} & 0.078 & \underline{0.099} & 0.086 & 0.077 & 0.131 & 0.123 & 0.094 \\
P2PNet (\emph{ours}) & \textbf{0.042} & \textbf{0.046} & \textbf{0.059} & \textbf{0.055} & \textbf{0.046} & 0.050 & \textbf{0.073} & \textbf{0.053} & \textbf{0.053} & \textbf{0.062} & \textbf{0.070} & \textbf{0.071} & \textbf{0.080} & \textbf{0.075} & \textbf{0.049} & \underline{0.107} & \textbf{0.083} & \textbf{0.074} \\
\bottomrule
\end{tabular}
\caption{
Scene-wise registration results on 3DMatch and 3DLoMatch.
}
\label{table:scene-wise}
\end{table*}
\subsection{Comparison with Deep Robust Estimators}
\label{supp:deep-robust}
We further compare with recent deep robust estimators: 3DRegNet~\cite{pais20203dregnet}, DGR~\cite{choy2020deep}, PointDSC~\cite{bai2021pointdsc}, DHVR~\cite{lee2021deep} and PCAM~\cite{cao2021pcam} on 3DMatch and KITTI.
Following common practice, we report RTE, RRE and RR on both benchmarks.
Here RR is defined as in \cref{supp:metrics-kitti}.
The RTE threshold is $30\text{cm}$ on 3DMatch and $60\text{cm}$ on KITTI, while the RRE threshold is $15^{\circ}$ on 3DMatch and $5^{\circ}$ on KITTI.
As shown in \cref{table:supp-direct}, our method outperforms all the baselines on both benchmarks.
Although different correspondence extractors are used, these results can already demonstrate the superiority of GeoTransformer.
It is noteworthy that our LGR is parameter-free and does not require training a specific network, which contributes to faster registration speed (0.013s \vs 0.08s~\cite{bai2021pointdsc} in our experiments).
\subsection{Additional Ablation Studies}
\label{supp:additional-ablation}
\begin{table}[!t]
\scriptsize
\centering
\begin{tabular}{l|cc|cc}
\toprule
\multirow{2}{*}{Model} & \multicolumn{2}{c|}{3DMatch} & \multicolumn{2}{c}{3DLoMatch} \\
& original & rotated & original & rotated \\
\midrule
(a) self-attention w/ ACE & 89.3 & 87.2{\tiny \ -2.1} & 69.3 & 67.4{\tiny \ -1.9} \\
(b) self-attention w/ RCE & 88.5 & 88.5{\tiny \ same} & 68.7 & 68.7{\tiny \ same} \\
(c) geometric self-attention & 91.5 & 91.4{\tiny \ -0.1} & 74.0 & 73.8{\tiny \ -0.2} \\
\bottomrule
\end{tabular}
\caption{
Ablation experiments with rotated superpoints.
}
\label{table:ablation-study-rotated}
\end{table}
\paragraph{Transformation invariance.}
We first evaluate the transformation invariance of different positional embeddings in \cref{table:ablation-study-rotated}.
For each model, we randomly apply arbitrary rotations to the \emph{superpoints} when computing the superpoint embeddings.
Among all the variants, enlarged rotations severely degrade the performance of (a) self-attention with absolute coordinate embedding, which indicates the lack of transformation variance in it.
Surprisingly, the performance of (b) self-attention with relative coordinate embedding is quite stable.
However, after masking the relative coorinate embedding out, we find that the results of this model still remain the same, which means the relative coordinate embedding contributes little to the final performance during testing.
In constrast, our (c) geometric self-attention shows strong invariance to rigid transformation.
\begin{table}[!t]
\scriptsize
\setlength{\tabcolsep}{3pt}
\centering
\begin{tabular}{l|cccc|cccc}
\toprule
\multirow{2}{*}{Model} & \multicolumn{4}{c|}{3DMatch} & \multicolumn{4}{c}{3DLoMatch} \\
& PIR & FMR & IR & RR & PIR & FMR & IR & RR \\
\midrule
(a) distance only & 84.9 & 98.0 & 69.1 & 90.7 & 50.6 & 85.8 & 40.3 & 72.1 \\
(b) $k=1$ angles & 86.5 & 97.9 & 70.6 & 91.0 & 54.6 & 87.1 & 42.7 & 73.1 \\
(c) $k=2$ angles & 86.1 & 97.9 & 70.4 & 91.3 & 55.0 & 88.2 & 43.5 & 73.5 \\
(d) $k=3$ angles & 86.1 & 97.7 & 70.3 & 91.5 & 54.9 & 88.1 & 43.3 & 74.0 \\
(e) $k=4$ angles & 86.6 & 98.0 & 70.7 & 91.7 & 55.1 & 88.4 & 43.5 & 74.2 \\
\midrule
(f) max pooling & 86.1 & 97.7 & 70.3 & 91.5 & 54.9 & 88.1 & 43.3 & 74.0 \\
(g) average pooling & 86.3 & 98.0 & 70.2 & 91.3 & 54.6 & 87.3 & 42.8 & 74.0 \\
\midrule
(h) w/ dual-normalization & 86.1 & 97.7 & 70.3 & 91.5 & 54.9 & 88.1 & 43.3 & 74.0 \\
(i) w/o dual-normalization & 86.2 & 97.7 & 70.3 & 91.0 & 53.5 & 87.9 & 42.8 & 73.8 \\
\bottomrule
\end{tabular}
\caption{Additional ablation experiments.}
\label{table:ablation-study-supp}
\end{table}
\vspace{-10pt}
\paragraph{Geometric structure embedding.}
Next, we study the design of geometric structure embedding.
We first vary the number of nearest neighbors for computing the triplet-wise angular embedding.
As shown in~\cref{table:ablation-study-supp}(top), increasing the neighbors slightly improves the registration recall, but also induces more computation. To better balance accuracy and speed, we select $k \tight{=} 3$ in our experiments unless otherwise noted.
We then replace max pooling with average pooling when aggregating the triplet-wise angular embedding in Eq.~(5) of our main paper.
From~\cref{table:ablation-study-supp}(middle), the results of two pooling methods are very close and max pooling performs slightly better than average pooling.
\vspace{-10pt}
\paragraph{Dual-normalization.}
We then investigate the effectiveness of the dual-normalization operation in the superpoint matching module.
As shown in \cref{table:ablation-study-supp}(bottom), it slightly improves the accuracy of the superpoint correspondences in low-overlap scenarios.
As there is less overlapping context when the overlapping area is small, it is much easier to extract outlier matches between the less geometrically discriminative patches.
The dual-normalization operation can mitigate this issue and slightly improves the performance.
\vspace{-10pt}
\paragraph{Pose refinement.}
At last, we evaluate the impact of the pose refinement in LGR.
As shown in \cref{fig:refinement}, the registration recall consistently improves with more iterations and gets saturated after about $5$ iterations.
To better balance accuracy and speed, we choose $5$ iterations in the experiments.
\input{figures/refinement}
\section{Limitations}
GeoTransformer relies on uniformly downsampled superpoints to hierarchically extract correspondences. However, there could be numerous superpoints if the input point clouds cover a large area, which will cause huge memory usage and computational cost. In this case, we might need to carefully select the downsampling rate to balance performance and efficiency.
Besides, it is inflexible to uniformly sample superpoints (patches). In practice, it is common that a single object is decomposed into multiple patches, which could be easily registered as a whole. So we think that it is a very promising topic to integrate point cloud registration with semantic scene understanding tasks (\eg, semantic segmentation and object detection), which converts scene registration into object registration. We will leave this for future work.
\section{Qualitative Results}
We provide more qualitative results on 3DLoMatch in \cref{fig:supp-gallery-3dmatch}. The registration results from Predator~\cite{huang2021predator} and CoFiNet~\cite{yu2021cofinet} are also shown for comparison. Here Predator and CoFiNet use RANSAC-$50k$ for registration, while LGR is used in GeoTransformer. Our method performs quite well in these low-overlap cases. It is noteworthy that our method can distinguish similar objects at different positions (see the comparison of CoFiNet and GeoTransformer in the $4^{\text{th}}$ and $6^{\text{th}}$ rows) thanks to the transformation invariance obtained from the geometric self-attention. \cref{fig:supp-gallery-kitti} visualizes the registration results of GeoTransformer in the bird's-eye view on KITTI. It can be observed that our method attains very accurate registration even without using RANSAC.
We also provide some failure cases of our method on 3DLoMatch in \cref{fig:supp-gallery-failure}. Generally, if the overlaping region between two point clouds is small and geometrically indiscriminative (\eg, wall, ceiling and floor) or the non-overlapping region is relatively complicated, the registration could fail. A commonality of these cases is that they cannot provide adequate geometric clues to detect overlapping area and extract reliable correspondences. A possible solution could combine the information from multiple point clouds. We will leave this for future work.
\input{figures/supp-gallery-3dmatch}
\input{figures/supp-gallery-kitti}
\input{figures/supp-gallery-failure}
\end{appendix}
\section{Conclusion}
We have presented Geometric Transformer to learn accurate superpoint matching allowing for robust coarse-to-fine correspondence and point cloud registration. Through encoding pair-wise distances and triplet-wise angles among superpoints, our method captures the geometric consistency across point clouds with transformation invariance.
Thanks to the reliable correspondences, it attains fast and accurate registration in a RANSAC-free manner. In the future, we would like to extend our method to handle cross-modality (\eg, 2D-3D) registration with richer applications.
\section{Introduction}
Point cloud registration is a fundamental task in graphics, vision and robotics.
Given two partially overlapping 3D point clouds, the goal is to estimate a rigid transformation that aligns them. The problem has gained renewed interest recently thanks to the fast growing of 3D point representation learning and differentiable optimization.
The recent advances have been dominated by learning-based, correspondence-based methods~\cite{deng2018ppfnet,gojcic2019perfect,choy2019fully,bai2020d3feat,huang2021predator,yu2021cofinet}. A neural network is trained to extract point correspondences between two input point clouds, based on which an alignment transformation is calculated with a robust estimator, \eg, RANSAC.
Most correspondence-based methods rely on keypoint detection~\cite{choy2019fully,bai2020d3feat,ao2021spinnet,huang2021predator}.
However, it is challenging to detect repeatable keypoints across two point clouds, especially when they have small overlapping area. This usually results in low inlier ratio in the putative correspondences.
Inspired by the recent advances in image matching~\cite{rocco2018neighbourhood,zhou2021patch2pix,sun2021loftr},
keypoint-free methods~\cite{yu2021cofinet} downsample the input point clouds into superpoints and then match them through examining whether their local neighborhood (patch) overlaps. Such superpoint (patch) matching is then propagated to individual points, yielding dense point correspondences. Consequently, the accuracy of dense point correspondences highly depends on that of superpoint matches.
\input{figures/teaser}
Superpoint matching is sparse and loose. The upside is that it reduces strict point matching into loose patch overlapping, thus relaxing the repeatability requirement. Meanwhile, patch overlapping is a more reliable and informative constraint than distance-based point matching for learning correspondence; consider that two spatially close points could be geodesically distant. On the other hand, superpoint matching calls for features capturing more global context.
To this end, Transformer~\cite{vaswani2017attention} has been adopted~\cite{wang2019deep,yu2021cofinet} to encode contextual information in point cloud registration. However, vanilla transformer overlooks the geometric structure of the point clouds, which makes the learned features geometrically less discriminative and induces numerous outlier matches (\cref{fig:teaser}(top)). Although one can inject positional embeddings~\cite{zhao2021point,yang2019modeling}, the coordinate-based encoding is transformation-variant, which is problematic when registering point clouds given in arbitrary poses.
We advocate that a point transformer for registration task should be learned with the \emph{geometric structure} of the point clouds so as to extract transformation-invariant geometric features. We propose \emph{Geometric Transformer}, or \emph{GeoTransformer} for short, for 3D point clouds which encodes only distances of point pairs and angles in point triplets.
Given a superpoint, we learn a non-local representation through geometrically ``pinpointing'' it w.r.t. all other superpoints based on pair-wise distances and triplet-wise angles. Self-attention mechanism is utilized to weigh the importance of those anchoring superpoints.
Since distances and angles are invariant to rigid transformation, GeoTransformer learns geometric structure of point clouds efficiently, leading to highly robust superpoint matching even in low-overlap scenarios. \cref{fig:teaser}(left) demonstrates that GeoTransformer significantly improves the inlier ratio of superpoint (patch) correspondences. For better convergence, we devise an overlap-aware circle loss to make GeoTransformer focus on superpoint pairs with higher patch overlap.
Benefitting from the high-quality superpoint matches, our method attains high-inlier-ratio dense point correspondences (\cref{fig:teaser}(right)) using an optimal transport layer~\cite{sarlin2020superglue}, as well as highly robust and accurate registration without relying on RANSAC. Therefore, the registration part of our method runs extremely fast, \eg, $0.01$s for two point clouds with $5$K correspondences, $100$ times faster than RANSAC.
Extensive experiments on both indoor and outdoor benchmarks~\cite{zeng20173dmatch,geiger2012we} demonstrate the superiority of GeoTransformer.
Our method improves the inlier ratio by $17\%{\sim}30\%$ and the registration recall by over $7\%$ on the challenging 3DLoMatch benchmark~\cite{huang2021predator}.
Our main contributions are:
\begin{itemize}
\vspace{-8pt}
\item A fast and accurate point cloud registration method which is both keypoint-free and RANSAC-free.
\vspace{-8pt}
\item A geometric transformer which learns transformation-invariant geometric representation of point clouds for robust superpoint matching.
\vspace{-8pt}
\item An overlap-aware circle loss which reweights the loss of each superpoint match according to the patch overlap ratio for better convergence.
\end{itemize}
\section{Method}
\label{sec:geotrans}
\input{figures/pipeline}
Given two point clouds $\mathcal{P} = \{\textbf{p}_i \in \mathbb{R}^3 \mid i = 1, ..., N\}$ and $\mathcal{Q} = \{\textbf{q}_i \in \mathbb{R}^3 \mid i = 1, ..., M\}$, our goal is to estimate a rigid transformation $\textbf{T} = \{\textbf{R}, \textbf{t}\}$ which aligns the two point clouds, with a 3D rotation $\textbf{R} \in SO(3)$ and a 3D translation $\textbf{t} \in \mathbb{R}^3$.
The transformation can be solved by:
\begin{equation}
\min_{\textbf{R}, \textbf{t}} \sum\nolimits_{(\textbf{p}^{*}_{x_i}, \textbf{q}^{*}_{y_i}) \in \mathcal{C}^{*}} \lVert \textbf{R} \cdot \textbf{p}^{*}_{x_i} + \textbf{t} - \textbf{q}^{*}_{y_i} \rVert^2_2.
\end{equation}
Here $\mathcal{C}^{*}$ is the set of ground-truth correspondences between $\mathcal{P}$ and $\mathcal{Q}$.
Since $\mathcal{C}^{*}$ is unknown in reality, we need to first establish point correspondences between two point clouds and then estimate the alignment transformation.
Our method adopts the hierarchical correspondence paradigm which finds correspondences in a coarse-to-fine manner.
We adopt KPConv-FPN to simultaneously downsample the input point clouds and extract point-wise features (\cref{sec:model-backbone}). The first and the last (coarsest) level downsampled points correspond to the dense points and the superpoints to be matched.
A \emph{Superpoint Matching Module} is used to extract superpoint correspondences whose neighboring local patches overlap with each other (\cref{sec:model-pam}).
Based on that, a \emph{Point Matching Module} then refines the superpoint correspondences to dense points (\cref{sec:model-pom}). At last, the alignment transformation is recovered from the dense correspondences without relying on RANSAC (\cref{sec:model-estimation}).
The pipeline is illustrated in \cref{fig:overview}.
\subsection{Superpoint Sampling and Feature Extraction}
\label{sec:model-backbone}
We utilize the KPConv-FPN backbone~\cite{thomas2019kpconv,lin2017feature} to extract multi-level features for the point clouds. A byproduct of the point feature learning is point downsampling. We work on downsampled points since point cloud registration can actually be pinned down by the correspondences of a much coarser subset of points. The original point clouds are usually too dense so that point-wise correspondences are redundant
and sometimes too clustered to be useful.
The points correspond to the coarsest resolution, denoted by $\hat{\mathcal{P}}$ and $\hat{\mathcal{Q}}$, are treated as \emph{superpoints} to be matched. The associated learned features are denoted as $\hat{\textbf{F}}{}^{\mathcal{P}} \medium{\in} \mathbb{R}^{\lvert \hat{\mathcal{P}} \rvert \times \hat{d}}$ and $\hat{\textbf{F}}{}^{\mathcal{Q}} \medium{\in} \mathbb{R}^{\lvert \hat{\mathcal{Q}} \rvert \times \hat{d}}$.
The dense point correspondences are computed at $1/2$ of the original resolution, \ie, the first level downsampled points denoted by $\tilde{\mathcal{P}}$ and $\tilde{\mathcal{Q}}$. Their learned features are represented by $\tilde{\textbf{F}}{}^{\mathcal{P}} \medium{\in} \mathbb{R}^{\lvert \tilde{\mathcal{P}} \rvert \times \tilde{d}}$ and $\tilde{\textbf{F}}{}^{\mathcal{Q}} \medium{\in} \mathbb{R}^{\lvert \tilde{\mathcal{Q}} \rvert \times \tilde{d}}$.
For each superpoint, we construct a local \emph{patch} of points around it using the point-to-node grouping strategy \cite{li2018so,yu2021cofinet}.
In particular, each point in $\tilde{\mathcal{P}}$ and its features from $\tilde{\textbf{F}}{}^{\mathcal{P}}$ are assigned to its nearest superpoint in the geometric space:
\vspace{-2pt}
\begin{equation}
\mathcal{G}^{\mathcal{P}}_i = \{\tilde{\textbf{p}} \in \tilde{\mathcal{P}} \mid i = \argmin\nolimits_j(\lVert \tilde{\textbf{p}} - \hat{\textbf{p}}_j \rVert_2), \hat{\textbf{p}}_j \in \hat{\mathcal{P}}\}.
\vspace{-2pt}
\end{equation}
This essentially leads to a Voronoi decomposition of the input point cloud seeded by superpoints.
The feature matrix associated with the points in $\mathcal{G}^{\mathcal{P}}_i$ is denoted as $\textbf{F}^{\mathcal{P}}_i \subset \tilde{\textbf{F}}{}^{\mathcal{P}}$.
The superpoints with an empty patch are removed.
The patches $\{\mathcal{G}^{\mathcal{Q}}_i\}$ and the feature matrices $\{\textbf{F}^{\mathcal{Q}}_i\}$ for $\mathcal{Q}$ are computed and denoted in a similar way.
In what follows, the terms ``\emph{superpoint}'' and ``\emph{patch}'' will be used interchangeably unless otherwise noted.
\subsection{Superpoint Matching Module}
\label{sec:model-pam}
\input{figures/geotr}
\paragraph{Geometric Transformer.}
Global context has proven critical in many computer vision tasks~\cite{dosovitskiy2020image,sun2021loftr,yu2021cofinet}.
For this reason, transformer has been adopted to leverage global contextual information for point cloud registration.
However, existing methods~\cite{wang2019deep,huang2021predator,yu2021cofinet} usually feed transformer with only high-level point cloud features and does not explicitly encode the geometric structure.
This makes the learned features geometrically less discriminative, which causes severe matching ambiguity and numerous outlier matches, especially in low-overlap cases.
A straightforward recipe is to explicitly inject positional embeddings~\cite{yang2019modeling,zhao2021point} of 3D point coordinates.
However, the resultant coordinate-based transformers are naturally \emph{transformation-variant}, while registration requires \emph{transformation invariance} since the input point clouds can be in arbitrary poses.
To this end, we propose \emph{Geometric Transformer} which not only encodes high-level point features but also explicitly captures intra-point-cloud geometric structures and inter-point-cloud geometric consistency.
GeoTransformer is composed of a \emph{geometric self-attention} module for learning intra-point-cloud features and a \emph{feature-based cross-attention} module for modeling inter-point-cloud consistency. The two modules are interleaved for $N_t$ times to extract hybrid features $\hat{\textbf{H}}{}^{\mathcal{P}}$ and $\hat{\textbf{H}}{}^{\mathcal{Q}}$ for reliable superpoint matching (see \cref{fig:overview} (bottom left)).
\vspace{-10pt}
\paragraph{Geometric self-attention.}
We design a \emph{geometric self-attention} to learn the global correlations in both feature and geometric spaces among the superpoints for each point cloud.
In the following, we describe the computation for $\hat{\mathcal{P}}$ and the same goes for $\hat{\mathcal{Q}}$. Given the input feature matrix $\textbf{X} \medium{\in} \mathbb{R}^{\lvert \hat{\mathcal{P}} \vert \times d_t}$, the output feature matrix $\textbf{Z} \medium{\in} \mathbb{R}^{\lvert \hat{\mathcal{P}} \vert \times d_t}$ is the weighted sum of all projected input features:
\vspace{-5pt}
\begin{equation}
\textbf{z}_i = \sum_{j=1}^{\lvert \hat{\mathcal{P}} \vert} a_{i, j} (\textbf{x}_j\textbf{W}^V),
\vspace{-5pt}
\end{equation}
where the weight coefficient $a_{i, j}$ is computed by a row-wise softmax on the attention score $e_{i, j}$, and $e_{i, j}$ is computed as:
\vspace{-5pt}
\begin{equation}
e_{i, j} = \frac{(\textbf{x}_i\textbf{W}^Q)(\textbf{x}_j\textbf{W}^K + \textbf{r}_{i, j}\textbf{W}^R)^T}{\sqrt{d_{t}}}.
\vspace{-5pt}
\end{equation}
Here, $\textbf{r}_{i, j} \medium{\in} \mathbb{R}^{d_t}$ is a \emph{geometric structure embedding} to be described in the next. $\textbf{W}^Q, \textbf{W}^K, \textbf{W}^V, \textbf{W}^R \in \mathbb{R}^{d_t \times d_t}$ are the respective projection matrices for queries, keys, values and geometric structure embeddings.
\cref{fig:geotr} shows the structure and the computation of geometric self-attention.
We design a novel \emph{geometric structure embedding} to encode the transformation-invariant geometric structure of the superpoints.
The core idea is to leverage the distances and angles computed with the superpoints which are consistent across different point clouds of the same scene.
Given two superpoints $\hat{\textbf{p}}_i, \hat{\textbf{p}}_j \tight{\in} \hat{\mathcal{P}}$, their geometric structure embedding consists of a \emph{pair-wise distance embedding} and a \emph{triplet-wise angular embedding}, which will be described below.
(1)
\emph{Pair-wise Distance Embedding}.
Given the distance $\rho_{i, j} \hspace{1pt} {=} \hspace{1pt} \lVert \hat{\textbf{p}}_i - \hat{\textbf{p}}_j \rVert_2$ between $\hat{\textbf{p}}_i$ and $\hat{\textbf{p}}_j$, the distance embedding $\textbf{r}^D_{i, j}$ between them is computed by applying a sinusoidal function \cite{vaswani2017attention} on $\rho_{i, j} / \sigma_d$.
Here, $\sigma_d$ is a hyper-parameter used to tune the sensitivity on distance variations.
Please refer to the Appx.~A.1 for detailed computation.
(2) \emph{Triplet-wise Angular Embedding}.
We compute angular embedding with triplets of superpoints.
We first select the $k$ nearest neighbors $\mathcal{K}_i$ of $\hat{\textbf{p}}_i$.
For each $\hat{\textbf{p}}_x \tight{\in} \mathcal{K}_i$, we compute the angle $\alpha^x_{i,j} \tight{=} \angle(\Delta_{x, i}, \Delta_{j, i})$, where $\Delta_{i, j} \tight{:=} \hat{\textbf{p}}_i \hspace{1pt} {-} \hspace{1pt} \hat{\textbf{p}}_j$.
The triplet-wise angular embedding $\textbf{r}^A_{i, j, x}$ is then computed with a sinusoidal function on $\alpha^x_{i,j} / \sigma_a$, with $\sigma_a$ controlling the sensitivity on angular variations.
Finally, the geometric structure embedding $\textbf{r}_{i, j}$ is computed by aggregating the pair-wise distance embedding and the triplet-wise angular embedding:
\vspace{-5pt}
\begin{equation}
\textbf{r}_{i, j} = \textbf{r}^D_{i, j}\textbf{W}^D + {\max}_x\left\{\textbf{r}^A_{i, j, x}\textbf{W}^A\right\},
\vspace{-5pt}
\label{eq:gse}
\end{equation}
where $\textbf{W}^D, \textbf{W}^A \in \mathbb{R}^{d_t \times d_t}$ are the respective projection matrices for the two types of embeddings. We use max pooling here to improve the robustness to the varying nearest neighbors of a superpoint due to self-occlusion.
\cref{fig:rge} illustrates the computation of geometric structure embedding.
\input{figures/rge}
\vspace{-10pt}
\paragraph{Feature-based cross-attention.}
Cross-attention is a typical module for point cloud registration task~\cite{huang2021predator,wang2019deep,yu2021cofinet}, used to perform feature exchange between two input point clouds.
Given the self-attention feature matrices $\textbf{X}^{\mathcal{P}}$, $\textbf{X}^{\mathcal{Q}}$ for $\hat{\mathcal{P}}$, $\hat{\mathcal{Q}}$ respectively, the cross-attention feature matrix $\textbf{Z}^{\mathcal{P}}$ of $\hat{\mathcal{P}}$ is computed with the features of $\hat{\mathcal{Q}}$:
\vspace{-2pt}
\begin{equation}
\textbf{z}^{\mathcal{P}}_i = \sum_{j=1}^{\lvert \hat{\mathcal{Q}} \rvert} a_{i, j} (\textbf{x}^{\mathcal{Q}}_j\textbf{W}^V).
\vspace{-2pt}
\end{equation}
Similarly, $a_{i, j}$ is computed by a row-wise softmax on the cross-attention score $e_{i, j}$, and $e_{i, j}$ is computed as the feature correlation between the $\textbf{X}^{\mathcal{P}}$ and $\textbf{X}^{\mathcal{Q}}$:
\vspace{-2pt}
\begin{equation}
e_{i, j} = \frac{(\textbf{x}^{\mathcal{P}}_i\textbf{W}^Q)(\textbf{x}^{\mathcal{Q}}_j\textbf{W}^K)^T}{\sqrt{d_{t}}}.
\vspace{-2pt}
\end{equation}
The cross-attention features for $\mathcal{Q}$ are computed in the same way.
While the geometric self-attention module encodes the transformation-invariant geometric structure for each individual point cloud, the feature-based cross-attention module can model the geometric consistency across the two point clouds.
The resultant hybrid features are both invariant to transformation and robust for reasoning correspondence.
\vspace{-10pt}
\paragraph{Superpoint matching.}
To find the superpoint correspondences, we propose a matching scheme based on global feature correlation.
We first normalize $\hat{\textbf{H}}{}^{\mathcal{P}}$ and $\hat{\textbf{H}}{}^{\mathcal{Q}}$ onto a unit hypersphere and compute a Gaussian correlation matrix $\textbf{S} \tight{\in} \mathbb{R}^{\lvert \hat{\mathcal{P}} \rvert \times \lvert \hat{\mathcal{Q}} \rvert}$ with $s_{i, j} \tight{=} \exp(-\lVert \hat{\textbf{h}}{}^{\mathcal{P}}_i \tight{-} \hat{\textbf{h}}{}^{\mathcal{Q}}_j\rVert_2^2)$.
In practice, some patches of a point cloud are less geometrically discriminative and have numerous similar patches in the other point cloud. Besides our powerful hybrid features, we also perform a dual-normalization operation \cite{rocco2018neighbourhood,sun2021loftr} on $\textbf{S}$ to further suppress ambiguous matches, leading to $\bar{\textbf{S}}$ with
\begin{equation}
\bar{s}_{i, j} = \frac{s_{i, j}}{\sum_{k=1}^{\lvert \hat{\mathcal{Q}} \rvert} s_{i, k}} \cdot \frac{s_{i, j}}{\sum_{k=1}^{\lvert \hat{\mathcal{P}} \rvert} s_{k, j}}.
\end{equation}
We found that this suppression can effectively eliminate wrong matches.
Finally, we select the largest $N_{c}$ entries in $\bar{\textbf{S}}$ as the \emph{superpoint correspondences}:
\vspace{-2pt}
\begin{equation}
\hat{\mathcal{C}} = \{ (\hat{\textbf{p}}_{x_i}, \hat{\textbf{q}}_{y_i}) \mid (x_i, y_i) \in \mathrm{topk}_{x, y}(\bar{s}_{x, y}) \}.
\vspace{-2pt}
\end{equation}
Due to the powerful geometric structure encoding of GeoTransformer, our method is able to achieve accurate registration in low-overlap cases and with less point correspondences, and most notably, in a RANSAC-free manner.
\subsection{Point Matching Module}
\label{sec:model-pom}
Having obtained the superpoint correspondences, we extract point correspondences using a simple yet effective \emph{Point Matching Module}.
At point level, we use only local point features learned by the backbone.
The rationale is that point level matching is mainly determined by the vicinities of the two points being matched, once the global ambiguity has been resolved by superpoint matching.
This design choice improves the robustness.
For each superpoint correspondence $\hat{\mathcal{C}}_i = (\hat{\textbf{p}}_{x_i}, \hat{\textbf{q}}_{y_i})$, an optimal transport layer \cite{sarlin2020superglue} is used to extract the \emph{local dense point correspondences} between $\mathcal{G}^{\mathcal{P}}_{x_i}$ and $\mathcal{G}^{\mathcal{Q}}_{y_i}$.
Specifically, we first compute a cost matrix $\textbf{C}_i \in \mathbb{R}^{n_i \times m_i}$:
\vspace{-2pt}
\begin{equation}
\textbf{C}_i = \textbf{F}^{\mathcal{P}}_{x_i} (\textbf{F}^{\mathcal{Q}}_{y_i})^T / \sqrt{\tilde{d}},
\vspace{-2pt}
\end{equation}
where $n_i = \lvert \mathcal{G}^{\mathcal{P}}_{x_i} \rvert$, $m_i = \lvert \mathcal{G}^{\mathcal{Q}}_{y_i} \rvert$.
The cost matrix $\textbf{C}_i$ is then augmented into $\bar{\textbf{C}}_i$ by appending a new row and a new column as in \cite{sarlin2020superglue}, filled with a learnable dustbin parameter $\alpha$.
We then utilize the Sinkhorn algorithm \cite{sinkhorn1967concerning} on $\bar{\textbf{C}}_i$ to compute a soft assignment matrix $\bar{\textbf{Z}}_i$ which is then recovered to $\textbf{Z}_i$ by dropping the last row and the last column.
We use $\textbf{Z}_i$ as the confidence matrix of the candidate matches and extract point correspondences via mutual top-$k$ selection, where a point match is selected if it is among the $k$ largest entries of both the row and the column that it resides in:
\vspace{-2pt}
\begin{equation}
\mathcal{C}_i \tight{=} \{(\mathcal{G}^{\mathcal{P}}_{x_i}(x_j), \mathcal{G}^{\mathcal{Q}}_{y_i}(y_j)) \tight{\mid} (x_j, y_j) \tight{\in} \mathrm{mutual\_topk}_{x, y}(z^i_{x, y})\}.
\end{equation}
The point correspondences computed from each superpoint match are then collected together to form the final \emph{global dense point correspondences}: $\mathcal{C} = \bigcup_{i=1}^{N_c} \mathcal{C}_i$.
\subsection{RANSAC-free Local-to-Global Registration}
\label{sec:model-estimation}
Previous methods generally rely on robust pose estimators to estimate the transformation since the putative correspondences are often predominated by outliers.
Most robust estimators such as RANSAC suffer from slow convergence.
Given the high inlier ratio of GeoTransformer, we are able to achieve robust registration without relying on robust estimators, which also greatly reduces computation cost.
We design a \emph{local-to-global registration} (LGR) scheme.
As a hypothesize-and-verify approach, LGR is comprised of a local phase of transformation candidates generation and a global phase for transformation selection.
In the local phase, we solve for a transformation $\textbf{T}_i \tight{=} \{\textbf{R}_i, \textbf{t}_i\}$ for each superpoint match using its \emph{local point correspondences}:
\vspace{-2pt}
\begin{equation}
\textbf{R}_i, \textbf{t}_i = \min_{\textbf{R}, \textbf{t}} \sum\nolimits_{(\tilde{\textbf{p}}_{x_j}, \tilde{\textbf{q}}_{y_j}) \in \mathcal{C}_i} w^i_j \lVert \textbf{R} \cdot \tilde{\textbf{p}}_{x_j} \hspace{-3pt} + \textbf{t} - \tilde{\textbf{q}}_{y_j} \rVert_2^2.
\label{eq:weighted-svd}
\vspace{-2pt}
\end{equation}
This can be solved in closed form using weighted SVD~\cite{besl1992method}.
The corresponding confidence score for each correspondence in $\textbf{Z}_i$ is used as the weight $w^i_j$.
Benefitting from the high-quality correspondences, the transformations obtained in this phase are already very accurate.
In the global phase, we select the transformation which admits the most inlier matches over the entire \emph{global point correspondences}:
\vspace{-2pt}
\begin{equation}
\textbf{R}, \textbf{t} = \max_{\textbf{R}_i, \textbf{t}_i} \sum\nolimits_{(\tilde{\textbf{p}}_{x_j}, \tilde{\textbf{q}}_{y_j}) \in \mathcal{C}} \llbracket \lVert \textbf{R}_i \cdot \tilde{\textbf{p}}_{x_j} \hspace{-3pt} + \textbf{t}_i - \tilde{\textbf{q}}_{y_j} \rVert_2^2 < \tau_a \rrbracket,
\end{equation}
where $\llbracket \cdot \rrbracket$ is the Iverson bracket. $\tau_a$ is the acceptance radius.
We then iteratively re-estimate the transformation with the surviving inlier matches for $N_r$ times by solving \cref{eq:weighted-svd}.
As shown in \cref{sec:exp-indoor}, our approach achieves comparable registration accuracy with RANSAC but reduces the computation time by more than $100$ times.
Moreover, unlike deep robust estimators~\cite{choy2020deep,pais20203dregnet,bai2021pointdsc}, our method is parameter-free and no network training is needed.
\subsection{Loss Functions}
\label{sec:model-loss}
The loss function $\mathcal{L} = \mathcal{L}_{oc} + \mathcal{L}_{p}$ is composed of an \emph{overlap-aware circle loss} $\mathcal{L}_{oc}$ for superpoint matching and a \emph{point matching loss} $\mathcal{L}_{p}$ for point matching.
\vspace{-10pt}
\paragraph{Overlap-aware circle loss.}
Existing methods~\cite{sun2021loftr,yu2021cofinet} usually formulate superpoint matching as a multi-label classification problem and adopt a cross-entropy loss with dual-softmax~\cite{sun2021loftr} or optimal transport~\cite{sarlin2020superglue,yu2021cofinet}.
Each superpoint is assigned (classified) to one or many of the other superpoints, where the ground truth is computed based on patch overlap and it is very likely that one patch could overlap with multiple patches.
By analyzing the gradients from the cross-entropy loss, we find that the positive classes with high confidence scores are suppressed by positive gradients in the multi-label classification\footnote{The detailed analysis is presented in Appx.~C.}.
This hinders the model from extracting reliable superpoint correspondences.
To address this issue, we opt to extract superpoint descriptors in a metric learning fashion.
A straightforward solution is to adopt a circle loss~\cite{sun2020circle} similar to~\cite{bai2020d3feat,huang2021predator}.
However, the circle loss overlooks the differences between the positive samples and weights them equally.
As a result, it struggles in matching patches with relatively low overlap.
For this reason, we design an \emph{overlap-aware circle loss} to focus the model on those matches with high overlap.
We select the patches in $\mathcal{P}$ which have at least one positive patch in $\mathcal{Q}$ to form a set of anchor patches, $\mathcal{A}$.
A pair of patches are positive if they share at least $10\%$ overlap, and negative if they do not overlap.
All other pairs are omitted.
For each anchor patch $\mathcal{G}^{\mathcal{P}}_i \in \mathcal{A}$, we denote the set of its positive patches in $\mathcal{Q}$ as $\varepsilon^i_p$, and the set of its negative patches as $\varepsilon^i_n$.
The overlap-aware circle loss on $\mathcal{P}$ is then defined as:
\begin{equation}
\label{eq:overlap-aware-circle-loss}
\mathcal{L}^{\mathcal{P}}_{oc} \tight{=} \frac{1}{\lvert\mathcal{A}\rvert} \sum_{\mathclap{\mathcal{G}^{\mathcal{P}}_i \in \mathcal{A}}} \log[1 + \sum_{\mathclap{\mathcal{G}^{\mathcal{Q}}_j \in \varepsilon^i_p}} e^{\lambda^j_i\beta^{i,j}_p (d^j_i - \Delta_p)} \cdot \sum_{\mathclap{\mathcal{G}^{\mathcal{Q}}_k \in \varepsilon^i_n}} e^{\beta^{i,k}_n (\Delta_n - d^k_i)}],
\end{equation}
where $d^j_i \hspace{1pt} {=} \hspace{1pt} \lVert \hat{\textbf{h}}{}^{\mathcal{P}}_i \hspace{1pt} {-} \hspace{1pt} \hat{\textbf{h}}{}^{\mathcal{Q}}_j \rVert_2$ is the distance in the feature space, $\lambda_i^j \tight{=} (o^j_i)^{\frac{1}{2}}$ and $o^j_i$ represents the overlap ratio between $\mathcal{G}^{\mathcal{P}}_i$ and $\mathcal{G}^{\mathcal{Q}}_j$.
The positive and negative weights are computed for each sample individually with $\beta^{i,j}_p \medium{=} \gamma(d^j_i \medium{-} \Delta_p)$ and $\beta^{i,k}_n \medium{=} \gamma(\Delta_n \medium{-} d^k_i)$.
The margin hyper-parameters are set to $\Delta_p \hspace{1pt} {=} \hspace{1pt} 0.1$ and $\Delta_n \hspace{1pt} {=} \hspace{1pt} 1.4$.
The overlap-aware circle loss reweights the loss values on $\varepsilon^i_p$ based on the overlap ratio so that the patch pairs with higher overlap are given more importance.
The same goes for the loss $\mathcal{L}^{\mathcal{Q}}_{oc}$ on $\mathcal{Q}$. And the overall loss is $\mathcal{L}_{oc} = (\mathcal{L}^{\mathcal{P}}_{oc} + \mathcal{L}^{\mathcal{Q}}_{oc}) / 2$.
\vspace{-10pt}
\paragraph{Point matching loss.}
The ground-truth point correspondences are relatively sparse because they are available only for downsampled point clouds.
We simply use a negative log-likelihood loss~\cite{sarlin2020superglue} on the assignment matrix $\bar{\textbf{Z}}_i$ of each superpoint correspondence.
During training, we randomly sample $N_g$ ground-truth superpoint correspondences $\{\hat{\mathcal{C}}^{*}_i\}$ instead of using the predicted ones.
For each $\hat{\mathcal{C}}^{*}_i$, a set of ground-truth point correspondences $\mathcal{M}_i$ is extracted with a matching radius $\tau$. The sets of unmatched points in the two patches are denoted as $\mathcal{I}_i$ and $\mathcal{J}_i$.
The individual point matching loss for $\hat{\mathcal{C}}^{*}_i$ is computed as:
\begin{equation}
\mathcal{L}_{p, i} = -\sum_{\mathclap{{(x, y) \in \mathcal{M}_i}}} \log \bar{z}^i_{x, y} - \sum_{x \in \mathcal{I}_i} \log \bar{z}^i_{x, m_i+1} - \sum_{y \in \mathcal{J}_i} \log \bar{z}^i_{n_i+1, y},
\end{equation}
The final loss is computed by averaging the individual loss over all sampled superpoint matches: $\mathcal{L}_p = \frac{1}{N_g} \sum^{N_g}_{i=1} \mathcal{L}_{p, i}$.
\section{Related Work}
\label{sec:related}
\ptitle{Correspondence-based Methods.}
Our work follows the line of the correspondence-based methods~\cite{deng2018ppfnet,deng2018ppf,gojcic2019perfect,choy2019fully}.
They first extract correspondences between two point clouds and then recover the transformation with robust pose estimators, \eg, RANSAC.
Thanks to the robust estimators, they achieve state-of-the-art performance in indoor and outdoor scene registration.
These methods can be further categorized into two classes according to how they extract correspondences.
The first class aims to detect more repeatable keypoints~\cite{bai2020d3feat,huang2021predator} and learn more powerful descriptors for the keypoints~\cite{choy2019fully,ao2021spinnet,wang2021you}.
While the second class~\cite{yu2021cofinet} retrieves correspondences without keypoint detection by considering all possible matches.
Our method follows the detection-free methods and improves the accuracy of correspondences by leveraging the geometric information.
\ptitle{Direct Registration Methods.}
Recently, direct registration methods have emerged. They estimate the transformation with a neural network in an end-to-end manner.
These methods can be further classified into two classes.
The first class~\cite{wang2019deep,wang2019prnet,yew2020rpm,fu2021robust} follows the idea of ICP~\cite{besl1992method}, which iteratively establishes soft correspondences and computes the transformation with differentiable weighted SVD.
The second class~\cite{aoki2019pointnetlk,huang2020feature,xu2021omnet} first extracts a global feature vector for each point cloud and regresses the transformation with the global feature vectors.
Although direct registration methods have achieved promising results on single synthetic shapes, they could fail in large-scale scenes as stated in~\cite{huang2021predator}.
\ptitle{Deep Robust Estimators.}
As traiditional robust estimators such as RANSAC suffer from slow convergence and instability in case of high outlier ratio, deep robust estimators~\cite{pais20203dregnet,choy2020deep,bai2021pointdsc} have been proposed as the alternatives for them.
They usually contain a classification network to reject outliers and an estimation network to compute the transformation.
Compared with traditional robust estimators, they achieve improvements in both accuracy and speed.
However, they require training a specific network.
In comparison, our method achieves fast and accurate registration with a parameter-free local-to-global registration scheme.
\section{Experiments}
\label{sec:experiments}
We evaluate GeoTransformer on indoor 3DMatch~\cite{zeng20173dmatch} and 3DLoMatch~\cite{huang2021predator} benchmarks (\cref{sec:exp-indoor}) and outdoor KITTI odometry~\cite{geiger2012we} benchmark (\cref{sec:exp-outdoor}).
Specifically, we interleave the geometric self-attention module and the feature-based cross-attention module for $N_t \medium{=} 3$ times to learn hybrid features, with $k \medium{=} 3$ in the triplet-wise angular embedding.
We use $N_c \medium{=} 256$ superpoint matches to extract dense point correspondences.
The alignment transformation is iteratively recomputed for $N_r {=} 5$ times in LGR.
See more implementation details in Appx.~A.3.
\subsection{Indoor Benchmarks: 3DMatch \& 3DLoMatch}
\label{sec:exp-indoor}
\paragraph{Dataset.}
3DMatch~\cite{zeng20173dmatch} contains $62$ scenes among which $46$ are used for training, $8$ for validation and $8$ for testing.
We use the training data preprocessed by~\cite{huang2021predator} and evaluate on both 3DMatch and 3DLoMatch~\cite{huang2021predator} protocols.
The point cloud pairs in 3DMatch have $>30\%$ overlap, while those in 3DLoMatch have low overlap of $10\%$ $\sim$ $30\%$.
\vspace{-10pt}
\paragraph{Metrics.}
Following~\cite{bai2020d3feat,huang2021predator}, we evaluate the performance with three metrics:
(1) \emph{Inlier Ratio} (IR), the fraction of putative correspondences whose residuals are below a certain threshold (\ie, $0.1\text{m}$) under the ground-truth transformation,
(2) \emph{Feature Matching Recall} (FMR), the fraction of point cloud pairs whose inlier ratio is above a certain threshold (\ie, $5\%$), and
(3) \emph{Registration Recall} (RR), the fraction of point cloud pairs whose transformation error is smaller than a certain threshold (\ie, $\mathrm{RMSE} < 0.2\text{m}$).
\begin{table}[!t]
\setlength{\tabcolsep}{1.8pt}
\scriptsize
\centering
\begin{tabular}{l|ccccc|ccccc}
\toprule
& \multicolumn{5}{c|}{3DMatch} & \multicolumn{5}{c}{3DLoMatch} \\
\# Samples & 5000 & 2500 & 1000 & 500 & 250 & 5000 & 2500 & 1000 & 500 & 250 \\
\midrule
\multicolumn{11}{c}{\emph{Feature Matching Recall} (\%) $\uparrow$} \\
\midrule
PerfectMatch~\cite{gojcic2019perfect} & 95.0 & 94.3 & 92.9 & 90.1 & 82.9 & 63.6 & 61.7 & 53.6 & 45.2 & 34.2 \\
FCGF~\cite{choy2019fully} & 97.4 & 97.3 & 97.0 & 96.7 & 96.6 & 76.6 & 75.4 & 74.2 & 71.7 & 67.3 \\
D3Feat~\cite{bai2020d3feat} & 95.6 & 95.4 & 94.5 & 94.1 & 93.1 & 67.3 & 66.7 & 67.0 & 66.7 & 66.5 \\
SpinNet~\cite{ao2021spinnet} & 97.6 & 97.2 & 96.8 & 95.5 & 94.3 & 75.3 & 74.9 & 72.5 & 70.0 & 63.6 \\
Predator~\cite{huang2021predator} & 96.6 & 96.6 & 96.5 & 96.3 & 96.5 & 78.6 & 77.4 & 76.3 & 75.7 & 75.3 \\
YOHO~\cite{wang2021you} & \textbf{98.2} & 97.6 & 97.5 & 97.7 & 96.0 & 79.4 & 78.1 & 76.3 & 73.8 & 69.1 \\
CoFiNet~\cite{yu2021cofinet} & \underline{98.1} & \textbf{98.3} & \textbf{98.1} & \textbf{98.2} & \textbf{98.3} & \underline{83.1} & \underline{83.5} & \underline{83.3} & \underline{83.1} & \underline{82.6} \\
GeoTransformer (\emph{ours}) & 97.9 & \underline{97.9} & \underline{97.9} & \underline{97.9} & \underline{97.6} & \textbf{88.3} & \textbf{88.6} & \textbf{88.8} & \textbf{88.6} & \textbf{88.3} \\
\midrule
\multicolumn{11}{c}{\emph{Inlier Ratio} (\%) $\uparrow$} \\
\midrule
PerfectMatch~\cite{gojcic2019perfect} & 36.0 & 32.5 & 26.4 & 21.5 & 16.4 & 11.4 & 10.1 & 8.0 & 6.4 & 4.8 \\
FCGF~\cite{choy2019fully} & 56.8 & 54.1 & 48.7 & 42.5 & 34.1 & 21.4 & 20.0 & 17.2 & 14.8 & 11.6 \\
D3Feat~\cite{bai2020d3feat} & 39.0 & 38.8 & 40.4 & 41.5 & 41.8 & 13.2 & 13.1 & 14.0 & 14.6 & 15.0 \\
SpinNet~\cite{ao2021spinnet} & 47.5 & 44.7 & 39.4 & 33.9 & 27.6 & 20.5 & 19.0 & 16.3 & 13.8 & 11.1 \\
Predator~\cite{huang2021predator} & 58.0 & 58.4 & \underline{57.1} & \underline{54.1} & 49.3 & \underline{26.7} & \underline{28.1} & \underline{28.3} & \underline{27.5} & 25.8 \\
YOHO~\cite{wang2021you} & \underline{64.4} & \underline{60.7} & 55.7 & 46.4 & 41.2 & 25.9 & 23.3 & 22.6 & 18.2 & 15.0 \\
CoFiNet~\cite{yu2021cofinet} & 49.8 & 51.2 & 51.9 & 52.2 & \underline{52.2} & 24.4 & 25.9 & 26.7 & 26.8 & \underline{26.9} \\
GeoTransformer (\emph{ours}) & \textbf{71.9} & \textbf{75.2} & \textbf{76.0} & \textbf{82.2} & \textbf{85.1} & \textbf{43.5} & \textbf{45.3} & \textbf{46.2} & \textbf{52.9} & \textbf{57.7} \\
\midrule
\multicolumn{11}{c}{\emph{Registration Recall} (\%) $\uparrow$} \\
\midrule
PerfectMatch~\cite{gojcic2019perfect} & 78.4 & 76.2 & 71.4 & 67.6 & 50.8 & 33.0 & 29.0 & 23.3 & 17.0 & 11.0 \\
FCGF~\cite{choy2019fully} & 85.1 & 84.7 & 83.3 & 81.6 & 71.4 & 40.1 & 41.7 & 38.2 & 35.4 & 26.8 \\
D3Feat~\cite{bai2020d3feat} & 81.6 & 84.5 & 83.4 & 82.4 & 77.9 & 37.2 & 42.7 & 46.9 & 43.8 & 39.1 \\
SpinNet~\cite{ao2021spinnet} & 88.6 & 86.6 & 85.5 & 83.5 & 70.2 & 59.8 & 54.9 & 48.3 & 39.8 & 26.8 \\
Predator~\cite{huang2021predator} & 89.0 & 89.9 & \underline{90.6} & 88.5 & 86.6 & 59.8 & 61.2 & 62.4 & 60.8 & 58.1 \\
YOHO~\cite{wang2021you} & \underline{90.8} & \underline{90.3} & 89.1 & \underline{88.6} & 84.5 & 65.2 & 65.5 & 63.2 & 56.5 & 48.0 \\
CoFiNet~\cite{yu2021cofinet} & 89.3 & 88.9 & 88.4 & 87.4 & \underline{87.0} & \underline{67.5} & \underline{66.2} & \underline{64.2} & \underline{63.1} & \underline{61.0} \\
GeoTransformer (\emph{ours}) & \textbf{92.0} & \textbf{91.8} & \textbf{91.8} & \textbf{91.4} & \textbf{91.2} & \textbf{75.0} & \textbf{74.8} & \textbf{74.2} & \textbf{74.1} & \textbf{73.5} \\
\bottomrule
\end{tabular}
\vspace{-5pt}
\caption{
Evaluation results on 3DMatch and 3DLoMatch.
}
\label{table:results-3dmatch}
\vspace{-10pt}
\end{table}
\vspace{-10pt}
\paragraph{Correspondence results.}
We first compare the correspondence results of our method with the recent state of the arts: PerfectMatch~\cite{gojcic2019perfect}, FCGF~\cite{choy2019fully}, D3Feat~\cite{bai2020d3feat}, SpinNet~\cite{ao2021spinnet}, Predator~\cite{huang2021predator}, YOHO~\cite{wang2021you} and CoFiNet~\cite{yu2021cofinet} in \cref{table:results-3dmatch}(top and middle).
Following~\cite{bai2020d3feat,huang2021predator}, we report the results with different numbers of correspondences.
The details of the correspondence sampling schemes are given in Appx.~A.3.
For \emph{Feature Matchig Recall}, our method achieves improvements of at least $5\%$ on 3DLoMatch, demonstrating its effectiveness in low-overlap cases.
For \emph{Inlier Ratio}, the improvements are even more prominent.
It surpasses the baselines consistently by $7\%$ $\sim$ $33\%$ on 3DMatch and $17\%$ $\sim$ $31\%$ on 3DLoMatch.
The gain is larger with less correspondences.
It implies that our method extracts more reliable correspondences.
\vspace{-10pt}
\paragraph{Registration results.}
\label{sec:exp-registration}
To evaluate the registration performance, we first compare the \emph{Registration Recall} obtained by RANSAC in \cref{table:results-3dmatch}(bottom).
Following~\cite{bai2020d3feat,huang2021predator}, we run $50$K RANSAC iterations to estimate the transformation.
GeoTransformer attains new state-of-the-art results on both 3DMatch and 3DLoMatch.
It outperforms the previous best by $1.2\%$ on 3DMatch and $7.5\%$ on 3DLoMatch, showing its efficacy in both high- and low-overlap scenarios.
More importantly, our method is quite stable under different numbers of samples, so it does not require sampling a large number of correspondences to boost the performance as previous methods \cite{choy2019fully,ao2021spinnet,wang2021you,yu2021cofinet}.
\begin{table}[!t]
\scriptsize
\setlength{\tabcolsep}{1pt}
\centering
\begin{tabular}{l|c|c|cc|ccc}
\toprule
\multirow{2}{*}{Model} & \multirow{2}{*}{Estimator} & \multirow{2}{*}{\#Samples} & \multicolumn{2}{c|}{RR(\%)} & \multicolumn{3}{c}{Time(s)} \\
& & & 3DM & 3DLM & Model & Pose & Total\\
\midrule
FCGF~\cite{choy2019fully} & RANSAC-\emph{50k} & 5000 & 85.1 & 40.1 & 0.052 & 3.326 & 3.378 \\
D3Feat~\cite{bai2020d3feat} & RANSAC-\emph{50k} & 5000 & 81.6 & 37.2 & 0.024 & 3.088 & 3.112 \\
SpinNet~\cite{ao2021spinnet} & RANSAC-\emph{50k} & 5000 & 88.6 & 59.8 & 60.248 & 0.388 & 60.636 \\
Predator~\cite{huang2021predator} & RANSAC-\emph{50k} & 5000 & 89.0 & 59.8 & 0.032 & 5.120 & 5.152 \\
CoFiNet~\cite{yu2021cofinet} & RANSAC-\emph{50k} & 5000 & \underline{89.3} & \underline{67.5} & 0.115 & 1.807 & 1.922 \\
GeoTransformer (\emph{ours}) & RANSAC-\emph{50k} & 5000 & \textbf{92.0} & \textbf{75.0} & 0.075 & 1.558 & 1.633 \\
\midrule
FCGF~\cite{choy2019fully} & weighted SVD & 250 & 42.1 & 3.9 & 0.052 & 0.008 & 0.056 \\
D3Feat~\cite{bai2020d3feat} & weighted SVD & 250 & 37.4 & 2.8 & 0.024 & 0.008 & 0.032 \\
SpinNet~\cite{ao2021spinnet} & weighted SVD & 250 & 34.0 & 2.5 & 60.248 & 0.006 & 60.254 \\
Predator~\cite{huang2021predator} & weighted SVD & 250 & 50.0 & 6.4 & 0.032 & 0.009 & 0.041 \\
CoFiNet~\cite{yu2021cofinet} & weighted SVD & 250 & \underline{64.6} & \underline{21.6} & 0.115 & 0.003 & 0.118 \\
GeoTransformer (\emph{ours}) & weighted SVD & 250 & \textbf{86.5} & \textbf{59.9} & 0.075 & 0.003 & 0.078 \\
\midrule
CoFiNet~\cite{yu2021cofinet} & LGR & all & 87.6 & 64.8 & 0.115 & 0.028 & 0.143 \\
GeoTransformer (\emph{ours}) & LGR & all & \textbf{91.5} & \textbf{74.0} & 0.075 & 0.013 & 0.088 \\
\bottomrule
\end{tabular}
\vspace{-5pt}
\caption{
Registration results w/o RANSAC on 3DMatch (3DM) and 3DLoMatch (3DLM).
The \emph{model time} is the time for network inference, while the \emph{pose time} is for transformation estimation.
}
\label{table:direct}
\vspace{-10pt}
\end{table}
We then compare the registration results \emph{without} using RANSAC in \cref{table:direct}.
We start with weighted SVD over correspondences in solving for alignment transformation.
The baselines either fail to achieve reasonable results or suffer from severe performance degradation.
In contrast, GeoTransformer (with weighted SVD) achieves the registration recall of $86.5\%$ on 3DMatch and $59.9\%$ on 3DLoMatch, close to Predator with RANSAC.
Without outlier filtering by RANSAC, high inlier ratio is necessary for successful registration.
However, high inlier ratio does not necessarily lead to high registration recall since the correspondences could cluster together as noted in~\cite{huang2021predator}. Nevertheless, our method without RANSAC performs well by extracting reliable and well-distributed superpoint correspondences.
When using our local-to-global registration (LGR) for computing transformation, our method brings the registration recall to $91.5\%$ on 3DMatch and $74.0\%$ on 3DLoMatch, surpassing all RANSAC-based baselines by a large margin.
The results are also very close to those of ours with RANSAC, but LGR gains over $100$ times acceleration over RANSAC in the pose time.
These results demonstrate the superiority of our method in both accuracy and speed.
\input{figures/gallery}
\vspace{-10pt}
\paragraph{Ablation studies.}
\label{sec:exp-ablation}
\begin{table}[!t]
\scriptsize
\setlength{\tabcolsep}{3pt}
\centering
\begin{tabular}{l|cccc|cccc}
\toprule
\multirow{2}{*}{Model} & \multicolumn{4}{c|}{3DMatch} & \multicolumn{4}{c}{3DLoMatch} \\
& PIR & FMR & IR & RR & PIR & FMR & IR & RR \\
\midrule
(a) graph neural network & 73.3 & 97.9 & 56.5 & 89.5 & 39.4 & 84.9 & 29.2 & 69.8 \\
(b) vanilla self-attention & 79.6 & 97.9 & 60.1 & 89.0 & 45.2 & 85.6 & 32.6 & 68.4 \\
(c) self-attention w/ ACE & 83.2 & \textbf{98.1} & 68.5 & 89.3 & 48.2 & 84.3 & 38.9 & 69.3 \\
(d) self-attention w/ RCE & 80.0 & 97.9 & 66.1 & 88.5 & 46.1 & 84.6 & 37.9 & 68.7 \\
(e) self-attention w/ RDE & \underline{84.9} & \underline{98.0} & \underline{69.1} & \underline{90.7} & \underline{50.6} & \underline{85.8} & \underline{40.3} & \underline{72.1} \\
(f) geometric self-attention & \textbf{86.1} & 97.7 & \textbf{70.3} & \textbf{91.5} & \textbf{54.9} & \textbf{88.1} & \textbf{43.3} & \textbf{74.0} \\
\bottomrule
\end{tabular}
\vspace{-5pt}
\caption{
Ablation experiments of the geometric self-attention.
}
\label{table:ablation-study-rge}
\vspace{-10pt}
\end{table}
\begin{table}[!t]
\scriptsize
\setlength{\tabcolsep}{2.5pt}
\centering
\begin{tabular}{l|cccc|cccc}
\toprule
\multirow{2}{*}{Model} & \multicolumn{4}{c|}{3DMatch} & \multicolumn{4}{c}{3DLoMatch} \\
& PIR & FMR & IR & RR & PIR & FMR & IR & RR \\
\midrule
(a) cross-entropy loss & 80.0 & 97.7 & 65.7 & 90.0 & 45.9 & 85.1 & 37.4 & 68.4 \\
(b) weighted cross-entropy loss & 83.2 & \textbf{98.0} & 67.4 & 90.0 & 49.0 & \underline{86.2} & 38.6 & 70.7 \\
(c) circle loss & \underline{85.1} & \underline{97.8} & \underline{69.5} & \underline{90.4} & \underline{51.5} & 86.1 & \underline{41.3} & \underline{71.5} \\
(d) overlap-aware circle loss & \textbf{86.1} & 97.7 & \textbf{70.3} & \textbf{91.5} & \textbf{54.9} & \textbf{88.1} & \textbf{43.3} & \textbf{74.0} \\
\bottomrule
\end{tabular}
\vspace{-5pt}
\caption{
Ablation experiments of the overlap-aware circle loss.
}
\label{table:ablation-study-ocl}
\vspace{-10pt}
\end{table}
We conduct extensive ablation studies for a better understanding of the various modules in our method.
To evaluate superpoint (patch) matching, we introduce another metric \emph{Patch Inlier Ratio} (PIR) which is the fraction of patch matches with actual overlap.
The FMR and IR are reported with \emph{all} dense point correspondences, with LGR being used for registration.
To study the effectiveness of the \emph{geometric self-attention}, we compare six methods for intra-point-cloud feature learning in \cref{table:ablation-study-rge}:
(a) graph neural network~\cite{huang2021predator}, (b) self-attention with no positional embedding~\cite{yu2021cofinet}, (c) absolute coordinate embedding~\cite{sarlin2020superglue}, (d) relative coordinate embedding~\cite{zhao2021point}, (e) pair-wise distance embedding, and (f) geometric structure embedding.
Generally, injecting geometric information boosts the performance.
But the gains of coordinate-based embeddings are limited due to their transformation variance.
Surprisingly, GNN performs well on RR. This is because $k$NN graphs are transformation-invariant.
However, it suffers from limited receptive fields which harms the IR performance.
Our method outperforms the alternatives by a large margin on all the metrics, especially in the low-overlap scenarios, even with only the pair-wise distance embedding.
Note that all methods use the same point matching module, so the improvements come from the more accurate superpoint correspondences.
\input{figures/attention}
Next, we ablate the \emph{overlap-aware circle loss} in \cref{table:ablation-study-ocl}.
We compare four loss functions for supervising the superpoint matching: (a) cross-entropy loss~\cite{sarlin2020superglue}, (b) weighted cross-entropy loss~\cite{yu2021cofinet}, (c) circle loss~\cite{sun2020circle}, and (d) overlap-aware circle loss.
For the first two models, an optimal transport layer is used to compute the matching matrix as in~\cite{yu2021cofinet}.
Circle loss works much better than the two variants of cross-entropy loss, verifying the effectiveness of supervising superpoint matching in a metric learning fashion.
Our overlap-aware circle loss beats the vanilla circle loss by a large margin on all the metrics.
\vspace{-10pt}
\paragraph{Qualitative results.}
\cref{fig:gallery} provides a gallery of the registration results of the models with vanilla self-attention and our geometric self-attention.
Geometric self-attention helps infer patch matches in structure-less regions from their geometric relationships to more salient regions ($1^{\text{st}}$ row) and reject outlier matches which are similar in the feature space but different in positions ($2^{\text{nd}}$ and $3^{\text{rd}}$ rows).
\cref{fig:attention} visualizes the attention scores learned by our geometric self-attention, which exhibits significant consistency between the anchor patch matches.
It shows that our method is able to learn inter-point-cloud geometric consistency which is important to accurate correspondences.
\subsection{Outdoor Benchmark: KITTI odometry}
\label{sec:exp-outdoor}
\paragraph{Dataset.}
KITTI odometry~\cite{geiger2012we} consists of 11 sequences of outdoor driving scenarios scanned by LiDAR.
We follow~\cite{choy2019fully,bai2020d3feat,huang2021predator} and use sequences 0-5 for training, 6-7 for validation and 8-10 for testing.
As in~\cite{choy2019fully,bai2020d3feat,huang2021predator}, the ground-truth poses are refined with ICP and we only use point cloud pairs that are at most $10\text{m}$ away for evaluation.
\vspace{-10pt}
\paragraph{Metrics.}
We follow~\cite{huang2021predator} to evaluate our GeoTransformer with three metrics:
(1) \emph{Relative Rotation Error} (RRE), the geodesic distance between estimated and ground-truth rotation matrices,
(2) \emph{Relative Translation Error} (RTE), the Euclidean distance between estimated and ground-truth translation vectors, and
(3) \emph{Registration Recall} (RR), the fraction of point cloud pairs whose RRE and RTE are both below certain thresholds (\ie, RRE$<$5$^\circ$ and RTE$<$2m).b
\begin{table}[!t]
\scriptsize
\centering
\begin{tabular}{l|ccc}
\toprule
Model & RTE(cm) & RRE($^{\circ}$) & RR(\%) \\
\midrule
3DFeat-Net~\cite{yew20183dfeat} & 25.9 & \textbf{0.25} & 96.0 \\
FCGF~\cite{choy2019fully} & 9.5 & 0.30 & \underline{96.6} \\
D3Feat~\cite{bai2020d3feat} & \underline{7.2} & 0.30 & \textbf{99.8} \\
SpinNet~\cite{ao2021spinnet} & 9.9 & 0.47 & 99.1 \\
Predator~\cite{huang2021predator} & \textbf{6.8} & \underline{0.27} & \textbf{99.8} \\
CoFiNet~\cite{yu2021cofinet} & 8.2 & 0.41 & \textbf{99.8} \\
GeoTransformer (\emph{ours}, RANSAC-\emph{50k}) & 7.4 & \underline{0.27} & \textbf{99.8} \\
\midrule
FMR~\cite{huang2020feature} & $\sim$66 & 1.49 & 90.6 \\
DGR~\cite{choy2020deep} & $\sim$32 & 0.37 & 98.7 \\
HRegNet~\cite{lu2021hregnet} & $\sim$\underline{12} & \underline{0.29} & \underline{99.7} \\
GeoTransformer (\emph{ours}, LGR) & \textbf{6.8} & \textbf{0.24} & \textbf{99.8} \\
\bottomrule
\end{tabular}
\vspace{-5pt}
\caption{
Registration results on KITTI odometry.
}
\vspace{-10pt}
\label{table:kitti}
\end{table}
\vspace{-10pt}
\paragraph{Registration results.}
In \cref{table:kitti}(top), we compare to the state-of-the-art \emph{RANSAC-based} methods: 3DFeat-Net~\cite{yew20183dfeat}, FCGF~\cite{choy2019fully}, D3Feat~\cite{bai2020d3feat}, SpinNet~\cite{ao2021spinnet}, Predator~\cite{huang2021predator} and CoFiNet~\cite{yu2021cofinet}.
Our method performs on par with these methods, showing good generality on outdoor scenes.
We further compare to three \emph{RANSAC-free} methods in \cref{table:kitti}(bottom): FMR~\cite{huang2020feature}, DGR~\cite{choy2020deep} and HRegNet~\cite{lu2021hregnet}.
Our method outperforms all the baselines by large margin.
In addition, our method with LGR beats all the RANSAC-based methods.
|
{'timestamp': '2022-02-15T02:44:03', 'yymm': '2202', 'arxiv_id': '2202.06688', 'language': 'en', 'url': 'https://arxiv.org/abs/2202.06688'}
|
arxiv
|
\section{Introduction}
In many countries, large amounts of renewable energy sources (RES) are integrated in the power system and they increase the operational uncertainty due to their fluctuating nature. In a power system, supply and demand of electric power must be balanced to keep frequency and voltage close to their nominal values. To maintain this balance, transmission system operators (TSOs) procure ancillary services (AS), e.g., frequency and voltage control, traditionally from conventional generators. With increasing RES shares, the need for AS is also increasing \cite{makarov_operational_2009}. For this reason, there has been a recent interest in offering AS by flexible loads, which is known as demand response (DR). If properly aggregated, loads can provide AS without environmental impacts and, possibly, more efficiently and at a lower cost compared to generators \cite{callaway_achieving_2011}.
Loads with thermal storage are suitable for DR because their consumption can be shifted in time without impact on consumer comfort. A lot of research focused on modeling, control, and estimation of large aggregations of thermostatically controlled loads (TCLs), i.e., small residential loads such as refrigerators, air conditioners, space and water heaters \cite{kalsi_development_2012,Vrettos2012,Perfumo2012,mathieu_state_2013,VrettosPSCC2014}. The heating, ventilation, and air conditioning (HVAC) systems of commercial buildings are also interesting for DR because they are large consumers with high thermal inertia, and they usually include a building automation and communication system that facilitates DR implementation \cite{IREP2013}. Recently, DR applications with commercial buildings has been the topic of several papers some of which are summarized below. The role of information systems and automated model-based control for energy efficiency and DR was discussed in \cite{pietteLBNL2012}. Commercial HVAC systems are typically complex with many control variables and cascaded loops, and thus low-order models are used for control purposes \cite{Sturzenegger2013Experiment,Lehmann_2013,Goddard2014}. Research on DR with commercial buildings has focused mainly on ``slow'' services. For example, \cite{Braun1990,Oldewurtel2010,Ma2012,VrettosECC2013} proposed optimization-based approaches and model predictive control (MPC) for peak shedding or load shifting to minimize energy costs.
This paper is concerned with frequency control with commercial buildings, in particular secondary frequency control (SFC), which is also known as automatic generation control (AGC), load frequency control (LFC), automatic frequency restoration reserve (FRR), or regulation service. Recently, some authors have considered either scheduling or provision of ``fast'' AS from commercial buildings including SFC reserves. Ref. \cite{kiliccote_field_2012} experimentally investigated the feasibility of offering up and down regulation products with university campus buildings, and identified baseline prediction and latency as potential obstacles for implementation. The authors of \cite{Hao2013Allerton,Hao2013ACC} investigated SFC via fan power control in buildings with variable air volume (VAV) systems. Based on simulations, the authors found that up to $15\%$ of a building's fan power can be offered as reserves without significant loss of comfort, if the SFC signal is within the frequency band $f \in [1/(10~\textrm{min}), 1/(4~\textrm{sec})]$. In \cite{LinTSG2014}, a control approach similar to that of \cite{Hao2013Allerton,Hao2013ACC} was experimentally validated in a real building, but without considering frequencies below $1/(10~\textrm{min})$ to avoid effects on chiller power consumption. The follow-up work \cite{LinIEEESGCom2013} included chiller control, which enlarged the frequency band of SFC signals to $1/(60~\textrm{min})$. Ref. \cite{Kim2014} investigated SFC by direct control of a heat pump's (HP) compressor power using a variable speed drive motor in a water-based HVAC system.
Apart from accurate tracking of the SFC signal, a TSO needs guarantees that the reserve capacity of commercial buildings will be \emph{reliably} available. Because the buildings are energy-constrained resources reserve scheduling is required, in particular if the SFC signal is not approximately zero-energy over short periods but can be biased towards one direction over long periods of time. A priori reserve scheduling allows buildings to participate in markets for such reserve products without compromising occupants' comfort. Ref. \cite{MaasoumyACC2014paper1} addressed this issue by developing an MPC-based method to quantify the flexibility of a commercial building and a contractual framework to declare it to the utility. In this paper, we follow this line of research and consider robust reserve scheduling for \emph{aggregations} of commercial buildings.
The main contributions of this paper are threefold. First, we propose a new framework to estimate the SFC reserve \emph{capacity} that can be reliably offered by an aggregation of commercial buildings considering weather conditions, occupancy, electricity prices, reserve payments, and comfort zone. The framework builds on a hierarchical control scheme with three levels, namely reserve scheduling and allocation, HVAC control, and reserve provision, and is based on robust optimization and MPC. The framework actively allocates reserves among aggregation's buildings based on their individual characteristics, which is expected to maximize the reserve potential in markets with typical requirements such as constant reserve capacity over a minimum duration and/or equal up- and down-reserve capacities. This is in contrast to \cite{Hao2013Allerton,Hao2013ACC,LinIEEESGCom2013} that estimated the capacity of a group of buildings by simply scaling up the estimated capacity of a single building. Second, we propose new methods to estimate reserve capacities in case of energy-constrained frequency signals, a practice adopted by several TSOs for loads or storage devices, e.g., \cite{PJMASmanual}. This is a significant advantage of our method compared to \cite{MaasoumyACC2014paper1}. A relevant approach is taken in \cite{Barooah2015HICSS}, where the reliable AS capacity from a commercial building is expressed as a function of the AS signal's frequency. In contrast to \cite{Barooah2015HICSS}, we are interested in the dependence of capacity on the integral of the SFC signal, i.e., on the signal's bias directly, which we believe is the major limiting factor when extracting reserves from energy-constrained resources. Third, we derive upper bounds on the untapped potential for SFC by different building types and for different reserve product characteristics such as duration, symmetry, and energy content.
Although in some cases the SFC signal is approximately zero-energy, this is not generally true for all power systems. Ideally the bias of the SFC signal would be obtained from generators, e.g., through activation of tertiary control reserves or in a nearly real-time (e.g., 5 minute) market. However, nearly real-time markets do not exist in many control areas, and activation of tertiary control reserves is not always more economical than SFC reserves, because it highly depends on the the availability of cheap and flexible generators. In addition, with increasing RES penetration in power systems, the share of conventional generators in the production mix will decrease. Despite the improvements in forecasting techniques, the RES forecasts will never be perfect and biased forecast errors will translate into biased SFC signals. With fewer controllable generators in the production mix, other resources will have to absorb these biases. For this reason, we believe that accounting for biases in the SFC signal will be very important in the future, possibly also in power systems where the SFC signal is today approximately zero-energy. To the authors' best knowledge, this is the first time that methods are proposed to allow building aggregations to systematically schedule the reserve capacity that they can offer depending on how much bias exists in the SFC signal.
This paper includes substantial extensions over our previous work \cite{VrettosIFAC2014}, where some preliminary results were presented. A major improvement is related to modeling of the SFC reserve requests within the reserve scheduling and building control optimization problems. This paper considers also energy-constrained SFC signals apart from conventional unconstrained signals, whereas \cite{VrettosIFAC2014} considered only the latter. In the absence of energy constraints, the worst case reserve request is equal to either the up- or down-reserve capacity along the whole scheduling horizon. The reserve scheduling problem for this case was cast as a robust optimization problem with additive uncertainty in \cite{VrettosIFAC2014}. On the contrary, the determination of the worst case reserve request along the scheduling horizon is more involved with energy constraints due to time coupling. In this paper, we model an energy-constrained SFC signal as an uncertain variable that lives in a polyhedral uncertainty set and enters multiplicatively in the constraints. This allows us to reformulate the robust reserve scheduling problem into a deterministic tractable one. Another main extension is related to the number and type of actuators that provide reserves in each building. In contrast to \cite{VrettosIFAC2014} that assumed either only heating or only cooling actuators per building, the proposed formulations can be used to allocate reserves among different types of actuators within the same building. Therefore, the proposed formulations are more general than the ones in \cite{VrettosIFAC2014}. In addition, the simulation studies of this paper contain new material compared with \cite{VrettosIFAC2014}. We analyze recorded data of the Swiss SFC signal to illustrate that the SFC signal is not necessarily approximately zero-energy, but it can be significantly biased over periods of several hours. The performance of the control framework is then evaluated using an energy-constrained SFC signal, whereas the sensitivity analysis is performed considering signals with and without energy constraints.
The rest of the paper is organized as follows: Section~\ref{FreqCtrl} summarizes some important aspects of power system SFC, Sections~\ref{Modeling} and~\ref{ControllerDesign} introduce the modeling and control framework, the performance of the framework is demonstrated and evaluated in Section~\ref{ControllerPerformance} in a simulation example, a sensitivity analysis is performed in Section~\ref{SensitivityAnalysis}, and Section~\ref{Conclusion} concludes the paper.
\section{Frequency Control in Power Systems} \label{FreqCtrl}
Typically, a TSO controls frequency in three steps: primary, secondary and tertiary control. Primary control is a distributed, proportional controller that stabilizes the frequency after a disturbance. Secondary control is a centralized, proportional-integral (PI) controller that restores the frequency to its nominal value and maintains the desired exchanges between neighboring control areas. Tertiary control releases secondary control in case of large disturbances and is typically manually activated.
Before continuing, we summarize some important aspects of scheduling and activation of SFC in power systems \cite{ENTSOE_AS_survey2014}, which will be particularly relevant to the sensitivity analysis of Section~\ref{SensitivityAnalysis}. In most of Europe, SFC reserves are procured in a market setting, i.e., the generators bid their reserve capacity and price in weekly or daily auctions. The requirements of these auctions and the characteristics of the SFC reserve products vary from country to country. The minimum bid size is typically in the range $[1,10]$ MW, e.g., $5$~MW in Switzerland \cite{swissgridAS}. In many countries, only symmetric reserves, i.e., equal up- and down-reserve capacities, are allowed, whereas in other countries asymmetric reserves are also accepted. The reserve energy is requested from the generators via a signal sent by the TSO, typically every $2-4$ seconds. There are two main activation rules: (a) the pro-rata activation, where the reserve energy is proportional to the capacity, and (b) the merit-order activation, where the reserves are requested based on the short term marginal costs of generators. The remuneration of reserve energy is also country dependent but it is typically separate from the reserve capacity remuneration. In some countries, e.g., in Switzerland, the reserve energy remuneration is coupled with the energy price in the spot market. As a final remark, note that we treat the SFC signal as uncertain in this paper because it is unknown at the time when the reserve capacities are determined.
\section{Modeling} \label{Modeling}
\subsection{Building Aggregation} \label{BldModeling}
We consider buildings with integrated room automation (IRA) systems, where heating, cooling, ventilation, blinds, and lighting are jointly controlled. IRA is typically used in office buildings because it provides high comfort while being energy efficient \cite{Oldewurtel2011}. We represent building \emph{thermal} dynamics using a well-tested $12^{\textrm{th}}$ order multiple-input-multiple-output bilinear model \cite{Lehmann_2013}. This model is based on the widespread thermal resistance-capacitance network approach, and was validated against the well-known building simulation software TRNSYS \cite{Lehmann_2013}. The model's satisfactory accuracy and its relatively low complexity make it suitable for MPC. A model similar to the one considered here was used in an MPC implementation in a real building, and it was found that it captures the building thermal dynamics well \cite{Sturzenegger2013Experiment}. Furthermore, this model is flexibly customizable and allows us to perform large-scale simulation studies with different representative building types.
The original model is bilinear between inputs $u$ and disturbances $v$ (e.g., blind position and solar radiation), as well as between inputs and states $x$ (e.g., blind position and room temperature). If the disturbances are fixed, e.g., according to their predicted values, the bilinearities between $u$ and $v$ vanish and the system becomes time-varying. However, the bilinearities between $x$ and $u$ remain. For optimization purposes, sequential linear programming (SLP) can be applied by iteratively linearizing the bilinear $x$ terms around the most recently calculated $x$ trajectory and solving the resulting linear program (LP) until convergence \cite{Oldewurtel2011}.
If SLP is applied, the dynamics of a building $b$ can be described by the linear time-varying model
\begin{align}
x^b_{t+1} &= A^bx_t^b +B^b_t u^b_t +E^bv^b_t +R^b\Delta{u}^b_t~, \label{OriginalModel1}
\end{align}
where $x^b_t \in \Rset^{n_x}$ denotes the states at time step $t$ ($n_x$ is the number of states), i.e., the room air temperature as well as the temperatures in different layers in the walls, floor, and ceiling (all measured in $^o$C). $u^b_t \in \Rset^{n_u}$ denotes the IRA control inputs, namely heating and cooling power, ventilation, blind position, and lighting ($n_u$ is the number of actuators). The heating and cooling are represented in the thermal model as heat fluxes affecting the system states and their units are W/m$^2$, i.e., the heat fluxes are normalized by the floor area. The blind position is a number between $0$ (fully closed) and $1$ (fully open). The lighting is also normalized by the floor area and measured in W/m$^2$. $v^b_t \in \Rset^{n_v}$ denotes the disturbances that affect building's states, e.g., ambient temperature in $^o$C, solar radiation in W/m$^2$, and internal heat gains by occupants and equipment in W/m$^2$ ($n_v$ is the number of disturbances). $\Delta{u}^b_t \in \Rset^{n_r}$ denotes the uncertain change in heat fluxes due to change in power consumption of the heating/cooling devices during reserve provision, where $n_r \leq n_u$ is the number of actuators that are used for reserve provision. $R^b$ consists of the columns of $B^b_t$ that correspond to the heating/cooling actuators that provide reserves. The system's output equation is $y^b_{t} = C^bx_t^b +D^b_t u^b_t +F^bv^b_t$, where $y^b_t \in \Rset^{n_y}$ denotes the room temperature in $^o$C and illuminance in lux.
Denote by $r_{e,t}^{b,j}$ the (electric) reserve capacity of actuator $j$ of building $b$ at time step $t$. Buildings can provide \emph{up-reserves} by decreasing their consumption, and \emph{down-reserves} by increasing it\footnote{The (electric) reserve capacity is the amount of SFC reserves that becomes available to the TSO \cite{ENTSOEnetworkCode}. In the context of frequency regulation, the term up-reserves denotes increase of a generator's production or decrease of a load's consumption to increase system frequency. Similarly, the term down-reserves denotes decrease of a generator's production or increase of a load's consumption to decrease system frequency.}. For now, we assume symmetric reserve capacities; asymmetric reserves will be discussed in Section~\ref{ControllerDesign}. Since the HVAC control input for heating and cooling is defined as a heat flux, it is convenient to define also the ``thermal'' reserve capacity $r_t^{b,j}$ that has W/m$^2$ units. $r_{e,t}^{b,j}$ can be obtained from $r_t^{b,j}$ by division with the coefficient of performance (COP). For notational convenience, we use the variable $r_t^{b,j}$ in the problem formulations and call it simply reserve capacity keeping in mind that it is actually the ``thermal'' reserve capacity. In the pro-rata activation case, the reserve energy is proportional to the reserve capacity based on a normalized SFC signal \mbox{$w_t \in [-1,1]$}. Note that the reserve capacity $r_t^{b,j}$ is a decision variable for the buildings, whereas the normalized SFC signal $w_t$ is uncertain. The primitive uncertainty $w_t$ results in an uncertain change in electric power consumption of actuator $j$, $\Delta{u}_{e,t}^{b,j} = r_{e,t}^{b,j} w_t$ and the corresponding uncertain change in heat flux $\Delta{u}_t^{b,j} = r_t^{b,j} w_t$.
Denote by $x^b_{t+k|t} \in \mathbb{R}^{n_x}$ the predicted state of building $b$ for time $t+k$ at time $t$. The predicted states at time $t$ along a prediction horizon $N$ are assembled in one vector as $\x^b_t = [x^b_{t|t}~~x^b_{t+k|t}~...~x^b_{t+N|t}]^\top \in \mathbb{R}^{n_x(N+1)}$. Adopting the same notation for inputs and disturbances, the building dynamics along $N$ can be written as $\x^b_t = \A^bx^b_0 + \B_t^b \u^b_t + \E^b \v^b_t + \R^b \boldsymbol{\Delta{u}}^b_t$ and $\y^b_{t} = \C^b \x_t^b + \D^b_t \u^b_t + \F^b \v^b_t$, where the matrices $\A^b, \B^b_t$, $\E^b$, $\R^b$, $\C^b$, $\D^b_t$, and $\F^b$ are of appropriate dimensions. The constraints on outputs (thermal comfort zone) and HVAC control inputs along $N$ are
\begin{align}
\y^b_{\textrm{min}} \leq \y^b_{t} \leq \y^b_{\textrm{max}}~,~~
\u^b_{\textrm{min}} \leq \u^b_t + \Hb^b \boldsymbol{\Delta{u}}^b_t \leq \u^b_{\textrm{max}}~, \label{yu_cons}
\end{align}
where $\Hb^b \in \mathbb{R}^{n_u \times n_r}$ has $0$ or $1$ as entries. By substituting the dynamics in \eqref{yu_cons}, the constraints can be written in terms of the control inputs and uncertainty as $\G^b \u^b_t + \Ss^b \boldsymbol{\Delta{u}}^b_t \leq \Q^b$, where the matrices $\G^b$, $\Ss^b$, and $\Q^b$ are defined as
\begin{align}
& \G^b = \begin{bmatrix}
\G^b_p \\
\Ib_N \\
-\G^b_p \\
-\Ib_N
\end{bmatrix},
\Ss^b = \begin{bmatrix}
\Ss^b_p \\
\Hb^b \\
-\Ss^b_p \\
-\Hb^b
\end{bmatrix},
\Q^b = \begin{bmatrix}
\y^b_{\textrm{max}}-\Q^b_p \\
\u^b_{\textrm{max}} \\
\Q^b_p - \y^b_{\textrm{min}} \\
-\u^b_{\textrm{min}}
\end{bmatrix}, \label{GbSbQb}\\
& \G^b_p = \C^b \B_t^b + \D^b_t~,~ \Ss^b_p = \C^b \R^b~, \label{GpbSpb} \\
& \Q^b_p = \C^b (\A^bx^b_0 + \E^b \v^b_t) + \F^b \v^b_t~, \label{Qpb}
\end{align}
and $\Ib_N$ is the N-dimensional identity matrix. Using $\G^b$, $\Ss^b$, and $\Q^b$, the HVAC input and comfort zone constraints along the prediction horizon can be represented compactly in the optimization problems of Section~\ref{ControllerDesign}.
We are interested in building aggregations for two main reasons. First, the reserve markets typically have requirements on the minimum size of the bidden reserve capacity, which is typically in the range $[1,10]$ MW, as mentioned in Section~\ref{FreqCtrl}. In most cases, individual commercial buildings cannot meet these minimum bid size requirements, so building aggregations are needed to enable participation in the reserve market. Even in markets with low minimum bid size requirements, e.g., in the range of a few hundred kWs, building aggregations would still be of interest in presence of other typical requirements, such as symmetry and minimum duration of the bidden reserve capacity. As shown in \cite{VrettosIFAC2014}, aggregating buildings with different characteristics results in a larger total reserve capacity compared with the case where each building participates individually in the market. The second argument in favor of building aggregations is more practical. An aggregator's job would be to determine the reserve capacity, bid it in the reserve market, and interact with the TSO during reserve activation and for the financial settlement. These tasks are very different to the normal activities of a building manager; therefore, the aggregator could take over this burden that would otherwise be with the building manager.
Consider an aggregation of $L$ buildings, i.e., $b=\{1 \ldots L\}$. Denote by $\x_{t}=\left[\x^1_t~~\x^2_t~...~\x^L_{t}\right]^\top \in \mathbb{R}^{n_xL(N+1)}$ the vector containing all predicted states of all buildings along $N$. Using the same notation for inputs and disturbances, the input/output constraints of the aggregation can be written as $\G \u_t + \Ss \boldsymbol{\Delta{u}}_t \leq \Q$, where $\G$, $\Ss$, and $\Q$ are block diagonal matrices with $\G^b$, $\Ss^b$, and $\Q^b$ on the diagonal, respectively. Denoting by $\w_t \in [-1,1]^{N}$ the SFC signal along $N$, and by \mbox{$\r_t \in \Rset^{n_r L N}$} a collection of the reserve capacities of all actuators and all buildings along $N$, the input/output constraints of the aggregation can be written as
\begin{align}
\tilde{\R} =
\begin{bmatrix}
R_{1,1} & \hspace{-0.2cm} 0 & \hspace{-0.2cm} \ldots & \hspace{-0.2cm} & \hspace{-0.4cm} 0 \vspace{-0.1cm} \\
R_{2,1} & \hspace{-0.2cm} R_{2,2} & \hspace{-0.2cm} 0 & \hspace{-0.2cm} \ldots & \hspace{-0.4cm} 0 \vspace{-0.3cm} \\
& \hspace{-0.2cm} & \hspace{-0.2cm} \vdots \vspace{-0.3cm} \\
R_{N,1} & \hspace{-0.2cm} R_{N,2} & \hspace{-0.2cm} \ldots & \hspace{-0.2cm} & \hspace{-0.4cm} R_{N,N}
\end{bmatrix},
\G \u_t + \Ss \tilde{\R} \w_t \leq \Q~,
\end{align}
where $\mathbf{\Delta{u}}_t = \tilde{\R} \w_t$, $\tilde{\R} \in \Rset^{\left(n_r L N\right) \times N}$ is the \emph{reserve capacity matrix}, and $R_{i,k} \in \Rset^{n_r L}$ is a column vector. The diagonal vectors of $\tilde{\R}$ are the actuators' reserve capacities for every time step $t$, i.e., $R_{t,t} = [ r_t^1 \ldots r_t^{n_rL}]^\top$. This lower triangular structure satisfies causality and allows us to model the effect of past SFC signals. For example, $R_{t,t-1}$ accounts for the signal at time $t-1$ to determine the reserve at time $t$. However, to comply with today's practice we fix $R_{i,k} = 0$ for $i \neq k$ in the following, i.e., the reserve energy depends only on the capacity and the current SFC signal. Thus, $\tilde{\R}$ is a block diagonal version of $\r_t$.
\subsection{Uncertain Frequency Signals} \label{UncertaintyModeling}
\subsubsection{Power Constraints (PC)}
In pro-rata activation \cite{swissgridAS}, the reserves are requested by the TSO via a normalized frequency signal $w_t \in [-1,1]$. This box constraint represents the power constraints of the signal. The values $w_t=-1$ and $w_t=1$ indicate full activation of up- and down-reserves, respectively. The uncertainty set along $N$ can be written as
\begin{align}
\Wset_1 = \{\w_t \in \Rset^N : ||\w_t||_\infty \leq 1 \}~. \label{Wset1}
\end{align}
\subsubsection{Power and Energy Constraints (PEC)}
To facilitate the participation of energy-constrained resources (thermal loads and storages) in AS, the frequency signals can be distinguished by their energy content. A building aggregation could then choose the preferred product to offer reserves. Energy constraints can be cast as linear constraints on the mean value of the signal as
\begin{align}
-\varepsilon T \leq \sum\nolimits_{k=t}^{t+T-1} w_k \leq \varepsilon T~, \label{EnergyCons}
\end{align}
where $\varepsilon$ is the bias coefficient, $T$ is the averaging period, and both are fixed by the TSO for a particular product. Equation \eqref{EnergyCons} implies that the bias of the signal over $T$ is bounded. If we stack \eqref{EnergyCons} along $N$, we get the polyhedral constraint on the uncertainty \mbox{$\A_w \w_t \leq \b_w$}, where $\A_w$ is a matrix with entries $-1$, $0$ or $1$, and $\b_w$ is a vector with entries $\varepsilon T$. The power constraints \eqref{Wset1} are still present, since the full reserve capacity could be requested anytime. Denote by $\I_N$ the N-dimensional identity matrix, and by $\bold{1}_N$ the N-dimensional vector with ones. Defining $\bar{\A}_w = [\A_w; \I_N; -\I_N]$ and $\bar{\b}_w = [\b_w; \bold{1}_N; \bold{1}_N]$, the uncertainty set for PEC is
\begin{align}
\Wset_2 = \{\w_t \in \Rset^N : \bar{\A}_w \w_t \leq \bar{\b}_w \}~. \label{EnergyCons3}
\end{align}
\subsection{Other Sources of Uncertainty} \label{OtherUncert}
Apart from the SFC signal, in general, there are two other sources of uncertainty associated with our problem: (a) weather and occupancy uncertainties, i.e., deviations from the predicted values, and (b) electricity and reserve price uncertainties. For simplicity, weather/occupancy uncertainties are not considered in this paper, i.e., the predictions are assumed to be perfect. There exist several approaches in the literature of building climate control to handle these uncertainties such as stochastic MPC with additive Gaussian noise \cite{Oldewurtel2011}, scenario-based MPC \cite{Zhang2013ECC}, or simply constraint tightening, which can be relatively easily integrated in our framework. We assume that the building aggregation acquires energy from the retail market, and since the utility company tariffs are typically constant over long periods, there is no electricity price uncertainty in our case. However, the situation is different for the reserve prices. Although the reserve bid price is selected by the aggregator, there is uncertainty involved because the bid might not be accepted in the auction. Incorporating this source of uncertainty requires modeling the market clearing process and is beyond the scope of this paper, but it may well constitute an interesting topic for future research.
\begin{figure}[t]
\centering
\includegraphics[width=1\textwidth]{HierarchicalScheme_bw_v4.eps}
\caption{Overview of the proposed hierarchical control scheme.} \label{fig:HierarchicalScheme}
\end{figure}
\section{Control Framework} \label{ControllerDesign}
\subsection{Hierarchical Scheme} \label{HierarchicalScheme}
In this section, we present the hierarchical control scheme for frequency reserve provision by commercial building aggregations, which is graphically shown in Fig.~\ref{fig:HierarchicalScheme}. Level $1$ (Lv$1$), the \emph{aggregator scheduling}, is performed on a daily basis centrally by an aggregator. There are two conflicting objectives in the problem: (a) minimize energy consumption through energy efficient control, and (b) deviate from the energy-optimal solution to leave slack for reserve provision. The optimal tradeoff between these conflicting objectives depends on the monetary incentives for reserves, which we call capacity payments, and the cost of electricity. Lv$1$ determines the reserve capacity, and its allocation among buildings, which achieve the optimal tradeoff while respecting occupants' comfort in case the reserve is requested. The aggregator solves a robust optimization problem using building state measurements, prices of electricity and reserves, as well as predictions of weather and occupancy. We formulate the robust problem first for PC only and second for PEC. Reliable provision of frequency reserves is critical for power system security, and so TSOs typically require $100\%$ availability of the reserve capacity \cite{swissgridAS}. For this reason, HVAC input constraints are truly hard constraints and robust optimization is a natural approach to follow.
Level $2$ (Lv$2$), the \emph{building HVAC control}, is a robust MPC \cite{MPCtextbook} that determines the energy optimal HVAC control inputs every $30$ minutes locally at each building, and leaves enough slack for reserves. Level $3$ (Lv$3$), the \emph{frequency signal filtering and tracking}, is a feedback controller that tracks the SFC signal by controlling the power consumption in real-time, e.g., every $10$ seconds. In Fig.~\ref{fig:HierarchicalScheme}, signals and control actions with thick/solid curves are real-time, the ones with thin/solid curves are executed every $30$ minutes, and the ones with dashed curves are executed once a day.
\subsection{Lv$1$: Aggregator Scheduling} \label{SchedulingLv1}
The aggregator's goal is to determine the optimal amount of reserves $\tilde{\R}^{\ast}$ to be offered in the market. Denote by $\c_t \in \Rset^{n_u L N_1}$ and $\k_t \in \Rset^{n_r L N_1}$ the electricity cost and reserve capacity payment vectors, respectively, where $N_1$ is the prediction horizon. Note that efficiency factors incorporating actuators' COP and building distribution system losses are included in $\c_t$ and $\k_t$. Lv$1$ can be cast as the robust LP
\begin{subequations} \label{GenForm}
\begin{align}
( \u_t^{\ast}, \tilde{\R}^{\ast}):= \arg\min ~ & \c_t^\top \u_t - \k^\top_t \tilde{\R} \bold{1}_{N_1} \label{ObjGenForm} \\
\text{s.t. } & \underset{\w_t \in \Wset}{\max} ( \G \u_t + \Ss \tilde{\R} \w_t )\leq \Q \label{NormalConsLv1GenForm}\\
& \M \tilde{\R} \bold{1}_{N_1} = \mathbf{0}~, \label{tender_periods_consGenForm}
\end{align}
\end{subequations}
where $\Wset$ is the uncertainty set, i.e., $\Wset \in \{\Wset_1, \Wset_2\}$. Equation \eqref{NormalConsLv1GenForm} requires that input and output constraints are satisfied even in the worst case of uncertainty realization. By appropriately selecting $\M$ in \eqref{tender_periods_consGenForm}, we can impose constant reserve capacities over a period of time and/or the block diagonal structure on $\tilde{\R}$ discussed in Section~\ref{BldModeling}. The building dynamics in \eqref{NormalConsLv1GenForm} are decoupled among buildings; however, the coupling comes via \eqref{tender_periods_consGenForm} and the objective function.
Denote by $\X_{(j)}$ the $j^\textrm{th}$ row of any matrix or vector $\X$. We derive the robust counterpart of \eqref{GenForm} for PC and PEC. Consider the $j^\textrm{th}$ row of \eqref{NormalConsLv1GenForm} $\max_{\w_t} ( \G_{(j)} \u_t + \Ss_{(j)} \tilde{\R} \w_t )\leq \Q_{(j)}$. The term $\Ss_{(j)} \tilde{\R} \w_t$ is a scalar and can be written as $\w_t^\top \F_{(j)} \tilde{\r}$, where $\tilde{\r} \in \Rset^{n_r L N_1^2}$ is a column-wise vectorized version of $\tilde{\R}$ and $\F_{(j)} = (\I_{N_1} \otimes \Ss_{(j)}^\top)^\top \in \Rset^{N_1 \times (n_r L N_1^2)}$, where $\otimes$ is the Kronecker product. Thus, the $j^\textrm{th}$ row of \eqref{NormalConsLv1GenForm} is equivalent to
\begin{align}
\underset{\w_t \in \Wset}{\max} ( \G_{(j)} \u_t + \w_t^\top \F_{(j)} \tilde{\r})\leq \Q_{(j)}~. \label{RowNormalConsv2}
\end{align}
\subsubsection{Robust Counterpart for Power Constraints} \label{RobustCounterpartPC}
In the presence of PC only, the uncertainty set $\Wset_1$ is given by \eqref{Wset1}, i.e., $\w_t$ is constrained in an $\infty$-norm ball. In this case, we can maximize the left-hand side of \eqref{RowNormalConsv2} analytically using the dual of $\infty$-norm, i.e., the $1$-norm \cite{Lofberg2012}. Following this procedure, the deterministic equivalent of \eqref{RowNormalConsv2} is \mbox{$\G_{(j)} \u_t + ||\F_{(j)} \tilde{\r}||_1 \leq \Q_{(j)}$}. Repeating this procedure for all rows of \eqref{NormalConsLv1GenForm}, the robust counterpart problem of \eqref{GenForm} can be written as
\begin{subequations} \label{RobustCounterW1}
\begin{align}
\left ( \u_t^{\ast}, \tilde{\r}^{\ast} \right ):= \arg\min ~ & \c_t^\top \u_t - \tilde{\k}^\top_t \tilde{\r} \\
\text{s.t. } & \G_{(j)} \u_t + ||\F_{(j)} \tilde{\r}||_1 \leq \Q_{(j)} ~~ \forall j \label{RobustConsW1} \\
& \tilde{\M} \tilde{\r} = \mathbf{0}~, \label{tender_periods_RobustCounterW1}
\end{align}
\end{subequations}
where $\tilde{\k}_t \in \Rset^{n_r L N_1^2}$ and $\tilde{\M}$ are defined by $\tilde{\k}^\top_t \tilde{\r} = \k^\top_t \tilde{\R} \bold{1}_{N_1}$ and $\tilde{\M} \tilde{\r} = \M \tilde{\R} \bold{1}_{N_1}$. Problem \eqref{RobustCounterW1} is an LP, but it grows quadratically in $N_1$ since we need $N_1$ auxiliary variables and $2N_1$ additional constraints for each uncertain constraint \eqref{RowNormalConsv2} to model the $1$-norm. A similar reformulation for a general class of linear systems with reserve demands can be found in \cite{Zhang2014CDC}.
We now consider the case where either only heating or only cooling actuators provide reserves in each building, which is likely in practice to avoid energy dumping by simultaneous heating and cooling. Recall from \eqref{GbSbQb}, \eqref{GpbSpb} that $\Ss$ is a block diagonal collection of $\Ss^b = [\C^b \R^b; \Hb^b; -\C^b \R^b; -\Hb^b]$. If only heating (cooling) actuators are used for reserve provision, then all entries of $\R^b$ are non-negative (non-positive). Additionally, all entries of $\C^b$ and $\Hb^b$ are non-negative by construction. Therefore, every row of $\Ss$ contains either only non-negative or only non-positive entries and, by construction, the same holds for all entries of $\F_{(j)}$, i.e., $[ \F_{(j)}(i,k) \geq 0 ~\forall i,k ]$ or $[ \F_{(j)}(i,k) \leq 0 ~\forall i,k ]$ $\forall j$. Based on the definitions of $\F_{(j)}$, $\Ss_{(j)}$, $\tilde{\r}$, and $\r_t$, and recalling that $\tilde{\r}$ is non-negative, $||\F_{(j)} \tilde{\r}||_1$ can be equivalently written as the linear term
\begin{align}
&||\F_{(j)} \tilde{\r}||_1 = \sum\nolimits_{i=1}^{N_1} \sum\nolimits_{k=1}^{n_{\textrm{el}}} | \F_{(j)}(i,k) \tilde{\r}(k) | = \label{Derivation} \\
& \sum\nolimits_{i=1}^{N_1} \sum\nolimits_{k=1}^{n_{\textrm{el}}} |\F_{(j)}(i,k)| \tilde{\r}(k)
= \bold{1}_{N_1} |\F_{(j)}|_{\star} \tilde{\r} = |\Ss_{(j)}|_{\star} \r_t, \nonumber
\end{align}
where $n_{\textrm{el}}=n_r L N_1^2$ and $|\cdot|_{\star}$ denotes the element-wise absolute value operator. In this case, the more general formulation \eqref{RobustCounterW1} can be simplified to the following LP that has the same size as \eqref{GenForm}, and so can be solved efficiently\footnote{Note that \eqref{RobustCounterW1simple} is a special case of \eqref{RobustCounterW1}, and it is equivalent to formulation (13)-(15) in our previous work \cite{VrettosIFAC2014}.}.
\begin{subequations} \label{RobustCounterW1simple}
\begin{align}
\left ( \u_t^{\ast}, \r_t^{\ast} \right ):= \arg\min ~ &\c_t^\top \u_t - \k^\top_t \r_t \\
\text{s.t. } & \G_{(j)} \u_t + |\Ss_{(j)}|_{\star} \r_t \leq \Q_{(j)} ~~ \forall j \\
& \M \r_t = \mathbf{0}~. \label{tender_periods_RobustCounterW1simple}
\end{align}
\end{subequations}
\subsubsection{Robust Counterpart for Power and Energy Constraints}
With PEC, the uncertainty set $\Wset_2$ is a polyhedron and duality theory can be applied to derive the robust counterpart problem \cite{BoydConvex,Lofberg2012}. We write constraint \eqref{RowNormalConsv2} as an optimization problem over $\w_t$
\begin{subequations} \label{RobustConsW2part1}
\begin{align}
& \underset{\w_t}{\max} & ( \G_{(j)} \u_t + \w_t^\top \F_{(j)} \tilde{\r} )\leq \Q_{(j)} \\
& \text{s.t. } & \bar{\A}_w \w_t \leq \bar{\b}_w~.
\end{align}
\end{subequations}
By deriving the dual problem of \eqref{RobustConsW2part1} for all $j$, we obtain the following robust counterpart of \eqref{GenForm}
\begin{subequations} \label{RobustCounterW2}
\begin{align}
( \u_t^{\ast}, \tilde{\r}^{\ast}, \boldsymbol{\lambda}_{(j)}^{\ast} ):= &\arg\min ~\c_t^\top \u_t - \tilde{\k}^\top_t \tilde{\r} \\
\text{s.t. } & \bar{\b}_w^\top \boldsymbol{\lambda}_{(j)} + \G_{(j)} \u_t - \Q_{(j)} \leq 0~~~\forall j \\
& \bar{\A}_w^\top \boldsymbol{\lambda}_{(j)} = \F_{(j)} \tilde{\r}~~~\forall j \\
& \boldsymbol{\lambda}_{(j)} \geq \mathbf{0}~\forall j,\\
&\tilde{\M} \tilde{\r} = \mathbf{0}~, \label{tender_periods_RobustCounterW2}
\end{align}
\end{subequations}
where $\boldsymbol{\lambda}_{(j)}$ is the vector of dual variables. Problem \eqref{RobustCounterW2} is an LP, but its size grows quadratically in $N_1$. Although this dualization technique holds also for PC, we apply analytic maximization in that case since it results in fewer variables and constraints.
\emph{Remark:} Asymmetric reserves can be modeled defining $\tilde{\R}^{+}$, $\w_t^{+} \in [0,1]^{N_1}$ for down- and $\tilde{\R}^{-}$, $\w_t^{-} \in [-1,0]^{N_1}$ for up-reserves. In case of PC only, the uncertainty set remains a polyhedron and a tractable robust counterpart problem can be derived using analytic maximization. The reader is referred to \cite{VrettosIFAC2014} for detailed formulations. In case of PEC, the non-linear constraint $w_t^{-} w_t^{+}=0$ is needed to ensure that up- and down- reserves are not requested simultaneously. Therefore, the uncertainty set is not a polyhedron any more and the dualization technique cannot be applied in this case to derive the robust counterpart problem.
\subsection{Lv$2$: Building HVAC Control} \label{BuildingControl}
Given the optimal reserve allocation from Lv$1$, in Lv$2$ the HVAC control inputs are determined every $30$ minutes by the robust MPC with prediction horizon $N_2$
\begin{subequations} \label{GenFormLv2}
\begin{align}
{\u}_t^{b,\ast}:= &\arg\min~~ {(\c^b_t)}^\top\u^b_t \\
\text{s.t. } &\underset{\w_t \in \Wset}{\max} \left( \G^b \u^b_t + \Ss^b \tilde{\R}^{b,\ast} \w_t \right) \leq \Q^b \label{GenFormLv2NormalCons}~,
\end{align}
\end{subequations}
where $\c^b_t$ and $\tilde{\R}^{b,\ast}$ are the parts of $\c_t$ and $\tilde{\R}^{\ast}$, respectively, that are relevant for building $b$. The first input of the optimal control sequence of \eqref{GenFormLv2} determines the Lv$2$ setpoint of the HVAC system for the next $30$ minutes\footnote{Although a consumption schedule is calculated in Lv$1$, the MPC of Lv$2$ can reduce the costs due to less uncertainty (recent reserve requests are known and better weather forecasts might be available) and, possibly, shorter optimization time steps. In case of plant-model mismatches, MPC additionally reduces constraint violations due to its closed-loop operation. The MPC schedule is the building's baseline consumption, and is communicated to the aggregator. Since the baseline is a by-product of the formulation, baseline prediction methods that have proven to be hard \cite{kiliccote_field_2012} are not required. Furthermore, the predictive nature of MPC inherently accounts for rebound effects due to reserve provision when calculating future HVAC setpoints \cite{pietteLBNL2012}.}, $u_t^{b,\text{Lv$2$}}$. Problem \eqref{GenFormLv2} formulates an MPC with open-loop predictions, i.e., the optimization is performed explicitly over the control inputs $\u^b_t$. MPC with closed-loop predictions, i.e., optimization over affine policies of the uncertainty, showed minor or zero performance improvement in this case, and so it is not used. In the following, we derive the robust counterparts of \eqref{GenFormLv2} for PC and PEC.
\subsubsection{Robust Counterpart for Power Constraints}
In this case, the deterministic equivalent of \eqref{GenFormLv2} can be obtained by substituting \eqref{GenFormLv2NormalCons} with $\G_{(j)}^b \u^b_t \leq \Q_{(j)}^b - ||\F_{(j)}^b \tilde{\r}^{b,\ast}||_1~\forall j$, where $\F_{(j)}^b$ is defined similarly to $\F_{(j)}$ but for a single building, and $\tilde{\r}^{b,\ast}$ is a column-wise vectorized version of $\tilde{\R}^{b,\ast}$. Note that $\tilde{\r}^{b,\ast}$ is fixed in Lv$2$, and the right-hand side of the inequality is a constant.
\subsubsection{Robust Counterpart for Power and Energy Constraints}
With PEC, the robust counterpart of \eqref{GenFormLv2} is
\begin{subequations} \label{RobustCounterLv2W2}
\begin{align}
( \u_t^{b,\ast}, \boldsymbol{\lambda}_{(j)}^{b,\ast} ):= &\arg\min {(\c^b_t)}^\top \u^b_t \\
\text{s.t. } & \bar{\b}_{w,t}^\top \boldsymbol{\lambda}_{(j)}^b + \G_{(j)}^b \u^b_t - \Q_{(j)}^b \leq 0~~~\forall j \\
& \bar{\A}_{w,t}^\top \boldsymbol{\lambda}_{(j)}^b = \F_{(j)}^b \tilde{\r}^{b,\ast}~\forall j,\\
&\boldsymbol{\lambda}_{(j)}^b \geq \mathbf{0}~\forall j~. \label{EqConsLv2W2}
\end{align}
\end{subequations}
Problem \eqref{RobustCounterLv2W2} is similar to \eqref{RobustCounterW2}, but there are two main differences: first, $\tilde{\r}^{b,\ast}$ is fixed; and second, $\bar{\A}_{w,t}$ and $\bar{\b}_{w,t}$ are time-varying. For a time step $t$ in the averaging interval $[t_1,t_2]$ of length $T$, \eqref{EnergyCons} can be written as $-\varepsilon T - w_{\textrm{p},t} \leq \sum_{k=t}^{t_2} w_k \leq \varepsilon T - w_{\textrm{p},t}$, where $w_{\textrm{p},t} = \sum_{k=t_1}^{t-1} w_k$ is known because the uncertainty up to $t-1$ is realized. Thus, the coupling constraint on $\{w_t, \ldots, w_{t_2}\}$ depends on the energy content of the SFC signal in the previous time steps of the averaging interval.
\subsection{Lv$3$: Frequency Signal Filtering and Tracking} \label{SFCtracking}
In Lv$3$, the HVAC consumption is controlled around $u_t^{b,\text{Lv$2$}}$ for reserve provision. We consider water-based HVAC systems that are common in Europe, but the proposed reserve scheduling problem applies also to air-based systems \cite{MaasoumyACC2014paper1}. The power consumption of water circulation pumps in water-based HVAC systems is typically small, and so we directly control the heating or cooling devices, e.g., heat pumps (HPs), to provide reserves. The desired power consumption of HP $j$ of building $b$ is
\begin{align} \label{Lv3}
u_t^{b,j,\text{Lv$3$}} &= u_t^{b,j,\text{Lv$2$}} + \Delta{u}^{b,j}_t = u_t^{b,j,\text{Lv$2$}} + w_t r^{b,j,\ast}_t~,
\end{align}
where $r^{b,j,\ast}_t$ is fixed from Lv$1$. In case of asymmetric reserves, $r^{b,j,\ast}_t$ is equal to the down-reserve capacity if $w_t \geq 0$, and equal to the up-reserve capacity if $w_t < 0$. In a fast time scale, and depending on the HVAC system, the HP consumption can be controlled by modifying either the water temperature setpoint at condenser's outlet or the refrigerant's flow rate via valves. We rely on the second approach that was experimentally shown to be able to track fast reference signals, e.g., SFC signals, in \cite{Hagiwara2011}. The desired HP consumption $u_t^{b,j,\text{Lv$3$}}$ can be tracked using a feedback PI controller.
With PC only, the normalized reserve request $w_t$ sent from the TSO is the original SFC signal, whereas with PEC, $w_t$ is a filtered version of that signal. With reasonable modifications, the current operational paradigm at the TSO side can integrate multiple SFC signals with different energy contents. In the current paradigm, there is a single SFC signal that is the output of a PI controller with the area control error (ACE) as input. In the new paradigm, the TSO provides a number of reserve products and each reserve provider chooses the product to offer its reserve capacity. Assume that the total reserve request (original SFC signal) at time step $t$ is $\tilde{w}_t$. The TSO will decompose $\tilde{w}_t$ into the desired number of signals (e.g., using a filter bank) and will sent the appropriate components to the providers depending on the reserve product they offer reserves for. To simulate this process in this paper, we use a causal Chebyshev filter to get the energy-constrained signal $w_t$ sent to the building aggregation, but other filters might also be used. Similar filtering approaches have been used in previous works on power system applications, e.g., \cite{AvramiotisGM2014}. Note that although $w_t$ is a filtered signal, it does not mean that its bias is zero but instead that its bias is bounded. The filter's transfer function is
\begin{align} \label{Chebyshev}
H(z) = \frac{\sum_{i=0}^{n_{\textrm{f}}} b_i z^{-i}}{1+\sum_{i=1}^{n_{\textrm{f}}} a_i z^{-i}}~,
\end{align}
where $n_{\textrm{f}}$ is the filter's order, and $a_i$, $b_i$ are its coefficients that depend on the pass-band edge frequency $f_\textrm{c}$. From a TSO perspective, $n_{\textrm{f}}$ and $f_\textrm{c}$ can be chosen such that the resulting low-frequency component (LF signal) and high-frequency component (HF signal) have the desired ramping rates and energy contents. In this paper, we fix $n_{\textrm{f}}=3$ since it showed good performance in preliminary simulations.
It is important to clarify how the SFC signal filtering is taken into account in the higher levels of the control hierarchy. Recall that the filtered signal is tracked every few seconds in Lv$3$, whereas the decisions in Lv$1$ (reserve scheduling) and Lv$2$ (determination of optimal building setpoints) are taken every $30$ minutes. Due to this time scale separation, the important information from the filtering of Lv$3$ that needs to be conveyed to Lv$1$ and Lv$2$ is only the integral of the SFC signal over this period, i.e., the bias of the signal. This is needed for example in Lv$1$ to schedule the reserve capacities without violating the buildings' thermal comfort constraints. By formulating the energy constraint of the SFC signal as the linear inequalities \eqref{EnergyCons}, we can directly account for the signal's bias in the optimization problems of Lv$1$ and Lv$2$ in a tractable way. Note that the bias coefficients $\varepsilon$ for different averaging periods $T$ in \eqref{EnergyCons} can be empirically obtained from the filter \eqref{Chebyshev}. To do so, one can simply apply the filter on historical data of SFC signals using different $f_\textrm{c}=1/T$.
Due to the robust design, any admissible reserve request $w_t$ that satisfies \eqref{EnergyCons} will not lead to comfort zone or input constraint violations, provided that there is no significant plant-model mismatch. The tracking quality of $w_t$ depends on HP's mechanical delays and dead-times, ramping limits, and minimum down-times and/or run-times. If such dynamics are significant, tests similar to the ones in \cite{Hagiwara2011} must be performed to identify upper limits on the frequency content of $w_t$ that result in good tracking by the HP. In this case, the building aggregation could form a coalition with faster resources, e.g., an aggregation of residential electric water heaters, exclude very high frequency components of the SFC signal using an appropriate band-pass filter, and send them to the faster resources. Since the focus of this paper is on the robust reserve scheduling and allocation side, we assume that such HP dynamics are negligible, i.e., the reference $u_t^{b,j,\text{Lv$3$}}$ (and so the SFC signal) can be perfectly tracked in our simulations if the comfort zone and input constraints are satisfied.
\section{Performance of Control Framework} \label{ControllerPerformance}
\begin{table}[t]
\renewcommand{\arraystretch}{1.1}
\caption{Bias Coefficients ($\varepsilon$) for the SFC Signal and its High-frequency Component (HF) for Different Averaging Periods ($T$)}
\centering
\begin{tabular}{ccccccc}
\hline
$T$ & $1$ h & $2$ h & $4$ h & $6$ h & $8$ h & $12$ h\\
\hline
SFC $2009$ & $1.000$ & $0.989$ & $0.952$ & $0.796$ & $0.592$ & $0.505$\\
HF $2009$ & $0.528$ & $0.467$ & $0.337$ & $0.273$ & $0.384$ & $0.229$\\
\hline
SFC $2012$ & $0.927$ & $0.781$ & $0.674$ & $0.624$ & $0.553$ & $0.448$\\
HF $2012$ & $0.382$ & $0.300$ & $0.317$ & $0.290$ & $0.237$ & $0.203$\\
\hline
\end{tabular}
\label{tab:LFCanalysis}
\end{table}
\subsection{Investigation Setup} \label{InvestigationSetup}
We investigate the performance of the proposed control framework in simulations with an aggregation of typical Swiss office buildings. We consider two HVAC systems: in system A, heating is performed via radiators with coefficient of performance (COP) equal to $3$, whereas cooling with cooled ceilings (COP $= 3.5$); in system B, both heating and cooling are performed using thermally activated building systems (TABS) with COP $= 3.4$. We also differentiate between heavy (eh) or light (el) building envelope, high (wh) or low (wl) window area fraction, and high (gh) or low (gl) internal gains. In our simulations, we consider an aggregation of $6$ large buildings ($15000$ m$^2$ each) with the following characteristics: $\textrm{A}1$ = \{A,eh,wh,gh\}, $\textrm{A}2$ = \{A,eh,wl,gl\}, $\textrm{A}3$ = \{A,el,wl,gl\}, $\textrm{B}1$ = \{B,eh,wh,gh\}, $\textrm{B}2$ = \{B,eh,wl,gl\}, and $\textrm{B}3$ = \{B,el,wl,gl\}. Typical occupancy profiles were used, whereas weather data were provided by Meteoswiss (the Swiss federal office of meteorology and climatology). More information regarding the buildings can be found in \cite{Oldewurtel2011,VrettosIFAC2014}. Because of the thermal inertia, heating/cooling actuators can be used to provide frequency reserves. In buildings with the HVAC systems considered here, the fresh air flow rate is usually kept constant because changes would be immediately realized by the occupants. For this reason, we do not use ventilation for reserve provision. The temperature comfort zone during working hours is $[21,24]^o$C in winter and $[22,25]^o$C in summer, which is in accordance with the ASHRAE 55-2013 standard \cite{CBEcomforttool}. During non-working hours and weekends, the comfort zone is relaxed to $[12,35]^o$C in both seasons. The optimizations are performed with a time step of $30$~minutes, which is the discretization step of building models \eqref{OriginalModel1}, and the prediction horizons of Lv$1$ and Lv$2$ are fixed to $N_1 = 96$ ($2$~days) and $N_2 = 48$ ($1$~day), respectively. We assume symmetric, daily reserves, i.e., constant reserve capacity over a day, and capacity payments $10\%$ higher than the electricity price, i.e., $k = 1.1 c$.
\subsection{Parameters of Energy Constraints} \label{EnergyConsParams}
To apply energy constraints as in \eqref{EnergyCons}, we determine appropriate pairs of averaging period and bias coefficient $(T, \varepsilon)$ based on the historical normalized SFC signals $w_k \in [-1,1]$ from the Swiss control area for $2009$ and $2012$. We consider six different averaging periods, $T=\{1,2,4,6,8,12\}~\textrm{hours}$, and calculate six sets of filter parameters in \eqref{Chebyshev}, one for each of the pass-band edge frequencies $f_\textrm{c}=1/T$. For each value of $T$, we filter the historical SFC signals using the corresponding filter \eqref{Chebyshev} to get the HF signals for $2009$ and $2012$. For each of the four signals and for each value of $T$, we calculate $\varepsilon$ as the largest absolute mean value of the SFC or HF signal over any period $T$, i.e., $\varepsilon = \max(|(1/T) \cdot \sum_{k=1}^{T} w_k|)$. The results are summarized in Table~\ref{tab:LFCanalysis}. Notice that the original SFC signals can be significantly biased over periods of several hours. Note also that the biases of the HF signals are significantly lower than those of the original SFC signals, and that the signals in $2012$ are generally less biased than in $2009$. This is because from March $2012$ the ACE of Switzerland is netted with that of other European countries before generating the SFC signal. We use the HF signal of $2012$ and select $(T=2~\textrm{h}, \varepsilon=0.3)$ for the simulations of this section, according to Table~\ref{tab:LFCanalysis}.
\subsection{Operation for Typical Weeks} \label{TypicalOperation}
\begin{figure}[t
\centering
\begin{subfigure}
\centering
\includegraphics[width=1\textwidth,height=2in]{LFCsignals_bw_v3.eps}
\caption{A $4$-hour extract of the original SFC signal, its low-frequency (LF), and its high-frequency (HF) components for a sample day.}
\label{fig:LFCsignals1}
\end{subfigure}
\begin{subfigure}
\centering
\includegraphics[width=1\textwidth,height=2in]{MovAvgLFCsignals_bw_v4.eps}
\caption{The moving averages of the signals of Fig.~\ref{fig:LFCsignals1} for the whole sample day.}
\label{fig:LFCsignals2}
\end{subfigure}
\end{figure}
We present simulation results for typical weeks in winter and summer. In Fig.~\ref{fig:LFCsignals1}, we show a \mbox{$4$-hour} extract of the SFC, LF, and HF signals for a sample day, whereas in Fig.~\ref{fig:LFCsignals2} we show the $2$-hour moving averages of the signals for the whole day. Although the original SFC signal is mostly negative, its bias is absorbed by the LF signal, and so the HF signal is approximately zero-mean. The bias $\varepsilon$ of the SFC signal is larger than $0.3$, whereas the energy-constrained HF signal has a bias less than $0.15$.
Figure~\ref{fig:ReserveCapacitiesWinter} shows the optimal total reserve capacity of the aggregation and its allocation among buildings for the winter week. The capacity is constant for each day and ranges from approximately $260$~kW on Friday to $380$~kW on Saturday with an average weekly value of $313$~kW. Note that the capacity is shifted among buildings in a way that maximizes the total capacity of the aggregation. Interestingly, the buildings offer higher reserve capacities when they normally consume less power. For example, buildings with system A contribute mainly at night, whereas buildings with system B offer more reserves during working hours, because they prefer to preheat at night. The scheduled total energy consumption of the aggregation is spread throughout the whole week to maximize the reserve potential. During the weekend, the buildings are not occupied and the comfort zone is larger, which results in higher reserve capacities compared to working days.
The optimal operation of building A$3$ based on Lv$2$ and Lv$3$ is presented in Figs.~\ref{fig:InputsWinter} and~\ref{fig:RoomTemperatureWinter}. Figure~\ref{fig:InputsWinter} shows the HVAC system heating power and Fig.~\ref{fig:RoomTemperatureWinter} the resulting temperature trajectories. The black-solid curves indicate the scheduled consumption and temperature by the MPC, whereas the grey-dashed curves correspond to the final values after tracking the HF signal. The grey envelope shows the problem's robust region, which is defined as the region of the thermal comfort zone with the following property. If the temperature is within the robust region at time step $t=0$, then for any SFC signal with the appropriate energy content there exists a feasible control input trajectory that satisfies the thermal comfort and HVAC input constraints (the black-dashed curves in both figures) along the prediction horizon $t \in [0,N-1]$. In our simulations, the HVAC inputs and room temperature stay always within the robust region.
\begin{figure}[t]
\centering
\begin{subfigure}
\centering
\includegraphics[width=1\textwidth]{ReserveCapacitiesWinter_bw_correct.eps}
\caption{Optimal reserve allocation among buildings (winter week).} \label{fig:ReserveCapacitiesWinter}
\end{subfigure}
\begin{subfigure}
\centering
\includegraphics[width=1\textwidth]{InputsWinter_bw.eps}
\caption{HVAC heating power for building A$3$ (winter week).} \label{fig:InputsWinter}
\end{subfigure}
\begin{subfigure}
\centering
\includegraphics[width=1\textwidth]{RoomTemperatureWinter_bw.eps}
\caption{Room temperature for building A$3$ (winter week).} \label{fig:RoomTemperatureWinter}
\end{subfigure}
\end{figure}
In summer, the reserve potential from cooling actuators is also significant. During the considered week, the capacities range from approximately $60$~kW on Sunday to $420$~kW on Saturday with an average weekly value of $323$~kW. We observed a more uniform distribution of reserves among different buildings in summer, compared to winter, because cooled ceilings and TABS have similar time constants. Due to space limitations, plots similar to Figs.~\ref{fig:ReserveCapacitiesWinter},~\ref{fig:InputsWinter} and~\ref{fig:RoomTemperatureWinter} are omitted.
Based on our results, the considered $6$ buildings with floor area $15000$ m$^2$, average rated heating power $27$ W/m$^2$, and average rated cooling power $32$ W/m$^2$ provide a reserve capacity equal to $313$ kW and $323$ kW on average in winter and summer, respectively. Using simple linear extrapolation, we find that the required minimum reserve capacity of $5$ MW in Switzerland can be provided by $96$ (similar) buildings in winter and $93$ buildings in summer, i.e., approximately $100$ buildings in both seasons. Note that this is only a rough estimate as: (a) it is based on the average reserve capacity values; and (b) the extrapolation might overestimate the required number of buildings to meet the $5$ MW limit, because the larger the aggregation the more flexibility exists in allocating reserves among buildings.
\subsection{Effect on Energy Consumption} \label{EnergyConsumption}
To maximize the reserve potential, the buildings operate in a less energy efficient way. For example, during the considered winter week reserve provision resulted in a consumption $60\%$ higher than that of energy efficient building control, i.e., an MPC with objective to minimize electricity cost without offering reserves. As shown in Fig.~\ref{fig:InputsWinter}, in order to provide reserves in both directions, the buildings try to operate close to the middle of the heating/cooling device's power range. This is in contrast to an energy efficient operation, where the power consumption would be as close as possible to the minimum value. However, the increase in energy consumption does not mean that the building control is suboptimal. For the given electricity price and capacity payment, this building operation minimizes the total cost defined as the sum of electricity cost and reserve profit.
It is important to note that the $60\%$ consumption increase is in comparison with an MPC-based energy efficient building control. However, most buildings today operate with supervisory rule-based controllers, i.e., not optimal controllers. Therefore, if the proposed methods are applied to such buildings, the observed increase in consumption is expected to be less than the reported value. Although energy efficiency is usually the goal in building control, increasing the energy consumption is not necessarily a drawback if this helps accommodate more RES in the power system, and at the same time the additional electric energy is stored as thermal energy in the buildings.
\subsection{Discussion on Imperfect Disturbance Predictions} \label{DiscussImperfectPred}
As mentioned in Section~\ref{OtherUncert}, the formulations and simulations in this paper assumed perfect weather and occupancy predictions. The robust formulation guarantees satisfaction of the HVAC and comfort constraints for any admissible reserve request and perfect weather and occupancy predictions, but it cannot provide mathematical guarantees on the worst case temperature deviations in case of imperfect predictions. Empirical guarantees could be provided by Monte Carlo simulations: (i) schedule the reserve capacities using imperfect disturbance predictions; (ii) simulate the building operation under disturbance uncertainty, i.e., the weather and occupancy realizations are different to the predictions; and (iii) analyze the results to keep track of the number and magnitude of temperature deviations. Alternatively, probabilistic guarantees could be obtained by modeling the weather and occupancy uncertainty via scenarios and then robustifying against the reserve uncertainty separately for each scenario. This is an exciting research direction for future work.
However, some intuition can be provided without following any of the above two approaches. Consider a building in energy efficient operation using a deterministic MPC that relies on an imperfect weather forecast. As explained in Section~\ref{EnergyConsumption}, the building would operate close to the minimum power consumption, and thus the temperature trajectory would stay close to one of the comfort zone boundaries. Now consider the same building operated under reserve provision. As shown in Fig.~\ref{fig:RoomTemperatureWinter}, the building would operate closer to the middle of the comfort zone to maximize the reserve capacity. For this reason, we expect the reserve provision case to result in smaller and perhaps less frequent comfort zone violations compared to the energy efficient control case, if the building is exposed to the same weather and occupancy uncertainty in both cases.
\section{Sensitivity Analysis} \label{SensitivityAnalysis}
\subsection{Capacity Payments} \label{CapPayments}
As explained in Section~\ref{HierarchicalScheme}, the proposed reserve scheduling methods identify the optimal tradeoff between minimizing energy consumption and leaving enough slack for reserve provision. The buildings would not deviate from the energy efficient control and would not offer any reserves if the additional electricity cost occurring due to this deviation were higher than the reward received for the slack provided as reserve capacity. In principle, the amount of reserves depends on the relationship (ratio) between the capacity payment $k$, i.e., the remuneration for each kW of reserve capacity provided, and the electricity price $c$, i.e., the cost for each kWh of electricity consumed. In this Section, we investigate this relationship by running simulations, similar to the ones in Section~\ref{TypicalOperation}, over $2$-week periods in winter and summer and for various $k/c$ ratios. The total reserve capacity for each case, i.e., the sum of the capacities of each day of the $2$-week period, is presented in Fig.~\ref{fig:CapacityPayment}, where the left plot is for ratios $k/c > 1$ and the right plot is for ratios $k/c \leq 1$. These plots represent the aggregation's bid curves because they communicate how much capacity the aggregation is willing to bid in the reserve market depending on the payment it receives for each kW of the capacity.
For $k/c >1$ (left plot - Fig.~\ref{fig:CapacityPayment}a) the simulations are performed for winter and summer with and without consideration of energy-constrained SFC signals: the black curves correspond to winter weeks (``win'') and the grey curves to summer weeks (``sum''), whereas the dashed curves are for PC and the solid curves for PEC. Our simulations show that with the same financial incentive and for both seasons, the buildings are willing to offer up to $10\%$ more reserves compared with PC if energy constraints are considered. Note that the gap between PC and PEC is generally larger for lower $k/c$, particularly in winter. In winter, the capacity saturates at its maximum value at $k/c=1.1$, whereas in summer it increases monotonically as the ratio increases up to $2$.
The analysis of Fig.~\ref{fig:CapacityPayment}a focused on $k/c>1$, which is a necessary condition for reserve provision with PC. This observation was also made in our previous work \cite{VrettosIFAC2014}; however, here we provide an explanation by studying the structure of problem \eqref{RobustCounterW1}. If $k<c$, the optimal solution is $(\u_t^{\ast}, \tilde{\r}^{\ast})=(\u_t^{\textrm{min}},\bold{0})$, where $\u_t^{\textrm{min}}$ is the energy optimal scheduling. If $k=c$, the optimal cost is $0$ and any solution within the feasible range of $\tilde{\r}$ will be optimal. If $k>c$, the optimal solution is $(\tilde{\r}^{\textrm{max}},\tilde{\r}^{\textrm{max}})$, where $\tilde{\r}^{\textrm{max}}$ is the upper limit of $\tilde{\r}$, and the optimal cost will be $(\c_t^\top-\k^\top_t) \tilde{\r}^{\textrm{max}}<0$, i.e., the aggregation earns profit. The limit $\tilde{\r}^{\textrm{max}}$ depends on input/output constraints, and so different solutions are obtained for different $k/c>1$ ratios, as shown in Fig.~\ref{fig:CapacityPayment}a. In case of daily reserves, $k/c>1$ need not to be satisfied point-wise throughout the whole day; instead, $k/c<1$ can be chosen during daytime, and $k/c>1$ at night when electricity prices might be lower. Reserve provision will be triggered if $||k||_1/||c||_1>1$, i.e., the capacity payment is on average higher than the electricity price.
On the other hand, with energy-constrained SFC signals (PEC) reserves can be provided also with ratios $k/c<1$ throughout the whole day. It is easier to explain this with an example. Assume that the buildings have declared a capacity $r(t)$ for day $d$. Assume also that up regulation (i.e., consumption decrease) is mainly requested during day $d$. If the signal is energy constrained, only a fraction of the worst case reserve energy $\int_{t=0}^{N-1} r(t) dt$ will be requested as consumption decrease from the buildings. The rest part of $\int_{t=0}^{N-1} r(t) dt$ will be stored as thermal energy in the buildings and will reduce the required heating/cooling energy (and the respective costs) during day $d+1$. For this reason, the buildings are willing to provide reserves even if $k/c<1$. We present simulation results for PEC in winter and summer in Fig.~\ref{fig:CapacityPayment}b. The threshold ratio for reserve provision is \mbox{$k/c=0.32$} for both winter and summer, and it depends on $\varepsilon$ and $T$. The capacity increases slowly in the ratio range $[0.32-0.99]$, particularly in summer, and then it suddenly jumps to higher values as $k/c$ approaches to $1$. No results are shown for PC in Fig.~\ref{fig:CapacityPayment}b because the capacity is zero for $k/c<1$, as explained before.
Fig.~\ref{fig:CapacityPayment}a shows that for unconstrained SFC signals (PC) a ratio $k/c=1.01$, which means a capacity payment $1\%$ higher than the electricity price, taps most of the reserve potential. In particular, further increasing the ratio up to the maximum considered value $k/c=2$ increases the reserves only by $8\%$ in winter and no more than $18\%$ in summer. Assuming an average electricity price of $146.6$~CHF/MWh, which is the case for consumers who consume more than $60$~MWh/year in Zurich, with a ratio $k/c=1.01$ capacity payments around $148$~CHF/MW/h are needed. This is significantly lower than the most expensive accepted bids, but approximately $4$~times higher than the average capacity payment in $2013$ \cite{swissgridOnline}. Fig.~\ref{fig:CapacityPayment}b shows that energy-constrained SFC signals can reduce the necessary capacity payments down to $32\%$ of the retail price ($k/c=0.32$), but of course with a large reduction in the reserve capacity. Thus, reserves are actually costly for buildings already equipped with MPC for \emph{energy efficient} (optimal) control, especially if the SFC signal is not energy-constrained. This is in contrast to TCLs with simple hysteresis control based on a deadband, where reserves can be provided at a lower cost. However, note that our calculations are based on the prevailing case where the buildings acquire energy in the retail electricity market. In another market setting where the buildings acquired energy directly in the spot market, the buildings could offer reserves at more competitive prices because the retail electricity prices are typically significantly higher than the wholesale spot electricity prices. The analysis of this section provides intuition on the relationship between the amount of reserves from building aggregations and the capacity payments. In practice, estimating the capacity payment is a challenging task that needs to consider additional costs, e.g., due to device wear, but also the competition, i.e., the expected bid prices of generators and/or other load aggregations.
\begin{figure}[t
\centering
\begin{minipage}{0.5\linewidth
\centering \includegraphics[width=2.5in]{CapacityPaymentAnalysis_bw_correct_v2.eps}
\end{minipage
\begin{minipage}{0.5\linewidth
\centering \includegraphics[width=2.5in]{CapacityPaymentAnalysisBelow1_bw_correct.eps}
\end{minipage
\caption{Bid curves of building aggregation in winter and summer. Left: for PC and PEC, and ratios $k/c>1$. Right: for PEC and ratios $k/c \leq 1$.
\label{fig:CapacityPayment
\end{figure}
\subsection{Reserve Product Characteristics} \label{ResProdChar}
In this section, we fix $k/c=1.1$ and investigate the influence of important reserve product characteristics on reserve capacities. For PC, we consider reserves with daily or hourly duration, and symmetric or asymmetric capacities. For PEC, we investigate reserves with daily or hourly duration, as well as different ($T$, $\varepsilon$) pairs, based on Table~\ref{tab:LFCanalysis}. We summarize simulation results with respect to the total reserve capacity for two weeks in winter and summer in Tables~\ref{tab:CapacityAndReserveCharacteristics1} and \ref{tab:CapacityAndReserveCharacteristics2}, where positive values denote up- and negative values down-reserves.
For PC and symmetric products\footnote{Note that the results of Table~\ref{tab:CapacityAndReserveCharacteristics1} are not directly comparable with the values reported in Tables 1 and 2 of \cite{VrettosIFAC2014}, because different COP values have been used in the simulations of the two papers.}, hourly reserves increase capacities by $2.9\%$ in winter and $3.3\%$ in summer, compared to daily reserves. If asymmetric reserves are allowed, the aggregation provides significantly more down- than up-reserves in summer, whereas in winter no up-reserves are provided at all. Down-reserves (increasing power consumption) are preferable for buildings equipped with MPC for energy efficient control because the capacity can be offered without increased baseline consumption. The energy efficient control tries to stay as close as possible to the minimum power consumption of the heating/cooling device. In order to provide up-reserves (consumption decrease), a building needs to be able to reduce its consumption without violating occupant comfort. Therefore, the building must schedule its operation (baseline) at a power level higher than the energy optimal, which increases energy costs. On the other hand, down-reserves can be provided while operating at the energy efficient trajectory because the consumption can only increase will tracking the SFC signal.
Compared to PC, PEC increase the reserves for all pairs ($T$, $\varepsilon$) up to $3.8\%$ in winter and $5.6\%$ in summer. For given $T$ and $\varepsilon$, adopting hourly instead of daily reserves increases the capacities up to $2\%$ in winter and $9.6\%$ in summer. Note that the increase is higher for large $T$. Notice that shorter $T$ are characterized by smaller $\varepsilon T$ products, and so constraint \eqref{EnergyCons} on the uncertainty becomes tighter. Therefore, one would intuitively expect that decreasing $T$ increases the reserve capacities monotonically. However, one has to consider that longer $T$ couple more optimization periods, which is why a monotonic behavior is not observed in our simulation results. To gain deeper insight into the dependence of reserve capacities on $T$ and $\varepsilon$, we run simulations for two weeks in winter and summer with $T \in \{1, 2, 4, 6, 8, 12\}$~hours and $\varepsilon$ varying from $0.05$ to $0.5$ with $0.05$ increments, i.e., $60$ combinations for each season. We assume daily, symmetric reserves and simulate only Lv$1$, i.e., the reserve scheduling problem, whereas the building HVAC control is not considered. The reason is that many of the combinations of $T$ and $\varepsilon$ are not achievable by the Chebyshev filter \eqref{Chebyshev}, and so Lv$2$ will likely be infeasible. However, our analysis provides intuition on the effect of $T$ and $\varepsilon$ that could be useful for filter design in a practical application.
\begin{table}[t]
\renewcommand{\arraystretch}{1.09}
\caption{Capacity (MW) of Reserve Products (Power Constraints)}
\centering
\begin{tabular}{cc|cccc}
\hline
Duration & Symmetry & \multicolumn{2}{c}{Winter} & \multicolumn{2}{c}{Summer} \\
\hline
daily & symmetric & \multicolumn{2}{c}{$\pm 105.9$} & \multicolumn{2}{c}{$\pm 89.6$} \\
daily & asymmetric & \multicolumn{2}{c}{$+ 0 / -196.9$} & \multicolumn{2}{c}{$+45.3 / -195.0$} \\
hourly & symmetric & \multicolumn{2}{c}{$\pm 109.0$} & \multicolumn{2}{c}{$\pm 92.6$} \\
hourly & asymmetric & \multicolumn{2}{c}{$+0 / -213.6$} & \multicolumn{2}{c}{$+44.8 / -198.4$} \\
\hline
\end{tabular}
\label{tab:CapacityAndReserveCharacteristics1}
\end{table}
\begin{table}[t]
\renewcommand{\arraystretch}{1.09}
\caption{Capacity (MW) of Reserve Products (Power \& Energy Constr.)}
\centering
\begin{tabular}{ccc|cccc}
\hline
$T$ (h) & $\varepsilon$ (-) & $\varepsilon T$ (h) & day/win & hour/win & day/sum & hour/sum\\
\hline
$1$ & $0.382$ & $0.382$ & $\pm 109.4$ & $\pm 110.0$ & $\pm 92.5$ & $\pm 97.6$\\
$2$ & $0.300$ & $0.600$ & $\pm 109.9$ & $\pm 110.7$ & $\pm 93.1$ & $\pm 99.3$\\
$4$ & $0.317$ & $1.268$ & $\pm 109.0$ & $\pm 110.2$ & $\pm 92.6$ & $\pm 99.5$\\
$6$ & $0.290$ & $1.740$ & $\pm 108.9$ & $\pm 110.4$ & $\pm 93.3$ & $\pm 99.6$\\
$8$ & $0.237$ & $1.896$ & $\pm 108.9$ & $\pm 111.0$ & $\pm 94.6$ & $\pm 101.5$\\
$12$ & $0.203$ & $2.436$ & $\pm 107.7$ & $\pm 111.1$ & $\pm 92.8$ & $\pm 99.6$\\
\hline
\end{tabular}
\label{tab:CapacityAndReserveCharacteristics2}
\end{table}
In Fig.~\ref{fig:TaEpsAnalysis}(a), we show the total reserve capacities for each of the simulated cases in winter. Similar results are obtained for summer, but are omitted here due to space limitations. The dependence of reserve capacities on $T$ and $\varepsilon$ demonstrates a clear pattern: increasing any of the two parameters reduces the reserve capacity. Note that the capacity is more sensitive to $\varepsilon$ than to $T$. To better illustrate this, we present the results of Fig.~\ref{fig:TaEpsAnalysis}(a) based on the product $\varepsilon T$ in Fig.~\ref{fig:TaEpsAnalysis}(b). As expected, increasing $\varepsilon T$ generally decreases the reserve capacity. The same $\varepsilon T$ can be obtained by different ($T$, $\varepsilon$) pairs: for example, both $(8~\textrm{h}, 0.25)$ and $(4~\textrm{h}, 0.5)$ obtain $\varepsilon T=2$, but the first achieves a capacity $96.72$~MW, whereas the second achieves $93.61$~MW. In this case, the capacity is more sensitive to $\varepsilon$ than to $T$. We compared all cases in winter and summer with the same $\varepsilon T$ and found out that in $70\%$ of them smaller $\varepsilon$ is preferable to smaller $T$. This means that buildings can cope easier with signals that are significantly energy constrained over long periods than signals that are moderately constrained over shorter periods.
\section{Concluding Remarks} \label{Conclusion}
In this paper, we proposed a new framework based on robust optimization and MPC for scheduling and provision of secondary frequency control (SFC) reserves by the HVAC systems of commercial building \emph{aggregations}. The framework incorporates tractable methods to account for energy-constrained SFC signals, and relies on decentralized reserve provision to keep real-time communication requirements low and preserve privacy. We also presented how the framework can be used to estimate the SFC reserve potential from commercial buildings.
Our analysis was based on four main assumptions: (a) there is no plant-model mismatch; (b) the predictions of weather and occupancy are perfect; (c) all building states can be measured; and (d) the reaction of heating/cooling devices is fast and does not cause any wear. Therefore, the reported results provide an upper bound on the amount of reserves from buildings. For a real implementation, additional care must be taken for (a)-(d): accounting for modeling and weather/occupancy prediction errors, use of state estimators, and modeling of the fast dynamics of heating/cooling devices. If multi-zone building models with hundreds of states are available, model reduction techniques \cite{Sturzenegger2013Experiment} can be used to reduce the optimization problem's size. The reserve scheduling problem considered capacity payments, but neglected revenues from reserve energy utilization. Incorporating the latter in the framework is possible if SFC signal scenarios can be generated based on historical data, and is expected to reduce the necessary capacity payments. Additionally, comfort constraints can be relaxed as chance constraints allowing comfort zone violations with a small probability, which is typical for building climate control, while keeping HVAC input constraints robust. Such combination of robust and chance-constrained optimization is likely to increase reserve capacities. In the future, we plan to include these aspects in the framework, implement and test it on a real building.
Overall, our results show that significant amounts of SFC reserves can be \emph{reliably} offered by an aggregation of {\raise.17ex\hbox{$\scriptstyle\sim$}}$100$ commercial buildings without loss of occupant comfort. We found that with traditional unconstrained SFC signals asymmetric reserves are preferable for buildings, that energy-constrained SFC signals reduce the necessary capacity payments and increase reserves by up to {\raise.17ex\hbox{$\scriptstyle\sim$}}$10\%$ compared to traditional SFC signals, and that reducing the duration of reserve products from $1$ day to $1$ hour increases reserves by up to {\raise.17ex\hbox{$\scriptstyle\sim$}}$9\%$.
\begin{figure}[t
\centering
\begin{minipage}{0.25\linewidth
\centering \includegraphics[width=2.45in,height=1.8in]{TaEpsAnalysisWinter_bw_correct_v2.eps}
\end{minipage
\begin{minipage}{0.94\linewidth
\centering \includegraphics[width=2.45in,height=1.8in]{TaEpsScatterWinterSummer_bw.eps}
\end{minipage
\caption{Left: sensitivity of reserve capacity (MW) on averaging period $T$ and bias $\varepsilon$ in winter. Right: capacity's dependence on $\varepsilon T$ in winter and summer.
\label{fig:TaEpsAnalysis
\end{figure}
\bibliographystyle{elsarticle-num}
|
{'timestamp': '2015-06-18T02:18:08', 'yymm': '1506', 'arxiv_id': '1506.05399', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05399'}
|
arxiv
|
\section{Introduction}\label{sec:intro}
Nowadays, online social networks which can provide users with various services have become ubiquitous in our daily life. The services provided by social networks are very diverse, e.g., make new friends online, read and write comments on recent news, recommend products and locations, etc. Real-world social networks which can provide these services usually have heterogeneous information, involving various kinds of information entities (e.g., users, locations, posts) and complex connections (e.g., social links among users, purchase links between users and products). Meanwhile, among these services provided by social networks, community detection techniques play a very important role. For example, organizing online friends into different categories (e.g., ``family members'', ``celebrities'', and ``classmates'') in Facebook and group-level recommendations of products in e-commerce sites are all based on community structures of users detected from the networks.
Meanwhile, as proposed in \cite{KZY13, ZKY13, ZKY14, ZYZ14}, to enjoy more social services, users nowadays are usually involved in multiple online social networks simultaneously, e.g., Facebook, Twitter and Foursquare. Furthermore, some of these networks can share common information either due to the common network establishing purpose or because of similar network features \cite{ZY15}. Across these networks, the common users are defined as the \textit{anchor users}, while the remaining non-shared users are named as the \textit{non-anchor users}. Connections between \textit{anchor users'} accounts in different networks are defined as the \textit{anchor links}. The networks partially aligned by \textit{anchor links} are called \textit{multiple partially aligned networks}.
In this paper, we want to detect the communities of each network across multiple \textit{partially aligned social networks} simultaneously, which is formally defined as the \textit{Mutual Clustering} problem. The goal is to distill relevant information from another social network to compliment knowledge directly derivable from each network to improve the clustering or community detection, while preserving the distinct characteristics of each individual network. The \textit{Mutual Clustering} problem is very important for online social networks and can be the prerequisite for many concrete social network applications: (1) \textit{network partition}: Detected communities can usually represent small-sized subgraphs of the network, and (2) \textit{comprehensive understanding of user social behaviors}: Community structures of the shared users in multiple aligned networks can provide a complementary understanding of their social interactions in online social networks.
Besides its importance, the \textit{Mutual Clustering} problem is a novel problem and different from existing clustering problems, including: (1) \textit{consensus clustering}, \cite{GF08, LDJ07, NC07, LBRFFP13, LD13} which aims at achieving a consensus result of several input clustering results about the same data; (2) \textit{multi-view clustering}, \cite{BS04, CNH13} whose target is to partition objects into clusters based on their different representations, e.g., clustering webpages with text information and hyperlinks; (3) \textit{multi-relational clustering}, \cite{YHY07, BG05} which focuses on clustering objects in one relation (called target relation) using information in multiple inter-linked relations; and (4) \textit{co-regularized multi-domain graph clustering} \cite{CZGW13}, which relaxes the \textit{one-to-one} constraints on node correspondence relationships between different views in multi-view clustering to ``\textit{uncertain}'' mappings. In \cite{CZGW13}, prior knowledge about the weights of mappings is required and each view is actually a homogeneous network (more differences are summarized in Section~\ref{sec:relatedwork}). Unlike these existing clustering problems, the \textit{Mutual Clustering} problem aims at detecting the communities for multiple networks involving both anchor and non-anchor users simultaneously and each network contains heterogeneous information about users' social activities. A more detailed comparison of \textit{Mutual Clustering} problem with these related problems is available in Table~\ref{tab:related}.
\begin{table*}[t]
\scriptsize
\centering
{
\caption{Summary of related problems.}\label{tab:related}
\begin{tabular}{|l|c|c|c|c|c|}
\hline
& \textbf{Mutual}
& \textbf{Co-Regularized}
& \textbf{Consensus}
& \textbf{Multi-View}
& \textbf{Multi-Relational} \\
& \textbf{Clustering}
& \textbf{Graph}
& \textbf{Clustering}
& \textbf{Clustering}
& \textbf{Clustering} \\
Property
& \textbf{}
& \textbf{Clustering \cite{CZGWSW13}}
& \textbf{\cite{LBRFFP13, LD13, ZL11-2}}
& \textbf{\cite{BS04, CNH13, CKLS09}}
& \textbf{\cite{YHY07, BG05}} \\
\hline
input
&multiple networks
&data with multi-views
&multiple clusters
&data with multi-views
&data of multi-relations\\
output
&clusters of
&clusters of items
&consensus of
&clusters of items
&clusters of item in\\
&each network
&in each view
&input clusters
&across views
&the target relation\\
\# networks
&multiple
&multiple
&n/a
&multiple
&single\\
network type
&heterogeneous
&homogeneous
&n/a
&homogeneous
&heterogeneous\\
network aligned?
&partially aligned
&no
&n/a
&no
&no\\
network connections
&anchor links
&uncertain mappings
&n/a
&certain mappings
&n/a\\
\hline
\end{tabular}
}
\end{table*}
Despite its importance and novelty, the \textit{Mutual Clustering} is very challenging to solve due to:
\begin{itemize}
\item \textit{Closeness Measure}: Users in heterogeneous social networks can be connected with each other by various direct and indirect connections. A general closeness measure among users with such connection information is the prerequisite for addressing the \textit{mutual clustering} problem.
\item \textit{Network Characteristics}: Social networks usually have their own characteristics, which can be reflected in the community structures formed by users. Preservation of each network's characteristics (i.e., some unique structures in each network's detected communities) is very important in the \textit{Mutual Clustering} problem.
\item \textit{Mutual Community Detection}: Information in different networks can provide us with a more comprehensive understanding about the anchor users' social structures. For anchor users whose community structures are not clear based on in formation in one network, utilizing the heterogeneous information in aligned networks to refine and disambiguate the community structures about the anchor users. However, how to achieve such a goal is still an open problem.
\item \textit{Lack of Metrics}. \textit{Mutual Clustering} problem is a new problem and few existing metrics can be applied to evaluate the comprehensive performance of \textit{Mutual Clustering} methods.
\end{itemize}
To solve all these challenges, a novel cross-network community detection method, {\textsc{MCD}} (Mutual Community Detector), is proposed in this paper. {\textsc{MCD}} maps the complex relationships in the social network into a heterogeneous information network \cite{SHYYW11} and introduces a novel meta-path based closeness measure, \textit{HNMP-Sim}, to utilize both direct and indirect connections among users in closeness scores calculation. With full considerations of the network characteristics, {\textsc{MCD}} exploits the information in aligned networks to refine and disambiguate the community structures of the multiple networks concurrently. Besides traditional \textit{quality} and \textit{consensus} metrics, we define a novel general metric, $IQC$ (Integrated Quality \& Consensus), to evaluate the performance of mutual clustering methods.
This paper is organized as follows: In Section~\ref{sec:formulation}, we formulate the problem. Section~\ref{sec:method} introduces the \textit{Mutual Clustering} methods. Section~\ref{sec:experiment} shows the experiment results. In Sections~\ref{sec:relatedwork} and \ref{sec:conclusion}, we give the related works and conclude this paper.
\section{Problem Formulation}
\label{sec:formulation}
\begin{figure}[t]
\centering
\begin{minipage}[l]{1.0\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{eg_fig3.pdf}
\end{minipage}
\caption{Heterogeneous online social networks.}\label{eg_fig3}
\end{figure}
The networks studied in this paper are Foursquare and Twitter. Users in both Foursquare and Twitter can follow other users, write tips/tweets, which can contain timestamps, text content and location check-ins. As a result, both Foursquare and Twitter can be modeled as heterogeneous information networks $G = (V, E)$, where $V = \mathcal{U} \cup \mathcal{P} \cup \mathcal{L} \cup \mathcal{T} \cup \mathcal{W}$ is the set of different types of nodes in the network and $\mathcal{U}$, $\mathcal{P}$, $\mathcal{L}$, $\mathcal{T}$, $\mathcal{W}$ are the node sets of users, posts, location check-ins, timestamps and words respectively, while $E = \mathcal{E}_{s} \cup \mathcal{E}_{p} \cup \mathcal{E}_{l} \cup \mathcal{E}_{t} \cup \mathcal{E}_{w}$ is set of directed links in the network and $\mathcal{E}_{s}$, $\mathcal{E}_{p}$, $\mathcal{E}_{l}$, $\mathcal{E}_{t}$ and $\mathcal{E}_{w}$ are the sets of social links among users, links between users and posts and those between posts and location-checkins, timestamps as well as words respectively. To illustrate the structure of the heterogeneous network studied in this paper, we also give an example in Figure~\ref{eg_fig3}. As shown in the figure, users in the network can be extensively connected with each other by different types of links (e.g., social links, co-location checkins connections).
The multiple aligned networks can be modeled as $\mathcal{G} = (G_{set}, A_{set})$, where $G_{set} = \{G^{(1)}, G^{(2)}, \ldots, G^{(n)}\}, |G_{set}| = n$ is the set of $n$ heterogeneous information networks and $A_{set} = \{A^{(1,2)}, \ldots, A^{(1,n)}, A^{(2,3)}, \ldots, A^{((n - 1),n)}\}$ is the set of undirected anchor links between different heterogeneous networks in $G_{set}$. In this paper, we will follow the definitions about ``anchor user'', ``non-anchor user'', ``anchor link'', etc. proposed in \cite{KZY13, ZKY13, ZKY14, ZYZ14} and the constraint on anchor links is ``\textit{one-to-one}'', i.e., each user can have one account in on network. The case that users have multiple accounts in online social networks can be resolved with method introduced in \cite{TZ14}, where these duplicated accounts can be aggregated in advance to form one unique vitural account in advance and the anchor links connecting these vitural accounts will be still ``\textit{one-to-one}''. Different from \cite{KZY13, ZKY13}, networks studied in this paper are all \textit{partially aligned} \cite{ZKY14, ZYZ14}.
\noindent \textbf{Mutual Clustering Problem}: For the given multiple aligned heterogeneous networks $\mathcal{G}$, the \textit{Mutual Clustering} problem aims to obtain the optimal communities $\{\mathcal{C}^{(1)}, \mathcal{C}^{(2)}, \cdots, \mathcal{C}^{(n)}\}$ for $\{G^{(1)}, G^{(2)}, \cdots, G^{(n)}\}$ simultaneously, where\\ $\mathcal{C}^{(i)} = \{U^{(i)}_1, U^{(i)}_2, \ldots, U^{(i)}_{k^{(i)}}\}$ is a partition of the users set $\mathcal{U}^{(i)}$ in $G^{(i)}$, $k^{(i)} = \left | \mathcal{C}^{(i)} \right |$, $U^{(i)}_l \cap U^{(i)}_m = \emptyset$, $\forall\ l,m \in \{1, 2, \ldots, k^{(i)}\}$ and $\bigcup_{j = 1}^{k^{(i)}} U^{(i)}_j = \mathcal{U}^{(i)}$. Users in each detected cluster are more densely connected with each other than with users in other clusters. In this paper, we focus on studying the hard (i.e., non-overlapping) clustering of users in online social networks.
\section{Proposed Methods}
\label{sec:method}
\begin{table*}[t]
\scriptsize
\centering
{
\caption{Summary of HNMPs.}\label{tab:meta_path}
\begin{tabular}{llll}
\hline
\textbf{ID}
&\textbf{Notation}
& \textbf{Heterogeneous Network Meta Path}
& \textbf{Semantics}\\
\hline
\hline
1
&U $\to$ U
&User $\xrightarrow{follow}$ User
&Follow\\
2
&U $\to$ U $\to$ U
&User $\xrightarrow{follow}$ User $\xrightarrow{follow}$ User
&Follower of Follower\\
3
&U $\to$ U $\gets$ U
&User $\xrightarrow{follow}$ User $\xrightarrow{follow^{-1}}$ User
&Common Out Neighbor\\
4
&U $\gets$ U $\to$ U
&User $\xrightarrow{follow^{-1}}$ User $\xrightarrow{follow}$ User
&Common In Neighbor\\
\hline
5
&U $\to$ P $\to$ W $\gets$ P $\gets$ U
&User $\xrightarrow{write}$ Post $\xrightarrow{contain}$ Word
&Posts Containing Common Words\\
&&\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\xrightarrow{contain^{-1}}$ Post $\xrightarrow{write^{-1}}$ User&\\
6
&U $\to$ P $\to$ T $\gets$ P $\gets$ U
&User $\xrightarrow{write}$ Post $\xrightarrow{contain}$ Time
&Posts Containing Common Timestamps\\
&&\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\xrightarrow{contain^{-1}}$ Post $\xrightarrow{write^{-1}}$ User&\\
7
&U $\to$ P $\to$ L $\gets$ P $\gets$ U
&User $\xrightarrow{write}$ Post $\xrightarrow{attach}$ Location
&Posts Attaching Common Location Check-ins\\
&&\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\xrightarrow{attach^{-1}}$ Post $\xrightarrow{write^{-1}}$ User&\\
\hline
\end{tabular}
}
\end{table*}
A co-regularization based multi-view clustering model was proposed in \cite{CZGW13}, which achieves the clustering results of nodes across multi-view by minimizing absolute clustering disagreement of all nodes (both shared and non-shared nodes). It cannot be applied to address the \textit{Mutual Clustering} problem, as in {mutual clustering}, we only exploit information across networks to refine the social community structures of anchor users only, while non-anchor users social community structures are not affected and can preserve their characteristics. To solve the \textit{Mutual Clustering} problem, a novel community detection method, {\textsc{MCD}}, will be proposed in this section. By mapping the social network relations into a heterogeneous information network, we use the concept of social meta path to define closeness measure among users in Section 3.1. Based on this similarity measure, we introduce the network characteristics preservation independent clustering method in Section 3.2 and normalized discrepancy based co-clustering method in Section 3.3. To preserve network characteristics and use information in other networks to refine community structures mutually at the same time, we study the mutual clustering problem in Section 3.4.
\subsection{HNMP-Sim}
Many existing similarity measures, e.g., ``Common Neighbor'' \cite{HZ11}, ``Jaccard's Coefficient'' \cite{HZ11}, defined for homogeneous networks cannot capture all the connections among users in heterogeneous networks. To use both direct and indirect connections among users in calculating the similarity score among users in the heterogeneous information network, we introduce meta path based similarity measure HNMP-Sim in this section.
\subsubsection{Meta Paths in Heterogeneous Networks}
In heterogeneous networks, pairs of nodes can be connected by different paths, which are sequences of links in the network. Meta paths \cite{SHYYW11, SYH09} in heterogeneous networks, i.e., \textit{heterogeneous network meta paths} (HNMPs), can capture both direct and indirect connections among nodes in a network. The length of a meta path is defined as the number of links that constitute it. Meta paths in networks can start and end with various node types. However, in this paper, we are mainly concerned about those starting and ending with users, which are formally defined as the \textit{social HNMPs}. The notation, definition and semantics of $7$ different \textit{social HNMPs} used in this paper are listed in Table~\ref{tab:meta_path}. To extract the social meta paths, prior domain knowledge about the network structure is required.
\subsubsection{HNMP-based Similarity}
These $7$ different social HNMPs in Table~\ref{tab:meta_path} can cover lots of connections among users in networks. Some meta path based similarity measures have been proposed so far, e.g., the \textit{PathSim} proposed in \cite{SHYYW11}, which is defined for undirected networks and considers different meta paths to be of the same importance. To measure the social closeness among users in directed heterogeneous information networks, we extend \textit{PathSim} to propose a new closeness measure as follows.
\noindent \textbf{Definition 1} (HNMP-Sim): Let $\mathcal{P}_i(x \rightsquigarrow y)$ and $\mathcal{P}_i(x \rightsquigarrow \cdot)$ be the sets of path instances of HNMP \# $i$ going from $x$ to $y$ and those going from $x$ to other nodes in the network. The HNMP-Sim (HNMP based Similarity) of node pair $(x, y)$ is defined as
$$\mbox{HNMP-Sim}(x, y) = \sum_i \omega_i \left(\frac{\left| \mathcal{P}_i(x \rightsquigarrow y) \right| + \left| \mathcal{P}_i(y \rightsquigarrow x) \right|} {{\left| \mathcal{P}_i(x \rightsquigarrow \cdot) \right| } + \left| \mathcal{P}_i(y \rightsquigarrow \cdot) \right|}\right),$$
where $\omega_i$ is the weight of HNMP \# $i$ and $\sum_i \omega_i = 1$. In this paper, the weights of different HNMPs can be automatically adjusted by applying the technique proposed in \cite{ZY15}.
Let $\mathbf{A}_i$ be the \textit{adjacency matrix} corresponding to the HNMP \# i among users in the network and $\mathbf{A}_i(m, n) = k$ iff there exist $k$ different path instances of HNMP \# $i$ from user $m$ to $n$ in the network. Furthermore, the similarity score matrix among users of HNMP \# $i$ can be represented as $\mathbf{S}_i = \left( \mathbf{D}_i + \bar{\mathbf{D}}_i \right)^{-1} \left( \mathbf{A}_i + \mathbf{A}_i^T \right)$, where $\mathbf{A}_i^T$ denotes the transpose of $\mathbf{A}_i$, diagonal matrices $\mathbf{D}_i$ and $\bar{\mathbf{D}}_i$ have values $\mathbf{D}_i{(l,l)} = \sum_m \mathbf{A}_i{(l,m)}$ and $\bar{\mathbf{D}}_i{(l,l)} = \sum_m (\mathbf{A}_i^T){(l,m)}$ on their diagonals respectively. The HNMP-Sim matrix of the network which can capture all possible connections among users is represented as follows:
$$\mathbf{S} = \sum_i \omega_i \mathbf{S}_i = \sum_i \omega_i \left( \left( \mathbf{D}_i + \bar{\mathbf{D}}_i \right)^{-1} \left( \mathbf{A}_i + \mathbf{A}_i^T \right) \right).$$
\subsection{Network Characteristic Preservation Clustering}
Clustering each network independently can preserve each networks characteristics effectively as no information from external networks will interfere with the clustering results. Partitioning users of a certain network into several clusters will cut connections in the network and lead to some costs inevitably. Optimal clustering results can be achieved by minimizing the clustering costs.
For a given network $G$, let $\mathcal{C} = \{U_1, U_2, \ldots, U_k\}$ be the community structures detected from $G$. Term $\overline{U_i} = \mathcal{U} - U_i$ is defined to be the complement of set $U_i$ in $G$. Various cost measure of partition $\mathcal{C}$ can be used, e.g., \textit{cut} \cite{WL93} and \textit{normalized cut} \cite{SM00}:
$$cut(\mathcal{C}) = \frac{1}{2}\sum_{i = 1}^k S(U_i, \overline{U_i}) = \frac{1}{2}\sum_{i = 1}^k \sum_{u \in U_i, v \in \overline{U_i}} S(u, v),$$
$$Ncut(\mathcal{C}) = \frac{1}{2}\sum_{i = 1}^k \frac{S(U_i, \overline{U_i})}{S(U_i, \cdot)} = \sum_{i = 1}^k\frac{cut(U_i, \overline{U}_i)}{S(U_i, \cdot)},$$
where $S(u, v)$ denotes the HNMP-Sim between $u, v$ and $S(U_i, \cdot) = S(U_i, \mathcal{U}) = S(U_i, U_i) + S(U_i, \overline{U}_i)$.
For all users in $\mathcal{U}$, their clustering result can be represented in the \textit{result confidence matrix} $\mathbf{H}$, where $\bf{H} = [\bf{h}_1,$ $\bf{h}_2,$ $\ldots,$ $\bf{h}_n]^T$, $n = |\mathcal{U}|$, $\mathbf{h}_i = (h_{i,1}, h_{i,2}, \ldots, h_{i,k})$ and $h_{i,j}$ denotes the confidence that $u_i \in \mathcal{U}$ is in cluster $U_j \in \mathcal{C}$. The optimal $\bf{H}$ that can minimize the normalized-cut cost can be obtained by solving the following objective function \cite{L07}:
\begin{align*}
\min_{\mathbf{H}}\ \ &\mbox{Tr} (\mathbf{H}^T\mathbf{L}\mathbf{H}),\\
s.t. \ \ &\mathbf{H}^T\mathbf{D}\mathbf{H} = \mathbf{I}.
\end{align*}
where $\mathbf{L} = \mathbf{D} - \mathbf{S}$, diagonal matrix $\mathbf{D}$ has $\mathbf{D}(i,i) = \sum_j \mathbf{S}(i,j)$ on its diagonal, and $\mathbf{I}$ is an identity matrix.
\subsection{Discrepancy based Clustering of Multiple Networks}
Besides the shared information due to common network construction purposes and similar network features \cite{ZY15}, anchor users can also have unique information (e.g., social structures) across aligned networks, which can provide us with a more comprehensive knowledge about the community structures formed by these users. Meanwhile, by maximizing the consensus (i.e., minimizing the ``\textit{discrepancy}'') of the clustering results about the anchor users in multiple partially aligned networks, we refine the clustering results of the anchor users with information in other aligned networks mutually. We can represent the clustering results achieved in $G^{(1)}$ and $G^{(2)}$ as $\mathcal{C}^{(1)} = \{U^{(1)}_1, U^{(1)}_2,$ $\cdots,$ $U^{(1)}_{k^{(1)}}\}$ and $\mathcal{C}^{(2)} = \{U^{(2)}_1, U^{(2)}_2, \cdots, U^{(2)}_{k^{(2)}}\}$ respectively.
Let $u_i$ and $u_j$ be two anchor users in the network, whose accounts in $G^{(1)}$ and $G^{(2)}$ are $u^{(1)}_i$, $u^{(2)}_i$, $u^{(1)}_j$ and $u^{(2)}_j$ respectively. If users $u^{(1)}_i$ and $u^{(1)}_j$ are partitioned into the same cluster in $G^{(1)}$ but their corresponding accounts $u^{(2)}_i$ and $u^{(2)}_j$ are partitioned into different clusters in $G^{(2)}$, then it will lead to a \textit{discrepancy} between the clustering results of $u^{(1)}_i$, $u^{(2)}_i$, $u^{(1)}_j$ and $u^{(2)}_j$ in aligned networks $G^{(1)}$ and $G^{(2)}$.
\noindent \textbf{Definition 2} (Discrepancy): The discrepancy between the clustering results of $u_i$ and $u_j$ across aligned networks $G^{(1)}$ and $G^{(2)}$ is defined as the difference of confidence scores of $u_i$ and $u_j$ being partitioned in the same cluster across aligned networks. Considering that in the clustering results, the confidence scores of $u^{(1)}_i$ and $u^{(1)}_j$ ($u^{(2)}_i$ and $u^{(2)}_j$ ) being partitioned into $k^{(1)}$ ($k^{(2)}$) clusters can be represented as vectors $\mathbf{h}_i^{(1)}$ and $\mathbf{h}_j^{(1)}$ ($\mathbf{h}_i^{(2)}$ and $\mathbf{h}_j^{(2)}$) respectively, while the confidences that $u_i$ and $u_j$ are in the same cluster in $G^{(1)}$ and $G^{(2)}$ can be denoted as $\mathbf{h}_i^{(1)} (\mathbf{h}_j^{(1)})^T$ and $\mathbf{h}_i^{(2)} (\mathbf{h}_j^{(2)})^T$. Formally, the discrepancy of the clustering results about $u_i$ and $u_j$ is defined to be $d_{ij}(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}) = \left(\mathbf{h}_i^{(1)} (\mathbf{h}_j^{(1)})^T - \mathbf{h}_i^{(2)} (\mathbf{h}_j^{(2)})^T\right )^2$ if $u_i, u_j$ are both anchor users; and $d_{ij}(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}) = 0$ otherwise.
Furthermore, the discrepancy of $\mathcal{C}^{(1)}$ and $\mathcal{C}^{(2)}$ will be:
\begin{align*}
d(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}) &= \sum_i^{n^{(1)}} \sum_j^{n^{(2)}} d_{ij}(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}),
\end{align*}
where ${n^{(1)}} = |\mathcal{U}^{(1)}|$ and ${n^{(2)}} = |\mathcal{U}^{(2)}|$. In the definition, non-anchor users are not involved in the discrepancy calculation, which is totally different from the clustering disagreement function (all the nodes are included) introduced in \cite{CZGW13}
However, considering that $d(\mathcal{C}^{(1)}, \mathcal{C}^{(2)})$ is highly dependent on the number of anchor users and anchor links between $G^{(1)}$ and $G^{(2)}$, minimizing $d(\mathcal{C}^{(1)}, \mathcal{C}^{(2)})$ can favor highly consented clustering results when the anchor users are abundant but have no significant effects when the anchor users are very rare. To solve this problem, we propose to minimize the \textit{normalized discrepancy} instead, which significantly differs from the absolute clustering disagreement cost used in \cite{CZGW13}.
\noindent \textbf{Definition 3} (Normalized Discrepancy) The normalized discrepancy measure computes the differences of clustering results in two aligned networks as a fraction of the discrepancy with regard to the number of anchor users across partially aligned networks:
$$Nd(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}) = \frac{d(\mathcal{C}^{(1)}, \mathcal{C}^{(2)})}{\left( \left | A^{(1,2)} \right | \right) \left( \left | A^{(1,2)} \right | - 1 \right)}.$$
Optimal consensus clustering results of $G^{(1)}$ and $G^{(2)}$ will be $\hat{\mathcal{C}^{(1)}}, \hat{\mathcal{C}^{(2)}}$:
$$
\hat{\mathcal{C}}^{(1)}, \hat{\mathcal{C}}^{(2)} = \arg \min_{\mathcal{C}^{(1)}, \mathcal{C}^{(2)}} Nd(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}).
$$
Similarly, the normalized-discrepancy objective function can also be represented with the \textit{clustering results confidence matrices} $\mathbf{H}^{(1)}$ and $\mathbf{H}^{(2)}$ as well. Meanwhile, considering that the networks studied in this paper are partially aligned, matrices $\mathbf{H}^{(1)}$ and $\mathbf{H}^{(2)}$ contain the results of both anchor users and non-anchor users, while non-anchor users should not be involved in the discrepancy calculation according to the definition of discrepancy. We propose to prune the results of the non-anchor users with the following \textit{anchor transition matrix} first.
\noindent \textbf{Definition 4} (Anchor Transition Matrix): Binary matrix $\mathbf{T}^{(1,2)}$ (or $\mathbf{T}^{(2,1)}$) is defined as the anchor transition matrix from networks $G^{(1)}$ to $G^{(2)}$ (or from $G^{(2)}$ to $G^{(1)}$), where $\mathbf{T}^{(1,2)} = ({\mathbf{T}^{(2,1)}})^T$, $\mathbf{T}^{(1,2)}(i, j) = 1$ if $(u^{(1)}_i, u^{(2)}_j) \in A^{(1,2)}$ and $0$ otherwise. The row indexes of $\mathbf{T}^{(1,2)}$ (or $\mathbf{T}^{(2,1)}$) are of the same order as those of $\mathbf{H}^{(1)}$ (or $\mathbf{H}^{(2)}$). Considering that the constraint on anchor links is ``\textit{one-to-one}'' in this paper, as a result, each row/column of $\mathbf{T}^{(1,2)}$ and $\mathbf{T}^{(2,1)}$ contains at most one entry filled with $1$.
\begin{figure}[t]
\centering
\begin{minipage}[l]{1.0\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{discrepancy_example.pdf}
\end{minipage}
\caption{An example to illustrate the clustering discrepancy.}\label{fig_discrepancy_example}
\end{figure}
In Figure~\ref{fig_discrepancy_example}, we show an example about the clustering discrepancy of two partially aligned networks $G^{(1)}$ and $G^{(2)}$, users in which are grouped into two clusters $\{\{u_1, u_3\}, \{u_2\}\}$ and $\{\{u_A, u_C\}, \{u_B, u_D\}\}$ respectively. Users $u_1$, $u_A$ and $u_3$, $u_C$ are identified to be anchor users, based on which we can construct the ``anchor transition matrices'' $\mathbf{T}^{(1,2)}$ and $\mathbf{T}^{(2,1)}$ as shown in the upper right plot. Furthermore, based on the community structure, we can construct the ``\textit{clustering confidence matrices}'' as shown in the lower left plot. To obtain the clustering results of anchor users only, the \textit{anchor transition matrix} can be applied to prune the clustering results of non-anchor users from the \textit{clustering confidence matrices}. By multiplying the \textit{anchor transition matrices} $(\mathbf{T}^{(1,2)})^T$ and $(\mathbf{T}^{(2,1)})^T$ with \textit{clustering confidence matrices} $\mathbf{H}^{(1)}$ and $\mathbf{H}^{(2)}$ respectively, we can obtain the ``pruned confidence matrices'' as show in the lower right plot of Figure~\ref{fig_discrepancy_example}. Entries corresponding anchor users $u_1$, $u_3$, $u_A$ and $u_C$ are preserved but those corresponding to non-anchor users are all pruned.
In this example, the clustering discrepancy of the partially aligned networks should be $0$ according to the above discrepancy definition. Meanwhile, networks $G^{(1)}$ and $G^{(2)}$ are of different sizes and the pruned confidence matrices are of different dimensions, e.g., $(\mathbf{T}^{(1,2)})^T\mathbf{H}^{(1)} \in \mathbb{R}^{4\times2}$ and $(\mathbf{T}^{(2,1)})^T\mathbf{H}^{(2)} \in \mathbb{R}^{3\times2}$. To represent the discrepancy with the clustering confidence matrices, we need to further accommodate the dimensions of different pruned \textit{clustering confidence matrices}. It can be achieved by multiplying one pruned \textit{clustering confidence matrices} with the corresponding \textit{anchor transition matrix} again, which will not prune entries but only adjust the matrix dimensions. Let $\bar{\mathbf{H}}^{(1)} = (\mathbf{T}^{(1,2)})^T\mathbf{H}^{(1)}$ and $\bar{\mathbf{H}}^{(2)} = (\mathbf{T}^{(1,2)})^T (\mathbf{T}^{(2,1)})^T {\mathbf{H}^{(2)}}$. In the example, we can represent the clustering discrepancy to be
$$\left \| \bar{\mathbf{H}}^{(1)} \left(\bar{\mathbf{H}}^{(1)} \right )^T - \bar{\mathbf{H}}^{(2)} \left ( \bar{\mathbf{H}}^{(2)} \right)^T \right \|^2_F = 0,$$
where matrix $\bar{\mathbf{H}}\bar{\mathbf{H}}^T$ indicates whether pairs of anchor users are in the same cluster or not.
Furthermore, the objective function of inferring clustering confidence matrices, which can minimize the normalized discrepancy can be represented as follows
\begin{align*}
\min_{\mathbf{H}^{(1)}, \mathbf{H}^{(2)}} & \frac{\left \| \bar{\mathbf{H}}^{(1)} \left(\bar{\mathbf{H}}^{(1)} \right )^T - \bar{\mathbf{H}}^{(2)} \left ( \bar{\mathbf{H}}^{(2)} \right)^T \right \|^2_F}{\left \| \mathbf{T}^{(1,2)} \right \|^2_F \left (\left \| \mathbf{T}^{(1,2)} \right \|^2_F - 1\right)}, \\
s.t. \ \ &(\mathbf{H}^{(1)})^T\mathbf{D}^{(1)}\mathbf{H}^{(1)} = \mathbf{I}, (\mathbf{H}^{(2)})^T\mathbf{D}^{(2)}\mathbf{H}^{(2)} = \mathbf{I}.
\end{align*}
where $\mathbf{D}^{(1)}$, $\mathbf{D}^{(2)}$ are the corresponding diagonal matrices of HNMP-Sim matrices of networks $G^{(1)}$ and $G^{(2)}$ respectively.
\begin{algorithm}[t]
\caption{Curvilinear Search Method ($\mathcal{CSM}$)}
\label{alg:update}
\begin{algorithmic}[1]
\REQUIRE $\mathbf{X}_k$ $C_k$, $Q_k$ and function $\mathcal{F}$\\
\qquad parameters $\mathbf{\epsilon} = \{\rho, \eta, \delta, \tau, \tau_m, \tau_M\}$\\
\ENSURE $\mathbf{X}_{k + 1}$, $C_{k + 1}$, $Q_{k + 1}$\\
\STATE $\mathbf{Y}(\tau) = \left( \mathbf{I} + \frac{\tau}{2}\mathbf{A}\right)^{-1} \left( \mathbf{I} - \frac{\tau}{2}\mathbf{A}\right) \mathbf{X}_k$
\WHILE{$\mathcal{F}\left( \mathbf{Y}(\tau)\right) \ge \mathbf{C}_k + \rho \tau \mathcal{F}^\prime \left( (\mathbf{Y}(0)) \right)$}
\STATE {$\tau = \delta \tau$}
\STATE $\mathbf{Y}(\tau) = \left( \mathbf{I} + \frac{\tau}{2}\mathbf{A}\right)^{-1} \left( \mathbf{I} - \frac{\tau}{2}\mathbf{A}\right) \mathbf{X}_k$
\ENDWHILE
\STATE {$\mathbf{X}_{k + 1} = \mathbf{Y}_k(\tau)$\\$Q_{k + 1} = \eta Q_k + 1$\\ $C_{k + 1} = \left( \eta Q_k C_k + \mathcal{F}(\mathbf{X}_{k + 1}) \right)/Q_{k + 1}$\\$\tau = \max \left( \min(\tau, \tau_M), \tau_m \right)$}
\end{algorithmic}
\end{algorithm}
\subsection{Joint Mutual Clustering of Multiple Networks}\label{subsec:joint}
Normalized-Cut objective function favors clustering results that can preserve the characteristic of each network, however, normalized-discrepancy objective function favors consensus results which are mutually refined with information from other aligned networks. Taking both of these two issues into considerations, the optimal mutual clustering results $\mathcal{\hat{C}}^{(1)}$ and $\mathcal{\hat{C}}^{(2)}$ of aligned networks $G^{(1)}$ and $G^{(2)}$ can be achieved as follows:
\begin{align*}
\arg \min_{\mathcal{C}^{(1)}, \mathcal{C}^{(2)}} \alpha \cdot Ncut(\mathcal{C}^{(1)}) + \beta \cdot Ncut(\mathcal{C}^{(2)}) + \theta \cdot Nd(\mathcal{C}^{(1)}, \mathcal{C}^{(2)})
\end{align*}
where $\alpha$, $\beta$ and $\theta$ represents the weights of these terms and, for simplicity, $\alpha$, $\beta$ are both set as $1$ in this paper.
By replacing $Ncut(\mathcal{C}^{(1)})$, $Ncut(\mathcal{C}^{(2)})$, $Nd(\mathcal{C}^{(1)}, \mathcal{C}^{(2)})$ with the objective equations derived above, we can rewrite the joint objective function as follows:
\begin{align*}
\min_{\mathbf{H}^{(1)}, \mathbf{H}^{(2)}}\ \ \alpha \cdot &\mbox{Tr} (({\mathbf{H}^{(1)}})^T\mathbf{L}^{(1)}\mathbf{H}^{(1)}) + \beta \cdot \mbox{Tr} (({\mathbf{H}^{(2)}})^T\mathbf{L}^{(2)}\mathbf{H}^{(2)}) \\
&+ \theta \cdot \frac{\left \| \bar{\mathbf{H}}^{(1)} \left(\bar{\mathbf{H}}^{(1)} \right )^T - \bar{\mathbf{H}}^{(2)} \left ( \bar{\mathbf{H}}^{(2)} \right)^T \right \|^2_F}{\left \| \mathbf{T}^{(1,2)} \right \|^2_F \left (\left \| \mathbf{T}^{(1,2)} \right \|^2_F - 1\right)},\\
s.t. \ \ &({\mathbf{H}^{(1)}})^T\mathbf{D}^{(1)}\mathbf{H}^{(1)} = \mathbf{I}, ({\mathbf{H}^{(2)}})^T\mathbf{D}^{(2)}\mathbf{H}^{(2)} = \mathbf{I},
\end{align*}
where $\mathbf{L}^{(1)} = \mathbf{D}^{(1)} - \mathbf{S}^{(1)}$, $\mathbf{L}^{(2)} = \mathbf{D}^{(2)} - \mathbf{S}^{(2)}$ and matrices $\mathbf{S}^{(1)}$, $\mathbf{S}^{(2)}$ and $\mathbf{D}^{(1)}$, $\mathbf{D}^{(2)}$ are the HNMP-Sim matrices and their corresponding diagonal matrices defined before.
The objective function is a complex optimization problem with orthogonality constraints, which can be very difficult to solve because the constraints are not only non-convex but also numerically expensive to preserve during iterations. Meanwhile, by substituting $\left( \mathbf{D}^{(1)} \right)^{\frac{1}{2}}\mathbf{H}^{(1)}$ and $\left( \mathbf{D}^{(2)} \right)^{\frac{1}{2}}\mathbf{H}^{(2)}$ with $\mathbf{X}^{(1)}$, $\mathbf{X}^{(2)}$, we can transform the objective function into a standard form of problems solvable with method proposed in \cite{WY10}:
\begin{align*}
&\min_{\mathbf{X}^{(1)}, \mathbf{X}^{(2)}}\ \ \alpha \cdot (\mbox{Tr} (({\mathbf{X}^{(1)}})^T \tilde{\mathbf{L}}^{(1)} \mathbf{X}^{(1)}) + \beta \cdot \mbox{Tr} (({\mathbf{X}^{(2)}})^T \tilde{\mathbf{L}}^{(2)} \mathbf{X}^{(2)}) \\
&+ \theta \cdot \frac{\left \| \tilde{\mathbf{T}}^{(1)}\mathbf{X}^{(1)} \left(\tilde{\mathbf{T}}^{(1)} \mathbf{X}^{(1)}\right )^T - \tilde{\mathbf{T}}^{(2)} \mathbf{X}^{(2)} \left (\tilde{\mathbf{T}}^{(2)} \mathbf{X}^{(2)} \right)^T \right \|^2_F}{\left \| \mathbf{T}^{(1,2)} \right \|^2_F \left (\left \| \mathbf{T}^{(1,2)} \right \|^2_F - 1\right)}),\\
&s.t. \ \ ({\mathbf{X}^{(1)}})^T \mathbf{X}^{(1)} = \mathbf{I}, ({\mathbf{X}^{(2)}})^T \mathbf{X}^{(2)} = \mathbf{I}.
\end{align*}
where $\tilde{\mathbf{L}}^{(1)} = ( (\mathbf{D}^{(1)})^{-\frac{1}{2}} )^T \mathbf{L}^{(1)} ( (\mathbf{D}^{(1)})^{-\frac{1}{2}} )$, $\tilde{\mathbf{L}}^{(2)} = ( (\mathbf{D}^{(2)})^{-\frac{1}{2}} )^T\\ \mathbf{L}^{(2)} ( (\mathbf{D}^{(2)})^{-\frac{1}{2}} )$ and $\tilde{\mathbf{T}}^{(1)} = (\mathbf{T}^{(1,2)})^T (\mathbf{D}^{(1)})^{-\frac{1}{2}}$,\\ $\tilde{\mathbf{T}}^{(2)} = (\mathbf{T}^{(1,2)})^T (\mathbf{T}^{(2,1)})^T (\mathbf{D}^{(2)})^{-\frac{1}{2}}$.
Wen et al. \cite{WY10} propose a feasible method to solve the above optimization problems with a constraint-preserving update scheme. They propose to update one variable, e.g., $\mathbf{X}^{(1)}$, while fixing the other variable, e.g., $\mathbf{X}^{(2)}$, alternatively with the curvilinear search with Barzilai-Borwein step method until convergence. For example, when $\mathbf{X}^{(2)}$ is fixed, we can simplify the objective function into
$$\min_{\mathbf{X}} \mathcal{F}(\mathbf{X}), s.t. (\mathbf{X})^T\mathbf{X} = \mathbf{I},$$
where $\mathbf{X} = \mathbf{X}^{(1)}$ and $\mathcal{F}(\mathbf{X})$ is the objective function, which can be solved with the curvilinear search with Barzilai-Borwein step method proposed in \cite{WY10} to update $\mathbf{X}$ until convergence and the variable $\mathbf{X}$ after the $(k+1)_{th}$ iteration will be
\begingroup\makeatletter\def\f@size{8}\check@mathfonts
$$\mathbf{X}_{k+1} = \mathbf{Y}(\tau_k), \mathbf{Y}(\tau_k) = \left( \mathbf{I} + \frac{\tau_k}{2}\mathbf{A}\right)^{-1} \left( \mathbf{I} - \frac{\tau_k}{2}\mathbf{A}\right) \mathbf{X}_k,$$
$$\mathbf{A} = \frac{\partial \mathcal{F}(\mathbf{X}_k)}{\partial \mathbf{X}} \mathbf{X}_k^T - \mathbf{X}_k (\frac{\partial \mathcal{F}(\mathbf{X}_k)}{\partial \mathbf{X}})^T,$$
\endgroup
where let $\hat{\tau} = \left(\frac{\mbox{Tr} \left( (\mathbf{X}_k - \mathbf{X}_{k - 1})^T (\mathbf{X}_k - \mathbf{X}_{k - 1}) \right) }{ \left |\mbox{Tr} \left ( (\mathbf{X}_k - \mathbf{X}_{k - 1})^T \left (\nabla\mathcal{F}(\mathbf{X}_k) - \nabla\mathcal{F}(\mathbf{X}_{k - 1}) \right) \right ) \right |} \right)$, $\tau_k = \hat{\tau} \delta^h$,
$\delta$ is the Barzilai-Borwein step size and $h$ is the smallest integer to make
$\tau_k$ satisfy
\begingroup\makeatletter\def\f@size{8}\check@mathfonts
$$\mathcal{F}\left( \mathbf{Y}(\tau_k) \right) \le C_k + \rho \tau_k \mathcal{F}^\prime_{\tau} \left( \mathbf{Y}(0) \right).$$
\endgroup
Terms $C$, $Q$ are defined as $C_{k + 1} = \left( \eta Q_k C_k + \mathcal{F}(\mathbf{X}_{k + 1}) \right) / Q_{k + 1}$ and $Q_{k + 1} = \eta Q_{k} + 1, Q_0 = 1$. More detailed derivatives of the curvilinear search method (i.e., Algorithm~\ref{alg:update}) with Barzilai-Borwein step is available in \cite{WY10}. Meanwhile, the pseudo-code of method {\textsc{MCD}} is available in Algorithm~\ref{alg:framework}. Based on the achieved solutions $\mathbf{X}^{(1)}$ and $\mathbf{X}^{(2)}$, we can get $\mathbf{H}^{(1)} = \left( \mathbf{D}^{(1)} \right)^{-\frac{1}{2}} \mathbf{X}^{(1)}$ and $\mathbf{H}^{(2)} = \left( \mathbf{D}^{(2)} \right)^{-\frac{1}{2}} \mathbf{X}^{(2)}$.
\begin{algorithm}[t]
\caption{Mutual Community Detector ({\textsc{MCD}})}
\label{alg:framework}
\begin{algorithmic}[1]
\REQUIRE aligned network: $\mathcal{G}$ = $\{\{G^{(1)}$, $G^{(2)}\}$, $\{A^{(1,2)},$ $A^{(2,1)}\}\}$;\\
\qquad number of clusters in $G^{(1)}$ and $G^{(2)}$: $k^{(1)}$ and $k^{(2)}$;\\
\qquad HNMP Sim matrices weight: $\mathbf{\omega}$;\\
\qquad parameters: $\mathbf{\epsilon} = \{\rho, \eta, \delta, \tau, \tau_m, \tau_M\}$;\\
\qquad function $\mathcal{F}$ and consensus term weight $\theta$
\ENSURE $\mathbf{H}^{(1)}$, $\mathbf{H}^{(2)}$\\
\STATE Calculate HNMP Sim matrices, $\mathbf{S}_i^{(1)}$ and $\mathbf{S}^{(2)}_i$
\STATE $\mathbf{S}^{(1)} = \sum_i \omega_i S_i^{(1)}$, $\mathbf{S}^{(2)} = \sum_i \omega_i S_i^{(2)}$
\STATE Initialize $\mathbf{X}^{(1)}$ and $\mathbf{X}^{(2)}$ with Kmeans clustering results on $\mathbf{S}^{(1)}$ and $\mathbf{S}^{(2)}$
\STATE Initialize $C^{(1)}_0 = 0, Q^{(1)}_0 = 1$ and $C^{(2)}_0 = 0, Q^{(2)}_0 = 1$
\STATE $converge = False$
\WHILE{$converge = False$}
\STATE /* update $\mathbf{X}^{(1)}$ and $\mathbf{X}^{(2)}$ with $\mathcal{CSM}$ */\\
$\mathbf{X}^{(1)}_{k+1}$, $C^{(1)}_{k+1}$, $Q^{(1)}_{k+1}$ = $\mathcal{CSM}(\mathbf{X}^{(1)}_k, C^{(1)}_k, Q^{(1)}_k, \mathcal{F}, \mathbf{\epsilon})$\\
$\mathbf{X}^{(2)}_{k+1}$, $C^{(2)}_{k+1}$, $Q^{(2)}_{k+1}$ = $\mathcal{CSM}(\mathbf{X}^{(2)}_k, C^{(2)}_k, Q^{(2)}_k, \mathcal{F}, \mathbf{\epsilon})$
\IF{$\mathbf{X}^{(1)}_{k+1}$ and $\mathbf{X}^{(2)}_{k+1}$ both converge}
\STATE $converge = True$
\ENDIF
\ENDWHILE
\STATE {$\mathbf{H}^{(1)} = \left((\mathbf{D}^{(1)})^{-\frac{1}{2}} \right)^T \mathbf{X}^{(1)}$, $\mathbf{H}^{(2)} = \left((\mathbf{D}^{(2)})^{-\frac{1}{2}} \right)^T \mathbf{X}^{(2)}$}
\end{algorithmic}
\end{algorithm}
\section{Experiments}\label{sec:experiment}
To demonstrate the effectiveness of {\textsc{MCD}}, we will conduct extensive experiments on two real-world partially aligned heterogeneous networks: Foursquare and Twitter, in this section.
\subsection{Dataset Description}
\begin{table}[t]
\caption{Properties of the Heterogeneous Social Networks}
\label{tab:datastat}
\centering
\footnotesize
\begin{tabular}{clrr}
\toprule
&&\multicolumn{2}{c}{network}\\
\cmidrule{3-4}
&property &\textbf{Twitter} &\textbf{Foursquare} \\
\midrule
\multirow{3}{*}{\# node}
&user & 5,223 & 5,392 \\
&tweet/tip & 9,490,707 & 48,756 \\
&location & 297,182 & 38,921 \\
\midrule
\multirow{3}{*}{\# link}
&friend/follow &164,920 &76,972 \\
&write & 9,490,707 & 48,756 \\
&locate & 615,515 & 48,756 \\
\bottomrule
\end{tabular}
\end{table}
As mentioned in the Section~\ref{sec:formulation}, both Foursquare and Twitter used in this paper are heterogeneous social networks, whose statistical information is given in Table~\ref{tab:datastat}. These two networks were crawled with the methods proposed in \cite{KZY13} during November, 2012. The number of anchor links obtained is $3,388$. Some basic descriptions about datasets are as follows:
\begin{itemize}
\item \textbf{Foursquare}: Users together with their posts are crawled from Foursquare, whose number are $5,392$ and $48,756$ respectively. The number of social link among users is $76,972$. All these posts written by these users and can attach locations checkins and, as a result, the numbers of write link and locate link are both $48,756$. $38,921$ different locations are crawled from Foursquare.
\item \textbf{Twitter}: $5,223$ users and all their tweets, whose number is $9,490,707$, are crawled from Twitter and, on average, each user has about $1,817$ tweets. Among these tweets, about $615,515$ have location check-ins, which accounts for about $6.48\%$ of all tweets. The number of locations crawled from Twitter is $297,182$ and the number of social links among users is $164,920$.
\end{itemize}
For more information about the datasets and crawling methods, please refer to \cite{KZY13, ZKY13, ZKY14, ZYZ14}.
\begin{table*}[t]
\caption{Community Detection Results of Foursquare and Twitter Evaluated by Quality Metrics.}
\label{tab:setting1}
\centering
{
\scriptsize
\begin{tabular}{llrcccccccccc}
\toprule
\multicolumn{2}{l}{ }&\multicolumn{10}{c}{remaining anchor link rates $\sigma$}\\
\cmidrule{4-13}
network &measure &methods &0.1 & 0.2 & 0.3 & 0.4 &0.5 &0.6 &0.7 & 0.8 &0.9 &1.0\\
\midrule
\multirow{16}{*}{\rotatebox{90}{Foursquare}}
&\multirow{4}{*}{ndbi}
&{\textsc{MCD}} &\textbf{0.927} &\textbf{0.924} &\textbf{0.95} &\textbf{0.969} &\textbf{0.966} &\textbf{0.961} &\textbf{0.958} &\textbf{0.954} &\textbf{0.971} &\textbf{0.958} \\
&&{\textsc{SIclus}} &0.891 &0.889 &0.88 &0.877 &0.894 &0.883 &0.89 &0.88 &0.887 &0.893 \\
&&{\textsc{Ncut}} &0.863 &0.863 &0.863 &0.863 &0.863 &0.863 &0.863 &0.863 &0.863 &0.863 \\
&&{\textsc{Kmeans}} &0.835 &0.835 &0.835 &0.835 &0.835 &0.835 &0.835 &0.835 &0.835 &0.835 \\
\cmidrule{2-13}
&\multirow{4}{*}{entropy}
&{\textsc{MCD}} &\textbf{1.551} &\textbf{1.607} &\textbf{1.379} &\textbf{1.382} &\textbf{1.396} &\textbf{1.382} &\textbf{1.283} &\textbf{1.552} &\textbf{1.308} &\textbf{1.497} \\
&&{\textsc{SIclus}} &4.332 &4.356 &4.798 &4.339 &4.474 &4.799 &4.446 &4.658 &4.335 &4.459 \\
&&{\textsc{Ncut}} &2.768 &2.768 &2.768 &2.768 &2.768 &2.768 &2.768 &2.768 &2.768 &2.768 \\
&&{\textsc{Kmeans}} &2.369 &2.369 &2.369 &2.369 &2.369 &2.369 &2.369 &2.369 &2.369 &2.369 \\
\cmidrule{2-13}
&\multirow{4}{*}{density}
&{\textsc{MCD}} &\textbf{0.216} &\textbf{0.205} &\textbf{0.196} &0.163 &\textbf{0.239} &\textbf{0.192} &\textbf{0.303} &\textbf{0.198} &0.170 &\textbf{0.311} \\
&&{\textsc{SIclus}} &0.116 &0.121 &0.13 &0.095 &0.143 &0.11 &0.13 &0.12 &0.143 &0.103 \\
&&{\textsc{Ncut}} &0.154 &0.154 &0.154 &0.154 &0.154 &0.154 &0.154 &0.154 &0.154 &0.154 \\
&&{\textsc{Kmeans}} &0.182 &0.182 &0.182 &\textbf{0.182} &0.182 &0.182 &0.182 &0.182 &\textbf{0.182} &0.182 \\
\cmidrule{2-13}
&\multirow{4}{*}{silhouette}
&{\textsc{MCD}} &\textbf{-0.137} &\textbf{-0.114} &\textbf{-0.148} &\textbf{-0.156} &\textbf{-0.117} &\textbf{-0.11} &\textbf{-0.035} &\textbf{-0.125} &\textbf{-0.148} &\textbf{-0.044} \\
&&{\textsc{SIclus}} &-0.168 &-0.198 &-0.173 &-0.189 &-0.178 &-0.181 &-0.21 &-0.195 &-0.167 &-0.18 \\
&&{\textsc{Ncut}} &-0.34 &-0.34 &-0.34 &-0.34 &-0.34 &-0.34 &-0.34 &-0.34 &-0.34 &-0.34 \\
&&{\textsc{Kmeans}} &-0.297 &-0.297 &-0.297 &-0.297 &-0.297 &-0.297 &-0.297 &-0.297 &-0.297 &-0.297 \\
\midrule
\multirow{16}{*}{\rotatebox{90}{Twitter}}
&\multirow{4}{*}{ndbi}
&{\textsc{MCD}} &\textbf{0.962} &\textbf{0.969} &\textbf{0.955} &\textbf{0.969} &\textbf{0.97} &\textbf{0.958} &\textbf{0.952} &\textbf{0.96} &\textbf{0.946} &\textbf{0.953} \\
&&{\textsc{SIclus}} &0.815 &0.843 &0.807 &0.83 &0.826 &0.832 &0.835 &0.808 &0.812 &0.836 \\
&&{\textsc{Ncut}} &0.759 &0.759 &0.759 &0.759 &0.759 &0.759 &0.759 &0.759 &0.759 &0.759 \\
&&{\textsc{Kmeans}} &0.761 &0.761 &0.761 &0.761 &0.761 &0.761 &0.761 &0.761 &0.761 &0.761 \\
\cmidrule{2-13}
&\multirow{4}{*}{entropy}
&{\textsc{MCD}} &\textbf{2.27} &\textbf{2.667} &\textbf{2.48} &\textbf{2.381} &\textbf{2.43} &\textbf{2.372} &\textbf{2.452} &\textbf{2.459} &\textbf{2.564} &\textbf{2.191} \\
&&{\textsc{SIclus}} &4.780 &5.114 &5.066 &4.961 &4.904 &4.866 &5.121 &4.629 &4.872 &5.000 \\
&&{\textsc{Ncut}} &3.099 &3.099 &3.099 &3.099 &3.099 &3.099 &3.099 &3.099 &3.099 &3.099 \\
&&{\textsc{Kmeans}} &3.245 &3.245 &3.245 &3.245 &3.245 &3.245 &3.245 &3.245 &3.245 &3.245 \\
\cmidrule{2-13}
&\multirow{4}{*}{density}
&{\textsc{MCD}} &\textbf{0.14} &0.097 &\textbf{0.142} &0.109 &\textbf{0.15} &\textbf{0.158} &\textbf{0.126} &\textbf{0.149} &\textbf{0.147} &\textbf{0.164} \\
&&{\textsc{SIclus}} &0.055 &0.017 &0.044 &0.026 &0.04 &0.062 &0.016 &0.044 &0.045 &0.02 \\
&&{\textsc{Ncut}} &0.107 &0.107 &0.107 &0.107 &0.107 &0.107 &0.107 &0.107 &0.107 &0.107 \\
&&{\textsc{Kmeans}} &0.119 &\textbf{0.119} &0.119 &\textbf{0.119} &0.119 &0.119 &0.119 &0.119 &0.119 &0.119 \\
\cmidrule{2-13}
&\multirow{4}{*}{silhouette}
&{\textsc{MCD}} &\textbf{-0.137} &\textbf{-0.179} &\textbf{-0.282} &\textbf{-0.175} &\textbf{-0.275} &\textbf{-0.273} &\textbf{-0.248} &\textbf{-0.269} &\textbf{-0.266} &\textbf{-0.286} \\
&&{\textsc{SIclus}} &-0.356 &-0.322 &-0.311 &-0.347 &-0.346 &-0.349 &-0.323 &-0.363 &-0.345 &-0.352 \\
&&{\textsc{Ncut}} &-0.424 &-0.424 &-0.424 &-0.424 &-0.424 &-0.424 &-0.424 &-0.424 &-0.424 &-0.424 \\
&&{\textsc{Kmeans}} &-0.406 &-0.406 &-0.406 &-0.406 &-0.406 &-0.406 &-0.406 &-0.406 &-0.406 &-0.406 \\
\bottomrule
\end{tabular
}
\end{table*}
\begin{table*}[t]
\caption{Community Detection Results of Foursquare and Twitter Evaluated by Consensus Metrics.}
\label{tab:setting3}
\centering
{\scriptsize
\begin{tabular}{lrcccccccccc}
\toprule
\multicolumn{2}{l}{ }&\multicolumn{10}{c}{remaining anchor link rates $\sigma$}\\
\cmidrule{3-12}
measure &methods &0.1 & 0.2 & 0.3 & 0.4 &0.5 &0.6 &0.7 & 0.8 &0.9 &1.0\\
\midrule
\multirow{4}{*}{rand}
&{\textsc{MCD}} &\textbf{0.095} &\textbf{0.099} &\textbf{0.107} &\textbf{0.138} &\textbf{0.116} &\textbf{0.121} &\textbf{0.132} &\textbf{0.106} &\textbf{0.089} &0.159\\
&{\textsc{SIclus}} &0.135 &0.139 &0.144 &0.148 &0.142 &0.14 &\textbf{0.132} &0.132 &0.144 &\textbf{0.141} \\
&{\textsc{Ncut}} &0.399 &0.377 &0.372 &0.4 &0.416 &0.423 &0.362 &0.385 &0.362 &0.341 \\
&{\textsc{Kmeans}} &0.436 &0.387 &0.4 &0.358 &0.403 &0.363 &0.408 &0.365 &0.35 &0.363 \\
\midrule
\multirow{4}{*}{vi}
&{\textsc{MCD}} &\textbf{3.309} &\textbf{4.052} &\textbf{4.058} &\textbf{3.902} &\textbf{4.038} &\textbf{4.348} &\textbf{3.973} &\textbf{3.944} &\textbf{4.078} &\textbf{2.911} \\
&{\textsc{SIclus}} &7.56 &8.324 &8.414 &8.713 &8.756 &8.836 &8.832 &8.621 &8.427 &8.02\\
&{\textsc{Ncut}} &5.384 &5.268 &5.221 &4.855 &5.145 &5.541 &5.909 &5.32 &5.085 &5.246\\
&{\textsc{Kmeans}} &5.427 &5.117 &5.355 &5.326 &5.679 &5.944 &5.452 &5.567 &5.513 &4.686\\
\midrule
\multirow{4}{*}{nmi}
&{\textsc{MCD}} &0.152 &\textbf{0.152} &\textbf{0.149} &\textbf{0.141} &\textbf{0.149} &\textbf{0.156} &\textbf{0.142} &\textbf{0.158} &\textbf{0.147} &0.146\\
&{\textsc{SIclus}} &\textbf{0.172} &0.097 &0.081 &0.06 &0.056 &0.069 &0.078 &0.093 &0.105 &\textbf{0.149}\\
&{\textsc{Ncut}} &0.075 &0.074 &0.111 &0.108 &0.109 &0.099 &0.05 &0.036 &0.042 &0.106\\
&{\textsc{Kmeans}} &0.008 &0.047 &0.048 &0.054 &0.048 &0.028 &0.047 &0.014 &0.067 &0.119\\
\midrule
\multirow{4}{*}{mi}
&{\textsc{MCD}} &0.756 &\textbf{0.611} &\textbf{0.4} &0.258 &\textbf{0.394} &\textbf{0.431} &\textbf{0.381} &\textbf{0.533} &\textbf{0.697} &0.689\\
&{\textsc{SIclus}} &\textbf{0.780} &0.446 &0.367 &\textbf{0.277} &0.258 &0.325 &0.374 &0.44 &0.489 &\textbf{0.698} \\
&{\textsc{Ncut}} &0.188 &0.181 &0.261 &0.232 &0.252 &0.243 &0.138 &0.092 &0.111 &0.31\\
&{\textsc{Kmeans}} &0.02 &0.112 &0.119 &0.135 &0.127 &0.078 &0.119 &0.038 &0.194 &0.314\\
\bottomrule
\end{tabular
}
\end{table*}
\begin{table*}[t]
\caption{Community Detection Results of Foursquare and Twitter Evaluated by $IQC$ Metrics.}
\label{tab:setting4}
\centering
{\scriptsize
\begin{tabular}{lrcccccccccc}
\toprule
\multicolumn{2}{l}{ }&\multicolumn{10}{c}{remaining anchor link rates $\sigma$}\\
\cmidrule{2-12}
measure &methods &0.1 & 0.2 & 0.3 & 0.4 &0.5 &0.6 &0.7 & 0.8 &0.9 &1.0\\
\midrule
\multirow{4}{*}{$IQC^{ndbi}_{rand}$}
&{\textsc{MCD}} &\textbf{-1.699} &\textbf{-1.695} &\textbf{-1.691} &\textbf{-1.662} &\textbf{-1.705} &\textbf{-1.676} &\textbf{-1.647} &\textbf{-1.703} &\textbf{-1.738} &\textbf{-1.594} \\
&{\textsc{SIclus}} &-1.459 &-1.451 &-1.44 &-1.434 &-1.444 &-1.45 &-1.465 &-1.465 &-1.442 &-1.448 \\
&{\textsc{Ncut}} &-0.824 &-0.869 &-0.878 &-0.821 &-0.789 &-0.776 &-0.899 &-0.851 &-0.897 &-0.94 \\
&{\textsc{Kmeans}} &-0.724 &-0.821 &-0.795 &-0.88 &-0.79 &-0.87 &-0.779 &-0.865 &-0.895 &-0.869 \\
\cmidrule{2-12}
\multirow{4}{*}{$IQC^{ent.}_{vi}$}
&{\textsc{MCD}} &\textbf{10.439} &\textbf{12.379} &\textbf{11.975} &\textbf{11.566} &\textbf{11.902} &\textbf{12.45} &\textbf{11.681} &\textbf{11.897} &\textbf{12.028} &\textbf{9.509} \\
&{\textsc{SIclus}} &24.58 &26.107 &26.287 &26.884 &26.971 &27.13 &27.123 &26.7 &26.313 &25.499 \\
&{\textsc{Ncut}} &16.634 &16.403 &16.308 &15.577 &16.156 &16.948 &17.684 &16.506 &16.036 &16.359 \\
&{\textsc{Kmeans}} &16.468 &15.847 &16.325 &16.267 &16.972 &17.503 &16.519 &16.748 &16.641 &14.986 \\
\cmidrule{2-12}
\multirow{4}{*}{$IQC^{dens.}_{nmi}$}
&{\textsc{MCD}} &\textbf{-0.659} &\textbf{-0.606} &\textbf{-0.636} &\textbf{-0.555} &\textbf{-0.686} &\textbf{-0.663} &\textbf{-0.713} &\textbf{-0.664} &\textbf{-0.611} &\textbf{-0.768} \\
&{\textsc{SIclus}} &-0.467 &-0.317 &-0.284 &-0.243 &-0.235 &-0.261 &-0.28 &-0.309 &-0.332 &-0.421 \\
&{\textsc{Ncut}} &-0.411 &-0.409 &-0.484 &-0.477 &-0.478 &-0.458 &-0.361 &-0.333 &-0.345 &-0.473 \\
&{\textsc{Kmeans}} &-0.317 &-0.395 &-0.397 &-0.41 &-0.398 &-0.357 &-0.396 &-0.329 &-0.436 &-0.54 \\
\cmidrule{2-12}
\multirow{4}{*}{$IQC^{sil.}_{mi}$}
&{\textsc{MCD}} &\textbf{-1.239} &\textbf{-0.93} &\textbf{-0.371} &\textbf{-0.186} &\textbf{-0.396} &\textbf{-0.479} &\textbf{-0.479} &\textbf{-0.673} &\textbf{-0.979} &\textbf{-1.048} \\
&{\textsc{SIclus}} &-1.028 &-0.361 &-0.202 &-0.022 &0.016 &-0.118 &-0.216 &-0.347 &-0.446 &-0.863 \\
&{\textsc{Ncut}} &0.389 &0.403 &0.242 &0.3 &0.261 &0.278 &0.488 &0.58 &0.542 &0.144 \\
&{\textsc{Kmeans}} &0.664 &0.479 &0.465 &0.433 &0.45 &0.546 &0.466 &0.628 &0.316 &0.074 \\
\bottomrule
\end{tabular
}
\end{table*}
\subsection{Experiment Settings}
\subsubsection{Comparison Methods}
The comparison methods used in the experiments can be divided into three categories,
\noindent \textbf{Mutual Clustering Methods}
\begin{itemize}
\item {\textsc{MCD}}: {\textsc{MCD}} is the mutual community detection method proposed in this paper, which can detect the communities of multiple aligned networks with consideration of the connections and characteristics of different networks. Heterogeneous information in multiple aligned networks are applied in building {\textsc{MCD}}.
\end{itemize}
\noindent \textbf{Multi-Network Clustering Methods}
\begin{itemize}
\item {\textsc{SIclus}}: the clustering method proposed in \cite{ZL13, ZY15} can calculate the similarity scores among users by propagating heterogeneous information across views/networks. In this paper, we extend the method proposed in \cite{ZL13, ZY15} and propose {\textsc{SIclus}} to calculate the intimacy scores among users in multiple networks simultaneously, based on which, users can be grouped into different clusters with clustering models based on intimacy matrix factorization as introduced in \cite{ZY15}. Heterogeneous information across networks is used to build {\textsc{SIclus}}.
\end{itemize}
\noindent \textbf{Isolated Clustering Methods}, which can detect communities in each isolated network:
\begin{itemize}
\item {\textsc{Ncut}}: {\textsc{Ncut}} is the clustering method based on normalized cut proposed in \cite{SM00}. Method {\textsc{Ncut}} can detect the communities in each social network merely based on the social connections in each network in the experiments.
\item {\textsc{Kmeans}}: {\textsc{Kmeans}} is a traditional clustering method, which can be used to detect communities \cite{QAH12} in social networks based on the social connections only in the experiments.
\end{itemize}
\subsubsection{Evaluation Methods}
The evaluation metrics applied in this paper can be divided into two categories: Quality Metrics and Consensus Metrics.
\noindent \textbf{Quality Metrics}: $4$ widely and commonly used quality metrics are applied to measure the clustering result, e.g., $\mathcal{C} = \{U_i\}_{i=1}^K$, of each network.
\begin{itemize}
\item \textit{normalized-dbi} \cite{ZL13}:
$$ndbi(\mathcal{C}) = \frac{1}{K} \sum_{i} \min_{j \ne i} \\ \frac{d(c_i, c_j) + d(c_j, c_i)}{\sigma_i + \sigma_j + d(c_i, c_j) + d(c_j, c_i)},$$
where $c_i$ is the centroid of community $U_i \in \mathcal{C}$, $d(c_i, c_j)$ denotes the distance between centroids $c_i$ and $c_j$ and $\sigma_i$ represents the average distance between elements in $U_i$ and centroid $c_i$. (Higher ndbi corresponds to better performance).
\item \textit{entropy} \cite{ZL13}:
$$H(\mathcal{C}) = - \sum_{i = 1}^K P(i) \log P(i),$$ where $P(i) = \frac{|U_i|}{\sum_{i = 1}^K |U_i|}$. (Lower entropy corresponds to better performance).
\item \textit{density} \cite{ZL13}:
$$dens(\mathcal{C}) = \sum_{i = 1}^K \frac{|E_i|}{|E|},$$ where $E$ and $E_i$ are the edge sets in the network and $U_i$. (Higher density corresponds to better performance).
\item \textit{silhouette} \cite{LLXGW10}:
$$sil(\mathcal{C}) = \frac{1}{K} \sum_{i = 1}^K (\frac{1}{|U_i|} \sum_{u \in U_i} \frac{b(u) - a(u)}{\max\{a(u), b(u)\}}),$$
where $a(u) = \frac{1}{|U_i| - 1}\sum_{v \in U_i, u \ne v} d(u,v)$ and \\$b(u) = \min_{j, j \ne i}\left( \frac{1}{|U_j|}\sum_{v \in U_j}d(u,v) \right)$. (Higher silhouette corresponds to better performance).
\end{itemize}
\noindent \textbf{Consensus Metrics}: Given the clustering results $\mathcal{C}^{(1)} = \{U^{(1)}_i\}_{i = 1}^{K^{(1)}}$ and $\mathcal{C}^{(2)} = \{U^{(2)}_i\}_{i = 1}^{K^{(2)}}$, the consensus metrics measuring the how similar or dissimilar the anchor users are clustered in $\mathcal{C}^{(1)}$ and $\mathcal{C}^{(2)}$ include:
\begin{itemize}
\item \textit{rand} \cite{NC07}: $rand(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}) = \frac{N_{01} + N_{10}}{N_{00} + N_{01} + N_{10} + N_{11}}$, where $N_{11}$($N_{00}$) is the numbers of pairwise anchor users who are clustered in the same (different) community(ies) in both $\mathcal{C}^{(1)}$ and $\mathcal{C}^{(2)}$, $N_{01}$($N_{10}$) is that of anchor users who are clustered in the same community (different communities) in $\mathcal{C}^{(1)}$ but in different communities (the same communities) in $\mathcal{C}^{(2)}$. (Lower rand corresponds to better performance).
\item \textit{variation of information} \cite{NC07}:
$$vi(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}) = H(\mathcal{C}^{(1)}) + H(\mathcal{C}^{(2)}) - 2mi(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}).$$ (Lower vi corresponds to better performance).
\item \textit{mutual information} \cite{NC07}:
$$mi(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}) = \sum_{i = 1}^{K^{(1)}} \sum_{j = 1}^{K^{(2)}} P(i,j) \log \frac{P(i,j)}{P(i)P(j)},$$ where $P(i,j) = \frac{|U_i^{(1)} \cap_{\mathcal{A}} U^{(2)}_j|}{|\mathcal{A}|}$ and $|U_i^{(1)} \cap_{\mathcal{A}} U^{(2)}_j| = \left| \{u | u \in U_i^{(1)}, \exists v \in U_i^{(2)}, (u, v) \in \mathcal{A}\} \right|$ \cite{KZY13}. (Higher mi corresponds to better performance).
\item \textit{normalized mutual information} \cite{NC07}:
$$nmi(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}) = \frac{mi(\mathcal{C}^{(1)}, \mathcal{C}^{(2)})}{\sqrt{H(\mathcal{C}^{(1)}) H(\mathcal{C}^{(2)})}}.$$ (Higher nmi corresponds to better performance).
\end{itemize}
\noindent \textbf{Definition 9} (Proportional and Inversely Proportional Metrics): Depending on relationship between the metric value and the clustering results, all the above metrics can be either \textit{proportional} or \textit{inversely proportional}. Metric $M$ is proportional iff better clustering results corresponds to higher $M$ value; $M$ is inversely proportional iff better clustering result corresponds lower $M$ value.
In the metrics introduced above, \textit{normalized-dbi}, \textit{density}, \textit{silhouette}, \textit{mutual information} and \textit{normalized mutual information} are \textit{proportional metrics}, \textit{entropy}, \textit{rand}, and \textit{variation of information} are \textit{inversely proportional metrics}.
To consider both the quality and consensus simultaneously, we introduce a new clustering metric, $IQC$ metrics, in this paper, which is \textit{inversely proportional}.
\noindent \textbf{Definition 10} ($IQC$ metrics): $IQC$ is a linear combination of quality metrics $Q$ and consensus metrics $C$.
\begin{align*}
IQC(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}) &= I(Q) (\beta_1 Q(\mathcal{C}^{(1)}) + \beta_2 Q(\mathcal{C}^{(2)}))\\
&+ I(C)(\beta_3 C(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}) + \beta_4 C(\mathcal{C}^{(2)}, \mathcal{C}^{(1)}))
\end{align*}
where $\beta_1, \beta_2, \beta_3, \beta_4$ are weights of different terms, which are all set as $1$ in this paper, and $I(Q), I(C) = -1$, if $Q/C$ is proportional and $1$, otherwise.
\noindent \textbf{IQC Metrics} used in this paper include:
\begin{itemize}
\item $IQC^{ent}_{vi}(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}) = H(\mathcal{C}^{(1)}) + H(\mathcal{C}^{(2)}) + 2 vi(\mathcal{C}^{(1)}, \mathcal{C}^{(2)})$
\item $IQC^{sil}_{mi}(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}) = -sil(\mathcal{C}^{(1)}) - sil(\mathcal{C}^{(2)}) - 2 mi(\mathcal{C}^{(1)}, \mathcal{C}^{(2)})$
\item $IQC^{ndbi}_{rand}(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}) = - ndbi(\mathcal{C}^{(1)}) - ndbi(\mathcal{C}^{(2)}) \\+ 2 rand(\mathcal{C}^{(1)}, \mathcal{C}^{(2)})$
\item $IQC^{dens}_{nmi}(\mathcal{C}^{(1)}, \mathcal{C}^{(2)}) = - dens(\mathcal{C}^{(1)}) - dens(\mathcal{C}^{(2)}) \\- 2 nmi(\mathcal{C}^{(1)}, \mathcal{C}^{(2)})$
\end{itemize}
\begin{figure}[t]
\centering
\subfigure[$\left \| \mathbf{X}^{(1)} \right \|_1$]{\label{eg_fig8_1}
\begin{minipage}[l]{0.45\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./foursquare_iteration_trace.pdf}
\end{minipage}
}
\subfigure[$\left \|\mathbf{X}^{(2)} \right \|_1$]{ \label{eg_fig8_2}
\begin{minipage}[l]{0.45\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./twitter_iteration_trace.pdf}
\end{minipage}
}
\caption{$\left \|\mathbf{X}^{(1)} \right \|_1$ and $\left \|\mathbf{X}^{(2)} \right \|_1$ in each iteration.}\label{eg_fig8}
\end{figure}
\begin{figure}[t]
\centering
\subfigure[$k^{(1)}$-ndbi (Foursquare)]{\label{eg_fig9_1}
\begin{minipage}[l]{0.45\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./foursquare_kt_internal.pdf}
\end{minipage}
}
\subfigure[$k^{(1)}$-ndbi (Twitter)]{ \label{eg_fig9_2}
\begin{minipage}[l]{0.45\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./twitter_kt_internal.pdf}
\end{minipage}
}
\subfigure[$k^{(1)}$-rand]{\label{eg_fig9_3}
\begin{minipage}[l]{0.45\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./kt_external.pdf}
\end{minipage}
}
\subfigure[$k^{(1)}$-$IQC^{ndbi}_{rand}$]{\label{eg_fig9_4}
\begin{minipage}[l]{0.45\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./kt_zyindex.pdf}
\end{minipage}
}
\subfigure[$k^{(2)}$-ndbi (Foursquare)]{\label{eg_fig10_1}
\begin{minipage}[l]{0.45\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./foursquare_ks_internal.pdf}
\end{minipage}
}
\subfigure[$k^{(2)}$-ndbi (Twitter)]{ \label{eg_fig10_2}
\begin{minipage}[l]{0.45\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./twitter_ks_internal.pdf}
\end{minipage}
}
\subfigure[$k^{(2)}$-rand]{ \label{eg_fig10_3}
\begin{minipage}[l]{0.45\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./ks_external.pdf}
\end{minipage}
}
\subfigure[$k^{(2)}$-$IQC^{ndbi}_{rand}$]{\label{eg_fig10_4}
\begin{minipage}[l]{0.45\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./ks_zyindex.pdf}
\end{minipage}
}
\caption{Analysis of parameters $k^{(1)}$ and $k^{(2)}$.}\label{eg_fig9}
\end{figure}
\subsection{Experiment Results}
The experiment results are available in Tables~\ref{tab:setting1}-\ref{tab:setting3}. To show the effects of the anchor links, we use the same networks but randomly sample a proportion of anchor links from the networks, whose number is controlled by $\sigma \in \{0.1, 0.2,\\ \cdots, 1.0\}$, where $\sigma = 0.1$ means that 10\% of all the anchor links are preserved and $\sigma = 1.0$ means that all the anchor links are preserved.
Table~\ref{tab:setting1} displays the clustering results of different methods in Foursquare and Twitter respectively under the evaluation of ndbi, entropy, density and silhouette. As shown in these two tables, {\textsc{MCD}} can achieve the highest ndbi score in both Foursquare and Twitter for different sample rate of anchor links consistently. The entropy of the clustering results achieved by {\textsc{MCD}} is the lowest among all other comparison methods and is about 70\% lower than {\textsc{SIclus}}, 40\% lower than {\textsc{Ncut}} and {\textsc{Kmeans}} in both Foursquare and Twitter. In each community detected by {\textsc{MCD}}, the social connections are denser than that of {\textsc{SIclus}} , {\textsc{Ncut}} and {\textsc{Kmeans}}. Similar results can be obtained under the evaluation of silhouette, the silhouette score achieved by {\textsc{MCD}} is the highest among all comparison methods. So, {\textsc{MCD}} can achieve better results than modified multi-view and isolated clustering methods under the evaluation of \textit{quality metrics}.
Table~\ref{tab:setting3} shows the clustering results on the aligned networks under the evaluation of consensus metrics, which include rand, vi, nmi and mi. As shown in Table~\ref{tab:setting3}, {\textsc{MCD}} can perform the best among all the comparison methods under the evaluation of consensus metrics. For example, the rand score of {\textsc{MCD}} is the lowest among all other methods and when $\sigma = 0.5$, the rand score of {\textsc{MCD}} is 20\% lower than {\textsc{SIclus}}, 72\% lower than {\textsc{Ncut}} and {\textsc{Kmeans}}. Similar results can be obtained for other evaluation metrics, like when $\sigma = 0.5$ , the vi score of {\textsc{MCD}} is about half of the the score of {\textsc{SIclus}}; the nmi and mi score of {\textsc{MCD}} is the triple of that of{\textsc{Kmeans}}. As a result, {\textsc{MCD}} can achieve better performance than both modified multi-view and isolated clustering methods under the evaluation of \textit{consensus metrics}.
Table~\ref{tab:setting4} is the clustering results of different methods evaluated by the $IQC$ metrics. As shown in Table~\ref{tab:setting4}, the $IQC^{ndbi}_{rand}$, $IQC^{ent.}_{vi}$, $IQC^{dens.}_{nmi}$, $IQC^{sil.}_{mi}$ scores of {\textsc{MCD}} are all the lowest among all comparison methods. As mentioned above, lower $IQC$ score corresponds to better clustering results, {\textsc{MCD}} can outperform all other baseline methods consistently under the evaluation of all $IQC$ metrics. In sum, {\textsc{MCD}} can perform better than both modified multi-view and isolated clustering methods evaluated by $IQC$ metrics.
According to the results shown in Tables~\ref{tab:setting1}-\ref{tab:setting4}, we observe that the performance of {\textsc{MCD}} doesn't varies much as $\sigma$ changes. The possible reason can be that, in method {\textsc{MCD}}, normalized clustering discrepancy is applied to infer the clustering confidence matrices. As $\sigma$ increases in the experiments, more anchor links are added between networks, part of whose effects will be neutralized by the normalization of clustering discrepancy and doesn't affect the performance of {\textsc{MCD}} much.
\subsection{Convergence Analysis}
{\textsc{MCD}} can compute the solution of the optimization function with Curvilinear Search method, which can update matrices $\mathbf{X}^{(1)}$ and $\mathbf{X}^{(2)}$ alternatively. This process will continue until convergence. To check whether this process can stop or not, in this part, we will analyze the convergence of $\mathbf{X}^{(1)}$ and $\mathbf{X}^{(2)}$. In Figure~\ref{eg_fig8}, we show the $L^1$ norm of matrices $\mathbf{X}^{(1)}$ and $\mathbf{X}^{(2)}$, $\left\| \mathbf{X}^{(1)} \right\|_1$ and $\left\| \mathbf{X}^{(2)} \right\|_1$, in each iteration of the updating algorithm, where the $L^p$ norm of matrix $\mathbf{X}$ is $\left\| \mathbf{X} \right\|_p = (\sum_i \sum_i {X_{ij}}^p)^{\frac{1}{p}}$. As shown in Figures~\ref{eg_fig8}, both $\left\| \mathbf{X}^{(1)} \right\|_1$ and $\left\| \mathbf{X}^{(2)} \right\|_1$ can converge in less than $200$ iterations.
\begin{figure*}[t]
\centering
\subfigure[$\theta$-ndbi (Foursquare)]{\label{eg_fig11_1}
\begin{minipage}[l]{0.45\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{eg_fig_foursquare_theta_internal.pdf}
\end{minipage}
}
\subfigure[$\theta$-ndbi (Twitter)]{ \label{eg_fig11_2}
\begin{minipage}[l]{0.45\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{eg_fig_twitter_theta_internal.pdf}
\end{minipage}
}
\subfigure[$\theta$-rand]{\label{eg_fig11_3}
\begin{minipage}[l]{0.45\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{eg_fig_theta_external.pdf}
\end{minipage}
}
\subfigure[$IQC^{ndbi}_{rand}$ metric]{\label{eg_fig11_4}
\begin{minipage}[l]{0.45\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./theta_zyindex.pdf}
\end{minipage}
}
\caption{Analysis of parameter $\theta$.}\label{eg_fig11}
\end{figure*}
\subsection{Parameter Analysis}
In method {\textsc{MCD}}, we have three parameters: $k^{(1)}$, $k^{(2)}$ and $\theta$, where $k^{(1)}$ and $k^{(2)}$ are the numbers of clusters in Foursquare and Twitter networks respectively, while $\theta$ is the weight of the normalized discrepancy term in the object function. In the pervious experiment, we set $k^{(1)} = 50$, $k^{(2)} = 50$ and $\theta = 1.0$. Here we will analyze the sensitivity of these parameters in details.
To analyze $k^{(1)}$, we fix $k^{(2)} = 50$ and $\theta = 1.0$ but assign $k^{(1)}$ with values in $\{10, 20, 30, 40, 50, 60, 70, 80, 90, 100\}$. The clustering results of {\textsc{MCD}} with different $k^{(1)}$ evaluated by $ndbi$, $rand$ and $IQC^{ndbi}_{rand}$ metrics are given in Figures~\ref{eg_fig9_1}-\ref{eg_fig9_4}. As shown in the figures, the results achieved by {\textsc{MCD}} are very stable for $k^{(1)}$ with in range $[40, 100]$ under the evaluation of $ndbi$ in both Foursquare and Twitter. Similar results can be obtained in Figures~\ref{eg_fig9_3}-\ref{eg_fig9_4}, where the performance of {\textsc{MCD}} on aligned networks is not sensitive to the choice of $k^{(1)}$ for $k^{(1)}$ in range $[40, 100]$ under the evaluation of both $rand$ and $IQC_{ndbi, rand}$. In a similar way, we can study the sensitivity of parameter $k^{(2)}$, the results about which are shown in Figures~\ref{eg_fig10_1}-\ref{eg_fig10_4}.
An interesting phenomenon is that the pre-defined number of clusters in the Foursquare network can also affect {\textsc{MCD}}'s performance in the Twitter network. As shown in Figure~\ref{eg_fig9_2}, the performance of {\textsc{MCD}} is the best in the Twitter network when $k^{(1)}$ is assigned with $30$, as the $ndbi$ score of {\textsc{MCD}} is the highest when $k^{(1)} = 30$. Figures~\ref{eg_fig9_3}-~\ref{eg_fig9_4} show the performance of {\textsc{MCD}} under the evaluation of $rand$ and $IQC_{ndbi, rand}$. {\textsc{MCD}} performs the best when $k^{(1)} = 40$ under the evaluation of the $rand$ metric and achieves the best performance when $k^{(1)} = 40$(or 90) evaluated by $IQC_{ndbi, rand}$.
To analyze the parameter $\theta$, we set both $k^{(1)}$ and $k^{(2)}$ as $50$ but assign $\theta$ with values in \{0.001, 0.01, 0.1, 1.0, 10.0, 100.0, 1000.0\}. The results are shown in Figure~\ref{eg_fig11}, where when $\theta$ is small, e.g., $0.001$, the $ndbi$ scores achieved by {\textsc{MCD}} in both Foursquare and Twitter are high but the $rand$ score is not good ($rand$ is inversely proportional). On the other hand, large $\theta$ can lead to good $rand$ score but bad $ndbi$ scores in both Foursquare and Twitter. As a result, (1) large $\theta$ prefers consensus results, (2) small $\theta$ can preserve network characteristics and prefers high quality results. Meanwhile, considering the clustering quality and consensus simultaneously, {\textsc{MCD}} can achieve the best performance when $\theta = 1$, as the $IQC^{ndbi}_{rand}$ is the lowest when $\theta = 1$ in Figure~\ref{eg_fig11_4}.
\section{Related Work} \label{sec:relatedwork}
Clustering is a very broad research area, which include various types of clustering problems, e.g., consensus clustering \cite{LBRFFP13, LD13}, multi-view clustering \cite{BS04, CNH13}, multi-relational clustering \cite{YHY07}, co-training based clustering \cite{KD11}, and dozens of papers have been published on these topics. Lourenco et al. \cite{LBRFFP13} propose a probabilistic consensus clustering method by using evidence accumulation. Lock et al. propose a bayesian consensus clustering method in \cite{LD13}. Meanwhile, Bickel et al. \cite{BS04} propose to study the multi-view clustering problem, where the attributes of objects are split into two independent subsets. Cai et al. \cite{CNH13} propose to apply multi-view K-Means clustering methods to big data. Yin et al. \cite{YHY07} propose a user-guided multi-relational clustering method, CrossClus, to performs multi-relational clustering under user's guidance. Kumar et al. propose to address the multi-view clustering problem based on a co-training setting in \cite{KD11}.
A multi-view clustering paper which is correlated to the problem studied in this paper is \cite{CZGW13}, which relaxes the \textit{one-to-one} constraint in traditional multi-view clustering problems to uncertain mappings. Weights of such mappings need to be decided by prior domain knowledge and each view is actually a homogeneous network. To regularize the clustering results, a cost function called \textit{clustering disagreement} is introduced in \cite{CZGW13}, whose absolute value of all nodes in multiple views is involved in the optimization. Different from \cite{CZGW13}: (1) the constraint on anchor links in this paper is \textit{one-to-one} and no domain knowledge is required, (2) each network involves different users and contains heterogeneous information, (3) we apply clustering discrepancy to constrain the community structures of anchor users only and non-anchor users are pruned before calculating discrepancy cost, and (4) the clustering discrepancy is normalized before being applied in mutual clustering objective function.
Clustering based community detection in online social networks is a hot research topic and many different techniques have been proposed to optimize certain measures of the results, e.g., modularity function \cite{NG04}, and normalized cut \cite{SM00}. Malliaros et al. give a comprehensive survey of correlated techniques used to detect communities in networks in \cite{MV13} and a detailed tutorial on spectral clustering has been given by Luxburg in \cite{L07}. These works are mostly studied based on homogeneous social networks. However, in the real-world online social networks, abundant heterogeneous information generated by users' online social activities exist in online social networks. Sun et al. \cite{SYH09} studies ranking-based clustering on heterogeneous networks, while Ji et al. \cite{JHD11} studies ranking-based classification problems on heterogeneous networks. Coscia et al. \cite{CGP11} proposes a classification based method for community detection in complex networks and Mucha et al. study the community structures in multiplex networks in \cite{MRMPO10}.
In recent years, researchers' attention has started to shift to study multiple heterogeneous social networks simultaneously. Kong et al. \cite{KZY13} are the first to propose the concepts of \textit{aligned networks} and \textit{anchor links}. Across aligned social networks, different social network application problems have been studied, which include different cross-network link prediction/transfer \cite{ZKY13, ZKY14, ZYZ14, ZY15_2}, emerging network clustering \cite{ZY15} and large-scale network community detection \cite{JZYYL14}, inter-network information diffusion and influence maximization \cite{ZZWYX15}.
\section{Conclusion}\label{sec:conclusion}
In this paper, we have studied the \textit{mutual clustering} problem across multiple partially aligned heterogeneous online social networks. A novel clustering method, {\textsc{MCD}}, has been proposed to solve the \textit{mutual clustering} problem. We have proposed a new similarity measure, HNMP-Sim, based on social meta paths in the networks. {\textsc{MCD}} can achieve very good clustering results in all aligned networks simultaneously with full considerations of network difference problem as well as the connections across networks. Extensive experiments conducted on two real-world partially aligned heterogeneous networks demonstrate that {\textsc{MCD}} can perform very well in solving the \textit{mutual clustering} problem.
\label{sec:appendix}
\section{Acknowledgement}
This work is supported in part by NSF through grants CNS-1115234 and OISE-1129076, Google Research Award, and the Pinnacle Lab at Singapore Management University.
|
{'timestamp': '2015-06-19T02:06:50', 'yymm': '1506', 'arxiv_id': '1506.05529', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05529'}
|
arxiv
|
\section{Introduction}
Interaction can be defined as the ensemble of reciprocal actions and responses of individuals and groups acting upon each other. It concerns verbal and nonverbal communication, implying conscious and nonconscious, enduring and casual processes. It can be considered globally as an a continually emerging process \cite{simpson1986interaction}.
This is nowadays a growing topic of interest in the fields of Computer-Human Interaction and Social Signal Processing, where the dynamics of interaction are used to perform more seamless and believable interaction between human and artificial agents.
In this PhD project, our goal is to develop an interaction model using group dynamics. It should be able to take into account the different modalities of interaction, especially the non-verbal communication. In particular, we aim at designing a model that can enable the emergence of synchronization in the interaction.
We expect that synchronization processes, which are a form of temporal adaptation, could make interaction dynamical in its various temporal dimensions (e.g. a conversation turn, an entire dialogue, repeated interaction, etc.). This model will then be applied to two use cases: Creative Musical Agents and Embodied Conversational Agents.
In the following section, we will try to describe the basic concepts of our interaction model. We will then present our research questions and directions.
\section{Background}
\paragraph{Synchrony and adaptation}
Modeling interaction must ideally take into account dynamic aspects and should thus be adapt to the evolution of the system. For this reason, we chose to study adaptation and one form of temporal adaptation: synchrony.
Adaptation in interaction is the way the system will evolve to match the stimuli given by the interaction context \cite{dooley1996complex}. This adaptation can be performed at various level of abstraction and timescales.
Delaherche et al. \cite{delaherche2012interpersonal} propose a definition of synchrony. They describe synchrony as a dynamical and reciprocal adaptation of the temporal structure of behaviors between interactive partners. It should be at the same time dynamical, because its main features are temporality and not actions themselves, multi-modal \cite{grammer1998courtship}, as opposite to simple imitation or the chameleon effect \cite{chartrand1999chameleon} that involve only one dimension, and happening in every interaction context, may it be cooperative or competitive. In adults, synchrony have two main roles. First, non-verbal synchrony would ease the construction of individual social connections \cite{lafrance1982posture}. Synchrony could also enhance cooperation between individuals, especially by augmenting group cohesion \cite{wiltermuth2009synchrony}.
\paragraph{Nonverbal behavior and Turn-Taking}
Nonverbal behavior can be described "as all actions distinct from speech" \cite{mehrabian1977nonverbal}, although it takes into account paralinguistic aspects of speech like prosody. Nonverbal behavior during communication can take various forms and expression supports (called modalities), such as gaze \cite{kendon1967some} or paralinguistic signals \cite{goodwin1981conversational,allwood1976linguistic}. According to Knapp et al., all human beings are natural "experts" in multimodal communication \cite{knapp2012nonverbal}, i.e. they are able to emit and receive simultaneously signals on different modalities knowingly or unknowingly. According to Argyle \cite{argyle2013bodily}, non-verbal communication fill four main functions: Express emotions, send interpersonal attitudes, present oneself's personality and accompany parole. This last notion is essential in turn-taking mechanisms. A turn in conversation can be defined as the moment between the taking of the floor to the withdrawal of the floor, that can be either consensual or forced \cite{goodwin1981conversational}. Overlapping turns can indicate a conflict between speakers but can also mean a high level of synchrony between interactants as they are able to decipher the cues of abandoning of the turn \cite{allwood1995activity}. Turn-Taking mechanisms are the way human regulates their conversational interactions and is perceivable through signals emitted by both the speakers and their interlocutors. Duncan identifies threes types of these signals in conversation \cite{duncan1972some}: turn-passing signals, signals to keep or try to take the turn from another speaker and backchannels that indicate multiple attentions, from the simple acknowledging of one's last utterance to the expression of the mental state of the emitter \cite{allwood1976linguistic}. These signals are essential to conversation and warrant its fluidity \cite{ten2005temporal}.
\section{Research Questions}
We intend to model synchrony emergence in Turn-Taking behavior in a group of agents whether they are taking part into a cooperative or competitive interaction. Our model describes an individual and the way it perceives other agents. Each agent is able to generate a meaningful output (that from this point we will define as conversation for clarity's sake ) and non-verbal cues through body animation and para-linguistic features. The agent model is based on a Turn-Taking system by Ravenet et al. (in press), that we modified. The model in itself can be shown in Fig. \ref{fig:TTModel}.
\begin{figure}
\centering
\includegraphics[width=0.2\textwidth]{Turn_Taking_Model_Kevin_Data_v4.png}
\caption{\label{fig:TTModel}A general view of our turn-taking model.}
\end{figure}
The Turn-Taking system can be modeled as a Finite State Machine \(A = \{S,\Sigma,s_{0},\delta,F\} \) where:
\begin{itemize}
\item \(S = \{\scriptstyle Unaddressed, Addressed, WantToSpeak, Speaking, InterruptionOfSpeech,EndOfSpeech \displaystyle \} \) the conversational states of the agent
\item \(\Sigma \) the transition matrix
\item \(s_{0} = Unaddressed\) the initial state
\item \(\delta: \Sigma \times S \to S \) the transition function
\item \(F = \{\emptyset\}\) the (empty) final states of the FSM
\end{itemize}
In this Turn-Taking system, states S describe the current mindset of the agents regarding the conversation, which could be unaddressed, addressed, wanting the turn, speaking, being interrupted and ending the speech and giving the floor to the other participants.
Each agent does not know the exact state of conversation in which the other agents are but are able to infer it through the non-verbal cues, backchannels and speech it perceive ; for instance, in a simple dyadic use case, an agent will know it is addressed by another agent if it perceives that the other agent is speaking, that it is oriented towards the one agent and that the one agent displays cues of attention. Transitions between these states are guided by interpersonal attitude \cite{argyle2013bodily}, modeled through two dimensions: liking and dominance. Liking can be defined as “a general and enduring positive or negative feeling about some person, object or issue ” \cite{moshkina2003tameing} and dominance as “the capacity of one agent to affect the behavior of another ” \cite{prada2008social}. Interpersonal attitude is private to an agent an directed towards another agent. An example of state transition could be
\[\delta( \scriptstyle \{ Mean_{S,D}, Mean_{S,L},Count_{S} \}\displaystyle,\scriptstyle WantToSpeak \displaystyle ) = \left\{ \begin{array}{l l l} Speaking & \quad \text{if $Mean_{S,D} + | Mean_{S,L}| \geq 0$} \\ Speaking & \quad \text{if $Count_{S} = 0$} \\ WantToSpeak & \quad \text{otherwise} \end{array} \right.\]
where:
\begin{itemize}
\item \(Mean_{S,D}\) is the mean of dominance values felt by the agent towards other agents speaking at this moment
\item \(Mean_{S,L}\) is the mean of liking values felt by the agent towards other agents speaking at this moment
\item \(Count_{S}\) is the number of other agents that are speaking at this moment
\end{itemize}
The dominance and the liking felt by an agent towards an agent can evolve through time. For instance, an agent interrupting another agent will feel its dominance value increase towards this agent, whereas the other agent can see its liking value decrease towards the agent that interrupted him, and since we use liking to determine the drive from an agent to speak to another, a decrease in liking will mean that the other agent will be less inclined to speak with the one who interrupted it. These values determining the Turn-Taking behavior of the system, we expect these values to converge to a defined close range, adapting to the change in the system but keeping it in a stable state and therefore making the Turn-Taking behavior synchronize. We intend to verify the existence of this synchrony in our system through the usage of automated method such as phase synchronization \cite{quiroga2002performance} or mutual information \cite{kraskov2004estimating}, and also through subjective evaluation by naive users to verify that the synchronous behavior observed in the agents are still similar to the behaviors taking place in human-human interaction. Since the agent have states that are inferred through observation, we intend to use Hidden Markov Models to describe our FSM.
\paragraph{Use cases: Existing Architectures}
The choice to pick musical improvisation as a use case was motivated by the nature of this phenomenon herself: according to Borgo et al., improvisation can be viewed as the "synchronization of our intentions and our actions, and also the upholding of a connection, a sensibility with group dynamics and evolutive experiences" \cite{borgo2004sync}.The OMax System \cite{levy2012omaxist} (See Fig \ref{fig:GRETAOMAX}, right) is an automatic improvisation mechanism that rely on the notion of stylistic reinjection \cite{assayag2006improvisation}, i.e. a system that extract characteristic elements of a musical sequence to devise a model which describe the style of the played sequence. After the listening of a musical sequence by a human instrumentalist, it can replay a similar sequence presenting stylistically close variations of what have been already played thanks to Factor Oracle \cite{allauzen1999factor}. Musical interaction between the musician and OMax is divided in two phases. In the listening phase, OMaX will perceive the musical sequence which will be decomposed note by note and stocked in the memory of the system where transitions between non-consecutive but similar states will be created thanks to the particular structure of the Factor Oracle. In the playing phase, a human operator select the sequences and sub-sequences of the memory for the system to play. If the operator select transitions between non-consecutive states, he/she introduces variety in the sequence though respecting the style of the sequences played by the human musician.
\begin{figure}
\centering
\includegraphics[width=0.3\textwidth]{Model_GRETA_OMAX_v4_EN.png}
\caption{\label{fig:GRETAOMAX}A general view of the OMAX and GRETA architectures.}
\end{figure}
The GRETA-VIB \cite{niewiadomski2011cross} (See Fig \ref{fig:GRETAOMAX}, left) system is a virtual embodied character that uses a modular architecture independent of the agent’s embodiment . This architecture follows the SAIBA framework that specifies three modules: the intent planner, the behavior planner and the behavior realizer. The modularity is at the center of the GRETA-VIB architecture. In addition to the three modules implementing the SAIBA framework, each designer can provide the program with independent module attached to these “backbone” modules and that could specify the characteristic of the ECA, notably its behavior, independently from the way it is embodied. One of these modules implements a Turn-Taking mechanism. The Turn-Taking system is done through a Finite State Machine (FSM) that specify the current state of the agent and the different transition between states regarding whether the agent is addressed or no and the interpersonal social attitude (modeled through the dominance and liking dimensions). Each agent has by now the knowledge of the state of all the other agent, but do not know either the interpersonal attitude towards him or the other agents or the internal variables such as the number of people addressing the agent.
\section{Current and Future work}
We first established a literature basis to ground our idea of a synchronous interaction model and to apply it to our use cases.
We are now looking to implement a first simple prototype using Hidden Markov Models or their extension called Influence Models \cite{dong2007using}. To guide the emergence of synchrony, we are now looking for metrics related to its expression and how to evaluate its occurrence, and will be very interested in every input the community can provide us on these questions.
\section{Acknowledgments}
This work was performed within the Labex SMART (ANR-11-LABX-65) supported by French state funds managed by the ANR within the Investissements d'Avenir programme under reference ANR-11-IDEX-0004-02 and the DYCI2 Project under reference ANR-14-CE24-0002-01.
\bibliographystyle{splncs03}
|
{'timestamp': '2015-06-19T02:09:07', 'yymm': '1506', 'arxiv_id': '1506.05573', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05573'}
|
arxiv
|
\section{Introduction}
\label{sect:intro}
{\em Online data-intensive (OLDI) services}, such as search
engines, product recommendation, sentiment analysis and Deep
QA power many popular websites and enterprise products.
Like traditional Internet services, OLDI services must
answer queries quickly. For example, Microsoft Bing's
revenue would decrease by \$316M if it
answered search queries 500ms slower~\cite{forrest-2009}.
Similarly, IBM Watson would have lost to elite Jeopardy
contestants if it waited too long to answer~\cite{lenchner-2011,ferrucci-aaai-2010}.
However, OLDI and traditional services differ during query
execution. Traditional services use structured databases to
retrieve answers, but OLDI services use loosely structured
or unstructured data. Extracting answers from loosely
structured data can be complicated. Consider the
OpenEphyra question answering
system~\cite{openephyra-webpage}. Each query execution
reduces text documents to a few phrases by finding noun-verb
answer templates within sentences.
OLDI services use large and growing data to improve the
quality of their answers, but large data also increases
processing demands. To keep response time low, OLDI query
executions are parallelized across distributed software
components. At Microsoft Bing, query execution invokes
over 100--1000 components in parallel~\cite{jalaparti-sigcomm-2013}.
Each component contributes intermediate data that could improve
answers. However, some query executions suffer from slow
running components that take too long to complete.
Since fast response time is essential,
OLDI query executions cannot wait for slow components.
Instead, they compute answers with whatever data is
available within response time constraints.
OLDI services answer queries quickly even though performance
anomalies, failed hardware and skewed partitioning schemes
slow down some parallel components. However, eliding data
from slow components could degrade answer
quality~\cite{ren-icac-2013,falsett2004limitation}.
{In this paper, answer quality is the similarity between answers
produced with and without data from slow components.
}
Queries achieve high answer quality when their
execution does not suffer from slow components or when
slow components do not affect answers. Low answer quality
means that slow, elided components have important
contributions that would affect final answers significantly.
Prior work has shown the virtue of adaptive resource
management with regard to response time.
Adaptive management could also help OLDI services manage
answer quality. For example, adaptive admission control
could stabilize answer quality in the face of time-varying
arrival rates.
Answer quality is hard to measure online because it requires
2 query executions.
\MYfigureref{fig:draw-contributions} depicts the process of
computing answer quality.
First, an online execution provides answers within response
time constraints by eliding data from slow components.
Second, a {\em mature execution} provides mature answers
by waiting for all components before producing answers.
Finally, a service-specific similarity function computes
answer quality. This paper uses true positive rate as the
similarity function, but other functions are permissible,
e.g., normalized discounted cumulative gain~\cite{manning-2008}.
{\em We present Ubora\footnote{Ubora means {\it quality} in
Swahili.}, an approach to speed up mature executions. }
Our key insight is that mature and online executions invoke
many components with the same parameters. Memoization can
speed up mature executions, i.e., a mature execution can
complete faster by reusing data from its
corresponding online execution instead of re-invoking
components.
\begin{figure}[t]
\centering
\includegraphics[width=3.0in]{draw-contributions.pdf}
\caption{\small Steps to measure answer quality
online. Mature and online executions may overlap. }
\label{fig:draw-contributions}
\vspace{-0.1in}
\end{figure}
When a query arrives, Ubora conducts a normal online query
execution except it records intermediate data provided by
each component, including data from slow components that
were elided from online answers. After the slow
components finish, Ubora computes {\em mature answers} using
data recorded during and after the online execution.
Implementing memoization for multi-component OLDI
services presents systems challenges.
First, OLDI components span multiple platforms. It is
challenging to coordinate mature and online executions
across components without changing application-level source code.
Ubora manages mature and online operating context. During
mature executions, it uses network redirection to replay
intermediate data stored in a shared key-value store.
Second, memoization speeds up computationally intensive
components but its increased bandwidth usage can also cause
slowdown for some components. Ubora provides flexible
settings for memoization, allowing each component to turn
off memoization. We use offline profiling to
determine which components benefit from memoization.
We have evaluated Ubora~ on Apache Lucene with
Wikipedia data, OpenEphyra with New York Times data, EasyRec
recommendation engine with Netflix data and Hadoop/Yarn with
BigBench data. To be sure, Ubora's systems-level
implementation is able to support these applications without
modification to their source code. We compared Ubora to a
competing approach that eschews transparency for
efficiency. Specifically, this competing approach changes
application source code to tag query executions with custom
online and mature timeout settings. A query executes until
its online timeouts trigger, it returns an answer and then
resumes for mature execution.
Ubora completes mature executions nearly as quickly as this
approach with slowdown ranging from 8--16\%.
We also compared Ubora to an alternative approach that does
not require changing application source code.
In this approach, each component's local timeout settings
are extended for a short period of time.
Ubora finishes mature executions 7X faster.
Finally, Ubora slows down normal, online
query executions by less than 7\%.
We also used Ubora to guide adaptive admission control.
We adaptively shed low priority queries to our Apache Lucene
and EasyRec systems. The goal was to maintain high answer
quality for high priority queries. Ubora provided answer
quality measurements quickly enough to detect shifts in the
arrival rate and query mix. Specifically, Ubora responded
quickly to changing arrival rates, keeping answer quality
above 90\% during most of the trace. The other transparent
approach to measure answer quality, i.e., toggling timeouts,
produced mature executions too slowly. This
approach allowed answer quality to fall below 90\% 12X much more
often than Ubora. We also used component
timeouts as a proxy for answer
quality~\cite{jalaparti-sigcomm-2013}. This metric is
available after online executions without conducting
additional mature executions. As a result, it has much lower
overhead. However, component timeouts are a conservative
approximation of answer quality because they do not assess
the effect of timeouts on answers. While achieving the same
answer quality on high priority queries, Ubora-driven
admission control processed 37\% more low priority queries
than admission control powered by component timeouts.
This paper is organized as follows. We describe the
structure of OLDI services in
\MYsectionref{sect:workflows}. We present Ubora in
\MYsectionref{sect:design}. \MYsectionref{sect:ubora}
presents our implementation of query context tracking and
profiling for memoization. In {\MYsectionref{sect:setup}},
we measure Ubora's performance using a wide range of OLDI
benchmarks.
In \MYsectionref{sect:onlinemanagement}, we show that
Ubora computes answer quality quickly enough to guide online
load shedding.
\section{Background on OLDI Services}
\label{sect:workflows}
Query executions differ fundamentally between online
data-intensive (OLDI) and traditional Internet services.
In traditional services, query executions process data
retrieved from well structured databases, often via SQL.
Correct query executions produce answers with well defined
structure, i.e., answers are provably right or wrong.
In contrast, OLDI queries execute on unstructured data.
They produce answers by discovering correlations within
data. OLDI services produce good answers if they process data
relevant to query parameters.
Large datasets improve the quality of OLDI answers.
For example, IBM Watson parsed 4TB of mostly public-domain
data~\cite{ferrucci-aaai-2010}. One of Watson's data
sources, Wikipedia, grew 116X from 2004--2011~\cite{wikigrowth}.
However, it is challenging to analyze a large dataset within
strict response time limits. This section provides
background on the software structure of OLDI services that
enables the following:
\begin{MYenumwide}
\item Parallelized query executions for high throughput,
\item Returning online answers based on partial, best-effort
data to prevent slow software components from delaying response time.
\end{MYenumwide}
\begin{figure}[t]
\centering
\includegraphics[scale=0.21]{single_query_workflow7b.pdf}
\caption{\small Execution of a single query in Apache Lucene.
Adjacent paths reflect parallel execution across data partitions.}
\label{fig:draw-solrworkflow}
\end{figure}
{\noindent \bf Parallelized Query Execution:}
\MYfigureref{fig:draw-solrworkflow} depicts a query execution
in an Apache Lucene system, a widely used open-source
information retrieval library~\cite{lucid-2008}.
Query execution invokes 25 software components.
Components in adjacent columns can execute in parallel.
A front-end node manages network connections with
clients, sorts results from nodes running Distributed Search logic and produces
final answers. Distributed Search parses the query, requests a wide
range of relevant data from storage nodes, and collects data returned within a given
timeout. Data is retrieved from either 1) an in-memory Redis cluster that caches a subset of index
entries and documents for a Lucene Index Server or 2) the Lucene Index Server
itself, which stores the entire index and data on relatively
slow disks.
The Lucene system in \MYfigureref{fig:draw-solrworkflow}
indexes 23.4 million Wikipedia and NY Times documents (pages
+ revisions) produced between 2001 and 2013.
It parallelizes query execution via data parallelism, i.e.,
the Lucene Index Servers partition the index across
multiple nodes. Each parallel sub-execution (i.e., a
vertical column) computes intermediate data based on its
underlying partition. Intermediate data is combined to
produce a query response.
OLDI services also parallelize query executions via partial
redundancy. In this approach, sub-executions compute
intermediate data from overlapping data partitions. The
query execution weights answers based on the degree of
overlap and aggregate data processing per partition.
Consider a product recommendation service. Its query
execution may spawn two parallel sub-executions. The first
finds relevant products from orders completed in the last
hour. The second considers the last 3 days. The service
prefers the product recommended by the larger (3-day)
sub-execution. However, if the preferred recommendation is
unavailable or otherwise degraded, the results from the smaller parallel
sub-execution help.
\begin{figure}[t]
\centering
\includegraphics[width=2.0in]{XcomponentYcompletiontime2.pdf}
\caption{\small OLDI components exhibit
diverse processing times. }
\label{fig:xcomponents-yrunningtimes}
\end{figure}
{\noindent \bf Online Answers Are Best Effort:}
In traditional Internet services, query execution invokes
software components sequentially. Their response time depends on
aggregate processing times of all components. In contrast,
online data-intensive query executions invoke components in
parallel. The processing time of the slowest components
determines response time.
\MYfigureref{fig:xcomponents-yrunningtimes} quantifies
component processing times in our Apache Lucene system.
The query workload from Google Trends and hardware
details are provided in \MYsectionref{sect:setup}.
Processing times vary significantly from query
to query. Note, the X-axis is shown in log scale.
Lucene Index servers can take several seconds on some
queries even though their typical processing times are much
faster. Further, processing time is not uniform across shards.
For example, a query for ``William Shakespeare'' transferred
138KB from the shard 4 execution path but only 1KB from the shard 1
execution path.
Shard 4 hosted more content related to this query even
though the data was partitioned randomly.
Many OLDI services prevent slow components from delaying response
time by returning answers prematurely---before slow
components finish. Specifically, query executions trigger
timeouts on slow components and produce answers that exclude
some intermediate data. Timeouts effectively control
response time. In our Apache system, we set a 2 second and a
4 second timeout in our front-end component. Average
response time fell. Also, third quartile response times
were consistently close to median times, showing that
timeouts also reduced variance.
Unfortunately, query executions that trigger timeouts
use less data to compute answers. This degrades answer
quality. For data-parallel queries answer quality degrades
if the elided data is relevant to query parameters.
\begin{figure}[t]
\centering
\includegraphics[width=3.1in]{draw-rcr.pdf}
\caption{\small Memoization in Ubora. Arrows reflect messages
in execution order (left to right). }
\label{fig:draw-rcr}
\end{figure}
\section{Design}
\label{sect:design}
Ubora measures the answer quality of online query
executions. By design, it directly computes answer quality
by comparing answers produced with and without timeouts.
It uses existing online resources and employs memoization to
speed up query executions.
\MYfigureref{fig:draw-rcr} depicts memoization in Ubora.
During online query execution, Ubora records inter-component
communication. It allows only front-end components to time
out. Components invoked by parallel sub-executions complete
in the background.
As shown on the left side of \MYfigureref{fig:draw-rcr},
without Ubora, the front-end component invokes a component
with query $q$, receives message $r_0$ and then times out.
The front-end component then triggers a timeout for the
invoked component, stopping its execution prematurely.
Ubora blocks the trigger from the front-end component,
allowing the invoked component to complete a mature execution.
It records output messages before and {\em after} the
front-end times out, in this case $r_0 + r_1$. These
messages are cached in fast, in-memory stores.
With Ubora, front-end components still answer online queries
within strict response time limits. As shown in
\MYfigureref{fig:draw-rcr}, the front-end component
uses $r_0$ to produce an {\em online answer}. After all
sub-executions for a query complete, Ubora
re-executes the front-end, as if a new query arrived.
However, during this re-execution, Ubora intercepts messages
to other components and serves from cache (i.e., memoization).
The cache delivers messages with minimal processing or disk delays.
During this mature execution, the front-end uses both $r_0 + r_1$ to
produce a {\em mature answer}.
\section{Implementation}
\label{sect:ubora}
This section discusses the implementation of Ubora.
First, we describe axiomatic choices, e.g., the user
interface, target users and prerequisite infrastructure.
Second, we discuss the impact of
operating system support on the implementation of memoization.
Finally, we provide details about our implementation, including our approach to
determine which components constitute a front-end.
\subsection{Interface and Users}
Ubora targets system managers. It runs on a cluster of compute nodes.
Each node runs a networked operating system. Many software components can map
to each node, but each component runs on just 1 node. To be
clear, a software component is a running binary that accepts
invocations over the network. Software components have unique network
addresses, e.g., IP address and TCP port.
System managers understand the query execution paths in their system (e.g.,
as depicted in~\MYfigureref{fig:draw-solrworkflow}). They classify each
component as front- or back-end. Front components receive
queries, record inter-component messages and produce online
and mature answers. They are re-executed to get mature
answers. Back-end components propagate query context,
record messages, and do not time out for sampled queries.
\MYfigureref{fig:draw-solrworkflow} labels the front-end
component. The search tier, Redis and/or Lucene could be
front-end or back-end components.
Ubora is started from the command line. Two shell scripts, {\em
startOnBack and startOnFront}, are run from a front component.
Managers can configure a number of parameters before starting Ubora, shown
in Listing~\ref{listing:config}.
The number of mature executions to produce per unit time controls the query
sampling rate. When new queries arrive at front end TCP ports, a query sampler
randomly decides how to execute the query. Sampled queries
are executed under the {\em record mode} context shown on
the left side of \MYfigureref{fig:draw-rcr}. Queries not
sampled are executed normally without intervention from Ubora.
Record timeout duration sets the upper bound on processing time for
a back-end component's mature execution. Propagate timeout
is used to set the upper bound on time to scan for newly
contacted components to propagate the execution context.
To get mature answers the query execution context is called
{\em replay mode}.
Finally, the callback function used to
compute answer quality is service specific. The default is True Positive Rate.
\subsection{Impact of Operating System Support}
A key goal was to make Ubora~ as transparent as possible.
Here, transparent means that 1) it should work with existing middleware and
operating systems without changing them and 2) it should have small effects on
response times for online queries.
Transparency is hard to achieve, because Ubora~ must manage record and
replay modes without changing the interaction between software components.
In other words, the execution context of a query must pass between components unobtrusively.
Some operating systems already support execution contexts. Therefore, we present
two designs. The first design targets these operating systems. The second design targets commodity operating
systems. Our designs exploit the following features of memoization:
\begin{MYenumwide}
\item {\em Queries produce valid output under record, replay, and normal modes.}
This property is achieved by maintaining a shadow connection to the invoked
component during replay. Cache misses trigger direct communication with
invoked components. As a result,
replay, normal, and record modes have access to full data.
\item {\em Back-end components use \MYnote{a lot} more resources during record mode than they
use during normal online execution because timeouts are disabled.}
\end{MYenumwide}
\lstset{basicstyle=\small\selectfont\ttfamily,breaklines=true}
\lstset{
frame = single,
language=Pascal,
}
{\small
\centering
\begin{lstlisting}[linewidth=2.9in,float,captionpos=b,caption={\small
Ubora's YAML Configuration.},label={listing:config}]
IPAddresses
- front: 10.243.2.*:80
- back: 10.244.2.*; 10.245.2.*:1064
samples: 8 per minute
recordTimeout: 15 seconds
propagateTimeout: 0.1 seconds
answerQualityFunction: default
\end{lstlisting}
}
{\bf \noindent Design with OS Managed Contexts:}
Some operating systems track execution context by annotating
network messages and thread-local memory with context and ID.
Dapper~\cite{sigelman-tr-2010} instruments Google's threading libraries, Power
Containers~\cite{shen-asplos-2012} tracks context switches between Linux
processes and annotates TCP messages and Xtrace~\cite{fonseca-nsdi-2007}
instruments networked middleware.
OS-managed execution context simplifies our design.
Ubora~ intercepts messages between components, acting as a middle box.
Before delivering messages that initiate remote procedures, Ubora~ checks
query ID and context and configures memoization-related
context (i.e., record or replay mode). The same
checks are performed on context switches.
During record mode, when a component initiates a remote
invocation, we use the message and query id as a key in the
cache. Subsequent component interactions comprise the value
associated with the key---provided the query context and
ID are matched. We split the value and form a new key when
the invoking component sends another message.
In replay mode, when an invocation message is intercepted,
the message is used to look up values in the cache. On hits, the cache returns
all values that are associated with the message. The cache results are turned into
properly formatted messages to transparently provide
the illusion of RPC. On misses, the message is delivered to
the destination component as described above.
{\bf \noindent Design without OS Support: }
Most vanilla operating systems do not track execution context.
Without such support, it is challenging to distinguish remote procedure calls
between concurrent queries. However, Ubora's memoization permits
imperfect context management because record, replay and normal modes yield valid
output. This feature allows us to execute concurrent queries under the same
context.
First, we describe a simple but broken idea that is highly transparent, and then we present an
empirical insight that allows us to improve this design without sacrificing transparency.
In this simple idea, each component manages its current, global execution context
that is applied to all concurrent queries. Also, it manages a context id that
distinguishes concurrent record contexts. Ubora intercepts
messages between components. When a component initiates a
remote invocation in record mode, the message and context id are
used to create a key. For the duration of record mode,
inter-component messages are recorded as values for the key.
If the context indicates replay mode, the message and context id are used to retrieve
values from cache.
This simple idea is broken because all messages from the
invoked component are recorded and cached, including
concurrent messages from different queries.
In replay mode, those messages can cause wrong output. Our key insight is that
record mode should use replies from the invoked component only if they are from the same
TCP connection as the initiating TCP connection.
The approach works well as long as TCP connections are not shared by
concurrent queries. Widely used paradigms like TCP connection
pooling and thread pooling are ideal for use with Ubora. We studied the source
code of 15 widely used open source components including: JBoss, LDAP,
Terracotta, Thrift and Apache Solr. Only 2 (13\%) of these platforms
multiplexed concurrent queries across the same connection. This suggests that
our transparent design can be applied across a wide range of services. We
confirm this in \MYsectionref{sect:overhead}.
Next we describe how to propagate request context, which is
necessary when the operating system does not support
execution contexts. On a front component,
we wait for queries to arrive on a designated TCP port. If a query is selected
for mature execution, we change the front component context from normal to
record and create a context id. Before sending any TCP message, we extract the
destination component. If the destination has not been contacted since record
mode was set, we send a UDP control message that tells that component to enter
record mode and forwards the proper context id. Then we send the original
message. Note, UDP messages can fail or arrive out of order. This causes the
mature execution to fail. However, we accept lower throughput (i.e., mature
executions per query) when this happens
to avoid increased latency from TCP roundtrips. Middle components propagate
state in the same way. Each component maintains its own local timers. After
a propagation timeout is reached, the context id is not forwarded anymore. After the
record timeout is reached, each component reverts back to normal mode independently.
We require front components to wait slightly longer than record timeout to ensure the system has returned to normal.
{\bf \noindent Reducing Bandwidth Needs:}
Ubora reduces bandwidth required for context propagation. First, Ubora propagates context to
only components used during online execution. Second, Ubora does not use
bandwidth to return components to normal mode, only sending UDP messages when
necessary to enable record or replay mode. Timeouts local to each component also
increase robustness to network partitions and congestion, ensuring that components
always return to normal mode.
\subsection{ Determining Front-End Components }
Thus far, we have described the front-end as the software
component at which queries initiate. Its internal timeout
ensures fast response time, even as components that it
invokes continue to execute in the background. To produce
an online answer, the front-end must complete its
execution. Ubora re-executes the front-end to get mature
answers. Ubora can not apply memoization to the front-end
component.
At first glance, re-execution seems slower than
memoization. However, as shown in
\MYfigureref{fig:xcomponents-yrunningtimes}, many components
execute quickly. In some cases, execution is faster than
transferring intermediate data to the key-value store.
Our implementation allows for a third class of component:
middle components. Like front-end components, middle
components are allowed to time out. They are re-executed in
replay mode without memoization. Unlike front-end
components, middle components do not initiate queries. In
\MYfigureref{fig:draw-solrworkflow}, Distributed Search or
Redis components could be labeled middle components.
Given a trace of representative queries, Ubora determines
which components to memoize by systematically measuring
throughput with different combinations of front-,
middle- and back-end components. We do the same to
determine the best sampling rate.
\subsection{Prototype}
We implemented transparent context tracking as described
above for the Linux 3.1 operating system.
The implementation is installed as user-level package and requires the Linux
Netfilter library to intercept and reroute TCP messages. It uses IPQueue to
trigger context management processes. It assumes components communicate through
remote procedure calls (RPC) implemented on TCP and that an IP address and TCP
port uniquely identify each component. It also assumes timeouts are triggered
by the RPC caller externally---not internally by the callee.
It extends timeouts transparently by blocking FIN packets sent to the callee and
spoofing ACKs to the caller. Messages from the callee that arrive
after a blocked FIN are cached but not delivered to the caller.
For workloads that use connection pooling, we block application-specific
termination payloads. Service managers can specify this in the configuration file.
We use a distributed Redis cache for in-memory key value storage. Redis allows
us to set a maximum memory footprint per node. The aggregate memory across all
nodes must exceed the footprint of a query. Our default setting is 1 GB.
Also, Redis can run as a user-level process even if another Redis instance runs
concurrently, providing high transparency.
We want to minimize the overhead in terms of response time and cache miss
rate. Each key value pair expires after a set amount of time. Assuming a set
request rate, cache capacity will stabilize over time. A small
amount of state is kept in local in-memory storage on the Ubora~ control
unit node (a front node). Such state includes sampled queries, online and
mature results and answer quality computations.
\section{Experimental Evaluation}
\label{sect:setup}
\begin{table*}[tbp]
\begin{center}
\small
\begin{tabular}{|l|l|l|r|r|r|r|r|}
\hline
\textbf{Code-} & \textbf{Platform} & \textbf{Parallelism} &
\multicolumn{1}{l|}{\textbf{Parallel}} &
\multicolumn{1}{l|}{\textbf{Data}} &
\multicolumn{1}{l|}{\textbf{Nodes}} &
\multicolumn{1}{l|}{\textbf{Online resp.}} &
\multicolumn{1}{l|}{\textbf{Mature resp.}} \\
\textbf{name} & \textbf{} & \textbf{} &
\multicolumn{1}{l|}{\textbf{Paths}} &
\multicolumn{1}{l|}{\textbf{(GB)}} &
\multicolumn{1}{l|}{\textbf{}} &
\multicolumn{1}{l|}{\textbf{time (sec)}} &
\multicolumn{1}{l|}{\textbf{time (sec)}} \\ \hline
\textbf{YN.bdb} & Apache Yarn & Partial Rep. & 2 & 1 & 8 &
178.00 & 185.00 \\
\textbf{LC.lit} & Lucene & Data & 1 & 4 & 4 & 1.00 & 1.22\\
\textbf{LC.wik} & Lucene & Data & 4 & 128 & 31 & 3.00 & 8.97\\
\textbf{LC.big} & Lucene & Data & 4 & 4096 & 31 & 5.00 &
23.52 \\
\textbf{ER.fst} & EasyRec & Partial Rep. & 2 & 2 & 7 & 0.50
& 0.60 \\
\textbf{OE.jep} & OpenEphyra & Data & 4 & 4 & 8 & 3.00 &
23.43 \\ \hline
\end{tabular}
\end{center}
\caption{The OLDI workloads used to evaluate Ubora supported
diverse data sizes and processing demands.}
\label{tab:workloads}
\end{table*}
In this section, we compare Ubora to alternative designs and
implementations across a wide range of OLDI workloads.
First, we discuss the chosen metrics of merit. Then, we
describe the competing designs and implementations. Then,
we present the software and hardware architecture for the
OLDI services used. Finally, we present experimental
results.
\subsection{Metrics of Merit}
Ubora speeds up mature query executions needed to compute
answer quality. The research challenge is to complete
mature query executions while processing other queries
online at the same time. The primary metric used to
evaluate Ubora's performance ({\em throughput}) is mature
executions completed per online execution.
Mature executions use resources otherwise reserved for
online query executions, slowing down response times.
Online queries that Ubora does not select for mature
execution (i.e., unsampled queries) are slowed down by
queuing delays. We report {\em slowdown} as the relative
increase in response time. In addition to queuing delay,
online queries sampled for mature execution are also slowed
down by context tracking and memoization.
Finally, we used {\em true positive rate}, i.e., the percentage
of mature results represented in online results, to compute answer quality.
\subsection{Competing Designs and Implementations}
Ubora achieves several axiomatic design goals.
Specifically, it (1) speeds up mature executions via
memoization, (2) uses a systems approach that works for
a wide range of OLDI services, (3) supports adjustable
query sampling rate and (4) implements optimizations that
reduce network bandwidth. Collectively, these goals
make Ubora usable. Our evaluation compares competing
designs that sacrifice one or more of these goals. They are
listed below with an associated codename that will be used
to reference them in the rest of the paper.
\begin{MYlistwide}
\item {\em Ubora} implements our full design and
implementation. The sampling rate is set to maximize
mature query executions per online query.
\item {\em Ubora-LowSamples} implements our full design and
implementation, but lowers the sampling rate to reduce slowdown.
\item {\em Ubora-NoOpt} disables Ubora's optimizations.
Specifically, this implementation disables node-local
timeouts that reduce network bandwidth.
\item {\em Query tagging and caching } essentially
implements Ubora at the application level. Here, we
implement context tracking by changing the OLDI service's
source code so that each query accepts a timeout
parameter. Further, we set up a query cache to reuse
computation from online execution. This approach is
efficient but requires invasive changes.
\item {\em Query tagging } implements context tracking at
the application level but disables memoization.
\item {\em Timeout toggling} eschews both context tracking and
memoization. This implementation increases each component's
global timeout settings by 4X for mature executions. All
concurrent query executions also have increased timeout settings.
This is non-invasive because most OLDI components support
configurable timeout policies. However, extending
timeouts for all queries is costly.
\end{MYlistwide}
\begin{figure*}[t!]
\includegraphics[width=6.0in]{uborasubfiguresv2.pdf}
\hrulefill
\caption{\small {\bf Experimental results: }
Ubora achieves greater throughput than competing
systems-level approaches. It performs nearly as well as
invasive application-level approaches (within 16\%). }
\label{fig:xsamplerate-ythroughput}
\end{figure*}
\subsection{OLDI Services}
\MYtableref{tab:workloads} describes each OLDI service used
in our evaluation. In the rest of this paper, we will
refer to these services using their codename.
The setup shown in \MYfigureref{fig:draw-solrworkflow} depicts LC.all, a 31
node cluster that supports 16 GB DRAM cache per TB stored on disk. Each
component runs on a dedicated node comparable to an EC2 medium instance, providing access to an Intel
Xeon E5-2670 VCPU, 4GB DRAM, 30 GB local storage and (up to) 2 TB block storage.
\begin{MYlistwide}
\item {\em YN.bdb} uses Hadoop/Yarn for sentiment analysis.
Specifically, it runs query 18 in BigBench, a data
analytics benchmark~\cite{ghazal-sigmod-2013}.
Each query spawns two parallel executions.
The first sub-execution extracts sentiments from customer
reviews over 2 months. The second covers 9 months.
The 9-month execution returns the correct answer, but the
1-month answer is used after a 3-minute timeout.
Each sub-execution flushes prior cached data in HDFS,
restores a directory structures and compresses its
output. As a result, query execution takes minutes, even
though customer reviews are smaller than 1 GB.
The average response time without timeout is 3 minutes.
44\% of queries get the 9-month answer within timeout.
We mainly include YN.bdb to show that Ubora can capture
answer quality for longer running services too.
\item {\em LC.big}, {\em LC.wik} and {\em LC.lit} use Apache
Lucene for bag-of-words search. All of these workloads
replay popular query traces taken from Google Trends. LC.lit
hosts 4GB of news articles and books on cluster with
16GB DRAM. LC.lit implements one parallel path shown in
\MYfigureref{fig:draw-solrworkflow}. It returns the best
answer produced within 1 second. Without
timeouts, the average response time is 1.22 seconds.
Over 83\% of LC.lit queries complete within the timeout.
{\em LC.wik} hosts 128GB of data from Wikipedia, New York
Times and TREC NLP~\cite{trec}. After executing warm-up
queries, the data mostly fits in memory. We set a
3-second timeout. Without the timeout, response time
was 8.9 seconds. 39\% of the LC.wik queries
complete within the timeout.
{\em LC.big} hosts 4TB. Most queries access
disk. Average response time without timeout is 23
seconds. The timeout is 5-seconds.
\item {\em ER.fst} uses the EasyRec platform to recommend
Netflix movies. It compiles two recommendation databases
from Netflix movie ratings~\cite{netflix-data}:
A 256MB version and a 2GB version. Each query provides a
set of movie IDs that seed the recommendation engine.
The engine with more ratings normally takes longer to
respond but provides better recommendations.
Query execution times out after 500 milliseconds. 80\% of
query executions produce the 2GB answer.
\item {\em OE.jep} uses OpenEphyra, a question answering
framework~\cite{openephyra-webpage}. OpenEphyra uses
bag-of-words search to extract sentences in NLP data
related to a query. It then compares each sentence to a
large catalog of noun-verb templates, looking for specific
answers. The workload is computationally intensive. The
average response time in our setup was 23 seconds.
Motivated by the responses times for IBM Watson, we set a
timeout of 3 seconds~\cite{ferrucci-aaai-2010}.
Fewer than 15\% of queries completed within timeout.
\MYnote{analyzes this data to answer a
trace of 1K questions related to recent events, sent to a front end running on
NanoWeb~\cite{nanoweb-webpage}. The front end aggregates results from
parallel invocations of OpenEphyra, a question
answering framework~\cite{openephyra-webpage}. OpenEphyra pulls whole web
pages from our MYSQL-based disk storage. It uses Lucene and Redis for indexing
and data caching.}
\end{MYlistwide}
We set up a workload generator
that replayed trace workloads at a set arrival rate. Our workload generator kept
CPU utilization between 15--35\%.
\subsection{Results}
\label{sect:overhead}
{\bf \noindent Comparison to Competing Approaches:}
\MYfigureref{fig:xsamplerate-ythroughput} compares
competing approaches in terms of mature executions completed
per query. Ubora-NoOpt reveals that node-local timeouts and
just-in-time query propagation collectively improve
throughput by 1.6X, 1.3X and 2.1X respectively. ER.fst
has relatively fast response times which require messages to
turn off record and replay modes. Node-local timeouts
reduce these costs. Internal component communications in
LC.big and LC.wik also benefit from node-local timeouts.
Excluding Ubora, the other competing approach that can be
implemented for a wide range of services is toggling timeouts.
Unfortunately, this approach performs poorly, lowering
throughput by 7-8X.
To explain this result, we use a concrete example of a
search for ``Mandy Moore'' in LC.big.
First, we confirm that both Ubora and toggling timeouts
produce the same results. They produce the same top-5 results and 90\%
of the top-20 results overlap. Under 5-second timeout, the query times out
prematurely, outputting only 60\% of top-20 results.
Ubora completes mature executions faster because it maintains execution context.
This allows concurrent queries to use different timeout settings. Queries
operating under normal timeouts free resources for the
mature execution. Further,
per-component processing times vary within mature
executions (recall, \MYfigureref{fig:xcomponents-yrunningtimes}). By maintaining execution context, Ubora avoids
overusing system resources.
For the ``Mandy Moore'' query, Ubora's mature execution took
21 seconds in record mode and 4 seconds in replay mode.
Conversely, under the toggle timeouts approach, service
times for all concurrent queries increased by 4X, exceeding
system capacity and taking 589 seconds.
We also compared Ubora, a systems level approach that
strives to transparently support a wide range of services,
to application-level approaches. Application-level approaches
can track query context efficiently by tagging queries as
they traverse the system~\cite{fonseca-nsdi-2007}.
Specifically, we modified LC.big, LC.lit and ER.fst to pass
query context on each component interaction. Further, we
implemented a query cache for targeted query
interactions~\cite{amza2005transparent,guo2013vcache,paiva2013autoplacer}.
Our cache uses the Ubora's mechanism for memoization but
tailors it to specific inter-component interactions and
context ids. As such, our application-level approach is
expected to outperform Ubora, and it does. However, Ubora
is competitive, achieving performance within 16\% on all
applications. We also compared to a simple
application-level approach that disables query caching.
This approach shows that memoization improves throughput by
1.3X on LC.big, 1.7X on LC.lit and 2.5X on ER.fst.
The benefit provided by memoization is correlated with the
ratio of mature execution times to online execution times.
In ER.fst, mature executions are mostly repeating online executions.
\begin{figure*}[t!]
\includegraphics[width=6.0in]{uborasubfiguresv3.pdf}
\hrulefill
\caption{\small {\bf Experimental results: } (a) Ubora
delayed unsampled queries by 7\% on average. Sampled
queries were slowed by 10\% on average. (b) Profiling
sampling and memoization options maximizes throughput.
(c) Timeout settings have complex, application-specific
affects on answer quality. }
\label{fig:uborafiguresv3}
\vspace{-0.2in}
\end{figure*}
{\bf \noindent Impact on Response Time:}
Ubora allows system managers to control the query sampling
rate. As shown in
\MYfigureref{fig:xsamplerate-ythroughput}, a slight
reduction in the sampling rate can still achieve high
throughput. However, this approach significantly reduces
Ubora's effect on response time.
\MYfigureref{fig:uborafiguresv3}(A) shows the slowdown
caused by the Ubora-LowSamples approach across all tested
workloads. By executing mature executions in the background
and staying within processing capacity, we achieve slowdown
below 13\% on all workloads for unsampled queries and below
10\% on 4 of 6 workloads for sampled queries. OpenEphyra
and LC.all incur the largest overhead because just-in-time
context interposes on many inter-component interactions due
to cluster size. For such workloads, OS-level context
tracking would improve response time for
sampled queries.
{\bf \noindent Impact of Profiling:}
\MYfigureref{fig:uborafiguresv3}(B) studies our
approach to determine sampling rate and front-end components
(i.e., memoization). We studied the ER.fst workload.
Along the x-axis, we vary the sampling rate and the
percentage of components included as front-end of middle
components. The y-axis shows the achieved throughput.
For the ER.fst workload it is better to apply memoization to
many components. The ideal sampling rate was 20\%.
{\bf \noindent Studying Answer Quality:}
\MYfigureref{fig:uborafiguresv3}(C) shows answer quality
(i.e., the true positive rate) as we increase timeout
settings. For LC.lit and ER.fst, we increase timeouts at
front-end components. We also validate our results by
increasing timeouts in an unrelated component in ER.fst (Static). We
observe that answer quality is stable in the static
setting. Further, answer quality curves differ between
applications. After timeout settings reach 600 milliseconds
for LC.lit and 300 milliseconds for ER.fst, the curves
diverge and answer quality increase slowly for ER.fst.
Finally, answer quality curves have 2 phases in LC.lit and 3
phases in ER.fst. It is challenging to use timeouts to
predict answer quality.
\section{Online Management}
\label{sect:onlinemanagement}
OLDI services are provisioned to provide target response times. In addition to
classic metrics like response time, these services could use answer quality to
manage resources. We show here that Ubora enables better resource management through answer quality.
{\noindent \bf Control Theory with Answer Quality:}
We studied load shedding on the LC.big workload. Using diurnal traces from previous
studies~\cite{stewart-eurosys-2007}, we issued two classes of queries: high and
low priority. The queries were directed to two different TCP ports.
At the peak workload, low and high priority arrival rates saturate
system resources (i.e., utilization is 90\%).
\MYfigureref{fig:xtime-y1answerquality-y2loadshed} shows the {\em Arrival Rate} over
time (on the right axis). At the 45 minute and 2 hour mark, the query mix
shifts toward multiple word queries that take longer to process fully.
We used Ubora~ to track answer quality for high
priority queries.
When quality dipped, we increased the load shedding rate on low priority
queries. Specifically, we used a proportional-integral-derivative (PID)
controller. Every 100 requests, we computed answer quality
from 20 sampled queries (20\% sample rate).
The left axis of \MYfigureref{fig:xtime-y1answerquality-y2loadshed} shows answer
quality of competing load shedding approaches. When all low priority queries are
shed, the {\em No Sharing} approach maintains answer quality above 90\%
throughout the trace. When shedding is disabled, the {\em Full Sharing}
approach sees answer quality drop as low as 20\%, corresponding with peak
arrival rates. The PID controller powered by Ubora manages the shed rate well, keeping
answer quality above 90\% in over 90\% of the trace. It maintains throughput
({\em Ubora TPUT})
of almost 60\% of low priority queries (shown on the right axis).
The state of the art for online management in OLDI services is to use proxies
for the answer quality metric. Metrics like the frequency of timeouts provide a
rough indication of answer quality and are easier to compute online~\cite{jalaparti-sigcomm-2013}.
For comparison, we implemented a PID controller that used frequency of timeouts
instead of answer quality. We tuned the controller to achieve answer quality
similar to the controller based on answer quality.
However, timeout frequency is a conservative indicator
of answer quality for Lucene workloads. It assumes that partial results caused by timeouts are
dissimilar to mature results. \MYfigureref{fig:xtime-y1answerquality-y2loadshed}
also shows that the controller based on timeout frequency ({\em TO Freq}) sheds requests too
aggressively. Our approach improved
throughput on low priority queries by 37\%.
\begin{figure}[t!]
\centering
\small
\includegraphics[width=3.3in]{xtime-y1answerquality-y2loadshed.pdf}
\vspace{-0.2in}
\caption{Ubora enables online load shedding.}
\label{fig:xtime-y1answerquality-y2loadshed}
\end{figure}
{\bf \noindent Sampling Rate and Representativeness:}
Ubora allows reducing the overhead of mature executions by
sampling online executions. This lowers mature results per
query, but how many mature results are needed for online
management? \MYnote{ \MYtableref{tab:representativeness} shows the
effect of lower sampling rates on the accuracy of answer
quality measurements and on the outcome of adaptive load
shedding.} We observed that sampling 5\% of online queries
significantly increased outlier errors on answer quality,
but our adaptive load shedding remained effective---it still
achieved over 90\% quality over 90\% of
the trace. In contrast, a 2\% sampling produced many quality
violations.
\section{Related Work}
\label{sect:relatedwork}
Ubora focuses on online systems, which trade answer quality for fast response times. Zilberstein first characterized similar applications as anytime algorithms~\cite{Zaimag96}. Like the online, data-intensive workloads used with Ubora, anytime algorithms increase in quality of result as they increase in computation time. Zilberstein uses three metrics, certainty, accuracy, and specificity; accuracy is closest to our answer quality metric, but does not indicate how the exact answer is to be reached for comparison. His work indicates that anytime algorithms should have measurable quality, monotonically increase in quality as computation time increases, provide diminishing returns, and produce a correct answer when interrupted. Properties of anytime algorithms that Ubora does not need to work correctly include recognizable quality and being able to suspend and resume application processing at any point in time. Recognizable quality refers to ability to determine the optimal answer in constant time for online processing; Ubora decreases the total time to acquire a mature execution by reducing data access times, but does not interfere with the processing of this data by software components.
Recent work has focused on introducing approximation into existing systems in order to increase performance~\cite{goiri2015approxhadoop,jeon-eurosys-2013,jalaparti-sigcomm-2013}.
Goiri et al. created ApproxHadoop~\cite{goiri2015approxhadoop} to integrate sampling of input data, user-defined approximate code versions, and execution of only a subset of tasks into Hadoop. The authors allow users to set error bounds within a confidence interval, set a specific data sampling ratio, or specify the percentage of tasks to drop in order to increase performance. ApproxHadoop uses extreme value theory and multi-stage sampling theory to compute error bounds and confidence intervals depending on type of aggregation query. Our work with Ubora uses mature executions to compute answer quality, and enables users to similarly manage resources based on the online answer quality trace.
Jeon et al. worked on intra-query parallel index search within a Bing server~\cite{jeon-eurosys-2013}. Sequential search may terminate early on a server if the processing of the ranked documents goes below a certain relevance. Since parallel search over the same index will generally result in more processing per query, the authors reduce this wasted work by keeping the order in which documents are processed sequential. While this is not necessary under low load, higher loads are more impacted by wasted work. The authors adaptively change the amount of parallelism per query based on the current system load.
Jalaparti et al. introduced Kwiken, their optimization framework for lowering tail latency in Bing~\cite{jalaparti-sigcomm-2013}. Techniques the authors used within Kwiken include allowing return of incomplete results, reissuing queries that lag on different servers, and increasing apportioned resources. They calculate incompleteness as utility loss based on whether the answer returned contains the highest ranked document for certain stages, and in other stages this is the percentage of parallel components that had not responded. In order to apportion utility loss as a resource, the authors use a budget constraint of 0.1\% average utility loss across the cluster. Our work differs from their solution in that we focus on speeding up the mature execution with which to produce answer quality. Additionally, our framework provides for provisioning of other resources based on answer quality.
Work has also been done to reduce energy cost using approximate computing~\cite{ceze,BaekCh10}.
At the application and compiler level, EnerJ~\cite{ceze} extends Java to include support for typed, approximate computing. Baek and Chilimbi created Green~\cite{BaekCh10} specifically to replace loops and functions with approximate versions, but do so cautiously—they require the programmer to supply the approximate versions of the loops and functions, as well as the quality-of-service where they would prefer to run their application.
Baek and Chilimbi expose an interface to the programmer to replace loops and functions with approximations of the same~\cite{BaekCh10}. Green offers statistical guarantees that the Quality of Service desired by the programmer will be met. However, it is left up to the programmer to provide approximate functions as replacements. In the case of loops, it is left up to the programmer to provide a quality-of-service function for early termination. Green uses the output of a function compared to the output of the corresponding non-approximate function to determine the loss in quality-of-service, unless told otherwise. Using the programmer-specified inputs and functions, Green does a first-pass run of the application to determine expected loss in quality-of-service. Before processing the full application, Green uses the information gathered from this first pass to generate a version which only uses approximation when doing so is not expected to violate the user-specified quality-of-service request~\cite{BaekCh10}.
The authors of EnerJ~\cite{ceze} combine approximate storage, approximate algorithms, and approximate computation into an easy to program interface, which separates data that requires precision from data that is allowed to be approximate. EnerJ is an extension to Java that uses approximate computing to reduce the energy consumed by a user program. The mechanism they use to keep precise data distinct from approximate data is a system of type qualifiers that allows the programmer to specify portions of their code which can be approximated without damaging quality of service. Data can be identified as permissively approximate by using a specific type identifier. It is then impossible to assign approximate values to the default precisely typed variables without endorsing these assignments explicitly. Operations are made approximate by overloading operators, and specifying that only approximately typed variables may use said approximate operators. As with overloaded operators, programmers can also specify two different algorithms for any function, one precise and one approximate, and use typing to force use of the approximate algorithm when the function results are assigned to an approximate variable.
EnerJ seeks to directly reduce energy cost using approximate computing, but neither directly quantifies the effect of its approximate computing mechanisms on overall application answer quality. EnerJ computes application-specific quality-of-service error offline for its results section~\cite{ceze}. Ubora can be used to reduce energy use of an application while keeping the answer quality at a target level. This is possible because the online answer quality trace can be used to trigger modifications to system variables such as timeouts, load shedding, reduction in auto-scaling, and DVFS scaling, all based on preset target answer quality levels.
Approximate computing is also used to tailor content for specific clients~\cite{kamat2014distributed,foxgr99,chen03,kephart-icac-2015}.
DICE~\cite{kamat2014distributed} focuses on the challenges of distributed system building for exploring data cubes interactively. Ad-hoc analytics have been growing in popularity with end users, but the delays involved are heightened when directed at data represented as a CUBE. The framework the authors built uses speculative execution, data subsets, and faceted data cube exploration. The authors aim to deliver sub-second latencies on queries which access distributed data from billion-tuple cubes, without keeping the entire data cube in fast cached memory or using offline data sampling, which does not update in real time. This work takes advantage of the observation that queries seldom happen in a vacuum, and tend to instead be one of several related queries. In between executing queries, the authors use wait time to speculatively execute the queries most likely to be asked next, and cache these results. This work also implements timeouts on total query execution, so that even if only one of the data shards is assembled in post processing, some answer will be available. Thirdly, the work in this paper used sampling, increasing the data sampling rates for the most likely speculative queries found~\cite{kamat2014distributed}. This paper is very similar in two ways to Ubora, in that we also uses cached data from queries hidden from the user. CUBE uses this cached data to improve the latencies of further queries within a user session. In our work, we have explored the possibility of improving user latency using cached results of mature executions, but our primary focus has been on using this data to measure answer quality. CUBE is optimized to use sampled data to reduce the amount of resources spent running speculative queries. In contrast, Ubora uses complete data for the queries it hides from the user, but only performs such mature executions for sampled queries.
Fox et al. show how a proxy-based approach could dynamically scale quality of web results across different end platforms~\cite{foxgr99}. Their work uses lossy compression to distil specifically typed information down to the portions with semantic value. Their proxy adapts on demand to fit the needs of a client. A high end desktop machine can support downloading a larger number of bytes over the network than a smart phone; reducing the number of bytes necessary to download in order to view the page benefits such mobile devices. In contrast to our work, Fox et al. accesses a mature execution from a web server and approximates this data to meet the needs of a range of client platforms. We instead focus on services that provide online results, and measure the amount of approximation present.
Chen et al. use a thumbnail sized image of each web page as a table of contents for simplified browsing~\cite{chen03}. For pages in which splitting content into blocks is not feasible, the authors use the table of contents image to enable automatic positioning of the full-size web page on the mobile screen. Their methods introduce error in 10\% of tested web pages in order to simplify the viewing of all on mobile screens.
As in our work, Kephart and Lenchner focus on online data-intensive computations occurring across multiple components working together~\cite{kephart-icac-2015}. While we measure the answer quality of online system responses, their work displays interpreted system responses to the user and corrects computations when the user indicates incorrect analysis.
Our work focuses on data-intensive applications, and uses application-specific similarity metrics to study answer quality. SocialTrove also focuses on data-intensive applications. Instead of measuring answer quality, SocialTrove uses application-specific similarity metrics to automatically cluster and summarize social media data~\cite{amin-icac-2015}.
Other works have focused on scheduling to increase answer quality and throughput~\cite{he-icac-2012,he-socc-2012,ren-icac-2013,zheng-cloud-2015}.
He et al. use a budget consisting of total execution time for current queries to determine whether and how long to schedule a query~\cite{he-icac-2012}. Their work uses a feedback mechanism to help ensure the desired response times are being met, and an optimization procedure to schedule based on request service demands and response quality profiles. Their algorithm takes advantage of prior knowledge regarding the overall concave quality profile of Microsoft Bing to estimate the individual request quality profile, rather than attempting to measure request quality with a mature execution.
Zeta~\cite{he-socc-2012} was designed to better schedule requests in online servers for high response quality and low response quality variance~\cite{he-socc-2012}. Zeta focuses on online services that produce partial results under a deadline, where additional computation time produces diminishing returns in additional response quality. Their response quality, like our answer quality, uses an application-specific metric to compare a partially executed request to a full execution. They measure their response quality offline.
Ren et al. explored how heterogeneous processors can execute long requests on faster cores and shorter requests on slow cores to achieve high throughput and high quality~\cite{ren-icac-2013}. The authors implemented a new algorithm, FOF, which focuses on requests where service demands are unknown. These new requests are scheduled on the fastest idle core. Then, requests are migrated from slow cores to faster cores as necessary. This algorithm can improve answer quality and throughput in heterogeneous processors as compared to homogeneous processors with the same power budget. The authors used Bing without deadlines in a controlled setting to produce mature executions, and then used this data in their simulation study. We also improve metrics using adaptive resource management based on answer quality, but Ubora produces mature executions online.
Zheng et al. wrote a deadline-agnostic scheduler ISPEED for anytime algorithm workloads~\cite{zheng-cloud-2015}. Their scheduler focuses on maximizing total utility over all jobs in the cluster, and ignores concerns regarding individual query deadlines. In addition to the utility functions used in ~\cite{he-icac-2012,he-socc-2012}, Zheng et al. also performed a user study for the Google search engine to find its average utility function~\cite{zheng-cloud-2015}.
Also highly related to Ubora is the area of adaptive resource allocation~\cite{spinner2014icpe,gandhi2014adaptive,lama2013aroma}.
Spinner et al. present their library for estimating resource demands with seven different approaches~\cite{spinner2014icpe}. Using their library, it is possible to control how often the resource use is sampled, when and for how long to perform the estimate. In general terms, Ubora also supports estimation of resource demand for mature executions.
Gandhi et al. show that their new autoscaling cloud service, DC2, can learn an application's system parameters and scale based on its understanding of resource requirements~\cite{gandhi2014adaptive}. The authors' solution attempts autoscaling applications without direct knowledge of their needs, instead relying on user-specified SLA information, virtual cpu statistics, and knowledge of request URLs. Like Ubora, DC2 is mostly transparent, with key information provided by the user. However, DC2 focuses directly on autoscaling rather than providing a solution for processing mature executions online.
Lama and Zhou describe their implementation of an automated resource provisioning system~\cite{lama2013aroma}. Their system, AROMA, targets quality of service while minimizing cost, using allocation of resources in a heterogeneous cloud and Hadoop parameter configurations. However, instead of directly profiling each workload and regulating resources based on answer quality, AROMA profiles each workload for a short time on a staging cluster before matching the workload's signature to a cluster of workloads with a set of associated resources.
\section{Conclusion}
\label{sect:conclusion}
OLDI queries have complex and data-parallel execution paths that must produce
results quickly. Data used by each query is skewed across data
partitions, causing some queries to time out and return premature results.
Answer quality is a metric that assesses the impact of
timeouts on the quality of results. It is challenging to
compute online because it require results from mature
executions that are unaffected by timeouts.
This paper describes Ubora, an approach to speed up mature
executions by reusing intermediate computations from online
queries, i.e., memoization. Ubora adopts a challenging
systems-level approach that allows us to measure answer
quality for a wide range of services. Our implementation
includes novel context tracking for commodity operating
systems and bandwidth optimizations. The evaluation shows
that Ubora produces mature results faster than competing
transparent approaches and nearly as fast as
less flexible, application-specific approach. Most
importantly, Ubora produces answer quality quickly enough to
enhance online system management.
\section{Addendum}
{\small
{\noindent \bf Availability:} An extended version of this
paper, Ubora's source code and executable images of our OLDI
workloads are available at: {\em \url{http://www.cse.ohio-state.edu/~kelleyj/ubora.html}}.
{\noindent \bf Acknowledgements:} This work was supported by
NSF grants CAREER CNS-1350941 and CNS-1320071, and also by
the Oak Ridge Leadership Computing Facility managed by UT
Battelle, LLC for the U.S. DOE (contract
No. DE-AC05-00OR22725).
}
\bibliographystyle{abbrv}
{
|
{'timestamp': '2015-06-18T02:05:39', 'yymm': '1506', 'arxiv_id': '1506.05172', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05172'}
|
arxiv
|
\section{Introduction}
\label{sec:intro}
Current statistical parametric speech synthesis typically uses hidden Markov models (HMMs) to represent probability densities of speech trajectories given text \cite{ref:Zen09}. This is a well-established method and it is straightforward to apply this framework for new languages. It also offers interesting advantages in terms of flexibility and compact footprint \cite{ref:Yoshimura97,ref:Yoshimura99,ref:Tsuzuki04,ref:Yamagishi05}. It is known, however, that speech synthesized from statistical models still sounds somehow artificial and less natural compared to speech synthesized by the best unit selection systems.
It is often said that averaging in statistical synthesis systems partly removes spectral fine structure of natural speech, and thus there is room for the improving the segmental quality. A stochastic postfilter approach \cite{ref:Chen14} proposes to use a deep neural network (DNN) to model the conditional probability of the spectral differences between natural and synthetic speech. The approach is able to reconstruct the spectral fine structure lost during modeling and has achieved significantly quality improvement for synthetic speech \cite{ref:Chen14}. In this experiment, the HMM-based speech synthesiser was trained in the mel-cepstral domain, while the DNN-based postfiler was trained in the spectral domain.
This indicates that the current statistical parametric speech synthesis suffers from quality loss due to statistical averaging in the mel-cepstral domain, but also due to conversion from high-dimensional spectral features to lower dimensional mel-cepstral parameters and hence this brings us a new question: are current intermediate representations such as mel-cepstral coefficients appropriate for statistical training of acoustic models? Can we automatically find a more appropriate intermediate representation that suits acoustic modelling and results in better quality of synthetic speech?
To answer this question, this paper proposes a DNN-based feature extraction method. More specifically we propose to use a deep denoising auto-encoder technique as a non-linear robust feature extractor for speech synthesis and apply it to high-dimensional spectral features obtained from STRAIGHT vocoder \cite{ref:Kawahara99}. We compare this data-driven, unsupervised feature extraction approach with the conventional mel-cepstral analysis, which is based on a linear discrete cosine transform of the log spectrum.
This paper is organised as follows: in Section 2, we outline related DNN-based approaches and in Section 3 we describe the proposed deep denoising auto-encoder technique. In Section 4, we mention how we train the model and the experimental conditions and evaluation results are shown in Section 5. Discussions and the summary of our findings are given in Section 6.
\section{Related work using DNN and auto-encoder}
\label{sec:related_work}
This section overviews related work using DNN and/or auto-encoder in the speech information processing field. DNN has been applied for acoustic modelling of speech synthesis. For instance \cite{ref:Zen13} uses DNN to learn the relationship between input texts and the extract features instead of decision tree-based state tying. Restricted Boltzmann machines or deep belief networks have been used for modelling output probabilities of HMM states instead of GMMs \cite{ref:Ling14}. Recurrent neural network or long-short term memory was used for prosody modelling \cite{ref:Fan14} or acoustic trajectory modelling \cite{ref:Fernandez14}.
To the best of our knowledge, this is the first work to use deep denoising auto-encoder for speech synthesis, but, deep auto-encoder based bottleneck features are used by several groups for ASR \cite{ref:Sainath12,ref:Gehring13} and deep denoising auto-encoder is also verified for noise-robust ASR \cite{ref:Maas12} or reverberant ASR tasks \cite{ref:Ishii13,ref:Feng14}.
Techniques that are closely related to this paper are a spectral binary coding approach using deep auto-encoder proposed by Deng et al \cite{ref:Deng10} and a speech enhancement approach using deep denoising auto-encoder where they try to reconstruct clean spectrum from noisy spectrum \cite{ref:Lu13}. The approach proposed here is also related to heteroscedastic linear discriminant analysis (HLDA) \cite{ref:Kumar98,ref:Gales02} and probabilistic linear discriminant analysis (PLDA) \cite{ref:Prince07,ref:Kenny10,ref:Lu14}. Our key idea is however different from these as we use deep auto-encoder based continuous bottleneck features calculated from spectrum to reconstruct high-quality synthetic speech.
\section{Auto-encoder}
\label{sec:auto-encoder}
\subsection{Basic Auto-encoder}
\label{ssec:basic_auto-encoder}
Auto-encoder is an artificial neural network that is used generally for learning a compressed and distributed representation of a dataset. It consists of the encoder and the decoder. The encoder maps a input vector $\mathbf{x}$ to a hidden representation $\mathbf{y}$ as follows:
\begin{equation}
\mathbf{y} = f_\theta(\mathbf{x}) = s(\mathbf{Wx + b}),
\end{equation}
where $\theta = \{\mathbf{W}, \mathbf{b}\}$. $\mathbf{W}$ and $\mathbf{b}$ represent a $m \times n$ weight matrix and a bias vector of dimensionality $m$ respectively, where $n$ is the dimension of $\mathbf{x}$.
The function $s$ is a non-linear transformation on the linear mapping $\mathbf{Wx+b}$. Frequently $s$ is a sigmoid, a tanh, and a relu function.
$\mathbf{y}$, the output of the encoder, is then mapped to $\mathbf{z}$, the output of the decoder.
The mapping is performed by a linear function alone that employs a $n \times m$ weight matrix $W'$ and a bias vector of dimensionality $n$ as follows:
\begin{equation}
\mathbf{z} = g_{\theta'}(\mathbf{y}) = \mathbf{W'y + b'},
\end{equation}
or a linear mapping followed by a non-linear transformation $t$,
\begin{equation}
\mathbf{z} = g_{\theta'}(\mathbf{y}) = t(\mathbf{W'y + b'}),
\end{equation}
where $\theta' = \{\mathbf{W', b'}\}$. The weight for the decoding is set as the transpose of the encoding weight \cite{ref:Hinton06} in order to allow more layers to be stacked together and be fine-tuned with stochastic gradient descend (SGD).
In general, the output $\mathbf{z}$ should be interpreted as a function of parameters $\{\theta,\theta'\}$ as $\mathbf{z} = g_{\theta'}(f_{\theta}(x))$. The parameters $\{\theta, \theta'\}$ are optimized such that the reconstructed $\mathbf{z}$ is as close as possible to the original $\mathbf{x}$ and maximizes $P(\mathbf{x|z})$. A typical loss function used is the mean square error (MSE), i.e. $L(\mathbf{x,z}) = \frac{1}{n}|\mathbf{x-z}|^2$.
\subsection{Denoising Auto-encoder}
\label{sssec:subsubhead}
The denoising auto-encoder is a variant of the basic auto-encoder. It is reported that the denoising auto-encoder can extract features more robustly than the basic auto-encoder \cite{ref:Vincent08}. In the denoising auto-encoder, the original data $\mathbf{x}$ is first corrupted to $\mathbf{\tilde{x}}$ before it is mapped to a higher representation $f_{\theta}(\mathbf{\tilde{x}})$ by an encoder.
The decoder then maps the higher representation to the output $\mathbf{z}$ for reconstructing the original $\mathbf{x}$.
The denoising auto-encoder is trained such that the reconstructed ${\mathbf{z}}$ is as close as possible to the original data ${\mathbf{x}}$. Note that it is only during training that the denoising auto-encoder is used to reconstruct the original $\mathbf{x}$ from the corrupted $\mathbf{\tilde{x}}$.
\subsection{Deep Auto-encoder}
Auto-encoder or denoisng auto-encoder can be made deeper by stacking multiple layers of encoders and decoders to form a deep architecture. \cite{ref:Yu11} shows that deeper architecture produces better high-level features compared to the shallow architecture up to 4 encoding and 4 decoding layers. For constructing a deep auto-encoder pre-training is widely used.
In pre-training, the number of layers in a deep auto-encoder increases twice as compare to a deep neural network (DNN) when stacking each pre-trained unit. It is reported that fine-tuning with back-propagation through a deep auto-encoder is ineffective due to vanishing gradients at the lower layers \cite{ref:Sepp01}. To over come this issue we restrict the decoding weight as the transpose of the encoding weight following \cite{ref:Hinton06}, that is, $\mathbf{W}'=\mathbf{W}^T$ where $\mathbf{W}^T$ denotes transpose of $\mathbf{W}$. We describe the detail of training a deep auto-encoder in the next session.
\section{Training a Deep Denoising Auto-encoder}
\subsection{Greedy Layer-wise Pre-training}
\begin{figure}[t]
\begin{center}
\includegraphics[width=8.0cm]{./images/Stacking_AEs.png}
\end{center}
\vspace{-0.5cm}
\caption{Greedy layer-wise pre-training for constructing deep auto-dencoder.}
\label{fig:Stacking_AEs}
\vspace{-5mm}
\end{figure}
Each layer of a deep auto-encoder can be pre-trained greedily to minimize the reconstruction loss $L(\mathbf{x},\mathbf{z})$ of the data locally. Figure \ref{fig:Stacking_AEs} shows a procedure of constructing a deep auto-encoder using pre-training.
In pre-training a 1-hidden-layer auto-encoder is trained and the encoding output of the locally trained layer is used as the input for the next layer.
This layer-wise training is repeated until the desired layer size is obtained.
The encoding, decoding and loss functions of each layer are represented as follows:
\begin{equation}
\begin{split}
\texttt{Layer 1:} \\
\mathbf{y}_1 &= f_{\mathbf{W}_1,\mathbf{b}_1}(\mathbf{x}), \\
\mathbf{z}_1 &= g_{\mathbf{W}'_1,\mathbf{b}'_1} (\mathbf{y}_1), \\
L(\mathbf{x},\mathbf{z}_1) &= |\mathbf{x} - \mathbf{z}_1|^2, \\
\texttt{Layer k (k>1):} \\
\mathbf{y}_k &= f_{\mathbf{W}_k,\mathbf{b}_k}(\mathbf{y}_{k-1}), \\
\mathbf{z}_k &= g_{\mathbf{W}'_k,\mathbf{b}'_k}(\mathbf{y}_k), \\
L(\mathbf{y}_{k-1},\mathbf{z}_k) &= |\mathbf{y}_{k-1} - \mathbf{z}_k|^2. \\
\end{split}
\end{equation}
Note that during the pre-training of the deep denoising auto-encoder, the input $\mathbf{x}$, $\mathbf{y}_k$ for each layer are corrupted to $\tilde{\mathbf{x}}$ and $\tilde{\mathbf{y}_k}$ respectively.
After all layers are pre-trained, all the pre-trained layers are stacked for constructing a deep denoising auto-encoder in the same way as the deep auto-encoder.
\subsection{Fine-tuning}
The purpose of fine-tuning is to minimize the reconstruction error $L(\mathbf{x,z})$ over the entire dataset and a model architecture using error back-propagation \cite{ref:Remelhart86}.
We use the mean square error (MSE) for the loss function of a deep auto-encoder and it is represented as follows:
\begin{equation}
E = \sum_{i=1}^N |\mathbf{x}^{(i)} - \mathbf{z}^{(i)}|^2,
\end{equation}
where $N$ is the total number of training examples.
The partial derivatives w.r.t weight $w_{i,j}^{(l)}$ is represented as follows:
\begin{equation}
\frac{\partial{E}}{\partial{w_{i,j}^{(l)}}} = \frac{\partial{E}}{\partial{t_j^{(l)}}} \times \frac{\partial{t_j^{(l)}}}{\partial{w_{i,j}^{(l)}}}
\end{equation}
where $t_j^{(l)}$ is the fan-in input to neuron $j$ in layer $l$, and $\frac{\partial{t_j^{(l)}}}{\partial{w_{i,j}^{(l)}}} = o_{i}^{(l-1)}$, where $o_{i}^{(l-1)}$ is the output from neuron $i$ at layer $l-1$. $\frac{\partial{E}}{\partial{t_j^{(l)}}}$ is the error transfer function which can be calculated recursively following
\begin{equation}
\frac{\partial{E}}{\partial{t_j^{(l-1)}}} = \frac{\partial{o_i^{(l-1)}}}{\partial{t_i^{(l-1)}}} \times \sum_{j=1}^{L}\frac{\partial{E}}{\partial{t_j^{(l)}}}\times \frac{\partial{t_j^{(l)}}}{\partial{o_i^{(l-1)}}}
\end{equation}
where $\frac{\partial{t_j^{(l)}}}{\partial{o_i^{(l-1)}}}=w_{i,j}^{(l)}$. For the output tanh layer we have $\frac{\partial{o_i^{(L)}}}{\partial{t_i^{(L)}}}=\text{sech}^2(t_i^{(L)})$. Once we have the gradients of error function w.r.t to the weight parameters, we can fine-tune the network with error back-propagation.
\subsection{Corrupted data}
\begin{figure}[t]
\begin{center}
\subfigure[Original]{\includegraphics[height=5.3cm]{./images/original_and_masked_spec/2696_1.png}}
\hspace{-3mm}
\subfigure[Masked]{\includegraphics[height=5.3cm]{./images/original_and_masked_spec/2696_1_mask.png}}
\end{center}
\vspace{-0.5cm}
\caption{These figures shows parts of original and masked spectra. In the right figure black points indicated masked regions.}
\label{fig:mask}
\vspace{-3mm}
\end{figure}
We used a masking technique reported in \cite{ref:Vincent08} to corrupt the training data for the denoising auto-encoder.
This technique independently and randomly set the values of the training data in different dimensions to zero following a Bernoulli distribution.
Figure \ref{fig:mask} shows an example of original and masked spectra.
In this figure, black points indicate masked regions.
\section{Evaluation}
This section shows experimental results. We have evaluated the proposed auto-encoder method in the context of analysis-by-synthesis condition and text-to-speech conditions. In the text-to-speech experiments, the synthetic voices using the proposed acoustic features were modeled using two state-of-the-art speech synthesis systems: HMM and DNN.
\subsection{Dataset}
The dataset we use consists of 4569 short audio waveforms uttered by a professional English female speaker and each waveform is around 5 seconds long. For each waveform, we first extract its frequency spectra using STRAIGHT vocoder with 2049 FFT points. We then extract the low dimensional feature from each 2049-dim STRAIGHT spectrum using autoencoder. All data was sampled at $48$ kHz. For comparison of the proposed method, we extracted mel-cepstral coefficients that use the same dimensions as that of auto-encoder. All other acoustic features such as log F0 and $25$ aperiodicity band energies are the same for all the systems.
\subsection{Configurations of the deep denoising auto-encoder}
\begin{figure}[t]
\begin{center}
\includegraphics[width=8.0cm]{./images/MSE.png}
\end{center}
\vspace{-0.5cm}
\caption{Reconstruction mean square errors for auto-encoders of different architectures but same bottleneck dimension.}
\label{fig:mse}
\vspace{-3mm}
\end{figure}
Figure \ref{fig:mse} shows the reconstruction mean square errors of auto-encoders trained on raw frequency-warped spectrum with different number of hidden layers. It shows that the error decreases with more hidden layers, and that deep auto-encoder is better than shallow auto-encoder with the same bottleneck dimension. For the results in the rest of paper, we use architecture of the auto-encoder as 2049-500-180-120 for producing the 120-dim acoustic features, tanh units for all the layers and the inputs are 2049-dim Bark-scale-based frequency-warped spectrum, which are preprocessed with global contrast normalization. The hyperparameters used for the layer-by-layer pre-training are searched randomly and the set of values that produce the best results are selected. Table \ref{tb:hyper} shows the hyperparameters for the auto-encoders used in the experiments.
\begin{table}[t]
\caption{The table lists down the hyperparameters used for training each model. lr: learning rate, m: momentum, b: batch size, s: numpy random variable weight initialization seed \cite{ref:Ilya13}, d: masking probability of each input dimension \cite{ref:Vincent08}.}
\label{tb:hyper}
\vspace{-1em}
\begin{center}
\begin{tabular}{l|c|c|c|c|c|c|c}
\cline{2-7}
& layer dim& lr & m & b & s & d &\\ \cline{1-7}
\multicolumn{1}{ |c }{\multirow{4}{*}{\begin{minipage}{0.5in}Deep auto-encoder\end{minipage}} } &
\multicolumn{1}{ |c| }{2049-500} & 0.001 & 0.9 & 200 & 8963 & N.A \\ \cline{2-7}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{500-180} & 0.01 & 0.5 & 50 & 1902 & N.A \\ \cline{2-7}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{180-120} & 0.01 & 0.9 & 50 & 6555 & N.A \\ \cline{2-7}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{Finetune} & 0.01 & 0.5 & 150 & 9781 & N.A \\ \cline{1-7}
\multicolumn{1}{ |c }{\multirow{4}{*}{\begin{minipage}{0.5in}Deep denoising auto-encoder\end{minipage}} } &
\multicolumn{1}{ |c| }{2049-500} & 0.01 & 0.1 & 150 & 5252 & 0.1 \\ \cline{2-7}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{500-180} & 0.01 & 0.5 & 150 & 7514 & 0.1 \\ \cline{2-7}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{180-120} & 0.01 & 0.9 & 100 & 594 & 0.5 \\ \cline{2-7}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{Finetune} & 0.001 & 0.9 & 100 & 2208 & N.A \\ \cline{1-7}
\end{tabular}
\end{center}
\vspace{-5mm}
\end{table}
\subsection{Analysis-by-synthesis experimental results}
First we report the analysis-by-synthesis experimental results. For this evaluation, we have divided the above database into three subsets, that is, training, validation and test. The training subset was used as training data for building the auto-encoder, the validation subset was used as a stopping criteria during training to prevent over-fitting, and the test subset was used for measuring log-spectral distortion and listening test.
Figure \ref{spectrum} shows the original and reconstructed spectra using each technique (mel-cepstral analysis, deep auto-encoder, deep denoising auto-encoder). We can clearly see that the deep auto-encoders reconstruct high-frequency parts more precisely than mel-cepstral analysis.
\begin{figure*}[t]
\begin{center}
\subfigure[Original]{\includegraphics[height=5.3cm]{./images/analysis-synthesis_reconstructed-spec/Original.png}}
\hspace{-3mm}
\subfigure[mel-cepstrum]{\includegraphics[height=5.3cm]{./images/analysis-synthesis_reconstructed-spec/MelCep-120.png}}
\hspace{-3mm}
\subfigure[deep auto-encoder]{\includegraphics[height=5.3cm]{./images/analysis-synthesis_reconstructed-spec/DeepAutoEncoder-120-warp.png}}
\hspace{-3mm}
\subfigure[deep denoising auto-encoder]{\includegraphics[height=5.3cm]{./images/analysis-synthesis_reconstructed-spec/DenoisingDeepAutoEncoder-120-warp.png}}
\end{center}
\vspace{-0.5cm}
\caption{Original and reconstructed spectra using each technique.}
\label{spectrum}
\end{figure*}
Figure \ref{fig:log_spectral_distortion} shows log spectral distortion between the original spectra and reconstructed spectra, calculated on the test subset. We can observe that the deep auto-encoder has reduced the distortion significantly compared to the mel-cepstral analysis and denoising version further reduced the distortion.
\begin{figure}[t]
\begin{center}
\includegraphics[width=6.5cm]{./images/log_spectral_distortion/120dims.png}
\end{center}
\vspace{-0.5cm}
\caption{log spectral distortion between the original and reconstructed spectra.}
\label{fig:log_spectral_distortion}
\vspace{-3mm}
\end{figure}
Figure \ref{fig:results_analysis-by-synthesis} shows subjective preference scores of these methods. The number of listeners that performed this test were seven. They have participated in two preference tests. In the first preference test, they were asked to compare deep auto-encoder (DA) with mel-cepstral analysis (MCEP). In the second preference test, they were asked to compare deep auto-encoder with deep denoising autoencoder (DDA). From the figure, we can see that deep auto-encoder based speech samples sound more natural than mel-cesptral analysis based speech samples. Deep denoising auto-encoder reduced the distortion, however, perceptual difference between clean and denoising auto-encoder is not statistically significant.
\begin{figure}[t]
\begin{center}
\includegraphics[width=8.5cm]{./images/preference_test/results_analysis-synthesis.png}
\end{center}
\vspace{-0.5cm}
\caption{Results of preference tests using analysis-by-synthesis speech samples. In this figure, MCEP, DA and DDA refer to mel-cepstrum analysis, deep auto-encoder and deep denoising auto-encoder respectively.}
\label{fig:results_analysis-by-synthesis}
\vspace{-5mm}
\end{figure}
\subsection{Text-to-speech experimental results}
Next we report the text-to-speech experimental results. For the HMM-based speech synthesis, we have used a hidden semi-Markov model and the observation vectors for the spectral and excitation parameters contained static, delta and delta-delta values, with one stream for the spectrum, three streams for F$0$ and one for the band-limited aperiodicity. The context-dependnet labels are built using the pronunciation lexicon Combilex \cite{ref:Richmond10}. For the DNN-based speech synthesis, we have trained a five-hidden-layer DNN for mapping between linguistic contexts and auto-encoder-based or mel-cepstral acoustic features. The number of units in each of the hidden layers was set to 512. Random initialisation was used in a similar way to \cite{ref:Zen13}.
\begin{figure}[t]
\begin{center}
\includegraphics[width=8.5cm]{./images/preference_test/results_text-to-speech.png}
\end{center}
\vspace{-0.5cm}
\caption{Results of preference tests using text-to-speech samples. In this figure, MCEP and DA refer to mel-cepstrum analysis and deep auto-encoder for the acoustic feature extraction, and HMM and DNN are the acoustic models.}
\label{fig:results_tts}
\end{figure}
Figure \ref{fig:results_tts} shows subjective preference scores where we have compared the proposed auto-encoder feature with the conventional mel-cepstral feature in each of the HMM-based speech synthesis and the DNN-based speech synthesis systems. Listeners are the same as those for Figure \ref{fig:results_analysis-by-synthesis}. We can see that synthetic speech using the proposed feature sound more natural than the conventional mel-cepstral features in both the synthesis methods. The proposed feature seems to suit the DNN-based speech synthesis better, but, this requires further investigation.
\section{Conclusions}
In this paper we have proposed the deep denoising auto-encoder technique to extract better acoustic features for speech synthesis. We have compared the new stochastic feature extractor with the conventional mel-cepstral analysis in the analysis-by-synthesis and text-to-speech experiments and have confirmed that the proposed method can increase the quality of synthetic speech in both the conditions.
Our future work includes the improvement of the deep denoising auto-encoder. In this paper, we have used the simplest noise, i.e. masking and the improvement was observed only from objective evaluation. We shall use or design different types of noises to improve the deep denoising auto-encoder for speech synthesis further.
\vfill
\pagebreak
\nocite{ref:Bergstra12}
\nocite{ref:Xue14}
\nocite{ref:Remelhart86}
\input{output.bbl}
\end{document}
\section{Introduction}
\label{sec:intro}
Current statistical parametric speech synthesis typically uses hidden Markov models (HMMs) to represent probability densities of speech trajectories given text \cite{ref:Zen09}. This is a well-established method and it is straightforward to apply this framework for new languages. It also offers interesting advantages in terms of flexibility and compact footprint \cite{ref:Yoshimura97,ref:Yoshimura99,ref:Tsuzuki04,ref:Yamagishi05}. It is known, however, that speech synthesized from statistical models still sounds somehow artificial and less natural compared to speech synthesized by the best unit selection systems.
It is often said that averaging in statistical synthesis systems partly removes spectral fine structure of natural speech, and thus there is room for the improving the segmental quality. A stochastic postfilter approach \cite{ref:Chen14} proposes to use a deep neural network (DNN) to model the conditional probability of the spectral differences between natural and synthetic speech. The approach is able to reconstruct the spectral fine structure lost during modeling and has achieved significantly quality improvement for synthetic speech \cite{ref:Chen14}. In this experiment, the HMM-based speech synthesiser was trained in the mel-cepstral domain, while the DNN-based postfiler was trained in the spectral domain.
This indicates that the current statistical parametric speech synthesis suffers from quality loss due to statistical averaging in the mel-cepstral domain, but also due to conversion from high-dimensional spectral features to lower dimensional mel-cepstral parameters and hence this brings us a new question: are current intermediate representations such as mel-cepstral coefficients appropriate for statistical training of acoustic models? Can we automatically find a more appropriate intermediate representation that suits acoustic modelling and results in better quality of synthetic speech?
To answer this question, this paper proposes a DNN-based feature extraction method. More specifically we propose to use a deep denoising auto-encoder technique as a non-linear robust feature extractor for speech synthesis and apply it to high-dimensional spectral features obtained from STRAIGHT vocoder \cite{ref:Kawahara99}. We compare this data-driven, unsupervised feature extraction approach with the conventional mel-cepstral analysis, which is based on a linear discrete cosine transform of the log spectrum.
This paper is organised as follows: in Section 2, we outline related DNN-based approaches and in Section 3 we describe the proposed deep denoising auto-encoder technique. In Section 4, we mention how we train the model and the experimental conditions and evaluation results are shown in Section 5. Discussions and the summary of our findings are given in Section 6.
\section{Related work using DNN and auto-encoder}
\label{sec:related_work}
This section overviews related work using DNN and/or auto-encoder in the speech information processing field. DNN has been applied for acoustic modelling of speech synthesis. For instance \cite{ref:Zen13} uses DNN to learn the relationship between input texts and the extract features instead of decision tree-based state tying. Restricted Boltzmann machines or deep belief networks have been used for modelling output probabilities of HMM states instead of GMMs \cite{ref:Ling14}. Recurrent neural network or long-short term memory was used for prosody modelling \cite{ref:Fan14} or acoustic trajectory modelling \cite{ref:Fernandez14}.
To the best of our knowledge, this is the first work to use deep denoising auto-encoder for speech synthesis, but, deep auto-encoder based bottleneck features are used by several groups for ASR \cite{ref:Sainath12,ref:Gehring13} and deep denoising auto-encoder is also verified for noise-robust ASR \cite{ref:Maas12} or reverberant ASR tasks \cite{ref:Ishii13,ref:Feng14}.
Techniques that are closely related to this paper are a spectral binary coding approach using deep auto-encoder proposed by Deng et al \cite{ref:Deng10} and a speech enhancement approach using deep denoising auto-encoder where they try to reconstruct clean spectrum from noisy spectrum \cite{ref:Lu13}. The approach proposed here is also related to heteroscedastic linear discriminant analysis (HLDA) \cite{ref:Kumar98,ref:Gales02} and probabilistic linear discriminant analysis (PLDA) \cite{ref:Prince07,ref:Kenny10,ref:Lu14}. Our key idea is however different from these as we use deep auto-encoder based continuous bottleneck features calculated from spectrum to reconstruct high-quality synthetic speech.
\section{Auto-encoder}
\label{sec:auto-encoder}
\subsection{Basic Auto-encoder}
\label{ssec:basic_auto-encoder}
Auto-encoder is an artificial neural network that is used generally for learning a compressed and distributed representation of a dataset. It consists of the encoder and the decoder. The encoder maps a input vector $\mathbf{x}$ to a hidden representation $\mathbf{y}$ as follows:
\begin{equation}
\mathbf{y} = f_\theta(\mathbf{x}) = s(\mathbf{Wx + b}),
\end{equation}
where $\theta = \{\mathbf{W}, \mathbf{b}\}$. $\mathbf{W}$ and $\mathbf{b}$ represent a $m \times n$ weight matrix and a bias vector of dimensionality $m$ respectively, where $n$ is the dimension of $\mathbf{x}$.
The function $s$ is a non-linear transformation on the linear mapping $\mathbf{Wx+b}$. Frequently $s$ is a sigmoid, a tanh, and a relu function.
$\mathbf{y}$, the output of the encoder, is then mapped to $\mathbf{z}$, the output of the decoder.
The mapping is performed by a linear function alone that employs a $n \times m$ weight matrix $W'$ and a bias vector of dimensionality $n$ as follows:
\begin{equation}
\mathbf{z} = g_{\theta'}(\mathbf{y}) = \mathbf{W'y + b'},
\end{equation}
or a linear mapping followed by a non-linear transformation $t$,
\begin{equation}
\mathbf{z} = g_{\theta'}(\mathbf{y}) = t(\mathbf{W'y + b'}),
\end{equation}
where $\theta' = \{\mathbf{W', b'}\}$. The weight for the decoding is set as the transpose of the encoding weight \cite{ref:Hinton06} in order to allow more layers to be stacked together and be fine-tuned with stochastic gradient descend (SGD).
In general, the output $\mathbf{z}$ should be interpreted as a function of parameters $\{\theta,\theta'\}$ as $\mathbf{z} = g_{\theta'}(f_{\theta}(x))$. The parameters $\{\theta, \theta'\}$ are optimized such that the reconstructed $\mathbf{z}$ is as close as possible to the original $\mathbf{x}$ and maximizes $P(\mathbf{x|z})$. A typical loss function used is the mean square error (MSE), i.e. $L(\mathbf{x,z}) = \frac{1}{n}|\mathbf{x-z}|^2$.
\subsection{Denoising Auto-encoder}
\label{sssec:subsubhead}
The denoising auto-encoder is a variant of the basic auto-encoder. It is reported that the denoising auto-encoder can extract features more robustly than the basic auto-encoder \cite{ref:Vincent08}. In the denoising auto-encoder, the original data $\mathbf{x}$ is first corrupted to $\mathbf{\tilde{x}}$ before it is mapped to a higher representation $f_{\theta}(\mathbf{\tilde{x}})$ by an encoder.
The decoder then maps the higher representation to the output $\mathbf{z}$ for reconstructing the original $\mathbf{x}$.
The denoising auto-encoder is trained such that the reconstructed ${\mathbf{z}}$ is as close as possible to the original data ${\mathbf{x}}$. Note that it is only during training that the denoising auto-encoder is used to reconstruct the original $\mathbf{x}$ from the corrupted $\mathbf{\tilde{x}}$.
\subsection{Deep Auto-encoder}
Auto-encoder or denoisng auto-encoder can be made deeper by stacking multiple layers of encoders and decoders to form a deep architecture. \cite{ref:Yu11} shows that deeper architecture produces better high-level features compared to the shallow architecture up to 4 encoding and 4 decoding layers. For constructing a deep auto-encoder pre-training is widely used.
In pre-training, the number of layers in a deep auto-encoder increases twice as compare to a deep neural network (DNN) when stacking each pre-trained unit. It is reported that fine-tuning with back-propagation through a deep auto-encoder is ineffective due to vanishing gradients at the lower layers \cite{ref:Sepp01}. To over come this issue we restrict the decoding weight as the transpose of the encoding weight following \cite{ref:Hinton06}, that is, $\mathbf{W}'=\mathbf{W}^T$ where $\mathbf{W}^T$ denotes transpose of $\mathbf{W}$. We describe the detail of training a deep auto-encoder in the next session.
\section{Training a Deep Denoising Auto-encoder}
\subsection{Greedy Layer-wise Pre-training}
\begin{figure}[t]
\begin{center}
\includegraphics[width=8.0cm]{./images/Stacking_AEs.png}
\end{center}
\vspace{-0.5cm}
\caption{Greedy layer-wise pre-training for constructing deep auto-dencoder.}
\label{fig:Stacking_AEs}
\vspace{-5mm}
\end{figure}
Each layer of a deep auto-encoder can be pre-trained greedily to minimize the reconstruction loss $L(\mathbf{x},\mathbf{z})$ of the data locally. Figure \ref{fig:Stacking_AEs} shows a procedure of constructing a deep auto-encoder using pre-training.
In pre-training a 1-hidden-layer auto-encoder is trained and the encoding output of the locally trained layer is used as the input for the next layer.
This layer-wise training is repeated until the desired layer size is obtained.
The encoding, decoding and loss functions of each layer are represented as follows:
\begin{equation}
\begin{split}
\texttt{Layer 1:} \\
\mathbf{y}_1 &= f_{\mathbf{W}_1,\mathbf{b}_1}(\mathbf{x}), \\
\mathbf{z}_1 &= g_{\mathbf{W}'_1,\mathbf{b}'_1} (\mathbf{y}_1), \\
L(\mathbf{x},\mathbf{z}_1) &= |\mathbf{x} - \mathbf{z}_1|^2, \\
\texttt{Layer k (k>1):} \\
\mathbf{y}_k &= f_{\mathbf{W}_k,\mathbf{b}_k}(\mathbf{y}_{k-1}), \\
\mathbf{z}_k &= g_{\mathbf{W}'_k,\mathbf{b}'_k}(\mathbf{y}_k), \\
L(\mathbf{y}_{k-1},\mathbf{z}_k) &= |\mathbf{y}_{k-1} - \mathbf{z}_k|^2. \\
\end{split}
\end{equation}
Note that during the pre-training of the deep denoising auto-encoder, the input $\mathbf{x}$, $\mathbf{y}_k$ for each layer are corrupted to $\tilde{\mathbf{x}}$ and $\tilde{\mathbf{y}_k}$ respectively.
After all layers are pre-trained, all the pre-trained layers are stacked for constructing a deep denoising auto-encoder in the same way as the deep auto-encoder.
\subsection{Fine-tuning}
The purpose of fine-tuning is to minimize the reconstruction error $L(\mathbf{x,z})$ over the entire dataset and a model architecture using error back-propagation \cite{ref:Remelhart86}.
We use the mean square error (MSE) for the loss function of a deep auto-encoder and it is represented as follows:
\begin{equation}
E = \sum_{i=1}^N |\mathbf{x}^{(i)} - \mathbf{z}^{(i)}|^2,
\end{equation}
where $N$ is the total number of training examples.
The partial derivatives w.r.t weight $w_{i,j}^{(l)}$ is represented as follows:
\begin{equation}
\frac{\partial{E}}{\partial{w_{i,j}^{(l)}}} = \frac{\partial{E}}{\partial{t_j^{(l)}}} \times \frac{\partial{t_j^{(l)}}}{\partial{w_{i,j}^{(l)}}}
\end{equation}
where $t_j^{(l)}$ is the fan-in input to neuron $j$ in layer $l$, and $\frac{\partial{t_j^{(l)}}}{\partial{w_{i,j}^{(l)}}} = o_{i}^{(l-1)}$, where $o_{i}^{(l-1)}$ is the output from neuron $i$ at layer $l-1$. $\frac{\partial{E}}{\partial{t_j^{(l)}}}$ is the error transfer function which can be calculated recursively following
\begin{equation}
\frac{\partial{E}}{\partial{t_j^{(l-1)}}} = \frac{\partial{o_i^{(l-1)}}}{\partial{t_i^{(l-1)}}} \times \sum_{j=1}^{L}\frac{\partial{E}}{\partial{t_j^{(l)}}}\times \frac{\partial{t_j^{(l)}}}{\partial{o_i^{(l-1)}}}
\end{equation}
where $\frac{\partial{t_j^{(l)}}}{\partial{o_i^{(l-1)}}}=w_{i,j}^{(l)}$. For the output tanh layer we have $\frac{\partial{o_i^{(L)}}}{\partial{t_i^{(L)}}}=\text{sech}^2(t_i^{(L)})$. Once we have the gradients of error function w.r.t to the weight parameters, we can fine-tune the network with error back-propagation.
\subsection{Corrupted data}
\begin{figure}[t]
\begin{center}
\subfigure[Original]{\includegraphics[height=5.3cm]{./images/original_and_masked_spec/2696_1.png}}
\hspace{-3mm}
\subfigure[Masked]{\includegraphics[height=5.3cm]{./images/original_and_masked_spec/2696_1_mask.png}}
\end{center}
\vspace{-0.5cm}
\caption{These figures shows parts of original and masked spectra. In the right figure black points indicated masked regions.}
\label{fig:mask}
\vspace{-3mm}
\end{figure}
We used a masking technique reported in \cite{ref:Vincent08} to corrupt the training data for the denoising auto-encoder.
This technique independently and randomly set the values of the training data in different dimensions to zero following a Bernoulli distribution.
Figure \ref{fig:mask} shows an example of original and masked spectra.
In this figure, black points indicate masked regions.
\section{Evaluation}
This section shows experimental results. We have evaluated the proposed auto-encoder method in the context of analysis-by-synthesis condition and text-to-speech conditions. In the text-to-speech experiments, the synthetic voices using the proposed acoustic features were modeled using two state-of-the-art speech synthesis systems: HMM and DNN.
\subsection{Dataset}
The dataset we use consists of 4569 short audio waveforms uttered by a professional English female speaker and each waveform is around 5 seconds long. For each waveform, we first extract its frequency spectra using STRAIGHT vocoder with 2049 FFT points. We then extract the low dimensional feature from each 2049-dim STRAIGHT spectrum using autoencoder. All data was sampled at $48$ kHz. For comparison of the proposed method, we extracted mel-cepstral coefficients that use the same dimensions as that of auto-encoder. All other acoustic features such as log F0 and $25$ aperiodicity band energies are the same for all the systems.
\subsection{Configurations of the deep denoising auto-encoder}
\begin{figure}[t]
\begin{center}
\includegraphics[width=8.0cm]{./images/MSE.png}
\end{center}
\vspace{-0.5cm}
\caption{Reconstruction mean square errors for auto-encoders of different architectures but same bottleneck dimension.}
\label{fig:mse}
\vspace{-3mm}
\end{figure}
Figure \ref{fig:mse} shows the reconstruction mean square errors of auto-encoders trained on raw frequency-warped spectrum with different number of hidden layers. It shows that the error decreases with more hidden layers, and that deep auto-encoder is better than shallow auto-encoder with the same bottleneck dimension. For the results in the rest of paper, we use architecture of the auto-encoder as 2049-500-180-120 for producing the 120-dim acoustic features, tanh units for all the layers and the inputs are 2049-dim Bark-scale-based frequency-warped spectrum, which are preprocessed with global contrast normalization. The hyperparameters used for the layer-by-layer pre-training are searched randomly and the set of values that produce the best results are selected. Table \ref{tb:hyper} shows the hyperparameters for the auto-encoders used in the experiments.
\begin{table}[t]
\caption{The table lists down the hyperparameters used for training each model. lr: learning rate, m: momentum, b: batch size, s: numpy random variable weight initialization seed \cite{ref:Ilya13}, d: masking probability of each input dimension \cite{ref:Vincent08}.}
\label{tb:hyper}
\vspace{-1em}
\begin{center}
\begin{tabular}{l|c|c|c|c|c|c|c}
\cline{2-7}
& layer dim& lr & m & b & s & d &\\ \cline{1-7}
\multicolumn{1}{ |c }{\multirow{4}{*}{\begin{minipage}{0.5in}Deep auto-encoder\end{minipage}} } &
\multicolumn{1}{ |c| }{2049-500} & 0.001 & 0.9 & 200 & 8963 & N.A \\ \cline{2-7}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{500-180} & 0.01 & 0.5 & 50 & 1902 & N.A \\ \cline{2-7}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{180-120} & 0.01 & 0.9 & 50 & 6555 & N.A \\ \cline{2-7}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{Finetune} & 0.01 & 0.5 & 150 & 9781 & N.A \\ \cline{1-7}
\multicolumn{1}{ |c }{\multirow{4}{*}{\begin{minipage}{0.5in}Deep denoising auto-encoder\end{minipage}} } &
\multicolumn{1}{ |c| }{2049-500} & 0.01 & 0.1 & 150 & 5252 & 0.1 \\ \cline{2-7}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{500-180} & 0.01 & 0.5 & 150 & 7514 & 0.1 \\ \cline{2-7}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{180-120} & 0.01 & 0.9 & 100 & 594 & 0.5 \\ \cline{2-7}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{Finetune} & 0.001 & 0.9 & 100 & 2208 & N.A \\ \cline{1-7}
\end{tabular}
\end{center}
\vspace{-5mm}
\end{table}
\subsection{Analysis-by-synthesis experimental results}
First we report the analysis-by-synthesis experimental results. For this evaluation, we have divided the above database into three subsets, that is, training, validation and test. The training subset was used as training data for building the auto-encoder, the validation subset was used as a stopping criteria during training to prevent over-fitting, and the test subset was used for measuring log-spectral distortion and listening test.
Figure \ref{spectrum} shows the original and reconstructed spectra using each technique (mel-cepstral analysis, deep auto-encoder, deep denoising auto-encoder). We can clearly see that the deep auto-encoders reconstruct high-frequency parts more precisely than mel-cepstral analysis.
\begin{figure*}[t]
\begin{center}
\subfigure[Original]{\includegraphics[height=5.3cm]{./images/analysis-synthesis_reconstructed-spec/Original.png}}
\hspace{-3mm}
\subfigure[mel-cepstrum]{\includegraphics[height=5.3cm]{./images/analysis-synthesis_reconstructed-spec/MelCep-120.png}}
\hspace{-3mm}
\subfigure[deep auto-encoder]{\includegraphics[height=5.3cm]{./images/analysis-synthesis_reconstructed-spec/DeepAutoEncoder-120-warp.png}}
\hspace{-3mm}
\subfigure[deep denoising auto-encoder]{\includegraphics[height=5.3cm]{./images/analysis-synthesis_reconstructed-spec/DenoisingDeepAutoEncoder-120-warp.png}}
\end{center}
\vspace{-0.5cm}
\caption{Original and reconstructed spectra using each technique.}
\label{spectrum}
\end{figure*}
Figure \ref{fig:log_spectral_distortion} shows log spectral distortion between the original spectra and reconstructed spectra, calculated on the test subset. We can observe that the deep auto-encoder has reduced the distortion significantly compared to the mel-cepstral analysis and denoising version further reduced the distortion.
\begin{figure}[t]
\begin{center}
\includegraphics[width=6.5cm]{./images/log_spectral_distortion/120dims.png}
\end{center}
\vspace{-0.5cm}
\caption{log spectral distortion between the original and reconstructed spectra.}
\label{fig:log_spectral_distortion}
\vspace{-3mm}
\end{figure}
Figure \ref{fig:results_analysis-by-synthesis} shows subjective preference scores of these methods. The number of listeners that performed this test were seven. They have participated in two preference tests. In the first preference test, they were asked to compare deep auto-encoder (DA) with mel-cepstral analysis (MCEP). In the second preference test, they were asked to compare deep auto-encoder with deep denoising autoencoder (DDA). From the figure, we can see that deep auto-encoder based speech samples sound more natural than mel-cesptral analysis based speech samples. Deep denoising auto-encoder reduced the distortion, however, perceptual difference between clean and denoising auto-encoder is not statistically significant.
\begin{figure}[t]
\begin{center}
\includegraphics[width=8.5cm]{./images/preference_test/results_analysis-synthesis.png}
\end{center}
\vspace{-0.5cm}
\caption{Results of preference tests using analysis-by-synthesis speech samples. In this figure, MCEP, DA and DDA refer to mel-cepstrum analysis, deep auto-encoder and deep denoising auto-encoder respectively.}
\label{fig:results_analysis-by-synthesis}
\vspace{-5mm}
\end{figure}
\subsection{Text-to-speech experimental results}
Next we report the text-to-speech experimental results. For the HMM-based speech synthesis, we have used a hidden semi-Markov model and the observation vectors for the spectral and excitation parameters contained static, delta and delta-delta values, with one stream for the spectrum, three streams for F$0$ and one for the band-limited aperiodicity. The context-dependnet labels are built using the pronunciation lexicon Combilex \cite{ref:Richmond10}. For the DNN-based speech synthesis, we have trained a five-hidden-layer DNN for mapping between linguistic contexts and auto-encoder-based or mel-cepstral acoustic features. The number of units in each of the hidden layers was set to 512. Random initialisation was used in a similar way to \cite{ref:Zen13}.
\begin{figure}[t]
\begin{center}
\includegraphics[width=8.5cm]{./images/preference_test/results_text-to-speech.png}
\end{center}
\vspace{-0.5cm}
\caption{Results of preference tests using text-to-speech samples. In this figure, MCEP and DA refer to mel-cepstrum analysis and deep auto-encoder for the acoustic feature extraction, and HMM and DNN are the acoustic models.}
\label{fig:results_tts}
\end{figure}
Figure \ref{fig:results_tts} shows subjective preference scores where we have compared the proposed auto-encoder feature with the conventional mel-cepstral feature in each of the HMM-based speech synthesis and the DNN-based speech synthesis systems. Listeners are the same as those for Figure \ref{fig:results_analysis-by-synthesis}. We can see that synthetic speech using the proposed feature sound more natural than the conventional mel-cepstral features in both the synthesis methods. The proposed feature seems to suit the DNN-based speech synthesis better, but, this requires further investigation.
\section{Conclusions}
In this paper we have proposed the deep denoising auto-encoder technique to extract better acoustic features for speech synthesis. We have compared the new stochastic feature extractor with the conventional mel-cepstral analysis in the analysis-by-synthesis and text-to-speech experiments and have confirmed that the proposed method can increase the quality of synthetic speech in both the conditions.
Our future work includes the improvement of the deep denoising auto-encoder. In this paper, we have used the simplest noise, i.e. masking and the improvement was observed only from objective evaluation. We shall use or design different types of noises to improve the deep denoising auto-encoder for speech synthesis further.
\vfill
\pagebreak
\nocite{ref:Bergstra12}
\nocite{ref:Xue14}
\nocite{ref:Remelhart86}
\input{output.bbl}
\end{document}
|
{'timestamp': '2015-06-18T02:12:01', 'yymm': '1506', 'arxiv_id': '1506.05268', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05268'}
|
arxiv
|
\section{Introduction}
In this paper we consider $d$-dimensional vectors of non-negative integers $\mathbb{N}$.
A vector $v$ \emph{dominates} vector $w$ if on each coordinate of $v$ is bigger or equal than $w$.
Sequence of vectors $v_1, v_2, \ldots$ is \emph{non-dominating} if there is no pair $v_i$, $v_j$
with $i < j$ such that $v_j$ dominates $v_i$.
Dickson has shown in~\cite{Dickson} that there is no infinite non-dominating sequence of vectors.
However, they can be arbitrarily long even when starting from a fixed vector, for example:
$(1, 0), (0, n), (0, n-1), \ldots, (0, 1), (0,0)$.
Figueira et al.~\cite{DBLP:conf/lics/FigueiraFSS11} and McAllon~\cite{DBLP:journals/tcs/McAloon84} have considered
sequences of vectors from $\mathbb{N}^d$ which fulfill some given restriction.
A possible restriction can be described by a function $f : \mathbb{N} \to \mathbb{N}$ such that for all $i$,
all coordinates of the $i$-th vector in the sequence do not exceed $f(i)$.
For different families of functions authors deliver different maximal lengths of non-dominating sequences,
however even for very restricted sequences bounds are non primitive recursive.
A problem stated in~\cite{DBLP:conf/wia/Zimmermann09} and~\cite{DBLP:conf/atva/HornTW08} concerns
games, but it can be formulated in terms of such sequences.
Authors consider a game on a finite graph with special vertices - request and response vertices.
The following condition is added to the objective of a game:
whenever a request vertex of type $k$ is visited, an response vertex of type $k$ has to be reached in the future of the play.
A \emph{summary} in such a play consists of:
\begin{itemize}
\item(1) a position in the graph
\item(2) waiting time since first unanswered request for each type of (vector part).
\end{itemize}
Authors of~\cite{DBLP:conf/wia/Zimmermann09} and~\cite{DBLP:conf/atva/HornTW08} want to determine which player has a winning strategy.
They have shown that there is a winning strategy which depends only on the summary.
Moreover only strategies for which vector part is a non-dominating sequence can be considered.
Hence, an upper bound on length of such sequences would give an upper bound on the complexity of the mentioned game.
It motivates investigations of an effective variant of Dickson's Lemma where for each vector
each coordinate can be either
\begin{itemize}
\item reset to $0$ (as a result of visiting a response vertex); or
\item increased by $1$ (waiting phase)
\end{itemize}
with respect to the same coordinate in the preceding vector.
So far only single exponential lower bound and doubly exponential upper bound were known.
This paper is devoted to present and explain a doubly exponential lower bound.
\section{Notation and definitions}
As mentioned above we consider $d$-dimensional vectors.
In each step, every coordinate can be either reset to 0 or incremented.
For two coordinate values $a, b \in \mathbb{N}$, we say that $a \rightarrow b$ iff
either $b=a+1$ or $b=0$.
By $v^\ell_i \in \mathbb{N}$ we denote the value of the $\ell$-th coordinate after $i$ steps.
By $v^\ell$ we denote the sequence of values (i.e., the history) of the $\ell$-th coordinate, and
by $v_i \in \mathbb{N}^d$ we denote the $i$-th vector in the sequence (state of the whole
system after $i$ steps).
For two vectors $v,w \in \mathbb{N}^d$, we say that $v \rightarrow w$ iff $v^\ell \rightarrow w^\ell$ for each $\ell$.
We say that a sequence of vectors of length $n$ is \emph{valid}
iff $v_i \rightarrow v_{i+1}$ for each $i < n-1$. Moreover, we say that a sequence of
vectors is \emph{cyclic} iff it is valid and $v_{n-1} \rightarrow v_0$.
For two vectors $v,w \in \mathbb{N}^d$, we write $v \leq w$ iff for each coordinate $\ell$ we have $v^\ell \leq w^\ell$.
Otherwise, we write $v \not\leq w$.
Thus a valid sequence $(v_i)$ is non-dominating iff whenever $i < j$ we have $v_i \not\leq v_j$.
Let $L_d$ be the maximum length of a non-dominating valid sequence for the given $d$.
In this paper, we show the double exponential lower bound for $L_d$.
\section{Main Idea}
In this section we present the main idea behind our solution.
Let us first consider an easier variant, where we allow coordinates to stay unchanged in the two
consecutive vectors. It is easy to obtain an exponential lower bound -- just encode a binary counter. We start with number $111\ldots11_2$ and count down to $000\ldots00_2$.
For example:
\vskip 0.3cm
$ \begin{matrix}
1&1&1&1&0&0&0&0 \\
1&1&0&0&1&1&0&0 \\
1&0&1&0&1&0&1&0
\end{matrix}
$
\vskip 0.3cm
Because we count down it is easy to see that there is no dominating pair of vectors.
Note that the same implementation of binary counter works when we disallow fixing coordinates.
\vskip 0.3cm
$ \begin{matrix}
1&2&3&4&0&0&0&0 \\
1&2&0&0&1&2&0&0 \\
1&0&1&0&1&0&1&0
\end{matrix}
$
\vskip 0.3cm
The main idea behind the double exponential sequence is to encode counters with higher basis.
However, a problem appears: we cannot decrease a coordinate.
It was irrelevant in case of binary counter - decreasing from $1$ to $0$ is just a reset.
Here induction shows up. When we want to decrease a coordinate in the bigger counter $B$
we reset it and wait until it grows to the appropriate value.
In the same time a counter $S$ with smaller base is launched.
Roughly speaking, because $S$ is decreasing while coordinates of $B$ are growing up
there is no dominating pair during a growing period.
\section{Overview}
\defL^\circ{L^\circ}
Let $L^\circ_d$ be the maximum length of a non-dominating {\bf cyclic} sequence for the given $d$;
obviously $L_d \geq L^\circ_d$. For example, the following sequence of four vectors shows that $L^\circ_2 \geq 4$:
\[
(1,1), (0,2), (1,0), (0,0)
\]
We will show that $L^\circ_{d+2} \geq L^\circ_d (2L^\circ_d+1)$. This is done by looping the
$d$ coordinates, and adding two new coordinates in a way which makes the
whole long sequence non-dominating.
These two new coordinates are meant to implement something like a counter of base $2n-1$.
By repeating this several times we get a double exponential
lower bound for $L^\circ_d$, and also for $L_d$.
As an additional verification, we have also implemented our construction in C++.
Source code available at:
\begin{center}
\verb|http://www.mimuw.edu.pl/~erykk/papers/vecseq.cpp|
\end{center}
\section{Construction}
\begin{theorem} $L^\circ_{d+2} \geq L^\circ_d (2L^\circ_d+1)$
\label{step}
\end{theorem}
\begin{proof}
Let $(u_0, \ldots, u_{n-1})$ be a non-dominating cyclic sequence of length $n$ and dimension
$d$.
We construct a sequence $(v_0, \ldots, v_{m-1})$ of length $m=n(2n+1)$ and dimension $d+2$.
For convenience, we name the two new coordinates $X$ and $Y$; therefore, $X_k = v^{d+1}_k$
and $Y_k = v^{d+2}_k$. The construction is as follows:
\begin{itemize}
\item (1) $v_{k}^{\ell} = u_{k \bmod n}^{\ell} $ for $\ell \leq d, 0 \leq k < m$
\item (2) $X_{2ni+j} = \max(j-i, 0)$ for $0 \leq j < 2n, 0 \leq 2ni+j < m$
\item (3) $Y_{k} = X_{(k+n) \bmod m}$ for $0 \leq k < m$
\end{itemize}
We will show that this sequence is indeed a non-dominating cyclic sequence.
The following table shows the evolution of the two new coordinates.
\vskip 0.3cm
\[
\begin{array}{c|ccccc|cccc}
j & 0 & 1 & 2 & \ldots & n-1 & n & n+1 & \ldots & 2n-1 \\
\hline
X_j & 0 & 1 & 2 & \ldots & n-1 & n & n+1 & \ldots & 2n-1 \\
Y_j & n & n+1 & n+2 & \ldots & 2n-1 & 0 & 0 & \ldots & n-2 \\
\hline
X_{2n+j} & 0 & 0 & 1 & \ldots & n-2 & n-1 & n & \ldots & 2n-2 \\
Y_{2n+j} & n-1 & n & n+1 & \ldots & 2n-2 & 0 & 0 & \ldots & n-3 \\
\hline
X_{4n+j} & 0 & 0 & 0 & \ldots & n-3 & n-2 & n-1 & \ldots & 2n-3 \\
Y_{4n+j} & n-2 & n-1 & n & \ldots & 2n-3 & 0 & 0 & \ldots & n-4 \\
\hline
\vdots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots \\
\hline
X_{2n(n-1)+j} & 0 & 0 & 0 & \ldots & 0 & 1 & 2 & \ldots & n \\
Y_{2n(n-1)+j} & 1 & 2 & 3 & \ldots & n & 0 & 0 & \ldots & 0 \\
\hline
X_{2n^2+j} & 0 & 0 & 0 & \ldots & 0 &&&& \\
Y_{2n^2+j} & 0 & 1 & 2 & \ldots & n-1 &&&&
\end{array}
\]
\vskip 0.3cm
We will start by showing that the sequence $v^\ell$ is cyclic for each $\ell$.
For $\ell \leq d$, the sequence $v^\ell$ is simply $u^\ell$ repeated $2n+1$ times.
Since $u^\ell$ is cyclic, $v^\ell$ is cyclic too. We also need to check the coordinates
$X$ and $Y$.
For the coordinate $X$, we need to verify three cases:
\begin{itemize}
\item $X_{2ni+j} \rightarrow X_{2ni+j+1}$, where $2ni+j+1 < m$, follows immediately
from the formula (2) for $j \neq 2n-1$.
\item $X_{m-1} \rightarrow X_0$ because $X_{0} = 0$.
\item $X_{2ni+(2n-1)} \rightarrow X_{2n(i+1)}$ because
$X_{2n(i+1)} = \max(0 - (i+1), 0) = 0$.
\end{itemize}
The sequence $Y$ is a cyclic shift of $X$. We already know that
$X$ is cyclic, so $Y$ is cyclic too.
Now, we need to show that our cyclic sequence is non-dominating:
whenever $a < b$, we have $v_a \not\leq v_b$.
If $a \bmod n < b \bmod n$, we know that
$u_{a \bmod n} \not\leq u_{b \bmod n}$. Since $u_{a \bmod n}$ is a part of $v_a$, and
$u_{b \bmod n}$ is a part of $v_b$, we get that $v_a \not\leq v_b$.
Now, suppose that $a \bmod n \geq b \bmod n$.
Let $a = 2ni_a + j_a$, and $b = 2ni_b + j_b$, where $0 \leq j_a, j_b < 2n$.
Since $j_a$ can be less than $n$ or not, and $j_b$ can be less than $n$ or not,
there are four cases, in each one we easily show that $v_a \not\leq v_b$.
\begin{itemize}
\item $j_a, j_b <n$, $j_a \geq j_b$, and $i_a < i_b$. In this case we have $Y_a = n + j_a - i_a
> n + j_b - i_b = Y_b$.
\item $j_a, j_b \geq n$, $j_a \geq j_b$, and $i_a < i_b$. In this case we have $X_a = j_a - i_a
> j_b - i_b = X_b$.
\item $j_a \geq n$, $j_b < n$, $j_a - n \geq j_b$, and $i_a < i_b$. In this case we have
$X_a = j_a - i_a > n+(j_a-n) - i_a > n + j_b - i_b \geq \max(n + j_b - i_b, 0) = X_b$.
\item $j_a < n$, $j_b \geq n$, $j_a + n \geq j_b$, and $i_a \leq i_b$. In this case we have
$Y_a = n + j_a - i_a \geq j_b - i_b > \max((j_b - n) - i_b, 0) = Y_b$, where the last inequality follows
from the fact that $j_b > i_b$.
\end{itemize}
This completes the proof.
\end{proof}
\begin{theorem} $L_d \geq L^\circ_d \geq 2^{3 \cdot 2^{\lfloor d/2 \rfloor-1}-1}$ for $d \geq 2$.
\end{theorem}
\begin{proof}
Obviously $L_d \geq L^\circ_d$ and $L^\circ_{d+1} \geq L^\circ_d$. Therefore,
it is enough to show the claim for $d=2c$.
For $c=1$ we have $L^\circ_{2c} \geq 4$, which satisfies the formula.
For $c+1$ we apply Theorem \ref{step} and the induction hypothesis:
\[L^\circ_{2c+2} \geq L^\circ_{2c} (2L^\circ_{2c} + 1) \geq 2 (2^{3 \cdot 2^{c-1}-1})^2 =
2^{3 \cdot 2^{(c+1)-1}-1}\]
\end{proof}
\bibliographystyle{plain}
|
{'timestamp': '2015-08-04T02:15:16', 'yymm': '1506', 'arxiv_id': '1506.05279', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05279'}
|
arxiv
|
\section{Introduction}
Compositional data are non-negative multivariate data and each vector sums to the same constant, usually $1$ for convenience. Compositional data are met in many disciplines, including geology \citep{ait1982}, economics \citep*{fry2000}, archaeology \citep{baxter2005} and political sciences \citep{rodrigues2009}. Their sample space is called simplex $S^d$ and in mathematical terms is
\begin{footnotesize}
\begin{eqnarray*}
S^d=\left\lbrace(x_1,...,x_D)^T \bigg\vert x_i \geq 0,\sum_{i=1}^Dx_i=1\right\rbrace,
\end{eqnarray*}
\end{footnotesize}
where $D$ denotes the number of components and $d=D-1$.
Ever since \citet{ait1982} suggested the use of the log-ratio transformation for compositional data, most of the analyses of such data have been implemented using this transformation. \citet{ait2003} implemented linear discriminant analysis for compositional data using the log-ratio transformation. Over the years though, researchers have suggested alternative ways for supervised classification of compositional data, see for example \citet{gallo2010} and \citet{neocleous2011}.
An important issue in compositional data is the presence of zeros, which cause problems for the logarithmic transformation. The issue of zero values in some components is not addressed in most papers, but see \citet{neocleous2011} for an example of discrimination in the presence of zeros. Alternatively, one could use alternative models (see for example \citealp{scealy2011a} and \citealp{stewart2011}) or replace the zero values by making parametric assumptions \citep{martin2012}.
In this paper we suggest the use of a recently developed metric, for classification of compositional data, when the $k$-nearest neighbours ($k$-NN) algorithm is implemented. It is a metric for probability distributions \citep{endres2003, osterreicher2003} which can be adopted to compositional data as well, since each vector sums to $1$. The second metric we suggest is the Manhattan metric, a scaled version of which has already been used for compositional data analysis \citep{miller2002}. We will extend both of these metrics by applying a power transformation. We will see that both of these metrics handle zeros naturally and hence they can be used regardless of them being present in some components. This is a very attractive feature of these metrics in contrast to the Aitchisonian metric suggested by \citet{ait2003} which is not applicable when zeros are present in the data. Examples using real data are used to illustrate the performance of these metrics.
Section 2 describes the two metrics, how they can be extended and also presents graphically their loci of points equidistant from the centre of the simplex. Section 3 shows the $k$-NN algorithm for compositional data and Section 4 contains examples using real data. Finally, section 5 concludes this paper.
\section{Metrics for compositional data}
We will present three metrics for compositional data ,two of which have already been examined. But first we will show the power transformation.
\citet{ait2003} defined the power transformation to be
\begin{footnotesize}
\begin{eqnarray} \label{alpha}
{\bf u}=\left( \frac{x_1^{\alpha}}{\sum_{j=1}^Dx_j^{\alpha}}, \ldots, \frac{x_D^{\alpha}}{\sum_{j=1}^Dx_j^{\alpha}} \right)^T.
\end{eqnarray}
\end{footnotesize}
The value of $\alpha$ will be determined by the estimated accuracy of the $k$-NN algorithm.
\subsection{The ES-OV$_\alpha$ metric for compositional data}
We advocate that as a measure of the distance between two compositions we can use the square root of the Jensen-Shannon divergence
\begin{footnotesize}
\begin{eqnarray} \label{ESOV}
ES-OV({\bf x},{\bf w})=\left[ \sum_{i=1}^D\left( x_i\log{\frac{2x_i}{x_i+w_i}}+w_i\log{\frac{2w_i}{x_i+w_i}} \right) \right]^{1/2},
\end{eqnarray}
\end{footnotesize}
where ${\bf x}, {\bf w} \in S^d$.
\citet{endres2003} and \citet{osterreicher2003} proved, independently, that (\ref{ESOV}) satisfies the triangular identity and thus it is a metric. For this reason we will refer to it as the ES-OV metric.
We will use the power transformation (\ref{alpha}) to define a more general metric termed ES-OV$_{\alpha}$ metric
\begin{footnotesize}
\begin{eqnarray} \label{ESOVa}
ES-OV_{\alpha}({\bf x},{\bf w})=\left[ \sum_{i=1}^D\left( \frac{x^{\alpha}_i}{\sum_{j=1}^Dx^{\alpha}_j}
\log{\frac{2\frac{x^{\alpha}_i}{\sum_{j=1}^Dx^{\alpha}_j}}{\frac{x^{\alpha}_i}{\sum_{j=1}^Dx^{\alpha}_j}+
\frac{w^{\alpha}_i}{\sum_{j=1}^Dw^{\alpha}_j}}}+
\frac{w^{\alpha}_i}{\sum_{j=1}^Dw^{\alpha}_j}\log{\frac{2\frac{w^{\alpha}_i}{\sum_{j=1}^Dw^{\alpha}_j}}{\frac{x^{\alpha}_i}{\sum_{j=1}^Dx^{\alpha}_j}+\frac{w^{\alpha}_i}{\sum_{j=1}^Dw^{\alpha}_j}}} \right) \right]^{1/2}.
\end{eqnarray}
\end{footnotesize}
\subsection{The taxicab$_{\alpha}$ metric for compositional data}
The taxicab metric is also known as $L_1$ (or Manhattan) metric and is defined as
\begin{footnotesize}
\begin{eqnarray} \label{taxicab}
TC\left({\bf x},{\bf w}\right)=\sum_{i=1}^D\left| x_i-w_i \right|
\end{eqnarray}
\end{footnotesize}
We will again employ the power transformation (\ref{alpha}) to define a more general metric which we will term the TC$_{\alpha}$ metric
\begin{footnotesize}
\begin{eqnarray} \label{taxicaba}
TC_{\alpha}\left({\bf x},{\bf w}\right)=\sum_{i=1}^D\left| \frac{x^{\alpha}_i}{\sum_{j=1}^Dx^{\alpha}_j}-
\frac{w^{\alpha}_i}{\sum_{j=1}^Dw^{\alpha}_j} \right|
\end{eqnarray}
\end{footnotesize}
\subsection{The Aitchisonian metric for compositional data}
\citet{ait2003} suggested the Euclidean metric applied to the log-ratio transformed data as a measure of distance between compositions
\begin{footnotesize}
\begin{eqnarray} \label{dist}
Ait\left({\bf x},{\bf w}\right)=\left[\sum_{i=1}^D\left(\log{\frac{x_i}{g\left({\bf x}\right)}}-\log{\frac{w_i}{g\left({\bf w}\right)}} \right)^2 \right]^{1/2},
\end{eqnarray}
\end{footnotesize}
where $g\left({\bf z} \right)=\prod_{i=1}^Dz_i^{1/D}$ stands for the geometric mean.
\subsection{Some comments}
The power transformed compositional vectors still sum to $1$ and thus the ES-OV$_{\alpha}$ (\ref{ESOVa}) is still a metric. It becomes clear that when $\alpha=1$ we end up with the ES-OV metric (\ref{ESOV}). If on the other hand $\alpha=0$, then the distance is zero, since the compositional vectors become equal to the centre of the simplex. An advantage of the ES-OV$_{\alpha}$ metric (\ref{ESOVa}) over the Aitchisonian metric (\ref{dist}) is that the the first one is defined even when zero values are present. In this case the Aitchisonian metric (\ref{dist}) becomes degenerate and thus cannot be used. We have to note that we need to scale the data so that they sum to $1$ in the case of the ES-OV metric, but this is not a requirement of the taxicab metric.
Alternative metrics could be used as well, such as
\begin{enumerate}
\item the Hellinger metric \citep{owen2001}
\begin{footnotesize}
\begin{eqnarray*}
H\left({\bf x},{\bf w}\right)=\frac{1}{\sqrt{2}}\left[\sum_{i=1}^D\left(\sqrt{x_i}-\sqrt{w_i}\right)^2\right]^{1/2}
\end{eqnarray*}
\end{footnotesize}
\item or the angular metric if we treat compositional data as directional data (for more information about this approach see \citet{stephens1982} and \citet{scealy2011b, scealy2012})
\begin{footnotesize}
\begin{eqnarray*}
Ang\left({\bf x},{\bf w}\right)=\arccos{\left(\sum_{i=1}^Dx_iw_i\right)}
\end{eqnarray*}
\end{footnotesize}
\end{enumerate}
\citet{ait1992} argued that a simplicial metric should satisfy certain properties. These properties include
\begin{enumerate}
\item \textit{Scale invariance}. The requirement here is that the measure used to define the distance between two compositional data vectors should be scale invariant, in the sense that it makes no difference whether the compositions are represented by proportions or percentages.
\item \textit{Subcompositional dominance}. To explain this we consider two compositional data vectors and we select sub-vectors from each consisting of the same components. Subcompositional dominance means that the distance between the sub-vectors is always less than or equal to the distance between the original compositional vectors.
\item \textit{Perturbation invariance}. The requirement here is that the distance between compositional vectors ${\bf x}$ and ${\bf w}$ should be the same as distance between ${\bf x}\oplus_0{\bf p}$ and ${\bf w}\oplus_0{\bf p}$, where the operator $\oplus_0$ means element-wise multiplication and then division by the sum so that the resulting vectors belong to $S^d$ and ${\bf p}$ is any vector (not necessarily compositional) with positive components.
\end{enumerate}
If all of the above metrics satisfy or not these thee properties should not be a problem. Take for example subcompositional dominance. If someone has a compositional dataset, there has to be a good reason why he would choose to discard some components and form a sub-composition. And even if he does, all the metrics are still applicable.
The message this paper tries to convey is that if someone uses a well defined metric (or even a dissimilarity measure) in order to perform classification he should be fine with that. When dealing with data lying on the Euclidean space, one can use dissimilarity measures as well to perform clustering or discrimination. The question of interest is how can we discriminate the observed groups of points as adequately as possible.
\subsection{Loci of points equidistant from the centre of the simplex}
Figure \ref{fig1} shows the effect of the power transformation (\ref{alpha}) on the data. As expected, the data come closer to the barycentre of the triangle as $\alpha$ tends to zero. The data used and plotted on Figure \ref{fig1} are the Arctic lake data \citep{ait2003}. Figures \ref{fig2} and \ref{fig3} show the plots of loci of points of the ES-OV$_{\alpha}$ metric (\ref{ESOVa}) and of the TC$_{\alpha}$ metric (\ref{taxicaba}) for different values of $\alpha$ and Figure \ref{fig4} shows the contour plots of the Aitchisonian metric (\ref{dist}). In all cases, the plots of loci of points refer to the distance from the barycentre of the simplex. The loci of points seen on Figure \ref{fig2} have similar shape regardless of the value of $\alpha$. This is not true for the loci in Figure \ref{fig3}, which change as the value of $\alpha$ changes.
\begin{figure}[!ht]
\centering
\begin{tabular}{ccc}
\includegraphics[scale=0.28,trim=0 20 0 20]{a1.eps} &
\includegraphics[scale=0.28,trim=0 20 0 20]{a2.eps} &
\includegraphics[scale=0.28,trim=0 20 0 20]{a3.eps} \\
\footnotesize{(a)} & \footnotesize{(b)} & \footnotesize{(c)} \\
\includegraphics[scale=0.28,trim=0 20 0 20]{a4.eps} &
\includegraphics[scale=0.28,trim=0 20 0 20]{a5.eps} &
\includegraphics[scale=0.28,trim=0 20 0 20]{a6.eps} \\
\footnotesize{(d)} & \footnotesize{(e)} & \footnotesize{(f)}
\end{tabular}
\caption{Ternary plots of the Arctic lake data \citep{ait2003} for different values of $\alpha$. The data are transformed calculated using (a) $\alpha=-1$, (b) $\alpha=-0.5$, (c) $\alpha=-0.1$, (d) $\alpha=0.1$, (e) $\alpha=0.5$ and (f) $\alpha=1$.}
\label{fig1}
\end{figure}
\begin{figure}[!ht]
\centering
\begin{tabular}{ccc}
\includegraphics[scale=0.27,trim=0 20 0 20]{b1.eps} &
\includegraphics[scale=0.27,trim=0 20 0 20]{b2.eps} &
\includegraphics[scale=0.27,trim=0 20 0 20]{b3.eps} \\
\footnotesize{(a)} & \footnotesize{(b)} & \footnotesize{(c)} \\
\includegraphics[scale=0.27,trim=0 20 0 20]{b4.eps} &
\includegraphics[scale=0.27,trim=0 20 0 20]{b5.eps} &
\includegraphics[scale=0.27,trim=0 20 0 20]{b6.eps} \\
\footnotesize{(d)} & \footnotesize{(e)} & \footnotesize{(f)}
\end{tabular}
\caption{Loci of points equidistant from the centre of the simplex using the ESOV$_{\alpha}$ metric (\ref{ESOVa}). In all cases the distances are from the barycentre of the simplex $\left(1/3,1/3,1/3\right)$. The contours are calculated using (a) $\alpha=-1$, (b) $\alpha=-0.5$, (c) $\alpha=-0.1$, (d) $\alpha=0.1$, (e) $\alpha=0.5$ and (f) $\alpha=1$.}
\label{fig2}
\end{figure}
\begin{figure}[!ht]
\centering
\begin{tabular}{ccc}
\includegraphics[scale=0.27,trim=0 20 0 20]{c1.eps} &
\includegraphics[scale=0.27,trim=0 20 0 20]{c2.eps} &
\includegraphics[scale=0.27,trim=0 20 0 20]{c3.eps} \\
\footnotesize{(a)} & \footnotesize{(b)} & \footnotesize{(c)} \\
\includegraphics[scale=0.27,trim=0 20 0 20]{c4.eps} &
\includegraphics[scale=0.27,trim=0 20 0 20]{c5.eps} &
\includegraphics[scale=0.27,trim=0 20 0 20]{c6.eps} \\
\footnotesize{(d)} & \footnotesize{(e)} & \footnotesize{(f)} \\
\end{tabular}
\caption{Loci of points equidistant from the centre of the simplex using the TC$_{\alpha}$ metric (\ref{taxicaba}). In all cases the distances are from the barycentre of the simplex $\left(1/3,1/3,1/3\right)$. The contours are calculated using (a) $\alpha=-1$, (b) $\alpha=-0.5$, (c) $\alpha=-0.1$, (d) $\alpha=0.1$, (e) $\alpha=0.5$ and (f) $\alpha=1$.}
\label{fig3}
\end{figure}
\begin{figure}[!ht]
\centering
\includegraphics[scale=0.35,trim=0 20 0 20]{c.eps}
\caption{Loci of points equidistant from the centre of the simplex using the Aitchisonian metric (\ref{dist}).}
\label{fig4}
\end{figure}
\section{Supervised classification for compositional data using the $k$-NN algorithm}
The goal of this paper is to perform supervised classification of compositional data using the $k$-NN algorithm. For this reason we will use the ES-OV$_{\alpha}$ (\ref{ESOVa}) and TC$_{\alpha}$ (\ref{taxicaba}) metrics and compare their performance and suitability with the Aitchisonian metric metric (\ref{dist}).
The $k$-NN algorithm is a non-parametric supervised learning technique which is computationally heavier than quadratic and linear discriminant analysis but easier to implement as it relies solely on metrics between points.
Similarly to other supervised classification techniques it requires some parameter tuning. The two parameters associated with it in our case are the power parameter $\alpha$ and the number of nearest neighbours $k$. We describe the steps of the $k$-NN for compositional data in our case.
\begin{enumerate}
\item Separate the data into the training and the test dataset.
\item Choose a value of $k$, the number of nearest neighbours.
\item Classify the test data using either the ES-OV$_{\alpha}$ (\ref{ESOVa}), the TC$_{\alpha}$ (\ref{taxicaba}) for a range of values of $\alpha$ and each time calculate the percentage of correct classification.
\item Repeat steps $2-3$ for a different value of $k$.
\item Repeat steps $1-4$ B (in our case $B=200$) times and for each $\alpha$ and $k$ and estimate the percentage of correct classification by averaging over all B times.
\end{enumerate}
We can of course use the Aitchisonian metric (\ref{dist}) instead of the ES-OV$_\alpha$ (\ref{ESOVa}) or the TC$_{\alpha}$ metric (\ref{taxicaba}). In this case we have to choose the number of nearest neighbours only, since no power transformation is involved. We could of course use any other metric defined in $R^d$. In this case we would have to apply the additive log-ratio transformation \citep{ait2003} to the data. The issue in that case though would be the presence of zeros in the data.
In the next section we will see two examples using real data and see the performance of the algorithm when each of the two metrics is used.
\subsection{Examples using real data}
We will now see the performance of the $k$-NN algorithm using the ES-OV$_\alpha$ metric (\ref{ESOVa}), the TC$_{\alpha}$ metric and the Aitchisonian metric (\ref{dist}) with real data.
\subsubsection*{\textit{Example 1. Hydrochemical data with no zero values}}
The first dataset comes from hydrochemistry. A hydrochemical data set \citep{otero2005} contains measurements on $14$ elements. the data were gathered within a period of $2$ years from $31$ stations located along the rivers and main tributaries of the Llobregat river, one of the medium rivers in northeastern Spain. Each of these elements is measured approximately once each month during these $2$ years. There are $4$ tributaries of interest, Anoia ($143$ measurements), Cardener ($95$ measurements), Upper Llobregat ($135$ measurements) and Lower Llobregat ($112$ measurements). Thus, there are $485$ across all $4$ tributaries.
This dataset contains no zero values, so all three metrics are applicable. The size of the training sample was equal to $434$ and thus the test sample consisted of $51$ observations, which were sampled using stratified random sampling each time to ensure that observations from all tributaries are selected every time. Figure \ref{fig5} shows the heat plot of the estimated percentage for different values of $k$ and $\alpha$.
\begin{figure}[!ht]
\centering
\begin{tabular}{cc}
\includegraphics[scale=0.45,trim=0 20 0 20]{d1.eps} &
\includegraphics[scale=0.45,trim=0 20 0 20]{d2.eps} \\
\footnotesize{(a)} & \footnotesize{(b)} \\
\end{tabular}
\caption{The estimated percentage of correct classification for the hydrochemical data as a function of $k$, the nearest neighbours and of $\alpha$ using the (a) ES-OV$_{\alpha}$ metric (\ref{ESOVa}) and (b) TC$_{\alpha}$ (\ref{taxicaba}).}
\label{fig5}
\end{figure}
\begin{figure}[!ht]
\centering
\includegraphics[scale=0.45,trim=0 20 0 20]{d3.eps}
\caption{The estimated percentage of correct classification as a function of $k$. The black and the red lines are based on the ES-OV$_{\alpha}$ metric (\ref{ESOVa}) with $\alpha=0.5$ and $\alpha=1$ respectively. The green and the blue lines are based on the TC$_{\alpha}$ metric (\ref{taxicaba}) with $\alpha=0.35$ and $\alpha=1$ respectively. The turquoise line is the Aitchisonian metric (\ref{dist}).}
\label{fig6}
\end{figure}
If $\alpha=0.5$ and $k=2$ the estimated percentage percentage of correct classification is equal to $92.78\%$ and when $\alpha=1$ and $k=3$ the estimated percentage is $89.88\%$ when the ES-OV$_{\alpha}$ metric (\ref{ESOVa}) was applied. When the TC$_{\alpha}$ metric (\ref{taxicaba}) is applied the results are similar, with $\alpha=0.35$ and $k=2$ the estimated percentage of correct classification is $93.77\%$ and when $\alpha=1$ and $k=2$, the estimated percentage of correct classification is $86.55\%$. This is an example where a value of $\alpha$ other than $1$ leads to better results. The change in the percentage might seem small, but if we take into account the total sample size, we will see that the $3\%$ of $485$ observations is $14$ observations and it is not a small number. The Aitchisonian metric on the other hand did not do that well. The maximum estimated percentage was equal to $85.46\%$ when $k=2$.
More information (including the specificities and sensitivities for each tributary averaged over all $200$ replications) regarding the classification results is presented in Table \ref{tab1} below. A general conclusion about the mean sensitivities and specificities is that the lower sensitivities are observed when the estimated percentage of correct classification is lower and they have also larger standard errors. The mean specificities on the other hand are in general high and are less affected by the estimated percentage of correct classification.
\begin{table}[h]
\begin{small}
\begin{center}
\begin{tabular}{ccccc} \hline
\multicolumn{5}{c}{{\bf ES-OV$_{\alpha}$ metric}} \\ \hline
Tuning parameters & Percentage of & Tributaries & Sensitivities & Specificities \\
& correct classification & & & \\ \hline
$\alpha=0.5$ \& k=2 & $92.78\%$ ($3.25\%$) & Anoia & $95.77\%$($4.92\%$) & $98.60\%$($2.14\%$) \\
& & Cardener & $85.25\%$($10.65\%$) & $97.06\%$($2.32\%$) \\
& & Upper Llobregat & $93.93\%$($6.07\%$) & $97.58\%$($2.34\%$) \\
& & Lower Llobregat & $94.00\%$($6.48\%$) & $97.24\%$($2.37\%$) \\ \hline
$\alpha=1$ \& k=3 & $89.88\%$ ($3.96\%$) & Anoia & $93.57\%$($5.92\%$) & $97.17\%$($2.83\%$) \\
& & Cardener & $82.10\%$($12.82\%$) & $96.13\%$($2.83\%$) \\
& & Upper Llobregat & $91.50\%$($7.42\%$) & $96.42\%$($2.84\%$) \\
& & Lower Llobregat & $89.88\%$($8.39\%$) & $96.85\%$($2.63\%$) \\ \hline \hline
\multicolumn{5}{c}{{\bf TC$_{\alpha}$ metric}} \\ \hline
Tuning parameters & Percentage of & Tributaries & Sensitivities & Specificities \\
& correct classification & & & \\ \hline
$\alpha=0.35$ \& k=2 & $93.77\%$ ($3.13\%$) & Anoia & $96.73\%$($4.58\%$) & $98.60\%$($1.83\%$) \\
& & Cardener & $87.80\%$($10.28\%$) & $97.66\%$($2.24\%$) \\
& & Upper Llobregat & $94.18\%$($5.86\%$) & $97.85\%$($2.30\%$) \\
& & Lower Llobregat & $94.58\%$($6.18\%$) & $97.65\%$($2.24\%$) \\ \hline
$\alpha=1$ \& k=2 & $86.55\%$ ($4.71\%$) & Anoia & $90.03\%$($7.41\%$) & $95.99\%$($3.52\%$) \\
& & Cardener & $79.70\%$($13.45\%$) & $96.56\%$($2.66\%$) \\
& & Upper Llobregat & $85.54\%$($8.84\%$) & $95.95\%$($3.12\%$) \\
& & Lower Llobregat & $89.08\%$($9.47\%$) & $93.58\%$($3.69\%$) \\ \hline \hline
\multicolumn{5}{c}{{\bf Aitchisonian metric}} \\ \hline
& Percentage of & Tributaries & Sensitivities & Specificities \\
& correct classification & & & \\ \hline
& $85.46\%$ ($5.07\%$) & Anoia & $87.40\%$($8.63\%$) & $96.25\%$($2.94\%$) \\
& & Cardener & $77.65\%$($12.68\%$) & $95.91\%$($2.86\%$) \\
& & Upper Llobregat & $89.89\%$($7.69\%$) & $93.95\%$($3.75\%$) \\
& & Lower Llobregat & $84.38\%$($9.88\%$) & $94.49\%$($3.72\%$) \\ \hline \hline
\end{tabular}
\caption{Classification results for the hydrochemical data. The number inside the parentheses indicates the standard error of the percentages.}
\label{tab1}
\end{center}
\end{small}
\end{table}
In addition we calculated the ROC curves for each of the three metrics. In order to do this we performed a $1$-fold cross validation. That is, we removed an observation and then using the parameters $\alpha$ and $k$ which are given in Table \ref{tab1} (since they produced the best results) we classified it. This procedure was repeated for all observations. Thus, we ended up with the predicted membership values for all observations based on the 3 metrics. This allowed us to draw the ROC curves for each tributary when all 3 metrics were used. The results are presented in Figure \ref{roc1}.
We can see that for all tributaries the ROC curves of the ES-OV$_{\alpha}$ metric (\ref{ESOVa}) and the TC$_{\alpha}$ metric (\ref{taxicaba}) are similar, whereas the ROC curve of the Aitchisonian metric (\ref{dist}) is always the lowest.
\begin{figure}[!ht]
\centering
\begin{tabular}{cc}
\includegraphics[scale=0.37,trim=0 20 0 20]{roc1.eps} &
\includegraphics[scale=0.37,trim=0 20 0 20]{roc2.eps} \\
\footnotesize{(a)} & \footnotesize{(b)} \\
\includegraphics[scale=0.37,trim=0 20 0 20]{roc3.eps} &
\includegraphics[scale=0.37,trim=0 20 0 20]{roc4.eps} \\
\footnotesize{(c)} & \footnotesize{(d)} \\
\end{tabular}
\caption{ROC curves for all tributaries using the three metrics For ES-OV$_{\alpha}$ we used $\alpha=0.35$ and $k=2$ and for TC$_{\alpha}$ we used $\alpha=0.5$ and $k=2$. For Each plot corresponds to one of the four tributaries (a) Anoia, (b) Cardener, (c) Upper Llobregat and (d) Upper Llobregat.}
\label{roc1}
\end{figure}
\subsubsection*{\textit{Example 2. Forensic glass data with zero values}}
In the second example we will use the forensic glass dataset which has $214$ observations from $6$ different categories of glass with $8$ chemical elements, in percentage form. The categories which occur are containers ($13$ observations), vehicle headlamps ($29$ observations), tableware ($9$ observations), vehicle window glass ($17$ observations), window float glass ($70$ observations) and window non-float glass ($76$ observations). This dataset contains a large number of zeros as well, thus excluding LRA from being applied here. The data are available from the \href{http://archive.ics.uci.edu/ml/datasets/Glass+Identification}{UC Irvine Machine Learning Repository}.
An interesting feature of this dataset is that it contains many zero values. This means that the Aitchisonian metric (\ref{dist}) is not to be used. The ES-OV$_{\alpha}$ and the TC$_{\alpha}$ metrics on the other hand are not affected by the presence of zeros, since $0\log0=0$. In this example the sample size of the test data was equal to $30$, hence we used $184$ compositional vectors to train the $k$-NN algorithm. Again, the test data were chosen via stratified random sampling to avoid having categories not been selected in the test sample. Figure \ref{fig7} shows the estimated percentage as a function of $k$ and $\alpha$ using both metrics.
\begin{figure}[!ht]
\centering
\begin{tabular}{cc}
\includegraphics[scale=0.45,trim=0 20 0 20]{d4.eps} &
\includegraphics[scale=0.45,trim=0 20 0 20]{d5.eps} \\
\footnotesize{(a)} & \footnotesize{(b)}
\end{tabular}
\caption{The estimated percentage of correct classification for the forensic glass data as a function of $k$, the nearest neighbours and of $\alpha$ using the (a) ES-OV$_{\alpha}$ metric (\ref{ESOVa}) and (b) TC$_{\alpha}$ (\ref{taxicaba}).}
\label{fig7}
\end{figure}
This is a simpler case to draw conclusions, since the best results are obtained when $\alpha=1$ and $k=2$ for both metrics, thus the ES-OV (\ref{ESOV}) and the TC (\ref{taxicab}) metrics should be used, with the estimated percentage of correct classification being $71.45\%$ and $73.35\%$ respectively. Table \ref{tab2} presents analytical information of the classification results. Estimates of the sensitivities and of the specificities for each category of glass are also given.
The mean sensitivities of ES-OV$_{\alpha}$ metric (\ref{ESOVa}) for Tableware and Vehicle window are low and the same is true for the Vehicle window when TC$_{\alpha}$ (\ref{taxicaba}) is used. We observed that many times, Tableware and Vehicle window were being wrongly classified as Vehicle float. A possible reason for this could be the small sample size of Tableware (this type of glass had the minimum number of observations). A chemist or a forensic scientist could perhaps give a possible answer to this (if that is the case of these types of glass being of similar structure).
\begin{table}[h]
\begin{small}
\begin{center}
\begin{tabular}{ccccc} \hline
\multicolumn{5}{c}{{\bf ES-OV$_{\alpha}$}} \\ \hline
Tuning parameters & Percentage of & Glass & Sensitivities & Specificities \\
& correct classification & categories & & \\ \hline
$\alpha=1$ \& k=3 & $71.45\%$ ($7.76\%$) & Containers & $77.25\%$($29.57\%$) & $97.46\%$($2.76\%$) \\
& & Vehicle headlamps & $80.88\%$($16.99\%$) & $96.44\%$($3.60\%$) \\
& & Tableware & $36.50\%$($48.26\%$) & $96.95\%$($3.00\%$) \\
& & Vehicle window & $29.25\%$($31.81\%$) & $97.50\%$($2.97\%$) \\
& & Vehicle float & $81.65\%$($11.60\%$) & $82.30\%$($7.28\%$) \\
& & Non-window float & $68.55\%$($13.39\%$) & $90.50\%$($6.30\%$) \\ \hline \hline
\multicolumn{5}{c}{{\bf TC$_{\alpha}$}} \\ \hline
Tuning parameters & Percentage of & Glass & Sensitivities & Specificities \\
& correct classification & categories & \\ \hline
$\alpha=1$ \& k=3 & $73.35\%$ ($8.00\%$) & Containers & $77.75\%$($30.37\%$) & $98.18\%$($2.43\%$) \\
& & Vehicle headlamps & $82.62\%$($16.66\%$) & $99.15\%$($1.77\%$) \\
& & Tableware & $74.50\%$($43.70\%$) & $98.14\%$($2.70\%$) \\
& & Vehicle window & $29.75\%$($31.74\%$) & $95.48\%$($3.71\%$) \\
& & Vehicle float & $77.90\%$($12.58\%$) & $82.10\%$($7.52\%$) \\
& & Non-window float & $72.86\%$($14.45\%$) & $90.11\%$($6.99\%$) \\ \hline \hline
\end{tabular}
\caption{Classification results for the forensic glass data. The number inside the parentheses indicates the standard error of the percentages.}
\label{tab2}
\end{center}
\end{small}
\end{table}
The ROC curves for each glass category (based on $1$-fold cross validation) using both metrics are presented in Figure \ref{roc2}. We cannot say that one metric does better than the other always. For some glass categories, the two ROC curves are similar and for some others one seems a bit better than the other.
\begin{figure}[!ht]
\centering
\begin{tabular}{ccc}
\includegraphics[scale=0.33,trim=0 20 0 20]{foc1.eps} &
\includegraphics[scale=0.33,trim=0 20 0 20]{foc2.eps} &
\includegraphics[scale=0.33,trim=0 20 0 20]{foc3.eps} \\
\footnotesize{(a)} & \footnotesize{(b)} & \footnotesize{(c)} \\
\includegraphics[scale=0.33,trim=0 20 0 20]{foc4.eps} &
\includegraphics[scale=0.33,trim=0 20 0 20]{foc5.eps} &
\includegraphics[scale=0.33,trim=0 20 0 20]{foc6.eps} \\
\footnotesize{(d)} & \footnotesize{(e)} & \footnotesize{(f)}
\end{tabular}
\caption{ROC curves for all tributaries using the three metrics In all cases $\alpha=1$ and $k=3$ were used in both metrics. Each plot corresponds to one of the six glass categories (a) containers, (b) vehicle headlamps, (c) tableware, (d) vehicle window glass, (e) window float glass and (f) window non-float glass.}
\label{roc2}
\end{figure}
\section{Conclusions}
We suggested the use of a recently developed metric (\ref{ESOV}), for supervised classification when the $k$-NN algorithm is implemented. We also added a free parameter to the metric with the intention of improving the classification results. This free parameter was used to generalize the taxicab metric as well. The examples showed that both the ES-OV$_{\alpha}$ (\ref{ESOVa}) and the taxicab$_{\alpha}$ (\ref{taxicaba}) metric can be used for supervised clustering of compositional data, but can also be used in other scenarios as well.
An advantage of both metrics over the Aitchisonian metric (\ref{dist}) is that they handle zeros naturally. This implies that no zero value replacement is necessary either parametrically \citep{martin2012} or non parametrically \citep{ait2003}. In order to appreciate the importance of this advantage one can think of large datasets with many zeros.
The two metrics outbalanced the Aitchisonian metric (\ref{dist}) in the examples presented in this manuscript. When it comes to comparing the the ES-OV$_{\alpha}$ (\ref{ESOVa}) and the taxicab$_{\alpha}$ (\ref{taxicaba}) metric between them we cannot say one is better than the other.
A closer examination of the ROC curves revealed valuable information, especially for the FGL data example (where zeros are present) regarding the classification abilities of the ES-OV$_{\alpha}$ (\ref{ESOVa}) and the taxicab$_{\alpha}$ (\ref{taxicaba}) metric. The sensitivities and specificities revealed interesting patterns of the misclassification rates not captured by the percentage of correct classification. In addition, the ROC curves provided graphical evidence as for the ability of each metric to classify the observations.
\section*{Acknowledgements}
The author would like to acknowledge the anonymous referee for pointing out very interesting details.
\newpage
|
{'timestamp': '2015-06-18T02:09:28', 'yymm': '1506', 'arxiv_id': '1506.05216', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05216'}
|
arxiv
|
\section{Introduction}
In recent years Interactive Theorem Provers (ITPs) have been
successfully used to give an ultimate degree of reliability to both
complex software systems, like the L4 micro
kernel~\cite{Klein:2010:SFV:1743546.1743574} and the CompCert C
compiler~\cite{Leroy-Compcert-CACM}, and mathematical theorems, like
the Odd Order Theorem~{\cite{gonthier:hal-00816699}}. These large
formalization projects have pushed interactive provers to their
limits, making their deficiencies apparent.
The one we deal with in this work is {\emph{reactivity}}: how long it
takes for the system to react to a user change and give her feedback on
her point of interest. For example if one takes the full proof of the
Odd Order Theorem, makes a change in the first file and asks the
Coq prover for any kind of feedback on the last file she has to wait
approximately two hours before receiving any feedback.
To find a solution to this problem it is important to understand how
formal documents are edited by the user and checked by the prover.
Historically ITPs have come with a simple text based Read Eval Print
Loop (REPL) interface: the user inputs a command, the system runs it
and prints a report. It is up to the user to stock the right sequence
of commands, called script, in a file. The natural evolution
of REPL user interfaces adds a very basic form of script
management on top of a text editor: the user writes his commands
inside a text buffer and tells the User Interface (UI) to send them one by
one to the same REPL interface. This
design
is so cheap, in terms of
coding work required on the prover side, and so generic that its best
incarnation, Proof General~{\cite{DBLP:conf/tacas/Aspinall00}}, has
served as the reference UI for many provers, Coq included, for over a
decade.
The simplicity of REPL comes at a price: commands must be executed in a linear
way, one after the other. For example the prover must tell the UI if
a command fails or succeeds before the following command can be sent
to the system. Under such constraint to achieve better reactivity one
needs to speed up the execution of each and every command composing
the formal document. Today one would probably do that by taking
advantage of modern, parallel hardware. Unfortunately it is very hard
to take an existing system coded in a imperative style and parallelize
its code at the fine grained level of single commands. Even more if
the programming language it is written in does not provide light
weight execution threads. Both conditions apply to Coq.
If we drop the constraint imposed by the REPL, a different,
complementary, way to achieve better reactivity becomes an option:
process the formal document \emph{out-of-order},\footnote{In analogy
with the ``out-of-order execution'' paradigm used in
most high-performance microprocessors} giving precedence to
the parts the user is really interested in and postpone the others.
In this view, even if commands do not execute faster, the system needs
to execute fewer of them in order to give feedback to the user. In
addition to that, when the parts the document is split in happen to be
independent, the system can even process them in parallel.
Three ingredients are crucial to process a formal document out-of-order.
First, the UI must not impose to the prover to run commands linearly.
A solution to this problem has been studied by Wenzel
in~\cite{DBLP:journals/corr/Wenzel13} for the Isabelle
system. His approach consists in
replacing the REPL with an \emph{asynchronous interaction loop}: each
command is marked with a unique identifier and each report generated
by the prover carries the identifier of the command to which it applies.
The user
interface sends the whole document to the prover and uses these unique
identifiers to
present the prover outputs coherently to the
user. The asynchronous interaction loop developed by Wenzel is part
of a generic middleware called PIDE (for Prover IDE) that we extend
with a Coq specific back end.
Second, the prover must be able to perform a \emph{static analysis of
the document} in order to organize it into coarse grained tasks and
take scheduling decisions driven by the user's point of
interest. Typically a task is composed of many consecutive commands.
In the case of Coq a task corresponds to the sequence of tactics,
proof commands, that builds an entire proof. In other words the text between
the \tmverbatim{Proof} and \tmverbatim{Qed} keywords.
Third, the system must feature an \emph{execution model} that allows
the reordering of tasks. In particular we model tasks as pure
computations and we analyze the role their output plays in the checking
of the document. Finally we implement the machinery required in order
to execute them in parallel by using the coarse grained concurrency
provided by operating system processes.
In this work we completely redesigned from the ground up
the way Coq processes a formal document
in order to obtain the three
ingredients above. The result is a more reactive system that also
performs better at checking documents in batch mode. Benchmarks show
that the obtained system is ten times more reactive when processing
the full proof of the Odd Order Theorem and that it scales better when
used on parallel hardware. In particular fully checking such proof on
a twelve core machine is now four times faster than before. Finally,
by plugging Coq in the PIDE middleware we get a modern user interface
based on the jEdit editor that follows the ``spell checker paradigm''
made popular by tools like Eclipse or Visual Studio: the user
freely edits the document and the prover constantly annotates it with
its reports, like underlining in red problematic sentences.
The work of
Wenzel~\cite{Wenzel_parallelproof,DBLP:conf/mkm/Wenzel11,DBLP:journals/corr/Wenzel13,Wenzel14} on the
Isabelle system has laid the foundations for our design, and has been
a great inspiration for this work. The design and implementation work
spanned over three years and the results are part of version 8.5 of
the Coq system. All authors were supported by the Paral-ITP
ANR-11-INSE-001 project.
The paper is organized as follows. Section~\ref{document} describes
the main data structure used by the prover in order to statically
analyze the document and represent the resulting tasks.
Section~\ref{futures} describes how asynchronous, parallel,
computations are modeled in the logical kernel of the system and how
they are implemented in the OCaml programming language.
Section~\ref{pide} describes how the document is represented on the UI
side, how data is aggregated and presented to the user.
Section~\ref{12core} presents a reactivity benchmark of the redesigned
system on the full proof of the Odd Order Theorem.
Section~\ref{conclusions}
concludes.
\section{Processing the formal document out-of-order}\label{document}
Unlike REPL in the asynchronously interaction model promoted by
PIDE~\cite{DBLP:journals/corr/Wenzel13}
the prover is made aware of the whole document and it is expected to process
it giving precedence to the portion of the text the user is looking at. To do
so the system must identify the parts of the document that are not relevant to
the user and postpone their processing. The most favorable case is when large
portions of the document are completely independent from each other, and hence
one has complete freedom on the order in which they must be processed. In the specific
case of Coq, {\emph{opaque proofs}} have this property. Opaque proofs are the
part of the document where the user builds a proof evidence (a proof
term in
Coq's terminology) by writing a sequence of tactics and that ends with the
\tmverbatim{Qed} keyword (lines four to seven in Figure~\ref{dag}). The
generated proof term is said to be opaque because it is verified
by the kernel of the system and stored on disk, but the term is never
used, only its corresponding statement (its type) is. The user can ask the
system to print such term or to translate it to OCaml code, but from the
viewpoint of the logic of Coq (type theory) the system commits not to use the
proof term while checking other proofs.{\footnote{In the Curry-Howard
correspondence Coq builds upon lemmas and definitions are the same: a
term of a given type. An opaque lemma is a definition one cannot unfold.}}
The notion of proof opacity was introduced a long ago in Coq version 5.10.5
(released in May 1994) and is crucial for us: given that the proof term is not
used,
we can postpone the processing of the piece of the
document that builds it as much as we want. All we need is its type, that is
the statement that is spelled out explicitly by the user. Proofs are also
lengthy and usually the time spent in processing them dominates the overall
time needed in order to check the entire document. For example in the
case of the Odd Order Theorem proofs amount to 60\% of the non-blanks
(3.175KB over 5.262KB) and Coq spends 90\% of its time on them. This means
that, by properly scheduling the processing of opaque proofs, we can increase
the reactivity of the system of a factor of ten. In addition to that, the
independence of each proof from the others makes it possible to process many
proofs at the same time, in parallel, giving a pretty good occasion to exploit
modern parallel hardware.
In the light of that, it is crucial to build an internal representation for
the document that makes it easy to identify opaque proofs.
Prior to this work Coq had no
internal representation of the document at all. To implement the
\tmverbatim{Undo} facility, Coq has a notion of {\emph{system state}} that
can can be saved and restored on demand. But the system used to keep no trace
of how a particular system state was obtained; which sequence of commands
results in a particular system state.
The most natural data structure for keeping track of how a system state is
obtained is a Directed Acyclic Graph (DAG), where nodes are system states and
edges are labeled with commands. The general idea is that in order to obtain a
system state from another one, one has to process all the commands on the edges
linking the two states. The software component in charge of building and
maintaining such data structure is called State Transaction Machine (STM),
where the word transaction is chosen to stress that commands need to be
executed atomically: there is no representation for a partially
executed command.
\subsection{The STM and the static analysis of the document}\label{static}
\begin{figure}[!tb]
\begin{lstlisting}
1 (* global *) Definition decidable (P : Prop) := P \/ ~ P.
2
3 (* branch *) Theorem dec_False : decidable False.
4 (* tactic *) Proof.
5 (* tactic *) unfold decidable, not.
6 (* tactic *) auto.
7 (* merge $~$*) Qed.
\end{lstlisting}
\begin{center}
\includegraphics[width=0.9\textwidth]{sample.png}
\end{center}
\caption{\label{dag}Coq document and its internal representation}
\end{figure}
The goal of the static analysis of the document is to build a DAG in which
proofs are explicitly separated from the rest of the document. We first parse
each sentence
obtaining the abstract syntax tree of the corresponding
command in order to classify it. Each command belongs to only one of the
following categories: commands that start a proof ({\emph{branch}}), commands
that end a proof ({\emph{merge}}), proof commands ({\emph{tactic}}), and
commands that have a global effect ({\emph{global}}). The DAG is built in the
very same way one builds the history of a software project in a version
control system. One starts with an initial state and a default branch, called
master, and proceeds by adding new commits for each command. A commit is a new
node and an edge pointing to the previous node. Global commands add the commit
on the main branch; branching commands start a new branch; tactic commands add
a commit to the current branch; merging commands close the current branch by
merging it into master. If we apply these simple rules to the document in
Figure~\ref{dag} we obtain a DAG where the commands composing the proof of
\tmverbatim{dec\_False} have been isolated. Each node is equipped with a unique
identifier, here positive numbers. The edge from the state six to state five
has no label, it plays the role of making the end of the proof easily
accessible but has not to be ``followed'' when generating state six.
Indeed to compute state six, or anything that follows it,
Coq starts from the initial state, zero, and then executes the labeled
transactions until it reaches state six, namely
``\tmverbatim{Definition}\ldots'',
``\tmverbatim{Theorem}\ldots'' and \tmverbatim{Qed}.
The nodes in gray (1, 2 and 6) are the ones whose
corresponding system state has been computed. The nodes and transactions in
the dotted region compose the proof that is processed asynchronously.
As a consequence of that the implementation of the
merging command has to be able to accommodate the situation where the proof
term has not been produced yet. This is the subject of Section~\ref{futures}.
For now the only relevant characteristic of the asynchronous processing of
opaque proofs is that such process is a pure computation.
The result of a pure computation does depend only on its input. It
does not
matter when it
is run nor in which environment and it has no visible global effect. If we are
not immediately interested in its result we can execute it lazily,
in parallel or even remotely via the network.
Tactic commands are not allowed to appear outside a proof; on the contrary
global commands can, an in practice do, appear in the middle of proofs, as in
Figure~\ref{dag2}. Mixing tactics with global commands is not a recommend
style for finished proof scripts, but it is a extremely
common practice while one
writes the script and it must be supported by the system. The current
semantics of Coq documents makes the effect of global commands appearing in
the middle of proofs persist outside proof blocks (hence the
very similar documents in Figure~\ref{dag} and Figure~\ref{dag2}
have a different semantics).
This is what naturally
happens if the system has a single, global, imperative state that is updated
by the execution of commands. In our scenario the commands belonging to opaque
proofs may even be executed remotely, hence a global side effect is
lost. To preserve the current semantics of documents, when a global command is
found in the middle of a proof its corresponding transaction is placed in the
DAG twice: once in the proof branch at its original position, and another time
on the master branch. This duplication is truly necessary: only the
transaction belonging to the master branch will retain its global effect; the
one in the proof branch, begin part of a pure computation, will have a local
effect only. In other words the effect of the ``\lstinline/Hint/\ldots''
transaction from state 3 to 4
is limited to states 4 and 5.
\begin{figure}[!h]
\begin{lstlisting}
1 (* global *) Definition decidable (P : Prop) := P \/ ~ P.
2
3 (* branch *) Theorem dec_False : decidable False.
4 (* tactic *) Proof.
5 (* global *) Hint Extern 1 => unfold decidable, not.
6 (* tactic *) auto.
7 (* merge $~$*) Qed.
\end{lstlisting}
\begin{center}
\includegraphics[width=0.9\textwidth]{sample2.png}
\end{center}
\caption{\label{dag2}Coq document and its internal representation}
\end{figure}
Branches identifying opaque proofs also define compartments from which errors
do not escape. If a proof contains an error one can replace such proof by
another one, possibly a correct one, without impacting the rest of the
document. As long as the statement of an opaque proof does not change,
altering the proof does not require re-checking what follows it in the document.
\section{Modelling asynchronously computed proofs}\label{futures}
The logical environment of a prover contains the statements of the theorems
which proof has already been checked. In some provers, like Coq, it also
contains the proof evidence, a proof term. A theorem enters the logical
environment only if its proof evidence has been checked. In our scenario the
proof evidences may be produced asynchronously, hence this condition has to be
relaxed, allowing a theorem to be part of the environment before its proof is
checked. Wenzel introduced the very general concept of proof
promise~\cite{Wenzel_parallelproof} in the core logic of Isabelle for this
precise purpose.
\subsection{Proof promises in Coq}
Given that only opaque proofs are processed asynchronously we can
avoid introducing in the theory of Coq the generic notion of a
sub-term asynchronously produced. The special status of opaque
proofs spares us to change the syntax of the terms and lets us
just act on the logical environment and the Well Founded (WF)
judgement. The relevant rules for the WF judgements, in
the presentation style of~\cite{compact}, are the following ones.
We took the freedom to omit some details, like $T$ being a well
formed type, that play no role in the current discussion.
\begin{center}
\AxiomC{$E \vdash$ WF $\quad E \vdash b : T \quad d$ fresh in $E$}
\UnaryInfC{$E \cup (\mbox{\textbf{definition }} d : T := b) \vdash$ WF}
\DisplayProof
~
\AxiomC{$E \vdash$ WF $\quad E \vdash b : T \quad d$ fresh in $E$}
\UnaryInfC{$E \cup (\mbox{\textbf{opaque }} d : T ~|~ b) \vdash$ WF}
\DisplayProof
\end{center}
Note that the proof evidence $b$ for opaque proofs is checked but
not stored in the environment as the body of non-opaque definitions.
After an opaque proof enters the environment, it shall behave exactly
like an axiom.
\begin{center}
\AxiomC{$E \vdash$ WF $\quad d$ fresh in $E$ }
\UnaryInfC{$E \cup (\mbox{\textbf{axiom }} d : T) \vdash$ WF}
\DisplayProof
\end{center}
We rephrase the WF judgement as the combination of
two new judgements: Asynchronous and Synchronous Well Founded (AWF and
SWF respectively).
The former is used while the user interacts with the system.
The latter complements the former when the complete
checking of the document is required.
\begin{center}
\AxiomC{$E \vdash$ AWF $\quad E \vdash b : T \quad d$ fresh in $E$}
\UnaryInfC{$E \cup (\mbox{\textbf{definition }} d : T := b) \vdash$ AWF}
\DisplayProof
~
\vspace{1.2em}
\AxiomC{$E \vdash$ AWF $\quad d$ fresh in $E$}
\UnaryInfC{$E \cup (\mbox{\textbf{opaque }} d : T ~|~ [f]_E) \vdash$ AWF}
\DisplayProof
\AxiomC{$E \vdash$ SWF}
\UnaryInfC{$E \cup (\mbox{\textbf{definition} } d \!:\! T := b ) \vdash$ SWF}
\DisplayProof
~
\vspace{1.2em}
\AxiomC{$E \vdash$ SWF $\quad b = $ run $f$ in $E \quad E \vdash b \!:\! T$}
\UnaryInfC{$E \cup (\mbox{\textbf{opaque} } d \!:\! T ~|~ [f]_E) \vdash$ SWF}
\DisplayProof
\AxiomC{$E \vdash $ AWF}
\AxiomC{$E \vdash $ SWF}
\BinaryInfC{$E \vdash $ WF}
\DisplayProof
\end{center}
The notation $[f]_E$ represents a pure computation in the environment
$E$ that eventually produces a proof evidence $b$.
The implementation of the two new judgements amounts to replace the
type of opaque proofs (\lstinline/term/) with a function type
(\lstinline/environment -> term/) and impose that such computation is
pure.
In practice the commitment of Coq to not use the proof terms of
theorems terminated with \tmverbatim{Qed} makes it possible to run
these computations when it is more profitable. In our implementation
this typically happens in the background.
As anticipated the Coq system is coded using the
imperative features provided by the OCaml language quite pervasively.
As a result we cannot simply rely on the regular
function type (\lstinline/environment -> term/)
to model pure computations, since the code
producing proof terms is not necessarily pure. Luckily the
\tmverbatim{Undo} facility lets one backup the state of the system and
restore it, and we can use this feature to craft our own, heavyweight,
type of pure
computations. A pure computation $c_0$ pairs a function $f$ with the
system state it should run in $s_0$ (that includes the logical
environment). When $c_0$ is executed, the
current system state $s_c$ is saved, then $s_0$ in installed and $f$
is run. Finally the resulting value $v$ and resulting state $s_1$
are paired in the resulting computation $c_1$, and the original state
$s_c$ is restored. We need to save $s_1$ only if the computation $c_1$
needs to be chained with additional impure code. A
computation producing a proof is the result of chaining few impure
functions with a final call to the kernel's type checker that is a
\emph{purely functional} piece of code. Hence the final system state is
always discarded, only the associated value (a proof term) is
retained.
The changes described in this section
enlarged the size of the trusted code base of Coq
by less than 300 lines (circa 2\% of its previous size).
\subsection{Parallelism in OCaml}
The OCaml runtime has no support
for shared memory and parallel thread execution, but provides
inter process communication facilities like sockets and data
marshaling.
Hence the most natural way to exploit parallel hardware is to split
the work among different worker processes.
While this approach imposes a clean message passing discipline, it may
clash with the way the state of the system is represented and stocked.
Coq's
global state is unstructured and fragmented: each software
module can hold some private
data and must register a pair of functions to take a snapshot and restore an
old backup to a central facility implementing the \tmverbatim{Undo}
command.
Getting a snapshot of the system state is hence possible, but marshalling it
and sending it to a worker process is still troublesome. In particular the
system state can contain a lot of unnecessary data, or worse data that
cannot be sent trough a channel (like a file descriptor) or even data one does
not want to send to a precise worker, like the description of the tasks he is
not supposed to perform.
Our solution to this problem is to extrude from the system state the unwanted
data, put a unique key in place of it and finally associate via a separate
table the data to the keys. When a
system state is sent to a worker process the keys it contains lose validity,
hence preventing the worker process to access the unwanted data.
The only remaining problem is that, while when a system state becomes
unreferenced it is collected by the OCaml runtime, the key-value table still
holds references to a part of that system state. Of course we want the
OCaml runtime to also collect such data. This can be achieved by making the
table ``key-weak'', in the sense that the references it holds to its keys do
not prevent the garbage collector from collecting them and that when this
happens the corresponding data has also to be collected. Even if the OCaml
runtime does not provide such notion of weak table natively, one can easily
code an equivalent finalization mechanism
known as \emph{ephemeron}
(key-value) pairs~\cite{Hayes:1997:ENF:263698.263733}
by attaching to the keys a custom finalization function.
\begin{figure}[!h]
\begin{center}
\includegraphics[width=0.7\textwidth]{ephemeron.png}
\end{center}
\caption{Reorganization of the prover state}
\end{figure}
\subsection{The asynchronous task queue and the quick compilation
chain}\label{sepcomp}
The STM maintains a structured
representation of the document the prover is processing, identifies
independent tasks and delegates them to worker processes.
Here we focus on the interaction between Coq and the pool of
worker processes.
The main kind of tasks identified by the STM is the one of opaque proofs we
discussed before, but two other tasks are also supported. The first one is
queries: commands having no effect but for producing a human readable output.
The other one is tactics terminating a goal applied to a set of goals via the
``\tmverbatim{par:}'' goal selector.{\footnote{The ``\tmverbatim{par:}'' goal
selector is a new feature of Coq 8.5 made possible by this work}} In all cases
the programming API for handling a pool of worker processes is the
\tmverbatim{AsyncTaskQueue},
depicted Figure~\ref{asyncqueue}. Such data structure, generic
enough to accommodate the three aforementioned kind of tasks, provides a priority
queue in which tasks of the same kind can be enqueued. Tasks will eventually
be picked up by a worker manager (a cooperative thread in charge of a
specific worker process), turned into requests and sent to the
corresponding worker.
\begin{figure}[h]
\begin{lstlisting}
module type Task = sig
type task
type request
type response
val request_of_task : [ `Fresh | `Old ] -> task -> request option
val use_response : task -> response -> [ `Stay | `Reset ]
val perform : request -> response
end
module MakeQueue(T : Task) : sig
val init : max_workers:int -> unit
val priority_rel : (T.task -> T.task -> int) -> unit
val enqueue_task : T.task -> cancel_switch:bool ref -> unit
val dump : unit -> request list
end
module MakeWorker(T : Task) : sig
val main_loop : unit -> unit
end
\end{lstlisting}
\caption{\label{asyncqueue}Programming API for asynchronous task queues}
\end{figure}
By providing a description of the task, i.e. a module implementing the
\tmverbatim{Task} interface, one can obtain at once the corresponding queue
and the main function for the corresponding workers. While the
\tmverbatim{task} datatype can, in principle, be anything,
\tmverbatim{request} and \tmverbatim{response} must be marshalable since they
will be exchanged between the master and a worker processes.
\tmverbatim{request\_of\_task} translates a \tmverbatim{task} into a
\tmverbatim{request} for a given worker. If the worker is an \tmverbatim{`Old}
one, the
representation of the request can be lightweight, since the worker can save
the context in which the tasks take place and reuse it (for example
the proof context is the same for each goal to which the
\tmverbatim{par:} goal selector applies). Also a \tmverbatim{task},
while waiting in the
queue, can become obsolete, hence the option type. The worker
manager calls \tmverbatim{use\_response} when a response is received, and
decides whether the worker has to be reset or not. The \tmverbatim{perform}
function is the code that is run in the worker. Note that when a task is
enqueued a handle to cancel the execution if it becomes outdated
is given. The STM will flip that bit eventually, and the worker manager will
stop the corresponding worker.
This abstraction is not only valuable because it hides to the programmer all
the communication code (socket, marshalling, error handling) for the three
kinds of tasks. But also because
it enables a new form of separate {\emph{quick compilation}} (batch document
checking) that splits such job into two steps. A first and quick one that
essentially amounts at checking everything but the opaque proofs and
generates an (incomplete) compiled file, and a second one that completes
such file. An incomplete file,
extension \tmverbatim{.vio}, can already be used: as we pointed out before the
logic of Coq commits not to use opaque proofs, no matter if they belong to the
current file or to another one.
Incomplete \tmverbatim{.vio} files can be completed into the usual
\tmverbatim{.vo} files later on, by resuming the
list of requests also saved in the
\tmverbatim{.vio} file.
The trick is to set the number of workers to zero when the queue is
initialized. This means that no task is processed at all when the document is
checked. One can then \tmverbatim{dump} the contents of the queue in terms of
a
list of requests (a marshalable piece of data) and stock it in
the \tmverbatim{.vio} files. Such lists represents all the tasks
still to be performed in order to check the opaque proofs of the document.
The performances of the quick compilation chain are assessed in
Section~\ref{12core}.
\section{The user side}\label{pide}
A prover can execute commands out-of-order only if the user can
interact with it asynchronously. We need an interface that
systematically gives to the prover the document the user is working on
and declares where the user is looking at to help the system take
scheduling decisions. This way the UI also frees the user
from the burden of explicitly sending a portion of its text buffer to
the prover. Finally this interface needs to be able to interpret the
reports the prover generates in no predictable order, and display them
to the user.
An UI like this one makes the user experience in editing a formal
document way closer to the one he has when editing a regular document
using a mainstream word processor: he freely edits the text while the
system performs ``spell checking'' in the background, highlighting in
red misspelled words. In our case it will mark in red illegal
proof steps. Contextual information, like the current goal being
proved, is displayed according to the position of the cursor. It is
also natural to have the UI aggregate diverse kinds of feedbacks on
the same piece of text. The emblematic example is the full names of
identifiers that are displayed as an hyperlink pointing to the place
where the identifier is bound.
\subsection{PIDE and its document model}
To integrate user interfaces with asynchronous provers in a uniform
way, Wenzel developed the PIDE middleware~{\cite{DBLP:journals/corr/Wenzel13}}.
This middleware consists of a number of API functions in a frontend
written in the Scala programming language,
that have an effect on a prover backend. The front-, and backend together
maintain a shared data structured, PIDE's notion of a \emph{document}.
Figure~\ref{fig:Architecture} depicts how the front and backend collaborate
on the document, and its various incarnations. The portions of the figure in
dark red represent parts of PIDE that were implemented to integrate Coq into
the PIDE middleware.
\begin{figure}[h]
\begin{center}
\includegraphics[width=0.9\textwidth]{arch_pidedoc.png}
\end{center}
\caption{PIDE sitting between the prover and the UI\label{fig:Architecture}}
\end{figure}
This document has a very simple, prover-independent, structure: it is a flat
list of spans. A span is the smallest portion of text in which the
document is chopped by a prover specific piece of code. In the case of Coq it
corresponds to a full command.
The frontend exposes an \emph{update} method on the
document, which allows an interface to notify the prover of changes. The
second functionality of the document on the frontend is the ability to query
the document for any markup attached to the command spans. This markup is
provided by the prover, and is the basis for the rich feedback we describe in
Section~\ref{sec:RichFeedback}.
The simple structure of the document keeps the frontend ``dumb'', which makes it
easy to integrate a new prover in PIDE: for Coq, this only required
implementing a parser that can recognize, chop, command spans (around
120 lines of Scala code) and a way to start the
prover and exchange data with it (10 more lines).
The prover side of this communication is further
described in Section~\ref{sec:PIDETop}, which also describes the
representation of the document text in the PIDE backend for Coq.
The way an interface uses the PIDE document model is by updating it with new
text, and then reacting to new data coming from the prover, transforming it in
an appropriate way. For example, Coq can report the abstract syntax tree (AST)
of each command in the proof document, which the interface can use to provide
syntax highlighting which is not based on error-prone regular expressions.
Beyond the regular interface services, the information can also be used to
support novel interactions with a proof document. In the case of an AST, for
example, the tree can be used to support refactoring operations
robustly.
\subsection{Pidetop}\label{sec:PIDETop}
Pidetop is the toplevel loop that runs on the Coq side and translates
PIDE's protocol messages into instructions for the STM. Pidetop
maintains an internal representation of the shared document. When its
update function is invoked, the toplevel updates the internal document
representation, inserting and deleting command phrases where
appropriate. The commands that are considered as new by pidetop are
not only those that have changed but also those that follow: because
the client is dumb, it does not know what the impact of a change is.
Instead it relies on the statical analysis the STM performs to
determine this.
Finally PIDE instructs the STM to start checking the updated document.
This instruction can include a \emph{perspective}: the set of
spans that frontend is currently showing to the user. This perspective
is
used by the STM to prioritize processing certain portions of the
document.
Processing the document
produces messages to update PIDE
of new information. During the computation, PIDE can interrupt the STM at any
moment, to update the document following the user's changes.
\subsection{Metadata collection}
The information Coq needs to report to the UI can be classified
according to its nature: persistent or volatile. \emph{Persistent
information} is part of the system state, and can be immediately
accessed. For this kind of information we follow the model of
asynchronous prints introduced by Wenzel in~\cite{Wenzel14}. When a
system state is ready it is reported to (any number of) asynchronous
printers, which process the state, reporting some information from it
as marked up messages for the frontend. Some of these printers, like
those reporting the goal state at each span, are always executed,
while others can be printed on-demand. An example of the latter are
Coq's queries, which are scheduled for execution whenever the user
requests it.
\emph{Volatile information} can only be reported during the execution
of a command, since it is not retained in the system state. An example
is the resolution of an identifier resulting in an hyper link: the
relation between the input text and the resulting term is not stored,
hence localized reports concerning sub terms can only be generated
while processing a command. Volatile information can also be produced
optionally and on demand by processing commands a second time, for example in
response to the user request of more details about a term.
From the UI perspective both kind of reports are asynchronously
generated and handled homogeneously.
\subsection{Rich Feedback}\label{sec:RichFeedback}
\begin{figure}
\includegraphics[width=\textwidth]{jedit_screenshot.png}
\caption{jEdit using PIDE \label{fig:jEdit-screenshot}}
\end{figure}
A user interface building on PIDE's frontend can use the marked up
metadata produced by the prover to provide a much richer editing
experience than was previously possible: the accessible information is no
longer restricted to
the output of
the last executed command.
For example jEdit, the reference frontend based on PIDE,
uses the spell checker idiom to report problems in the entire proof
document: instead of refusing to proceed beyond a line containing an
error the interface underlines all the offending parts in red, and the
user can inspect each of them.
This modeless interaction model also allows the interface to take
different directions than the write-and-execute one imposed by REPL
based UI. For example it is now easy to decorrelate the user's point
of observation and the place where she is editing the document. A
paradigmatic example concerns the linguistic construct of postfix
bookkeeping of variables and hypotheses (the \lstinline{as} intro
pattern in Coq). The user is encouraged to decorate commands like the one
that starts an induction with the names of the new variables and
hypotheses that are available in each subgoal. This decoration is
usually done in a sloppy way: when the user starts to work
on the third subgoal she goes back to the induction command in order
to write the intro pattern part concerning the third goal. In the
REPL model she would lose the display of the goal she is actually working
on because the only goal displayed.
would be the one immediately
before the induction command. By using a PIDE based interface to Coq
the user can now leave the observation point on the third goal and see
how it changes \emph{while} she is editing the intro pattern (note the
``Do not follow caret'' check box in
Figure~\ref{fig:jEdit-screenshot}).
These new ways of interaction are the first experiments with the PIDE
model for Coq, and we believe that even more drastically different
interaction idioms can be provided, for example allowing the user to
write more structured proofs, where the cases of a proof are gradually
refined, possibly in a different order than the one in which they
appear in the finished document.
The PIDE/jEdit based interface for Coq 8.5 is distributed at the
following URL: \url{http://coqpide.bitbucket.org/}.
\section{Assessment of the quick compilation chain}\label{12core}
As described in Section~\ref{sepcomp} our design enables Coq to postpone the
processing of opaque proofs even when used as a batch compiler. To have a
picture of the improvement in the reactivity of the system we consider the time
that one needs to wait (we call that latency) in order to be able to use
(\tmverbatim{Require} in Coq's terminology) the last file of the proof
of the Odd Order Theorem after a change in the first file of such proof.
With Coq 8.4 there is nothing one can do but to wait for the full
compilation of the whole formalization. This takes a bit less than two and a
half hours on a fairly recent Xeon 2.3GHz machine using a single core (first
column). Using two cores, and compiling at most two files at a time, one can
cut that time to ninety minutes (second column). Unfortunately batch
compilation has to honour the dependency among files and follow a topological
order, hence by adding extra 10 cores one can cut only twelve minutes (third
column). Hence, in Coq 8.4 the best latency
is of the order of one hour.
\begin{figure}[h]
\includegraphics[width=\textwidth]{image-1.png}
\caption{Benchmarks}
\end{figure}
Thanks to to the static analysis of the document described in
Section~\ref{static}, the work of checking
definitions and statements (in blue) can be separated by the checking of
opaque proofs
(in red), and one can use a (partially) compiled Coq file even if its opaque
proofs are not checked yet.
In this scenario, the same hardware gives a latency of twelve minutes
using a single core (fourth column), eight minutes using two cores (fifth
column) and seven minutes using twelve cores (sixth column). After that time
one can use the entire formalization.
When one then decides to complete the compilation he can
exploit the fact that each proof is independent to obtain a
good degree of parallelism. For example
checking all proofs using twelve cores requires thirteen extra minutes after
the
initial analysis, for a total of twenty minutes. This is 166\% of the
theoretical optimum one could get (seventh column). Still with
12 cores the latency is
only six minutes, on par with the theoretical optimum for 24 cores.
The reader may notice that the quick compilation chain using 1 core (4th
column) is slightly faster than the standard compilation chain.
This phenomenon concerns only the
largest and most complicated files of the development.
To process these files Coq requires a few gigabytes of
memory and it stresses the OCaml garbage collector quite a bit (where it spends
more than 20\% of the time). The separation of the two compilation phases
passes trough marshalling
to (a fast) disk and un-marshaling to an empty process space. This operation
trades (non blocking, since the size of files fits the memory of the computer)
disk I/O for a more compact and less fragmented memory layout that makes the
OCaml runtime slightly faster.
\section{Concluding remarks and future directions}\label{conclusions}
This paper describes the redesign Coq underwent in order to provide a
better user experience, especially when used to edit large formal
developments. The system is now able to better exploit parallel
hardware when used in batch mode, and is more reactive when used
interactively. In particular it can now talk with user
interfaces that use the PIDE middleware, among which we find the one
of Isabelle~\cite{Isabelle} that is based on jEdit and the
Coqoon~\cite{coqoon,coqoon2} one based on Eclipse.
There are many ways this work can be improved.
The most interesting paths seem to be the following ones.
First, one could make the prover generate, on demand, more metadata for the
user consumption. A typical example is the type of sub expressions to
ease the reading of the document. Another example is the
precise list of theorems or local assumptions used by automatic tactics like
\tmverbatim{auto}. This extra metadata could be at the base of assisted
refactoring functionalities the UI could provide.
Another interesting direction is to refine the static analysis of the
document to split proofs into smaller, independent, parts. In a
complementary way one could make such structure easier to detect in
the proof languages supported by the system. The extra structure
could be used in at least two ways.
First, one could give more accurate
feedback on broken proofs. Today the system stops at the first error it
encounters, but a more precise structure would enable the system to
backup by considering the error confined to the sub-proof in which it
occurs.
Second, one could increase the degree of parallelism we can exploit.
Finally one could take full profit of the PIDE middleware by adapting to
Coq interesting user interfaces based on it. For example
clide~\cite{RingL14} builds on top of PIDE
and provides a web based, collaborative, user interface for the
Isabelle prover. The cost of adapting it to work with Coq seems
now affordable.
\bibliographystyle{abbrv}
|
{'timestamp': '2015-06-19T02:10:34', 'yymm': '1506', 'arxiv_id': '1506.05605', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05605'}
|
arxiv
|
\section{Introduction}
{\color{black}Recognition/classification is an important computer vision problem and has gained significant research attention over last few decades. Most of the efforts, in this regard, has been tailored towards generic object recognition (an image with one or multiple instances of the same object) and face recognition (an image with the face region of the person). Unlike these classification tasks, indoor scene classification is quite different since an image of an indoor scene contains multiple distinct objects, with different scales and sizes and laid across different spatial locations in a number of possible layouts. Due to the challenging nature of the problem, the state of the art performance for indoor scene classification is much lower (69\% classification accuracy on MIT-67 dataset with only 67 classes \cite{GongMOP14}) compared with other classification tasks such as object classification (94\% rank-5 identification rate on ImageNet database with 1000 object categories \cite{simonyan2014very}) and face recognition (human level performance on face recognition on real life datasets including Labeled Faces in the Wild and YouTube Faces \cite{taigman2014deepface}). This paper proposes a novel method of feature description, specifically tailored for indoor scene images, in order to address the challenges of large scale spatial layout deformations and scale variations.}
We can characterize some indoor scenes by only global spatial information \cite{oliva2001modeling, razavian2014cnn}, whereas for others, local appearance information \cite{fei2005bayesian, lazebnik2006beyond, margolin2014otc} is more critical.
For example, a corridor can be predominantly characterized by a single large object (\emph{walls}) whereas a bedroom scene is characterized by multiple objects (e.g, \emph{sofa}, \emph{bed}, \emph{table}).
Both global and local spatial information must therefore be leveraged in order to accommodate different scene types \cite{quattoni2009recognizing}.
This however is very challenging, for two main reasons. \textbf{First}, the spatial scale of the constituent objects varies significantly across different scene types.
\textbf{Second}, the constituent objects can be present in different spatial locations and in a number of possible layouts.
This is demonstrated in the example images of the kitchen scene in Fig. \ref{fig:SceneExample}, where a microwave can be present in many different locations in the image with significant variations in scale, pose and appearance.
\begin{figure}[t!]
\centering
\includegraphics[clip, trim=0 0 0 0 , width=1\columnwidth]{Figs/IntroFig.pdf}
\caption{The spatial structure of indoor scenes is loose, irregular and unpredictable which can confuse the classification system.
As an example, a microwave in a kitchen scene can be close to the sink, fridge, kitchen door or top cupboards (\emph{green} box in the images). Our objective is to learn feature representations which are robust to these variations by spatially shuffling the convolutional activations (Sec.~\ref{Proposed Spatial Layout and Scale Invariant Convolutional Activations}).}
\label{fig:SceneExample}
\end{figure}
This paper aims to achieve invariance with respect to the spatial layout and the scale of the constituent objects for indoor scene images. For this purpose, in order to achieve invariance with respect to the spatial scale of objects, we generate a pyramidal image representation where an image is resized to different scales, and features are computed across these scales (Sec~\ref{Pyramid Image Representation}).
To achieve spatial layout invariance, we introduce a new method of feature description which is based on a proposed modified Convolutional Neural Network (CNN) architecture (Sec.~\ref{subsec:CNNArch}).
CNNs preserve the global spatial layout in an image.
This is desirable for the classification tasks where an image predominantly contains only a single object (e.g., objects in ImageNet database \cite{ILSVRCarxiv14}).
However, for a high level vision task such as indoor scene classification, an image may contain multiple distinct objects across different spatial locations.
We therefore want to devise a method of feature description which is robust with respect to the spatial layout of objects in a scene.
Although commonly used local pooling layers (max or mean pooling) in standard CNN architectures have been shown to achieve viewpoint and pose invariance to some extent \cite{krizhevsky2012imagenet,he2014spatial}, these layers cannot accommodate large-scale deformations that are caused by spatial layout variations in indoor scenes.
In order to achieve spatial layout invariance, this paper introduces a modified CNN architecture with an additional layer, termed `spatially unstructured layer' (Sec. \ref{subsec:CNNArch}). The proposed CNN is then trained with images of indoor scenes (using our proposed strategy described in Sec.~\ref{Adapting Large-scale CNNs for Indoor Scene Categorization}) and the learnt feature representations are invariant to the spatial layout of the constituent objects.
Training a deep CNN requires a large amount of data because the number of parameters to be learnt is quite huge.
However, for the case of indoor scenes, we only have a limited number of annotated training data. This becomes then a serious limitation for the feasible training of a deep CNN.
Some recently proposed techniques demonstrate that pre-trained CNN models (on large datasets e.g., ImageNet) can be adapted for similar tasks with limited additional training data \cite{Chatfield14}.
However, cross domain adaptation becomes problematic in the case of heterogeneous tasks due to the different natures of source and target datasets.
For example, an image in the ImageNet dataset contains mostly centered objects belonging to only one class.
In contrast, an image in an indoor scene dataset has many constituent objects, all appearing in a variety of layouts and scales.
In this work, we propose an efficient strategy to achieve cross domain adaptation with only a limited number of annotated training images in the target dataset (Sec.~\ref{Adapting Large-scale CNNs for Indoor Scene Categorization}).
The major contributions of this paper can be summarized as: \textbf{1)} {\color{black}A new method of feature description (using the activations of a deep convolutional neural network) is proposed to deal with the large-scale spatial layout deformations in scene images } (Sec~\ref{subsec:CNNArch}),
\textbf{2)} A pyramidal image representation is proposed to achieve scale invariance (Sec~\ref{Pyramid Image Representation}), \textbf{3)} A novel transfer learning approach is introduced to efficiently adapt a pre-trained network model (on a large dataset) to any target classification task with only a small amount of available annotated training data (Sec~\ref{Adapting Large-scale CNNs for Indoor Scene Categorization}) and
\textbf{4)} Extensive experiments are performed to validate the proposed approach. Our results show a significant performance improvement for the challenging indoor scene classification task on a number of datasets.
\section{Related Work}
Indoor scene classification has been actively researched and a number of methods have been developed in recent years \cite{wu2011centrist,quattoni2009recognizing,pandey2011scene,lazebnik2006beyond,sun2013learning,razavian2014cnn,singh2012unsupervised,zuo2014learning}.
While some of these methods focus on the holistic properties of scene images (e.g., CENTRIST \cite{wu2011centrist}, Gist descriptor \cite{oliva2001modeling}), others give more importance to the local distinctive aspects (e.g., dense SIFT \cite{lazebnik2006beyond}, HOG \cite{xiao2010sun}).
In this paper, we argue that we cannot rely on either of the local or holistic image characteristics to describe all indoor scene types \cite{quattoni2009recognizing}.
For some scene types, holistic or global image characteristics are enough (e.g., \emph{corridor}), while for others, local image properties must be considered (e.g., \emph{bedroom}, \emph{shop}).
We therefore neither focus on the global nor the local feature description and instead extract mid-level image patches to encode an intermediate level of information. Further, we propose a pyramidal image representation which is able to capture the discriminative aspects of indoor scenes at multiple levels.
Recently, mid-level representations have emerged as a competitive candidate for indoor scene classification.
Strategies have been devised to discover discriminative mid-level image patches which are then encoded by a feature descriptor.
For example, the works \cite{juneja2013blocks, doersch2013mid, sun2013learning} learn to discover discriminative patches from the training data.
Our proposed method can also be categorized as a mid-level image patches based approach.
However, our method is different from previous methods, which require discriminative patch ranking and selection procedures or involve the learning of distinctive primitives.
In contrast, our method achieves state of the art performance by simply extracting mid-level patches densely and uniformly from an image (see more details in Sec.~\ref{Image Representation and Classification}.
An open problem in indoor scene classification is the design of feature descriptors which are robust to global layout deformations.
The initial efforts to resolve this problem used bag-of-visual-words models or variants (e.g., \cite{lazebnik2006beyond, bosch2008scene, yang2009linear}), which are based on locally invariant descriptors e.g., SIFT \cite{lowe2004distinctive}.
Recently, these local feature representations have been outperformed by learned feature representations from deep neural networks \cite{krizhevsky2012imagenet, ILSVRCarxiv14, razavian2014cnn}.
However, since there is no inherent mechanism in these deep networks to deal with the high variability of indoor scenes, several recent efforts have been made to fill in this gap (e.g., \cite{GongMOP14, he2014spatial}).
The bag of features approach of Gong et al. \cite{GongMOP14} performs VLAD pooling \cite{jegou2010aggregating} of CNN activations.
Another example is the combination of spatial pyramid matching and CNNs (proposed by He et al. \cite{he2014spatial}) to increase the feature's robustness.
These methods, however, devise feature representations on top of CNN activations and do not inherently equip the deep architectures to effectively deal with the large deformations.
In contrast, this work provides an alternative strategy based on an improved network architecture to enhance invariance towards large scale deformations. The detailed description of our proposed feature representation method is presented next.
\begin{figure*}[t]
\centering
\includegraphics[width=1\textwidth]{Figs/MainMethodology.jpg}
\caption{Overview of the proposed Spatial Layout and Scale Invariant Convolutional Activations ($\text{S}^2\text{ICA}$) based feature description method. Mid-level patches are extracted from three levels (A, B, C) of the pyramidal image representation. The extracted patches are separately feed-forwarded to the two trained CNNs (with and without the spatially unstructured layer). The convolutional activations based feature representation of the patches is then pooled and a single feature vector for the image is finally generated by concatenating the feature vectors from both CNNs. Figure best seen in color.}
\label{fig:MainMethod}
\end{figure*}
\section{Proposed Spatial Layout and Scale Invariant Convolutional Activations - $\text{S}^2\text{ICA}$}
\label{Proposed Spatial Layout and Scale Invariant Convolutional Activations}
The block diagram of our proposed Spatial Layout and Scale Invariant Convolutional Activations ($\text{S}^2\text{ICA}$) based feature description method is presented in Fig~\ref{fig:MainMethod}. The detailed description of each of the blocks is given here. We first present our baseline CNN architecture followed by a detailed description of our spatially unstructured layer in Sec.~\ref{subsec:CNNArch}. Note that the spatially unstructured layer is introduced to achieve invariance to large scale spatial deformations, which are commonly encountered in images of indoor scenes. The baseline CNN architecture is pre-trained for a large scale classification task. A novel method is then proposed to adapt this pre-trained network for the specific task of scene categorization (Sec.~\ref{Adapting Large-scale CNNs for Indoor Scene Categorization}). Due to the data hungry nature of CNNs, it is not feasible to train a deep architecture with only a limited amount of available training data.
For this purpose, we pre-train a `TransferNet', which is then appended with the initialized CNN and the whole network can then be efficiently fine-tuned for the scene classification task. Convolutional activations from this fine-tuned network are then used for a robust feature representation of the input images. To deal with the scale variations, we propose a pyramidal image representation and combine the activations from multiple levels which results in a scale invariant feature representation (Sec.~\ref{Pyramid Image Representation}). This representation is then finally used by a linear Support Vector Machine (SVM) for classification (Sec.~\ref{Image Representation and Classification}).
\subsection{CNN Architecture}
\label{subsec:CNNArch}
Our baseline CNN architecture is presented in Fig~\ref{fig:CNNArch}. It consists of five convolutional layers and four fully connected layers.
The architecture of our baseline CNN is similar to AlexNet \cite{krizhevsky2012imagenet}.
The main difference is that we introduce extra fully connected layer, and that all of our neighboring layers are densely connected (in contrast to the sparse connections in AlexNet).
To achieve spatial layout invariance, the architecture of the baseline CNN is modified and a new unstructured layer is added after the first sub-sampling layer.
A brief description of each layer of the network follows next.
Let us suppose that the convolutional neural network consists of $L$ hidden layers and each layer is indexed by $l \in \{ 1 \ldots L \}$.
The feed-forward pass can be described as a sequence of convolution, optional sub-sampling and normalization operations.
The response of each convolution node in layer $l$ is given by:
\begin{equation}
\mathbf{a}^{l}_{n} = f\left(\sum\limits_{m} (\mathbf{a}^{l-1}_{m} * \mathbf{k}^{l}_{m,n}) + b^{l}_{n}\right),
\end{equation}
where $\mathbf{k}$ and $b$ denote the learned kernel and bias, the indices $(m,n)$ indicate that the mapping is from the $m^{th}$ feature map of the previous layer to the $n^{th}$ feature map of the current layer.
The function $f$ is the element-wise Rectified Linear Unit (ReLU) activation function.
The response of each normalization layer is given by:
\begin{equation}
\mathbf{a}_n^{l} = \frac{\mathbf{a}_n^{l-1}}{\left(\alpha + \beta \sum\limits_{j = max(0, n - \sigma)}^{min(N-1, n+\sigma)} (\mathbf{a}^{l-1}_{j} )^2 \right)^{\gamma}},
\end{equation}
where $\alpha, \beta, \gamma, \sigma$\footnote{These constants are defined as in \cite{krizhevsky2012imagenet}: $\alpha = 2$, $\beta = 10^{-4}$, $\gamma=3/4$ and $\sigma = 5/2$.} are constants and $N$ is the total number of kernels in the layer.
The response of each sub-sampling node is given by:
\begin{equation}
\mathbf{a}^{l}_{n} = \frac{k^l_n}{T^2}\sum\limits_{T \times T}\mathbf{a}^{l-1}_n + b^l_n
\end{equation}
where, $k_n^l$ is the connection weight and $T$ is the neighborhood size over which the values are pooled.
\begin{figure*}[t]
\centering
\includegraphics[width=0.8\textwidth]{Figs/NewCNNArch.jpg}
\caption{The architecture of our proposed Convolutional Neural Network used to learn tailored feature representations for scene categorization. We devise a strategy (see Sec.~\ref{Adapting Large-scale CNNs for Indoor Scene Categorization} and Alg.~\ref{alg:s-svm}) to effectively adapt the learned feature representation from a large scale classification task to scene categorization.}
\label{fig:CNNArch}
\end{figure*}
In our proposed modified CNN architecture, a spatially unstructured layer follows the first sub-sampling layer and breaks the spatial order of the output feature maps. This helps in the generation of robust feature representations that can cope with the high variability of indoor scenes.
For each feature response, we split the feature map into a specified number of blocks ($n$).
Next, a matrix $\mathbf{U}$ is constructed whose elements correspond to the scope of each block defined as a tuple:
\begin{equation}
\mathbf{U}_{\sqrt{n}\times\sqrt{n}} = \{\mathbf{u}_i \; \forall i \;| \mathbf{u}_i = (p,q) \},
\end{equation}
where, $p$ and $q$ indicate the starting and ending index of each block.
To perform a local swapping operation, we define a matrix $\mathbf{S}$ in terms of an identity matrix $I$ as follows:
\begin{equation}
\mathbf{S}_{2\times2} = |I - 1| =
\left(
\begin{array}{cc}
0 & 1 \\
1 & 0
\end{array} \right)
\end{equation}
Next, a transformation matrix $\mathbf{T} \in \mathbb{R}^{\sqrt{n}\times\sqrt{n}}$ is defined in terms of $\mathbf{S}$ as follows:
\begin{equation}
\mathbf{T}_{\sqrt{n}\times\sqrt{n}} =
\left(
\begin{array}{cccc}
\mathbf{S} & \mathbf{0} & \ldots & \mathbf{0} \\
\mathbf{0} & \mathbf{S} & \ldots & \mathbf{0} \\
\vdots & \vdots & \ddots & \vdots \\
\mathbf{0} & \mathbf{0} & \ldots & \mathbf{S}
\end{array}
\right)_{\sqrt{n}/2\times\sqrt{n}/2}
\end{equation}
The transformation matrix $\mathbf{T}$ has the following properties:
\begin{itemize}
\itemsep0em
\item $\mathbf{T} = \{t_{ij}\}$ is a permutation matrix ($\mathbf{T}: \{\mathbf{u}_{ij}\} \rightarrow \{\mathbf{u}_{ij}\} $) since the sum along each row and column is always equal to one i.e., $\sum\limits_{i} t_{ij} = \sum\limits_{j} t_{ij} = 1$.
\item $\mathbf{T}$ is a bistochastic matrix and therefore according to Birkhoff–von Neumann theorem and the above property, $\mathbf{T}$ lies on the convex hull of the set of bistochastic matrices.
\item It is a binary matrix with entries belonging to the Boolean domain $\{0,1\}$.
\item Its an orthogonal matrix i.e., $\mathbf{T} \mathbf{T}^{T} = I$ and $\mathbf{T}^{-1} = \mathbf{T}^{T}$.
\end{itemize}
Using the matrix $\mathbf{T}$, we transform $\mathbf{U}$ to become:
\begin{equation}
\hat{\mathbf{U}} = (\mathbf{U}^{T}\mathbf{T})^{T}\mathbf{T} = \mathbf{T}^{T} \mathbf{U} \mathbf{T}.
\end{equation}
The updated matrix $\hat{\mathbf{U}} $ contains the new indices of the modified feature maps.
If $\mathcal{Y}(\cdot)$ is a function which reads the indices of the blocks stored in the form of tuples in matrix $\hat{\mathbf{U}}$, the layer output are as follows:
\begin{equation}
\mathbf{a}_{n}^{l} = r * \mathcal{Y}(\mathbf{a}_{n}^{l-1}, \hat{\mathbf{U}}),
\end{equation}
\begin{equation}
\text{where, } r \sim \text{Bernoulli}(p).
\end{equation}
$r$ is a random variable which has a probability $p$ of being equal to $1$.
Note that this shuffling operation is applied randomly so that a network does not get biased towards the normal patches.
Fig.~\ref{fig:distortion} illustrates the distortion operation performed by the spatially unstructured layer for a different number of blocks.
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{Figs/Distort_Fig.jpg}
\caption{(\emph{left} to \emph{right}) Original image and the spatially unstructured versions with $2^{16}$, $2^{14}$ and $2^{2}$ blocks respectively. }
\label{fig:distortion}
\end{figure}
\begin{algorithm*}[htp]
\caption{Operations Involved in Spatially Unstructured Layer}
\begin{algorithmic}
\Require
Feature map : $\mathbf{F} \in \mathbf{M}_{p\times q \times r \times s}(\mathbb{R})$, Number of Blocks : $n$
// $\mathbf{F}$ is a real valued four dimensional matrix
\Ensure Modified feature map ($ \mathbf{F}_m$)
\State $\ell = \floor*{\frac{\sqrt{n}}{2}}$ \hfill // Rearrangement level
\State $h_{pts} \leftarrow (\ell + 1)$ linearly spaced points in range $[1:p]$
\State $h_{pts} = \floor*{h_{pts}}$
\State $h_{pts}[end] \; += 1$
\State $w_{pts} = h_{pts}$ \hfill // $\because p = q \text{ for } \mathbf{F}$
\For {$ \forall i \in [1:length(h_{pts})-1]$}
\For {$ \forall j \in [1:length(w_{pts})-1]$}
\State \resizebox{0.6\textwidth}{!}{$F_{tmp} = \mathbf{F}[h_{pts}(i):h_{pts}(i+1)-1, w_{pts}(j): w_{pts}(j+1) -1,:,:] $}
\State \resizebox{0.65\textwidth}{!}{$F_{tmp} = [F_{tmp}(\ceil*{\frac{rows(F_{tmp})}{2}}: end, :, :, :) ; F_{tmp}(1: \floor*{\frac{rows(F_{tmp})}{2}}, :, :, :)]$}
\State \resizebox{0.63\textwidth}{!}{$F_{tmp} = [F_{tmp}(:, \ceil*{\frac{cols(F_{tmp})}{2}}: end, :, :) ; F_{tmp}(:, 1: \floor*{\frac{cols(F_{tmp})}{2}}, :, :)] $}
\State \resizebox{0.65\textwidth}{!}{$\mathbf{F}_m [h_{pts} (i):h_{pts}(i+1)-1, w_{pts}(j):w_{pts}(j+1) -1, :,:] = F_{tmp}$}
\EndFor
\EndFor
\State \Return $\{\mathbf{R}\}$
\end{algorithmic}\label{alg:region_growing}
\end{algorithm*}
\subsection{Training CNNs for Indoor Scenes}
\label{Adapting Large-scale CNNs for Indoor Scene Categorization}
Deep CNNs have demonstrated exceptional feature representation capabilities for the classification and detection tasks (e.g., see ILSVRC'14 Results \cite{ILSVRCarxiv14}). Training deep CNNs however requires a large amount of data since the number of parameters to be learnt is huge. The requirement of a large amount of training data makes the training of CNNs infeasible where only a limited amount of annotated training data is available. In this paper, we propose to leverage from the image representations learnt on a large scale classification task (such as on ImageNet \cite{ILSVRCarxiv14}) and propose a strategy to learn tailored feature representations for indoor scene categorization. An algorithmic description of our proposed strategy is summarized in Algorithm.~\ref{alg:s-svm}. The details are presented here.
We first train our baseline CNN architecture on ImageNet database following the procedure in \cite{krizhevsky2012imagenet}. Next, we densely extract mid-level image patches from our scene classification training data and represent them in terms of the convolutional activations of the trained baseline network. The output of the last convolution layer followed by ReLU non-linearity is considered as a feature representation of the extracted patches. These feature representations ($\mathcal{F}$) will be used to train our TransferNet.
As depicted in Fig~\ref{fig:CNNArch}, our TransferNet consists of three hidden layers (with 4096 neurons each) and an output layer, whose number of neurons are equal to the number of classes in the target dataset (e.g., indoor scenes dataset). TransferNet is trained on convolutional feature representations ($\mathcal{F}$) of mid-level patches of the scene classification dataset.
Specifically, the input to TransferNet are the feature representations ($\mathcal{F}$) of the patches and the outputs are their corresponding class labels.
After training TransferNet, we remove all fully connected layers of the baseline CNN and join the trained TransferNet to the last convolutional layer of the baseline CNN.
The resulting network then consists of five convolutional layers and four fully connected layers (of the trained TransferNet).
This complete network is now fine-tuned on the patches extracted from the training images of the scene classification data.
Since the network initialization is quite good (the convolutional layers of the network are initialized from the baseline network trained on imageNet dataset, whereas the fully connected layers are initialized from the trained transferNet), only few epochs are required for the network to converge.
Moreover, with a good initialization, it becomes feasible to learn deep CNN's parameters even with a smaller number of available training images
Note that the baseline CNN was trained with images from the ImageNet database, where each image pre-dominantly contains one or multiple instances of the same object.
In the case of scene categorization, we may deal with multiple distinct objects from a wide range of poses, appearances and scales across different spatial locations.
Therefore, in order to incorporate large scale deformations, we train two CNNs: with and without the spatially unstructured layer (learned weights represented by $\mathbf{W}$ and $\mathbf{W}_{su}$ respectively).
These trained CNNs are then used for robust feature representation in Sec.~\ref{Image Representation and Classification}. Below, we first explain our approach in dealing with scale variations.
\begin{algorithm}[h]
\caption{Training CNNs for indoor scenes}
\begin{algorithmic}[1]
\Require
Source DB (ImageNet), Target DB (Scene Images)
\Ensure
Learned weights: $\{\mathbf{W}\}_{1\times L}$, $\{\mathbf{W}_{su}\}_{1\times L}$
\State Pre-train the CNN on the large-scale Source DB.
\State Feed-forward image patches from target DB to trained CNN.
\State Take feature representations ($\mathcal{F}$) from the last convolution layer.
\State Train the `TransferNet' of $4$ fully connected layers with $\mathcal{F}$ as input and target annotations as output.
\State Append `TransferNet' to the last convolution layer of trained CNN.
\State Fine-tune the complete network with and without the spatially unstructured layer to get $\{\mathbf{W}\}_{1\times L}$ and $\{\mathbf{W}_{su}\}_{1\times L}$ respectively.
\end{algorithmic}\label{alg:s-svm}
\end{algorithm}
\subsection{Pyramid Image Representation}
\label{Pyramid Image Representation}
In order to achieve scale invariance, we generate a pyramid of an image at multiple spatial resolutions.
However, unlike conventional pyramid generation processes (e.g., Gaussian or Laplacian pyramid) where smoothing and sub-sampling operations are repeatedly applied, we simply resize each image to a set of scales and this may involve up or down sampling.
Specifically, we transform each image to three scales, $\{0.75 \times D, D, 1.25 \times D \}$, where $D$ is the smaller dimension of an image which is set based on the given dataset.
At each scale, we densely extract patches which are then encoded in terms of the convolutional activations of the trained CNNs.
\subsection{Image Representation and Classification}
\label{Image Representation and Classification}
From each of the three images of the pyramidal image representation, we extract multiple overlapping patches of $224 \times 224$ using a sliding window. A shift of $32$ pixels is used between patches. The extracted image patches are then fed forwarded to the trained CNNs (both with and without the spatially unstructured layer). The convolutional feature representation of the patches are max-pooled to get a single feature vector representation for the image. This is denoted by A, B and C corresponding to three images of the pyramid in Fig~\ref{fig:MainMethod}. We then max pool the feature representations of these images and generate one single representation of the image for each network (with and without the spatially unstructured layer). The final feature representation is achieved by concatenating these two feature vectors. After encoding the spatial layout and the scale invariant feature representations for the images, the next step is to perform classification. We use a simple linear Support Vector Machine (SVM) classifier for this purpose.
\begin{figure*}[pth]
\centering
\includegraphics[width=.8\linewidth]{Figs/MITCM.jpg}
\caption{Confusion Matrix for the MIT 67 Indoor Scenes Dataset. Figure best seen in color.}
\label{fig:confu_mat_MIT}
\end{figure*}
\begin{figure*}[tph]
\centering
\begin{subfigure}[]{0.27\textwidth}
\imagebox{45mm}{\includegraphics[width=\textwidth]{Figs/15Scene_CM.jpg}}
\label{1}
\end{subfigure}
\;
\begin{subfigure}[]{0.30\textwidth}
\imagebox{50mm}{\includegraphics[trim= 0 0 4em 0, clip, width=\textwidth]{Figs/SportsCM.jpg}}
\label{2}
\end{subfigure}
\;
\begin{subfigure}[]{0.34\textwidth}
\imagebox{50mm}{\includegraphics[trim= 0 0 0em 0, clip, width=\textwidth]{Figs/NYUCM.jpg}}
\label{3}
\end{subfigure}
\caption{Confusion matrices for Scene-15, Sports-8 and NYU scene classification datasets. Figure best seen in color.}
\label{fig:confu_mat}
\end{figure*}
\section{Experiments and Evaluation}
The proposed approach is validated through extensive experiments on a number of datasets. To this end, we perform experiments on three indoor scene datasets (MIT-67, NYU and Scene-15). Amongst these datasets, MIT-67 is the largest dataset for indoor scene classification. The dataset is quite challenging since images of many classes are similar in appearance and thus hard to classify (see Fig.~\ref{fig: misclassImages}). Apart from indoor scene classification, we further validate our approach for two other tasks i.e., event and object datasets (Graz-02 and Sports-8). Below (Sec.~\ref{Datasets}), we first present a brief description about each of the datasets and the adopted experimental protocols. We then present our experimental results along with a comparison with existing state of the art in Sec.~\ref{subsec:results}. An ablative analysis to study the individual effect of each component on the proposed method is also presented in Sec.~\ref{subsec:results}.
\begin{table*}[pth]
\centering
\begin{tabular}{l|c|| l|c}
\toprule
\multicolumn{4}{c}{\textbf{MIT-67 Indoor Scenes Dataset}} \\
\midrule
Method & Accuracy(\%) & Method & Accuracy (\%) \\
\hline\hline
ROI + GIST [CVPR'09] \cite{quattoni2009recognizing} & $26.1$ & OTC [ECCV'14] \cite{margolin2014otc} & $47.3$ \\
MM-Scene [NIPS'10] \cite{zhu2010large} & $28.3$ & Discriminative Patches [ECCV'12] \cite{singh2012unsupervised}
& $49.4$ \\
SPM [CVPR'06] \cite{lazebnik2006beyond} & $34.4$ & ISPR [CVPR'14]\cite{linlearning14} & $50.1$ \\
Object Bank [NIPS'10] \cite{li2010object} & $37.6$& D-Parts [ICCV'13] \cite{sun2013learning} & $51.4$ \\
RBoW [CVPR'12] \cite{parizi2012reconfigurable} & $37.9$ & VC + VQ [CVPR'13] \cite{li2013harvesting} & $52.3$ \\
Weakly Supervised DPM [ICCV'11] \cite{pandey2011scene} & $43.1$ & IFV [CVPR'13]\cite{juneja2013blocks} & $60.8$ \\
SPMSM [ECCV'12] \cite{kwitt2012scene} & $44.0$ & MLRep [NIPS'13] \cite{doersch2013mid} & $64.0$ \\
LPR-LIN [ECCV'12] \cite{sadeghi2012latent} & $44.8$ & CNN-MOP [ECCV'14]\cite{GongMOP14} & $68.9$ \\
BoP [CVPR'13] \cite{juneja2013blocks} & $46.1$ & CNNaug-SVM [CVPRw'14] \cite{razavian2014cnn} & $69.0$ \\
\cline{3-4}
Hybrid Parts + GIST + SP [ECCV'12] \cite{zheng2012learning} & $47.2$ & \textbf{Proposed $\text{S}^2\text{ICA}$} & \textbf{71.2}\\
\bottomrule
\end{tabular}
\caption{Mean accuracy on the MIT-67 indoor scenes dataset.}
\label{tab:MIT67acc}
\end{table*
\subsection{Datasets}
\label{Datasets}
\noindent
The \textbf{MIT-67 Dataset}
contains a total of 15620 images of 67 indoor scene classes. For our experiments, we follow the standard evaluation protocol in \cite{quattoni2009recognizing}. Specifically, 100 images per class are considered, out of which 80 are used for training and the remaining 20 are used for testing. We therefore have a total of 5360 and 1340 images for training and testing respectively.
\noindent
The \textbf{15 Category Scene Dataset} contains images of 15 urban and natural scene classes. The number of images for each scene class in the dataset ranges from 200-400. For performance evaluation and comparison with existing state of the art, we follow the standard evaluation protocol in \cite{lazebnik2006beyond}, where 100 images per class are selected for training and the rest for testing.
\noindent
The \textbf{NYU v1 Indoor Scene Dataset} contains a total of 2347 images belonging to 7 indoor scene categories. We follow the evaluation protocol described in \cite{silberman11indoor} and use the first $60\%$ of the images of each class for training and the last $40\%$ images for testing
\noindent
The \textbf{Inria Graz 02 Dataset} contains a total of 1096 images of three classes (bikes, cars and people). The images of this dataset exhibit a wide range of appearance variations in the form of heavy clutter, occlusions and pose changes. The evaluation protocol defined in \cite{marszatek2007accurate} is used in our experiments. Specifically, the training and testing splits are generated by considering the first 150 odd images for training and the first 150 even images for testing.
\noindent
The \textbf{UIUC Sports Event Dataset}
contains 1574 images of 8 sports event categories. Following the protocol defined in \cite{li2007and}, we used $70$ and $60$ randomly sampled images per category for training and testing respectively.
\subsection{Results and Analysis}\label{subsec:results}
The quantitative results of the proposed method in terms of classification rates for the task of indoor scene categorization are presented in Tables~\ref{tab:MIT67acc},~\ref{tab:nyu_acc}~and~\ref{tab:15scenes_acc}. A comparison with the existing state of the art techniques shows that the proposed method consistently achieves a superior performance on all datasets. We also evaluate the proposed method for the tasks of sports events and highly occluded object classification (Tables~\ref{tab:Sports_acc}~and~\ref{tab:graz_acc}). The results show that the proposed method achieves very high classification rates. The experimental results suggest that the gain in performance of our method is more significant and pronounced for the MIT-67, Scene-15, Graz-02 and Sports-8 datasets.
The confusion matrices showing the class wise accuracies of Scene-15, Sports-8 and NYU datasets are presented in Fig.~\ref{fig:confu_mat}.
The confusion matrix for the MIT-67 scene dataset is given in Fig.~\ref{fig:confu_mat_MIT}.
It can be noted that all the confusion matrices have a very strong diagonal (Fig.~\ref{fig:confu_mat_MIT} and Fig.~\ref{fig:confu_mat}). The majority of the confused testing samples belong to very closely related classes e.g., \emph{living room} is confused with \emph{bedroom}, \emph{office} with \emph{computer-room}, \emph{coast} with \emph{open-country} and \emph{croquet} with \emph{bocce}
The superior performance of our method is attributed to its ability to handle a large spatial layout (through the introduction of the spatially unstructured layer in our modified CNN architecture) and scale variations (achieved by the proposed pyramidal image representation). Further, our method is based on deep convolutional representations, which have recently shown to be superior in performance over shallow handcrafted feature representations \cite{razavian2014cnn,he2014spatial, ILSVRCarxiv14}.
A number of compared methods are based upon mid-level feature representations (e.g., \cite{juneja2013blocks, doersch2013mid, sun2013learning}). Our results show that our proposed method achieves superior performance over these methods. It should be noted that in contrast to existing mid-level feature representation based methods (whose main focus is on the automatic discovery of discriminative mid-level patches) our method simply densely extracts mid-level patches from uniform locations across an image. This is computationally very efficient since we do not need to devise patch selection and sorting strategies. Further, our dense patch extraction is similar to dense keypoint extraction, which has shown a comparable performance with sophisticated keypoint extraction methods over a number of classification tasks \cite{hayatHSI}. The contributions of the extracted mid-level patches towards a correct classification are shown in the form of heat maps for some example images in Fig~\ref{fig:DiscriminativePacthes}. It can be seen that our proposed spatial layout and scale invariant convolutional activations based feature descriptor gives automatically more importance to the meaningful and information rich parts of an image.
The actual and predicted labels of some miss-classified images from MIT-67 dataset are shown in Fig~\ref{fig: misclassImages}. Note the extremely challenging nature of the images in the presence of high inter-class similarities. Some of the classes are very challenging and there is no visual indication to determine the actual label. It can be seen that the miss-classified images belong to highly confusing and very similar looking scene types. For example, the image of \emph{inside subway} is miss-classified as \emph{inside bus}, \emph{library} as \emph{bookstore}, \emph{movie theater} as \emph{auditorium} and \emph{office} as \emph{classroom}.
\begin{table}
\centering
\begin{tabular}{l|c}
\toprule
\multicolumn{2}{c}{\textbf{UIUC Sports-8 Dataset}} \\
\midrule
Method & Accuracy (\%) \\
\hline\hline
GIST-color [IJCV'01] \cite{oliva2001modeling} & $70.7$ \\
MM-Scene [NIPS'10] \cite{zhu2010large} & $71.7$ \\
Graphical Model [ICCV'07] \cite{li2007and} & $73.4$ \\
Object Bank [NIPS'10] \cite{li2010object} & $76.3$ \\
Object Attributes [ECCV'12] \cite{li2012objects} & $77.9$ \\
CENTRIST [PAMI'11] \cite{wu2011centrist} & $78.2$ \\
RSP [ECCV'12] \cite{jiang2012randomized} & $79.6$ \\
SPM [CVPR'06] \cite{lazebnik2006beyond} & $81.8$ \\
SPMSM [ECCV'12] \cite{kwitt2012scene} & $83.0$ \\
Classemes [ECCV'10] \cite{torresani2010efficient} & $84.2$ \\
HIK [ICCV'09] \cite{wu2009beyond} & $84.2$ \\
LScSPM [CVPR'10] \cite{gao2010local} & $85.3$ \\
LPR-RBF [ECCV'12] \cite{sadeghi2012latent} & $86.2$ \\
Hybrid Parts + GIST + SP [ECCV'12] \cite{zheng2012learning} & $87.2$ \\
LCSR [CVPR'12] \cite{shabou2012locality} & $87.2$ \\
VC + VQ [CVPR'13] \cite{li2013harvesting} & $88.4$ \\
IFV \cite{vedaldi08vlfeat} & $90.8$ \\
ISPR [CVPR'14] \cite{linlearning14} & $89.5$ \\
\hline
\textbf{Proposed $\text{S}^2\text{ICA}$} & \textbf{95.8} \\
\bottomrule
\end{tabular}
\caption{Mean accuracy on the UIUC Sports-8 dataset. }
\label{tab:Sports_acc}
\end{table
\begin{table}
\centering
\begin{tabular}{l|c}
\toprule
\multicolumn{2}{c}{\textbf{NYU Indoor Scenes Dataset}} \\
\midrule
Method & Accuracy (\%) \\
\hline\hline
BoW-SIFT [ICCVw'11] \cite{silberman11indoor} & $55.2$ \\
RGB-LLC [TC'13] \cite{tao2013rank} & $78.1$ \\
RGB-LLC-RPSL [TC'13] \cite{tao2013rank} & $79.5$ \\
\hline
\textbf{Proposed $\text{S}^2\text{ICA}$} & $\mathbf{81.2}$\\
\bottomrule
\end{tabular}
\caption{Mean Accuracy for the NYU v1 dataset. }
\label{tab:nyu_acc}
\end{table}
\begin{table}
\centering
\begin{tabular}{l|ccc|c}
\toprule
\multicolumn{5}{c}{\textbf{Graz-02 Dataset}} \\
\midrule
& Cars & People & Bikes & Overall \\
\hline\hline
OLB [SCIA'05] \cite{opelt2005object} & 70.7 & 81.0
& 76.5 & 76.1 \\
VQ [ICCV'07] \cite{tuytelaars2007vector} & 80.2 & 85.2 & 89.5 & 85.0 \\
ERC-F [PAMI'08] \cite{moosmann2008randomized} & 79.9 & - & 84.4 & {82.1}\\
TSD-IB [BMVC'11] \cite{krapac2011learning} & 87.5 & 85.3 & 91.2 & 88.0 \\
TSD-k [BMVC'11] \cite{krapac2011learning} & 84.8 & 87.3 & 90.7 & 87.6 \\
\hline
\textbf{Proposed $\text{S}^2\text{ICA}$} & 98.7 & 97.7 & 97.7 & \textbf{98.0} \\
\bottomrule
\end{tabular}
\caption{Equal Error Rates (EER) on Graz-02 dataset. }
\label{tab:graz_acc}
\end{table}
\begin{table*}[th]
\centering
\begin{tabular}{l|c || l|c}
\toprule
\multicolumn{4}{c}{\textbf{15 Category Scene Dataset}} \\
\midrule
Method & Accuracy(\%) & Method & Accuracy (\%) \\
\hline\hline
GIST-color [IJCV'01] \cite{oliva2001modeling} & $69.5$ & ISPR [CVPR'14] \cite{linlearning14} & $85.1$ \\
RBoW [CVPR'12] \cite{parizi2012reconfigurable} & $78.6$ & VC + VQ [CVPR'13] \cite{li2013harvesting} & $85.4$ \\
Classemes [ECCV'10] \cite{torresani2010efficient} & $80.6$ & LMLF [CVPR'10] \cite{boureau2010learning} & $85.6$ \\
Object Bank [NIPS'10] \cite{li2010object} & $80.9$
& LPR-RBF [ECCV'12] \cite{sadeghi2012latent} & $85.8$ \\
SPM [CVPR'06] \cite{lazebnik2006beyond} & $81.4$ & Hybrid Parts + GIST + SP [ECCV'12] \cite{zheng2012learning} & $86.3$ \\
SPMSM [ECCV'12] \cite{kwitt2012scene} & $82.3$ & CENTRIST+LCC+Boosting [CVPR'11] \cite{yuan2011mining} & $87.8$ \\
LCSR [CVPR'12] \cite{shabou2012locality} & $82.7$ & RSP [ECCV'12] \cite{jiang2012randomized} & $88.1$ \\
SP-pLSA [PAMI'08] \cite{bosch2008scene} & $83.7$ & IFV \cite{vedaldi08vlfeat} & $89.2$ \\
CENTRIST [PAMI'11] \cite{wu2011centrist} & $83.9$ & LScSPM [CVPR'10] \cite{gao2010local} & $89.7$ \\
HIK [ICCV'09]\cite{wu2009beyond} & $84.1$
& \\
\cline{3-4}
OTC [ECCV'14] \cite{margolin2014otc} & $84.4$
& \textbf{Proposed $\text{S}^2\text{ICA}$} & \textbf{93.1} \\
\bottomrule
\end{tabular}
\caption{Mean accuracy on the 15 Category scene dataset. Comparisons with the previous best techniques are also shown.}
\label{tab:15scenes_acc}
\end{table*
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{Figs/DiscriminativePatches.pdf}
\caption{The contributions (\emph{red}: most; \emph{blue}: least) of mid-level patches towards correct class prediction. Best seen in color.}
\label{fig:DiscriminativePacthes}
\end{figure}
\begin{figure*}
\centering
\includegraphics[trim= 0 0 0 0, clip, width=\textwidth]{Figs/incorrectClassified.pdf}
\caption{Some examples of misclassified images from MIT-67 indoor scenes dataset. Actual and predicted labels of each image are given. Images from highly similar looking classes are confused amongst each other. For example, the proposed method misclassifies \emph{library} as \emph{bookstore}, \emph{office} as \emph{classroom} and \emph{inside subway} as \emph{inside bus}.}
\label{fig: misclassImages}
\end{figure*}
An ablative analysis to assess the effect of each individual component of the proposed technique towards the overall performance is presented in Table~\ref{tab:ablation}.
Specifically, the contributions of the proposed spatially unstructured layer, pyramid image representation, training of the CNN on the target dataset and pooling (mean pooling and max pooling) are investigated. In order to investigate a specific componenet of the proposed method, we only modify (add or remove) that part, while the rest of the pipeline is kept fixed.
The experimental results in Table~\ref{tab:ablation} show that the feature representations from trained CNNs with and without the spatially unstructured layer complement each other and achieve the best performance. Furthermore, the proposed pyramidal image representation also contributes significantly towards the performance improvement of the proposed method. Our proposed strategy to adapt a deep CNN (trained on a large scale classification task) for scene categorization also proves to be very effective and it results in a significant performance improvement. Amongst the pooling strategies, max pooling provides a superior performance compared with mean pooling.
\begin{table}[tph]
\centering
\begin{tabular}{l|c}
Baseline CNN (w/o Spatially Unstructured layer) & $65.4\%$ \\
Modified CNN (with Spatially Unstructured layer) & $65.9\%$ \\
Baseline CNN + Modified CNN & $71.2\%$\\
\hline
w/o pyramidal representation & $68.5\%$\\
with pyramidal representation & $71.2\%$\\
\hline
\hline
CNN trained on imageNet & $67.3\%$\\
CNN trained on imageNet+MIT-67 & $71.2\%$\\
\hline
Mean-pooling & $65.7\%$\\
Max-pooling & $71.2\%$\\
\end{tabular}
\caption{Ablative analysis on MIT-67 dataset. The joint feature representations from baseline and modified CNNs gives the best performance. The proposed pyramidal image representation results in a significant performance boost.}
\label{tab:ablation}
\end{table}
\section{Conclusion}
This paper proposed a novel approach to handle the large scale deformations caused by spatial layout and scale variations in indoor scenes.
A pyramidal image representation has been contrived to deal with scale variations. A modified Convolutional Neural Network Architecture with an added layer has been introduced to deal with the variations caused by spatial layout changes. In order to feasibly train a CNN on tasks with only a limited annotated training dataset, the paper proposed an efficient strategy which conveniently transfers learning from a large scale dataset. A robust feature representation of an image is then achieved by extracting mid-level patches and encoding them in terms of the convolutional activations of the trained networks. Leveraging on the proposed spatial layout and scale invariant image representation, state of the art classification performance has been achieved by using a simple linear SVM classifier.
\section*{Acknowledgements}
This research was supported by the SIRF and IPRS scholarships from the University of Western Australia (UWA) and the Australian Research Council (ARC) grants DP110102166, DP150100294 and DP120102960.
We gratefully acknowledge the support of NVIDIA Corporation with the donation of the Tesla K40 GPU used for this research.
\bibliographystyle{IEEEtrans}
|
{'timestamp': '2015-08-17T02:05:22', 'yymm': '1506', 'arxiv_id': '1506.05532', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05532'}
|
arxiv
|
\section{Introduction}\label{sec:intro}
Polar codes and Reed-Muller codes are Kronecker product-based codes. Such a code of block-length $2^n$ is based on the $n$-fold Kronecker product $G(n):=F^{\otimes n}$, where
\begin{equation}
F:=\left[\begin{array}{cc}
1 & 0\\ 1 & 1
\end{array}
\right].\label{eq:Fmatrix}
\end{equation}
Following the terminology of~\cite{Kahraman_Fractal}, a rate-$K/2^n$ Kronecker product-based code is uniquely defined by a set $\Fset$ of $K$ indices: Its generator matrix is the submatrix of $G(n)$ consisting of the rows indexed by $\Fset$. For polar codes~\cite{Arikan_PolarCodes}, in which each row of $G(n)$ can be interpreted as a (partially polarized) channel, $\Fset$ consists of rows corresponding to the $K$ channels with the lowest Bhattacharyya parameters~\cite{Arikan_PolarRM} (the ``good'' channels, see Section~\ref{sec:prelim:polar}). For Reed-Muller codes, $\Fset$ consists of those rows of $G(n)$ with a Hamming weight above a certain threshold (see Section~\ref{sec:prelim:RM}). Despite its importance for code construction, at least for polar codes, very little is known about the structure of $\Fset$. A recent exception is the work by Renes, Sutter, and Hassani, stating conditions under which polarized sets are aligned, i.e., under which the good (bad) channels derived from one binary-input memoryless channel are a subset of the good (bad) channels derived from another~\cite{Renes_Aligned}.
That Kronecker product-based codes, such as polar codes~\cite{Arikan_PolarCodes} or Reed-Muller codes, possess a fractal nature has been observed in~\cite{Kahraman_Fractal}, noting the similarity between $G(n)$ and the Sierpinski triangle. Much earlier, Abbe suspected that the set of ``good'' polarized channels is fractal~\cite{Abbe_PC}. Nevertheless, to the best of the author's knowledge, no definite statement regarding this fractal nature has been made yet. In this paper, we try to fill this gap and present results about the sets $\Fset$ for polar codes (Section~\ref{sec:polar}) and Reed-Muller codes (Section~\ref{sec:reedmuller}). The self-similar structure of these sets is also suggested in~\cite{Bardet_DecreasingMonomial}, which shows that polar and Reed-Muller codes are decreasing monomial codes. While~\cite{Bardet_DecreasingMonomial} focuses on finite blocklengths, we study the properties of $\Fset$ for infinite blocklengths, i.e., for $n\to \infty$.
To simplify analysis, we represent every infinite binary sequence indexed in $\Fset$ by a point in the unit interval $[0,1]$. Let $\Omega:=\{0,1\}^\infty$ be the set of infinite binary sequences, and let $b:=(b_1b_2\cdots)\in\Omega$ be an arbitrary such sequence. We abbreviate $b^n:=(b_1b_2\cdots b_n)$. Let $(\Omega,\mathfrak{B},\Prob)$ be a probability space with $\mathfrak{B}$ the Borel field generated by the cylinder sets $S(b^n):=\{w\in\Omega{:}\ w_1=b_1,\dots,w_n=b_2\}$ and $\Prob$ a probability measure satisfying $\Prob(S(b^n))=1/2^n$. The following function $f{:}\ \Omega\to [0,1]$ converts these sequences to real numbers:
\begin{equation}
f(b):=\sum_{n=1}^\infty \frac{b_n}{2^n}\label{eq:functionf}
\end{equation}
Letting $\mathbb{D}:=[0,1]\cap \{p/2^n{:}\ p\in\mathbb{Z},n\in\mathbb{N}\}$ denote the set of dyadic rationals in the unit interval, we recognize that $f$ is non-injective:
\begin{example}\label{ex:dyadics}
$f$ maps both $b=(01111111\cdots)$ and $b=(10000000\cdots)$ to $0.5$. We call the latter binary expansion \emph{terminating}.
\end{example}
However, as the following lemma shows, $f$ is bijective if we exclude the dyadic rationals:
\begin{lem}[{\cite[Exercises 7-10, p.~80]{Taylor_MeasureTheory}}]\label{lem:fprops}
Let $\mathfrak{B}_{[0,1]}$ be the Borel $\sigma$-algebra on $[0,1]$ and let $\lambda$ be the Lebesgue measure. Then, the function $f$ in~\eqref{eq:functionf} satisfies the following properties:
\begin{enumerate}
\item $f$ is measurable w.r.t.\ $\mathfrak{B}_{[0,1]}$
\item $f$ is bijective on $\Omega\setminus f^{-1}(\mathbb{D})$
\item for all $I\in\mathfrak{B}_{[0,1]}$, $\Prob(f^{-1}(I)) = \lambda(I)$
\end{enumerate}
\end{lem}
We believe that the results we prove in the following not only improve our understanding of polar and Reed-Muller codes: Since its introduction in 2009, the polarization technique proposed by Ar{\i}kan has found its way into areas different from polar coding. Haghighatshoar and Abbe showed in the context of compression of analog sources that R\'{e}nyi information dimension can be polarized~\cite{Haghighatshoar_RenyiPolarization}, and Abbe and Wigderson used polarization for the construction of high-girth matrices~\cite{Abbe_HighGirth}. Recently, Nasser proved that a binary operation is polarizing if and only if it is uniformity preserving and its inverse is strongly ergodic~\cite{Nasser_Ergodic1,Nasser_Ergodic2}. We believe that our results might carry over to these areas as well; Section~\ref{sec:discussion} points to possible extensions.
\section{Preliminaries for Polar Codes}\label{sec:prelim:polar}
We adopt the notation of~\cite{Arikan_PolarCodes}. Let $W{:}\ \{0,1\}\to\dom{Y}$ be a binary-input memoryless channel with output alphabet $\dom{Y}$, capacity $0<I(W)<1$, and with Bhattacharyya parameter
\begin{equation}
Z(W) := \sum_{y\in\dom{Y}} \sqrt{W(y|0)W(y|1)}.
\end{equation}
That $Z(W)=0\Leftrightarrow I(W)=1$ and $Z(W)=1\Leftrightarrow I(W)=0$ is a direct consequence of~\cite[Prop.~1]{Arikan_PolarCodes}. We say a channel is \emph{symmetric} if there exists a permutation $\pi{:}\ \dom{Y}\to\dom{Y}$ such that $\pi^{-1}=\pi$ and, for every $y\in\dom{Y}$, $W(y|0)=W(\pi(y)|1)$.
The heart of Ar{\i}kan's polarization technique is that two channel uses of $W$ can be \emph{combined and split} into one use of a ``worse'' channel
\begin{subequations}\label{eq:channels}
\begin{equation}
W_2^0(y_1^2|u_1) := \frac{1}{2} \sum_{u_2} W(y_1|u_1\oplus u_2) W(y_2|u_2)\label{eq:worse}
\end{equation}
and one use of a ``better'' channel
\begin{equation}
W_2^1(y_1^2,u_1|u_2) := \frac{1}{2} W(y_1|u_1\oplus u_2) W(y_2|u_2)\label{eq:better}
\end{equation}
\end{subequations}
where $u_1,u_2\in\{0,1\}$ and $y_1,y_2\in\dom{Y}$. In essence, the combining operation codes two input bits by $F$ in~\eqref{eq:Fmatrix} and transmits the coded bits over $W$ via two channel uses, creating a vector channel. The splitting operation splits this vector channel into the two virtual binary-input memoryless channels indicated in~\eqref{eq:channels}. Of these, the better (worse) channel has a strictly larger (smaller) capacity than the original channel $W$, i.e., $I(W_2^0)<I(W)<I(W_2^1)$, while the sum capacity equals twice the capacity of the original channel, i.e., $I(W_2^0)+I(W_2^1)=2I(W)$~\cite[Prop.~4]{Arikan_PolarCodes}.
The effect of combining and splitting on the channel capacities $I(W_2^0)$ and $I(W_2^1)$ admits no closed-form expression; the effect on the Bhattacharyya parameter at least admits bounds:
\begin{lem}[{\cite[Prop.~5~\&~7]{Arikan_PolarCodes}}]\label{lem:Bhattacharyya}
\begin{subequations}
\begin{align}
Z(W_2^1) &= g_1(Z(W)) := Z^2(W)< Z(W)\\
Z(W)<Z(W_2^0) &\le g_0(Z(W)) := 2Z(W)-Z^2(W) \label{eq:Bhattacharyya:worse}
\end{align}
\end{subequations}
with equality if $W$ is a binary erasure channel.
\end{lem}
Channels with larger blocklengths $2^n$, $n>1$, can either be obtained by direct $n$-fold combining (using the matrix $G(n)$) and $n$-fold splitting, or by recursive pairwise combining and splitting. For $b^n\in\{0,1\}^n$, we obtain
\begin{equation}
\left(W_{2^n}^{b^n},W_{2^n}^{b^n}\right) \to \left(W_{2^{n+1}}^{b^n0},W_{2^{n+1}}^{b^n1}\right)
\end{equation}
where $b^n0$ and $b^n1$ denote the sequences of zeros and ones obtained by appending $0$ and $1$ to $b^n$, respectively. Note that $g_1$ and $g_0$ from Lemma~\ref{lem:Bhattacharyya} are non-negative and non-decreasing functions mapping the unit interval onto itself, hence the inequality in~\eqref{eq:Bhattacharyya:worse} is preserved under composition:
\begin{equation}
Z(W_{2^n}^{b^n}) \le p_{b^n}(Z(W)):=g_{b_n}(g_{b_{n-1}}(\cdots g_{b_1}(Z(W)) \cdots ))
\end{equation}
The channel polarization theorem shows that, with probability one, after infinitely many combinations and splits, only perfect or useless channels remain, i.e., either $I(W_\infty^{b})=1$ or $I(W_\infty^{b})=0$ for $b\in\{0,1\}^\infty$. This is made precise in:
\begin{prop}[{\cite[Prop.~10]{Arikan_PolarCodes}}]\label{prop:polarization}
With probability one, the limit RV $I_\infty(b):=I(W_\infty^b)$ takes values in the set $\{0,1\}$: $\Prob(I_\infty=1)=I(W)$ and $\Prob(I_\infty=0)=1-I(W)$.
\end{prop}
This immediately gives rise to
\begin{definition}[The Good and the Bad Channels]\label{def:gset}
Let $\Gset$ denote the set of good channels, i.e.,
\begin{subequations}
\begin{equation}
x\in\Gset \Leftrightarrow \exists b\in f^{-1}(x){:}\ I(W_\infty^b)=1.
\end{equation}
Let $\Bset$ denote the set of bad channels, i.e.,
\begin{equation}
x\in\Bset \Leftrightarrow \exists b\in f^{-1}(x){:}\ I(W_\infty^b)=0.
\end{equation}
\end{subequations}
\end{definition}
If the polarization procedure is stopped at a finite blocklength $2^n$ for $n$ large enough, it can still be shown that the vast majority of the resulting $2^n$ channels are either almost perfect or almost useless, in the sense that the channel capacities are close to one or to zero (or that the corresponding Bhattacharyya parameters are close to zero or to one). The idea of polar coding is to transmit data only on those channels that are almost perfect: $n$-fold combining and splitting leads to $2^n$ virtual channels, each corresponding to a row of $G(n)$. The channels with high capacity are indicated by $\Fset$, and the generator matrix of the corresponding polar code is the submatrix of $G(n)$ consisting of those indicated rows. If the blocklength grows to infinity ($n\to\infty$), the set $\Fset$ becomes equivalent to the set $\Gset$ in Definition~\ref{def:gset}.
The difficulty of polar coding lies in code construction, i.e., in determining \emph{which} channels/row indices are in the sets $\Fset$ and $\Gset$ for finite and infinite blocklengths. This immediately translates to the question which sequences $b\in\{0,1\}^\infty$ correspond to combinations and splits leading to a perfect channel (or which finite-length sequences $b^n$ lead to channels with capacity sufficiently close to one). Determining the capacity of the virtual channels is an inherently difficult operation, since, whenever $W$ is not a binary erasure channel (BEC), the cardinality of the output alphabet increases exponentially in $2^n$~\cite[Ch.~3.3]{Sasoglu_PolarCodes},~\cite[p.~36]{Korada_PhD}. To circumvent this problem, Tal and Vardy presented an approximate construction method in~\cite{Tal_PolarConstruction}, that relies on reduced output alphabet channels that are either upgraded or degraded w.r.t.\ the channel of interest. As these upgrading/degrading properties -- mentioned earlier in Korada's PhD thesis~\cite[Def.~1.7 \& Lem.~1.8]{Korada_PhD} -- play a fundamental role in this work, we present
\begin{definition}[Channel Up- and Degrading]
A channel $W^-{:}\ \{0,1\}\to\dom{Z}$ is \emph{degraded} w.r.t.\ the channel $W$ (short: $W^- \preccurlyeq W$) if there exists a channel $Q{:}\ \dom{Y}\to\dom{Z}$ such that
\begin{equation}
W^-(z|u) = \sum_{y\in\dom{Y}} W(y|u)Q(z|y).
\end{equation}
A channel $W^+{:}\ \{0,1\}\to\dom{Z}$ is \emph{upgraded} w.r.t.\ the channel $W$ (short: $W^+ \succcurlyeq W$) if there exists a channel $P{:}\ \dom{Z}\to\dom{Y}$ such that
\begin{equation}
W(y|u) = \sum_{z\in\dom{Z}} W^+(z|u)P(y|z).
\end{equation}
Moreover, $W^+ \succcurlyeq W$ if and only if $W \preccurlyeq W^+$.
\end{definition}
The upgraded (degraded) approximation remains upgraded (degraded) during combining and splitting:
\newlength{\yuckkyhack}
\settowidth{\yuckkyhack}{$Z(W)$}
\begin{lem}[{\cite[Lem.~4.7]{Korada_PhD} \& \cite[Lem.~3]{Tal_PolarConstruction}}]\label{lem:grading}
Assume that $W^- \preccurlyeq W\preccurlyeq W^+$. Then,
\begin{subequations}
\begin{alignat}{2}
I(W^-) &\le \makebox[\yuckkyhack]{$I(W)$} & &\le I(W^+)\\
Z(W^-) &\ge Z(W) & &\ge Z(W^+)\\
(W^-)_2^1 &\preccurlyeq \makebox[\yuckkyhack]{$W_2^1$} & &\preccurlyeq (W^+)_2^1\\
(W^-)_2^0 &\preccurlyeq \makebox[\yuckkyhack]{$W_2^0$} & &\preccurlyeq (W^+)_2^0.
\end{alignat}
\end{subequations}
\end{lem}
It can be shown that the better channel~\eqref{eq:better} obtained from combining and splitting is upgraded w.r.t.\ the original channel (as already mentioned in~\cite[p.~9]{Sasoglu_PolarCodes}). The worse channel~\eqref{eq:worse} is degraded at least if $W$ is symmetric.
\begin{lem}[{\cite[p.~9]{Sasoglu_PolarCodes}}~\&{~\cite[Lem.~3]{Bardet_DecreasingMonomial}}]\label{lem:betterisupgraded}
$W\preccurlyeq W_2^1$. If $W$ is symmetric, then $W_2^0 \preccurlyeq W\preccurlyeq W_2^1$.
\end{lem}
\begin{IEEEproof}
By choosing
\begin{equation}
P(y|y_1^2,u_1) =\begin{cases}
1,& \text{if } y=y_2\\ 0, & \text{else.}
\end{cases}
\end{equation}
one can show that $W\preccurlyeq W_2^1$. To show that also $W_2^0 \preccurlyeq W$ for symmetric channels, take~\cite[Lem.~3]{Bardet_DecreasingMonomial}
\begin{equation}
Q(y_1^2|y) = \begin{cases}
\frac{1}{2}W(y_2|0) & \text{ if } y_1=y\\
\frac{1}{2}W(y_2|1) & \text{ if } y_1=\pi(y)\\
0 & \text{ else}
\end{cases}.
\end{equation}
\end{IEEEproof}
\begin{example}
For a BEC $W$ with erasure probability $\epsilon$, $W_2^1$ is a BEC with erasure probability $\epsilon^2$ and $W_2^0$ is a BEC with erasure probability $2\epsilon-\epsilon^2$~\cite[Prop.~6]{Arikan_PolarCodes}. The channel $W_2^1$ is an upgrade of $W$, because it can be degraded to $W$ by appending a BEC with erasure probability $\epsilon/(1+\epsilon)$. The channel $W_2^0$ is degraded w.r.t.\ $W$ by appending a BEC with erasure probability $\epsilon$.
\end{example}
\section{Properties of the Sets $\Gset$ and $\Bset$}\label{sec:polar}
In this section we develop the properties of the sets of good and bad channels.
\begin{prop}\label{prop:basins}
For almost all $x$, there exists a value $0\le\vartheta(x)\le 1$ such that $Z(W)<\vartheta(x)$ implies $x\in\Gset$. If $W$ is a BEC, then additionally $Z(W)>\vartheta(x)$ implies $x\in\Bset$.
\end{prop}
\begin{IEEEproof}
See Appendix~\ref{proof:basins}.
\end{IEEEproof}
If $W$ is not a BEC, it may happen that $Z(W)>\vartheta(f(b))$ while still $I(W_\infty^b)=1$. This leads to the question whether the set of good channels is (almost surely) increasing with decreasing Bhattacharyya parameter, i.e., if the sets of good channels for $W$ and $W'$ with $Z(W)>Z(W')$ are \emph{aligned}. While in general the answer is negative~\cite{Renes_Aligned}, Proposition~\ref{prop:basins} answers it positively if $W$ is a BEC: The set of good channels for a BEC is also good for any binary-input memoryless channel with a smaller Bhattacharyya parameter~\cite{Hassani_Compound}.
\begin{example}
For $x\in\mathbb{D}$, $\vartheta(x)=1$: If $Z(W)<1$, i.e., if the channel is not completely useless a priori, the non-terminating expansion of $x$ will make it a perfect channel (cf.~Proposition~\ref{prop:dyadic}).
\end{example}
In Appendix~\ref{proof:symmetry} we prove that the thresholds of Proposition~\ref{prop:basins} are symmetric:
\begin{prop}\label{prop:symmetry}
For those $x\notin\mathbb{D}$ for which $\vartheta(x)$ exists, $\vartheta(1-x) = 1-\vartheta(x)$.
\end{prop}
The case $x\in\mathbb{Q}\setminus\mathbb{D}$ is interesting. In this case, the binary expansion is unique and \emph{recurring}, i.e., there is a length-$k$ sequence $a^k\in\{0,1\}^k$, such that $f(b^na^ka^ka^k\cdots)=x$ for some $b^n\in\{0,1\}^n$. It is straightforward to show that for every non-trivial sequence $a_k$ (i.e., $a_k$ contains zeros and ones), $p_{a^k}$ is from $[0,1]$ to $[0,1]$, non-negative, and non-decreasing, with vanishing derivatives at 0 and 1. Since this ensures that $p_{a^k}(z)<z$ for $z$ close to zero and $p_{a^k}(z)>z$ for $z$ close to one, the operation $z_{i+1}=p_{a^k}(z_i)$ constitutes an iterated function system with attracting fixed points at $z=0$ and $z=1$. Note further that, since $p_{a^k}$ corresponds to the recurring part of the binary expansion of $x$, $Z(W_\infty^{b^na^ka^k\cdots})$ will be bounded from above by the value to which this iterated function system converges after being initialized with $Z(W_{2^n}^{b^n})$. To show that Proposition~\ref{prop:basins} holds for $x\in\mathbb{Q}\setminus\mathbb{D}$ requires showing that $p_{a^k}$ intersects the identity function only once on $(0,1)$, i.e., that there is no attracting fixed point on this open interval. We leave this problem for future investigation.
\begin{figure*}
\begin{pspicture}[showgrid=false](0,-5)(18,7.5)
\rput(0.5,4.5){
\psaxes[xLabels={\empty},yLabels={\empty},Dx=0.05,dx=1.7,Dy=0.25,dy=0.75,Ox=0.5]{-}(0,0)(17,3)[,-90][,0]
\readdata{\foo}{Base.dat}
\psset{xunit=34cm,yunit=3cm}
\dataplot[plotstyle=LineToXAxis,linewidth=0.1pt,xStart=0.5,origin={-0.5,0}]{\foo}
}
\rput(0.5,0){
\psaxes[Dx=0.1,dx=1.7,Dy=0.25,dy=0.75]{-}(0,0)(17,3)[$x$,0][$\vartheta(x)$,90]
\readdata{\foo}{Base.dat}
\psset{xunit=17cm,yunit=3cm}
\dataplot[plotstyle=LineToXAxis,linewidth=0.1pt,nStep=2,nStart=1]{\foo}
}
\rput(0.5,-4.5){
\psaxes[xLabels={\empty},yLabels={\empty},Dx=0.05,dx=1.7,Dy=0.25,dy=0.75]{-}(0,0)(17,3)[,-90][,90]
\readdata{\foo}{Base.dat}
\psset{xunit=34cm,yunit=3cm}
\dataplot[plotstyle=LineToXAxis,linewidth=0.1pt,xEnd=0.5]{\foo}
}
\psline[linecolor=red!50,linestyle=dashed](0.5,-.1)(0.5,-1.4)
\psline[linecolor=red!50,linestyle=dashed](9,-.1)(17.5,-01.4)
\psline[linecolor=red!50,linestyle=dashed](17.5,3.1)(17.5,4.4)
\psline[linecolor=red!50,linestyle=dashed](9,3.1)(0.5,4.4)
\end{pspicture}
\caption{The polar fractal for a BEC. The center plot shows the thresholds $\vartheta(x)$ for $x\in[0,1]$, while the bottom and the top plots show these thresholds for the scaled and shifted sets $[0,0.5]$ and $[0.5,1]$, respectively. Hence, the thresholds in the top plot are larger than the thresholds in the center plot, which are larger than those in the bottom plot. The indicator function of $\Gset$ is obtained by setting each value in the plot to one (zero) if the erasure probability $\epsilon$ is smaller (larger) than the threshold. Note further that the figure illustrates the symmetry of $\vartheta(x)$ mentioned in Proposition~\ref{prop:symmetry}.}
\label{fig:polarfractal}
\end{figure*}
\begin{example}\label{ex:goldenratio}
Let $x=2/3$, hence $f^{-1}(x)=101010101\cdots$. It suffices to consider one period of the recurring sequence and determine its fixed points. In this case we get $p_{10}(z)=2z^2-z^4$. Its fixed points are the roots of $p_{10}(z)-z$; removing the trivial roots at $z=0$ and $z=1$ leaves two further roots at $(\pm\sqrt{5}-1)/2$. One of these roots lies outside $[0,1]$ and is hence irrelevant. The remaining root determines the threshold, $\vartheta(2/3)=(\sqrt{5}-1)/2$.
Let $W$ be a BEC with erasure probability $\epsilon=Z(W)=\vartheta(2/3)$. Since $\epsilon=\vartheta(2/3)$ is a fixed point of the iterated function system corresponding to the recurring binary expansion, one gets $Z(W_\infty^{f^{-1}(2/3)})=\epsilon\notin\{0,1\}$. This example illustrates that Proposition~\ref{prop:polarization} holds only almost surely.
\end{example}
\begin{prop}\label{prop:dyadic}
$\Gset\cap\Bset = \mathbb{D}$.
\end{prop}
\begin{IEEEproof}
See Appendix~\ref{proof:dyadic}.
\end{IEEEproof}
That the intersection of the sets of good and bad channels is non-empty is a direct consequence of the non-injectivity of $f$. Note further that this intersection cannot be larger, since $\mathbb{D}$ is the only set to which $f$ maps non-injectively. Since $\mathbb{D}$, a common subset of $\Gset$ and $\Bset$, is dense in $[0,1]$, both the set of good channels and the set of bad channels are dense in the unit interval. But even if dyadic rationals are excluded, results about denseness can be proved:
\begin{prop}\label{prop:dense}
$\Gset\setminus\mathbb{D}$ is dense in $[0,1]$. If $W$ is a BEC, then also $\Bset\setminus\mathbb{D}$ is dense in $[0,1]$.
\end{prop}
\begin{IEEEproof}
See Appendix~\ref{proof:dense}.
\end{IEEEproof}
The proposition states that, at least for the BEC, there is no interval which contains only good channels. Hence, given a specific channel $W_{2^n}^{b^n}$, it is not possible to assume that a well-specified subset of channels (e.g., all $W_{\infty}^{b^na}$ for $a$ starting with $1$) generated from this channel by combining and splitting will be perfect. The construction algorithm for an infinite-blocklength, \emph{vanishing-error} polar code hence cannot stop at a finite blocklength. This is in contrast with finite-blocklength polar codes, for which an approximate construction technique suggests to stop polarizing some channels at already shorter blocklengths~\cite{ElKhamy_Relaxed}.
\begin{prop}\label{prop:lebesgue}
$\Gset$ is Lebesgue measurable and has Lebesgue measure $\lambda(\Gset)=I(W)$. $\Bset$ is Lebesgue measurable and has Lebesgue measure $\lambda(\Bset)=1-I(W)$.
\end{prop}
\begin{IEEEproof}
See Appendix~\ref{proof:lebesgue}.
\end{IEEEproof}
Note that $\lambda(\Gset\cup\Bset)=1$ although $\Gset\cup\Bset\subset[0,1]$. The reason is that convergence to good or bad channels is only almost sure, i.e., there may be channels $W_\infty^b$ that are neither good nor bad (see Example~\ref{ex:goldenratio}).
An immediate consequence of Proposition~\ref{prop:lebesgue} is that $\Gset$ and $\Bset$ have a Hausdorff dimension equal to one. This follows from the fact that the one-dimensional Hausdorff measure of a set equals its Lebesgue measure up to a constant~\cite[eq.~(3.4), p.~45]{Falconer_Fractals}. Since, thus, the one-dimensional Hausdorff measures of $\Gset$ and $\Bset$ are positive and finite, we have
\begin{cor}\label{cor:hausdorff}
The Hausdorff dimensions of $\Gset$ and $\Bset$ satisfy $\infodim{\Gset}=1$ and $\infodim{\Bset}=1$.
\end{cor}
Also the box-counting dimensions~\cite[p.~28]{Falconer_Fractals} are equal to one, since both sets are dense on the unit interval~\cite[Prop.~2.6]{Falconer_Fractals}.
We finally come to the claim that polar codes are fractal. Following Falconer's definition~\cite[p.~xxviii]{Falconer_Fractals}, a set is fractal if it is (at least approximately) self-similar and has detail on arbitrarily small scales, or if its fractal dimension (e.g., its Hausdorff dimension) is larger than its topological dimension. Whether or not the result shown below will convince the reader of this property is a mere question of definition; strictly speaking, we can show only \emph{quasi self-similarity} of $\Gset$:
\begin{prop}\label{prop:selfsimilar}
Let $\Gset_n(k):=\Gset \cap [(k-1)2^{-n},k2^{-n}]$ for $k=1,\dotsc,2^n$. $\Gset=\Gset_0(1)$ is \emph{quasi self-similar} in the sense that, for all $n$ and all $k$, $\Gset_n(k)={\Gset}_{n+1}(2k-1)\cup{\Gset}_{n+1}(2k)$ is quasi self-similar to its right half:
\begin{equation}
\Gset_{n}(k)\subset2{\Gset}_{n+1}(2k)-k2^{-n}
\end{equation}
If $W$ is symmetric, $\Gset_n(k)$ is quasi self-similar:
\begin{equation}
2{\Gset}_{n+1}(2k-1)-(k-1)2^{-n} \subset \Gset_{n}(k)\subset 2{\Gset}_{n+1}(2k)-k2^{-n}
\end{equation}
\end{prop}
\begin{IEEEproof}
See Appendix~\ref{proof:selfsimilar}.
\end{IEEEproof}
In other words, at least for a symmetric channel, $\Gset$ is composed of two similar copies of itself (see Fig.~\ref{fig:polarfractal}). The self-similarity is closely related to the fact that polar codes are decreasing monomial codes~\cite[Thm.~1]{Bardet_DecreasingMonomial}. Along the same lines, the quasi self-similarity of $\Bset$ can be shown.
\begin{example}
By careful computations we obtain $\vartheta(1/6)\approx 0.214$, $\vartheta(1/3)\approx 0.382$, and $\vartheta(2/3)\approx 0.618$. Indeed, if we consider $1/3$ in $\Gset$, then $1/6$ and $2/3$ are the corresponding values in $\Gset_1(1)$ and $\Gset_1(2)$. Since $\vartheta(1/6)<\vartheta(1/3)<\vartheta(2/3)$, for the BEC we have the inclusion indicated in Proposition~\ref{prop:selfsimilar}.
\end{example}
\section{Preliminaries for Reed-Muller Codes}\label{sec:prelim:RM}
As mentioned above, a rate-$K/2^n$ Reed-Muller code has a $K\times 2^n$ generator matrix with all $K$ rows having a Hamming weight larger than a predefined threshold. To make this more precise, let $w(b^n)=\sum_{i=1}^n b_i$ be the \emph{Hamming weight} of $b^n\in\{0,1\}^n$ and let $s_i(n)$ be the $i$-th row of $G(n)$. The generator matrix $G_{RM}(r,n)$ of an order-$r$, length-$2^n$ Reed-Muller code consists of the rows of $G(n)$ indicated in~\cite{Arikan_PolarRM}
\begin{equation}
\Fset =\{i\in\{1,\dotsc,2^n\}{:}\ w(s_i(n))\ge 2^{n-r} \}.
\end{equation}
Trivially, $G_{RM}(n,n)=G(n)$, while $G_{RM}(0,n)$ is a single row vector containing only ones (length-$2^n$ repetition code).
To analyze the effect of doubling the block length, note that
\begin{equation}
G(n+1):=\left[\begin{array}{cc}
G(n) & 0\\ G(n) & G(n)
\end{array}
\right].\label{eq:RMiteration}
\end{equation}
Assume that we indicate the rows of $G(n)$ by a sequence of binary numbers, i.e., let the $i$-th row be indexed by $h_n(b^n):=2^n\sum_{l=1}^n b_l 2^{-l}$. Furthermore, let $0b^n$ and $1b^n$ denote the sequences of zeros and ones obtained be prepending 0 and 1 to $b^n$, respectively. Clearly, $h_{n+1}(0b^n)=h_n(b^n)$ and $h_{n+1}(1b^n)=h_n(b^n)+2^n$. Combining this with~\eqref{eq:RMiteration} yields
\begin{align}
w(s_{h_{n+1}(0b^n)}(n+1))&=w(s_{h_n(b^n)}(n))\\
w(s_{h_{n+1}(1b^n)}(n+1))&=2w(s_{h_n(b^n)}(n)).
\end{align}
Defining $G(0):=1$, we thus get
\begin{equation}
w(s_{h_n(b^n)}(n)) = 2^{w(b^n)}\label{eq:powerofweight}
\end{equation}
and
\begin{equation}
\Fset =h_n\left(\{b^n\in\{0,1\}^n{:}\ 2^{w(b^n)} \ge 2^{n-r} \}\right).
\end{equation}
Letting the blocklengths go to infinity, we may ask questions about the following set:
\begin{definition}[The Heavy Channels]\label{def:heavy}
Let $\Hset(\rho)$ denote the set of $\rho$-heavy channels, i.e.,
\begin{equation}
x\in \Hset(\rho) \Leftrightarrow \exists b\in f^{-1}(x){:}\ \liminf_{n\to\infty} \frac{2^{w(b^n)}}{2^{n\rho}} \ge 1.
\end{equation}
\end{definition}
Loosely speaking, the set of heavy channels corresponds to those rows of $G(n)$, which \emph{asymptotically} have a Hamming weight larger than a given threshold.
\begin{example}\label{ex:heavyH}
$\Hset(1)=\{1\}$. This follows from the fact that 1 is the only number in the unit interval with a binary expansion consisting only of ones. $\Hset(0)=[0,1]$. This follows from the fact that $w(b^n)\ge 0$.
\end{example}
The results we will show for the set $\Hset(\rho)$ are tightly linked to the concept of \emph{normal numbers}.
\begin{definition}[Normal Numbers]\label{def:normal}
A number $x\in[0,1]$ is called \emph{simply normal to base 2} ($x\in\mathcal{N}$) iff
\begin{equation}
\exists b\in f^{-1}(x){:}\ \limn\frac{w(b^n)}{n} = \frac{1}{2}.
\end{equation}
\end{definition}
In general, a number is simply normal in base $M$ if the number of each of its digits used in its $M$-ary expansion is $1/M$. A number is called normal if this property not only holds for digits, but for subsequences: a number is normal in base $M$ if, for each $k\ge 1$, the number of each of its length-$k$ sequences used in its $M$-ary expansion is $1/M^k$. It immediately follows that a normal number is simply normal. The converse is in general not true:
\begin{example}\label{ex:normal}
Let $x=1/3$, hence $b=010101\cdots$. $x$ is simply normal to base 2, but not normal (since the sequences $00$ and $11$ never occur). Let $x=1/7$, hence $b=001001001\cdots$. $x$ is neither normal nor simply normal. Let $x\in\mathbb{D}$, hence $b$ is either terminating ($\limn w(b^n)/n=0$) or non-terminating ($\limn w(b^n)/n=1$). Dyadic rationals are not simply normal.
\end{example}
\begin{lem}[Borel's Law of Large Numbers, cf.~{\cite[Cor.~8.1, p.~70]{Kuipers_Uniform}}]\label{lem:borel}
Almost all numbers in $[0,1]$ are simply normal, i.e.,
\begin{equation}
\lambda(\mathcal{N})=1.
\end{equation}
\end{lem}
Although normal numbers are, in this sense, \emph{normal}, there are uncountably many numbers in the unit interval which are not normal. Moreover, the set of numbers that are not normal is \emph{superfractal}, i.e., it has a Hausdorff dimension equal to one although it has zero Lebesgue measure~\cite{Albeverio_Superfractal}.
\section{Properties of the Set $\Hset$}\label{sec:reedmuller}
We can show in Appendix~\ref{proof:dyadic:RM} that the dyadic rationals are not only good and bad, but also heavy:
\begin{prop}\label{prop:dyadic:RM}
For all $\rho\in[0,1)$, $\mathbb{D}\subset \Hset(\rho)$.
\end{prop}
It follows that $\Hset(\rho)$ is dense in $[0,1]$ for all $\rho\in[0,1)$.
The Lebesgue measure of the set of good channels was equal to the channel capacity of $W$. The result for heavy channels is inherently different, because $\Hset(\rho)$ does not depend on $W$. The proof of the following result can be found in Appendix~\ref{proof:lebesgue:RM}.
\begin{prop}\label{prop:lebesgue:RM}
$\Hset(\rho)$ is Lebesgue measurable and has Lebesgue measure
\begin{equation}
\lambda(\Hset(\rho))=\begin{cases}
1, & \text{ if } \rho<1/2\\ 0, & \text{ if } \rho\ge1/2
\end{cases}.
\end{equation}
\end{prop}
The result is surprising since it suggests a \emph{phase transition} for the rate of Reed-Muller codes: If $\rho<1/2$, the infinite-blocklength Reed-Muller code consists of almost all (in the sense of Lebesgue measure) possible binary sequences. In contrast, if $\rho\ge 1/2$, the infinite-blocklength Reed-Muller code consists of almost no code words (again, in the sense of Lebesgue measure). The picture is not as simple if one also considers the Hausdorff dimension of $\Hset(\rho)$. In Appendix~\ref{proof:hausdorff:RM} we prove that $\Hset(\rho)$ has positive Hausdorff dimension even if it is a Lebesgue null set.
\begin{prop}\label{prop:hausdorff:RM}
The Hausdorff dimension satisfies
\begin{equation}
\infodim{\Hset(\rho)}\begin{cases}
=1, & \text{ if } \rho\le 1/2\\ \ge h_2(\rho), & \text{ if } \rho>1/2
\end{cases}
\end{equation}
where $h_2(x):=-x\log_2 x - (1-x)\log_2 (1-x)$.
\end{prop}
Unfortunately, we were not able to give an exact expression for the Hausdorff dimension of $\Hset(\rho)$ for $\rho>1/2$. While the set of all non-normal numbers is superfractal, we are not sure if this holds also for a proper subset.
The sets $\Gset$ and $\Bset$ exhibit self-similarity, i.e., detailed structure on every scale (cf. Fig.~\ref{fig:polarfractal}). We next show that also $\Hset(\rho)$ is self-similar. At least for $\Hset(0)$ and $\Hset(1)$ (cf.~Example~\ref{ex:heavyH}) this is as trivial as the self-similarity of a point or a line. For $\rho\in(0,1)$ this self-similarity is more interesting, and related to the fact that Reed-Muller codes are decreasing monomial codes~\cite[Prop.~2]{Bardet_DecreasingMonomial}. In Appendix~\ref{proof:selfsimilar:RM} we prove
\begin{prop}\label{prop:selfsimilar:RM}
Let $\Hset_n(\rho,k):=\Hset(\rho) \cap [(k-1)2^{-n},k2^{-n}]$ for $k=1,\dotsc,2^n$. $\Hset(\rho)=\Hset_0(\rho,1)$ is \emph{quasi self-similar} in the sense that, for all $n$ and all $k$, $\Hset_n(\rho,k)={\Hset}_{n+1}(\rho,2k-1)\cup{\Hset}_{n+1}(\rho,2k)$ is quasi self-similar:
\begin{multline}
2{\Hset}_{n+1}(\rho,2k-1)-(k-1)2^{-n} \subset\\ \Hset_{n}(\rho,k)\subset 2{\Hset}_{n+1}(\rho,2k)-k2^{-n}.
\end{multline}
\end{prop}
\section{Discussion \& Outlook}\label{sec:discussion}
That polar codes satisfy fractal properties has long been suspected: Every nontrivial, partly polarized channel $W_{2^n}^{b^n}$ gives rise, by further polarization, to both perfect and useless channels, regardless how close $I(W_{2^n}^{b^n})$ is to zero or one. This fact is reflected in our Propositions~\ref{prop:dyadic} and~\ref{prop:dense}, which state that the good channels are dense in the unit interval (and so are the bad channels for BECs): A partial polarization with sequence $b^n$ corresponds to an interval with dyadic endpoints, and denseness implies that in this interval there will be both perfect and useless channels. Proposition~\ref{prop:selfsimilar}, claiming the self-similarity of the sets of good and bad channels, goes one step further and gives these sets structure: If a channel polarized according to the sequence $b^na$ is good, then so is the channel polarized according to $b^n1a$.
An obvious extension of our work should deal with the fractal properties of non-binary polar and Reed-Muller codes. For example, if $q$ is a prime number, then every invertible $\ell\times\ell$ matrix with entries from $\{0,\dots,q-1\}$ is polarizing, unless it is upper-triangular~\cite[Thm.~5.2]{Sasoglu_PolarCodes}. The $n$-fold Kronecker product of one of these matrices generates $\ell^n$ channels. It is easy to design a function mapping $\{0,\dots,\ell-1\}^\infty$ to $[0,1]$ (cf.~\eqref{eq:functionf}), admitting an analysis similar to the one presented in this paper. Along the same lines, it would be interesting to examine the properties of $q$-ary Reed-Muller codes, e.g.,~\cite{Kasami_RMCodes,Delsarte_RMCodes}.
Whether binary or not, it is presently not clear how our infinite-blocklength results can be carried over to practically relevant finite-length codes. Future work shall investigate this issue.
\section*{Acknowledgments}
The author thanks Emmanuel Abbe, Princeton University, and Hamed Hassani, ETH Zurich, for fruitful discussions and suggesting material. The author is particularly indebted to Jean-Pierre Tillich, INRIA, for helpful suggestions and generalizing Proposition~\ref{prop:selfsimilar}.
\appendices
\section{Proof of Proposition~\ref{prop:basins}}\label{proof:basins}
Recall that, by Lemma~\ref{lem:Bhattacharyya}, we have
\begin{equation*}
Z(W_{2^n}^{b^n}) \le p_{b^n}(Z(W)):=g_{b_n}(g_{b_{n-1}}(\cdots g_{b_1}(Z(W)) \cdots )).
\end{equation*}
\begin{lem}[{\cite[Lem.~11]{Hassani_FiniteLength}}]\label{lem:thresholds}
For $\Prob$-almost every realization $b\in\Omega$, there exists a point $\theta(b)\in[0,1]$, such that
\begin{equation}
\limn p_{b^n}(z)=\begin{cases}
0, & z\in[0,\theta(b))\\ 1, & z\in(\theta(b),1]
\end{cases}.
\end{equation}
Furthermore, the thus constructed RV $\theta$ is uniformly distributed on $[0,1]$.
\end{lem}
If $Z(W)<\theta(b)$, $Z(W_\infty^b)\le \limn p_{b^n}(Z(W))=0$, and hence $f(b)\in\Gset$. We now define $\vartheta(f(b)):=\theta(b)$ if $f(b)\notin\mathbb{D}$ and $\vartheta(f(b))=1$ if $f(b)\in\mathbb{D}$ (since $\mathbb{D}\subset\Gset$ by Proposition~\ref{prop:dyadic}).
\begin{IEEEproof}[Proof for BECs]
If $W$ is a BEC, then $Z(W_{2^n}^{b^n}) = p_{b^n}(Z(W))$. Hence, by Lemma~\ref{lem:thresholds}, if $\epsilon<\theta(b)$, then $Z(W_\infty^b)=\limn p_{b^n}(\epsilon)=0$, and if $\epsilon>\theta(b)$, then $Z(W_\infty^b)=\limn p_{b^n}(\epsilon)=1$.
\end{IEEEproof}
\section{Proof of Proposition~\ref{prop:symmetry}}\label{proof:symmetry}
Let $b\in f^{-1}\left([0,1]\setminus\mathbb{D}\right)\subset\{0,1\}^\infty$, and let $\overline{b}$ be such that $\overline{b}_i=1-b_i$ for all $i$. It follows from the linearity of $f$ that $f(b)+f(\overline{b})=f(b+\overline{b})=1$, because $b+\overline{b}=11111\cdots$. Hence, if $x\notin\mathbb{D}$ has binary expansion $b$, then $1-x$ has binary expansion $\overline{b}$.
It can be easily verified that $g_i(1-z)=1-g_{1-i}(z)$ for $i=0,1$. Hence,
\begin{align*}
p_{b^n}(z)&=g_{b_n}(g_{b_{n-1}}(\cdots g_{b_2}(g_{b_1}(z)) \cdots ))\\
&= g_{b_n}(g_{b_{n-1}}(\cdots g_{b_2}(1-g_{\overline{b}_1}(1-z)) \cdots ))\\
&= g_{b_n}(g_{b_{n-1}}(\cdots 1-g_{\overline{b}_2}(g_{\overline{b}_1}(1-z)) \cdots ))\\
&= 1-g_{\overline{b}_n}(g_{\overline{b}_{n-1}}(\cdots g_{\overline{b}_2}(g_{\overline{b}_1}(1-z)) \cdots ))\\
&= 1-p_{\overline{b}^n}(1-z).
\end{align*}
If $0\le z<\theta(b)$, then $1-\theta(b)<1-z\le 1$. Since $0\le z<\theta(b)$ implies $p_{b^n}(z)\to0$ and $p_{\overline{b}^n}(1-z)\to1$, we get $\theta(\overline{b})=1-\theta(b)$, and hence $\vartheta(1-x)=1-\vartheta(x)$. This completes the proof.\hfill\IEEEQED
\section{Proof of Proposition~\ref{prop:dyadic}}\label{proof:dyadic}
That $\Gset\cap\Bset\subseteq\mathbb{D}$ follows from the fact that only dyadic rationals have a non-unique binary expansion. In particular, the preimage of every $x\in\mathbb{D}$ consists of two elements, namely
\begin{subequations}
\begin{equation}
(b^{n-1}b_n 0000000\cdots) \label{eq:dyadic:worse}
\end{equation}
and
\begin{equation}
(b^{n-1}\overline{b}_n 1111111\cdots) \label{eq:dyadic:better}
\end{equation}
\end{subequations}
where $\overline{b}_n=1-b_n$. By the properties of combining and splitting,
\begin{equation}
0<I(W_{2^n}^{b^{n-1}\overline{b}_n}), I(W_{2^n}^{b^{n-1}b_n}) <1.
\end{equation}
We first show that~\eqref{eq:dyadic:better} leads to a good channel. To this end, observe that, by~\cite[Prop.~7]{Arikan_PolarCodes}, the Bhattacharyya parameter satisfies $0<Z(W_{2^{n+1}}^{b^{n-1}\overline{b}_n1})=Z(W_{2^{n}}^{b^{n-1}\overline{b}_n})^2<1$. Iterating the squaring operation drives the Bhattacharyya parameter to zero, i.e., $Z(W_\infty^{b^{n-1}\overline{b}_n 1111111\cdots}) = 0$, hence $I(W_\infty^{b^{n-1}\overline{b}_n 1111111\cdots})=1$ and $\mathbb{D}\in\Gset$.
To show that~\eqref{eq:dyadic:worse} leads to a bad channel, assume that $I(W_{\infty}^{b^n0000000\cdots})=\delta$. We now show that for every $a\in\Omega$, $I(W_\infty^{b^n0000000\cdots})\le I(W_\infty^{b^na})$. For example, take $a=(1011100\cdots)$. By Lemmas~\ref{lem:grading} $(a)$ and~\ref{lem:betterisupgraded} $(b)$, the following list of relations can be shown:
\begin{align*}
W_\infty^{b^n} &\stackrel{(a)}{\preccurlyeq} W_\infty^{b^n1}\\
W_\infty^{b^n0} &\stackrel{(b)}{\preccurlyeq} W_\infty^{b^n10}\\
W_\infty^{b^n0} &\stackrel{(a)}{\preccurlyeq} W_\infty^{b^n101}\\
W_\infty^{b^n0} &\stackrel{(a)}{\preccurlyeq} W_\infty^{b^n1011}\\
W_\infty^{b^n0} &\stackrel{(a)}{\preccurlyeq} W_\infty^{b^n10111}\\
W_\infty^{b^n00} &\stackrel{(b)}{\preccurlyeq} W_\infty^{b^n101110}\\
W_\infty^{b^n000} &\stackrel{(b)}{\preccurlyeq} W_\infty^{b^n1011100}\\
\dots &\preccurlyeq \dots
\end{align*}
and hence, $W_\infty^{b^n0000000\cdots} \preccurlyeq W_\infty^{b^na}$. By Lemma~\ref{lem:grading}, $\delta=I(W_\infty^{b^n0000000\cdots})\le I(W_\infty^{b^na})$ for every $a\in\Omega$, hence also
\begin{equation}
\delta \le \inf_{a\in\Omega} I(W_\infty^{b^na}).
\end{equation}
But since $0<I(W_{2^n}^{b^n})<1$, by Proposition~\ref{prop:polarization} there must be sequences $a$ such that $I(W_\infty^{b^na})=0$, hence $\delta=0$ and $\mathbb{D}\in\Bset$.\hfill\IEEEQED
\section{Proof of Proposition~\ref{prop:dense}}\label{proof:dense}
The proof follows from showing that between every dyadic rational we can find a rational $x\in\mathbb{Q}\setminus\mathbb{D}$ such that $x\in\Gset$. To this end, fix $x_1=p/2^n$ and $x_2=(p+1)/2^n$. Let further $b^n$ be the terminating binary expansion of $x_1$, i.e., $f(b^n000\cdots)=x_1$. Let $a^k$ be such that $a_1=\cdots=a_{k-1}=1$ and $a_k=0$. Note that $x:=f(b^na^ka^ka^k\cdots)\in(x_1,x_2)$. We now bound the polynomial $p_{a^k}$ from above:
\begin{equation*}
p_{a^k}(z)= 2z^{2^{k-1}}-z^{2^{k}}\le 2 z^{2^{k-1}}
\end{equation*}
The bound crosses $z$ at $z=0$ and at $z^*=2^{-1/(2^{k-1}-1)}$. From this follows that $p_{a^k}(z)<z$ for $z<z^*$, where $z^*$ can be made arbitrarily close to one for $k$ sufficiently large. Hence, if $z_{i+1}=p_{a^k}(z_i)$, then $z_i\to 0$ if $z_0<z^*$. Let $z_0=Z(W_{2^n}^{b_n})$ and let $k$ be sufficiently large such that $z^*>z_0$. Then, $Z(W_\infty^{b^na^ka^k\cdots})=0$ and $x\in\Gset$.
\begin{IEEEproof}[Proof for BECs]
It remains to show that also $\Bset\setminus\mathbb{D}$ is dense in $[0,1]$. To this end, we consider the sequence $a^k$ such that $a_1=\cdots=a_{k-1}=0$ and $a_k=1$. We now bound the polynomial $p_{a^k}$ from below:
\begin{align*}
p_{a^k}(z) &= \left(1-(1-z)^{2^{k-1}}\right)^2\\
&= 1-2(1-z)^{2^{k-1}}+(1-z)^{2^{2k-2}}\\
&\ge 1-2(1-z)^{2^{k-1}}
\end{align*}
The bound crosses $z$ at at $z=1$ and $z^*=1-2^{-1/(2^{k-1}-1)}$. From this follows that $p_{a^k}(z)>z$ for $z>z^*$, where $z^*$ can be made arbitrarily close to zero for $k$ sufficiently large. Hence, if $z_{i+1}=p_{a^k}(z_i)$, then $z_i\to 1$ if $z_0>z^*$. Let $z_0=Z(W_{2^n}^{b_n})$ and let $k$ be sufficiently large such that $z^*<z_0$. Then, $Z(W_\infty^{b^na^ka^k\cdots})=1$ and $x\in\Bset$.
\end{IEEEproof}
\section{Proof of Proposition~\ref{prop:lebesgue}}\label{proof:lebesgue}
In the proof we use Lemma~\ref{lem:fprops}. Note that $\lambda(\Gset)=\lambda(\Gset\setminus\mathbb{D}) + \lambda(\mathbb{D}) = \lambda(\Gset\setminus\mathbb{D})$, and similarly, $\lambda(\Bset)=\lambda(\Bset\setminus\mathbb{D})$. Since $f$ is bijective on $\Omega':=\Omega\setminus f^{-1}(\mathbb{D})$, Definition~\ref{def:gset} implies
\begin{equation}
x\in\Gset\setminus\mathbb{D} \Leftrightarrow I(W_\infty^{f^{-1}(x)})=1
\end{equation}
or $f^{-1}(\Gset\setminus\mathbb{D}) = \{b\in\Omega'{:}\ I(W_\infty^{b})=1\}$. Note further that $\Prob(f^{-1}(\mathbb{D}))=0$. Hence, by Proposition~\ref{prop:polarization},
\begin{multline}
\lambda(\Gset)=\lambda(\Gset\setminus\mathbb{D}) = \Prob(\{b\in\Omega'{:}\ I(W_\infty^{b})=1\}) \\= \Prob(I_\infty=1)=I(W).
\end{multline}
The proof for the set of bad channels follows along the same lines.\hfill\IEEEQED
\section{Proof of Proposition~\ref{prop:selfsimilar}}\label{proof:selfsimilar}
Since the dyadic rationals are self-similar and since, by Proposition~\ref{prop:dyadic}, $\mathbb{D}\subset\Gset$, one has, for all $n$ and $k$,
\begin{equation}
\Gset_n(k)\cap\mathbb{D} = 2\left(\Gset_{n+1}(2k)\cap\mathbb{D}\right)-k2^{-n}.
\end{equation}
We now treat those values in $[0,1]$ that are not dyadic rationals. If $b_k^n=b_1b_2\cdots b_n$ is the terminating binary expansion of $(k-1)2^{-n}$, every value in $[(k-1)2^{-n},k2^{-n}]$ has a binary expansion $b_k^na$ for some $a\in\Omega$, where $b_n=1$ if and only if $(k-1)$ is odd. Similarly, and since $(2k-1)$ is always odd, every value in $[(2k-1)2^{-n-1},k2^{-n}]$ has a binary expansion $b_k^n1a'$ for some $a'\in\Omega$. Assume that $a'=a$. Then, by Lemmas~\ref{lem:grading} and~\ref{lem:betterisupgraded}, $W_\infty^{b_k^na}\preccurlyeq W_\infty^{b_k^n1a}$ for all $a$. Hence, if $f(b_k^na)\in\Gset_n(k)$, then $f(b_k^n1a)\in\Gset_{n+1}(2k)$. It remains to show that $2f(b_k^n1a)-f(b_{k+1}^n)=f(b_k^na)$:
\begin{align*}
f(b_k^na)+f(b_{k+1}^n) &= f(b_k^n)+2^{-n}f(a)+f(b_{k+1}^n)\\
&= (k-1)2^{-n} + 2^{-n}f(a) + k2^{-n}\\
&= (2k-1)2^{-n} + 2^{-n}f(a)\\
&= 2(2k-1)2^{-n-1}+ 2\cdot2^{-n-1}f(a)\\
&= 2f(b_k^n1)+2\cdot2^{-n-1}f(a)\\
&= 2f(b_k^n1a)
\end{align*}
\begin{IEEEproof}[Proof for Symmetric Channels]
Since $(2k-2)$ is always even, every value in $[(2k-2)2^{-n-1},(2k-1)2^{-n-1}]$ has a binary expansion $b_k^n0a$ for some $a\in\Omega$. Then, by Lemmas~\ref{lem:grading} and~\ref{lem:betterisupgraded}, $W_\infty^{b_k^n0a}\preccurlyeq W_\infty^{b_k^na}$ for all $a$. Hence, if $f(b_k^n0a)\in\Gset_{n+1}(2k)$, then $f(b_k^na)\in\Gset_n(k)$. It remains to show that $2f(b_k^n0a)-f(b_{k}^n)=f(b_k^na)$:
\begin{align*}
f(b_k^na)+f(b_{k}^n) &= f(b_k^n)+2^{-n}f(a)+f(b_{k}^n)\\
&= (k-1)2^{-n} + 2^{-n}f(a) + (k-1)2^{-n}\\
&= (2k-2)2^{-n} + 2^{-n}f(a)\\
&= 2(2k-2)2^{-n-1}+ 2\cdot2^{-n-1}f(a)\\
&= 2f(b_k^n0)+2\cdot2^{-n-1}f(a)\\
&= 2f(b_k^n0a)
\end{align*}
\end{IEEEproof}
\section{Proof of Proposition~\ref{prop:dyadic:RM}}\label{proof:dyadic:RM}
We take the non-terminating expansion of $x\in\mathbb{D}$, i.e., there is a $b^k\in\{0,1\}^k$ such that $f(b^k1111\cdots)=x$. Hence, $w(b^n)\ge n-k$ for $n\ge k$. In Definition~\ref{def:heavy} we can take the binary logarithm on both sides of the inequality to get the condition
\begin{equation}
x\in \Hset(\rho) \Leftrightarrow \exists b\in f^{-1}(x){:}\ \liminf_{n\to\infty} w(b^n)-n\rho \ge 0.
\end{equation}
But
\begin{align}
\liminf_{n\to\infty} w(b^n)-n\rho &= \limn n(1-\rho)-k
\end{align}
goes to infinity for $\rho<1$.\hfill\IEEEQED
\section{Proof of Proposition~\ref{prop:lebesgue:RM}}\label{proof:lebesgue:RM}
By Example~\ref{ex:normal}, dyadic rationals are not simply normal, hence let $\mathcal{N}\subset [0,1]\setminus\mathbb{D}$ be the set of simply normal numbers in $[0,1]$. Note that $f$ is bijective on $\mathcal{N}$ by Lemma~\ref{lem:fprops}. By Lemma~\ref{lem:borel} we have
\begin{equation}
\forall b\in f^{-1}(\mathcal{N}){:}\ w(b^n)=\frac{1}{2}n+o(n).
\end{equation}
Fix $\rho$. Then,
\begin{equation}
\liminf_{n\to\infty} w(b^n)-n\rho = \limn n\left(\frac{1}{2}-\rho\right) + o(n).
\end{equation}
If $\rho<1/2$, then this limit diverges to infinity, and hence $\mathcal{N}\subset \Hset(\rho)$. Thus, since $\lambda(\mathcal{N})=1$, we have $\lambda(\Hset(\rho))=1$. If $\rho>1/2$, the limit diverges to minus infinity, and hence $\mathcal{N}\not\subset \Hset(\rho)$. Thus, $\Hset(\rho)\subset [0,1]\setminus\mathcal{N}$, from which follows $\lambda(\Hset(\rho))= 0$.
Now let $\rho=1/2$. We define a random variable $B$ on our probability space, such that for all $b\in\Omega$, $B(b)=b$. $B$ is a sequence of independent, identically distributed Bernoulli-1/2 random variables, i.e., for all $i$ we have $\Prob(B_i=1)=\Prob(B_i=0)=1/2$. We have
\begin{equation}
\lambda(\Hset(1/2)) = \Prob\left(\liminf_{n\to\infty} w(B^n)-\frac{n}{2}\ge 0\right).
\end{equation}
Consider the simple random walk $S_n:= w(B^n)-\frac{n}{2}$. Let $N_0(n)$ be the number of zero crossings of the sequence $S_1,\dotsc,S_n$, and let $N_0(n,b)$ be the number of zero crossings corresponding to the realization $b\in\Omega$. The event $\liminf_{n\to\infty} w(b^n)-\frac{n}{2}\ge 0$ can only happen if the realization of $S_n$ corresponding to $b$ has only finitely many zero crossings, i.e.,
\begin{align*}
&\{b\in\Omega{:}\ \liminf_{n\to\infty} w(b^n)-\frac{n}{2}\ge 0\}\notag\\
&\subseteq
\{b\in\Omega{:}\ \exists R\in\mathbb{N}_0{:} \limn N_0(n,b)\le R\}\\
&= \bigcup_{R=0}^\infty \{b\in\Omega{:}\ \limn N_0(n,b)\le R\}\\
&= \bigcup_{R=0}^\infty \liminf_{n\to\infty} \{b\in\Omega{:}\ N_0(n,b)\le R\}
\end{align*}
and hence
\begin{multline}
\Prob\left(\{b\in\Omega{:}\ \liminf_{n\to\infty} w(b^n)-\frac{n}{2}\ge 0\}\right)\\
\le \sum_{R=0}^\infty \Prob(\liminf_{n\to\infty} \{b\in\Omega{:}\ N_0(n,b)\le R\})\\
\le \sum_{R=0}^\infty \limn \Prob(N_0(n)\le R) \label{eq:sumOfProbabilities}
\end{multline}
where the second inequality is due to Fatou's lemma~\cite[Lem.~1.28, p.~23]{Rudin_Analysis3}.
With~\cite[Ch.~III.5,~p.~84]{Feller_Probability}
\begin{equation}
\Prob(N_0(n)=R) = 2\Prob(S_{2n+1}=2R+1)
\end{equation}
we get
\begin{align*}
\Prob(N_0(n)\le R)&=2\sum_{r=0}^R \Prob(S_{2n+1}=2r+1)\\
&\stackrel{(a)}{=}2\sum_{r=0}^R {2n+1 \choose n-r} 2^{-2n-1}\\
&\le 2^{-2n} \sum_{r=0}^R {2n+2 \choose n+1}\\
&= 2^{-2n} (R+1) {2n+2 \choose n+1}\\
&\stackrel{(b)}{\le} 2^{-2n} (R+1) e 2^{2n+2} \frac{1}{\sqrt{(n+1)\pi}}\\
&= \frac{4e (R+1)}{\sqrt{(n+1)\pi}}
\end{align*}
where $(a)$ is~\cite[eq.~(2.2),~p.~75]{Feller_Probability} and $(b)$ is due to Stirling's approximation~\cite[eq.~6.1.38, p.~257]{Abramowitz_Handbook}. Since for $n\to\infty$ this probability is zero, we have by~\eqref{eq:sumOfProbabilities}
\begin{equation}
\lambda(\Hset(1/2)) = \Prob\left(\liminf_{n\to\infty} w(B^n)-\frac{n}{2}\ge 0\right) =0.
\end{equation}
This completes the proof.\hfill\IEEEQED
\section{Proof of Proposition~\ref{prop:hausdorff:RM}}\label{proof:hausdorff:RM}
That $\infodim{\Hset(\rho)}=1$ for $\rho<1/2$ follows from Proposition~\ref{prop:lebesgue:RM} in combination with Corollary~\ref{cor:hausdorff}.
For $\rho\ge 1/2$, we define
\begin{equation}
\tilde{\mathcal{N}}_p := \left\{x\in[0,1]{:}\ \exists b\in f^{-1}(x){:} \limn \frac{w(b^n)}{n}=p\right\}
\end{equation}
for some $p\in (0,1)$. Note that $\tilde{\mathcal{N}}_{1/2}=\mathcal{N}$. By~\cite{Eggleston_FractalSets} (cf.~\cite[Chapter~8]{Kuipers_Uniform} for further notes), the Hausdorff dimension of this set is given by\footnote{Interestingly, in Eggleston's paper, the dimension was not connected to entropy; it was submitted earlier in the same year as Shannon's Mathematical Theory of Communication was published.}
\begin{equation}
\infodim{\tilde{\mathcal{N}}_p}=h_2(p).
\end{equation}
Reasoning as in the proof of Proposition~\ref{prop:lebesgue:RM}, $\tilde{\mathcal{N}}_p\subset \Hset(\rho)$ if $p>\rho$ and $\tilde{\mathcal{N}}_p\not\subset \Hset(\rho)$ if $p<\rho$. As a consequence,
\begin{equation}
\bigcup_{n=1}^\infty \tilde{\mathcal{N}}_{\rho+1/n}\subset\Hset(\rho).
\end{equation}
For a countable sequence of sets $A_n$, Hausdorff dimension satisfies~\cite[p.~49]{Falconer_Fractals}
\begin{equation}
\infodim{\bigcup_{n=1}^\infty A_n} = \sup_{n\ge 1} \infodim{A_n},
\end{equation}
and hence, by the monotonicity of Hausdorff dimension~\cite[p.~48]{Falconer_Fractals},
\begin{equation}
\infodim{\Hset(\rho)} \ge \sup_{n\ge 1} h_2(\rho+1/n) = h_2(\rho)
\end{equation}
where the last equality follows from the fact that the binary entropy function decreases with increasing $\rho$ for $\rho\ge 1/2$. In particular, for $\rho=1/2$, $\infodim{\Hset(\rho)} =1$. This completes the proof. \hfill\IEEEQED
\section{Proof of Proposition~\ref{prop:selfsimilar:RM}}\label{proof:selfsimilar:RM}
The proof follows along the lines of the proof of Proposition~\ref{prop:selfsimilar}. Let again $b_k^n$ be the terminating expansion of $(k-1)2^{-n}$, and let $a\in\Omega$. The connections between the sequences $b:=b_k^na$, $b_-:=b_k^n0a$, and $b_+:=b_k^n1a$ have been established above. To prove the theorem, we have to show that
\begin{subequations}
\begin{align}
& \liminf_{m\to\infty} w(b_-^m)-\rho m\ge 0 \label{eq:bminus}\\
&\Rightarrow \liminf_{m\to\infty} w(b^m)-\rho m\ge 0\label{eq:b}\\
&\Rightarrow \liminf_{m\to\infty} w(b_+^m)-\rho m\ge 0\label{eq:bplus}.
\end{align}
\end{subequations}
This is obtained by
\begin{subequations}
\begin{align}
&\liminf_{m\to\infty}w(b_-^m)-\rho m \notag\\
&= w(b_k^n0)-\rho (n+1) + \liminf_{m\to\infty}w(a^m)-\rho m\notag\\
&= w(b_k^n)-\rho n-\rho + \liminf_{m\to\infty}w(a^m)-\rho m\notag\\
&\le w(b_k^n)-\rho n + \liminf_{m\to\infty}w(a^m)-\rho m\label{eq:boundb}\\
&\le w(b_k^n)-\rho n + (1-\rho) + \liminf_{m\to\infty}w(a^m)-\rho m\notag\\
&= w(b_k^n1)-\rho (n+1) + \liminf_{m\to\infty}w(a^m)-\rho m\label{eq:boundbplus}
\end{align}
\end{subequations}
where~\eqref{eq:boundb} equals~\eqref{eq:b} and where~\eqref{eq:boundbplus} equals~\eqref{eq:bplus}. The inequalities yield the desired result. \hfill\IEEEQED
\bibliographystyle{IEEEtran}
|
{'timestamp': '2016-02-26T02:06:49', 'yymm': '1506', 'arxiv_id': '1506.05231', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05231'}
|
arxiv
|
\section{Introduction}
\label{sec:intro}
In recent years, online social networks providing various featured services have become an essential part in our lives. To enjoy more social network services, users nowadays are usually involved in multiple online social networks simultaneously \cite{KZY13, ZKY13, ZKY14, ZYZ14} and there can be significant overlaps of users shared by different networks. As pointed out in \cite{DS13}, by the end of 2013, $42\%$ of online adults are using multiple social sites at the same time. For example, $93\%$ of Instagram users are involved in Facebook concurrently and 53\% Twitter users are using Instagram as well \cite{M14}. Formally, the common users involved in different networks simultaneously are named as the ``\textit{anchor users}'' \cite{KZY13}, while the remaining unshared users are called the ``\textit{non-anchor users}'' \cite{ZYZ14}. The connections between accounts of anchor users in different networks are defined as the ``\textit{anchor links}'' \cite{KZY13} and networks partially aligned by anchor links can be represented as ``\textit{partially aligned networks}'' \cite{ZKY14}.
\noindent \textbf{Problem Studied}: In this paper, we want to predict the \textit{anchor links} across \textit{partially aligned networks}, which is formally defined as the ``\textit{partial network alignment}'' problem.
\textit{Partial network alignment} problem is very important for social networks and can be the prerequisite for many real-world social applications, e.g., link prediction and recommendations \cite{ZKY13, ZKY14, ZYZ14, ZY15-3}, community detection \cite{JZYYL14, ZY15, ZY15-2} and information diffusion \cite{ZZWYX15}. Identifying accounts of anchor users across networks provides the opportunity to compose a more complete social graph with users' information in all the networks they are involved in. Information in the complete social graph is helpful for a better understanding of users' social behavior in online social networks \cite{KZY13, ZY15-2, ZZWYX15}. In addition, via the predicted anchor links, cross-platform information exchange enables new social networks to start their services based on the rich data available in other developed networks. The information transferred from developed networks can help emerging networks \cite{ZKY14, ZY15} to overcome the information shortage problem promisingly \cite{ZKY13, ZKY14, ZY15}.
What's more, the \textit{partial network alignment} problem is a novel problem and different from existing link prediction works, like (1) \textit{traditional intra-network link prediction problems} \cite{SBGAH11, SHAC12}, which mainly focus on predicting links in \textit{one single} social network, (2) \textit{inter-network link transfer problems} \cite{ZKY14}, which can predict links in \textit{one single} network with information from multiple \textit{aligned networks}, and (3) \textit{inferring anchor links across fully aligned networks} \cite{KZY13}, which aims at predicting anchor links across \textit{fully aligned networks}.
The \textit{inferring anchor links across fully aligned networks} problem \cite{KZY13} also studies the \textit{anchor link prediction} problem. However, both the problem setting and method proposed to address the ``\textit{network alignment}'' problem between two \textit{fully aligned networks} in \cite{KZY13} are very ad hoc and have many disadvantages. First of all, the full alignment assumption of social networks proposed in \cite{KZY13} is too strong as fully aligned networks can hardly exist in the real world \cite{ZYZ14}. Secondly, the features extracted for \textit{anchor links} in \cite{KZY13} are proposed for Foursquare and Twitter specifically, which can be hard to get generalized to other networks. Thirdly, the classification based link prediction algorithm used in \cite{KZY13} can suffer from the \textit{class imbalance} problem \cite{LLC10, ME11}. The problem will be more serious when dealing with \textit{partially aligned networks}. Finally, the matching algorithm proposed in \cite{KZY13} is designed specially for \textit{fully aligned networks} and maps all users (including both \textit{anchor} and \textit{non-anchor} users) from one network to another network via the predicted anchor links, which will introduce a large number of non-existing anchor links when applied in the partial network alignment problem.
Totally different from the ``\textit{inferring anchor links across fully aligned networks}'' problem \cite{KZY13}, we study a more general \textit{network alignment} problem in this paper. Firstly, networks studied in this paper are partially aligned \cite{ZYZ14}, which contain large number of anchor and non-anchor users \cite{ZYZ14} at the same time. Secondly, networks studied are not confined to Foursquare and Twitter social networks. A minor revision of the ``\textit{partial network alignment}'' problem can be mapped to many other existing tough problems, e.g., large biology network alignment \cite{BGGSW09}, entity resolution in database integration \cite{BG07}, ontology matching \cite{ES07}, and various types of entity matching in online social networks \cite{PFRE13}. Thirdly, the \textit{class imbalance} problem will be addressed via link sampling effectively in the paper. Finally, the constraint on \textit{anchor links} is ``$one-to-one_{\le}$'' (i.e., each user in one network can be mapped to at most one user in another network). Across partially aligned networks, only anchor users can be connected by anchor links. Identifying the non-anchor users from networks and pruning all the predicted potential anchor links connected to them is a novel yet challenging problem. The ``$one-to-one_{\le}$'' constraint on anchor links can distinguish the ``\textit{partial network alignment}'' problem from most existing link prediction problems. For example, in traditional link prediction and link transfer problems \cite{SBGAH11, SHAC12, ZKY14}, the constraint on links is ``\textit{many-to-many}'', while in the ``\textit{anchor link inference}'' problem \cite{KZY13} across fully aligned networks, the constraint on \textit{anchor links} is strict ``\textit{one-to-one}''.
To solve the ``\textit{partial network alignment}'' problem, a new method, {\our} (\underline{P}artial \underline{N}etwork \underline{A}ligner), is proposed in this paper. {\our} exploits the concept of \textit{anchor meta paths} \cite{ZYZ14, SBGAH11} and utilizes the \textit{tensor decomposition} \cite{MJE12, KB09} technique to obtain a set of \textit{explicit anchor adjacency features} and \textit{latent topological features}. In addition, {\our} generalizes the traditional \textit{stable matching} to support partially aligned network through \textit{self-matching} and \textit{partial stable matching} and introduces the a novel matching method, \textit{generic stable matching}, in this paper.
The rest of this paper is organized as follows. In Section~\ref{sec:formulation}, we will give the definition of some important concepts and formulate the \textit{partial network alignment} problem. {\our} method will be introduces in Sections~\ref{sec:feature_extraction}-\ref{sec:truncation}. Section~\ref{sec:experiment} is about the experiments. Related works will be given in Section~\ref{sec:relatedworks}. Finally, we conclude the paper in Section~\ref{sec:conclusion}.
\section{Problem Formulation}
\label{sec:formulation}
Before introducing the method {\our}, we will first define some important concepts and formulate the \textit{partial network alignment} problem in this section.
\subsection{Terminology Definition}
\noindent \textbf{Definition 1} (Heterogeneous Social Networks): A \textit{heterogeneous social network} can be represented as $G = (\mathcal{V}, \mathcal{E})$, where $\mathcal{V} = \bigcup_i \mathcal{V}_i$ contains the sets about various kinds of nodes, while $\mathcal{E} = \bigcup_j \mathcal{E}_j$ is the set of different types of links among nodes in $\mathcal{V}$.
\noindent \textbf{Definition 2} (Aligned Heterogeneous Social Networks): Social networks that share common users are defined as the \textit{aligned heterogeneous social networks}, which can be represented as $\mathcal{G} = (G_{set}, A_{set})$, where $G_{set} = (G^{(1)}, G^{(2)}, \cdots, G^{(n)})$ is the set of $n$ different \textit{heterogeneous social networks} and $A_{set} = (\mathcal{A}^{(1,2)}, \mathcal{A}^{(1,3)}, \cdots, \mathcal{A}^{((n-1), n)})$ is the sets of undirected \textit{anchor links} between networks in $G_{set}$.
\noindent \textbf{Definition 3} (Anchor Link): Given two social networks $G^{(i)}$ and $G^{(j)}$, link $(u^{(i)}, v^{(j)})$ is an \textit{anchor link} between $G^{(i)}$ and $G^{(j)}$ iff ($u^{(i)} \in \mathcal{U}^{(i)}$) $\land$ ($v^{(j)} \in \mathcal{U}^{(j)}$) $\land$ ($u^{(i)}$ and $v^{(j)}$ are accounts of the same user), where $\mathcal{U}^{(i)}$ and $\mathcal{U}^{(j)}$ are the user sets of $G^{(i)}$ and $G^{(j)}$ respectively.
\noindent \textbf{Definition 4} (Anchor Users and Non-anchor Users): Users who are involved in two social networks, e.g., $G^{(i)}$ and $G^{(j)}$, simultaneously are defined as the \textit{anchor users} between $G^{(i)}$ and $G^{(j)}$. \textit{Anchor users} in $G^{(i)}$ between $G^{(i)}$ and $G^{(j)}$ can be represented as $\mathcal{U}^{(i)}_{\mathcal{A}^{(i,j)}} = \{u^{(i)} | u^{(i)} \in \mathcal{U}^{(i)}, \exists v^{(j)} \in \mathcal{U}^{(j)}, \mbox{ and }\\(u^{(i)}, v^{(j)}) \in \mathcal{A}^{(i,j)}\}$. Meanwhile, the \textit{non-anchor user} in $G^{(i)}$ between $G^{(i)}$ and $G^{(j)}$ are those who are involved in $G^{(i)}$ only and can be represented as $\mathcal{U}^{(i)}_{-\mathcal{A}^{(i,j)}} = \mathcal{U}^{(i)} - \mathcal{U}^{(i)}_{\mathcal{A}^{(i,j)}}$. Similarly, the \textit{anchor users} and \textit{non-anchor users} in $G^{(j)}$ between $G^{(j)}$ and $G^{(i)}$ can be defined as $\mathcal{U}^{(j)}_{\mathcal{A}^{(i,j)}}$ and $\mathcal{U}^{(j)}_{-\mathcal{A}^{(i,j)}}$ respectively.
\noindent \textbf{Definition 5} (Full Alignment, Partial Alignment and Isolated): Given two social networks $G^{(i)}$ and $G^{(j)}$, if users in both $G^{(i)}$ and $G^{(j)}$ are all anchor users, i.e., $\mathcal{U}^{(i)} = \mathcal{U}^{(i)}_{\mathcal{A}^{(i,j)}}$ and $\mathcal{U}^{(j)} = \mathcal{U}^{(j)}_{\mathcal{A}^{(i,j)}}$, then $G^{(i)}$ and $G^{(j)}$ are \textit{fully aligned}; if users in both of these two networks are all non-anchor users, i.e., $\mathcal{U}^{(i)} = \mathcal{U}^{(i)}_{-\mathcal{A}^{(i,j)}}$ and $\mathcal{U}^{(j)} = \mathcal{U}^{(j)}_{-\mathcal{A}^{(i,j)}}$, then these two networks are \textit{isolated}; otherwise, they are \textit{partially aligned}.
\noindent \textbf{Definition 6} (Bridge Nodes): Besides users, many other kinds of nodes can be shared between different networks, which are defined as the \textit{bridge nodes} in this paper. The \textit{bridge nodes} shared between $G^{(i)}$ and $G^{(j)}$ can be represented as $\mathcal{B}^{(i,j)} = \{v | (v \in (\mathcal{V}^{(i)} - \mathcal{U}^{(i)})) \land (v \in (\mathcal{V}^{(j)} - \mathcal{U}^{(j)}))\}$.
The social networks studied in this paper can be any \textit{partially aligned social networks} and we use Foursquare, Twitter as a example to illustrate the studied problem and the proposed method. Users in both Foursquare and Twitter can make friends with other users, write posts, which can contain words, timestamps, and location checkins. In addition, users in Foursquare can also create lists of locations that they have visited/want to visit in the future. As a result, Foursquare and Twitter can be represented as \textit{heterogeneous social network} $G = (\mathcal{V}, \mathcal{E})$. In Twitter $\mathcal{V} = \mathcal{U} \cup \mathcal{P} \cup \mathcal{W} \cup \mathcal{T} \cup \mathcal{L}$ and in Foursquare $\mathcal{V} = \mathcal{U} \cup \mathcal{P} \cup \mathcal{W} \cup \mathcal{T} \cup \mathcal{I} \cup \mathcal{L}$, where $\mathcal{U}$, $\mathcal{P}$, $\mathcal{W}$, $\mathcal{T}$, $\mathcal{I}$ and $\mathcal{L}$ are the nodes of users, posts, words, timestamps, lists and locations. While in Twitter, the heterogeneous link set $\mathcal{E} = \mathcal{E}_{u,u} \cup \mathcal{E}_{u,p} \cup \mathcal{E}_{p,w} \cup \mathcal{E}_{p,t} \cup \mathcal{E}_{p,l}$ and in Foursquare $\mathcal{E} = \mathcal{E}_{u,u} \cup \mathcal{E}_{u,p} \cup \mathcal{E}_{p,w} \cup \mathcal{E}_{p,t} \cup \mathcal{E}_{p,l} \cup \mathcal{E}_{u,i} \cup \mathcal{E}_{i,l}$. The \textit{bridge nodes} shared between Foursquare and Twitter include the \textit{common locations}, \textit{common words} and \textit{common timestamps}.
\subsection{Problem Statement}
\noindent \textbf{Definition 7} (Partial Network Alignment): For any two given \textit{partially aligned heterogeneous social networks}, e.g., $\mathcal{G} = ((G^{(i)}, G^{(j)}), (\mathcal{A}^{(i,j)}))$, part of the known \textit{anchor links} between $G^{(i)}$ and $G^{(j)}$ are represented as $\mathcal{A}^{(i,j)}$. Let $\mathcal{U}^{(i)}$, $\mathcal{U}^{(j)}$ be the user sets of $G^{(i)}$ and $G^{(j)}$ respectively, the set of other potential \textit{anchor links} between $G^{(i)}$ and $G^{(j)}$ can be represented as $\mathcal{L}^{(i,j)} = \{(u^{(i)}, v^{(j)}) | (u^{(i)} \in \mathcal{U}^{(i)}) \land (v^{(j)} \in \mathcal{U}^{(j)}\} - \mathcal{A}^{(i,j)}$. We solve the \textit{partial network alignment} problem as a \textit{link classification} problem, where existing and non-existing \textit{anchor links} are labeled as ``+1'' and ``-1'' respectively. In this paper, we aim at building a model $\mathcal{M}$ with the existing \textit{anchor links} $\mathcal{A}^{(i,j)}$, which will be applied to predict potential \textit{anchor links} in $\mathcal{L}^{(i,j)}$. In model $\mathcal{M}$, we want to determine both \textit{labels} and \textit{existence probabilities} of \textit{anchor links} in $\mathcal{L}^{(i,j)}$.
\section{Feature Extraction and Anchor Link Prediction} \label{sec:feature_extraction}
\textit{Supervised link prediction} method has been widely used in research due to its excellent performance and the profound supervised learning theoretical basis. In supervised link prediction, links are labeled differently according to their physical meanings, e.g., existing vs non-existent \cite{ZYZ14}, friends vs enemies \cite{WS12}, trust vs distrust \cite{YTYXL13}, positive attitude vs negative attitude \cite{YCZC13}. With information in the networks, a set of heterogeneous features can be extracted for links in the training set, which together with the labels are used to build the link prediction model $\mathcal{M}$.
In this section, we will introduce different categories of general features extracted for \textit{anchor links} across \textit{partially aligned networks}, which include a set of \textit{explicit anchor adjacency features} based on \textit{anchor meta paths} and the ``\textit{latent topological feature vector}'' extracted via \textit{anchor adjacency tensor} decomposition.
\subsection{Traditional Intra-Network Meta Path}
Traditional \textit{meta paths} are mainly defined based on the \textit{social network schema} of one single network \cite{SBGAH11, SHYYW11}.
\noindent \textbf{Definition 8} (Social Network Schema): For a given network $G$, its \textit{schema} is defined as $S_G = (\mathcal{T}_G, \mathcal{R}_G)$, where $\mathcal{T}_G$ and $\mathcal{R}_G$ are the sets of node types and link types in $G$ respectively.
\noindent \textbf{Definition 9} (Meta Path): Based on the schema of network $G$, i.e., $S_G = (\mathcal{T}_G, \mathcal{R}_G)$, the traditional intra-network \textit{meta path} in $G$ is defined as $\Phi = T_1 \xrightarrow{R_1} T_2 \xrightarrow{R_2} \cdots \xrightarrow{R_{k-1}} T_k$, where $T_i \in \mathcal{T}_G, i \in \{1, 2, \cdots, k\}$ and $R_j \in \mathcal{R}_G, j \in \{1, 2, \cdots, k-1\}$ \cite{SBGAH11, SHYYW11}.
For example, according to the networks introduced in Section~\ref{sec:formulation}, we can define the network schema of Twitter as $S_G = (\{User, Post, Word, Timestamp, List, Location\}, \{Follow, \\ Write, Create, Contain, At, Checkin\})$. Based on the schema, ``\textit{User - Location - User}'' is a \textit{meta path} of length 2 connecting user nodes in the network via location node and path ``\textit{Alice} - \textit{San Jose} - \textit{Bob}'' is an instance of such meta path in the network, where \textit{Alice}, \textit{Bob} and \textit{San Jose} are the users and location in the network.
\begin{figure}[t]
\centering
\begin{minipage}[l]{0.8\columnwidth}
\centering
\includegraphics[width=\textwidth]{./fig_schema_of_aligned_networks.pdf}
\end{minipage}
\caption{Schema of aligned heterogeneous network.}\label{fig:schema}
\end{figure}
\subsection{Inter-Network Anchor Meta Path}
Traditional Intra-network \textit{meta paths} defined based on one single network cannot be applied to address the inter-network \textit{partial network alignment} problem directly. To overcome such a problem, in this subsection, we will define the concept of \textit{anchor meta paths} and introduce a set of \textit{inter-network anchor meta paths} \cite{ZYZ14} across partially aligned networks.
\noindent \textbf{Definition 10} (Aligned Social Network Schema): Given the \textit{partially aligned networks}: $\mathcal{G} = (G_{set}, A_{set})$, let $S_{G^{(i)}} = (\mathcal{T}_{G^{(i)}}, \mathcal{R}_{G^{(i)}})$ be the \textit{schema} of network $G^{(i)} \in G_{set}$, the \textit{schema} of \textit{partially aligned networks} $\mathcal{G}$ can be defined as $S_{\mathcal{G}} = \left(\bigcup_i \mathcal{T}_{G^{(i)}}, (\bigcup_i \mathcal{R}_{G^{(i)}}) \cup \{Anchor\}\right)$, where $\{Anchor\}$ is the \textit{anchor link} type.
An example of the schema about two \textit{partially aligned social networks}, e.g., $G^{(i)}$ (e.g., Foursquare) and $G^{(j)}$ (e.g., Twitter), is shown in Figure~\ref{fig:schema}, where the schema of these two aligned networks are connected by the anchor link type and the green dashed circles are the shared \textit{bridge nodes} between $G^{(i)}$ and $G^{(j)}$.
\noindent \textbf{Definition 11} (AMP: Anchor Meta Path): Based on the \textit{aligned social network schema}, \textit{anchor meta paths} connecting users across $\mathcal{G}$ is defined to be $\Psi = T_1 \xrightarrow{R_1} T_2 \xrightarrow{R_2} \cdots \xrightarrow{R_{k-1}} T_k$, where $T_1$ and $T_{k}$ are the ``User'' node type in two \textit{partially aligned social networks} respectively. To differentiate the \textit{anchor link} type from other link types in the \textit{anchor meta path}, the direction of $R_i$ in $\Psi$ will be bidirectional if $R_i = Anchor, i \in \{1, 2, \cdots, k-1\}$, i.e., $T_i \xleftrightarrow{R_i} T_j$.
Via the instances of \textit{anchor meta paths}, users across \textit{aligned social networks} can be extensively connected to each other. In the two partially aligned social networks (e.g., $\mathcal{G} = ((G^{(i)}, G^{(j)}), (\mathcal{A}^{(i,j)}))$) studied in this paper, various \textit{anchor meta paths} from $G^{(i)}$ (i.e., Foursquare) and $G^{(j)}$ (i.e., Twitter) can be defined as follows:
\begin{itemize}
\item \textit{Common Out Neighbor Anchor Meta Path} ($\Psi_1$): $User^{(i)}$ $\xrightarrow{follow}$ $User^{(i)}$ $\xleftrightarrow{Anchor}$ $User^{(j)}$ $\xleftarrow{follow}$ $User^{(j)}$ or ``$\mathcal{U}^{(i)} \to \mathcal{U}^{(i)} \leftrightarrow \mathcal{U}^{(j)} \gets \mathcal{U}^{(j)}$'' for short.
\item \textit{Common In Neighbor Anchor Meta Path} ($\Psi_2$): $User^{(i)}$ $\xleftarrow{follow}$ $User^{(i)}$ $\xleftrightarrow{Anchor}$ $User^{(j)}$ $\xrightarrow{follow}$ $User^{(j)}$ or ``$\mathcal{U}^{(i)} \gets \mathcal{U}^{(i)} \leftrightarrow \mathcal{U}^{(j)} \to \mathcal{U}^{(j)}$'' .
\item \textit{Common Out In Neighbor Anchor Meta Path} ($\Psi_3$): $User^{(i)}$ $\xrightarrow{follow}$ $User^{(i)}$ $\xleftrightarrow{Anchor}$ $User^{(j)}$ $\xrightarrow{follow}$ $User^{(j)}$ or ``$\mathcal{U}^{(i)} \to \mathcal{U}^{(i)} \leftrightarrow \mathcal{U}^{(j)} \to \mathcal{U}^{(j)}$''.
\item \textit{Common In Out Neighbor Anchor Meta Path} ($\Psi_4$): $User^{(i)}$ $\xleftarrow{follow}$ $User^{(i)}$ $\xleftrightarrow{Anchor}$ $User^{(j)}$ $\xleftarrow{follow}$ $User^{(j)}$ or ``$\mathcal{U}^{(i)} \gets \mathcal{U}^{(i)} \leftrightarrow \mathcal{U}^{(j)} \gets \mathcal{U}^{(j)}$''.
\end{itemize}
These above \textit{anchor meta paths} are all defined based the ``User'' node type only across \textit{partially aligned social networks}. Furthermore, there can exist many other \textit{anchor meta paths} consisting of user node type and other \textit{bridge node} types from Foursquare to Twitter, e.g., Location, Word and Timestamp.
\begin{itemize}
\item \textit{Common Location Checkin Anchor Meta Path 1} ($\Psi_5$): $User^{(i)}$ $\xrightarrow{write}$ $Post^{(i)}$ $\xrightarrow{checkin\ at}$ $Location$ $\xleftarrow{checkin\ at}$ $Post^{(j)}$ $\xleftarrow{write}$ $User^{(j)}$ or ``$\mathcal{U}^{(i)} \to \mathcal{P}^{(i)} \to \mathcal{L} \gets\mathcal{P}^{(j)} \gets \mathcal{U}^{(j)}$''.
\item \textit{Common Location Checkin Anchor Meta Path 2} ($\Psi_6$): $User^{(i)}$ $\xrightarrow{create}$ $List^{(i)}$ $\xrightarrow{contain}$ $Location$ $\xleftarrow{checkin\ at}$ $Post^{(j)}$ $\xleftarrow{write}$ $User^{(j)}$ or ``$\mathcal{U}^{(i)} \to \mathcal{I}^{(i)} \to \mathcal{L} \gets\mathcal{P}^{(j)} \gets \mathcal{U}^{(j)}$''.
\item \textit{Common Timestamps Anchor Meta Path} ($\Psi_7$): $User^{(i)}$ $\xrightarrow{write}$ $Post^{(i)}$ $\xrightarrow{at}$ $Time$ $\xleftarrow{at}$ $Post^{(j)}$ $\xleftarrow{write}$ $User^{(j)}$ or ``$\mathcal{U}^{(i)} \to \mathcal{P}^{(i)} \to \mathcal{T} \gets\mathcal{P}^{(j)} \gets \mathcal{U}^{(j)}$''.
\item \textit{Common Word Usage Anchor Meta Path} ($\Psi_8$): $User^{(i)}$ $\xrightarrow{write}$ $Post^{(i)}$ $\xrightarrow{contain}$ $Word$ $\xleftarrow{contain}$ $Post^{(j)}$ $\xleftarrow{write}$ $User^{(j)}$ or ``$\mathcal{U}^{(i)} \to \mathcal{P}^{(i)} \to \mathcal{W} \gets\mathcal{P}^{(j)} \gets \mathcal{U}^{(j)}$''.
\end{itemize}
\subsection{Explicit Anchor Adjacency Features}
Based on the above defined \textit{anchor meta paths}, different kinds of anchor meta path based adjacency relationship can be extracted from the network. In this paper, we define the new concepts of \textit{anchor adjacency score}, \textit{anchor adjacency tensor} and \textit{explicit anchor adjacency features} to describe such relationships among users across \textit{partially aligned social networks}.
\noindent \textbf{Definition 12} (Anchor Meta Path Instance): Based on \textit{anchor meta path} $\Psi = T_1 \xrightarrow{R_1} T_2 \xrightarrow{R_2} \cdots \xrightarrow{R_{k-1}} T_k$, path $\psi = n_1-n_2-\cdots-n_{k-1}-n_k$ is an instance of $\Psi$ iff $n_i$ is an instance of node type $T_i$, $i \in \{1, 2, \cdots, k\}$ and $(n_i, n_{i+1})$ is an instance of link type $R_i$, $\forall i \in \{1, 2, \cdots, k - 1\}$.
\noindent \textbf{Definition 13} (AAS: Anchor Adjacency Score): The \textit{anchor adjacency} score is quantified as the number of \textit{anchor meta path instances} of various \textit{anchor meta paths} connecting users across networks. The \textit{anchor adjacency score} between $u^{(i)} \in \mathcal{U}^{(i)}$ and $v^{(j)} \in \mathcal{U}^{(j)}$ based on meta path $\Psi$ is defined as:
$$AAS_{\Psi}(u^{(i)}, v^{(j)}) = \left| \{ \psi | (\psi \in \Psi) \land (u^{(i)} \in T_1) \land (v^{(j)} \in T_k) \} \right|,$$
where path $\psi$ starts and ends with node types $T_1$ and $T_k$ respectively and $\psi \in \Psi$ denotes that $\psi$ is a path instance of meta path $\Psi$.
The \textit{anchor adjacency scores} among all users across \textit{partially aligned networks} can be stored in the \textit{anchor adjacency matrix} as follows.
\noindent \textbf{Definition 14} (AAM: Anchor Adjacency Matrix): Given a certain \textit{anchor meta path}, $\Psi$, the \textit{anchor adjacency matrix} between $G^{i}$ and $G^{j}$ can be defined as $\mathbf{A}_{\Psi} \in \mathbb{N}^{|\mathcal{U}^{(i)}| \times |\mathcal{U}^{(j)}|}$ and $A(l, m) = AAS_{\Psi}(u_l^{(i)}, u^{(j)}_m), u_l^{(i)} \in \mathcal{U}^{(i)}, u^{(j)}_m \in \mathcal{U}^{(j)}.$
Multiple \textit{anchor adjacency matrix} can be grouped together to form a \textit{high-order tensor}. A \textit{tensor} is a multidimensional array and an N-order \textit{tensor} is an element of the tensor product of $N$ vector spaces, each of which can have its own coordinate system. As a result, an $1$-order \textit{tensor} is a vector, a $2$-order \textit{tensor} is a matrix and \textit{tensors} of three or higher order are called the \textit{higher-order tensor} \cite{KB09, MJE12}.
\noindent \textbf{Definition 15} (AAT: Anchor Adjacency Tensor): Based on meta paths in $\{\Psi_1, \Psi_2, \cdots, \Psi_8\}$, we can obtain a set of \textit{anchor adjacency matrices} between users in two \textit{partially aligned networks} to be $\{\mathbf{A}_{\Psi_1}, \mathbf{A}_{\Psi_2}, \cdots, \mathbf{A}_{\Psi_8}\}$. With $\{\mathbf{A}_{\Psi_1},$ $\mathbf{A}_{\Psi_2},$ $\cdots,$ $\mathbf{A}_{\Psi_8}\}$, we can construct a 3-order \textit{anchor adjacency tensor} $\mathcal{X} \in \mathbb{R}^{|\mathcal{U}^{(i)}| \times |\mathcal{U}^{(j)}| \times 8}$, where the $i_{th}$ layer of $\mathcal{X}$ is the \textit{anchor adjacency matrix} based on \textit{anchor meta path} $\Psi_i$, i.e., $\mathcal{X}(:,:,i) = \mathbf{A}_{\Psi_i}, i \in \{1, 2, \cdots, 8\}$.
Based on the \textit{anchor adjacency tensor}, a set of \textit{explicit anchor adjacency features} can be extracted for \textit{anchor links} across \textit{partially aligned social networks}.
\noindent \textbf{Definition 16} (EAAF: Explicit Anchor Adjacency Features): For a certain \textit{anchor link} $(u^{(i)}_l, u^{(j)}_m)$, the \textit{explicit anchor adjacency feature vectors} extracted based on the \textit{anchor adjacency tensor} $\mathcal{X}$ can be represented as $\mathbf{x} = [x_1, x_2, \cdots, x_8]$ (i.e., the \textit{anchor adjacency scores} between $u^{(i)}_l$ and $u^{(j)}_m$ based on $8$ different \textit{anchor meta paths}), where $x_k = \mathcal{X}(l, m, k), k \in \{1, 2, \cdots, 8\}.$
\subsection{Latent Topological Feature Vectors Extraction}
\textit{Explicit anchor adjacency features} can express manifest properties of the connections across \textit{partially aligned networks} and are the \textit{explicit topological features}. Besides explicit topological connections, there can also exist some hidden common connection patterns \cite{YCZC13} across \textit{partially aligned networks}. In this paper, we also propose to extract the \textit{latent topological feature vectors} from the \textit{anchor adjacency tensor}.
As proposed in \cite{KB09, MJE12}, a \textit{higher-order tensor} can be decomposed into a \textit{core tensor}, e.g., $\mathcal{G}$, multiplied by a matrix along each mode, e.g., $\mathbf{A}, \mathbf{B}, \cdots, \mathbf{Z}$, with various \textit{tensor decomposition methods}, e.g., Tucker decomposition \cite{KB09}. For example, the \textit{3-order anchor adjacency tensor} $\mathcal{X}$ can be decomposed into three matrices $\mathbf{A} \in \mathbb{R}^{\mathcal{U}^{(i)} \times P}$, $\mathbf{B} \in \mathbb{R}^{\mathcal{U}^{(j)} \times Q}$ and $\mathbf{C} \in \mathbb{R}^{8 \times R}$ and a core tensor $\mathcal{G} \in \mathbb{R}^{P \times Q \times R}$, where $P, Q, R$ are the number of columns of matrices $\mathbf{A}, \mathbf{B}, \mathbf{C}$ \cite{KB09}:
\begin{align*}
\mathcal{X} &= \sum_{p=1}^P \sum_{q=1}^Q \sum_{r=1}^R g_{pqr} \mathbf{a}_p \circ \mathbf{b}_q \circ \mathbf{c}_r = [\mathcal{G}; \mathbf{A}, \mathbf{B}, \mathbf{C}],
\end{align*}
where $\mathbf{a}_p \circ \mathbf{b}_q$ denotes the vector outer product of $\mathbf{a}_p$ and $\mathbf{b}_q$.
Each row of $\mathbf{A}$ and $\mathbf{B}$ represents a \textit{latent topological feature vector} of users in $\mathcal{U}^{(i)}$ and $\mathcal{U}^{(j)}$ respectively \cite{MJE12}. Method HOSVD introduced in \cite{KB09} is applied to achieve these decomposed matrices in this paper.
\begin{figure}[t]
\centering
\begin{minipage}[l]{0.7\columnwidth}
\centering
\includegraphics[width=\textwidth]{./fig_under_and_over_sampling_2.pdf}
\end{minipage}
\caption{Instance distribution in feature space.}\label{fig:under_and_over_sampling_2}
\end{figure}
\subsection{Class Imbalance Link Prediction}
Based on the extracted features, various supervised link prediction models \cite{KZY13, ZKY14, ZYZ14} can be applied to infer the potential anchor links across networks. As proposed in \cite{ME11, LLC10}, conventional supervised link prediction methods \cite{TGHL13}, can suffer from the \textit{class imbalance} problem a lot. To address the problem, two effective methods (\textit{down sampling} \cite{KM97} and \textit{over sampling} \cite{CBHK02}) are applied.
\textit{Down sampling} methods aim at deleting the \textit{unreliable negative instances} from the training set. In Figure~\ref{fig:under_and_over_sampling_2}, we show the distributions of training links in the feature space, where negative links can be divided into $4$ different categories \cite{KM97}: (1) \textit{noisy links}: links mixed in the positive links; (2) \textit{borderline links}: links close to the decision boundary; (3) \textit{redundant links}: links which are too far away from the decision boundary in the negative region; and (4) \textit{safe links}: links which are helpful for determining the classification boundary.
Different heuristics have been proposed to remove the \textit{noisy instances} and \textit{borderline instances}, which are detrimental for the learning algorithms. In this paper, we will use the method called \textit{Tomek links} proposed in \cite{T76, KM97}. For any two given instances $\mathbf{x}_1$ and $\mathbf{x}_2$ of different labels, pair $(\mathbf{x}_1, \mathbf{x}_2)$ is called a \textit{tomek link} if there exists no other instances, e.g., $\mathbf{z}$, such that $d(\mathbf{x}_1, \mathbf{z}) < d(\mathbf{x}_1, \mathbf{x}_2)$ and $d(\mathbf{x}_2, \mathbf{z}) < d(\mathbf{x}_1, \mathbf{x}_2)$. Examples that participate in \textit{Tomek links} are either borderline or noisy instances \cite{T76, KM97}. As to the \textit{redundant instances}, they will not harm correct classifications as their existence will not change the classification boundary but they can lead to extra classification costs. To remove the \textit{redundant instances}, we propose to create a \textit{consistent subset} $\mathcal{C}$ of the training set, e.g., $\mathcal{S}$ \cite{KM97}. Subset $\mathcal{C}$ is \textit{consistent} with $\mathcal{S}$ if classifiers built with $\mathcal{C}$ can correctly classify instances in $\mathcal{S}$. Initially, $\mathcal{C}$ consists of all positive instances and one randomly selected negative instances. A classifier, e.g., $kNN$, built with $\mathcal{C}$ is applied to $\mathcal{S}$, where instances that are misclassified are added into $\mathcal{C}$. The final set $\mathcal{C}$ contains the \textit{safe links}.
Another method to overcome the \textit{class imbalance} problem is to \textit{over sample} the \textit{minority class}. Many \textit{over sampling} methods have been proposed, e.g., \textit{over sampling with replacement}, \textit{over sampling with ``synthetic'' instances} \cite{CBHK02}: the minority class is over sampled by introducing new ``synthetic'' examples along the line segment joining $m$ of the $k$ nearest minority class neighbors for each minority class instances. Parameter $k$ is usually set as $5$, while the value of $m$ can be determined according to the ratio to \textit{over sample} the minority class. For example, if the minority class need to be \textit{over sampled} $200\%$, then $m=2$. The instance to be created between a certain example $\mathbf{x}$ and one of its nearest neighbor $\mathbf{y}$ can be denoted as $\mathbf{x} + \mathbf{\theta}^T(\mathbf{x} - \mathbf{y})$, where $\mathbf{x}$ and $\mathbf{y}$ are the feature vectors of two instances and $\mathbf{\theta}^T$ is the transpose of a coefficient vector containing random numbers in range $[0, 1]$.
\section{Anchor Link Pruning with Generic Stable Matching} \label{sec:truncation}
In this section, we will introduce the anchor link pruning methods in details, which include (1) candidate pre-pruning, (2) brief introduction to the traditional stable matching, and (3) the \textit{generic stable matching} method proposed in this paper, which generalizes the concept of traditional stable matching through both \textit{self matching} and \textit{partial stable matching}.
\subsection{Candidate Pre-Pruning}
Across two \textit{partially aligned social networks}, users in a certain network can have a large number of potential \textit{anchor link candidates} in the other network, which can lead to great time and space costs in predicting the anchor links. The problem can be even worse when the networks are of large scales, e.g., containing million even billion users, which can make the \textit{partial network alignment} problem unsolvable. To shrink size of the candidate set, we propose to conduct \textit{candidate pre-pruning} of links in the test set with users' profile information (e.g., names and hometown).
As shown in Figure~\ref{fig:nash_equilibrium}, in the given input test set, users are extensively connected with all their potential partners in other networks via anchor links. For each users, we propose to prune their potential candidates according to the following heuristics:
\begin{itemize}
\item \textit{profile pre-pruning}: users' profile information shared across \textit{partially aligned social networks}, e.g., Foursquare and Twitter, can include username and hometown \cite{ZL13}. Given an anchor link $(u^{(i)}_l, u^{(j)}_m) \in \mathcal{L}$, if the username and hometown of $u^{(i)}_l$ and $u^{(j)}_m$ are totally different, e.g., cosine similarity scores are $0$, then link $(u^{(i)}_l, u^{(j)}_m)$ will be pruned from test set $\mathcal{L}$.
\item \textit{EAAF pruning}: based on the \textit{explicit anchor adjacency tensor} $\mathcal{X}$ extracted in Section~\ref{sec:feature_extraction}, for a given link $(u^{(i)}_l, u^{(j)}_m) \in \mathcal{L}$, if its extracted \textit{explicit anchor adjacency features} are all $0$, i.e., $\mathcal{X}(l, m, x) = 0, x \in \{1, 2, \cdots, 8\}$, then link $(u^{(i)}_l, u^{(j)}_m)$ will be pruned from test set $\mathcal{L}$.
\end{itemize}
\begin{figure}[t]
\centering
\begin{minipage}[l]{1.0\columnwidth}
\centering
\includegraphics[width=\textwidth]{./fig_nash_equilibrium.pdf}
\end{minipage}
\caption{Partial network alignment with pruning.}\label{fig:nash_equilibrium}
\end{figure}
\begin{figure}[t]
\centering
\begin{minipage}[l]{0.8\columnwidth}
\centering
\includegraphics[width=\textwidth]{./fig_truncated_strategy.pdf}
\end{minipage}
\caption{Example of partial matching strategy(K=2).}\label{fig:truncated_strategy}
\end{figure}
\subsection{Traditional Stable Matching}
Meanwhile, as proposed in \cite{KZY13}, the \textit{one-to-one} constraint of anchor links across \textit{fully aligned social networks} can be met by pruning extra potential \textit{anchor link candidates} with \textit{traditional stable matching}. In this subsection, we will introduce the concept of traditional \textit{stable matching} briefly.
Given the user sets $\mathcal{U}^{(1)}$ and $\mathcal{U}^{(2)}$ of two \textit{partially aligned social networks} $G^{(1)}$ and $G^{(2)}$, each user in $\mathcal{U}^{(1)}$(or $\mathcal{U}^{(2)}$) has his preference over users in $\mathcal{U}^{(2)}$(or $\mathcal{U}^{(1)}$). Term $v_j P^{(1)}_{u_i} v_k$ is used to denote that $u_i \in \mathcal{U}^{(1)}$ prefers $v_j$ to $v_k$ for simplicity, where $v_j, v_k \in \mathcal{U}^{(2)}$ and $P^{(1)}_{u_i}$ is the preference operator of ${u_i} \in \mathcal{U}^{(1)}$. Similarly, we can use term $u_i P^{(2)}_{v_j} u_k$ to denote that $v_j \in \mathcal{U}^{(2)}$ prefers $u_i$ to $u_k$ in $\mathcal{U}^{(1)}$ as well.
\noindent \textbf{Definition 17} (Matching): Mapping $\mu: \mathcal{U}^{(1)} \cup \mathcal{U}^{(2)} \to \mathcal{U}^{(1)} \cup \mathcal{U}^{(2)}$ is defined to be a \textit{matching} iff (1) $|\mu(u_i)| = 1, \forall u_i \in \mathcal{U}^{(1)}$ and $\mu(u_i) \in \mathcal{U}^{(2)}$; (2) $|\mu(v_j)| = 1, \forall v_j \in \mathcal{U}^{(2)}$ and $\mu(v_j) \in \mathcal{U}^{(1)}$; (3) $\mu(u_i) = v_j$ iff $\mu(v_j) = u_i$.
\noindent \textbf{Definition 18} (Blocking Pair): A pair $(u_i, v_j)$ is a a \textit{blocking pair} of matching $\mu$ if $u_i$ and $v_j$ prefers each other to their mapped partner, i.e., $(\mu(u_i) \neq v_j) \land (\mu(v_j) \neq u_i)$ and $(v_j P^{(1)}_{u_i} \mu(u_i)) \land (u_i P^{(2)}_{v_j} \mu(v_j))$.
\noindent \textbf{Definition 19} (Stable Matching): Given a matching $\mu$, $\mu$ is \textit{stable} if there is no \textit{blocking pair} in the matching results \cite{DF81}.
As introduced in \cite{KZY13}, the \textit{stable matching} can be obtained with the Gale-Shapley algorithm proposed in \cite{GS62}.
\subsection{Generic Stable Matching}
Stable matching based method proposed in \cite{KZY13} can only work well in \textit{fully aligned social networks}. However, in the real world, few social networks are fully aligned and lots of users in social networks are involved in one network only, i.e., \textit{non-anchor users}, and they should not be connected by any anchor links. However, traditional \textit{stable matching} method cannot identify these \textit{non-anchor users} and remove the predicted \textit{potential anchor links} connected with them. To overcome such a problem, we will introduce the \textit{generic stable matching} to identify the \textit{non-anchor users} and prune the anchor link results to meet the $one-to-one_{\le}$ constraint.
In {\our}, we introduce a novel concept, \textit{self matching}, which allows users to be mapped to themselves if they are discovered to be \textit{non-anchor users}. In other words, we will identify the \textit{non-anchor users} as those who are mapped to themselves in the final matching results.
\noindent \textbf{Definition 20} (Self Matching): For the given two partially aligned networks $G^{(1)}$ and $G^{(2)}$, user $u_i \in \mathcal{U}^{(1)}$, can have his preference $P^{(1)}_{u_i}$ over users in $\mathcal{U}^{(2)} \cup \{u_i\}$ and $u_i$ preferring $u_i$ himself denotes that $u_i$ is an \textit{non-anchor user} and prefers to stay unconnected, which is formally defined as \textit{self matching}.
Users in one social network will be matched with either partners in other social networks or themselves according to their preference lists (i.e., from high preference scores to low preference scores). Only partners that users prefer over themselves will be \textit{accepted} finally, otherwise users will be matched with themselves instead.
\noindent \textbf{Definition 21} (Acceptable Partner): For a given \textit{matching} $\mu: \mathcal{U}^{(1)} \cup \mathcal{U}^{(2)} \to \mathcal{U}^{(1)} \cup \mathcal{U}^{(2)}$, the mapped partner of users $u_i \in \mathcal{U}^{(1)}$, i.e., $\mu(u_i)$, is \textit{acceptable} to $u_i$ iff $\mu(u_i)P^{(1)}_{u_i}u_i$.
To cut off the partners with very low \textit{preference scores}, we propose the \textit{partial matching strategy} to obtain the promising partners, who will participate in the matching finally.
\noindent \textbf{Definition 22} (Partial Matching Strategy): The \textit{partial matching strategy} of user $u_i \in \mathcal{U}^{(1)}$, i.e., $Q^{(1)}_{u_i}$, consists of the first $K$ the \textit{acceptable partners} in $u_i$'s preference list $P^{(1)}_{u_i}$, which are in the same order as those in $P^{(1)}_{u_i}$, and $u_i$ in the $(K+1)_{th}$ entry of $Q^{(1)}_{u_i}$. Parameter $K$ is called the \textit{partial matching rate} in this paper.
An example is given in Figure~\ref{fig:truncated_strategy}, where to get the top $2$ promising partners for the user, we place the user himself at the $3_{rd}$ cell in the preference list. All the remaining potential partners will be cut off and only the top $3$ users will participate in the final matching.
Based on the concepts of \textit{self matching} and \textit{partial matching strategy}, we define the concepts of \textit{partial stable matching} and \textit{generic stable matching} as follow.
\noindent \textbf{Definition 23} (Partial Stable Matching): For a given \textit{matching} $\mu$, $\mu$ is (1) \textit{rational} if $\mu(u_i) Q^{(1)}_{u_i} u_i, \forall u_i \in \mathcal{U}^{(1)}$ and $\mu(v_j) Q^{(2)}_{v_j} v_j, \forall v_j \in \mathcal{U}^{(2)}$, (2) \textit{pairwise stable} if there exist no \textit{blocking pairs} in the matching results, and (3) \textit{stable} if it is both \textit{rational} and \textit{pairwise stable}.
\noindent \textbf{Definition 24} (Generic Stable Matching): For a given \textit{matching} $\mu$, $\mu$ is a \textit{generic stable matching} iff $\mu$ is a \textit{self matching} or $\mu$ is a \textit{partial stable matching}.
As example of \textit{generic stable matching} is shown in the bottom two plots of Figure~\ref{fig:nash_equilibrium}. \textit{Traditional stable matching} can prune most non-existing anchor links and make sure the results can meet \textit{one-to-one} constraint. However, it preserves the anchor links (Rebecca, Becky) and (Jonathan, Jon), which are connecting \textit{non-anchor users}. In \textit{generic stable matching} with parameter $K=1$, users will be either connected with their most preferred partner or stay \textit{unconnected}. Users ``William'' and ``Wm'' are matched as link (William, Wm) has the highest score. ``Rebecca'' and ``Jonathan'' will prefer to stay \textit{unconnected} as their most preferred partner ``Wm'' is connected with ``William'' already. Furthermore, ``Becky'' and ``Jon'' will stay \textit{unconnected} as their most preferred partner ``Rebecca'' and ``Jonathan'' prefer to stay \textit{unconnected}. In this way, \textit{generic stable matching} can further prune the non-existing anchor links (Rebecca, Becky) and (Jonathan, Jon).
The \textit{truncated generic stable matching} results can be achieved with the \textit{Generic Gale-Shapley} algorithm as given in Algorithm~\ref{alg:gale_shapley}.
\begin{algorithm}[t]
\caption{Generic Gale-Shapley Algorithm}
\label{alg:gale_shapley}
\begin{algorithmic}[1]
\REQUIRE user sets of aligned networks: $\mathcal{U}^{(1)}$ and $\mathcal{U}^{(2)}$. \\
\qquad classification results of potential anchor links in $\mathcal{L}$\\
\qquad known anchor links in $\mathcal{A}^{(1,2)}$\\
\qquad truncation rate $K$\\
\ENSURE a set of inferred anchor links $\mathcal{L}'$ \\
\STATE Initialize the preference lists of users in $\mathcal{U}^{(1)}$ and $\mathcal{U}^{(2)}$ with predicted existence probabilities of links in $\mathcal{L}$ and known anchor links in $\mathcal{A}^{(1,2)}$, whose existence probabilities are $1.0$
\STATE construct the truncated strategies from the preference lists
\STATE Initialize all users in $\mathcal{U}^{(1)}$ and $\mathcal{U}^{(2)}$ as \textit{free}
\STATE $\mathcal{L}' = \emptyset$
\WHILE{$\exists$ \textit{free} $u^{(1)}_i$ in $\mathcal{U}^{(1)}$ and $u^{(1)}_i$'s truncated strategy is non-empty}
\STATE Remove the top-ranked account $u^{(2)}_j$ from $u^{(1)}_i$'s truncated strategy
\IF {$u^{(2)}_j$==$u^{(1)}_i$}
\STATE $\mathcal{L}' = \mathcal{L}' \cup \{ (u^{(1)}_i, u^{(1)}_i)\}$
\STATE Set $u^{(1)}_i$ as \textit{stay unconnected}
\ELSE
\IF{ $u^{(2)}_j$ is \textit{free}}
\STATE $\mathcal{L}' = \mathcal{L}' \cup \{ (u^{(1)}_i, u^{(2)}_j)\}$
\STATE Set $u^{(1)}_i$ and $u^{(2)}_j$ as \textit{occupied}
\ELSE
\STATE $\exists u^{(1)}_p$ that $u^{(2)}_j$ is occupied with.
\IF{ $u^{(2)}_j$ prefers $u^{(1)}_i$ to $u^{(1)}_p$}
\STATE $\mathcal{L}' = (\mathcal{L}' - \{ (u^{(1)}_p,u^{(2)}_j) \}) \cup \{ (u^{(1)}_i,u^{(2)}_j) \}$
\STATE Set $u^{(1)}_p$ as \textit{free} and $u^{(1)}_i$ as \textit{occupied}
\ENDIF
\ENDIF
\ENDIF
\ENDWHILE
\end{algorithmic}
\end{algorithm}
\section{Experiments}\label{sec:experiment}
\begin{table}[t]
\caption{Properties of the Heterogeneous Networks}
\label{tab:dataset}
\centering
\begin{tabular}{clrr}
\toprule
&&\multicolumn{2}{c}{network}\\
\cmidrule{3-4}
&property &\textbf{Twitter} &\textbf{Foursquare} \\
\midrule
\multirow{3}{*}{\# node}
&user & 5,223 & 5,392 \\
&tweet/tip & 9,490,707 & 48,756 \\
&location & 297,182 & 38,921 \\
\midrule
\multirow{3}{*}{\# link}
&friend/follow &164,920 &76,972 \\
&write & 9,490,707 & 48,756 \\
&locate & 615,515 & 48,756 \\
\bottomrule
\end{tabular}
\end{table}
To demonstrate the effectiveness of {\our} in predicting \textit{anchor links} for partially aligned heterogeneous social networks, we conduct extensive experiments on two real-world heterogeneous social networks: Foursquare and Twitter. This section includes three parts: (1) dataset description, (2) experiment settings, and (3) experiment results.
\subsection{Dataset Description}
The datasets used in this paper include: Foursquare and Twitter, which were crawled during November 2012 \cite{KZY13, ZKY13, ZKY14, ZYZ14}. More detailed information about these two datasets is shown in Table~\ref{tab:dataset} and in \cite{KZY13, ZKY13, ZKY14, ZYZ14}. The number of anchor links crawled between Foursquare and Twitter is $3,388$ and $62.83\%$ Foursquare users are \textit{anchor users}.
\begin{figure*}[t]
\centering
\subfigure[AUC: alignment rate]{ \label{eg_fig_6_1}
\begin{minipage}[l]{0.8\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./AUC_result_alignment_rate.pdf}
\end{minipage}
}
\subfigure[AUC: negative positive rate]{ \label{eg_fig_6_2}
\begin{minipage}[l]{0.8\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./AUC_result_negative_positive_rate.pdf}
\end{minipage}
}
\caption{AUC of different class imbalance link prediction methods.}\label{eg_fig_6}
\end{figure*}
\subsection{Experiment Settings}
In this part, we will talk about the experiment settings in details, which includes: (1) comparison methods, (2) evaluation methods, and (3) experiment setups.
\subsubsection{Comparison Methods}
The comparison methods used in the experiments can be divided into the following $4$ categories:
\noindent \textit{Methods with Generic Stable Matching}:
\begin{itemize}
\item {\ouromt}: {\ouromt} (PNA with \underline{O}ver sampling \& \underline{G}eneric stable \underline{M}atching) is the method proposed in this paper, which consists of two steps: (1) class imbalance link prediction with over sampling, and (2) candidate pruning with \textit{generic stable matching}.
\item {\ourdmt}: {\ourdmt} (PNA with \underline{D}own sampling \& \underline{G}eneric stable \underline{M}atching) is another method proposed in this paper, which consists of two steps: (1) class imbalance link prediction with down sampling, and (2) candidate pruning with \textit{generic stable matching}.
\end{itemize}
\noindent \textit{Methods with Traditional Stable Matching}
\begin{itemize}
\item {\ourom}: {\ourom} (PNA with \underline{O}ver sampling \& traditional stable \underline{M}atching) is identical to {\ouromt} except that in the second step, {\ourom} applies the traditional \textit{stable matching} \cite{GS62, KZY13}.
\item {\ourdm}: {\ourdm} (PNA with \underline{D}own sampling \& traditional stable \underline{M}atching) is identical to {\ourdmt} except that in the second step, {\ourdm} applies the traditional \textit{stable matching} \cite{GS62, KZY13}.
\end{itemize}
\noindent \textit{Class Imbalance Anchor Link Prediction}:
\begin{itemize}
\item {\ouro}: {\ouro} (PNA with \underline{O}ver sampling) is the link prediction method with over sampling to overcome the class imbalance problem and has no matching step.
\item {\ourd}: {\ourd} (PNA with \underline{D}own sampling) is the link prediction method with down sampling to overcome the class imbalance problem and has no matching step.
\end{itemize}
\noindent \textit{Existing Network Anchoring Methods}
\begin{itemize}
\item {\ourm}: {\ourm} (\underline{M}ulti-\underline{N}etwork \underline{A}nchoring) is a \textit{two-phase} method proposed in \cite{KZY13} which includes: (1) supervised link prediction without addressing class imbalance problem; (2) traditional stable matching \cite{GS62, KZY13}.
\item {\oursup}: {\oursup} ({\ourm} without one-to-one constraint) is the first step of {\ourm} proposed in \cite{KZY13} which can predict anchor links without addressing the class imbalance problem and has no matching step.
\end{itemize}
\subsubsection{Evaluation Metrics}
The output of different link prediction methods can be either \textit{predicted labels} or \textit{confidence scores}, which are evaluated by \textit{Accuracy}, \textit{AUC}, \textit{F1} in the experiments.
\subsubsection{Experiment Setups}
In the experiment, initially, a fully aligned network containing $3000$ users in both Twitter and Foursquare is sampled from the datasets. All the existing \textit{anchor links} are grouped into the positive link set and all the possible non-existing \textit{anchor links} are used as the potential link set. Certain number of links are randomly sampled from the potential link set as the negative link set, which is controlled by parameter $\theta$. Parameter $\theta$ represents the $\frac{\#negative}{\#positive}$ rate, where $\theta = 1$ denotes the class balance case, i.e., $\# positive$ equals to $\# negative$; $\theta = 50$ represents that case that negative instance set is $50$ times as large as that of the positive instance set, i.e., $\# negative = 50 \times\# positive$. In the experiment, $\theta$ is chosen from $\{1, 2, 3, 4, 5, 10, 20, 30, 40, 50\}$. Links in the positive and negative link sets are partitioned into two parts with 10-fold cross validation, where $9$ folds are used as the training set and $1$ fold is used as the test set. To simulate the \textit{partial alignment} networks, certain positive links are randomly sampled from the positive training set as the final positive training set under the control of parameter $\eta$. $\eta$ is chosen from $\{0.1, 0.2, \cdots, 1.0\}$, where $\eta = 0.1$ denotes that the networks are $10\%$ aligned and $\eta = 1.0$ shows that the networks are fully aligned. With links in the positive training set, \textit{anchor adjacency tensor} based features and the \textit{latent feature vectors} are extracted from the network to build \textit{link prediction model} $\mathcal{M}$. In building model $\mathcal{M}$, \textit{over sampling} and \textit{under sampling} techniques are applied and the sampling rate is determined by parameter $\sigma \in \{0.0, 0.1, 0.2, \cdots, 1.0\}$, where $\sigma = 0.3$ denotes that $0.3 \times (\#negative - \#positive)$ negative links are randomly removed from the negative link set in under sampling; or $0.3 \times (\#negative - \#positive)$ positive links are generated and added to the positive link set in over sampling. Before applying model $\mathcal{M}$ to the test set, \textit{pre-pruning} process is conducted on the test set in advance. Based on the prediction results of model $\mathcal{M}$ on the test set, \textit{post-pruning} with \textit{generic stable matching} is applied to further prune the non-existent candidates to ensure that the final prediction results across the \textit{partially aligned networks} can meet the $one-to-one_{\le}$ constraint controlled by the \textit{partial matching parameter} $K$.
\begin{figure*}[t]
\centering
\subfigure[Acc.@$\theta = 5$, $\eta = 0.4$]{ \label{eg_fig_7_1}
\begin{minipage}[l]{0.8\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./acc_trucation_rate.pdf}
\end{minipage}
}
\subfigure[F1@$\theta = 5$, $\eta = 0.4$]{ \label{eg_fig_7_2}
\begin{minipage}[l]{0.8\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./f1_trucation_rate.pdf}
\end{minipage}
}
\subfigure[Acc.@$\theta = 50$, $\eta = 0.9$]{ \label{eg_fig_7_3}
\begin{minipage}[l]{0.8\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./acc_trucation_rate_2.pdf}
\end{minipage}
}
\subfigure[F1@$\theta = 50$, $\eta = 0.9$]{ \label{eg_fig_7_4}
\begin{minipage}[l]{0.8\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./f1_trucation_rate_2.pdf}
\end{minipage}
}
\caption{F1, Accuracy of {\ouromt} and {\ourdmt} with different partial matching rates.}\label{eg_fig_7}
\end{figure*}
\subsection{Experiment Results}
In this part, we will give the experiment results of all these comparison methods in addressing the \textit{partial network alignment} problem. This part includes (1) analysis of sampling methods in class imbalance link prediction; (2) performance comparison of different link prediction methods; and (3) parameter analysis.
\subsubsection{Analysis of Sampling Methods}
To examine whether sampling methods can improve the prediction performance on the imbalanced classification problem or not, we also compare {\ouro}, {\ourd} with {\oursup} and the results are given in Figure~\ref{eg_fig_6}, where we fix $\theta$ as 10 but change $\eta$ with values in $\{0.1, 0.2, \cdots, 1.0\}$ and compare the \textit{AUC} achieved by {\ouro}, {\ourd} and {\oursup}. We can observe that the \textit{AUC} values of all these three methods increases with the increase of $\eta$ but {\ouro} and {\ourd} perform consistently better than {\oursup}. In Figure~\ref{eg_fig_6_2}, we fix $\eta$ as $0.6$ but change $\theta$ with values in \{1, 2, 3, 4, 5, 10, 20, 30, 40, 50\} and compare the \textit{AUC} of {\ouro}, {\ourd} and {\oursup}. As shown in Figure~\ref{eg_fig_6_2}, the performance of {\ouro}, {\ourd} and {\oursup} can all varies slightly with $\theta$ changing from $1$ to $50$ and {\ouro}, {\ourd} can achieve better performance than {\oursup} consistently.
\subsubsection{Comparison of Different Link Prediction Methods}
Meanwhile, as \textit{generic stable matching} based post pruning can only output the labels of potential \textit{anchor links} in the test set, we also evaluate all these methods by comparing their \textit{Accuracy} and \textit{F1} score Tables~\ref{tab:setting1}-\ref{tab:setting2}. In Table~\ref{tab:setting1}, we fix $\theta$ as $10$, $K$ as $5$ but change $\eta$ with values in $\{0.1, 0.2, \cdots, 1.0\}$. Table~\ref{tab:setting1} has two parts. The upper part of Table~\ref{tab:setting1} shows the \textit{Accuracy} achieved by all the methods with various $\eta$, and the lower part shows the \textit{F1} score. Generally, the performance of all comparison methods rises as $\eta$ increases. In the upper part, methods {\ouromt} and {\ourdmt} can consistently perform better than all other comparison methods for different $\eta$. For example, when $\eta = 0.5$, the \textit{Accuracy} achieved by {\ouromt} is higher than {\ourom} by $3.45\%$, higher than {\ourm} by $6.0\%$, higher than {\ouro} by $7.51\%$ and higher than {\oursup} by $7.75\%$; meanwhile, the \textit{Accuracy} achieved by {\ourdmt} is higher than {\ourdm}, {\ourm}, {\ourd} and {\oursup} as well. The advantages of {\ouromt} and {\ourdmt} over other comparison methods are more obvious under the evaluation of \textit{F1} as in \textit{class imbalance} settings, \textit{Accuracy} is no longer an appropriate evaluation metric \cite{C05}. For example, when $\eta = 0.5$, the \textit{F1} achieved by {\ouromt} is about $13.25\%$ higher than {\ourom}, $24\%$ higher than {\ourm}, $101.6\%$ higher than {\ouro} and $165\%$ higher than {\oursup}; so is the case for method {\ourdmt}. The experiment results show that {\ouromt} and {\ourdmt} can work well with datasets containing different ratio of anchor links across the networks. Similar results can be obtained from Table~\ref{tab:setting2}, where we fix $\eta = 0.6$, $K$ as $5$ but change $\theta$ with values in $\{1, 2, 3, 4, 5, 10, 20, 30, 40, 50\}$. It shows that {\ouromt} and {\ourdmt} can effectively address the class imbalance problem.
The fact that (1) {\ouromt} can outperform {\ourom} ({\ourdmt} outperforms {\ourdm}) shows that \textit{generic stable matching} can work well in dealing with \textit{partially aligned social networks}; (2) {\ourom} can beat {\ouro} (and {\ourdm} beats {\ourd}) means that \textit{stable matching} can achieve very good \textit{post-pruning} results; (3) {\ourom} and {\ourdm} can perform better than {\ourm} (or {\ouro} and {\ourd} can achieve better results than {\oursup}) means that sampling methods can overcome the \textit{class imbalance} problem very well.
\begin{table*}[t]
\caption{Performance comparison of different methods for partial network alignment with different network alignment rates.}
\label{tab:setting1}
\centering
{
\begin{tabular}{lrcccccccccc}
\toprule
\multicolumn{2}{l}{}&\multicolumn{10}{c}{anchor link sampling rate $\eta$}\\
\cmidrule{3-12}
\rotatebox{90}{}&Methods &0.1 &0.2 & 0.3 & 0.4 &0.5 &0.6 &0.7 &0.8 &0.9 &1.0 \\
\midrule
\multirow{8}{*}{\textsc{Acc}}
&{\ouromt} &\textbf{0.964} &\textbf{0.966} &\textbf{0.973} &\textbf{0.967} &\textbf{0.987} &\textbf{0.989} &\textbf{0.981} &\textbf{0.988} &\textbf{0.989} &\textbf{0.990} \\
&{\ourdmt} &\textbf{0.960} &\textbf{0.974} &\textbf{0.961} &\textbf{0.976} &\textbf{0.983} &\textbf{0.975} &\textbf{0.982} &\textbf{0.989} &\textbf{0.986} &\textbf{0.990} \\
\cmidrule{3-12}
&{\ourom} &{0.942} &{0.938} &{0.948} &{0.945} &{0.954} &{0.960} &{0.970} &{0.968} &{0.983} &{0.981} \\
&{\ourdm} &{0.940} &{0.951} &{0.949} &{0.929} &{0.949} &{0.947} &{0.969} &{0.966} &{0.983} &{0.981} \\
&{\ourm} &{0.917} &{0.918} &{0.922} &{0.922} &{0.931} &{0.937} &{0.940} &{0.943} &{0.949} &{0.971} \\
\cmidrule{3-12}
&{\ouro} &{0.905} &{0.907} &{0.915} &{0.915} &{0.918} &{0.927} &{0.926} &{0.925} &{0.929} &{0.921} \\
&{\ourd} &{0.905} &{0.908} &{0.911} &{0.912} &{0.915} &{0.926} &{0.923} &{0.925} &{0.929} &{0.923} \\
&{\oursup} &{0.895} &{0.899} &{0.901} &{0.907} &{0.916} &{0.921} &{0.922} &{0.924} &{0.919} &{0.922} \\
\midrule
\multirow{8}{*}{F1}
&{\ouromt} &\textbf{0.280} &\textbf{0.375} &\textbf{0.442} &\textbf{0.496} &\textbf{0.615} &\textbf{0.717} &\textbf{0.776} &\textbf{0.843} &\textbf{0.941} &\textbf{0.965} \\
&{\ourdmt} &\textbf{0.283} &\textbf{0.374} &\textbf{0.412} &\textbf{0.481} &\textbf{0.589} &\textbf{0.658} &\textbf{0.783} &\textbf{0.848} &\textbf{0.925} &\textbf{0.972} \\
\cmidrule{3-12}
&{\ourom} &{0.230} &{0.318} &{0.384} &{0.452} &{0.543} &{0.638} &{0.723} &{0.824} &{0.916} &{0.963} \\
&{\ourdm} &{0.239} &{0.324} &{0.369} &{0.424} &{0.526} &{0.593} &{0.716} &{0.812} &{0.919} &{0.963} \\
&{\ourm} &{0.211} &{0.267} &{0.375} &{0.420} &{0.496} &{0.578} &{0.705} &{0.782} &{0.899} &{0.943} \\
\cmidrule{3-12}
&{\ouro} &{0.014} &{0.054} &{0.211} &{0.210} &{0.305} &{0.402} &{0.413} &{0.385} &{0.428} &{0.438} \\
&{\ourd} &{0.010} &{0.048} &{0.131} &{0.165} &{0.257} &{0.380} &{0.365} &{0.367} &{0.405} &{0.438} \\
&{\oursup} &{0.004} &{0.021} &{0.042} &{0.067} &{0.232} &{0.322} &{0.339} &{0.346} &{0.360} &{0.380} \\
\bottomrule
\end{tabular
}
\end{table*}
\begin{table*}[t]
\caption{Performance comparison of different methods for partial network alignment with different negative positive rates.}
\label{tab:setting2}
\centering
{
\begin{tabular}{lrcccccccccc}
\toprule
\multicolumn{2}{l}{}&\multicolumn{10}{c}{negative positive rate $\theta$}\\
\cmidrule{3-12}
Measure&Methods &1 &2 & 3 &4 &5 &10 &20 &30 &40 &50 \\
\midrule
\multirow{8}{*}{\textsc{Acc}}
&{\ouromt} &\textbf{0.941} &\textbf{0.900} &\textbf{0.903} &\textbf{0.904} &\textbf{0.905} &\textbf{0.989} &\textbf{0.995} &\textbf{0.995} &\textbf{0.998} &\textbf{0.997} \\
&{\ourdmt} &\textbf{0.920} &\textbf{0.917} &\textbf{0.903} &\textbf{0.913} &\textbf{0.893} &\textbf{0.975} &\textbf{0.994} &\textbf{0.998} &\textbf{0.997} &\textbf{0.997} \\
\cmidrule{3-12}
&{\ourom} &{0.934} &{0.898} &{0.899} &{0.882} &{0.898} &{0.960} &{0.975} &{0.981} &{0.992} &{0.995} \\
&{\ourdm} &{0.916} &{0.914} &{0.892} &{0.910} &{0.887} &{0.947} &{0.977} &{0.981} &{0.990} &{0.990} \\
&{\ourm} &{0.914} &{0.863} &{0.884} &{0.886} &{0.878} &{0.937} &{0.966} &{0.970} &{0.978} &{0.986} \\
\cmidrule{3-12}
&{\ouro} &{0.706} &{0.795} &{0.834} &{0.849} &{0.880} &{0.927} &{0.958} &{0.970} &{0.976} &{0.980} \\
&{\ourd} &{0.752} &{0.812} &{0.836} &{0.865} &{0.875} &{0.926} &{0.955} &{0.968} &{0.976} &{0.980} \\
&{\oursup} &{0.714} &{0.781} &{0.825} &{0.839} &{0.873} &{0.921} &{0.953} &{0.968} &{0.975} &{0.980} \\
\midrule
\multirow{8}{*}{F1}
&{\ouromt} &\textbf{0.943} &0.870 &\textbf{0.835} &\textbf{0.805} &\textbf{0.776} &\textbf{0.717} &\textbf{0.608} &\textbf{0.552} &\textbf{0.565} &\textbf{0.524} \\
&{\ourdmt} &0.926 &\textbf{0.890} &\textbf{0.834} &\textbf{0.821} &0.754 &\textbf{0.658} &\textbf{0.602} &\textbf{0.577} &\textbf{0.548} &\textbf{0.533} \\
\cmidrule{3-12}
&{\ourom} &{0.936} &{0.867} &{0.832} &{0.772} &{0.769} &{0.638} &{0.550} &{0.470} &{0.438} &{0.366} \\
&{\ourdm} &{0.923} &{0.887} &{0.822} &{0.819} &{0.747} &{0.593} &{0.563} &{0.468} &{0.419} &{0.405} \\
&{\ourm} &{0.887} &{0.800} &{0.790} &{0.760} &{0.694} &{0.578} &{0.508} &{0.397} &{0.346} &{0.329} \\
\cmidrule{3-12}
&{\ouro} &{0.600} &{0.609} &{0.553} &{0.515} &{0.492} &{0.402} &{0.294} &{0.251} &{0.131} &{0.051} \\
&{\ourd} &{0.687} &{0.633} &{0.569} &{0.528} &{0.455} &{0.380} &{0.230} &{0.131} &{0.093} &{0.067} \\
&{\oursup} &{0.575} &{0.542} &{0.526} &{0.483} &{0.447} &{0.322} &{0.204} &{0.105} &{0.075} &{0.041} \\
\bottomrule
\end{tabular
}
\end{table*}
\subsubsection{Analysis of Partial Matching Rate}
In the \textit{generic stable matching}, only top $K$ \textit{anchor link candidates} will be preserved. In this part, we will analyze the effects of parameter $K$ on the performance of {\ouromt} and {\ourdmt}. Figure~\ref{eg_fig_7} gives the results (both \textit{Accuracy} and \textit{F1}) of {\ouromt} and {\ourdmt} by setting parameter $K$ with values in $\{1, 2, 3, 4, 5, 10, 20, 30, 40, 50\}$.
In Figures~\ref{eg_fig_7_1}-\ref{eg_fig_7_2}, parameters $\theta$ and $\eta$ are fixed as $5$ and $0.4$ respectively. From the results, we observe that both {\ouromt} and {\ourdmt} can perform very well when $K$ is small and the best is obtained at $K=1$. It shows that the \textit{anchor link candidates} with the highest confidence predicted by {\ouro} and {\ourd} are the optimal \textit{network alignment results} when $\theta$ and $\eta$ are low. In Figures~\ref{eg_fig_7_3}-\ref{eg_fig_7_4}, we set $\eta$ as $0.9$ and $\theta$ as $50$ (i.e., the networks contain more anchor links and the training/test sets become more imbalance), we find that the performance of both {\ouromt} and {\ourdmt} increases first and then decreases and finally stay stable as $K$ increases, which shows that the optimal \textit{anchor link candidates} are those within the top $K$ candidate set rather than the one with the highest confidence as the training/test sets become more imbalance.
In addition, the \textit{partial matching strategy} can shrink the preference lists of users a lot, which can lead to lower time cost as shown in Figure~\ref{eg_fig_8} especially for the smaller K values which lead to better accuracy as shown in Figure~\ref{eg_fig_7}.
Results in all these figures show that \textit{generic stable matching} can effectively prune the redundant candidate links and significantly improve the prediction results.
\begin{figure}[t]
\centering
\begin{minipage}[l]{0.8\columnwidth}
\centering
\includegraphics[width=1.0\textwidth]{./time_cost.pdf}
\end{minipage}
\caption{Time cost of {\ouromt} and {\ourdmt} with different partial matching rates.}\label{eg_fig_8}
\end{figure}
\section{Related Works}
\label{sec:relatedworks}
\textit{Aligned social network} studies have become a hot research topic in recent years. Kong et al. \cite{KZY13} are the first to propose the \textit{anchor link prediction} problem in \textit{fully aligned social networks}. Zhang et al. \cite{ZKY13, ZKY14, ZYZ14, ZY15-3} propose to predict links for new users and new networks by transferring heterogeneous information across \textit{aligned social networks}. A comprehensive survey about link prediction problems across \textit{multiple social networks} is available in \cite{ZY14}. In addition to link prediction problems, Jin and Zhang et al. \cite{JZYYL14, ZY15, ZY15-2} introduce the community detection problems across aligned networks and Zhan et al. \cite{ZZWYX15} study the information diffusion across aligned social networks.
Meta path first proposed by Sun et al. \cite{SBGAH11} has become a powerful tool, which can be applied in either in link prediction problems \cite{SBGAH11, SHAC12} or clustering problems \cite{SHYYW11, SAH12}. Sun et al. \cite{SBGAH11} propose to predict co-author relationship in heterogeneous bibliographic networks based on meta path. Sun et al. extend the link prediction model to relationship prediction model based on meta path in \cite{SHAC12}. Sun et al. \cite{SHYYW11} propose to calculate the similarity scores among users based on meta path in bibliographical network. Sun et al. \cite{SAH12} also apply meta path in clustering problem of heterogeneous information networks with incomplete attributes.
Tensor has been widely used in social networks studies. Moghaddam et al. \cite{MJE12} propose to apply extended tensor factorization model for personalized prediction of review helpfulness. Liu et al. \cite{LJGM13} present a tensor-based framework for integrating heterogeneous multi-view data in the context of spectral clustering. A more detailed tutorial about tensor decomposition and applications is available in \cite{KB09}.
Class imbalance problems in classification can be very common in real-world applications. Chawla et al. \cite{CBHK02} propose a technique for over-sampling the minority class with generated new synthetic minority instances. Kubat et al. \cite{KM97} propose to address the class imbalance problems with under sampling of the majority cases in the training set. A systematic study of the \textit{class imbalance problem} is available in \cite{JS02}.
College admission problem \cite{R85} and stable marriage problem \cite{GI89} have been studied for many years and lots of works have been done in the last century. In recent years, some new papers have come out in these areas. Sotomayor et al. \cite{S08} propose to analyze the stability of the equilibrium outcomes in the admission games induced by stable matching rules. Ma \cite{M98} analyzes the truncation in stable matching and the small core in nash equilibrium in college admission problems. Flor\'{e}en et al. \cite{FKPS10} propose to study the almost stable matching by truncating the Gale-Shapley algorithm.
\section{Conclusion}\label{sec:conclusion}
In this paper, we study the \textit{partial network alignment} problem across \textit{partially aligned social networks}.
To address the challenges of the studied problem, a new method {\our} is proposed in this paper. {\our} can extract features for \textit{anchor links} based on a set of \textit{anchor meta paths} and overcome the \textit{class imbalance} problem with \textit{over sampling} and \textit{down sampling}. {\our} can effectively prune the non-existing \textit{anchor links} with \textit{generic stable matching} to ensure the results can meet the $one-to-one_{\le}$ constraint. Extensive experiments done on two real-world \textit{partially aligned networks} show the superior performance of {\our} in addressing the \textit{partial network alignment problem}.
\label{sec:ack}
\section{Acknowledgement}
This work is supported in part by NSF through grants CNS-1115234, Google Research Award, the Pinnacle Lab at Singapore Management University, and Huawei grants.
|
{'timestamp': '2015-06-18T02:04:02', 'yymm': '1506', 'arxiv_id': '1506.05164', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05164'}
|
arxiv
|
\section{Introduction}\label{Introduction}
Given a text $T$ and a pattern $P$, the order-preserving matching problem is to find all substrings in $T$ which have the same relative orders as $P$. For example, given $T=(10,15,20,25,15,30,20,25,30,35)$ and $P=(35,40,30,45,35)$, $P$ has the same relative orders as the substring $T'=(20,25,15,30,20)$ of $T$. In $T'$ (resp. $P$), the first character $20$ (resp. $35$) is the second smallest number, the second character $25$ (resp. $40$) is the third smallest number, the third character $15$ (resp. $30$) is the smallest number, and so on. See Fig.~\ref{fig:opmex}. This problem is naturally generalized to the problem of finding multiple patterns. The order-preserving matching for a single pattern will be called the \emph{single order-preserving matching}, and one for multiple patterns the \emph{multiple order-preserving matching}. In this paper we are concerned with the multiple order-preserving matching problem.
Order-preserving matching was introduced by Kubica et al. \cite{kubica2013linear} and Kim et al. \cite{kim2014order}, where Kubica et al. \cite{kubica2013linear} defined order relations by order isomorphism of two strings, while Kim et al. \cite{kim2014order} defined them explicitly by the sequence of rank values, which they called the \emph{natural representation}. They both proposed $O(n+m\log{m})$ time solutions for the single order-preserving matching based on the Knuth-Morris-Pratt algorithm, where $n$ is the length of the text and $m$ is the length of the pattern. Kim et al. \cite{kim2014order} also proposed an $O(n\log{M})$ time algorithm for the multiple order-preserving matching based on the Aho-Corasick algorithm, where $M$ is the sum of lengths of all the patterns. Henceforth, there has been considerable research on the single and multiple order-preserving matching problems. For the single order-preserving matching, Cho et al. \cite{cho2015fast} proposed a method to apply the Boyer-Moore bad character rule to order-preserving matching by using the notion of $q$-grams. Chhabra and Tarhio \cite{chhabra2014order} presented a more practical solution based on filtering. They first encoded input sequences into binary sequences and then applied standard string matching algorithms as a filtering method. Faro and K\"ulekci~\cite{faro2015efficient} improved Chhabra and Tarhio's solution by using new encoding techniques which reduced the false positive rate of the filtering step. For the multiple order-preserving matching, Belazzougui et al. \cite{belazzougui2013single} theoretically improved the solution of Kim et al. \cite{kim2014order} by replacing the underlying data structure by the van-Emde-Boas tree. They achieved randomized $O(n\cdot \text{min}(\log{\log{n}},\sqrt{\frac{\log{r}}{\log{\log{r}}}},k))$ time for the search, where $r$ is the length of the longest pattern and $k$ is the number of patterns.
Order-preserving matching has been an active research area and many related problems have been studied such as order-preserving suffix trees \cite{crochemore2013order} and order-preserving matching with $k$ mismatches \cite{gawrychowski2014order}. Kim et al. \cite{kim2014representations} extended the representations of order relations from binary relations to ternary relations. With their representations, one can modify earlier order-preserving matching algorithms to accommodate strings with duplicate characters, i.e., a number can appear more than once in a string.
\begin{figure}
\begin{center}\
\centerline{\includegraphics[scale=0.7]{opmex.png}}
\caption{An example of the order-preserving matching. $P$ has the same relative orders as the substring $T'=(20,25,15,30,20)$ of $T$. }
\label{fig:opmex}
\end{center}
\end{figure}
In this paper, we present two new algorithms for the multiple order-preserving matching problem which are more efficient on average than the previously proposed algorithms. The algorithms are based on modifications of some conventional pattern matching algorithms such as Wu-Manber \cite{wu1994fast} and Karp-Rabin \cite{karp1987efficient}. The first algorithm, called Algorithm \rom{1}, uses the ideas of the Wu-Manber algorithm, and the second algorithm, called Algorithm \rom{2}, uses the ideas of the Karp-Rabin algorithm and the encoding techniques of Chhabra and Tarhio \cite{chhabra2014order} and Faro and K\"ulekci \cite{faro2015efficient} for fingerprinting. Algorithm \rom{1} runs in $O(\frac{n}{m}\log{M})$ time on average, where $n$ is the length of the text, $m$ is the length of the shortest pattern, and $M$ is the sum of lengths of all the patterns. Algorithm \rom{2} runs in $O(n)$ time on average, assuming that $M$ is polynomial with respect to $m$.
In order to verify practical behaviors of our algorithms, we conducted experiments where the two algorithms were compared with the algorithms of Kim et al. \cite{kim2014order} and Belazzougui et al. \cite{belazzougui2013single}. Experiments show that our algorithms run much faster in practice.
\section{Problem Formulation}\label{section:pf}
Let $\Sigma$ denote a set of numbers such that a comparison of two numbers can be done in constant time, and let $\Sigma^*$ denote the set of strings over the alphabet $\Sigma$. For a string $x \in \Sigma^*$, let $|x|$ denote the length of $x$. A string $x$ is described by a sequence of characters $(x[1], x[2], ..., x[|x|])$.
Let a substring $x[i..j]$ be $(x[i], x[i+1], ..., x[j])$ and a prefix $x_i$ be $x[1..i]$.
For a character $c \in \Sigma$, let $rank_x(c) = 1 + |\{ i : x[i] < c \; \text{for} \; 1 \leq i \leq |x| \}|$.
We use the \emph{natural representation} defined by Kim et al.~\cite{kim2014order} to compare order relations of two strings. The natural representation is equivalent to \emph{order-isomorphism} defined by Kubica et al.~\cite{kubica2013linear}, because the natural representation of two strings are identical if and only if they are order-isomorphic.
\begin{definition}[Natural representation \cite{kim2014order}] For a string $x$ of length $n$, the natural representation is defined as $Nat(x) = ( rank_x(x[1]), rank_x(x[2]) , ..., rank_x(x[n]) )$.
\end{definition}
For example, for $x=(30, 40, 30, 45, 35)$, the natural representation is
$Nat(x)=(1, 4, 1, 5, 3)$. We will simply say that $x$ matches $y$ if $|x|=|y|$ and $Nat(x)=Nat(y)$.
Order-preserving matching can be defined in terms of the natural representation.
\begin{definition}[Single Order-Preserving Matching \cite{kim2014order}]\label{def:sopm}
Given a text $T[1..n] \in \Sigma^*$ and a pattern $P[1..m] \in \Sigma^*$, $P$ matches $T$ at position $i$ if
$Nat(P)=Nat(T[i-m+1..i])$. The order-preserving matching is the problem of finding all the positions of $T$ matched with $P$.
\end{definition}
Definition~\ref{def:sopm} is naturally generalized to the multiple order-preserving matching, formally defined in Definition~\ref{def:mopm}.
\begin{definition}[Multiple Order-Preserving Matching \cite{kim2014order}]\label{def:mopm}
Given a text $T[1..n] \in \Sigma^*$ and a set of patterns $\mathcal{P}=\{ P_1, P_2, ..., P_k \}$ where $P_i \in \Sigma^*$ for $1 \leq i \leq k$, the multiple order-preserving matching is the problem of finding all the positions of $T$ matched with any pattern in $\mathcal{P}$.
\end{definition}
There are two other representations in addition to the natural representation for comparing order relations of two strings: \emph{prefix representation} and \emph{nearest neighbor representation}. The \emph{prefix representation} can be defined as a sequence of rank values of characters in prefixes.
\begin{definition}[Prefix Representation~\cite{kim2014order}] For a string $x$, the prefix representation is defined as $Pre(x) = ( rank_{x_1}(x[1]), rank_{x_2}(x[2]) , ..., rank_{x_{|x|}}(x[|x|]) )$.
\label{appendix:definition:prefix_rep}
\end{definition}
For example, for $x=(30, 40, 30, 45, 35)$, the prefix representation is
$Pre(x)=(1, 2, 1, 4, 3)$. We can compute $Pre(x)$ in time $O(|x|\log{|x|})$ for general alphabet using the order-statistic tree~\cite{kim2014order}. The time complexity can be reduced to $O(|x|)$ if the characters can be sorted in $O(|x|)$ time.
\begin{lemma}~\cite{cho2015fast}
For two strings $x$ and $y$ where $|x|=|y|$, if $x$ matches $y$, then $Pre(x)=Pre(y)$.
\label{lemma:if}
\end{lemma}
The prefix representation has an ambiguity between different strings if they include duplicate characters. For example, when $x=(10,30,20)$, and $y=(10,20,20)$, the prefix representations of both $x$ and $y$ are $(1,2,2)$, whereas their natural representations are different. Kim et al. defined a new representation called the \emph{extended prefix representation}~\cite{kim2014representations} for strings with duplicate characters. We omit the details here.
For the \emph{nearest neighbor representation}, we define $LMax_x[i]$ and $LMin_x[i]$ as follows.
\[ LMax_x[i] = \left\{
\begin{array}{l l}
j & \quad \text{if $x[j] = \max \{ x[k]: x[k] \leq x[i] \text{ for } 1 \leq k \leq i-1 \}$ }\\
-\infty & \quad \text{if no such $j$ ,}
\end{array} \right.\]
\[ LMin_x[i] = \left\{
\begin{array}{l l}
j & \quad \text{if $x[j] = \min \{ x[k]: x[k] \geq x[i] \text{ for } 1 \leq k \leq i-1 \}$ }\\
\infty & \quad \text{if no such $j$ .}
\end{array} \right.\]
If there are multiple $j$'s for $LMax_x[i]$ or $LMin_x[i]$, we choose the rightmost one.
\begin{definition}[Nearest Neighbor Representation~\cite{kim2014representations,kim2014order}] For a string $x$, the nearest neighbor representation is defined as $\text{NN}(x) =$
$\pair{LMax_{x}[1]}{LMin_{x}[1]}$
$\pair{LMax_{x}[2]}{LMin_{x}[2]}$
$\cdots$
$\pair{LMax_{x}[|x|]}{LMin_{x}[|x|]}$.
\end{definition}
For example, for $x=(30, 40, 30, 45, 30)$, the nearest neighbor representation is as follows.
\[
\begin{array}{l}
\text{NN}(x)=\left(\pair{-\infty}{\infty}, \pair{1}{\infty}, \pair{1}{1}, \pair{2}{\infty}, \pair{3}{3}\right) \;.
\end{array}
\]
For convenience, let $x[-\infty] = -\infty$, $x[\infty] = \infty$, $Nat(x)[-\infty] = 0$ and $Nat(x)[\infty] = |x|+1$ for any string $x$. Then, $Nat(x)[LMax_x[i]] \leq Nat(x)[i] \leq Nat(x)[LMin_x[i]]$ holds for $1\le i\le |x|$.
The time complexity for computing $\text{NN}(x)$ is $O(|x|\log{|x|})$~\cite{kim2014order}. Using this representation, we can check if two strings match in time linear to the size of the input, even when the strings have duplicate characters.
\begin{lemma}~\cite{cho2015fast,kim2014representations,kim2014order,kubica2013linear} Given two strings $x$ and $y$ where $|x|=|y|$, assume $\text{NN}(x)$ is computed. Then we can determine whether $x$ matches $y$ in $O(|x|)$ time.
\label{lemma:nn matching}
\end{lemma}
\section{Algorithm \rom{1}}\label{section:alg1}
In this section, we present our first algorithm for the multiple order-preserving matching. Algorithm \rom{1} is based on the Wu-Manber algorithm, which is widely used for multiple pattern matching. Algorithm \rom{1} is divided into two steps: the preprocessing step and the searching step.
\subsection{Preprocessing Step of Algorithm \rom{1}}
Let $m$ be the length of the shortest pattern, and $M$ be the sum of lengths of all the patterns. We consider only the first $m$ characters of each pattern. Let $\mathcal{P}'=\{P_1',P_2',\cdots ,P_k'\}$ where $P_i'=P_i[1..m]$ (this notation is provided only for clarity of exposition). In the preprocessing step, we build a SHIFT table and a HASH table based on $\mathcal{P}'$, which are analogous to those of the Wu-Manber algorithm. However, since we are looking for strings matched with patterns in terms of order-preserving matching, we have to consider the order representations of strings rather than strings themselves for comparison. Consider a block of length $b$ on the text, where $b\le m$. The SHIFT table determines the shift value based on the prefix representation of the given block. Given a block $x$, we define
\begin{eqnarray*}
\ l_x=\max\{j : Pre(P_i'[j-b+1..j])=Pre(x) \;\text{for} \; 1\le i\le k, b\le j\le m \} \;.
\end{eqnarray*}
That is, $l_x$ means the position of the rightmost block in any $P_i'\in\mathcal{P}'$ which is likely to match $x$. Here, the term "is likely to" is used because $Pre(x)=Pre(y)$ does not necessarily mean that $x$ matches $y$. For convenience, let $l_x=-\infty$ if there is no such block. Then, the SHIFT table is defined as
\begin{eqnarray*}
\ \text{SHIFT}[f(x)]=\min(m-l_x, m-b+1)\;,
\end{eqnarray*}
where $f(x)$ is a fingerprint mapping a block $x$ to an integer used as an index to the SHIFT table. Using the factorial number system \cite{kunuth1998art}, we define $f(x)$ as
\begin{eqnarray*}
\ f(x)=\sum_{i=1}^{b} (Pre(x)[i]-1)\cdot (i-1)!\;.
\end{eqnarray*}
Note that $f(x)$ maps a block $x$ into a unique integer within the range $[0..b!-1]$ according to its prefix representation.
Fig.~\ref{alg1_example}-(a) shows the SHIFT table when there are three patterns. Assume that $b=3$. Consider the block $T[3..5]$. The rightmost block in $\mathcal{P}'$ whose prefix representation equals that of $T[3..5]$ is $P_1[2..4]$. The fingerprint $f(T[3..5])$ is $3$. Thus, $\text{SHIFT}[3]$ is $m-4=1$. Note that in the figure, we can safely shift the patterns by $1$.
\begin{figure}
\begin{center}\
\centerline{\includegraphics[scale=0.30]{alg1ex.png}}
\caption{SHIFT and HASH tables.}
\label{alg1_example}
\end{center}
\end{figure}
The fingerprint is also used to index the HASH table. $\text{HASH}[i]$ contains a pointer to the list of the patterns whose last block in $\mathcal{P}'$ is mapped to the fingerprint $i$. Fig.~\ref{alg1_example}-(b) shows the HASH table with the same patterns.
To compute the values of the SHIFT table, we consider each pattern $P_i'$ separately. For each pattern $P_i'$, we compute the fingerprint of each block $P_i'[j-b+1..j]$ consecutively, and set the corresponding value of the SHIFT table to the minimum between its current value (initially set to $m-b+1$) and $m-j$. In order to obtain the fingerprint of a block, we have to compute its prefix representation. Once we compute the fingerprint of the first block $Pre(P_i'[1..b])$ using the order-statistic tree, the tree contains the first $b$ characters of $P_i'$. To compute the prefix representations of the subsequent blocks, we observe that we can compute $Pre(P_i'[j+1..j+b])$ by taking advantage of the order-statistic tree containing characters of the previous block $P_i'[j..j+b-1]$. Specifically, we erase $P_i'[j]$ from the tree and insert the new character $P_i'[j+b]$ into the tree. Inserting and deleting an element into the order-statistic tree is accomplished in $O(\log{b})$ time since the tree contains $O(b)$ elements. Then we traverse the tree in $O(b)$ time to retrieve the prefix representation of the new block. We repeat this until we reach the last block. When we reach the last block, we map into the HASH table and add $P_i$ into the corresponding list. The whole process is performed for all the patterns. Since there are $O(km)$ blocks, it takes $O(kmb)$ time to construct the SHIFT and HASH tables.
We also precompute the nearest neighbor representations of all the patterns, namely, $\text{NN}(P_i)$ for $1\le i\le k$. They are used in the searching step for verifying whether patterns actually match the text. Using the order-statistic tree, they are computed in $O(M\log{r})$ time, where $r$ denotes the length of the longest pattern. As a result, the time complexity for the preprocessing step is $O(kmb+M\log{r})$.
\subsection{Searching Step of Algorithm \rom{1}}
In the searching step, we find all the positions of $T$ matched with any pattern in $\mathcal{P}$. Fig.~\ref{alg1} shows the pseudocode of Algorithm \rom{1}. For the search, we slide a position $pos$ along the text, reading a block of length $b$, $T[pos-b+1..pos]$, and computing the corresponding fingerprint $i$. If $\text{SHIFT}(i)>0$, then we shift the search window to $pos+\text{SHIFT}(i)$ and continue the search. Otherwise, $\text{SHIFT}(i)=0$ and there may be a match. Thus we select the list of patterns in $\text{HASH}[i]$, and compare each pattern in the list with the text via the nearest neighbor representation. We call this process the verification step. We repeat this until we reach the end of the text.
\begin{figure}
\begin{normalsize}
\textbf{Algorithm \rom{1}($P=\{P_1,P_2,\cdots,P_k\}$, $T[1..n]$)}
\end{normalsize}
\begin{algorithmic}[1]
\State $m\gets min_{1\le i\le k}(|P_i|)$
\State Preprocess $P$ and compute SHIFT, HASH, NN
\State $pos\gets m$
\While{$pos\le n$}
\State $i\gets f(T[pos-b+1..pos])$
\If{$\text{SHIFT}[i]=0$}
\State Verify each pattern in $\text{HASH}[i]$ via NN
\State $pos\gets pos+1$
\Else
\State $pos\gets pos+\text{SHIFT}[i]$
\EndIf
\EndWhile
\end{algorithmic}
\caption{The pseudocode of Algorithm \rom{1}}\label{alg1}
\end{figure}
\subsection{Average Time for the Search of Algorithm \rom{1}} \label{anal1}
We present a simplified analysis of the average running time for the searching step. For the analysis, we assume that there are no duplicate characters in any $b$-length block in strings, i.e., any consecutive $b$ characters in the text and patterns are distinct. Although this assumption restricts the generality of our problem, it is insignificant because: (1) a fairly large alphabet makes the case against the assumption very unlikely to happen; (2) even if it happens, the algorithm still works correctly without a significant impact on the performance in practice. We leave it as an open problem whether the average $O(\frac{n}{m}\log{M})$ time can be derived when the strings are totally random, which is more complicated. Now, we assume that each distinct block appears randomly at a given position (i.e., with the same probability). Let us denote $\sigma=|\Sigma|$, then there are $_\sigma \!P_b$ different possible blocks and the probability of a block to appear is $1/{_\sigma \!P_b}$.
\begin{lemma}
\label{lemma1}
For two random blocks $x$ and $y$, where $x,y\in {\Sigma}^b$ and each has no duplicate characters, the probability that $Pre(x)=Pre(y)$ is $\frac{1}{b!}$.
\end{lemma}
\noindent Recall that Algorithm \rom{1} determines a shift value according to the prefix representation of a current block on the text.
\begin{lemma}
\label{lemma:shift}
The probability that a random block $x$ leads to a shift value of $j$, $0\le j\le m-b$, is at most $\frac{k}{b!}$.
\end{lemma}
\begin{lemma}
\label{lemma5}
The expected value of a shift during the search is at least $(m-b+1)\lbrace 1-\frac{k(m-b+2)}{2b!}\rbrace$.
\end{lemma}
We set $b=1.5\log{M}/\log{\log{M}}$. Then, by Stirling's approximation~\cite{abramowitz1972handbook}, we can easily prove that $b!=2^{b\log{b}+b\log{e}+O(\log{b})}=\Omega(M)$, and thus the expected value of a shift is at least $\Theta(m)$. Consequently, the average number of iterations of the \textbf{while} loop during the search is bounded by $O(\frac{n}{m})$. At each iteration, we compute a fingerprint and the computation takes $O(b\log{b})=O(\log{M})$ time. Lemma~\ref{avgcost} shows that the verification step at each iteration is accomplished in constant time on average.
\begin{lemma}
\label{avgcost}
The average cost of the verification step at each iteration is $O(1)$.
\end{lemma}
\noindent Hence, the average time complexity of the searching step is roughly $O(\frac{n}{m} \log{M})$.
\section{Algorithm \rom{2}}\label{section:alg2}
In this section, we present a simple algorithm that achieves average linear time for search. Algorithm \rom{2} exploits the ideas of the Karp-Rabin algorithm and the encoding techniques of Chhabra and Tarhio~\cite{chhabra2014order} and Faro and K\"ulekci~\cite{faro2015efficient} for fingerprinting.
\subsection{Fingerprinting in Algorithm \rom{2}}
The Karp-Rabin algorithm is a practical string matching algorithm that makes use of fingerprints to find patterns, and it is important to choose a fingerprint function such that a fingerprint should be efficiently computed and efficiently compared with other fingerprints. Furthermore, the fingerprint function should be suitable for identifying strings in terms of order-preserving matching.
Given an $m$-length pattern $P$, Chhabra and Tarhio~\cite{chhabra2014order} encode the pattern into a binary sequence $\beta(P)$ of length $m-1$, where
\[ \beta(P)[i] = \left\{
\begin{array}{l l}
1 & \quad \text{if $P[i]<P[i+1] $ }\\
0 & \quad \text{otherwise.}
\end{array} \right.\]
We consider the fingerprint $\beta(P)$ as an $(m-1)$-bit binary number. We can compute $\beta(P)$ in time $O(m)$.
As $m$ increases, the fingerprint $\beta(P)$ may be too large to work with; we need at least $(m-1)$ bits to represent a fingerprint. To address this issue, we compute the fingerprints as residues modulo a prime number $p$. According to \cite{karp1987efficient}, we choose the prime $p$ pseudorandomly in the range $[1..mn^2]$. With this choice, it is proved that the probability of a single false positive due to the modulo operation while searching is bounded by $2.53/n$, which is negligibly small for sufficiently large $n$~\cite{karp1987efficient}.
Faro and K\"ulekci~\cite{faro2015efficient} proposed more advanced encoding techniques such as $q$-NR and $q$-NO. Instead of comparing between only a pair of neighboring characters, they compared between a set of $q$ characters for computing the relative position of a character. We can compute fingerprints using those techniques similarly to above. We implemented Algorithm \rom{2} using three encoding techniques, including Chhabra and Tarhio's binary encoding \cite{chhabra2014order}, $q$-NR, and $q$-NO~\cite{faro2015efficient}, for fingerprinting. In the following sections, we will describe the algorithm assuming the binary encoding.
\subsection{Preprocessing Step of Algorithm \rom{2}}
Again, let $\mathcal{P}'=\{P_1',P_2',\cdots ,P_k'\}$ be the set of $m$-length prefixes of the patterns. In the preprocessing step, we first compute $\beta(P_i')$ for $1\le i\le k$ and build a HASH table. $\text{HASH}[i]$ contains a pointer to the list of the patterns whose fingerprints equal $i$. We also compute $\text{NN}(P_i)$ for $1\le i\le k$. In total, the preprocessing step takes $O(M\log{r})$ time. Fig.~\ref{alg2_example}-(a) shows the HASH table when there are three patterns. We use a prime $p=7$ in the example.
\begin{figure}
\begin{center}\
\centerline{\includegraphics[scale=0.35]{alg2ex.png}}
\caption{(a) The HASH table. (b) An example of the search. For the window $T[2..6]$, the corresponding fingerprint is $5$. We check $\text{HASH}[5]$, which has $P_1,P_2$ as elements, and thus verify them via NN.}
\label{alg2_example}
\end{center}
\end{figure}
\subsection{Searching Step of Algorithm \rom{2}}
In the searching step, we scan the text $T$ while iteratively computing fingerprints of the successive windows of size $m$. Fig.~\ref{alg2} shows the pseudocode of Algorithm \rom{2}. We slide a search window $T[i..i+m-1]$ along the text, computing the corresponding fingerprint $\beta$. If the list pointed by $\text{HASH}[\beta]$ is not empty, we compare each pattern in the list with the text via its nearest neighbor representation. We call this process the verification step. We repeat this until we reach the end of the text. Fig.~\ref{alg2_example}(b) shows an example of the searching step.
\begin{figure}
\begin{normalsize}
\textbf{Algorithm \rom{2}($P=\{P_1,P_2,\cdots,P_k\}$, $T[1..n]$)}
\end{normalsize}
\begin{algorithmic}[1]
\State $m\gets min_{1\le i\le k}(|P_i|)$
\State Preprocess $P$ and compute HASH, NN
\State $pos\gets m$
\For{$i=1 \;\text{for}\;n-m+1$}
\State $\beta=\beta(T[i..i+m-1]) \; \text{mod} \; p$
\State Verify each pattern in $\text{HASH}[\beta]$ via NN
\EndFor
\end{algorithmic}
\caption{The pseudocode of Algorithm \rom{2}}\label{alg2}
\end{figure}
\subsection{Average Time for the Search of Algorithm \rom{2}}
At each iteration of the \textbf{for} loop, we compute the fingerprint $\beta$ of the search window. Let us denote $\beta_i=\beta(T[i..i+m-1]) \; \text{mod} \; p$, which is the fingerprint of the $i$-th search window. We can compute $\beta_1$ in time $O(m)$. To compute the fingerprints for the subsequent windows, we observe that we can compute $\beta_{i+1}$ from $\beta_i$ using Horner's rule~\cite{cormen2001introduction}, since
\begin{eqnarray*}
\ \beta_{i+1}=(2(\beta_i-H\cdot\beta(T)[i])+\beta(T)[i+m]) \; \text{mod} \; p\;,
\end{eqnarray*}
where $H=2^{m-2} \;(\text{mod}\;p)$ is a precomputed value. It is clear that this calculation is done in constant time.
Now, we analyze the time spent to perform the verification step. We assume that the numbers in the text and patterns are statistically independent and uniformly at random. The verification is performed when there is a match between encoded binary strings of the text and patterns. The probability that a 1 appears at a position of an encoded string is $q=({\sigma}^2/2-\sigma/2)/{\sigma}^2=(\sigma-1)/2\sigma$. So the probability of a character match~\cite{chhabra2014order} is
\begin{eqnarray*}
\ s=q^2+(1-q)^2=\frac{1}{2}+\frac{1}{2\sigma^2}\;.
\end{eqnarray*}
Since the odd positions of an encoded string are mutually independent, we can (upper) bound the probability of a match between two encoded strings by $s^{(m-1)/2}$. Note that $s\le 5/8$ for $\sigma\geq 2$.
\begin{lemma}
\label{lemma6}
When $M$ is polynomial with respect to $m$, the average cost of the verification step during the search is $O(1)$.
\end{lemma}
\noindent Hence, the average time complexity of the searching step is $O(n)$, when $M$ is polynomial with respect to $m$.
\section{Experiments}\label{section:exp}
In order to verify the practical behaviors of our algorithms, we tested them against the previous algorithms based on the Aho-Corasick algorithm: Kim et al.'s \cite{kim2014order}, and Belazzougui et al.'s~\cite{belazzougui2013single}.\footnote[1]{For the implementation of the van-Emde-Boas tree used in \cite{belazzougui2013single}, we used the source code publicly available at https://code.google.com/p/libveb/.} Kim et al.'s algorithm is denoted by \emph{KEF}, Belazzougui et al.'s by \emph{BPR}, and Algorithm \rom{1} by \emph{Alg1}. Algorithm \rom{2} is denoted by \emph{Alg2}, followed by a notation of the encoding technique adopted for fingerprinting. Specifically, \emph{Alg2\_Bin} refers to Algorithm \rom{2} with Chhabra and Tarhio's binary encoding \cite{chhabra2014order}, and \emph{Alg2\_NR2} (resp. \emph{Alg2\_NO2}) refers to Algorithm \rom{2} with the $q$-NR (resp. $q$-NO) encoding of Faro and K\"ulekci \cite{faro2015efficient} where we set $q=2$. All algorithms were implemented in C++ and run on a Debian Linux 7(64bit) with Intel Xeon X5672 processor and 32 GB RAM. During the compilation, we used the –O3 optimization option.
We tested for a random text $T$ of length $n=10^6$ searched for $k=10,50,100$ random patterns of length $m=5,10,20,50,100$, respectively. All the texts and patterns were selected randomly from an integer alphabet $\Sigma=\{1,2,\cdots ,1000\}$ (we tested for varying alphabet sizes, but we didn't observe sensible differences in the results). For each combination of $k$ and $m$, we randomly selected a text and patterns, and then ran each algorithm. We performed this 10 times and measured the average time for the searching step. Table~\ref{table1} shows the results.
Fig.~\ref{NumberOfPattern10} in Appendix shows the average search times when $k=10$. When $m$ is less than 50, \emph{Alg2\_Bin} is the best among the algorithms, achieving a speed up of about 6 times compared to \emph{KEF}, and about 14 times compared to \emph{BPR}. As $m$ increases, however, \emph{Alg1} becomes better, achieving a speed up of about 11 times compared to \emph{KEF}, and about 24 times compared to \emph{BPR}. This is due to the increase of the average shift value during the search. The reason that the average shift value increases is that since we set $b=1.5\log{M}/\log{\log{M}}$, the block size increases as $m$ increases, and thus the probability that a block appears in the patterns decreases. Fig.~\ref{NumberOfPattern50} and \ref{NumberOfPattern100} in Appendix show the average search times when $k=50,100$. They show similar trends with Fig.~\ref{NumberOfPattern10}. One thing to note is that as $k$ increases, the point of $m$ where \emph{Alg1} becomes for the first time faster than the \emph{Alg2} family increases. We attribute this to the fact that as $k$ increases, a block appears more often in the patterns, which leads to lower shift values.
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{table}\caption{Average search times with different values for $k$ and $m$.}
\begin{center}
\begin{tabular}{|C{1.0cm}|C{1.0cm}|c|C{1.5cm}|C{1.5cm}|C{1.5cm}|C{1.5cm}|C{1.5cm}|C{1.5cm}|}
\hline
\ $k$ & $m$ & & \emph{KEF} &\emph{BPR} & \emph{Alg1} & \emph{Alg2\_Bin} & \emph{Alg2\_NR2} & \emph{Alg2\_NO2}\\ \hline \hline
\multirow{5}{*}{10} & 5 & & 527.3 & 1215.1 & 274.8 & \textbf{107.6} & 164.8 & 186.5\\ \cline{2-9}
& 10 & & 544.3 & 1258.2 & 216.9 & \textbf{91.5} & 148.8 & 197.6\\ \cline{2-9}
& 20 & & 557.1 & 1254.8 & 286.5 & \textbf{88.4} & 155.4 & 194.8\\ \cline{2-9}
& 50 & & 556.2 & 1213 & \textbf{51.1} & 65.4 & 116.7 & 203\\ \cline{2-9}
& 100 & & 561.7 & 1244.8 & \textbf{56.2} & 70.4 & 123.9 & 206.9\\ \hline \hline
\multirow{5}{*}{50} & 5 & & 598 & 1227.2 & 647.8 & 234.1 & \textbf{215.3} & 310\\ \cline{2-9}
& 10 & & 573.8 & 1238.6 & 269.6 & \textbf{100.5} & 152.3 & 194.6\\ \cline{2-9}
& 20 & & 562.9 & 1244.2 & 308.6 & \textbf{114.8} & 187.1 & 216.4\\ \cline{2-9}
& 50 & & 570.7 & 1239.8 & 313.5 & \textbf{113.8} & 184.5 & 226.2\\ \cline{2-9}
& 100 & & 587.6 & 1271.8 & \textbf{55.4} & 86.1 & 150.6 & 227.6\\ \hline \hline
\multirow{5}{*}{100} & 5 & & 569 & 1291.1 & 674.4 & 395.6 & 386.3 & \textbf{307.3}\\ \cline{2-9}
& 10 & & 629 & 1304.3 & 522.4 & \textbf{81.9} & 100.3 & 150.5\\ \cline{2-9}
& 20 & & 589 & 1250.2 & 498.4 & \textbf{102.6} & 164 & 205.1\\ \cline{2-9}
& 50 & & 605.3 & 1259.9 & 103.3 & \textbf{86} & 184.8 & 225.7\\ \cline{2-9}
& 100 & & 588.9 & 1247.2 & 73.2 & \textbf{53.8} & 182 & 227.5\\ \hline
\end{tabular}
\end{center}
\label{table1}
\end{table}
\section{Conclusion}\label{section:con}
We proposed two efficient algorithms for the multiple order-preserving matching problem. Algorithm \rom{1} is based on the Wu-Manber algorithm, and Algorithm \rom{2} is based on the Karp-Rabin algorithm and exploits the encoding techniques of the previous works~\cite{chhabra2014order,faro2015efficient}. Algorithm \rom{1} performs the multiple order-preserving matching in average $O(\frac{n}{m} \log{M})$ time, and Algorithm \rom{2} performs it in average $O(n)$ time when $M$ is polynomial with respect to $m$. The experimental results show that both of the algorithms are much faster than the existing algorithms. When the lengths of the patterns are relatively short, Algorithm \rom{2} with the binary encoding performs the best due to its inherent simplicity. However, Algorithm \rom{1} becomes more efficient as the lengths of the patterns grow.
|
{'timestamp': '2015-06-18T02:08:51', 'yymm': '1506', 'arxiv_id': '1506.05203', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05203'}
|
arxiv
|
\section{Introduction}
Network densification via small cells -- resulting in heterogeneous cellular networks (HetNets) -- along with novel multiple antenna technologies are two of the key methods for achieving a 1000x capacity increase in 5G networks \cite{Andrews14}.
By densely deploying different types of small cells overlaid on the existing macrocell network, spatial reuse and thus area spectral efficiency (ASE) can be significantly improved and uniform coverage can be provided \cite{Hwang13,Ghosh12,Bartoli14}. Independently, multiple antenna technology, known as MIMO, is playing an increasingly important role in 4G cellular networks, and is expected to be even more essential for meeting 5G target data rates. One key such technique is multiuser MIMO, which allows a base station (BS) with many antennas to communicate simultaneously with numerous mobile units each with a very small number of antennas. Although multiuser MIMO -- also known as space division multiple access (SDMA) -- has been known for quite some time and previous implementation efforts have been relatively disappointing, enthusiasm has been recently renewed, as seen in the extensive recent literature on ``massive MIMO'' \cite{Rusek13}, as well as the very recent 3GPP standardization of full-dimension (FD) MIMO, which can support 64 antennas in a 2D array at the BS to communicate simultaneously with 32 mobile terminals \cite{Kim14}.
\subsection{Related Work}
A key result from early HetNet analysis was the derivation of the signal-to-interference-plus-noise (SINR) distribution, also known as the coverage or outage probability, where the HetNet is characterized by randomly placed base stations forming $K$ tiers, each tier distinguished by a unique transmit power and \emph{density}, i.e. the average number of BSs per unit area \cite{Jo12,Dhillon12}. A key resulting observation was that the signal-to-interference ratio (SIR) distribution is invariant to the BS densities, as long as the mobile connects to the BS providing the strongest received signal power. This \emph{SIR invariance} property means that cell densification does not degrade the link reliability, and so the area spectral efficiency (ASE) of the network can be increased indefinitely by deploying more BSs. These early papers have resulted in a flurry of follow on work, e.g.
\cite{Singh13,Cheung12,Renzo13,Dhillon13_LA,DiRenzo14,DiRenzo15}, and see \cite{ElSawy13} for a survey.
Multi-antenna transmissions bring significant additional complexity to HetNet analysis, primarily due to the complexity of the random matrix channel. As shown in \cite{Dhillon13}, the invariance property may be lost in multi-antenna HetNets, i.e., the outage probability will increase as the BS density increases. This is mainly because the distributions of both the signal and interference depend on the number of BS antennas and the adopted multi-antenna transmission strategy of each BS. The work \cite{Dhillon13} relied on stochastic ordering to compare different multi-antenna techniques, but such a method cannot be used for quantitative analysis, since the SINR and SIR distributions were not provided. That work was extended to incorporate load balancing and thus the achievable rate in \cite{Gupta14}. Other notable efforts on MIMO HetNets include work limited to two tiers \cite{Chandrasekhar09,Adhikary15}, and the analysis in \cite{Heath13}, which focused on the interference distribution.
In this paper, we attempt to solve a more fundamental problem, namely the determination of the SIR distribution in a MIMO HetNet, particularly a multiuser MIMO HetNet, and the resulting effect of the BS density on the network performance. By ``performance'', we are interested in both link reliability -- i.e. the success probability -- and the sum throughput, which we characterize per unit area as the ASE.
The link reliability vs. ASE tradeoff discussed in this paper is related to the notion of ``transmission capacity'' in wireless ad hoc networks \cite{Weber05,Weber12}, with related multi-antenna results such as \cite{Hunter08,Govindasamy07,Jindal11,Kountouris12}. In wireless ad hoc networks, to maximize the spatial throughput, i.e. ASE, while guaranteeing the link reliability at a certain SINR, the density of transmitters cannot exceed a certain value, which is called the \emph{transmission capacity} \cite{Weber12}. Naturally, allowing more simultaneous transmitters will increase the spatial reuse efficiency, but the interference to the receivers will become higher and so the SINR and thus link reliability will decrease, similar to the ASE vs. link reliability tradeoff studied in this paper.
\subsection{Contributions}
The main contributions of this paper are summarized as follows.
\subsubsection{Tractable Expressions of the Success Probability for Downlink Multiuser MIMO HetNets}
An exact expression of the success probability of the typical user in a general $K$-tier multiuser MIMO HetNet with zero-forcing (ZF) precoding and perfect channel state information (CSI) is derived. This expression has a simple structure and can be utilized for performance evaluation and system design of general MIMO HetNets. Moreover, based on this exact expression, an asymptotic (large SIR) expression of the success probability is also provided, which has a simple and symmetric form with respect to the network parameters.
\subsubsection{Key Properties of the Success Probability}
Based on these tractable expressions, we explicitly show the effect of the BS densities on the success probability, i.e., the link reliability. First, we prove that increasing the BS density of one tier will either increase or decrease the link reliability. Thus, the SIR invariance property no longer holds in MIMO HetNets. Second, we prove that the maximum link reliability of the network is achieved by only activating one tier of BSs. This is a surprising result, as nowadays a common intuition is that deploying more and more BSs will improve the network performance. Moreover, we show that such phenomena result from the fact that different tiers in MIMO HetNets have different influences on the link reliability, and the overall link reliability is an average of users in different tiers.
\subsubsection{ASE vs. Link Reliability Tradeoff}
Since adjusting the BS densities will affect both the link reliability and ASE, a tradeoff is needed to balance these two aspects. Thus, we propose efficient algorithms to find the optimal BS densities that can achieve the maximum ASE while guaranteeing a certain link reliability requirement. If the required link reliability is low, all the BSs should be activated to achieve the maximum ASE. On the contrary, if the required link reliability becomes higher, more BSs should be deactivated. The extreme case is that to achieve the highest link reliability, only a single tier of BSs should be active. Therefore, care is needed when densifying a HetNet with multi-antenna BSs.
\subsection{Paper Organization and Notation}
The rest of the paper is organized as follows. Section~\ref{Sec:SystemModel} presents the system model. Section~\ref{Sec:PsAnalysis} derives the expressions of the success probability. In Section~\ref{Sec:Tradeoff}, we investigate the tradeoff between the ASE and link reliability. Finally, Section~\ref{Sec:Conclusions} concludes the paper.
In this paper, vectors and matrices are denoted by hold-face lower-case and upper-case letters, respectively. The $M\times M$ identity matrix is denoted by $\mathbf{I}_M$. We use $\left(\cdot\right)^{T}$ and $\left(\cdot\right)^{*}$ to denote transpose and conjugate transpose, respectively. The Euclidean norm of the vector $\mathbf{x}$ is $\left\Vert \mathbf{x}\right\Vert$, while $\left\Vert \mathbf{A}\right\Vert _{1}$ is the $L_1$ induced matrix norm, i.e., $\left\Vert \mathbf{A}\right\Vert _{1}=\max_{1\leq j\leq n}\sum_{i=1}^{m}\left|a_{ij}\right|$ for $\mathbf{A}\in\mathbb{R}^{m\times n}$. The expectation is denoted as $\mathbb{E}\left[\cdot\right]$. The notation $X \stackrel{d}{\sim} Y$ means that $X$ is distributed as $Y$. The normalized sinc function is defined by ${\rm sinc}\left(\delta\right)=\frac{\sin\left(\pi \delta\right)}{\pi \delta}$. Finally, $\mathcal{O}\left(\cdot\right)$ is the Landau's notation, where $f\left(x\right)=\mathcal{O}\left(g\left(x\right)\right)$ as $x\rightarrow x_0$ means that there are constants $C>0$ and $\varepsilon>0$, such that for $0<\left|x-x_{0}\right|<\varepsilon$, $\left|f\left(x\right)\right|\leq C\left|g\left(x\right)\right|$. The asymptotic equivalence is denoted as $\sim$, where $f\left(x\right)\sim g\left(x\right)$ as $x\rightarrow\infty$ means that $f\left(x\right)/g\left(x\right)$ tends to unity as $x\rightarrow\infty$.
\section{System Model} \label{Sec:SystemModel}
In this section, we will first introduce a stochastic model for downlink multiuser MIMO HetNets, and then the main performance metrics considered in the paper will be presented.
\subsection{A Tractable Model for Downlink MIMO HetNets}
We consider a downlink cellular network consisting of $K$ different tiers of BSs, indexed by $\mathcal{K}=\left\{1,2,\ldots,K\right\}$. In the $k$th tier, the BSs are spatially distributed according to a homogeneous Poisson point process (PPP) \cite{Stoyan96} in $\mathbb{R}^2$ of density $\lambda_k$, denoted by $\Psi_k$. Each BS in the $k$th tier has transmit power $P_k$, with $M_k$ antennas, and serves $U_k$ ($U_k\leq M_k$) users at each time slot, i.e., intra-cell SDMA is considered. Note that when $U_k=1$, $\forall k\in\mathcal{K}$, the network becomes a TDMA HetNet. Meanwhile, we assume that mobile users are distributed as a homogeneous PPP $\Phi_u$ of density $\lambda_u$, which is independent of $\Psi_k$, $\forall k\in\mathcal{K}$. Each user has a single receive antenna, and is associated with one BS\footnote{Note that our analysis also applies to single user MIMO, where each user in the $k$th tier has $U_k$ uncorrelated receive antennas, and BSs in the $k$th tier apply equal power allocation to the $U_k$ streams. Then the success probability to the typical user analyzed in this paper becomes the success probability per stream.}. We assume the network is fully-loaded ($\lambda_u\gg\lambda_k,\forall k\in\mathcal{K}$), i.e., there are at least $U_k$ users in each cell in the $k$th tier, and each BS will randomly choose $U_k$ users to serve at each time slot. Note that this is a common assumption in the analysis of random cellular networks \cite{Singh13,Gupta14}, and the analysis of the non-fully-loaded network is left to our future work. An example of a 3-tier multiuser MIMO HetNet is shown in Fig.~\ref{fig:System_Model}.
\begin{figure}
\begin{center}
\scalebox{0.7}{\includegraphics{3TierHetNets.eps}}
\end{center}
\caption{A demonstration of a 3-tier HetNet, in which each macro BS has 8 antennas and serves 4 users, each micro BS has 4 antennas and serves 2 users, and each pico BS has a single antenna and serves 1 user.}
\label{fig:System_Model}
\end{figure}
The network is open access, which means a user is allowed to access any BS in any tier. Particularly, each user will listen to the pilot signals from different BSs, and measure the long-term average received power. We will consider a commonly adopted cell association rule \cite{Jo12}, i.e., the user will be associated with the $k$th tier if\footnote{In the user association procedure, the first antenna normally uses the total transmission power of a BS to transmit reference signals for biased received power determination according to the LTE standard \cite{Ghosh10}.}
\begin{equation}
k=\arg\max_{j\in\mathcal{K}} P_j B_j r_j^{-\alpha},
\end{equation}
where $r_j$ denotes the minimal distance from a user to its nearest BS in the $j$th tier, $\alpha>2$ is the path loss exponent\footnote{Note that in this paper, we assume the same path loss exponent in the network. However, the analysis can be extended to the model in which different tiers have different path loss exponents (e.g., \cite{Jo12}).}, and $B_j$ is the bias factor of the $j$th tier, which is used for load balancing \cite{Jo12,ElSawy13}. It is shown in \cite{Jo12} that the typical user will be associated with the $k$th tier with probability
\begin{equation}
A_k = \frac{\lambda_k P_k^\delta B_k^\delta}{A},
\end{equation}
where $\delta\triangleq \frac{2}{\alpha}$ and $A=\sum_{j=1}^K \lambda_j P_j^\delta B_j^\delta$.
For each BS, equal power allocation is assumed in this paper, i.e., the BS in the $k$th tier will equally allocate $P_k$ to its $U_k$ users. Furthermore, we adopt ZF precoding and assume perfect CSI at each BS\footnote{ZF is commonly used as the transmission strategy for multiuser MIMO in both the literature and industry, due to its simplicity and fairly well performance. It will be interesting to investigate how the findings in this paper will change if other precoding methods are used. However, this is left to our future work.}. Therefore, the received power of the typical user at origin $o$ from a BS located at $x\in\Psi_k$ is given by
\begin{equation}
P\left(x\right) = \frac{P_k}{U_k} g_{x,k} \left\Vert x\right\Vert ^{-\alpha},
\end{equation}
where $g_{x,k}$ is the channel gain, and its distribution depends on whether the BS is the home BS (i.e., the associated BS) or the interfering BS. Assuming Rayleigh fading channels, it is shown in \cite{Heath11} that $g_{x,k}$ is gamma distributed with the shape parameter $M_k-U_k+1$ if the BS at $x$ is the home BS, i.e., $g_{x,k}\stackrel{d}{\sim}{\rm Gamma}\left(D_k,1\right)$, where $D_k\triangleq M_k-U_k+1$, while it can be approximated as $g_{x,k}\stackrel{d}{\sim}{\rm Gamma}\left(U_k,1\right)$ if the BS is the interfering BS in the $k$th tier. This approximation has been commonly adopted in performance analysis of multiuser MIMO networks, e.g., \cite{Dhillon13,Hosseini14,Chandrasekhar09,Kountouris12}. In addition, the gamma distribution is a good approximation for the channel gain distributions for a large class of multi-antenna transmission schemes \cite{Heath13}, and thus the analysis in this paper can be extended to more general settings.
In this paper, we assume that universal frequency reuse is applied, which implies that the user will not only receive the information signal from its home BS, but also suffer interference from all the other BSs. The resulting SIR of the typical user, served by the BS at $x_0$ in the $k$th tier, is given by
\begin{equation} \label{eq:SINR_def}
{\rm SIR}_{k}= \frac{\frac{P_{k}}{U_{k}}g_{x_{0},k}r_{k}^{-\alpha}} {\sum_{j=1}^{K}\sum_{x\in\Psi_{j}\backslash\left\{ x_{0}\right\}} \frac{P_{j}}{U_{j}}g_{x,j}\left\Vert x\right\Vert ^{-\alpha}}.
\end{equation}
Note that we consider SIR, rather than SINR, in this paper, as the SIR distribution captures the key tradeoffs in reasonably dense deployments.
\begin{remark}
In summary, the most important parameters of the network are the per-tier parameters: $\left\{\lambda_k,P_k,B_k,M_k,U_k\right\}$. Compared with existing works, the $K$-tier HetNet model in this paper includes intra-cell multi-antenna transmissions, which generalizes the SISO HetNet model (where $M_k=U_k=1$ for all $k\in\mathcal{K}$) \cite{Jo12}. Based on this model, the effects of the multiple antennas and the number of served users can be evaluated. Meanwhile, the derivation and analysis will be more difficult, as both the signal and interfering channel gains become gamma distributed, while in SISO HetNets, all the channel gains are exponentially distributed.
\end{remark}
\subsection{Performance Metrics}
In this paper, we consider two performance metrics. The first one is the success probability, also called the coverage probability \cite{Andrews11,Jo12}, which measures the reliability of the typical transmission link. The definition of the success probability for the typical user is given by
\begin{equation} \label{eq:Ps_def}
p_{\rm s}= \mathbb{P}\left({\rm SIR}\geq\hat\gamma\right),
\end{equation}
where $\hat\gamma$ is the SIR threshold. Since the success probability is different if the typical user is associated with different tiers, the overall success probability in \eqref{eq:Ps_def} can be written as in \cite{Jo12} as
\begin{equation} \label{eq:Psk_def}
p_{\rm s}= \sum_{k=1}^K A_k p_{\rm s} \left(k\right),
\end{equation}
where $p_{\rm s} \left(k\right)$ is the success probability when the user is served by the BS in the $k$th tier.
On the other hand, to describe the network capacity, we use the ASE as the metric\footnote{Note that in some literature, e.g., \cite{Andrews11} and \cite{Wang14}, the Shannon throughput of a cell, defined by $\mathbb{E}\left[\log_2\left(1+{\rm SIR}\right)\right]$, is used as the performance metric. The extension of our results to this case will be left to future work.}, defined by \cite{Singh13,Baccelli06,Cheung12} as
\begin{equation} \label{eq:ASE_def}
{\rm ASE}=\sum_{k=1}^K \lambda_k U_k p_{\rm s} \left(k\right) \log_2\left(1+\hat\gamma\right),
\end{equation}
for which the unit is bit/s/Hz/${\rm m}^2$. Note that ASE measures the total data rate in a unit area normalized by the bandwidth, and it can directly tell the capacity gain by cell densification.
The ASE defined in \eqref{eq:ASE_def} applies to the fully-loaded networks. Note that if the network is not fully-loaded, the inactive BSs will increase the SIR and thus the success probability, but decrease the achieved ASE since there are fewer active links per unit area \cite{Dhillon13_LA}.
The success probability and ASE are two different aspects of a communication system, and both of them are fundamental metrics. A higher ASE means the network can support more users, i.e., with a higher spatial reuse efficiency, while a higher success probability implies that the transmission links are more reliable, i.e., a better quality of experience (QoE). While previous studies revealed the invariance property of the success probability in SISO HetNets, in this paper, we will investigate the interplay of these two metrics in more general multiuser MIMO HetNets. Since the ASE depends on $p_{\rm s} \left(k\right)$, we will first derive it in Section \ref{Sec:PsAnalysis}, and then investigate the tradeoff between ASE and $p_{\rm s}$ in Section \ref{Sec:Tradeoff}.
\section{Analysis of the Success Probability} \label{Sec:PsAnalysis}
In this section, we will first derive an exact expression of the success probability. Then, an asymptotic expression will be provided, which will expose its key properties in MIMO HetNets.
\subsection{The Exact Expression of $p_{\rm s}$}
To obtain the overall success probability $p_{\rm s}$ from \eqref{eq:Psk_def}, we need to first derive the per-tier values $p_{\rm s}\left(k\right)$. Assuming the typical user is served by the BS in the $k$th tier, then based on \eqref{eq:SINR_def}, $p_{\rm s}\left(k\right)$ is given by
\begin{equation} \label{eq:Psk_ori}
p_{{\rm s}}\left(k\right)= \mathbb{P}\left(\frac{\frac{P_{k}}{U_{k}}g_{x_{0},k}r_{k}^{-\alpha}} {\sum_{j=1}^{K}\sum_{x\in\Psi_{j}\backslash\left\{ x_{0}\right\} }\frac{P_{j}}{U_{j}}g_{x,j}\left\Vert x\right\Vert ^{-\alpha}}\geq\hat{\gamma}\right).
\end{equation}
The main difficulty of the derivation is the gamma distributed channel gains $g_{x_{0},k}$ and $g_{x,j}$. There exist some previous works studying similar network models. While only a qualitative comparison between SDMA and TDMA was considered in \cite{Dhillon13}, the complicated expression of $p_{\rm s}$ derived in \cite{Gupta14} based on the Fa{\`a} di Bruno lemma obscured useful design insights. In this paper, we adopt a novel method and derive a more tractable expression for $p_{\rm s}$, as shown in Theorem \ref{Thm:Psk_General}.
\begin{theorem} \label{Thm:Psk_General}
The success probability of the typical user served by the BS in the $k$th tier is given by
\begin{equation} \label{eq:Psk_Matrix}
p_{s}\left(k\right)=A\left\Vert \mathbf{Q}_{D_{k}}^{-1}\right\Vert _{1},
\end{equation}
where $A=\sum_{j=1}^K \lambda_j P_j^\delta B_j^\delta$, $\delta=\frac{2}{\alpha}$, $D_{k}\triangleq M_{k}-U_{k}+1$, $\left\Vert \cdot\right\Vert _{1}$ is the $L_1$ induced matrix norm, and $\mathbf{Q}_{D_k}$ is the $D_k\times D_k$ lower triangular Toeplitz matrix, given by
\begin{equation} \label{eq:Q}
\mathbf{Q}_{D_{k}}=\left[\begin{array}{ccccc}
q_{0}\\
q_{1} & q_{0}\\
q_{2} & q_{1} & q_{0}\\
\vdots & & & \ddots\\
q_{D_{k}-1} & \cdots & q_{2} & q_{1} & q_{0}
\end{array}\right],
\end{equation}
in which
\begin{equation} \label{eq:qi}
q_{i} = \sum_{j=1}^{K}\lambda_{j}P_{j}^{\delta}B_{j}^{\delta} \frac{\Gamma\left(U_j+i\right)}{\Gamma\left(U_j\right)\Gamma\left(i+1\right)} \frac{\delta}{\delta-i} \left(\frac{U_{k}B_{k}}{U_{j}B_{j}}\hat{\gamma}\right)^{i}
{}_{2}F_{1} \left(i-\delta,U_{j}+i;i+1-\delta;-\frac{U_{k}B_{k}}{U_{j}B_{j}}\hat{\gamma}\right),
\end{equation}
where ${}_{2}F_{1}\left(a,b;c;z\right)$ is the Gauss hypergeometric function \cite[p.~1005]{Table}
\end{theorem}
\begin{IEEEproof}
See Appendix \ref{App:Psk_General}.
\end{IEEEproof}
Note that expression \eqref{eq:Psk_Matrix} is similar to the expression of $p_{\rm s}$ of multi-antenna single-tier networks \cite{Li14}. However, compared with the result in \cite{Li14}, the expression in Theorem~\ref{Thm:Psk_General} is in a simpler form while dealing with more general cases. Furthermore, the derivation provided in Appendix~\ref{App:Psk_General} adopts a different method which is more tractable than the one in \cite{Li14}. Accordingly, the success probability of the typical user is given by
\begin{equation}
p_{\rm s} = \sum_{k=1}^K \lambda_k P_k^\delta B_k^\delta \left\Vert \mathbf{Q}_{D_{k}}^{-1}\right\Vert _{1}.
\end{equation}
The success probability of the single-tier network is given as a special case in the following corollary.
\begin{corollary} \label{Col:SingleTier}
The success probability of the typical user in the single-tier network where each BS has $M$ antennas and serves $U$ users is given by
\begin{equation} \label{eq:Ps_singletier}
p_{s}\left(k\right)=\left\Vert \mathbf{\tilde{Q}}_{D}^{-1}\right\Vert _{1},
\end{equation}
where $D = M-U+1$, and $\mathbf{\tilde{Q}}_{D}$ has the same structure as $\mathbf{Q}_{D_k}$ in \eqref{eq:Q}, with the elements $\tilde{q}_i$ given by
\begin{equation} \label{eq:qi_singletier}
\tilde{q}_i=\frac{\Gamma\left(U+i\right)}{\Gamma\left(U\right)\Gamma\left(i+1\right)} \frac{\delta}{\delta-i}\hat{\gamma}^{i} {}_{2}F_{1}\left(i-\delta,U+i;i+1-\delta;-\hat{\gamma}\right).
\end{equation}
\end{corollary}
It shows in Corollary~\ref{Col:SingleTier} that the success probability of the typical user is independent to the BS density, which indicates that the SIR-invariance property still holds in SDMA homogeneous cellular networks, which is consistent with SISO networks \cite{Andrews11}.
Theorem~\ref{Thm:Psk_General} provides a tractable expression that can be easily evaluated numerically. However, it is still in a complicated form, which makes it difficult to directly observe the effects of different system parameters. To overcome this difficulty, in the next subsection, we will provide an asymptotic result of $p_{\rm s}$ as the SIR threshold becomes large.
\subsection{The Asymptotic Expression of $p_{\rm s}$ and Its Properties}
In this subsection, we will first derive an asymptotic expression of $p_{\rm s}$ as the SIR threshold is large, i.e., $\hat{\gamma}\rightarrow \infty$. Then, we will provide some basic properties of $p_{\rm s}$, which can help to better understand multiuser MIMO HetNets.
The Taylor expansion of the coefficients $q_i$ in \eqref{eq:qi} gives
\begin{equation} \label{eq:qi_Asy}
q_{i}= \sum_{j=1}^{K}\lambda_{j}P_{j}^{\delta}B_{j}^{\delta} \left(\frac{U_{k}B_{k}}{U_{j}B_{j}}\hat{\gamma}\right)^{\delta} \frac{\delta}{\delta-i}\frac{\Gamma\left(i+1-\delta\right)\Gamma\left(U_{j} +\delta\right)} {\Gamma\left(i+1\right)\Gamma\left(U_{j}\right)} +\mathcal{O}\left(\frac{1}{\hat{\gamma}^{U_{j}}}\right).
\end{equation}
Then, under the assumption that $\hat\gamma\rightarrow\infty$, the asymptotic expression of the success probability is given in the following theorem.
\begin{theorem} \label{Thm:Psk_Asy}
The asymptotic expression of $p_{\rm s}\left(k\right)$ as $\hat\gamma\rightarrow\infty$ is given by
\begin{equation} \label{eq:Psk_Asy}
p_{{\rm s}}\left(k\right)\sim A\hat{\gamma}^{-\delta} {\rm sinc}\left(\delta\right) \frac{\left(U_{k}B_{k}\right)^{-\delta} \frac{\Gamma\left(D_{k}+\delta\right)}{\Gamma\left(D_{k}\right)}} {\sum_{j=1}^{K}\lambda_{j}\left(\frac{P_{j}}{U_{j}}\right)^{\delta} \frac{\Gamma\left(U_{j}+\delta\right)}{\Gamma\left(U_{j}\right)}}.
\end{equation}
\end{theorem}
\begin{IEEEproof}
See Appendix \ref{App:Psk_Asy}.
\end{IEEEproof}
Based on Theorem~\ref{Thm:Psk_Asy}, the success probability of the typical user is given by
\begin{equation} \label{eq:Ps_Asy}
p_{{\rm s}}=\sum_{k=1}^{K}A_{k}p_{{\rm s}}\left(k\right)\sim \hat{\gamma}^{-\delta}{\rm sinc}\left(\delta\right) \frac{\sum_{k=1}^{K}\lambda_{k}\left(\frac{P_{k}}{U_{k}}\right)^{\delta} \frac{\Gamma\left(D_{k}+\delta\right)}{\Gamma\left(D_{k}\right)}} {\sum_{j=1}^{K}\lambda_{j}\left(\frac{P_{j}}{U_{j}}\right)^{\delta} \frac{\Gamma\left(U_{j}+\delta\right)}{\Gamma\left(U_{j}\right)}}.
\end{equation}
In Fig. \ref{fig:Ps_Asy}, we compare the asymptotic result in \eqref{eq:Ps_Asy} with the exact numerical result in Theorem~\ref{Thm:Psk_General}, as well as the simulation result. We consider a 3-tier HetNet, and the parameters are provided in the caption of the figure. From Fig. \ref{fig:Ps_Asy}, we can find that the numerical result in Theorem~\ref{Thm:Psk_General} is exactly the same as the simulation result. Moreover, the asymptotic result in \eqref{eq:Ps_Asy} provides as an upper bound when the SIR threshold $\hat\gamma$ is not large, but the gap becomes smaller when $\hat\gamma$ increases. This result confirms the effectiveness of the asymptotic result when the SIR threshold is large. For example, in this setting, the asymptotic result is almost the same as the exact result when $\hat\gamma \gtrsim 5$ dB, and above 10 dB, is indistinguishable. Note that MIMO techniques will enhance the data rate at relatively high SIRs, so $\hat\gamma \gtrsim 5$ dB is practical in MIMO HetNets.
\begin{figure}
\begin{center}
\scalebox{0.7}{\includegraphics{Ps_Sim_Num_Asy.eps}}
\end{center}
\caption{The success probability with different SIR threshold, with $\alpha=4$, $\left[\lambda_1,\lambda_2,\lambda_3\right]=\left[1, 5, 10\right]\times10^{2}$ per ${\rm km}^2$, $\left[M_1,M_2, M_3\right]=\left[8, 4, 1\right]$, $\left[U_1,U_2, U_3\right]=\left[4, 2, 1\right]$, $\left[P_1,P_2, P_3\right]=\left[6.3, 0.13, 0.05\right]$W and $B_k=1/U_k$.}
\label{fig:Ps_Asy}
\end{figure}
From \eqref{eq:Ps_Asy}, we can see a clear relation between the success probability and each parameter. It is a perfectly symmetric structure, since both the numerator and denominator are summations of each tier's density $\left\{\lambda_k\right\}$\footnote{In this paper, we use $\left\{\lambda_k\right\}$ to denote the set $\left\{\lambda_k:k\in\mathcal{K}\right\}$, representing the BS densities of all the tiers, while $\lambda_k$ is used to denote the BS density of the $k$th tier.}, the transmit power to each user $\left\{\frac{P_k}{U_k}\right\}$, and the effects of link array gain $\left\{D_k\right\}$ and multiplexing gain $\left\{U_k\right\}$, respectively. Interestingly, this expression bears a similar form with the one in \cite{Dhillon12}, which considered SISO HetNets. Based on \eqref{eq:Ps_Asy}, we can easily investigate the effects of different parameters on the success probability in the general MIMO HetNets. Due to space limitations, in this paper, we will focus on how the BS densities $\left\{\lambda_k\right\}$ affect the success probability, and present two important properties. For convenience, we rewrite \eqref{eq:Ps_Asy} in the vector form by defining the column vectors $\boldsymbol{\lambda}=\left[\lambda_{1},\lambda_{2},\ldots,\lambda_{K}\right]^{T}$, $\mathbf{c}=\left[c_1,c_2,\ldots,c_K\right]^{T}$ where $c_i=\left(\frac{P_{i}}{U_{i}}\right)^{\delta} \frac{\Gamma\left(D_{i}+\delta\right)}{\Gamma\left(D_{i}\right)}$, and $\mathbf{d}=\left[d_1,d_2,\ldots,d_K\right]^{T}$ where $d_i=\left(\frac{P_{i}}{U_{i}}\right)^{\delta} \frac{\Gamma\left(U_{i}+\delta\right)}{\Gamma\left(U_{i}\right)}$. Then, \eqref{eq:Ps_Asy} is equivalent to
\begin{equation} \label{eq:Ps_Asy_Vector}
p_{{\rm s}}\sim\hat{\gamma}^{-\delta}{\rm sinc}\left(\delta\right) \frac{\mathbf{c}^{T}\boldsymbol{\lambda}}{\mathbf{d}^{T}\boldsymbol{\lambda}}.
\end{equation}
\subsubsection{Monotonicity of $p_{\rm s}$ with respect to $\lambda_k$}
Based on \eqref{eq:Ps_Asy_Vector}, we can obtain the following result.
\begin{lemma} \label{Lemma:Ps_Monotonic}
When the SIR threshold $\hat{\gamma}$ is large, if the ratio $\frac{c_{k}}{d_{k}}= \frac{\Gamma\left(D_{k}+\delta\right)/\Gamma\left(D_{k}\right)} {\Gamma\left(U_{k}+\delta\right)/\Gamma\left(U_{k}\right)}$ is the same for all the tiers, $p_{\rm s}$ is invariant with $\lambda_k$, $\forall k\in \mathcal{K}$; Otherwise, $p_{\rm s}$ is monotonic with respect to $\lambda_k$, i.e., $p_{\rm s}$ will either increase or decrease as $\lambda_k$ increases.
\end{lemma}
\begin{IEEEproof}
See Appendix~\ref{App:Ps_Monotonic}.
\end{IEEEproof}
This result explicitly shows that there is, in general, no invariance property for $p_{\rm s}$ in MIMO HetNets. Deploying more BSs of one tier will either increase or decrease the success probability. The invariance property that $p_{\rm s}$ is independent of the BS densities in SISO HetNets is only a special case, where $\frac{c_{i}}{d_{i}}=1$ for all the tiers. Therefore, we should carefully consider how the success probability will be affected when densifying the HetNet with multi-antenna BSs.
\subsubsection{The maximum $p_{\rm s}$ of the network}
In this part, we will determine the maximum $p_{\rm s}$ that can be achieved in a given MIMO HetNet. This is equivalent to considering the following optimization problem:
\begin{eqnarray} \label{eq:OptiPs_Asy}
\underset{\left\{ \lambda_{k}\right\} }{\text{maximize}} & p_{{\rm s}} \\
\text{subject to} & 0\leq\lambda_k \leq \lambda_k^{\max}, \forall k\in\mathcal{K}, \nonumber
\end{eqnarray}
where $\lambda_k$ can be regarded as the active BS density of the $k$th tier, and $\lambda_k^{\max}$ is the actual BS density. The solution of this optimization problem is provided in Lemma~\ref{Lemma:MaxPs_Asy}.
\begin{lemma} \label{Lemma:MaxPs_Asy}
The maximum $p_{\rm s}$ with respect to $\left\{\lambda_k\right\}$ in MIMO HetNets is given by
\begin{equation} \label{eq:Ps_Asy_Max}
p_{{\rm s}}^{\max}=p_{\rm s}\left(k\right)\quad\text{for }k=\arg\max_{j}\frac{\Gamma\left(D_{j}+\delta\right)/\Gamma\left(D_{j}\right)} {\Gamma\left(U_{j}+\delta\right)/\Gamma\left(U_{j}\right)},
\end{equation}
and the optimal BS density is
\begin{equation}
\lambda_{k}^{\star}\begin{cases}
\in\left(0,\lambda_{k}^{\max}\right] & k=\arg\max_{j} \frac{\Gamma\left(D_{j}+\delta\right)/\Gamma\left(D_{j}\right)} {\Gamma\left(U_{j}+\delta\right)/\Gamma\left(U_{j}\right)},\nonumber\\
=0 & k\neq\arg\max_{j} \frac{\Gamma\left(D_{j}+\delta\right)/\Gamma\left(D_{j}\right)} {\Gamma\left(U_{j}+\delta\right)/\Gamma\left(U_{j}\right)}. \nonumber
\end{cases}
\end{equation}
\end{lemma}
\begin{IEEEproof}
See Appendix~\ref{App:MaxPs}.
\end{IEEEproof}
From Lemma~\ref{Lemma:MaxPs_Asy}, we see that when the numbers of antennas and the numbers of served users are determined, i.e., when $\left\{D_k,U_k\right\}$ are determined, then no matter how to change the BS densities, the success probability of the network cannot exceed the value in \eqref{eq:Ps_Asy_Max}. Furthermore, the maximum $p_{\rm s}$ is achieved by only activating one tier of BSs, which has the largest value of $\frac{\Gamma\left(D_{i}+\delta\right)/\Gamma\left(D_{i}\right)} {\Gamma\left(U_{i}+\delta\right)/\Gamma\left(U_{i}\right)}$.
The two properties above have shown the effect of the BS densities on the success probability in a general MIMO HetNet. In the next section, we will provide a more comprehensive investigation and jointly analyze the effects of the BS densities on the success probability and ASE.
\section{ASE and Link Reliability Tradeoff} \label{Sec:Tradeoff}
In this section, we will investigate the effects of the BS densities on both the link reliability and ASE, and show there is a tradeoff between these two metrics. Moreover, efficient algorithms will be proposed to find the optimal BS densities. To start with, we will first consider a special case where all the BSs serve the same number of users. The purpose of investigating such a special case is to reveal the physical insight of the tradeoff. Then, we will show the tradeoff in general MIMO HetNets using the asymptotic results provided in the last section.
\subsection{ASE and Link Reliability Tradeoff in $U$-SDMA Networks}
In this subsection, we will consider the tradeoff between the ASE and link reliability in the $U$-SDMA network \cite{Li13}, where each BS serves $U$ ($U_k=U\leq M_k$ for all $k\in\mathcal{K}$) users. By limiting each BS to serve the same number of users, exact expressions of $p_{\rm s}$ and ASE are available. Such a network still possesses the key characteristics of the MIMO HetNet. For example, when $U=1$, the network becomes a TDMA HetNet. For simplicity, we assume $B_k=1$ for $\forall k\in\mathcal{K}$. Then $p_{\rm s}\left(k\right)$ can be directly obtained from Theorem \ref{Thm:Psk_General}, as given in the following corollary.
\begin{corollary} \label{col:USDMA}
The success probability of the typical user served by the $k$th tier in the unbiased $U$-SDMA HetNet is given by
\begin{equation}
p_{{\rm s}}\left(k\right) =\left\Vert \tilde{\mathbf{Q}}_{D_{k}}^{-1}\right\Vert _{1},
\end{equation}
where $\tilde{\mathbf{Q}}_{D_{k}}$ has the same structure as ${\mathbf{Q}}_{D_{k}}$ in \eqref{eq:Q}, with the elements $\tilde{q}_i$ given in \eqref{eq:qi_singletier}.
\end{corollary}
Therefore, the success probability of the typical user is given by
\begin{equation} \label{eq:Ps_USDMA}
p_{{\rm s}}= \sum_{k=1}^{K}A_{k}p_{{\rm s}}\left(k\right) = \frac{\sum_{k=1}^{K}\left(\frac{P_{k}}{U}\right)^{\delta}p_{{\rm s}}\left(k\right)\lambda_{k}}{\sum_{k=1}^{K}\left(\frac{P_{k}}{U}\right)^{\delta}\lambda_{k}},
\end{equation}
and its vector form is given by
\begin{equation}\label{eq:Ps_USDMA_Vector}
p_{{\rm s}}= \frac{\tilde{\mathbf{c}}^{T}\boldsymbol{\lambda}}{\tilde{\mathbf{d}}^{T}\boldsymbol{\lambda}},
\end{equation}
where the $k$th elements of $\tilde{\mathbf{c}}$ and $\tilde{\mathbf{d}}$ are $\tilde{c}_k=\left(\frac{P_{k}}{U}\right)^{\delta}p_{{\rm s}}\left(k\right)$ and $\tilde{d}_k=\left(\frac{P_{k}}{U}\right)^{\delta}$, respectively.
From Corollary~\ref{col:USDMA}, we have the following observations.
\begin{lemma} \label{Lemma:Psk_USDMA}
$p_{\rm s}\left(k\right)$ in unbiased $U$-SDMA HetNets has the following properties:
\begin{itemize}
\item $p_{{\rm s}}\left(k\right)$ is independent of the BS densities $\left\{\lambda_k\right\}$ and the transmit power $\left\{P_k\right\}$.
\item $p_{\rm s}\left(i\right)\geq p_{\rm s}\left(j\right)$ if and only if $M_i\geq M_j$, and the equality holds only if $M_i = M_j$.
\end{itemize}
\end{lemma}
This result means that the tier with more antennas at each BS provides higher link reliability, since the interference suffered by each user has the same distribution in unbiased $U$-SDMA HetNets, while more transmit antennas will provide a higher diversity and array gain. While $p_{{\rm s}}\left(k\right)$ is independent of both $\left\{\lambda_k\right\}$ and $\left\{P_k\right\}$, the overall success probability $p_{\rm s}$ in \eqref{eq:Ps_USDMA} depends on $\left\{\lambda_k,P_k\right\}$, and $p_{\rm s}$ can be regarded as a weighted sum of $p_{{\rm s}}\left(k\right)$ for $k\in\mathcal{K}$. From \eqref{eq:Ps_USDMA_Vector}, the network success probability has the following properties:
\begin{lemma} \label{Lemma:Ps_USDMA}
$p_{\rm s}$ in unbiased $U$-SDMA HetNets has the following properties:
\begin{itemize}
\item $p_{{\rm s}}$ is monotonic with respect to $\lambda_k$ for $\forall k\in\mathcal{K}$.
\item The maximum $p_{\rm s}$ is achieved by only activating one tier of BSs which has the largest number of antennas, i.e.,
\begin{equation} \label{eq:Ps_Max_USDMA}
p_{{\rm s}}^{\max}=p_{\rm s}\left(k\right)\quad\text{for }k=\arg\max_{j}M_{j}.
\end{equation}
\end{itemize}
\end{lemma}
\begin{IEEEproof}
Since \eqref{eq:Ps_USDMA_Vector} has the same structure with \eqref{eq:Ps_Asy_Vector}, Lemmas \ref{Lemma:Ps_Monotonic} and \ref{Lemma:MaxPs_Asy} can be applied. Moreover, we have $\frac{\tilde{c}_k}{\tilde{d}_k}=p_{\rm s}\left(k\right)$ in this case, and from Lemma~\ref{Lemma:Psk_USDMA}, we know the maximum $p_{\rm s}\left(k\right)$ is determined by $M_k$.
\end{IEEEproof}
By now, it is clear that the success probabilities in different tiers ($p_{\rm s}\left(k\right)$) are different, and $p_{\rm s}$ is an average of each tier's performance. Thus, the densification of different tiers will have different effects on $p_{\rm s}$. In particular, increasing the BS density of the tier with a lower $p_{\rm s}\left(k\right)$ will pull down the overall $p_{\rm s}$.
On the other hand, increasing the BS density will increase the ASE, which can be found in its expression:
\begin{equation} \label{eq:ASE_USDMA}
{\rm ASE}=U\log_2\left(1+\hat\gamma\right)\sum_{k=1}^K \lambda_k p_{\rm s} \left(k\right).
\end{equation}
Note that since $p_{\rm s}\left(k\right)$ is independent of the BS densities, \eqref{eq:ASE_USDMA} shows that activating as many BSs as possible can achieve a higher ASE. Combining the above results, we have the following two conflicting aspects:
\begin{itemize}
\item To achieve the maximum ASE, it is optimal to activate all the BSs, but in this case $p_{{\rm s}}$ may be low.
\item To achieve the maximum $p_{{\rm s}}$, activating only the tier with the largest number of antennas is optimal, but the ASE will be low.
\end{itemize}
Thus we need to investigate the tradeoff between ASE and link reliability. We are interested in maximizing the achievable ASE given a requirement on $p_{{\rm s}}$, formulated as the following problem.
\begin{eqnarray} \label{eq:Problem_ori}
\mathcal{P}_o : \underset{\left\{\lambda_k\right\}}{\text{maximize}} & {\rm ASE} \\
\text{subject to} & p_{\rm s} \geq \Theta, \nonumber\\
& 0\leq \lambda_k \leq \lambda_k^{\max}, \forall k\in\mathcal{K}, \nonumber
\end{eqnarray}
where ASE is given in \eqref{eq:ASE_USDMA} and $p_{\rm s}$ is given in \eqref{eq:Ps_USDMA}.
Note that in unbiased $U$-SDMA networks, Problem~$\mathcal{P}_o$ is a linear programming problem \cite{Boyd04}, which can be solved efficiently. To get more insights, we will derive a more explicit solution. From Lemma~\ref{Lemma:Ps_USDMA}, we know that if $\Theta>\max_k p_{\rm s}\left(k\right)$, there is no feasible solution, which implies that whatever the BS density is, the network cannot achieve such a link reliability requirement. Thus, in the following analysis, we assume $\Theta\leq\max_k p_{\rm s}\left(k\right)$.
Denote $y_k=p_{\rm s}\left(k\right)\lambda_k$, then Problem~$\mathcal{P}_0$ is equivalent to
\begin{eqnarray} \label{eq:Problem_eqv}
\mathcal{P}_{U-\rm{SDMA}} : \underset{\left\{y_k\right\}}{\text{maximize}} & \sum_{k=1}^K y_k \\
\text{subject to} & \sum_{k=1}^K b_k y_k \geq 0, \nonumber\\
& 0\leq y_k \leq y_k^{\max}, \forall k\in\mathcal{K}, \nonumber
\end{eqnarray}
where $b_k=\left(\frac{P_k}{U}\right)^\delta \left[1-\frac{\Theta}{p_{\rm s}\left(k\right)}\right]$.
Note that $b_k<0$ if $p_{\rm s}\left(k\right)<\Theta$. To find the solution, we start from $\left\{y_k^\star=y_k^{\max}\right\}$. If $\sum_{j=1}^K b_j y_j^\star \geq 0$, then the optimal solution is to activate all the BSs. On the contrary, if $\sum_{j=1}^K b_j y_j^\star < 0$, it means we need to decrease some $y_k^\star$ until $\sum_{j=1}^K b_j y_j^\star = 0$. Without loss of generality, assume some of $\left\{b_k\right\}$, i.e., $\left\{b_1,\ldots,b_n\right\}$ where $n\leq K$, are negative, and $b_1\leq b_2 \leq b_n <0$. Then, we need to firstly decrease $y_1^\star$, as $b_1$ has the most negative effect. If $y_1^\star=0$ and $\sum_{j=1}^K b_j y_j^\star < 0$, then $y_2^\star$ should be decreased. So on and so forth until $\sum_{j=1}^K b_j y_j^\star = 0$. The formal solution is described in Algorithm~\ref{alg:alg}.
\begin{algorithm}
\caption{Finding the optimal solution of Problem~$\mathcal{P}_0$ in unbiased $U$-SDMA HetNets}
\label{alg:alg}
\begin{algorithmic}[1]
\State Initialize $y_k^{\star} \gets y_k^{\max}$ for $k\in\mathcal{K}$ and $n \gets 1$;
\While{$\sum_{k=1}^K b_k y_k^{\star} <0$}
\State $i \gets$ the index of the $n$th minimal value among $\left\{b_k\right\}$;
\State $y_i^\star \gets 0$;
\If{$\sum_{k=1}^K b_k y_k^{\star} \geq 0$}
\State $y_i^\star \gets \frac{1}{-b_i} \sum_{k=1}^K b_k y_k^{\star}$;
\State $\textbf{break}$;
\EndIf
\State $n \gets n+1$;
\EndWhile
\end{algorithmic}
\end{algorithm}
From Algorithm~\ref{alg:alg}, we see that the value of $b_k$ is related to the transmit power $P_k$ and the number of antennas $M_k$. A negative $b_k$ will have a negative effect on $p_{\rm s}$. If the BSs in the $k$th tier have a smaller $M_k$ and a larger $P_k$, the value of $b_k$ will be negative and smaller. Therefore, to achieve a high link reliability requirement, the BSs of the tiers with a small $b_k$ should be switched off. Note that one special case is that all the BSs have the same number of antennas, i.e., $M_k=M$ for $\forall k\in\mathcal{K}$. In this special case, $p_{\rm s}\left(k\right)$ is the same for all $k\in\mathcal{K}$. Thus, all the values of $\left\{b_k\right\}$ are either greater than 0 or less than 0, and there is no tradeoff since $p_{\rm s}$ becomes a constant. SISO HetNets belong to this special case.
\subsection{A Demonstration of the Tradeoff in Unbiased $U$-SDMA Networks}
In this subsection, we will demonstrate how to achieve the maximum ASE given the link reliability requirement in a 3-tier HetNet, consisting of micro-BSs, pico-BSs and femto-BSs, where $\left[M_1,M_2,M_3\right]=\left[4,2,2\right]$, $\left[P_1,P_2,P_3\right]=\left[6.3, 0.13, 0.05\right]$ Watts \cite{Auer11}, and the actual BS densities are $\left[\lambda_1^{\max},\lambda_2^{\max},\lambda_3^{\max}\right]=[1,2,5]\times10^{2}$ per ${\rm km}^2$. We consider two cases with $U=1$ and $U=2$, respectively.
\begin{figure}
\begin{center}
\scalebox{0.7}{\includegraphics{Tradeoff_USDMA.eps}}
\end{center}
\caption{The maximum ASE with different requirements of the success probability, with $\alpha=4$, $\hat\gamma=0$ dB, $\left[M_1,M_2,M_3\right]=\left[4, 2, 2\right]$, and $\left[P_1,P_2,P_3\right]=\left[6.3, 0.13, 0.05\right]$ Watts. The actual BS densities are $\left[\lambda_1^{\max},\lambda_2^{\max},\lambda_3^{\max}\right]=\left[1, 2, 5\right]\times10^{2}$ per ${\rm km}^2$.}
\label{fig:Tradeoff_USDMA}
\end{figure}
In Fig.~\ref{fig:Tradeoff_USDMA}, we show the tradeoff between the maximum ASE and the link reliability requirement $\Theta$. As a benchmark, we also consider the SISO HetNet with the same transmit power $\left\{P_k\right\}$ and actual BS densities $\left\{\lambda_k^{\max}\right\}$. From Fig.~\ref{fig:Tradeoff_USDMA}, we can find that: 1) Compared with the SISO HetNet, deploying multi-antenna BSs can increase both the ASE and link reliability. For example, in the SISO HetNet, $p_{\rm s}$ is always 0.56 whatever the BS density is. But when using multi-antenna BSs, the network can achieve better ASE and $p_{\rm s}$. 2) Comparing the cases with $U=1$ and $U=2$, we see that serving one user at each time slot (i.e., TDMA) can obtain a higher maximum $p_{\rm s}$. This is because the channel gains of the interference links are small when $U$ is small. However, the maximum ASE is higher when $U=2$, compared with $U=1$, since there are more links in a unit area.
\begin{figure}
\begin{center}
\scalebox{0.7}{\includegraphics{OptimalBSDensity_USDMA.eps}}
\end{center}
\caption{The optimal BS densities with different requirements of the success probability, with $\alpha=4$, $\hat\gamma=0$ dB, $\left[M_1,M_2,M_3\right]=\left[4, 2, 2\right]$, $U=2$, and $\left[P_1,P_2,P_3\right]=\left[6.3, 0.13, 0.05\right]$ Watts. The actual BS densities are $\left[\lambda_1^{\max},\lambda_2^{\max},\lambda_3^{\max}\right]=\left[1, 2, 5\right]\times10^{2}$ per ${\rm km}^2$.}
\label{fig:OptimalBSDensity_USDMA}
\end{figure}
The corresponding optimal BS densities of the case with $U=2$ are provided in Fig.~\ref{fig:OptimalBSDensity_USDMA}. When $\Theta>0.58$, using $\left\{\lambda_k^{\max}\right\}$ cannot satisfy the link reliability constraint. From calculation, we find that the 2nd tier has the minimal value of $\left(\frac{P_k}{U}\right)^\delta \left[1-\frac{\Theta}{p_{\rm s}\left(k\right)}\right]$, which means we need to first decrease the BS density of the 2nd tier, as confirmed in Fig.~\ref{fig:OptimalBSDensity_USDMA}. Comparing the 3rd tier with the 2nd tier, we can find that $M_2=M_3$, but $P_2>P_3$, which means that BSs in the 2nd tier have more negative effects on the link reliability as they will cause higher interference. This is the reason why we need to decrease the BS density of the 2nd tier to improve the link reliability.
\subsection{ASE and Link Reliability Tradeoff in General MIMO HetNets}
Now, we will concentrate on the tradeoff in a general multiuser MIMO HetNet. Since the analysis becomes extremely difficult with the exact expression of $p_{\rm s}$ in \eqref{eq:Psk_Matrix}, we resort to the asymptotic expression in \eqref{eq:Psk_Asy}. By substituting \eqref{eq:Psk_Asy} into \eqref{eq:ASE_def}, the ASE is given by
\begin{equation} \label{eq:ASE_Vector}
{\rm ASE}\sim\hat{\gamma}^{-\delta}{\rm sinc}\left(\delta\right) \log_{2}\left(1+\hat{\gamma}\right) \frac{\left(\mathbf{c}_{1}^{T}\boldsymbol{\lambda}\right) \left(\mathbf{c}_{2}^{T}\boldsymbol{\lambda}\right)} {\mathbf{d}^{T}\boldsymbol{\lambda}},
\end{equation}
where $\mathbf{c}_{1}\!=\!\left[c_{11},c_{12},\ldots c_{1K}\right]^{T}$, and its element is given as $c_{1i}\!=\!P_{i}^{\delta}\!B_{i}^{\delta}$, while $\mathbf{c}_{2}\!=\!\left[c_{21},c_{22},\ldots c_{2K}\right]^{T}$, in which $c_{2i}=U_{i}^{1-\delta}B_{i}^{-\delta}\frac{\Gamma\left(D_{i}+\delta\right)}{\Gamma\left(D_{i}\right)}$, and $\mathbf{d}$ has the same expression as in \eqref{eq:Ps_Asy_Vector}.
From \eqref{eq:ASE_Vector}, we can find that the ASE is a quadratic-over-linear function with respect to $\boldsymbol{\lambda}$. It means, in general, we cannot guarantee that increasing the BS density will always increase the ASE, and the effect of the BS density on the ASE becomes complicated. In the following, we consider the same problem $\mathcal{P}_o$ as in \eqref{eq:Problem_ori}, to find the optimal BS densities that can achieve the maximum ASE. Based on \eqref{eq:Ps_Asy_Vector} and \eqref{eq:ASE_Vector}, the optimization problem is given as
\begin{eqnarray} \label{eq:Problem_Gen}
\mathcal{P}_{1} : \underset{\boldsymbol{\lambda}}{\text{maximize}} & \frac{\left(\mathbf{c}_{1}^{T}\boldsymbol{\lambda}\right) \left(\mathbf{c}_{2}^{T}\boldsymbol{\lambda}\right)} {\mathbf{d}^{T}\boldsymbol{\lambda}} \\
\text{subject to} & \hat{\gamma}^{-\delta}{\rm sinc}\left(\delta\right) \frac{\mathbf{c}^{T}\boldsymbol{\lambda}}{\mathbf{d}^{T}\boldsymbol{\lambda}} \geq \Theta, \nonumber\\
& 0\leq \lambda_k \leq \lambda_k^{\max}, k\in\mathcal{K}. \nonumber
\end{eqnarray}
Since the maximum $p_{\rm s}$ is obtained by activating only one tier which has the maximal value of $\frac{\Gamma\left(D_{i}+\delta\right)/\Gamma\left(D_{i}\right)} {\Gamma\left(U_{i}+\delta\right)/\Gamma\left(U_{i}\right)}$ (cf. Lemma~\ref{Lemma:MaxPs_Asy}), and $p_{\rm s}^{\max}\sim \hat{\gamma}^{-\delta}{\rm sinc}\left(\delta\right) \max_i \frac{\Gamma\left(D_{i}+\delta\right)/\Gamma\left(D_{i}\right)} {\Gamma\left(U_{i}+\delta\right)/\Gamma\left(U_{i}\right)}$, we only consider the case when $\Theta\leq p_{\rm s}^{\max}$.
Problem $\mathcal{P}_{1}$ is a non-convex problem since the ASE is not a concave function with respect to the BS density. Fortunately, Dinkelbach has proposed an algorithm to solve the nonlinear fractional problems \cite{Dinkelbach67}. By defining $N\left(\boldsymbol{\lambda}\right)= \left(\mathbf{c}_{1}^{T}\boldsymbol{\lambda}\right)\left(\mathbf{c}_{2}^{T}\boldsymbol{\lambda}\right)$ and \begin{equation} \label{eq:Problem_Gen_Func}
F\left(t\right)=\max_{\boldsymbol{\lambda}}\left\{ N\left(\boldsymbol{\lambda}\right)-t\mathbf{d}^{T}\boldsymbol{\lambda} \mid\boldsymbol{\lambda}\in\mathcal{S}\right\},
\end{equation}
where $\mathcal{S}=\left\{\boldsymbol{\lambda} \mid \hat{\gamma}^{-\delta}{\rm sinc}\left(\delta\right) \frac{\mathbf{c}^{T}\boldsymbol{\lambda}}{\mathbf{d}^{T}\boldsymbol{\lambda}} \geq \Theta, 0\leq \lambda_k \leq \lambda_k^{\max}, k\in\mathcal{K}\right\}$, the optimal BS density $\boldsymbol{\lambda}^{\star}$ can be obtained by finding $t^{\star}$ such that $F\left(t^{\star}\right)=0$ \cite{Dinkelbach67}. Specifically, by iterating $t^{\left(i\right)}=N\left(\boldsymbol{\lambda} ^\star\right)/\left(\mathbf{d}^{T}\boldsymbol{\lambda} ^\star\right)$, where $\boldsymbol{\lambda} ^\star$ is the optimal solution of the right hand side of \eqref{eq:Problem_Gen_Func}, $F\left(t^{\left(i\right)}\right)$ will converge to 0 and $\boldsymbol{\lambda}^\star$ will be the optimal BS density. However, the optimization problem in \eqref{eq:Problem_Gen_Func} is still a non-convex problem due to the non-convex function $N\left(\boldsymbol{\lambda}\right)$. To resolve this difficulty, we resort to the sequential convex programming (SCP) by approximating $N\left(\boldsymbol{\lambda}\right)$ with the first order Taylor expansion, given by $N\left(\boldsymbol{\lambda}\right)\approx N\left(\boldsymbol{\lambda}^{\left(n\right)}\right)+\nabla N\left(\boldsymbol{\lambda}^{\left(n\right)}\right)^{T}\left(\boldsymbol{\lambda}- \boldsymbol{\lambda}^{\left(n\right)}\right)$. It is a simple but effective method and has wide applications, e.g., see \cite{Facchinei14}. Therefore, given the $n$th iterative $\boldsymbol{\lambda}^{\left(n\right)}$ and the $i$th iterative $t^{\left(i\right)}$, the convex optimization problem is given by
\begin{eqnarray} \label{eq:Problem_Iteration}
\mathcal{P}_{2}\left(\boldsymbol{\lambda}^{\left(n\right)},t^{\left(i\right)}\right) : \underset{\boldsymbol{\lambda}}{\text{maximize}} & N\left(\boldsymbol{\lambda}^{\left(n\right)}\right)+\nabla N\left(\boldsymbol{\lambda}^{\left(n\right)}\right)^{T} \left(\boldsymbol{\lambda}-\boldsymbol{\lambda}^{\left(n\right)}\right) -t^{\left(i\right)}\mathbf{d}^{T}\boldsymbol{\lambda} \nonumber\\
\text{subject to} & \left(\hat{\gamma}^{-\delta}{\rm sinc}\left(\delta\right)\mathbf{c}^{T} -\Theta\mathbf{d}^{T}\right) \boldsymbol{\lambda}\geq0, \nonumber\\
& 0\leq \boldsymbol{\lambda} \leq \boldsymbol{\lambda}^{\max}. \nonumber
\end{eqnarray}
Then, the optimal BS density can be obtained by Algorithm~\ref{alg:alg2}. Note that since SCP can only obtain a local maximum, we will randomly generate multiple initial values of $\boldsymbol{\lambda}^{\left(0\right)}$ to find a better solution.
\begin{algorithm}
\caption{The Locally Optimal BS Densities in General MIMO HetNets}
\label{alg:alg2}
\begin{algorithmic}[1]
\State Initialize $\boldsymbol{\lambda}^{\left(0\right)} \gets$ random value between $\left[0,\boldsymbol{\lambda}^{\max}\right]$, $n \gets 0$, $i \gets 0$ and assign $\varepsilon$ a small value;
\State $t^{\left(i\right)} \gets \frac{\left(\mathbf{c}_{1}^{T}\boldsymbol{\lambda}^{\left(n\right)}\right) \left(\mathbf{c}_{2}^{T}\boldsymbol{\lambda}^{\left(n\right)}\right)} {\mathbf{d}^{T}\boldsymbol{\lambda}^{\left(n\right)}}$; \label{algstep:t}
\State Solve Problem $\mathcal{P}_{2}\left(\boldsymbol{\lambda}^{\left(n\right)},t^{\left(i\right)}\right)$ and obtain the optimal value $\boldsymbol{\lambda}^{\star}$; \label{algstep:solve}
\If{$\left\Vert \boldsymbol{\lambda}^{\star}-\boldsymbol{\lambda}^{\left(n\right)}\right\Vert /\left\Vert \boldsymbol{\lambda}^{\left(n\right)}\right\Vert \geq\varepsilon$}
\State $n\gets n+1$, $\boldsymbol{\lambda}^{\left(n\right)} \gets \boldsymbol{\lambda}^{\star}$, and go to Step~\ref{algstep:solve};
\Else
\If{$\left(\mathbf{c}_{1}^{T}\boldsymbol{\lambda}^{\star}\right) \left(\mathbf{c}_{2}^{T}\boldsymbol{\lambda}^{\star}\right) -t^{\left(i\right)}\mathbf{d}^{T}\boldsymbol{\lambda}^{\star}\geq\varepsilon$}
\State $i \gets i+1$, and go to Step~\ref{algstep:t};
\Else
\State \textbf{return} $\boldsymbol{\lambda}^{\star}$;
\EndIf
\EndIf
\end{algorithmic}
\end{algorithm}
\subsection{A Demonstration of the Tradeoff in General MIMO HetNets}
\begin{figure}
\begin{center}
\scalebox{0.7}{\includegraphics{Tradeoff_General.eps}}
\end{center}
\caption{The maximum ASE with different requirements of the success probability, with $\alpha=4$, $\hat\gamma=5$ dB, $\left[M_1,M_2,M_3\right]=\left[8, 4, 1\right]$, $\left[U_1,U_2,U_3\right]=\left[4, 1, 1\right]$, $B_k=1/U_k$ for $k=1,2,3$, and $\left[P_1,P_2,P_3\right]=\left[6.3, 0.13, 0.05\right]$ Watts. The actual BS densities are $\boldsymbol{\lambda}^{\max}=\left[1, 5, 10\right]\times10^{2}$ per ${\rm km}^2$.}
\label{fig:Tradeoff_General}
\end{figure}
\begin{figure}
\begin{center}
\scalebox{0.7}{\includegraphics{OptimalBSDensity_General.eps}}
\end{center}
\caption{The optimal BS densities with different requirements of the success probability, with $\alpha=4$, $\hat\gamma=5$ dB, $\left[M_1,M_2,M_3\right]=\left[8, 4, 1\right]$, $\left[U_1,U_2,U_3\right]=\left[4, 1, 1\right]$, $B_k=1/U_k$ for $k=1,2,3$, and $\left[P_1,P_2,P_3\right]=\left[6.3, 0.13, 0.05\right]$ Watts. The actual BS densities are $\boldsymbol{\lambda}^{\max}=\left[1, 5, 10\right]\times10^{2}$ per ${\rm km}^2$.}
\label{fig:OptimalBSDensity_General}
\end{figure}
In this subsection, we will use Algorithm~\ref{alg:alg2} to evaluate the tradeoff between the ASE and the link reliability. We consider a 3-tier HetNet, where $\left[M_1,M_2,M_3\right]=\left[8,4,1\right]$, $\left[U_1,U_2,U_3\right]=\left[4,1,1\right]$, $B_k=1/U_k$ for $k=1,2,3$, $\left[P_1,P_2,P_3\right]=\left[6.3, 0.13, 0.05\right]$ Watts, and the actual BS densities are $\boldsymbol{\lambda}^{\max}=\left[\lambda_1^{\max},\lambda_2^{\max},\lambda_3^{\max}\right] =[1,5,10]\times10^{2}$ per ${\rm km}^2$. For Algorithm~\ref{alg:alg2}, we generate 20 randomly initial values of $\boldsymbol{\lambda}^{\left(0\right)}$, and set $\varepsilon = 10^{-6}$. In Fig.~\ref{fig:Tradeoff_General}, we show the tradeoff between the maximum ASE and the link reliability requirement $\Theta$, while the corresponding optimal BS densities are shown in Fig.~\ref{fig:OptimalBSDensity_General}.
First, we find from both figures that the proposed algorithm can achieve almost the same performance as using the exhaustive search, while the proposed algorithm runs much faster. Second, from Fig.~\ref{fig:Tradeoff_General}, we find that in general cases, there exists a tradeoff between the ASE and link reliability, and the higher the link reliability requires, the lower the ASE can be achieved. More interestingly, from Fig.~\ref{fig:OptimalBSDensity_General}, we find that: 1) Even in general HetNets, the maximal ASE is achieved by activating all the BSs. 2) With the increasing requirement of the link reliability, the BS density will decrease from one tier to another tier. Moreover, only when the BS density decrease to 0, the BS density from another tier will start to decrease, which is the same as $U$-SDMA HetNets. Thus, we can infer that for a given $\Theta$, different tiers have different influences on the network, and there is an ordering of such influences. Recall that in $U$-SDMA networks, the ordering can be explicitly obtained from $\left\{b_k\right\}$, where $b_{k}=\left(\frac{P_{k}}{U}\right)^{\delta}\left[1-\frac{\Theta}{p_{\rm s}\left(k\right)}\right]$, and the tier with the minimal negative $b_k$ among $k\in\mathcal{K}$ has the most negative effect on the link reliability. However, in the general MIMO HetNets, so far we are unable to derive an exact expression to find such an ordering, since both signal and interference distributions are complicated. But with our algorithm, we can numerically find the effects of different tiers on the link reliability. For example, from Fig.~\ref{fig:OptimalBSDensity_General}, we can see that tier 1 (circle points) has the most negative effect on the link reliability. When $\Theta\gtrsim0.5$, the BSs from tier 1 need to be deactivated to guarantee the link reliability. It is because the interference caused by tier 1 is large due to the high multiplexing gain $U_1=4$.
\section{Conclusions} \label{Sec:Conclusions}
In this paper, we developed a new set of analytical results for performance analysis of downlink multiuser MIMO HetNets, where multi-antenna BSs use SDMA (ZF precoding) to serve multiple users. Both exact and asymptotic expressions of the success probability were provided. We focused on the effect of the BS densities, and proved that there is no invariance property for the success probability in general MIMO HetNets. A unique tradeoff between the link reliability and the ASE was revealed. By using the proposed algorithms, we found the optimal BS densities to achieve the maximum ASE while guaranteeing a given link reliability requirement. It was shown that the maximum ASE of the network is achieved by activating all the BSs, while the maximum link reliability is achieved by activating only one tier of BSs.
The link reliability vs. ASE tradeoff analyzed in this paper provides a new perspective in designing multiuser MIMO HetNets, which is fundamentally different from SISO HetNets. Both the link reliability and ASE should be considered when evaluating different transmission techniques for HetNets. A basic network model is considered in this paper, while more general models require further investigation, such as multi-slope path loss models \cite{Zhang15}, together with more sophisticated techniques such as interference coordination \cite{Li15} and load balancing \cite{Gupta14}.
|
{'timestamp': '2016-02-09T02:02:08', 'yymm': '1506', 'arxiv_id': '1506.05197', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05197'}
|
arxiv
|
\section{Introduction}
\label{sec:caps-intro}
Rankings provide an effective means to artificially assign order to the ever increasing volume of published research and researchers.
The study and development of such work is increasingly trending towards what could be termed as \emph{bibliometric analytics},
which we define here as\footnote{We note that~\cite{bhatt2009topics} and~\cite{rethlefsen2013environmental} used the term ``\emph{bibliometric analytics}'' but have not provided a formal definition.}
``key indicators derived from bibliometric data through mathematical or statistical analysis for the purpose of generating insight''.
In addition to information retrieval, bibliometric analytics focuses on discovering patterns specific to the data at hand in order to support decision-making or inference-related tasks.
This paper is yet another step in this direction.
Specifically, this paper builds on recent work established by~\cite{2015arXiv150104894P} to simultaneously score research authors and papers by relative importance.
The proposed algorithm, dubbed CITEX (CITation indEX), takes advantage of the many-to-many correspondence between a given set of authors and the papers they have collectively published.
For this purpose, mappings between both sets can be formalized as linkages on a bipartite graph, hereon referred to as the author-paper (or author-document) network.
In this sense, the cumulative advantage accrued by authors due to their papers and vice versa can be quantified using graph theoretic methods.
Furthermore, papers are interconnected through citation links;
that is, a typical paper refers to previous works in order to acknowledge \emph{relevance}\footnote{In general, citation linkages are made to indicate \emph{reaction} to past work rather than concrete \emph{dependence}.
Hence, the presence of citation linkages -- that is, a link pointing from citing (referring) paper to cited (referred) paper -- serves to describe intellectual flows in successive works, which in itself does not necessarily imply a flow of influence.
} in addition to specifying its own \emph{placement}\footnote{This is a notion of the paper's \emph{location} as opposed to its~\emph{position}.
As with a citation count, the presence of a citation link does not explicitly convey whether it takes on the position of supporting or opposing the referred work.
} within the existing literature.
The resulting paper citation network can thus be represented as a directed graph.
Since the distribution of citation links varies from one paper to the next -- usually in a highly skewed manner~\citep{simon1955class,de1965networks,price1976general,newman2009first} -- this can then be used as a basis to distinguish which papers are more prominently located than others.
Several schemes have been proposed to exploit precisely this feature;
i.e.~scores are computed for each paper based on some discriminatory function of its connectivity (or how it is embedded within a structure of links)~\citep{chen2007finding}.
These papers can then be ordered according to the computed scores to produce rankings.
Such schemes are integral to information retrieval tasks on online databases, for example, Google Scholar, CiteSeerX, and Microsoft Academic Search.
CITEX extends this tradition by combining information from the author-paper network with the paper citation network to determine which authors and which papers stands out more than others.
The development of such algorithms are important to explore alternative means of assembling bibliometric indicators (and their derived rankings) through purposeful integration of available information.
CITEX is interesting in its construction because it provides a coupled dual score system: a relative importance score for authors and another for papers,
hence, the relative standings of knowledge creators and the results of their labours can be determined within a single framework.
Simply put, CITEX asserts that: (1) good authors are either highly prolific with, or are highly cited by good authors; and,
(2) good papers share the same authors with, or are cited by good papers.
This paper is organized as follows.
We provide an in-depth discussion on the construction of the CITEX algorithm in Section~\ref{sec:citex-algo-construction} and a critique is offered in Section~\ref{sec:citex-algo-inspection}.
Our proposed modification, hereon referred to as the CAPS (Coupled Author-Paper Scoring) algorithm, is then described in detail in Section~\ref{sec:caps-method}.
To provide a point of comparison, both algorithms are tested on a real world dataset in Section~\ref{sec:caps-data}.
This consists of 200,000+ ISI-cited papers published from 1980-2012 listed under the Journal Citation Reports subject category of ``\emph{Information Science \& Library Science}''.
The paper is concluded in Section~\ref{sec:caps-conclusion}.
\section{The CITEX algorithm}
\label{sec:citex-algo-construction}
Suppose we are presented with a corpus consisting of $m$ authors and $n$ papers.
Furthermore, suppose that from this corpus, we are able to extract the binary $m \times n$ author-paper feature matrix, $M$, and binary $n \times n$ citation matrix, $C$.
Let an entry $M_{ij} = 1$ denote that author $i$ on the $i$-th row of $M$ has (co)authored paper $j$ on the $j$-th column of $M$ ($M_{ij} = 0$ otherwise).
This implies that row sums of $M$ correspond to total papers published by each author.
Column sums of $M$ correspond to total authors for each paper.
A column-normalized version of $M$ (with the same dimensions) can be constructed so that \emph{authorship share} of author $i$ to paper $j$ is divided equally as $W_{ij} = M_{ij}/{\sum_i M_{ij}}$.
In a similar way, let $C_{ij} = 1$ denote that cited paper $j$ on the $j$-th column of $C$ receives a citation from a citing paper $i$ on the $i$-th row of $C$ ($C_{ij} = 0$ otherwise).
Additionally, we require that $C$ contains no self-citations ($C_{ii} = 0$).
Given an extreme case where $C = \mathbb{0}_{n \times n}$, Pal and Ruj define the CITEX paper and author scores as $y_j = \sum_{i=1}^m M_{ij} x_i$ and $x_i = \sum_{j=1}^n W_{ij} y_j$, respectively.
These expressions are written in matrix form as $y \leftarrow M^T x$ and $x \leftarrow W y$.
This captures the notion that the $y$-score for paper $j$ depends on the relative importance of its authors, while the $x$-score for author $i$ depends on her authorship share ($W_{ij}$) for each paper $j$ multiplied by its corresponding score $y_j$.
A complete description however requires the inclusion of citation features.
Since this must reduce to the case of a zero citation matrix, Pal and Ruj achieve this by the inclusion of a $(I + C^T)$ term (which is equivalent to adding in paper self-citations to $C$).
Since $y \leftarrow M^T W y$ and $x \leftarrow W M^T x$, then for the $k$-th recursion:
\begin{align}
x^{(k)} &= W(I + C^{T})M^{T} x^{(k-1)} \label{eqn:citex-rule-1} \\
y^{(k)} &= (I + C^{T})M^{T}W y^{(k-1)} \label{eqn:citex-rule-2}
\end{align}
is one such possible choice.
By induction, we obtain:
\begin{align}
x^{(k)} &= [W(I + C^{T})M^{T}]^k x^{(0)} \\
y^{(k)} &= [(I + C^{T})M^{T}W]^k y^{(0)}
\end{align}
For initial guess vectors, Pal and Ruj use $x^{(0)} = \mathbb{1}_{m \times 1}$ and $y^{(0)} = \mathbb{1}_{n \times 1}$.
Supposing $P = W(I + C^T)M^T$, so that $x^{(k)} = P^k x^{(0)}$, then:
\begin{equation}
x^{(k + 1)} = P P^k x^{(0)} = P x^{(k)} \label{eqn:citex-authorscore-recursion}
\end{equation}
If the distance between two $x$ score vectors is $\| x^{(k+1)} - x^{(k)} \| < \epsilon$ then convergence is met relative to tolerance $\epsilon$~\citep{franceschet2011pagerank}.
Since $P$ is a nonnegative matrix with dimensions $n \times n$ and $x^{(0)} > 0$, then in accordance with the Perron-Frobenius theorem\footnote{In particular, given that $P x = c x$ and $c = 1$ is the largest eigenvalue, then $P^k x^{(0)}$ converge to a vector $x^{*}$ (in the same direction as $x$) as $k \rightarrow \infty$.}, the $x$ scores become stationary as $k \rightarrow \infty$, thus satisfying $P x^{*} = x^{*}$~\citep{perron1907theorie,frobenius1912matrizen}.
A similar argument is applicable for $y$ by setting $Q = (I + C^T) M^T W$.
There are other algorithms that combine author and paper features.
One notable example is the Co-Ranking framework proposed in~\cite{zhou2007co}.
This approach uses a PageRank-based model on a bipartite co-authorship/paper citation network, whereby two intra-class random walks allow traversal strictly between one class of nodes, while an inter-class random walk allows jumps between networks.
The stationary probabilities for author nodes and paper nodes are computed by coupling the random walks (assuming the status of researchers and the work they produce are mutually reinforced).
The resulting algorithm yields improvements compared to when applying PageRank on either feature (network) in isolation, although at the expense of introducing three additional adjustable parameters to the usual one-parameter PageRank\footnote{We are referring to the \emph{damping parameter} originally described in~\cite{brin1998anatomy}.
The interested reader is referred to~\cite{langville2006google} and~\cite{chen2007finding} for an in-depth discussion on the PageRank algorithm.
}.
CITEX adds an interesting twist to the current literature since, unlike PageRank, it does not depend on any adjustable parameters.
\section{Expected behaviour and blindspots}
\label{sec:citex-algo-inspection}
Since the performance of a data mining algorithm depends on its design~\citep{jahne2000computer,balakin2009pharmaceutical},
it is useful to determine precisely what features are emphasized by CITEX in order to anticipate the qualitative aspects of the ranking it will necessarily produce.
In particular, we are interested in the conditions that maximize a given score since the highest percentile is designed to correspond to the topmost ranks.
Specific to the CITEX author score, Equation~\ref{eqn:citex-rule-1} can be expanded as:
\begin{align}
x^{(k)} &= W M^T x^{(k-1)} + W C^T M^T x^{(k-1)} \label{eqn:citex-rule-1-expanded} \\
x^{(k)}_i &= \sum_{a=1}^m \sum_{p=1}^n W_{i p} M_{a p} x^{(k-1)}_a
+ \sum_{a=1}^m \sum_{p_1,p_2=1}^n W_{i p_1} C_{p_2 p_1} M_{a p_2} x^{(k-1)}_a \label{eqn:citex-rule-1-summation-form}
\end{align}
The first term on the right hand side of Equation~\ref{eqn:citex-rule-1-summation-form} captures the \emph{cumulative authorship share} of author $i$ with author $a$.
This term is positively biased towards author $i$ if she is prolific (adjusting for authorship share), and more so if she collaborates frequently with ``good authors'' (those with high $x$-scores).
This includes the case where $a=i$, so that if the cumulative authorship share of $i$ herself is significantly large, then $x_i^{(k)} \sim x_i^{(k-1)} \sum_{p=1}^n W_{ip}$.
As for the second term, a citation from paper $p_2 \rightarrow p_1$ corresponds to an author citation from $a \rightarrow i$ fractionalized by $W_{ip_1}$.
Hence, this term increases the larger the number of citations from $a \rightarrow i$, the larger the authorship share for each paper authored by $i$ (for which credit is minimally split), and the larger the $x$-score of $i$'s citing authors.
Put together, \emph{CITEX defines a good author as one who publishes frequently with good authors, and is even more so if he/she is cited by good authors}.
A similar analysis can be done for the CITEX paper score as given in Equation~\ref{eqn:citex-rule-2}:
\begin{align}
y^{(k)} &= M^T W y^{(k-1)} + C^T M^T W y^{(k-1)} \label{eqn:citex-rule-2-expanded} \\
y^{(k)}_j &= \sum_{a=1}^m \sum_{p=1}^n M_{a j} W_{a p} y^{(k-1)}_p
+ \sum_{a_1,a_2=1}^m \sum_{p=1}^n C_{p j} M_{a_1 j} W_{a_2 p} y^{(k-1)}_p \label{eqn:citex-rule-2-summation-form}
\end{align}
From the right hand side of Equation~\ref{eqn:citex-rule-2-summation-form}, we see again that CITEX defines relative importance in terms of two components; the first term captures publication features while the second term captures citation features.
For the first term, we see that paper $j$ receives fractional $y$-score contributions for each author $a$ appearing in both papers $j$ and $p$.
Essentially, $M_{aj} W_{ap}$ is an \emph{author similarity} term, hence, this part of the equation increases for papers that share the same authors.
This term will also increase the larger the $y$-score for each ``similar author'' paper $p$ (relative to $j$) and whenever $W_{ap} \rightarrow 1$.
For the case of an author $i$ with a significantly large number of papers, we could end up with $y^{(k)}_j \sim y^{(k-1)}_j \sum_{p=1}^n W_{ip}$.
For the second term, we see that $y_j$ depends on the sum of $y$-scores from each paper that cites it, $p$ (``good papers'' have high $y$-score).
With some rearranging, the second term also contains the product $W_{a_2 p} C_{pj} M_{a_1 j}$.
This means that the $y$-score of paper $j$ depends on the sum of fractionalized citations from all citing papers $p$ (i.e. $\sum_{p=1}^n W_{a_2 p}C_{pj}$).
Combining this with the effect from the first term of Equation~\ref{eqn:citex-rule-2-summation-form}, we surmise that \emph{CITEX defines a good paper as one with high author similarity with good papers, and is even more so if it is cited by good papers}.
Based on our analysis, we have determined two quirks with the original formulation of CITEX.
These are:
\begin{enumerate}
\item $x_i^{(k)} \sim x_i^{(k-1)} \sum_{p=1}^n W_{ip}$:
the CITEX author score for an author $i$ can increase from being highly prolific, and more so if he/she tends to coauthor in small teams.
This allows for the case of an extremely prolific solo author to be over-represented by the algorithm.
He or she may not even need a boost from citation count (from good authors or otherwise) in order to obtain a high CITEX author score.
\item $y_j^{(k)} \sim y_j^{(k-1)} \sum_{p=1}^n W_{ip}$:
the CITEX paper score can increase just by having the same author list repeat over a significant fraction of the collection, with this effect becoming more pronounced if the listing tends to be short.
Similarly, such cases can be over-represented by CITEX without a boost from citation count (from good papers or otherwise).
\end{enumerate}
To illustrate the potential problems associated with these quirks, we construct two toy calculations analogous to those posed in~\cite{2015arXiv150104894P}.
These are as shown in Figure~\ref{fig:caps-toy-model-1} and Figure~\ref{fig:caps-toy-model-2}.
\begin{figure}[hbt!]
\begin{align*}
M &=
\begingroup\setlength{\arraycolsep}{3pt}
\begin{bmatrix}
1 & 1 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 1 & 1 & 0 \\
0 & 0 & 0 & 0 & 0 & 1 \\
\end{bmatrix}
\endgroup
&
\begin{tikzpicture}[baseline=-20pt]
\tikzset{VertexStyle/.style={shape=circle,red,minimum size=0.1pt,fill}}
\Vertex[x=0,y=0.0,LabelOut=true,Lpos=180]{$a_1$}
\Vertex[x=0,y=-0.6,LabelOut=true,Lpos=180]{$a_2$}
\Vertex[x=0,y=-1.2,LabelOut=true,Lpos=180]{$a_3$}
\tikzset{VertexStyle/.style={shape=rectangle,blue,minimum size=0.5pt,fill}}
\Vertex[x=3,y=0.4,LabelOut=true,Lpos=0,Ldist=10pt]{$p_1$}
\Vertex[x=3,y=0.0,LabelOut=true,Lpos=0,Ldist=10pt]{$p_2$}
\Vertex[x=3,y=-0.4,LabelOut=true,Lpos=0,Ldist=10pt]{$p_3$}
\Vertex[x=3,y=-0.8,LabelOut=true,Lpos=0,Ldist=10pt]{$p_4$}
\Vertex[x=3,y=-1.2,LabelOut=true,Lpos=0,Ldist=10pt]{$p_5$}
\Vertex[x=3,y=-1.6,LabelOut=true,Lpos=0,Ldist=10pt]{$p_6$}
\Edges[lw=0.5pt]($a_1$,$p_1$)
\Edges[lw=0.5pt]($a_1$,$p_2$)
\Edges[lw=0.5pt]($a_1$,$p_3$)
\Edges[lw=0.5pt]($a_2$,$p_4$)
\Edges[lw=0.5pt]($a_2$,$p_5$)
\Edges[lw=0.5pt]($a_3$,$p_6$)
\tikzset{EdgeStyle/.style={->,bend left}}
\Edges($p_4$,$p_5$)
\Edges($p_4$,$p_6$)
\Edges($p_5$,$p_6$)
\end{tikzpicture}
&
C =
\begingroup\setlength{\arraycolsep}{3pt}
\begin{bmatrix}
0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 1 & 1 \\
0 & 0 & 0 & 0 & 0 & 1 \\
0 & 0 & 0 & 0 & 0 & 0
\end{bmatrix}
\endgroup
\end{align*}
\caption{Problem 1 --- Hypothetical case of one prolific solo author with no citations.
CITEX gives $x = [0.333, 0.333, 0.333]$ and $y = [0.143, 0.143, 0.143, 0.095, 0.191, 0.285]$.
Hence, all three authors are ranked equally even though there are stark qualitative differences between their publication and citation patterns.
Understandably, paper $p_6$ has the highest score followed by $p_5$ due to the number of citations they receive compared to no citations for the other papers.
Oddly, $p_4$ is ranked lower than papers $p_1$, $p_2$ and $p_3$ despite being authored by author $a_2$ who has one citation more than $a_1$ (via $p_5$).
}
\label{fig:caps-toy-model-1}
\end{figure}
\begin{figure}[hbt!]
\begin{align*}
M &=
\begingroup\setlength{\arraycolsep}{3pt}
\begin{bmatrix}
1 & 1 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 1 & 1 & 0 \\
0 & 0 & 0 & 0 & 0 & 1 \\
\end{bmatrix}
\endgroup
&
\begin{tikzpicture}[baseline=-20pt]
\tikzset{VertexStyle/.style={shape=circle,red,minimum size=0.1pt,fill}}
\Vertex[x=0,y=0.0,LabelOut=true,Lpos=180]{$a_1$}
\Vertex[x=0,y=-0.6,LabelOut=true,Lpos=180]{$a_2$}
\Vertex[x=0,y=-1.2,LabelOut=true,Lpos=180]{$a_3$}
\tikzset{VertexStyle/.style={shape=rectangle,blue,minimum size=0.5pt,fill}}
\Vertex[x=3,y=0.4,LabelOut=true,Lpos=0,Ldist=10pt]{$p_1$}
\Vertex[x=3,y=0.0,LabelOut=true,Lpos=0,Ldist=10pt]{$p_2$}
\Vertex[x=3,y=-0.4,LabelOut=true,Lpos=0,Ldist=10pt]{$p_3$}
\Vertex[x=3,y=-0.8,LabelOut=true,Lpos=0,Ldist=10pt]{$p_4$}
\Vertex[x=3,y=-1.2,LabelOut=true,Lpos=0,Ldist=10pt]{$p_5$}
\Vertex[x=3,y=-1.6,LabelOut=true,Lpos=0,Ldist=10pt]{$p_6$}
\Edges[lw=0.5pt]($a_1$,$p_1$)
\Edges[lw=0.5pt]($a_1$,$p_2$)
\Edges[lw=0.5pt]($a_1$,$p_3$)
\Edges[lw=0.5pt]($a_2$,$p_4$)
\Edges[lw=0.5pt]($a_2$,$p_5$)
\Edges[lw=0.5pt]($a_3$,$p_6$)
\tikzset{EdgeStyle/.style={->,bend left}}
\Edges($p_4$,$p_5$)
\Edges($p_4$,$p_6$)
\Edges($p_5$,$p_6$)
\tikzset{EdgeStyle/.style={->,bend right}}
\Edges($p_6$,$p_1$)
\end{tikzpicture}
&
C =
\begingroup\setlength{\arraycolsep}{3pt}
\begin{bmatrix}
0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 1 & 1 \\
0 & 0 & 0 & 0 & 0 & 1 \\
1 & 0 & 0 & 0 & 0 & 0
\end{bmatrix}
\endgroup
\end{align*}
\caption{Problem 2 --- The effect of high author similarity with good papers.
The setup in this diagram is similar to Figure~\ref{fig:caps-toy-model-1} with one additional citation link added from paper $p_6$ to $p_1$.
CITEX gives $x = [0.521, 0.214, 0.214]$ and $y = [0.243, 0.175, 0.175, 0.068, 0.136, 0.203]$.
Author $a_1$ leads by author score followed by a tie between $a_2$ and $a_3$, despite the absence of (co)author self-citations to $a_1$ (note that $a_2$ has one author self-citation via $p_4 \rightarrow p_5$).
Paper $p_1$ is ranked highest despite having only one citation because it is cited by a good paper ($p_6$).
Due to the way paper scores are propagated in CITEX, papers $p_2$ and $p_3$ also receive high scores just by having high author similarity with paper $p_1$.
}
\label{fig:caps-toy-model-2}
\end{figure}
As a result of the quirks highlighted in Figure~\ref{fig:caps-toy-model-1} and Figure~\ref{fig:caps-toy-model-2}, we can expect that author and paper rankings generated by CITEX will suffer from specificity issues since extreme publication and citation traits are mixed together.
The task of this paper is to propose a more elegant variation of the CITEX algorithm that addresses the above mentioned issues.
\section{An improved Coupled Author-Paper Scoring algorithm}
\label{sec:caps-method}
As highlighted in Section~\ref{sec:citex-algo-inspection}, CITEX has a built-in tendency to produce a rank ordering that gives undesired priority to highly productive authors (even if they are relatively uninfluential), in addition to assigning high relative importance to papers associated to highly prolific authors (overriding the citation impact of other papers).
To circumvent these issues, we propose dropping the self-citation term $(I + C^T)$ in Equations~\ref{eqn:citex-rule-1} and~\ref{eqn:citex-rule-2}, and replace the $M$ matrices with $W$ matrices to ensure conservation of citation count when switching from the paper citation network to the author citation network (inter-author citations are fractionalized).
This results in the following set of equations which defines our \textbf{Coupled Author-Paper Scoring} (\textbf{CAPS}) algorithm:
\begin{align}
x^{(k)} &= W C^{T} W^{T} x^{(k-1)} \label{eqn:rule-1} \\
y^{(k)} &= C^{T} W^{T} x^{(k)} \label{eqn:rule-2}
\end{align}
Following previous conventions~\citep{kleinberg1999authoritative,2015arXiv150104894P}, we start with an initial guess vector (specifically, $x^{(0)} = \mathbb{1}_{m \times 1}$ and $y^{(0)} = \mathbb{1}_{n \times 1}$) and determine the values of scores iteratively (i.e.~iterate $k \geq 1$ until convergence is achieved for a given tolerance level).
Equation~\ref{eqn:rule-1} quantifies the criterion that ``\emph{a good author is cited by good authors}''.
Equation~\ref{eqn:rule-2} quantifies the criterion that ``\emph{a good paper is cited by good authors}''.
The equations above provide a self-consistent basis for repeated improvement~\citep[pp. 355--356]{easley2010networks}.
This can be seen by writing $L = W C$:
\begin{align}
x^{(k)} &= W L^{T} x^{(k-1)} = W y^{(k-1)}\label{eqn:rule-1-simplified} \\
y^{(k)} &= L^{T} x^{(k)} \label{eqn:rule-2-simplified}
\end{align}
Hence, \emph{a good author has good papers that are cited by good authors who have good papers} and so on.
The $m \times n$ matrix $L$ has entries $(L)_{ij} = \sum_{p=1}^n W_{ip} C_{pj}$ which correspond to the cumulative fractional citations made by citing author $i$ through papers $p$ (if authored by $i$) to some cited paper $j$.
Essentially, $L$ encodes the \emph{author-paper citation matrix}.
Entries of the $m \times m$ matrix product $WL^T$ in Equation~\ref{eqn:rule-1-simplified} corresponds to the cumulative fractional citations received by authors in row $i$ from authors in column $a$.
This is because $(W L^T)_{ia} = \sum_{p_1,p_2=1}^n W_{ap_2} C_{p_2 p_1} W_{i p_1}$ signifies that author $a$ in paper $p_2$ cites paper $p_1$ which is (co)authored by $i$.
The sum over all possible papers $p_1$ serves to aggregate all fractional citations received by author $i$ from author $j$.
$WL^T$ is thus the (fractional) \emph{author citation matrix}.
In effect, we find that the author score defined in Equation~\ref{eqn:rule-1-simplified} therefore corresponds to $x_i^{(k)} = \sum_{a=1}^m \sum_{p_1,p_2=1}^n W_{ap_2} C_{p_2 p_1} \allowbreak W_{ip_1} x^{(k-1)}_a$.
Therefore, the author score for author $i$ is proportional to the cumulative author citations received as well as the score of the citing authors.
This captures the intuition that \emph{authors promote each other through their published works}.
Similarly, Equation~\ref{eqn:rule-2-simplified} implies that the paper score for paper $j$ is $y^{(k)}_j = \sum_{i=1}^m L_{ij} x^{(k)}_i$.
This quantifies the relationship that \emph{the relative importance of a paper depends on the authority its citing authors}.
\section{Empirical test}
\label{sec:caps-data}
We test the CITEX and CAPS algorithm on papers published under the Thomson ISI \emph{Journal Citation Reports} (JCR) subject category of ``\emph{Information Science \& Library Science}'' (LIS) from the years 1980 up to 2012 inclusive.
This dataset consists of 213,530 papers, 471,191 total inter-paper citations, and 73,597 author keywords.
We do not conduct author or bibliographic reference disambiguation in order to assess the output quality of CAPS and CITEX when used with minimal data preprocessing.
\subsection{Authors}
\label{sec:analysis-authors}
The output of a ranking scheme depends on how it scores selected features that are present (or absent) for each datum relative to the rest of the dataset.
In general, it is difficult to determine the performance of the underlying scoring algorithm when there is no ground truth to base such judgements.
In cases like this, the most sensible thing to do is to speak of the properties of the scores generated by the algorithm of interest, and whether the rankings generated show reasonable agreement with known methods and observations.
In this respect, the distribution of author scores for CAPS and CITEX exhibit a reasonably high Spearman rank correlation coefficient ($\rho$) with $h$-index score ($p < 0.01)$: specifically, 0.77 and 0.69 for CAPS and CITEX, respectively.
The $h$-index~\citep{hirsch2005index} provides a useful comparison to CAPS and CITEX as it too combines publication and citation traits together.
However, unlike CAPS (and to a lesser extent, CITEX), the $h$-index is not designed to differentiate whether a citation is received from a relatively ``good'' paper (author) or otherwise, hence some disparity in the resulting ranking is to be expected.
This can be seen in Table~\ref{tbl:caps-top25-authors}.
\begin{table}[hbt!]
\caption{Top 25 (out of 73,597) authors by publication count, citation count, CAPS author score, CITEX author score, and $h$-index, respectively.
Note that $h$-index values in columns denoted by $h$ are computed using available data (only ISI papers indexed under LIS JCR category from 1980-2012).
Note the usage of ordinal ranking for the $h$-index column.
}
\label{tbl:caps-top25-authors}
{\scriptsize
\begin{flushleft}
\begin{tabular}{|l|ll|ll|ll|ll|ll|}
\hline
& \multicolumn{2}{c|}{Pubs.} & \multicolumn{2}{c|}{Times Cited} & \multicolumn{2}{c|}{CAPS} & \multicolumn{2}{c|}{CITEX} & \multicolumn{2}{c|}{$h$-index} \tabularnewline
Rank & $h$ & Author key & $h$ & Author key & $h$ & Author key & $h$ & Author key & $h$ & Author key\tabularnewline
\hline
1 & 5 & rogers.m & 5 & davis.fd & 21 & egghe.l & 5 & rogers.m & 30 & glanzel.w\tabularnewline
2 & 0 & cassada.j & 29 & benbasat.i & 26 & leydesdorff.l & 0 & cassada.j & 29 & bates.dw\tabularnewline
3 & 0 & klett.re & 12 & venkatesh.v & 23 & rousseau.r & 0 & klett.re & 29 & benbasat.i\tabularnewline
4 & 1 & ramsdell.k & 29 & bates.dw & 30 & glanzel.w & 1 & ramsdell.k & 28 & garfield.e\tabularnewline
5 & 1 & christian.g & 1 & pawlak.z & 24 & thelwall.m & 1 & christian.g & 26 & leydesdorff.l\tabularnewline
6 & 0 & vicarel.ja & 19 & straub.dw & 16 & burrell.ql & 0 & vicarel.ja & 25 & schubert.a\tabularnewline
7 & 2 & hoffert.b & 30 & glanzel.w & 25 & schubert.a & 2 & hoffert.b & 25 & spink.a\tabularnewline
8 & 1 & sutton.j & 1 & gruber.tr & 17 & ingwersen.p & 1 & sutton.j & 24 & grover.v\tabularnewline
9 & 1 & sutton.jc & 25 & spink.a & 17 & bar-ilan.j & 24 & thelwall.m & 24 & moed.hf\tabularnewline
10 & 1 & bigelow.d & 14 & salton.g & 22 & braun.t & 21 & egghe.l & 24 & thelwall.m\tabularnewline
11 & 1 & stevens.n & 3 & furnas.gw & 18 & cronin.b & 30 & glanzel.w & 23 & rousseau.r\tabularnewline
12 & 0 & zlendich.j & 24 & grover.v & 17 & van.raan.afj & 26 & leydesdorff.l & 22 & braun.t\tabularnewline
13 & 0 & fairchild.ca & 3 & deerwester.s & 16 & white.hd & 1 & sutton.jc & 21 & egghe.l\tabularnewline
14 & 1 & pearl.n & 3 & dumais.st & 12 & jacso.p & 2 & decandido.ga & 20 & willett.p\tabularnewline
15 & 0 & richard.o & 2 & landauer.tk & 24 & moed.hf & 23 & rousseau.r & 19 & ford.n\tabularnewline
16 & 2 & gordon.rs & 8 & buckley.c & 15 & vinkler.p & 3 & stlifer.e & 19 & saracevic.t\tabularnewline
17 & 0 & maccann.d & 25 & schubert.a & 16 & small.h & 1 & bigelow.d & 19 & smaglik.p\tabularnewline
18 & 0 & lombardo.d & 5 & morris.mg & 18 & mccain.kw & 25 & schubert.a & 19 & straub.dw\tabularnewline
19 & 1 & williamson.ga & 1 & harshman.r & 16 & bornmann.l & 2 & rawlinson.n & 18 & bates.mj\tabularnewline
20 & 5 & butler.t & 7 & todd.pa & 28 & garfield.e & 0 & davidson.a & 18 & chen.hc\tabularnewline
21 & 1 & raiteri.s & 9 & karahanna.e & 9 & pao.ml & 0 & de.baron.fhk & 18 & cronin.b\tabularnewline
22 & 1 & gillespie.t & 26 & leydesdorff.l & 15 & vaughan.l & 0 & elizabeth.p & 18 & dennis.ar\tabularnewline
23 & 1 & campbell.p & 18 & zmud.rw & 6 & rao.ikr & 1 & furlong.cw & 18 & lyytinen.k\tabularnewline
24 & 3 & burns.a & 14 & gefen.d & 15 & daniel.hd & 0 & hammett.d & 18 & mccain.kw\tabularnewline
25 & 2 & wyatt.n & 19 & saracevic.t & 15 & oppenheim.c & 0 & hemingway.h & 18 & zmud.rw\tabularnewline
\hline
\end{tabular}
\par\end{flushleft}
}
\end{table}
Since CAPS and CITEX are also positively correlated with $\rho = 0.85$ ($p < 0.01$), we can expect that the $h$-index distribution for top $N$ ranks by CAPS and CITEX score to resemble each other for increasingly large $N$.
For the top $N=25$ ranks, $\mu_{\mathrm{CAPS}}(h) = 18.44$ while $\mu_{\mathrm{CITEX}}(h)=6.76$.
For $N=250$ the mean $h$-index values are 8.03 and 7.03,
while for $N=2500$ we obtain 3.32 and 3.36 for CAPS and CITEX, respectively.
Ideally, the top percentile of any ranking should correspond to an easily interpreted ordering by quality, hence in this sense, CAPS improves on the CITEX author ranking (since the top ranks tend to correspond to high $h$-index values).
Incidentally, the top ranked author by CITEX (Rogers, with a score of $3.37 \times 10^{-5}$) corresponds to 83.6\% of the entire CITEX author score distribution.
Together with Cassada ($\mathrm{author~score}=2.39 \times 10^{-14}$), both authors take up a shocking 96\% of total scores.
Over the entire list of authors, this corresponds to a Gini coefficient\footnote{The Gini coefficient is a measure of statistical dispersion typically used to measure the level of inequality in a given sample.
For a sample of size $n$ ordered such that $x_i \leq x_{i+1}$, it is given by $G = \frac{2 \sum_{i=1}^n i x_i}{n \sum_{i=1}^n x_i} - \frac{n+1}{n}$.
A Gini coefficient of 1 indicates maximal inequality whereby the total score is associated to only one element in the sample while the remainder of the sample contributes nothing to the total score.
A Gini coefficient of 0 indicates perfect equality whereby the total score is distributed equally among all elements in the sample.
}
of 0.9999.
In contrast, 20\% (14,719) of top scoring authors according to the CAPS algorithm accounts for approximately 99.96\% of the scores (corresponds to a Gini coefficient of 0.9891).
This implies that the difference between CAPS author scores for adjacent ranks becomes progressively smaller as we go down the ranks.
This is exaggerated to a greater extreme in CITEX.
Interestingly, the Gini coefficients for fractional publication count and fractional citation count of authors in the LIS dataset are 0.7744 and 0.8715, respectively.
Furthermore, 20\% of top authors account for 81.4\% of the total fractional publications as well as 90\% of the total fractional citations.
While these values are characteristic of high levels of inequailty, they are quite tame compared to the level of inequality implied by CAPS.
The presence of such extreme levels of inequality suggests a vast differential in the ability of LIS researchers to capitalize the resources, technical skills, and opportunities at their disposal~\citep{shockley1957statistics}.
\subsection{Papers}
\label{sec:analysis-papers}
The top 25 ranking by citation count, CAPS paper score, and CITEX paper score is as displayed in Table~\ref{tbl:caps-top25-papers}.
The topmost ranks of CITEX are populated by papers sharing the same high-scoring author (Rogers).
Looking beyond the top 25 ranks, we find that with the exception of papers at ranks 7 to 12, the first 3819 positions are papers authored by Rogers, while the next 2610 positions (ranks $3820 - 6429$) are papers authored by Cassada.
Hence, CITEX tends to over-represent the importance of papers from the same highly scored author even if these do not correspond to ``high impact'' works or works that impact ``high impact works''.
This is precisely the effect we described in Section~\ref{sec:citex-algo-inspection}.
As we have seen in the case of authors, the paper citation data shows high inequality since the top 10\% of cited papers accounts for nearly 88.8\% of total citations.
This is expected since only a fraction of papers are cited and each of these papers receives additional citation in-links at a rate proportional to their current number of citation in-links.
This suggests that the citation distribution is governed by a cumulative advantage/preferential attachment process whereby the \emph{rich get richer}~\citep{price1976general,barabasi1999mean}.
\begin{table}[hbt!]
\caption{Top 25 (out of 213,530) papers by citation count, CAPS paper score, and CITEX paper score.
Papers are identified by publication year, followed by source journal abbreviation, volume, page number, and first author.
Source journal abbreviations are listed in Table~\ref{tbl:caps-journal-composition}.
TC designates the times cited for papers as reported by ISI in 2012.
The Spearman rank correlation coefficients ($p < 0.01$) over all papers are: $\rho(C_1,C_2) = 0.87$, $\rho(C_1,C_3) = 0.17$, and $\rho(C_2,C_3)=0.26$.
CAPS appears in better agreement with citation count than CITEX.
}
\label{tbl:caps-top25-papers}
{\scriptsize
\begin{flushleft}
\begin{tabular}{|l|ll|ll|ll|}
\hline
& \multicolumn{2}{c|}{Citation count ($C_1$)} & \multicolumn{2}{c|}{CAPS ($C_2$)} & \multicolumn{2}{c|}{CITEX ($C_3$)}\tabularnewline
Rank & Paper & TC & Paper & TC & Paper & TC\tabularnewline
\hline
1 & 1982/IJCIS/11/341/pawlak & 3319 & 2006/SCI/69/121/egghe & 105 & 1995/LJ/120/113/rogers & 1\tabularnewline
2 & 1989/MISQ/13/319/davis & 3251 & 1990/JIS/16/17/egghe & 61 & 1995/LJ/120/119/rogers & 1\tabularnewline
3 & 1993/KA/5/199/gruber & 2618 & 2006/SCI/69/131/egghe & 250 & 1995/LJ/120/130/rogers & 1\tabularnewline
4 & 1990/JASIS/41/391/deerwester & 2150 & 1998/JD/54/236/ingwersen & 199 & 1995/LJ/120/187/rogers & 1\tabularnewline
5 & 1980/PAL/14/130/porter & 1653 & 2005/S/19/8/braun & 86 & 1995/LJ/120/213/rogers & 1\tabularnewline
6 & 2003/MISQ/27/425/venkatesh & 1534 & 2003/JASIST/54/550/ahlgren & 123 & 1996/LJ/121/100/rogers & 1\tabularnewline
7 & 1988/IPM/24/513/salton & 1449 & 2006/SCI/69/169/braun & 127 & 2011/LJ/136/30/fox & 0\tabularnewline
8 & 2001/MISQ/25/107/alavi & 1075 & 2006/SCI/67/491/van.raan & 177 & 2007/LJ/132/36/albanese & 4\tabularnewline
9 & 1995/ISR/6/144/taylor & 1021 & 1999/JD/55/577/smith & 93 & 1993/LJ/118/32/berry & 2\tabularnewline
10 & 2003/JMIS/19/9/delone & 772 & 2001/JASIST/52/1157/thelwall & 94 & 1989/LJ/114/18/decandido & 1\tabularnewline
11 & 2004/MISQ/28/75/hevner & 724 & 1985/JD/41/173/egghe & 48 & 1989/LJ/114/57/decandido & 0\tabularnewline
12 & 1995/MISQ/19/189/compeau & 684 & 1992/IPM/28/201/egghe & 41 & 1995/LJ/120/12/stlifer & 1\tabularnewline
13 & 2003/MISQ/27/51/gefen & 677 & 1989/SCI/16/3/schubert & 165 & 1992/LJ/117/52/rogers & 0\tabularnewline
14 & 2000/ISR/11/342/venkatesh & 596 & 1997/JD/53/404/almind & 163 & 2000/LJ/125/91/rogers & 0\tabularnewline
15 & 1999/MISQ/23/67/klein & 569 & 2001/SCI/50/65/bjorneborn & 93 & 2005/LJ/130/172/rogers & 0\tabularnewline
16 & 2000/MISQ/24/169/bharadwaj & 568 & 1986/SCI/9/281/schubert & 162 & 2006/LJ/131/114/rogers & 0\tabularnewline
17 & 1992/MISQ/16/227/adams & 542 & 2006/SCI/67/315/glanzel & 88 & 2006/LJ/131/114/rogers & 0\tabularnewline
18 & 1995/MISQ/19/213/goodhue & 540 & 2006/SCI/69/161/banks & 60 & 2006/LJ/131/123/rogers & 0\tabularnewline
19 & 1987/MISQ/11/369/benbasat & 526 & 1996/SCI/36/97/egghe & 31 & 2006/LJ/131/123/rogers & 0\tabularnewline
20 & 1999/MISQ/23/183/karahanna & 513 & 1991/JASIS/42/479/egghe & 29 & 2007/LJ/132/132/rogers & 1\tabularnewline
21 & 1999/JAMIA/6/313/bates & 497 & 2003/SCI/56/357/glanzel & 82 & 2007/LJ/132/132/rogers & 1\tabularnewline
22 & 1988/MISQ/12/259/doll & 477 & 1986/SCI/9/103/leydesdorff & 46 & 2007/LJ/132/171/rogers & 0\tabularnewline
23 & 1999/IJGIS/13/143/stockwell & 475 & 2001/SCI/50/7/bar-ilan & 64 & 2007/LJ/132/96/rogers & 0\tabularnewline
24 & 2000/MISQ/24/115/venkatesh & 475 & 2002/JASIST/53/995/thelwall & 72 & 2006/LJ/131/27/rogers & 1\tabularnewline
25 & 2003/ISR/14/189/chin & 472 & 1996/JIS/22/165/egghe & 24 & 2003/LJ/128/40/rogers & 2\tabularnewline
\hline
\end{tabular}
\par\end{flushleft}
}
\end{table}
\begin{table}[hbt!]
\caption{Journal composition in top 100 ranks by algorithm.}
\label{tbl:caps-journal-composition}
{\scriptsize
\begin{tabular}{|llr|llr|llr|}
\hline
\multicolumn{3}{|c|}{Citation count} & \multicolumn{3}{c|}{CAPS} & \multicolumn{3}{c|}{CITEX}\tabularnewline
\hline
MISQ & mis.quart & 43 & SCI & scientometrics & 33 & LJ & libr.j & 100 \tabularnewline
ISR & inform.syst.res & 14 & JASIS & j.am.soc.inform.sci & 17 & & & \tabularnewline
JAMIA & j.am.med.inform.assn & 9 & JASIST & j.am.soc.inf.sci.tec & 14 & & & \tabularnewline
JASIS & j.am.soc.inform.sci & 6 & JD & j.doc & 12 & & & \tabularnewline
JD & j.doc & 3 & JIS & j.inform.sci & 9 & & & \tabularnewline
IPM & inform.process.manag & 3 & IPM & inform.process.manag & 6 & & & \tabularnewline
JMIS & j.manage.inform.syst & 3 & JI & j.informetr & 5 & & & \tabularnewline
IJCIS & int.j.comput.inf.sci & 2 & ARIS & annu.rev.inform.sci & 2 & & & \tabularnewline
IM & inform.manage & 2 & SSI & soc.sci.inform & 1 & & & \tabularnewline
IJGIS & int.j.geogr.inf.sci & 2 & S & scientist & 1 & & & \tabularnewline
SCI & scientometrics & 2 & & & & & & \tabularnewline
ARIS & annu.rev.inform.sci & 1 & & & & & & \tabularnewline
CJIS & can.j.inform.sci & 1 & & & & & & \tabularnewline
EJIS & eur.j.inform.syst & 1 & & & & & & \tabularnewline
GIQ & gov.inform.q & 1 & & & & & & \tabularnewline
IJGIS & int.j.geogr.inf.syst & 1 & & & & & & \tabularnewline
IMA & inform.manage-amster & 1 & & & & & & \tabularnewline
JASIST & j.am.soc.inf.sci.tec & 1 & & & & & & \tabularnewline
JIS & j.inf.sci & 1 & & & & & & \tabularnewline
KA & knowl.acquis & 1 & & & & & & \tabularnewline
OR & online.rev & 1 & & & & & & \tabularnewline
PAL & program-autom.libr & 1 & & & & & & \tabularnewline
\hline
\end{tabular}
}
\end{table}
In contrast, the CAPS paper score possesses a Gini coefficient of 0.9912, while CITEX has a slightly lower value of 0.9785.
This implies that both methods exhibit large score differentials only between the topmost ranks.
For CAPS paper score, this can be traced to the fact that 81.2\% of the lowest scoring population has a score of exactly zero (76\% of papers in the study data have zero citations\footnote{The LIS dataset consists of 103,768 papers from \emph{Library Journal} ($\sim 48.6$\% of total).
This is nearly 14 times larger than the the $2^{nd}$ largest contributor, i.e.~\emph{Scientist}.
While this seems excessively high, consider that only 1.9\% of papers from \emph{Library Journal} contributes 1\% of non-zero citations in the LIS dataset (from a total of 471,191 citations for 213,530 papers).
In comparison, \emph{Scientometrics} is only the $6^{th}$ largest contributor to the dataset with 3100 papers (1.5\% of total LIS papers) yet contributes a total of 29792 citations (6.3\% from LIS total) making it the $4^{th}$ largest contributor citation-wise.
For reference, the largest citation counts are attributed to \emph{MIS Quarterly}, \emph{J AM MED INFORM ASSN}, and \emph{J AM SOC INFORM SCI} with 55736, 30470, 30317 citations, respectively.
}).
The reason for this is that the coupling of both author features and paper features places strict limits on the size of the non-zero scoring population.
On the other hand, the CITEX paper score has no zero scoring population (due to the presence of artificial paper self-citations).
The extremely high Gini coefficients for both CITEX and CAPS\footnote{For CITEX, 1\% of the top scoring population accounts for 50.1\% of the total score, while 2\% accounts for 91\%.
In comparison, CAPS has 1\% and 2\% of the top scoring population accounting for 88\% and 97\% of total scores, respectively.
}
implies that we can only reasonably differentiate a small fraction of the dataset corresponding to top scoring papers that coincide with top scoring authors.
A quick glance at top scoring papers listed in the ``Citation count'' column of Table~\ref{tbl:caps-top25-papers} reveals that these mostly correspond to informatics papers rather than informetrics.
Contrast this with the listing shown in the ``CAPS'' column where the emphasis is more towards informetrics papers instead.
The reason for this is that the CAPS algorithm takes into account authorship features when scoring papers, which are not accounted for in a simple citation count.
Since informetrics authors are highlighted in Table~\ref{tbl:caps-top25-authors}, it follows that informetrics papers are also highlighted in Table~\ref{tbl:caps-top25-papers}.
Table~\ref{tbl:caps-journal-composition} provides a listing of journals in the top 100 ranks.
This provides some indication of the research field predominantly featured by each method.
\section{Conclusion}
\label{sec:caps-conclusion}
In this paper we have constructed a modified version of the CITEX algorithm originally introduced by~\cite{2015arXiv150104894P}.
This algorithm was designed to assign relative importance scores to papers and authors by taking into account data from both entities simultaneously.
Conventional methods like citation count and PageRank, for example, cannot do so without appropriate modification.
The modification of CITEX which we propose, dubbed the CAPS (Coupled Author-Paper Scoring) algorithm, is designed to address some of the weaknesses of Pal and Ruj's original algorithm which we described in Section~\ref{sec:citex-algo-inspection} (essentially, the shortcomings can be traced to artificially introduced self-citations on the paper-level).
Using a real dataset (ISI papers published from $1980-2012$ in the JCR subject category of ``\emph{Information Science \& Library Science}''), we show that our proposed modifications outperforms CITEX in identifying important authors and papers.
However, the CAPS algorithm appears to suffer from high inequality in the resulting score distributions as indicated by an extremely high Gini coefficient ($\sim 0.99$).
The inequality is similarly pronounced in CITEX.
This implies that both CAPS and CITEX generate extreme prejudice in the allocation of scores to the top scoring minority.
However, this is not necessarily a bad thing.
By design, CAPS allocates high scores to authors and papers associated to instances where the likelihood of future success (an increase in publication count or citation count) is proportional to previous success.
Hence, CAPS can be used to highlight parts of the data attributed to the ``\emph{rich get richer}'' effect.
In contrast, CITEX rewards high scores for authors lying at the tail of the publication productivity distribution, and by association, rewards high scores for papers published by such authors irrespective of the relative importance of their papers within the paper citation network.
In this sense, CITEX is useful to find instances where high productivity is mismatched with low impact.
While bibliometric analytic algorithms such as CITEX or CAPS, or even bibliometric adaptations of website ranking algorithms such as HITS or PageRank can prove useful in identifying what is important in a given dataset, it is crucial to be aware of the limitations and subtleties of such methods.
Each method finds exactly what it is designed to seek and since it is hard to account for, let alone anticipate every relevant feature or contingency, we must concede that the rankings produced are themselves only facets of the underlying organization in the data.
Hence, bibliometric analytic algorithms should be used first and foremost to guide decisions on where to look deeper (i.e.~to construct recommendation engines), and if necessary, used with extreme caution when drawing inferences on the relative standing of bibliometric entities.
\bibliographystyle{apalike}
|
{'timestamp': '2015-06-18T02:18:19', 'yymm': '1506', 'arxiv_id': '1506.05404', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05404'}
|
arxiv
|
\section{Introduction}\label{Sec:Intro}
\IEEEPARstart{F}{uture} hyper-dense small-cell deployments are expected to play a pivotal role in delivering high capacity and reliability by bringing the network closer to users~\cite{05:00250}. However, in order to make hyper-dense deployments a reality, enhancements including effective interference management, self-organization, and energy efficiency are required~\cite{05:00240}. Given that large-scale deployments composed of hundreds or thousands of network elements can increase the energy consumption substantially, the need for energy efficiency (\textit{green communications}) has been recognized by the cellular communications industry as an important item in research projects and standardization activities~\cite{05:00129, 05:00183}.
Initial attempts to improve the energy efficiency in cellular networks were oriented towards minimizing the power radiated through the air interface, which in turn reduces the electromagnetic pollution and its potential effects on human health. However, most of the energy consumption (between 50\% to 80\%) in the radio access network takes place in base stations~(BSs)~\cite{05:00183} and it is largely independent of the BSs' load. Since cellular networks are dimensioned to meet the service demand in \textit{the busy hour}~(i.e.,~peak demand), it is expected that, under non-uniform demand distributions~(both in space and time), a substantial portion of the resources may end up being underutilized, thus incurring in an unnecessary expenditure of energy. The problem may become worse in many of the scenarios foreseen for 5G, presumably characterized by hyper-dense small-cell deployments, hierarchical architectures, and highly heterogeneous service demand conditions~\cite{05:00242}. Therefore, the idea of switching off lightly loaded base stations has been considered recently as a promising method to reduce the energy consumption in cellular networks. This framework is referred to as Cell Switch-Off~(CSO) and it is focused on determining the largest set of cells that can be switched off without compromising the Quality-of-Service~(QoS) provided to users. Unfortunately, CSO is difficult to carry out due to the fact that it represents a highly challenging (combinatorial) optimization problem whose complexity grows exponentially with the number of BSs, and hence, finding optimal solutions is not possible in polynomial time. Moreover, the implementation of CSO requires coordination among neighbor cells and several other practical aspects, such as coverage provision and the need for minimizing the number of (induced) handovers and \mbox{on-off/off-on} transitions. In practice, optimizing the number of transitions, as well as the time required for them, is advisable because switching on/off BSs is far from being a simple procedure, and indeed, this process must be gradual and controlled~\cite{04:00232, 05:00126}. Moreover, a large number of transitions could result in a high number of handovers with a potentially negative impact on QoS~\cite{04:00233}.
Although CSO is a relatively young research topic, a significant amount of contributions has been made. Hence, an exhaustive survey is both out of the scope and not feasible herein. Instead, a literature review including, in the opinion of the authors, some of the most representative works is provided. Thus, in the comparative perspective shown in Table~\ref{TableRelatedWork}, the following criteria have been considered:\vspace{-0.125cm}
\begin{table*}
\caption{Summary of Related Work.}
\vspace{-0.4cm}
\begin{center}
\begin{tabular}{c c c c c c}
\toprule
\multirow{2}{*}{{\small \textbf{Ref} }} & \multirow{2}{*}{{\small \textbf{Year}}} & \multirow{2}{*}{{\small \textbf{CSO type~/~architecture}}}& {\small\textbf{Realistic}} & \multirow{2}{*}{{\small\textbf{Coverage aspects}}} & {\small\textbf{Complexity and }} \\
& & & {\small\textbf{ICI model}} & & {\small\textbf{feasibility analysis}} \\
\midrule
{\small \cite{7322281} } & {\small 2016} & {\small Snapshot / Semi-distributed} & {\small Full-load} & {\small Downlink} & {\small $\checkmark$} \\
{\small \cite{7060678} } & {\small 2016} & {\small Traffic profiling / Centralized} & {\small Full-load} & {\small Downlink} & {\small Partially} \\
{\small \cite{JaGH2016} } & {\small 2016} & {\small Traffic profiling / Semi-distributed} & {\small Load-coupling} & {\small Downlink} & {\small Partially} \\
{\small \cite{7105671} } & {\small 2015} & {\small Snapshot / Centralized} & {\small Full-load} & {\small Downlink} & {\small Partially} \\
{\small \cite{NewHalim} } & {\small 2015} & {\small Snapshot / Centralized} & {\small Full-load} & {\small Downlink} & {\small Partially} \\
{\small \cite{04:00342} } & {\small 2014} & {\small Snapshot / Centralized} & {\small Constant} & {\small Downlink} & {\small $\times$} \\
{\small \cite{04:00328} } & {\small 2014} & {\small Traffic profiling / Semi-distributed} & {\small Full-load} & {\small Downlink} & {\small $\checkmark$} \\
{\small \cite{04:00346} } & {\small 2014} & {\small Snapshot / Centralized} & {\small Constant} & {\small Downlink} & {\small $\times$} \\
{\small \cite{04:00341} } & {\small 2013} & {\small Snapshot / Centralized} & {\small Full-load} & {\small Downlink} & {\small $\times$} \\
{\small \cite{04:00343} } & {\small 2013} & {\small Traffic profiling / Centralized} & {\small Load-coupling} & {\small Downlink} & {\small $\times$} \\
{\small \cite{04:00344} } & {\small 2013} & {\small Snapshot / Centralized} & {\small Constant} & {\small $\times$} & {\small Partially} \\
{\small \cite{04:00345} } & {\small 2013} & {\small Snapshot / Centralized} & {\small Full-load} & {\small Downlink} & {\small Partially} \\
{\small \cite{04:00347} } & {\small 2013} & {\small Snapshot / Centralized} & {\small Full-load} & {\small Downlink} & {\small $\times$} \\
{\small \cite{04:00212} } & {\small 2012} & {\small Snapshot / Centralized} & {\small Constant} & {\small $\times$} & {\small $\times$} \\
{\small \cite{04:00220} } & {\small 2012} & {\small Snapshot / Centralized} & {\small Full-load} & {\small Downlink} & {\small $\times$} \\
{\small \cite{04:00236} } & {\small 2011} & {\small Traffic profiling / Semi-distributed} & {\small Full-load} & {\small Downlink} & {\small Partially} \\
{\small \cite{04:00229} } & {\small 2010} & {\small Snapshot / Centralized} & {\small Full-load} & {\small Downlink} & {\small $\times$} \\
{\small \cite{05:00125} } & {\small 2010} & {\small Snapshot / Centralized} & {\small Constant} & {\small Downlink} & {\small $\times$} \\
{\small \cite{04:00225} } & {\small 2010} & {\small Traffic profiling / Semi-distributed} & {\small Full-load} & {\small $\times$} & {\small $\times$} \\
{\small \cite{04:00224} } & {\small 2009} & {\small Snapshot / Both} & {\small Full-load} & {\small $\times$} & {\small $\times$} \\
\bottomrule
\end{tabular} \end{center}
\label{TableRelatedWork}
\end{table*}
\begin{itemize}[leftmargin=*]
\item \textsl{CSO type / architecture}: CSO solutions can be classified as `snapshot' or `traffic profiling' CSO depending on the approach followed to take the on/off decisions. In snapshot CSO~(e.g.,~\cite{04:00342, 04:00346, 04:00341, 04:00344}),~decisions involve the analysis of discrete realizations of users, i.e., whenever a CSO decision is required, information of every single user in the network needs to be available at a central unit where an heuristic or optimization procedure is performed. Given its nature, this type of solution provides the ultimate performance in terms of energy savings. However, feasibility becomes a serious issue as it will be shown later on. On the other hand, in traffic profiling CSO~(e.g.,~\cite{04:00328, 04:00236, 04:00225}), a certain knowledge about the service demand behavior is assumed.
\item \textsl{Realistic ICI model}: Switching off/on BSs modifies not only the levels of Intercell Interference~(ICI), but also the resulting load coupling~\cite{05:00169}. The load of each BS can be understood as the fraction of resources that are being used to satisfy a certain service demand. There are three different ICI models that can be used in CSO:
\begin{enumerate}[leftmargin=*
\item \textsl{Constant}: The assumption is that ICI is always constant or it does not exist~(e.g.,~\cite{04:00342, 04:00344}). In such cases, ICI levels are calculated as if all cells were always active no matter their actual state (on or off).
\item \textsl{Full-load}~(FL): ICI is only created by active BSs, but assuming that they are fully loaded~(e.g.,~\cite{04:00345, 04:00328, 7322281}). This approach is reasonable in CSO since traffic is concentrated in a subset of BSs which tend to be highly loaded. Thus, active BSs always cause ICI to its neighbors while BSs in sleeping mode do not.
\item \textsl{Load-coupling}~(LC): The ICI created by each BS is proportional to its load~(e.g., \cite{04:00343, JaGH2016}). This model is more realistic and accurate but involves more \mbox{complexity}.
\end{enumerate}
\item \textsl{Coverage}: It indicates whether coverage aspects (in downlink, uplink, or both) are considered. This is an important criterion in CSO to avoid coverage holes.
\item \textsl{Complexity and feasibility}: It indicates whether a complexity and/or feasibility analysis is provided. For instance, in case of CSO, how much information is required to be exchanged among cells is an important metric. Moreover, the number of transitions and handovers in a dynamic environment must also be estimated.
\end{itemize}
As it can be seen from~Table~\ref{TableRelatedWork}, snapshot-based schemes require centralized operation, and due to the NP-complete nature of the problem, heuristics are the preferred way to deal with it. Representative examples of this type of solutions include \cite{04:00341, 04:00212, 05:00125, 04:00342} where the main idea is, in general, to sequentially switch~1)~on highly loaded cells (cells that can get more traffic), or~2)~off lightly loaded ones (cells whose users can easily be migrated to neighbor BSs) until the service demand is fulfilled.
In general, this type of schemes requires employing basic models for ICI, e.g., \cite{05:00125, 04:00342, 04:00212}. As indicated, another approach to CSO is traffic profiling, the case of \cite{04:00328, 04:00343, 04:00236, 04:00225}, where CSO decisions are taken assuming a certain knowledge about the service demand~\cite{04:00326, 05:00221}. However, most of the solutions presented so far employ models and assumptions oriented to macrocellular deployments, such as~\cite{04:00343, 04:00236, JaGH2016}, where the use of CSO is not so clear due to practical issues~\cite{04:00340}. Other practical aspects, such as the number of transitions and handovers are often overlooked as~well. Recently, CSO has also been studied in the context of infrastructure sharing~\cite{7105671} and by means of stochastic geometry~\cite{7060678}.
Thus, in the light of these observations, this paper presents a novel multiobjective framework\footnote{A preliminary version of this work was presented in~\cite{04:00328}. From it, a US patent application has also been made: US patent application no:~14/334,134, application date: 17 July 2014.} that 1)~includes the strengths of previous proposals,~2)~overcomes many of their drawbacks, and 3)~extends the analysis to address aspects that have not fully been investigated.
\vspace{0.1cm}
\begingroup
\leftskip0.99em
\rightskip0.99em
\noindent\textbf{Main contribution:} a framework for multiobjective optimization for CSO that explicitly takes into account a statistical description of the service demand distribution when computing the performance metrics.
\par
\endgroup
\vspace{0.1cm}
As it will be illustrated by the numerical results, this idea has the following advantages:
{\renewcommand{\labelitemi}{$\checkmark$}
\begin{itemize}[leftmargin=*]
\item The use of the spatial service demand distribution (represented by a spatial probability density function) allows to the proposed algorithm to rapidly identify network topologies, i.e., on/off patterns, providing higher capacity to areas where high service demand is more likely to appear, and hence, the \textit{search space} and required computational effort is significantly reduced.
\item Given that, in general, traffic profiles are \textit{stable} in time scales of dozens of minutes, the (computationally-heavy) optimization can be done offline and required topologies can be applied as needed as these traffic profiles are recognized/observed during network operation. This feature makes the implementation of CSO feasible, given that the required BS coordination and real-time processing are significantly reduced. However, the conceptual idea will still be valid when new paradigms (cloud computing, software defined networking, and network virtualization, see~\cite{05:00250}) allow faster computation and information exchange among network nodes. Thus, more dynamic traffic profile recognition and optimization will also be possible under the proposed framework.
\item The proposed optimization formulation allows considering several downlink and uplink coverage criteria, such as minimum received power and Signal to Interference plus Noise Ratio~(SINR).
\item Given that there exist a correlation between the topologies that are specific for a given traffic profile, the number of handovers and transitions is minimized.
\end{itemize}}
Finally, the following set of secondary/minor contributions are also presented in this work:
\begin{enumerate}[leftmargin=*]
\item Analysis of the impact of the most extended interference models (FL and LC) on the performance of CSO.
\item A quantitative assessment of how CSO operation affects the critical uplink power consumption (on user equipment side). To the best of the authors' knowledge, this aspect/criterion has been overlooked in most of previous studies, and only recently in \cite{NewHalim} it has been integrated within an optimization framework.
\item While the multiobjective problem formulation presented herein can be solved by means of standard stochastic optimization tools~\cite{08:00044}, an alternative iterative algorithm is also proposed for computing the important tradeoff between the number of active cells and network capacity. As it will be shown shortly, although its performance is slightly inferior to stochastic search, it is significantly faster, and hence, it could be used when real-time operation becomes feasible.
\end{enumerate}
The rest of the paper is organized as follows: the next section presents the system model. The proposed Multiobjective Optimization (MO) framework (performance metrics and problem formulation) is explained in Section~\ref{Sec:PropFramework}. Section~\ref{Sec:EvaSetParameters} describes the evaluation setting and benchmarks used
in simulations. Numerical results are also analyzed therein. Section~\ref{Sec:Conclusions} closes the article with
conclusions and research directions.
\section{System Model}\label{Sec:SysModel}
\subsection{Definitions and notations}\label{Sec:SysModel_DefNot}
In this study, an OFDMA cellular network is considered. The system bandwidth is $B$ and the network is composed of $L$ BSs that can be independently switched off/on. The indices of the BSs are contained in the set $\mathcal{L}=\{0,1,\cdots,L-1\}$. The set $\mathcal{A}$, composed of $A=|\mathcal{A}|$ small area elements, represents the spatial domain to which the network provides service. It is assumed that within each area elements $a\in\mathcal{A}$, the average received power is constant. The maximum transmit power per cell is $P_{\text{max}}$. The network geometry is captured by the path loss matrix $\mathbf{G}\in\mathbb{R}^{A\times L}$ (distance dependent attenuation, antenna gains, and shadowing). The vectors $\mathbf{p}_{\text{PS}}$ and $\mathbf{p}_{\text{D}}$, both $\in\mathbb{R}^{L}$, indicate the transmit power at each cell in Pilot Signals~(PS), and data channels, respectively. Cell selection is based on the average PS received power, which can be calculated by means of the following expression:
\begin{equation}
\mathbf{R}_{\text{PS}} = \text{\textbf{G}} \cdot \text{diag}\left(\mathbf{p}_{\text{PS}}\odot\mathbf{x}\right),~~\mathbf{R}_{\text{PS}}\in\mathbb{R}^{A\times L}.
\label{eq:R_CSRS}
\end{equation}
The operator $\odot$ denotes Hadamard (pointwise) operations. The vector $\mathbf{x}\in\{0,1\}^{L}$ indicates which cells are active and which ones are switched off. Hereafter, $\mathbf{x}$ is also referred to as
`network topology'. Thus, the matrix~$\mathbf{R}_{\text{PS}}$~in~(\ref{eq:R_CSRS}) contains the PS received power, i.e., $\mathbf{R}_{\text{PS}}(a,l)$ indicates the received power from the $l^{\text{th}}$ BS in the $a^{\text{th}}$ area element. Of interest is the Number of Active Cells~(NAC) in each network topology as energy consumption is related to it.
The $a^{\text{th}}$ area element (the $a^{\text{th}}$ row in $\mathbf{R}_{\text{PS}}$) is served by cell~$l^{\star}$~if
\begin{equation}
\label{Eq:ServingCell}
l^{\star}=\underset{l\in\{0,1,\dotso,L-1\}}{\operatorname{argmax}}\hspace{0.2cm}
\mathbf{R}_{\text{PS}}(a,l).
\end{equation}
The dependence of $l^{\star}$ on $\mathbf{x}$ has not been explicitly indicated for the sake of clarity.
Based on (\ref{eq:R_CSRS})~and~(\ref{Eq:ServingCell}), the binary coverage matrices
$\text{\textbf{S}}$ and $\text{\textbf{S}}^{\text{c}}\in\mathbb{R}^{A\times L}$ can be obtained.
If the $a^{\text{th}}$ pixel is served by $l^{\star}$, then $\text{\textbf{S}}(a,l^{\star})=1$. $\text{\textbf{S}}^{\text{c}}$
is the binary complement of~$\text{\textbf{S}}$. Hence, the coverage pattern, implicitly defined in $\text{\textbf{S}}$, is a function of~$\mathbf{x}$. The cell selection rule indicated by~(\ref{Eq:ServingCell}) can be regarded as a connectivity function $f_\text{c}:\mathcal{A}\rightarrow\mathcal{L}\,\cup\,\{-1\}$. If $f_\text{c}(a)=-1$, the $a^{\text{th}}$ area element is out of coverage, i.e.,
\begin{itemize}[leftmargin=*
\item the received power in $a\in\mathcal{A}$ ($\mathbf{R}_{\text{PS}}\left(a,l^{\star} \right)$) is smaller than $P_{\text{min}}^{\text{Rx}}$, i.e., $\mathbf{R}_{\text{PS}}\left(a,l^{\star} \right)\leq P_{\text{min}}^{\text{Rx}}$,
\item the SINR ($\psi_a$) in the area element $a\in\mathcal{A}$ is smaller than $\psi_{\text{min}}$, i.e., $\psi_a\leq \psi_{\text{min}}$, or
\item the path loss $\mathbf{G}\left(a,l^{\star} \right)$ between the area element and its server is greater than $G^{\text{UL}}_{\text{max}}$, i.e., \mbox{$\mathbf{G}\left(a,l^{\star} \right)\geq G^{\text{UL}}_{\text{max}}$}. In practice, $G^{\text{UL}}_{\text{max}}$~is the maximum path-loss obtained from the uplink link budget (a design criterion).
\end{itemize}
The cell $\mathcal{A}_l$ is the subset of $\mathcal{A}$ served by the $l^{\text{th}}$ BS. Thus, $\mathcal{A}_l\triangleq \{\,a\in\mathcal{A}:\,f_{\text{c}}(a)=l\,\}$, where $\set{A}_i\cap\set{A}_j=\emptyset,~\forall~i\neq j$. The set $\set{A}_{\text{c}}$ is the subset of $\set{A}$ that are associated to one BS. Thus, $\set{A}_{\text{c}}\triangleq \{\,a\in\set{A}:f_{\text{c}}(a)\neq-1\}=\bigcup_{l\in\set{L}} \set{A}_l$. The vector $\mathbf{\Gamma}\in\mathbb{R}^{A}$ corresponds to the spatial service demand distribution. Thus, $\mathbf{\Gamma}(a)$ indicates the probability, in the event of a new user, that the $a^{\text{th}}$ pixel has the user on it, and hence, $\mathbf{\Gamma}^{\text{T}}\cdot\mathbf{1}=1$. It should be noted that $\mathbf{\Gamma}$~is time-dependent, however it is reasonable to assume that $\mathbf{\Gamma}$ is constant during fixed intervals~\cite{04:00326}. In order to represent the service demand volume, two parameters are considered: inter-arrival time~($\lambda$) and session time~($\mu$). Both are modeled as exponentially distributed random variables. Thus, service demand's spatial distribution and volume are described by $\mathbf{\Gamma}$ and the first order statistics of $\lambda$ and $\mu$, i.e., $\mathbb{E}\{\lambda\}$ and $\mathbb{E}\{\mu\}$, respectively. It is assumed that the QoS of a user is satisfied if the target rate ($r_{\text{min}}$) is fulfilled. Hence, the total service demand volume ($R$) in $\mathcal{A}$ is given by
\begin{equation}
R=\sum_{a\in\set{A}}r_{a}~~~\text{[bps]},\label{Eq:V}
\end{equation}
where
\begin{equation}
r_{a}=\frac{\spc{E}\{\mu\}}{\spc{E}\{\lambda\}}\cdot\mathbf{\Gamma}(a)\cdot r_{\text{min}}~~~\text{[bps]}\label{Eq:ra}
\end{equation}
corresponds to the average demand in the $a^{\text{th}}$ area element. The previous model for the service demand can easily be extended to the general case of more than one service to account with the fact that service time, inter-arrival time, spatial distribution, and target rate can be \textsl{service-specific}. Assuming that there are $N_{\text{S}}$ service classes, each of them with different characteristics, i.e., $\mu^c$, $\lambda^c$, $\mathbf{\Gamma}^c$, and $r_{\text{min}}^c$ for $c=1,2,\cdots,N_{\text{S}}$, (\ref{Eq:ra}) can be rewritten as follows:
\vspace{-0.0cm}
\begin{equation}
r_{a}^{\text{S}}=\sum_{c=1}^{N_{\text{S}}}\left(\frac{\spc{E}\{\mu^c\}}{\spc{E}\{\lambda^c\}}\cdot\mathbf{\Gamma}^c(a)\cdot r_{\text{min}}^c\right)~~~\text{[bps]}.\label{Eq:ra_gen}
\end{equation}
The resulting spatial service demand distribution (that is required to compute the performance metrics introduced later on) can be obtained by considering the resulting demand as follows:
\vspace{-0.0cm}
\begin{equation}
\mathbf{\Gamma}^{\text{S}}(a)=\frac{r_{a}^{\text{S}}}{\sum_{a\in\set{A}}r_{a}^{\text{S}}}.\label{Eq:Gamma_gen}
\end{equation}
Hereafter, one single service class (possibly the result of a mix of many others) is assumed for the sake of clarity, and hence, one single set of parameters ($\mu$, $\lambda$, $\mathbf{\Gamma}$, and $r_{\text{min}}$) are considered.
\begin{definition}[Cell load]\label{Def:CellLoad}
\normalfont The load of the $l^{\text{th}}$ BS ($\alpha_l(t)$), at any given time $t$, is defined as the fraction of the available resources (bandwidth) that are being used.
\end{definition}
The average load of the $l^{\text{th}}$ BS is $\bar{\alpha}_l\triangleq\spc{E}\{\alpha_l(t)\}$. Thus, the vector~\mbox{$\bar{\boldsymbol{\alpha}}=[~\bar{\alpha}_0~\bar{\alpha}_1~\cdots~\bar{\alpha}_{L-1}~]$} indicates the load conditions in the network, on average. Note that if $\myvec{x}(l)=0$, then \mbox{$\bar{\boldsymbol{\alpha}}(l)=0$}. As the reader can easily infer, as long as $\bar{\boldsymbol{\alpha}}\leq\myvec{1}$, the network topology ($\myvec{x}$) is able to satisfy, on average, the service demand given by $\mathbf{\Gamma}$, $\mathbb{E}\{\lambda\}$, and $\mathbb{E}\{\mu\}$, and hence, it can be said that $\myvec{x}$ is \textit{adequate}.
\begin{definition}[Network capacity]\label{Def:NetCap}
\normalfont The network capacity ($V_{\text{Cap}}$) is defined as the maximum service demand volume such that $\bar{\boldsymbol{\alpha}}\leq\myvec{1}$. Thus, $V_{\text{Cap}} \triangleq \text{max}~V:~\bar{\boldsymbol{\alpha}}\leq\myvec{1}$.
\end{definition}
\begin{definition}[Saturation point]\label{Def:Sat}
\normalfont The saturation point ($V_{\text{Sat}}$) is the minimum service demand volume such that $\bar{\boldsymbol{\alpha}}\geq\myvec{1}$. Thus, $V_{\text{Sat}} \triangleq \text{min}~V:~\bar{\boldsymbol{\alpha}}\geq\myvec{1}$.
\end{definition}
As indicated, different models can be used for modeling ICI. In this work, two models are considered: `\textsl{full load}' and `\textsl{load coupling}'. Recall that in full load, active cells are assumed to have full load, i.e., $\bar{\alpha}_l=1,~\text{if}~\myvec{x}(l)=1$, and $\bar{\alpha}_l=0$, if $\myvec{x}(l)=0$. In case of load coupling, the ICI created by each cell is proportional to its load. An iterative algorithm to estimate the cell load coupling is provided in Appendix~\ref{App:LoadCoupling}. Thus, the vector $\mathbf{\Psi}\in\mathbb{R}^{A}$ representing the average SINR at each area element is given by
\vspace{-0.55cm}
{\small\begin{equation}
\mathbf{\Psi} = \left[ (\mathbf{S} \odot \mathbf{G}) \cdot (\mathbf{p}_{\text{D}}\odot\mathbf{x}) \hspace{0.00cm} \right]
\oslash \left[\hspace{0.00cm} \left[ (\mathbf{S}^{\textnormal{c}} \odot \mathbf{G}) \cdot (\mathbf{p}_{\text{D}}\odot\mathbf{x}\odot\bar{\boldsymbol{\alpha}}) \right] \oplus
\sigma^2 \hspace{0.00cm}\right].
\label{Eq:CSO_AVG_SINR}
\end{equation}}
The operators $\oslash$ and $\oplus$ denote Hadamard (pointwise) operations. By means of (\ref{Eq:CSO_AVG_SINR}), average SINR figures as function of the network topology~($\myvec{x}$) are obtained. Since load levels also depend on SINR values, the load coupling generates a system of non-linear equations which have a unique non-negative ($\bar{\boldsymbol{\alpha}}\geq\myvec{0}$) solution~\cite{05:00169}. In order to estimate $\bar{\boldsymbol{\alpha}}$, let's look at the average SINR at area element level. The average SINR at $a\in\set{A}_{l}$ can be expressed as
\begin{equation}
\psi(a)= \frac{\mathbf{p}_{\text{D}}(l)\cdot\mathbf{G}\left(a,l\right)}{\left(\displaystyle\sum\limits_{j\in\set{L}\backslash\{l\}}\bar{\alpha}_{j}\cdot\mathbf{p}_{\text{D}}(j)\cdot\mathbf{G}\left(a,j \right) \right)+\sigma^2}. \label{Eq:SINR_Coupling_NoIntra}
\end{equation}
In (\ref{Eq:SINR_Coupling_NoIntra}), the ICI coming from neighbor BSs is proportional to their average loads ($\bar{\alpha}_j$'s). It is customary to define link performance in terms of $\psi(a)$ by means of a concave (e.g., logarithmic) function ($f_{\text{LP}}$) of it, such that \mbox{$\gamma_{a}=f_{\text{LP}}(\psi(\myvec{a}))~\text{[bps/Hz]}$}. The bandwidth requirement of a single user in $a\in\set{A}_{l}$ to satisfy the QoS can be obtained as
\begin{equation}
b_{\text{u}}(a) = \frac{r_{\text{min}}}{f_{\text{LP}}(\psi(a))}~~~\text{[Hz]},\label{Eq:UserRequirement}
\end{equation}
and the average load ($\bar{\alpha}_{l}$) in the $l^{\text{th}}$ BS would be given by
\begin{equation}
\bar{\alpha}_{l}= \frac{1}{ B_{\text{sys}}}\cdot N_{\text{u}}^{l}\cdot b_{l}, \label{Eq:NELoadStatistically_2}
\end{equation}
where
\begin{equation}
N_{\text{u}}^{l}= \left( \sum_{a\in\set{A}_{l}}\mathbf{\Gamma}(a) \right)\frac{\spc{E}\{\mu\}}{\spc{E}\{\lambda\}}, \label{Eq:A}
\end{equation}
and
\begin{equation}
b_{l}= \sum_{a\in\set{A}_{l}}\left(\frac{\mathbf{\Gamma}(a)}{\sum_{k\in\set{A}_{l}}\mathbf{\Gamma}(k)}\right)b_{\text{u}}(a)~~~~\text{[Hz]}. \label{Eq:B}
\end{equation}
In~(\ref{Eq:NELoadStatistically_2}), $N_{\text{u}}^{l}$ and $b_{l}$ are the average number of users and bandwidth consumption in BS $l$, respectively.
In order to take into account the coverage criteria and penalize solutions with coverage holes, i.e., a significant number of area elements without coverage, the spectral efficiency of the $a^{\text{th}}$ area element is stored in the vector~\mbox{$\myvec{H}\in\mathbb{R}^{A}$} and it is computed according to the following rule: \mbox{$h_a = \myvec{v}(a)\cdot f_{\text{LP}}(\psi_a)$}. The binary vector $\mathbf{v}\in\{0,1\}^{A}$ indicates if the $a^{\text{th}}$ is out of coverage. Therefore, if the $a^{\text{th}}$~area element is in outage, \mbox{$\mathbf{v}(a)$ = 1}, and 0 otherwise.
Finally, the list of symbols is provided in Table~\ref{TableNotation}.
\begin{table*}
\caption{Basic notation.}
\vspace{-0.4cm}
\begin{center}
\begin{tabular}{r l r l }
\toprule
{\small \textbf{Symbol} } & {\small\textbf{Description}} & {\small \textbf{Symbol} } & {\small\textbf{Description}} \\[-0.025cm]
\midrule
{\small $B$ } & {\small System bandwidth} & {\small $P_{\text{max}}$} & {\small Maximum transmit power per cell} \\[-0.00cm]
{\small $L$ } & {\small Number of BSs} & {\small $\set{L}$} & {\small Set with the base stations' indexes} \\[-0.00cm]
{\small $A$ } & {\small Number of area elements} & {\small $\set{A}$} & {\small Set of area elements in the target area} \\[-0.00cm]
{\small $\myvec{G}$ } & {\small Path-loss matrix} & {\small $\mathbf{p}_{\text{PS}}$, $\mathbf{p}_{\text{D}}$} & {\small Power vectors: pilots and data channels} \\[-0.00cm]
{\small $\mathbf{R}_{\text{PS}}$ } & {\small Received power matrix} & {\small $\mathbf{x}$} & {\small Network topology} \\[-0.00cm]
{\small $\set{A}_{\text{c}}$ } & {\small Coverage area ($\set{A}_{\text{c}}\subseteq\set{A}$)} & {\small $\set{A}_l$} & {\small Coverage of the $l^{\text{th}}$ BS} \\[-0.00cm]
{\small $\mathbf{R}_{\text{PS}}$ } & {\small Received power matrix} & {\small $\text{\textbf{S}}$, $\text{\textbf{S}}^{\text{c}}$} & {\small Coverage matrices, i.e., coverage of each cell} \\[-0.00cm]
{\small $f_\text{c}$ } & {\small Connectivity function (cell selection)} & {\small $f_\text{LP}$} & {\small Link performance model} \\[-0.00cm]
{\small $P_{\text{min}}$ } & {\small Minimum received power} & {\small $\psi_{\text{min}}$} & {\small Minimum SINR} \\[-0.00cm]
{\small $G^{\text{UL}}_{\text{max}}$ } & {\small Maximum path-loss} & {\small $r_{\text{min}}$} & {\small Minimum target rate (QoS criterion)} \\[-0.00cm]
{\small $\lambda$ } & {\small Inter-arrival time} & {\small $\mu$} & {\small Session time} \\[-0.00cm]
{\small $\mathbf{\Gamma}$ } & {\small Spatial demand distribution} & {\small $\bar{\boldsymbol{\alpha}}$} & {\small Average load vector} \\[-0.00cm]
{\small $V$ } & {\small Service demand volume} & {\small $\mathbf{\Psi}$} & {\small Average SINR vector} \\[-0.00cm]
{\small $\mathbf{H}$ } & {\small Spectral efficiency vector} & {\small $\kappa_{\text{UL}}$} & {\small Uplink fractional compensation} \\[-0.00cm]
{\small $\mathbf{v}$ } & {\small Coverage vector} & {\small $\kappa_{\text{COV}}$} & {\small Coverage threshold} \\[-0.00cm]
{\small $\mathbf{n}$ } & {\small Inverse of cell's size} & {\small $$} & {\small } \\[-0.05cm]
\bottomrule
\end{tabular} \end{center}
\label{TableNotation}
\end{table*}
\section{Metrics, Problem Formulation, and Solution}\label{Sec:PropFramework}
\subsection{Multiobjective optimization: basics}\label{Sec:MObasics}
In order to study the tradeoffs in CSO, the use of multiobjective optimization has been considered. Multiobjective optimization is the discipline that focuses on the resolution of the problems involving the simultaneous optimization of several conflicting objectives, and hence, it is a convenient tool to investigate CSO, where the two fundamental metrics, energy consumption and network capacity, are in conflict. The target is to find a subset of \textit{good} solutions $\mathcal{X}^{\star}$ from a set $\mathcal{X}$ according to a set of criteria $\set{F}=\{ f_1, f_2,\cdots,f_{|\set{F}|}\}$, with cardinality $|\set{F}|$ greater than one. In general, the objectives are in conflict, and so, improving one of them implies worsening another. Consequently, it makes no sense to talk about a single global optimum, and hence, the notion of an optimum set $\mathcal{X}^{\star}$ becomes very important. A central concept in multiobjective optimization is Pareto efficiency. A solution $\text{\textbf{x}}^{\star}\in\mathcal{X}$ has Pareto efficiency if and only if there does not exist a solution $\text{\textbf{x}}\in\mathcal{X}$, such that $\text{\textbf{x}}$ dominates $\text{\textbf{x}}^{\star}$. A solution $\text{\textbf{x}}_{1}$ is preferred to (dominates) another solution $\text{\textbf{x}}_{2}$, ($\text{\textbf{x}}_{1}\succ\text{\textbf{x}}_{2}$), if $\text{\textbf{x}}_{1}$ is better than $\text{\textbf{x}}_{2}$ in at least one criterion and not worse than any of the remaining ones. The set $\mathcal{X}^{\star}$ of Pareto efficient solutions is called optimal nondominated set and its image is known as the Optimal Pareto Front (OPF). In multiobjective optimization, it is unusual to obtain the OPF due to problem complexity; instead, a near-optimal or estimated Pareto front (PF) is found. Readers are referred to~\cite{08:00044} for an in-depth discussion.
\subsection{Performance metrics}\label{Sec:PropFramework_ProbForm_FL}
The following performance metrics have been considered\footnote{In the definition of some metrics, the dependence with $\mathbf{x}$ is not explicit, however, it is important to note that all of them depend on $\mathbf{x}$, i.e., the network topology.}:
\begin{itemize}[leftmargin=*
\item \textsl{The number of active cells} ($f_1$). Under the full-load assumption, energy consumption is proportional to the number of active cells~\cite{04:00212, 05:00125}:
\begin{equation}
f_1=\mathbf{x}\cdot\mathbf{1}.
\label{Eq:CSO_f1}
\end{equation}
\item \textsl{Average network capacity} ($f_2$). This metric is based on the expected value of the spectral efficiency at area element level. Hence, the effect of the spatial service demand distribution ($\mathbf{\Gamma}$) must be considered. The metric is defined as follows:
\begin{equation}
f_2 = \left(B\cdot A\right) \left[ \left[ ( \mathbf{H}\odot\mathbf{\Gamma} )^{\text{T}}
\cdot\mathbf{S}\right]\odot \mathbf{n} \right]\cdot \mathbf{1}.
\label{Eq:CSO_f2}
\end{equation}
The vector \hspace{0.025cm}$\mathbf{H}\odot\mathbf{\Gamma}$ corresponds to the \textit{weighted} spectral efficiency of each area element. The idea is to give more importance to the network topologies ($\mathbf{x}$'s) that provide better aggregate capacity ($f_2$) to the areas with higher service demand. In~(\ref{Eq:CSO_f2}), $A$ (the number of area elements) is used to normalize the obtained capacity to the uniform distribution case, i.e., $\mathbf{\Gamma}(a)=1/A,\hspace{0.25cm\forall\,a\in\set{A}}$. The vector~$\mathbf{n}\in\mathbb{R}^{L}$ contains the inverse of the sum of each column in $\text{\textbf{S}}$, i.e., the number of pixels served by each cell. It is assumed that each user is served by one cell at a~time. This vector is used to distribute the capacity of each cell evenly over its coverage area, i.e., the bandwidth is shared equally by the area elements belonging to each cell. This improves the fairness in the long run similar to the proportional fairness policy that tends to share the resources equally among users as time passes. This fairness notion results in decreasing the individual rates as the number of users increases. This effect is also captured by $\mathbf{n}$ as the bandwidth per area element is inversely proportional to the size of the~cell.
\item \textsl{Cell edge performance} ($f_3$). The $5^{\text{th}}$ percentile of the pixel rate Cumulative Distribution Function (CDF) is commonly used to provide an indicator for cell edge performance~\cite{05:00138}. A vector with the weighted average rate at area element level can be obtained as follows:
\begin{equation}
\myvec{r} = A\cdot\left( \myvec{H}\odot\myvec{\Gamma} \right) \odot \left[ \myvec{S}\cdot \left( \myvec{n}^{\text{T}}\cdot\text{diag}(B) \right)^{\text{T}} \right].
\label{Eq:CSO_f3}
\end{equation}
Then, the percentile 5 is given by
\begin{equation}
f_3 = \myvec{r}^{\prime}( 0.05\cdot A).
\label{Eq:CSO_f32}
\end{equation}
The vector $\myvec{r}^{\prime}$ is a sorted (ascending order) version of $\myvec{r}$.
\item \textsl{Uplink power consumption} ($f_4$). In order to provide an estimate of the uplink power consumption of any network topology, a fractional compensation similar to the Open Loop Power Control~(OLPC) used in Long Term Evolution~(LTE) is considered~\cite{04:00282}. It is given by
\begin{equation}
f_4 = \frac{1}{\sum_{k\in\set{A}_{\text{c}}}\myvec{\Gamma}(k)}\cdot\sum_{l=0}^{L-1}\sum_{a\in\set{A}_{\text{l}}}~\myvec{\Gamma}(a)\cdot\left( P_0 + \kappa_{\text{UL}} \cdot \mathbf{G}\left(a,l \right) \right),
\label{Eq:CSO_fUPLPC}
\end{equation}
where $P_0$ is a design parameter that depends on the allocated bandwidth and target Signal-to-Noise Ratio~(SNR) and $\kappa_{\text{UL}}\in[0,1]$ is the (network controlled) fractional compensation factor.
\item \textsl{Load dependent power consumption} ($f_5$). In order to estimate the network power consumption under the load coupling assumption, the parameterized BS power model proposed in~\cite{05:00232} has been used. Thus,
\begin{equation}
f_5=\sum_{l=0}^{L-1}f_{\text{PC}}^{l}(\bar{\alpha}_l),
\label{Eq:CSO_PCLC}
\end{equation}
where $f_{\text{PC}}^{l}(\bar{\alpha}_l)$ is a function that gives the power consumption in the $l^{\text{th}}$~BS as function of its load. Essentially, in this model, there is a fixed power consumption ($P_0$) that is independent of the load but that can be further reduced (till $P_{\text{CSO}}$) if the base station is switched-off. Moreover, there is a part that grows linearly with the load till a maximum power consumption ($P_{\text{max}}$) that obviously contains the transmitted power over the air interface ($P_{\text{max}}^{\text{Tx}}$).
\item \textsl{Load dispersion} ($f_6$). As it will be shown, load dispersion in load coupling conditions is an important parameter because it measures how well distributed the service demand is. In order to quantify this value, the Coefficient of Variation is considered. Thus,
\begin{equation}
f_6= \frac{\text{std}\{\bar{\boldsymbol{\alpha}}\}}{\text{mean}\{\bar{\boldsymbol{\alpha}}\}}.
\label{Eq:Irreg}
\end{equation}
\item \textsl{Handovers}. In the context of CSO, handovers are a quite important concern~\cite{04:00233}. Handovers are produced when users need to be associated to another base station because their serving cells are switched-off. In practice, handovers are mainly produced due to users mobility, but independently of the type, either user- or network-triggered, handovers require a certain time and signaling, both at the air interface and core network. Thus, the CSO operation should, as much as possible, minimize the number of handover, i.e., the transition from one topology to another should be done with the minimal impact and/or cost. A pictorial representation of the aforementioned situation is shown in Figure~\ref{Fig:HANDOVERS}. Thus, handovers are considered herein as an important performance metric.
\end{itemize}
\begin{figure}[t]
\centering
\includegraphics[width = 0.39\textwidth]{HANDOVERS.pdf}
\vspace{-0.25cm}\caption{Illustration of network-initiated handover due to CSO operation.}
\label{Fig:HANDOVERS}
\end{figure}
\subsection{Multiobjective problem formulation}\label{Sec:PropFramework_ProbForm_MOPF}
The multiobjective optimization problem considered herein can be formulated as follows:
\begin{subequations}
\label{OP:CSO}
\begin{align}
\hspace{0.2cm} \text{optimize}~\myvec{f}(\myvec{x})& =
\hspace{0.025cm} [\hspace{0.05cm}
f_{i}\left(\mathbf{x}\right), \hspace{0.05cm} f_{j}\left(\mathbf{x}\right) \hspace{0.025cm}], \label{OP:CSO:MAIN}\\
\text{subject to:} & \nonumber\\[-0.0cm]
\textcolor[rgb]{1,1,1}{.}&\hspace{0.5cm} \left(A^{-1}\cdot\left(\mathbf{v}^{\text{T}}\cdot\mathbf{1}\right)\right)\hspace{0.1cm}\leq\hspace{0.1cm}\kappa_{\text{COV}}, \label{OP:CSO:C1}\\[-0.05cm]
\textcolor[rgb]{1,1,1}{.}&\hspace{0.5cm} \mathbf{x}\in\{0,1\}^L,\hspace{0.1cm}\mathbf{x}\neq \mathbf{0}. \label{OP:CSO:C3}
\end{align}
\end{subequations}
Problem~\eqref{OP:CSO} proposes the simultaneous optimization of two of the previously introduced performance metrics as follows:
\begin{itemize}
\item Full load: if full load is assumed as model for intercell interference, $i=1$ and $j\in\{2,3,4\}$ in~\eqref{OP:CSO:MAIN}.
\item Load coupling: if load coupling is assumed as model for intercell interference, $i=5$ and $j=6$ in~\eqref{OP:CSO:MAIN}.
\end{itemize}
The previous optimization scheme allows to study and characterized the tradeoffs between conflicting metrics (see Section~\ref{Sec:PropFramework_ProbForm_FL}) in a deployment-specific manner.
Constraints~\eqref{OP:CSO:C1}~and~\eqref{OP:CSO:C3} correspond to the coverage criterion and feasible set definition, respectively.
In general, solving multiobjective problems such as \eqref{OP:CSO} is very difficult~\cite{08:00044}. Indeed, (\ref{OP:CSO}) is a combinatorial problem that belongs to the class NP-complete, and hence, optimal solutions cannot be found in polynomial time. The domain (search space) defined by the optimization variable ($\mathbf{x}$, the on/off pattern) is a set of size $2^{L}-1$, where $L$ is the number of BSs. The objective space (or \textit{image}) is defined by the objective functions, and due to their mathematical structure, it is highly non-linear, non-convex, and full of discontinuities and local optima~\cite{08:00053}. Certain algorithms such as Simplex~\cite{05:00120} are susceptible to be trapped in local optima, while other optimization techniques, such as Sequential Quadratic Programming \cite{10:00021}, require convexity to guarantee convergence. Moreover, traditional constrained optimization, in which only one objective function is optimized subject to a set of constraints on the remaining ones, has the drawback of limiting the visibility of the whole objective space. For this reason, \textsl{heuristic}-based algorithms are popular approaches in CSO as it was seen in Section~\ref{Sec:Intro}, but unfortunately, by means of this type of solutions it is very difficult to address multiobjective optimization problems. In order to overcome this difficulty, the use of Multiobjective evolutionary algorithms~(MOEAs)~\cite{08:00052} is proposed herein as described next.
\subsection{Multiobjective evolutionary algorithms}\label{Sec:PropFramework_ProbForm_MOEAs}
As it was mentioned, heuristic solutions are usually problem-specific and typically used for single-objective optimization. Thus, the so-called `\textsl{metaheuristics}' have become an active research field~\cite{08:00053}. Metaheuristics can be used to solve very general kind of multiobjective optimization problems, such as the CSO formulation presented herein.
Indeed, \eqref{OP:CSO} requires a tool able to~1)~find good solutions by efficiently exploring the search space, and~2)~operate efficiently with multiple criteria and a large number of design variables. In addition, it should not have strong requirements, such as convexity or continuity. Multiobjective evolutionary algorithms~(MOEAs)~\cite{08:00052} fulfill the previous goals, and hence, their use is proposed to deal with the CSO framework presented herein. MOEAs are population-based metaheuristics that simulate the process of natural evolution and they are convenient due to their \textit{black-box} nature that requires no assumption on the objective functions.
Thus, the Nondominated Sorting Genetic Algorithm II~(NSGA-II)~\cite{05:00087} is employed herein to solve~(\ref{OP:CSO}). NSGA-II is accepted and well-recognized as a reference in the field of evolutionary optimization as it has desirable features, such as \textit{elitism} (the ability to preserve good solutions), and mechanisms to flexibly improve \textit{convergence} and \textit{distribution}. Further details can be found in~\cite{08:00052}. One key insight for selecting evolutionary (genetic) algorithms is that, in CSO, a certain correlation is expected among network topologies that are suitable for a given spatial service demand distribution, i.e., they are expected to be similar, with more cells where the traffic is concentrated. The operation in evolutionary algorithms precisely does that, i.e., once a good (Pareto efficient) solution (network topology) is found, the algorithm iteratively try to improve it by~1)~combining it with other good solutions (\textsl{crossover} mechanism), and 2)~adding random minor variations to them (\textsl{mutation} mechanism). The complete description of NSGA-II can be found in~\cite{05:00087}.
As it will be shown, the use of MOEAs provides a quite convenient approach to CSO. However, depending on the scale of the problem, convergence can be slow, especially if computational resources are limited. Thus, based on the insight previously indicated, and in order to provide additional possibilities, Algorithm~\ref{Alg:CSO:MinDist} is also proposed for solving (finding the set $\mathcal{X}^{\star}$ of Pareto efficient solutions) a particular, yet important, case of (\ref{OP:CSO}); when the number of active cells ($f_1$) and the average network capacity ($f_2$) need to be jointly optimized. Given that the need for minimizing the number of transitions is very important from a practical point of view, Algorithm~\ref{Alg:CSO:MinDist} aims at finding a collection of network topologies, all with different number of active BSs, featuring~1)~the minimum distance property, and~2)~acceptable performance. In this context, the word~\textit{distance} refers to the Hamming distance ($d_{\text{H}}$), i.e., the number of positions in which the corresponding symbols in two different solutions are different. In this manner, for two solutions $\mathbf{x}_i$ and $\mathbf{x}_j$ in a set $\mathcal{X}_{\text{MD}}^{\star}$ featuring the minimum distance property, \mbox{$d_{\text{H}}\left(\mathbf{x}_i,\mathbf{x}_j\right)=1\Rightarrow|(\mathbf{x}_i\cdot\mathbf{1})-(\mathbf{x}_j\cdot\mathbf{1})|=1$} always holds. Initially, Algorithm~\ref{Alg:CSO:MinDist} determines the best~topology with~1~active BS~($\mathbf{x}_1$) in line~2. Then, in lines~4-14, for each successive number of active cells ($\text{NAC}=2,~\dotso,~L$), the algorithm sequentially finds the BSs that should be activated (resulting in the solution $\mathbf{x}_j$), such that~1)~the Hamming distance with the previous solution $\mathbf{x}_{j-1}$ is one, and 2)~the function $f_2$ is maximized. Thus, each solution added to $\mathcal{X}^{\star}_{\text{MD}}$ provides the biggest increment in terms of $f_2$ with respect to the one previously added, and only one off/on transition is required. It should be noted that, although not explicitly indicated, Algorithm~\ref{Alg:CSO:MinDist} indeed optimizes not only the number of active base stations and the network capacity, but also the number of transitions when moving from one topology to another. Thus, more than two objetives are jointly considered. The same applies for~\eqref{OP:CSO}, i.e., more than two metrics could be considered, at expense of an increase in complexity, but it should be taken into account that in the context of CSO, a Pareto Front in more than two dimensions could complicate the implementation.
\begin{algorithm}[t]
\caption{Minimum Distance Algorithm~(MDA).}
\label{Alg:CSO:MinDist}
\SetAlgoLined
\SetKwInOut{Input}{input}
\SetKwInOut{Output}{output}
\SetKwFunction{BestBS}{BestBS}
\BlankLine\small
\Input{{\small
$\mathcal{X}_1$: $\mathcal{X}_1=\{ \mathbf{x}\in\mathcal{X}
\hspace{0.075cm}|\hspace{0.075cm}\mathbf{x}\cdot\mathbf{1}=1\}$, $|\mathcal{X}_1|=L$.}} \vspace{-0.0cm}
\Output{{\small $\mathcal{X}^{\star}_{\text{MDA}}$: A set of $L$ network topologies. }}
{\small
$C^{\star}\leftarrow0$;~~$\mathcal{X}^{\star}_{\text{MD}}\leftarrow \emptyset$\;\vspace{-0.0cm}
$\mathbf{x}_1\leftarrow$\BestBS{$\mathcal{X}_1$}\;\vspace{-0.0cm}
$\mathcal{X}^{\star}_{\text{MD}}\leftarrow \mathcal{X}^{\star}_{\text{MD}} \cup\{\mathbf{x}_1\}$\;\vspace{-0.0cm}
\For{\textnormal{\textbf{each}} $j=2:L$}
{\vspace{-0.0cm}
$C^{\star}\leftarrow0$\;\vspace{-0.0cm}
\For{\textnormal{\textbf{each}} $\mathbf{x}\in\mathcal{X}_{j}\hspace{0.1cm}|\hspace{0.1cm}d_{\text{H}}(\mathbf{x},\mathbf{x}_{j-1})=1$}
{\vspace{-0.0cm}
$C_\mathbf{x}\leftarrow f_2(\mathbf{x})$\;\vspace{-0.0cm}
\If{$C_\mathbf{x} > C^{\star}$}
{\vspace{-0.0cm}
$C^{\star}\leftarrow C_\mathbf{x}$\;\vspace{-0.0cm}
$\mathbf{x}_j\leftarrow \mathbf{x}$\;\vspace{-0.0cm}
} \vspace{-0.0cm}
} \vspace{-0.0cm}
$\mathcal{X}^{\star}_{\text{MD}}\leftarrow \mathcal{X}^{\star}_{\text{MD}} \cup\{\mathbf{x}_j\}$\;\vspace{-0.0cm}
}\vspace{-0.0cm}
\textbf{return} $\mathcal{X}^{\star}$\;\vspace{-0.0cm}
}
\end{algorithm}
\subsection{Conceptual design and implementation}\label{Sec:PropFramework_ConceptualDesign}
Figure~\ref{Fig:CONCEPTUAL_DESIGN} illustrates the conceptual design of the proposed multiobjective framework. The framework relies on having a statistical description of the behavior of the service demand (in time and space). Thus, by means of different traffic distributions ($\mathbf{\Gamma}_x$), the spatial component of the traffic at different moments of the day can be captured. These patterns can be considered fairly constant during time intervals
of \textit{small} duration (tens of minutes or few hours)~\cite{04:00225, 04:00236}.
\begin{figure}[t]
\centering
\includegraphics[width = 0.48\textwidth]{ARCHITECTURE01.pdf}
\vspace{-0.25cm}\caption{Conceptual design of the MO framework for CSO.}
\label{Fig:CONCEPTUAL_DESIGN}
\end{figure}
Starting from the knowledge of a given $\mathbf{\Gamma}$, network analysis and optimization based on (\ref{OP:CSO}) is done offline. The main idea is that, for different demand conditions (spatial distribution and volume), different sets of Pareto efficient network topologies can be obtained, i.e., for each $\mathbf{\Gamma}_x$, there is a corresponding $\mathcal{X}^{\star}_x$. These sets of near-optimal solutions ($\mathcal{X}^{\star}_x$'s) can be
evaluated by means of system level simulations (in which several QoS criteria, scheduling policies, and ICI models can be considered independently) in order to determine which network topologies ($\myvec{x}\in\mathcal{X}^{\star}_x$) provide the desired level of QoS. Obviously, the network operator may act rather conservatively in this selection process as it will be explained in Section~\ref{Sec:EvaSetParameters}.
Moreover, in order to allow for semi-distributed implementation, a cluster-based operation is encouraged. The benefit of doing so is twofold. First, the demand in relatively small areas covered by small cells (e.g., pico-cells in a university campus) can be characterized easily. Second, the amount of intercell coordination is reduced compared with the schemes aiming at operating in large urban areas. Since demand profiles are stored and indexed at coordinating points in each cluster, the amount of data that need to be exchanged (from time to time) is negligible. Instead, different clusters (a certain amount of overlapping can be allowed) can also share information in longer time scales, so that better decisions can be made in boundary cells. In any case, the idea of identifying traffic profiles and applying multiobjective-optimized on/off patterns, is compatible with novel paradigms that 1)~are being considered for 5G (\textit{cloud-networking} and \textit{virtualization}~\cite{05:00242, 05:00240}) and~2)~would allow for more dynamic and centralized operation. In addition, several research contributions in the increasingly research field of service demand modeling and pattern recognition~\cite{6966182, 7147784, 6757900} (a research problem out of our scope) are appearing, and hence, the method proposed herein can extensively be benefit from that activity.
\section{Performance Evaluation}\label{Sec:EvaSetParameters}
\subsection{Simulation conditions and parameters}\label{Sec:EvaSetParameters_SimulPar}
\begin{figure}[t]
\centering
\subfloat[Cellular layout.]
{\label{Fig:LAYOUT}
\includegraphics[width = 0.23\textwidth]{LAYOUT2.pdf}}
\subfloat[Spatial service demand ($\mathbf{\Gamma}$).]
{\label{Fig:STD}
\includegraphics[width = 0.23\textwidth]{STD.pdf}}\\[-0.2cm]
\subfloat[CDF of pixel prob. ($\mathbf{\Gamma}(a)$).]
{\label{Fig:STD_CDF}
\includegraphics[width = 0.23\textwidth]{STD_CDF.pdf}}
\subfloat[Power consumption model.]
{\label{Fig:POWER_CONSUMPTION_MODEL}
\includegraphics[width = 0.224\textwidth]{POWER_CONSUMPTION_MODEL.pdf}}
\vspace{-0.05cm}\caption{Test case scenario.}
\label{Fig:TESTCASE}
\end{figure}
The simulation setup is based on the assumptions for evaluating the IMT-Advanced systems~\cite{03:00002}. The urban micro-cell (UMi) downlink scenario was chosen. Fig.~\ref{Fig:LAYOUT} shows the corresponding cellular layout. As it can be seen, the network is composed of 37 small cells (radius = $100\,$m, $\text{network area}\approx1\,\text{km}^2$). Fig.~\ref{Fig:STD} corresponds to the (irregular) spatial service demand distribution ($\myvec{\Gamma}$) used in the numerical examples. The Kullback-Leiber distance $\set{D}$ with respect to the uniform distribution~($\myvec{\Gamma}_{\text{u}}$) can be used as a measure of the non-uniformity of the spatial service demand distribution as it is shown in Figure~\ref{Fig:STD_CDF}. This setting is perfectly valid to study CSO as in this context gains are obtained from the mismatch between demand and supply. Indeed, CSO is about finding the smallest network topology that is \textit{compatible}~\cite{7127727} enough with the service demand to provide the required QoS and coverage.
In this study, a Single-Input Single-Output~(SISO) is considered. This assumption does not imply any loss of generality as long as all cells use the same scheme. The load-dependent power consumption model, based on the parameters given in~\cite{05:00232}, for pico-BSs assuming an operating bandwidth of $5\,$MHz and a maximum transmission power of $30\,$dBm is shown in~Fig.~\ref{Fig:POWER_CONSUMPTION_MODEL}.
Dynamic system level simulations are carried based on Monte~Carlo experiments. The results compile statistics taken from 100~independent experiments each of which has a duration of $5400\,$s. At each cell, the scheduler assigns each user with a bandwidth such that the target rate ($r_{\text{min}}$) is satisfied. If the percentage of users that obtain a rate equal to $r_{\text{min}}$ is greater or equal to the operator-specific target QoS ($Q$), then the QoS policy is said to be fulfilled. Thus, in order to satisfy the maximum number of users, users are sorted based on their spectral efficiency and served accordingly. When there is not enough bandwidth to satisfy a user, the resource allocation ends. The set of parameters used in simulations is provided in Table~\ref{TableEvaluationSetting}. Calibration and complexity aspects of NSGA-II are briefly discussed in Section~\ref{Sec:NumResults_Complexity analysis}, and additional guidelines can be found in~\cite{05:00087, 05:00138}. The experimentally obtained setting is also shown in Table~\ref{TableEvaluationSetting}.
\begin{table*}
\caption{Evaluation setting and parameters.}
\vspace{-0.4cm}
\begin{center}
\begin{tabular}{r l |r l| r l}
\toprule
\multicolumn{6}{c}{{\scriptsize \textbf{General setting}}} \\
{\scriptsize Number of cells~($L$)} & {\scriptsize 37~(wraparound, omni)} & {\scriptsize Carrier freq.} & {\scriptsize 2.140~GHz} & {\scriptsize Bandwidth~($B$)} & {\scriptsize 5~MHz} \\[-0.01cm]
{\scriptsize Max. BS transmit power~($P_{\text{max}}^{\text{Tx}}$)} & {\scriptsize 30~dBm} & {\scriptsize Pixels' resolution} & {\scriptsize $5\times 5$~m$^2$} & {\scriptsize Path loss} & {\scriptsize M.2135 Umi~\cite{03:00002}} \\[-0.01cm]
{\scriptsize BS's height} & {\scriptsize 15~m} & {\scriptsize Noise power~($\sigma^2$)} & {\scriptsize -174~dBm/Hz} & {\scriptsize Shadowing } & {\scriptsize $\set{N}(0.4)~[\text{dB}]$ } \\[-0.01cm]
{\scriptsize Cell selection ($f_c$)} & {\scriptsize Highest Rx. power} & {\scriptsize Rx. power~($P_{\text{min}}$)} & {\scriptsize -123 dBm} & {\scriptsize Small scale fad.} & {\scriptsize As in~\cite{03:00002}} \\[-0.01cm]
{\scriptsize Link performance ($f_{\text{LP}}$)} & {\scriptsize Shannon's formula} & {\scriptsize Frac. comp. ($\kappa_{\text{UL}}$)} & {\scriptsize 1.00} & {\scriptsize Cov. ($\kappa_{\text{COV}}$)} & {\scriptsize 0.02} \\[-0.01cm]
{\scriptsize Max. path loss ($G_{\text{max}}^{\text{UL}}$)} & {\scriptsize 163 dB} & {\scriptsize Min. rate~($r_{\text{min}}$)} & {\scriptsize 400 kbps} & {\scriptsize Target QoS ($Q$)} & {\scriptsize 97.5$\%$} \\[-0.01cm]
{\scriptsize User distribution} & {\scriptsize According to $\myvec{\Gamma}$} & {\scriptsize Traffic model} & {\scriptsize Full buffers} & {\scriptsize SINR~($\psi_{\text{min}}$)} & {\scriptsize -7.0 dB} \\[-0.01cm]
{\scriptsize QoS checking interval} & {\scriptsize $1\,\text{s}$} & {\scriptsize } & {\scriptsize } & {\scriptsize } & {\scriptsize } \\[-0.01cm]
\multicolumn{6}{c}{{\scriptsize \textbf{Calibration of NSGA-II}}}\\
{\scriptsize Population size} & {\scriptsize 100} & {\scriptsize Crossover. prob.} & {\scriptsize 1.00} & {\scriptsize Type of var.} & {\scriptsize Discrete} \\[-0.01cm] {\scriptsize Mutation prob.} & {\scriptsize $1/L$} & {\scriptsize Termination crit.} & \multicolumn{3}{l}{{\scriptsize Hypervolume $<0.001\%$, \cite{08:00044}}} \\[-0.01cm]
\bottomrule
\end{tabular} \end{center}
\label{TableEvaluationSetting}
\end{table*}
\vspace{-0.0cm}\begin{figure}
\centering
\subfloat[Coverage maps.]
{\label{Fig:CoverageMaps}
\includegraphics[width = 0.235\textwidth]{CoverageMaps2.pdf}}
\subfloat[Coverage vs. Tx power.]
{\label{Fig:CoverageVsTxPower}
\includegraphics[width = 0.235\textwidth]{CoverageVsTxPower.pdf}}\\[-0.2cm]
\subfloat[Detectable cells.]
{\label{Fig:ServersOverlapping2}
\includegraphics[width = 0.235\textwidth]{ServersOverlapping2.pdf}}
\subfloat[Candidate servers.]
{\label{Fig:ServersOverlapping11}
\includegraphics[width = 0.235\textwidth]{ServersOverlapping11.pdf}}
\vspace{-0.1cm}\caption{Coverage aspects: impact of transmit power.}
\label{Fig:CoverageTxPow}
\end{figure}
\subsection{Coverage aspects}\label{Sec:NumResults_Cov}
The first part of this section is devoted to illustrate some coverage aspects and provides insights into the potential impact of the transmit power on the performance of CSO. Fig.~\ref{Fig:CoverageMaps} provides a qualitative perspective. The figure shows the size of the maximum coverage (points in which the received PS power is greater than $P_{\text{min}}$) for the central BSs ($l=0$) for two different transmit powers ($P_{\text{max}}=18\,$dBm and $P_{\text{max}}=33\,$dBm). For the sake of clarity, shadowing is not considered. A quantitative description is shown in Fig.~\ref{Fig:CoverageVsTxPower} which indicates the percentage of the target area~($\set{A}$) that can be covered with different values of $P_{\text{max}}$. Note for instance that, starting from $18\,$dBm~($15\,\%$ of coverage), $P_{\text{max}}$ need to be increased more than eight times (up to $30\,$dBm) to double the coverage (up to $30\,\%$), while reaching $60\,\%$ of coverage requires less than four times the power required for $30\,\%$ of coverage. Obviously, this depends on the propagation model, but the message is that this analysis should be taken into account during the design phase of any CSO strategy in order to determine appropriate values for $P_{\text{max}}$. In the results shown in Figs.~\ref{Fig:ServersOverlapping2}~and~\ref{Fig:ServersOverlapping11}, all the cells are active and transmit at the same~$P_{\text{max}}$. Fig.~\ref{Fig:ServersOverlapping2} indicates the average number of BS that can be \textit{detected} as a function of $P_{\text{max}}$~(the average is taken over the whole coverage area). Fig.~\ref{Fig:ServersOverlapping11} shows the percentage of the coverage area in which $x$ BSs (servers) are \textit{heard} with a quality~(SINR) within $X\,$dB below the one of the best server. From these results, it becomes clear that the choice of $P_{\text{max}}$ has a big influence on the size of the feasible set in (\ref{OP:CSO}), i.e., the set of $\myvec{x}$'s for which Constraint~\ref{OP:CSO:C1} is fulfilled. Hence, the impact of $P_{\text{max}}$ is significant, mainly in low load conditions
\subsection{Estimation of network topologies}\label{Sec:NumResults_NetTop}
\begin{figure}
\centering
\subfloat[Capacity: MOEA vs. MDA.]
{\label{Fig:PARETO_FRONT_MOEA_MDA}
\includegraphics[width = 0.235\textwidth]{PARETO_FRONT_MOEA_MDA.pdf}}
\subfloat[Gains: MOEA vs. MDA.]
{\label{Fig:PARETO_FRONT_MOEA_MDA_GAINS}
\includegraphics[width = 0.235\textwidth]{PARETO_FRONT_MOEA_MDA_GAINS.pdf}}\\[-0.2cm]
\subfloat[Cell edge performance.]
{\label{Fig:PARETO_FRONT_P5_NEL}
\includegraphics[width = 0.235\textwidth]{PARETO_FRONT_P5_NEL.pdf}}
\subfloat[Uplink Tx power.]
{\label{Fig:PARETO_FRONT_UPC_NEL}
\includegraphics[width = 0.235\textwidth]{PARETO_FRONT_UPC_NEL.pdf}}
\vspace{-0.03cm}\caption{Multiobjective optimization results.}
\label{Fig:NO_CELL_COUPLING_PFs}
\end{figure}
\begin{figure*}[t]
\centering
\subfloat[Load sharing.]
{\label{Fig:CV_LOADS}
\includegraphics[width = 0.26\textwidth]{CV_LOADS.pdf}}
\subfloat[Impact of load.]
{\label{Fig:CV_PC_LOAD}
\includegraphics[width = 0.26\textwidth]{CV_PC_LOAD.pdf}}
\subfloat[MO (Load = $0.6\cdot C_{\text{Max}}$).]
{\label{Fig:CV_PC_MO}
\includegraphics[width = 0.26\textwidth]{CV_PC_MO.pdf}}
\vspace{-0.10cm}\caption{Analysis considering cell coupling and load-dependent power consumption.}
\label{Fig:CELL_COUPLING_BASED_ANALYSIS}
\end{figure*}
First, the results regarding the solution of~(\ref{OP:CSO}) for the objectives functions introduced in Subsection~\ref{Sec:PropFramework_ProbForm_FL}~($f_1,\,f_2,\,f_3,\,\text{and}\,f_4$) are provided. Fig.~\ref{Fig:PARETO_FRONT_MOEA_MDA} shows the resulting Pareto Front by solving~(\ref{OP:CSO}), when $i=1\,\text{and}\,j=2$ in~(\ref{OP:CSO:MAIN}), i.e., the joint optimization of the number of active BS ($f_1$) and the average network capacity~($f_2$), by means of MOEAs (algorithm NSGA-II) and Algorithm~\ref{Alg:CSO:MinDist}. As expected, the use of evolutionary optimization provides \textit{better} solutions than Algorithm~\ref{Alg:CSO:MinDist}, i.e., greater values of $f_2$ for the same value of $f_1$. However, it is important to recall that the solutions obtained through Algorithm~\ref{Alg:CSO:MinDist} feature the minimum distance property (see Section~\ref{Sec:PropFramework_ProbForm_MOPF}), and that, Algorithm~\ref{Alg:CSO:MinDist}~($\mathcal{O}(L^2)$) is, in case of small-to-moderate cluster size, less complex than NSGA-II ($\set{O}(N^2\cdot |\set{F}|)$, $N$: population size). A quantitative perspective of such performance gap is shown in Fig.~\ref{Fig:PARETO_FRONT_MOEA_MDA_GAINS}. The blue/circle pattern corresponds to the gain in terms of $f_2$ for each value of $f_1$ indicated in the left vertical axis as `Average capacity gain'. As a result of the combinatorial nature of NSGA-II, the gains are higher when network topologies are composed of less BSs, i.e., small values of $f_1$. The red/square pattern shows the capacity gain per cell, indicated in the right vertical axis. It can be seen that the gain of using MOEA is around $1\,\text{Mbps/cell}$ in topologies with less than 20 active BSs~($f_1\leq20$). Hence, the use of MOEAs implies better network topologies in cases where the computational complexity can be afforded. The resulting Pareto Front by solving~(\ref{OP:CSO}), for ($i=1,\,j=3$) and ($i=1,\,j=4$) in~(\ref{OP:CSO:MAIN}), are shown in Figs.~\ref{Fig:PARETO_FRONT_P5_NEL}~and~\ref{Fig:PARETO_FRONT_UPC_NEL}, respectively. The first case illustrates the impact of CSO on cell edge performance. Note that while Fig.~\ref{Fig:PARETO_FRONT_MOEA_MDA} shows a fairly linear growth of the average network capacity with the number of active cells, Fig.~\ref{Fig:PARETO_FRONT_P5_NEL} indicates that cell edge performance (represented by $f_3$) is substantially improved only by network topologies featuring a higher number of active cells ($f_1\geq27$). This result clearly suggests that mechanisms for Intercell Interference Coordination~(ICIC) should be applied together with CSO in cases of low load conditions to improve the QoS of cell edge users. Fig.~\ref{Fig:PARETO_FRONT_UPC_NEL} illustrates the impact of CSO on the power consumption of users (uplink). As it was mentioned, the goal is not to determine exact uplink power consumption figures, but to create means for comparison among network topologies with different number of active BSs. Thus, a normalized version of $f_4$ (see~\ref{Eq:CSO_fUPLPC}) is considered. As it can be seen, it turns out that the relationship between the number of active BSs and the resulting uplink (open-loop-based) power consumption is highly nonlinear, being the energy expenditure considerably high in sparse network topologies~($f_1<15$). Hence, in scenarios where the lifetime of devices should be maximized (sensor networks), the use of CSO is not clear. Recall that uplink link budget is also considered as a coverage criterion.
To close this subsection, Fig.~\ref{Fig:CELL_COUPLING_BASED_ANALYSIS} shows the results corresponding to the solution of~(\ref{OP:CSO}) for the objective functions introduced in Section~\ref{Sec:PropFramework_ProbForm_FL}~($f_5\,\text{and}\,f_6$). According to Definition~\ref{Def:NetCap}, and given the spatial demand distribution~$\myvec{\Gamma}$~(see Fig.~\ref{Fig:STD}), \mbox{$\mathbb{E}\{\lambda\}=115.0\,\text{ms}$} and \mbox{$\mathbb{E}\{\mu\}=119.2\,\text{s}$} yield a demand volume ($V$) equal to $V_{\text{Cap}}$. The resulting load sharing patterns (obtained by means of Algorithm~\ref{Alg:IterAproxLoads}) for \mbox{$V=V_{\text{Cap}}$} and \mbox{$V=0.5\cdot V_{\text{Cap}}$} are shown in Fig.~\ref{Fig:CV_LOADS}. Note that increasing~$V$ results in higher load dispersion. To quantify this, Fig.~\ref{Fig:CV_PC_LOAD} shows the impact of~$V$ on the Coefficient of Variation~(CV) of the loads~($f_6$). The associated load-dependent power consumption~($f_5$) is also indicated. Note that $f_5$ and $f_6$ are maximized when \mbox{$V=V_{\text{Sat}}$} and \mbox{$V=V_{\text{Cap}}$}, respectively. As expected, the load dependent power consumption ($f_5$) is maximized when $\bar{\boldsymbol{\alpha}}\geq\myvec{1}$, i.e., $V\geq V_{\text{Sat}}$. The dependence of $f_6$ on $V$ is explained by the strong nonlinearity of~(\ref{Eq:NELoadStatistically_2}) and the fact that, from the load-coupling point of view, $\bar{\boldsymbol{\alpha}}\leq\myvec{1}$, and hence, no change is expected after \mbox{$V=V_{\text{Sat}}$}. The results shown in Figs.~\ref{Fig:CV_LOADS}~and~\ref{Fig:CV_PC_LOAD} are obtained for $\myvec{x}=\myvec{1}$, i.e., when all the BSs are active. The joint optimization of $f_5$~and~$f_6$ is shown in Fig.~\ref{Fig:CV_PC_MO}. As it can be seen, there is a conflicting relationship between them. The attributes of the \textit{extreme} solutions ($\myvec{x}_{\text{A}}$ and $\myvec{x}_{\text{B}}$) in the Pareto Front are indicated. There is also a certain correlation between the objectives ($f_5$ and $f_6$) and the number of active cells~(NAC). The topology with the lowest energy consumption~($f_5$) requires less active BSs but it has the highest load dispersion ($f_6$). Note the difference between the highest and lowest loaded BS in $\myvec{x}_{\text{A}}$. In contrast, the best load balancing~($\myvec{x}_{\text{B}}$) involves more active BSs, and hence, worst values of $f_5$. A comparison among solutions obtained through each ICI model, FL and LC, is provided~next.
\subsection{System level simulations}\label{Sec:NumResults_SysLevSim}
As indicated earlier, solving (\ref{OP:CSO}) results in a set of Pareto efficient (nondominated) network topologies that are specific for either a spatial service demand distribution ($\set{X}_{\text{FL}}$: full-load) or a service demand conditions, i.e., spatial demand distribution plus volume ($\set{X}_{\text{LC}}$: load-coupling). Recall that $\set{X}_{\text{FL}}$ is obtained by joint optimizing $f_1$ and $f_2$ in (\ref{OP:CSO}) for a given spatial demand distribution ($\myvec{\Gamma}$), while obtaining $\set{X}_{\text{LC}}$ involves the joint optimization of $f_5$ and $f_6$ in (\ref{OP:CSO}) for a given $\myvec{\Gamma}$ and $V$ (volume). Note that, the `full-load' analysis is volume-independent, and hence, it does not require specify $V$ (full load is assumed for the active cells).
\begin{figure*}[t]
\centering
\subfloat[Power consumption.]
{\label{Fig:COMPARATIVE_C_NC_LOAD}
\includegraphics[width = 0.245\textwidth]{COMPARATIVE_C_NC_LOAD.pdf}}
\subfloat[$V=0.2\cdot V_{\text{Cap}}$.]
{\label{Fig:COMPARATIVE_C_NC_LOAD_DOT2}
\includegraphics[width = 0.364\textwidth]{COMPARATIVE_C_NC_LOAD_DOT2.pdf}}
\subfloat[$V=0.6\cdot V_{\text{Cap}}$.]
{\label{Fig:COMPARATIVE_C_NC_LOAD_DOT6}
\includegraphics[width = 0.364\textwidth]{COMPARATIVE_C_NC_LOAD_DOT6.pdf}}
\vspace{-0.05cm}\caption{Comparative analysis: Load-coupling vs. Full ICIC MO optimization.}
\label{Fig:COMPARATIVE}
\end{figure*}
\begin{figure*}[t]
\centering
\subfloat[Number of active cells.]
{\label{Fig:BENCH_NEL}
\includegraphics[width = 0.475\textwidth]{BENCH_NEL.pdf}}
\subfloat[QoS.]
{\label{Fig:BENCH_QoS}
\includegraphics[width = 0.475\textwidth]{BENCH_QoS.pdf}}\\[-0.05cm]
\subfloat[Key performance indicators.]
{\label{Fig:BENCH_BARS}
\includegraphics[width = 0.780\textwidth]{BENCH_BARS.pdf}}
\vspace{-0.1cm}\caption{Performance comparisons.}
\label{Fig:PER_COMP}
\end{figure*}
Thus, in order to evaluate these solutions by means of system level simulations, it is initially assumed that at each QoS checking interval (evaluation parameters are shown in Table~\ref{TableEvaluationSetting}), the (nondominated) network topologies of each set ($\set{X}_{\text{FL}}$~and~$\set{X}_{\text{LC}}$) are all applied and evaluated. The goal is to create QoS statistics for each network topology and load condition. Then, the network topology that is able to provide the desired QoS ($Q\,\%$ of users are satisfied $Q\,\%$ of time) is selected and applied (as indicated in Subsection~\ref{Sec:PropFramework_ConceptualDesign}).
The comparative assessment is shown in Fig.~\ref{Fig:COMPARATIVE}, where the legends indicate the set the applied network topology belongs to ($\set{X}_{\text{FL}}$ or $\set{X}_{\text{LC}}$) and the ICI model (FL or LC) used in the system level trials. Fig.~\ref{Fig:COMPARATIVE_C_NC_LOAD} shows the load-dependent power consumption of each network topology. Clearly, from the CSO point of view, the topologies in $\set{X}_{\text{LC}}$ result in lower power consumption as they feature less active BSs (NAC is indicated in green boxes) given that the load-coupling model predicts better SINR than full-load~(see~Fig.~\ref{Fig:SINR_Bound}), and hence, network capacity is favored. However, as $V$ increases, both models become somehow equivalent as the loads tend to 1; as a result, the energy consumption is quite similar. Figs.~\ref{Fig:COMPARATIVE_C_NC_LOAD_DOT2}~and~\ref{Fig:COMPARATIVE_C_NC_LOAD_DOT6} show the QoS level (in terms of the number of satisfied users) that is obtained with the selected solution of each set for $V=0.2\cdot V_{\text{Cap}}$ and $V=0.6\cdot V_{\text{Cap}}$, respectively. The results make evident that the performance of the network topologies in $\set{X}_{\text{LC}}$ is severely degraded if the ICI levels become higher than the ones from which they were calculated for, see~$\set{X}_{\text{LC}}$@FL (full ICI). Indeed, the performance of these solutions is sensitive to variations from the mean values (that happens when considering snapshots) in moderate-to-high load conditions, even when the load-coupling based ICI is considered, as seen in Fig.~\ref{Fig:COMPARATIVE_C_NC_LOAD_DOT6} for $\set{X}_{\text{LC}}$@LC. On the other hand, the network topologies in $\set{X}_{\text{FL}}$ provide consistent performance when they are evaluated under full load ($\set{X}_{\text{FL}}$@FL), and obviously, provide an even better performance under load-coupling~($\set{X}_{\text{FL}}$@LC) for both demand volumes. Hence, given that the energy consumption gain is in the order of $10\,\%$ in the best case, it can be concluded that the full load model provides a competitive and somehow \textit{safer} energy-saving vs. QoS tradeoff in the context of CSO. The proposed CSO scheme can use either approach. Summarizing:
{\renewcommand{\labelitemi}{$\checkmark$}
\begin{itemize}
\item The MO for FL, i.e., $f_1$ and $f_2$ in (\ref{OP:CSO}), is volume-independent; offline system level simulations are required for each load condition ($V$), and energy saving is smaller in comparison to~LC.
\item In MO for LC, i.e., $f_5$ and $f_6$ in (\ref{OP:CSO}), is volume dependent; different offline optimization procedures are required for each load condition ($V$), and energy saving is larger in comparison to~FC.
\end{itemize}
\subsection{Performance comparison}\label{Sec:NumResults_PerComp}
In order to provide a wide perspective of the merit of the CSO framework presented herein, several recent/representative CSO schemes have been used as baselines. Obviously, an exhaustive comparison is not feasible. However, the idea is to illustrate some \textsl{pros} and \textsl{cons} of different approaches and the impact of some design assumptions. The following benchmarks are considered:
\begin{itemize}[leftmargin=0.3cm]
\item \textsl{Cell zooming}: It was proposed in~\cite{05:00125}. The idea is to sequentially switch-off BS starting from the lowest loaded. The algorithm ends when a cell cannot be switched-off because at least one user cannot be \mbox{re-allocated.}
\item \textsl{Improved cell zooming}: This scheme is presented in~\cite{04:00212} and it is similar to the one in~\cite{05:00125}, but it includes a more flexible termination criterion that allows to check more cells before terminating, and so, more energy-efficient topologies can be found.
\item \textsl{Load-and-interference aware CSO}: The design of this CSO scheme presented in~\cite{04:00341} takes into account both the received interference and load of each cell to create a ranking that is used to sequentially switch-off the cells whose load is below a certain threshold.
\item \textsl{Set cover based CSO}: The CSO scheme proposed in~\cite{04:00342} relies on the idea of switch-on BS sequentially according to a certain sorting criterion. In this work, the sorting criterion is based on the number of users a cell can served in the SNR regime.
\end{itemize}
The performance comparison is shown in Fig.~\ref{Fig:PER_COMP}. To make the comparison fair, the full-load ICI conditions are considered. Figs.~\ref{Fig:BENCH_NEL}~and~\ref{Fig:BENCH_QoS} show the average number of active cells and QoS (for different service demand volumes), respectively. As it can be seen, the best energy saving is obtained by~\cite{04:00341}, although at the expense of QoS degradations. This is due to the fact that in~\cite{04:00341}, users can be easily put in outage. In contrast, CSO schemes such as~\cite{04:00212, 05:00125, 04:00342} provide the desired QoS (as long as $V\leq V_{\text{Cap}}$) since CSO decisions require associating all users. However, this results in an increment in the average number of active cells with respect to~\cite{04:00341}. The schemes labeled as `MDA' and `MOEA' correspond to the (infeasible) dynamic selection of network topologies from the sets $\set{X}_{\text{FL}}$ obtained through Algorithms~\ref{Alg:CSO:MinDist} and NSGA-II, respectively, which are shown as reference. The performance of the proposed MO CSO is indicated by red boxes and labeled as `MO~CSO'. As it can be seen, the proposed scheme provides an excellent tradeoff between the required number of active cells and the obtained QoS, especially when $V\geq V_{\text{Cap}}$ where the performance (QoS) of other CSO is compromised. However, the most significant enhancement in the proposed scheme is its feasibility. Fig.~\ref{Fig:BENCH_BARS} shows four performance indicators: transitions, handovers, QoS, and NAC. Given that the network topologies are calculated offline, they can be evaluated extensively by means of system level simulations (under a wide range of coverage criteria and conditions) to further guarantee their real-time performance, i.e., the operator can select topologies with more active cells rather than the ones which strictly need to guarantee QoS. Therefore, the selected network topologies can be applied (without real-time complexity) during periods of time in which service demand is described by $\myvec{\Gamma}$; as a result, no transitions or handovers are induced due to CSO. Hence, feasible yet effective CSO performance is achieved. As it was shown earlier, the proposed framework is generic, flexible, and no assumption are made in regards to, for instance, the cellular layout or objective functions; as a result, the framework is also suitable for small-cell deployments where irregular topologies and heterogeneous demand conditions are expected.
\subsection{Complexity analysis and calibration aspects}\label{Sec:NumResults_Complexity analysis}
To close this section, a complexity overview of the optimization algorithms is provided.
According to~\cite{05:00087}, the complexity of NSGA-II is $\mathcal{O}(M\cdot N^2)$, where $M$ and $N$ correspond
to the population size and the number of objective functions, respectively. In our case, $N=2$ and $M$ can be
set depending on the scale of the problem. However, there is a consensus about the size of the population
when using genetic algorithms, such as NSGA-II, and it is considered that during calibration populations
of 20 up to 100 individuals can be used. Values greater than 100 hardly achieve significant gains and
the same global convergence is obtained~\cite{spall2005introduction}. Regarding Algorithm~\ref{Alg:CSO:MinDist},
it's complexity is $\mathcal{O}(L^2)$, where $L$ is the number of cells in the network. In practice, $L^2\ll M\cdot N^2$ which is a significant reduction
in terms of complexity that comes at expense of some performance. In evolutionary algorithms, a termination criterion is usually defined/need. One metric
used to measure the level of convergence is the the \textsl{hypervolume} indicator~\cite{08:00052}. It reflects the size of volume dominated
by the estimated Pareto Front. In this work, the seacrh is terminated if the improvement in the hypervolume is smaller than a threshold~(0.001\%) after a certain number of
generations (in this study, 20). Finally, crossover and mutation probabilities are set to $1$ and $1/L$ (one mutation per solution, on average), respectively, as indicated in Table~\ref{TableEvaluationSetting}.
}
\section{Conclusions and Research Directions}\label{Sec:Conclusions}
CSO is a promising strategy that allows significant energy saving in cellular networks where both radio access network~(capacity supply) and service demand are heterogeneous. In this article~1)~CSO has been carefully analyzed considering coverage criteria, ICI models, and practical aspects, such as network-initiated handovers and on-off/off-on transitions, and~2)~a novel MO-based~CSO scheme has been introduced. The proposed solution succeeds in minimizing the number of transitions and handovers caused by the CSO operation and it is able to operate without need for heavy computational burden as the core processing is done offline. In addition, a cluster based-operation have been proposed to allow for semi-distributed implementation. The results show that, when compared with previous proposals, the proposed solution provides competitive performance in terms of QoS and energy saving while offering clear advantages from the feasibility perspective as it reduces the number of handovers and transitions.
The results also highlight the importance of considering coverage criteria (in downlink and uplink) and pay attention to the selection of operational parameters, e.g., the power allocated to PS (typically used as criterion for coverage). \vspace{-0.05cm}
A comparative analysis between ICI models (full-load and load-coupling) indicates that the full-load assumption is a \textit{safe} approach in the context of CSO as it provides natural protection against deviations from average load values that are 1) used as input of the algorithm, and~2)~inherent of real time operation, i.e., discrete realizations of users.
The impact of CSO on the power consumption of UE has also been studied. The results indicate that sparse topologies (few active BSs) have a significant impact on uplink power consumption, and hence, CSO is not suitable for scenarios with energy-sensitive devices such as sensor networks.
Research on topology adaptation has still a long way until its maturity. Feasible and effective techniques for traffic pattern recognition to complement CSO are still in infancy. It is our strong belief that CSO, as a promising approach to \textit{greener} networks, is a key piece of a more general set of capabilities that will appear in 5G networks, also including promizing and disruptive concepts, such as Downlink Uplink Decoupling~(DUDe). DUDe, where user equipment can transmit and receive to and from different base stations, is indeed, a clear research direction from the perspective of CSO, where both uplink and downlink could be considered as \textit{independent} networks.
\section*{Acknowledgment}
The authors would like to thank Tamer Beitelmal from Carleton University, and Dr. Ngoc Dao from Huawei Canada Research Centre, for their valuable feedback. This work was supported by the Academy of Finland (grants 287249 and 284811). Mario García-Lozano is funded by the Spanish National Science Council through the project \mbox{TEC2014-60258-C2-2-R}.
\vspace{-0.4cm}
\appendices
\section{Iterative approximation of cell loads}\label{App:LoadCoupling}
In order to estimate the average load vector ($\bar{\boldsymbol{\alpha}}$), Algorithm~\ref{Alg:IterAproxLoads} is proposed.
Basically, the estimation of the average load at each cell ($\bar{\alpha}_l$) is refined through each iteration comprising Lines~\ref{Alg1_l4}~to~\ref{Alg1_OuterLoop2}. In line~\ref{Alg1_Load}, the function~\ttfamily Load()\rmfamily~estimates each $\bar{\alpha}$, based on (\ref{Eq:NELoadStatistically_2}), from the values of previous iterations (where \mbox{$\bar{\alpha}_l=\text{min}\{1,\bar{\alpha}_l\}$}) and the ones that have been just updated in the current iteration (this \textit{fast} update is done in line~\ref{Alg1_innerLoop2}). Fig.~\ref{Fig:ITER_LOAD_ALG} illustrates the motivation and performance of Algorithm~\ref{Alg:IterAproxLoads}. Basically, the use of load coupling provides a more accurate estimation of ICI levels in the network as shown in Fig.~\ref{Fig:SINR_Bound}. Note that the use of Full ICIC represents a more \textit{conservative} approach. Fig.~\ref{Fig:ITER_LOAD} shows that Algorithm~\ref{Alg:IterAproxLoads} only requires few iterations to converge and that this depends on the starting point, but in any case convergence is fast.
\begin{algorithm}[t]
\SetAlgoLined
\SetKwInOut{Input}{Inputs}
\SetKwInOut{Output}{Output}
\SetKwFunction{Load}{Load}
\SetKwFunction{Sort}{Sort}
\BlankLine\small
\Input{{\small~All relevant information and $\epsilon$ (termination).\\
}}
\Output{{\small~$\bar{\boldsymbol{\alpha}}\in\spc{R}_{+}^{|\set{L}|}$: Load vector.
}}
\BlankLine
$\boldsymbol{\bar{\alpha}}^{0}\leftarrow\myvec{1}$; $\boldsymbol{\epsilon}\leftarrow\epsilon\cdot\myvec{1}$; $k\leftarrow 0$\tcc*[r]{{\footnotesize Initializing}}\label{Alg1_l1}\vspace{-0.0cm}
\Repeat{$\boldsymbol{\epsilon}>\frac{|\boldsymbol{\bar{\alpha}}^{k}-\boldsymbol{\bar{\alpha}}^{*}|}{\boldsymbol{\bar{\alpha}}^{*}}$}{\vspace{-0.0cm}
$k\leftarrow k+1$\label{Alg1_l4}\;\vspace{-0.0cm}
$\boldsymbol{\bar{\alpha}}^{*}\leftarrow \boldsymbol{\bar{\alpha}}^{k-1}$\label{Alg1_l5}\;\vspace{-0.0cm}
\For{$l=1:|\set{L}|$}
{\vspace{-0.0cm}
$\bar{\alpha}_l^{k}\leftarrow$\Load{~$\{\bar{\alpha}_{j}^{k-1}:(\forall j\in\set{L}) \wedge (j\neq l)\}$}\label{Alg1_Load}\;\vspace{-0.0cm}
$\bar{\alpha}_l^{k-1}\leftarrow\bar{\alpha}_l^{k}$\tcc*[r]{{\footnotesize Fast update}} \label{Alg1_innerLoop2}\vspace{-0.0cm}
} \vspace{-0.0cm}
$\boldsymbol{\bar{\alpha}}^{k}\leftarrow[\bar{\alpha}_0^{k}\,\cdots\,\bar{\alpha}_{L-1}^{k}]$\tcc*[r]{{\footnotesize Update: iteration $k$}}\label{Alg1_OuterLoop2} \vspace{-0.0cm}
}\vspace{-0.0cm}
\textbf{return}~~$\boldsymbol{\bar{\alpha}}^{k}$\tcc*[r]{{\footnotesize Return estimated load vector}} \vspace{-0.0cm}
\caption{Iterative approximation of cells load.}
\label{Alg:IterAproxLoads}
\end{algorithm}
\begin{figure}[t]
\centering
\subfloat[Bounds of SINR distributions.]
{\label{Fig:SINR_Bound}
\includegraphics[width = 0.43\textwidth]{SINR_Bound.pdf}}\\[-0.015cm]
\subfloat[Iterative load estimation.]
{\label{Fig:ITER_LOAD}
\includegraphics[width = 0.43\textwidth]{ITER_LOAD.pdf}}
\vspace{-0.10cm}\caption{Impact of cell load coupling on SINR distributions.}
\label{Fig:ITER_LOAD_ALG}
\end{figure}
{\footnotesize
|
{'timestamp': '2016-11-07T02:03:57', 'yymm': '1506', 'arxiv_id': '1506.05595', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05595'}
|
arxiv
|
\section{Introduction}
Linear loops are an ubiquitous programming template. Linear loops iterate
over continuous variables, which are updated with a linear transformation.
Linear loops may be guarded, i.e., terminate if a given linear condition
holds. Inputs from the environment can be modelled by means of
non-deterministic choices within the loop. These features make linear loops
expressive enough to capture the dynamics of many hybrid dynamical models.
The usage of such models in safety-critical embedded systems makes linear
loops a fundamental target for formal methods.
Many high-level requirements for embedded control systems can be modelled as
safety properties: the problem is deciding reachability of certain ``bad
states'', in which the system exhibits unsafe behaviour. Bad states may, in
linear loops, be encompassed by guard assertions.
Reachability in linear programs, however, is a formidable challenge for automatic analysers:
the problem is undecidable despite the restriction to linear transformations
(i.e., linear dynamics) and linear guards.
Broadly, there are two principal approaches to safety problems. The first
approach is to attempt to infer a \emph{loop invariant}, i.e., an
inductive set of states that includes all reachable states. If the computed
invariant is disjoint from the set of bad states, this proves that
the latter are unreachable and hence that the loop is safe. However,
analysers frequently struggle to obtain an invariant that is precise enough
with acceptable computational cost. The problem is evidently exacerbated by
the presence of non-determinism in the loop, which corresponds to the case of
open systems. Prominent representatives of this analysis approach include
Passel~\cite{johnsonpassel}, Sting~\cite{colon2003linear}, and abstract
interpreters such as \textsc{Astr\'ee} \cite{BCC+03} and
InterProc~\cite{jeannet2010interproc}.
The second approach is to surrender exhaustive analysis over the infinite time horizon,
and to restrict the exploration to system dynamics up to some given finite time bound.
Bounded-time reachability is decidable, and decision procedures
for the resulting satisfiability problem have made much progress in the past
decade. The precision related to the bounded analysis is offset by the
price of uncertainty: behaviours beyond the given time bound are not
considered, and may thus violate a safety requirement.
Representatives are STRONG~\cite{DRJ13} and SpaceEx~\cite{FLD+11}.
The goal of this paper is to push the frontiers of unbounded-time
reachability analysis: we aim at devising a method that is able to
reason soundly about unbounded trajectories. We present a new
approach for performing \emph{abstract acceleration}. Abstract
acceleration~\cite{GH06,JSS14,GS14} captures the effect of an
arbitrary number of loop iterations with a single, non-iterative
transfer function that is applied to the entry state of the loop
(i.e., to the set of initial conditions of the linear dynamics). The
key contribution of this paper is to lift the restriction
of~\cite{JSS14} to closed systems, and thus to allow for the presence of
non-determinism.
We summarise next the contributions of this work:
\begin{enumerate}
\item We present a new technique to include inputs (non-determinism) in the abstract acceleration of general linear loops, thus overcoming its greatest limitation.
\item We introduce the use of support functions in complex spaces, in order to increase the precision of previous abstract acceleration methods.
\item By extending abstract acceleration and combining it with the use of support functions,
we produce a time-unbounded reachability analysis that overcomes the main barrier of state-of-the-art techniques and tools for linear hybrid systems with inputs.
\item We employ floating point computations associated to bounded error quantification,
to significantly increase the speed and scalability of previous
abstract acceleration techniques, while retaining soundness.
\end{enumerate}
\subsubsection*{Related work} \label{sec:rw}
We review contributions within the two main perspectives in reachability
analysis of hybrid systems, dealing respectively with bounded- and
unbounded-time problems.
The first approach deals with bounded-time horizons:
set-based simulation
methods generalise guaranteed integration~\pponly{\cite{Loe88}}\rronly{\cite{Loe88,Bou08}}
from enclosing intervals to relational domains. They use precise
abstractions with low computational cost to over-approximate sets
of reachable states up to a given time horizon.
Early tools used polyhedral sets (\textsc{HyTech}~\cite{HHW97},
\textsc{PHAVer}~\cite{Fre05}),
polyhedral flow-pipes~\cite{CK98},
ellipsoids~\cite{BT00} and zonotopes~\cite{Gir05}.
A breakthrough has been achieved by~\cite{GLM06,LG09}, with the
representation of convex sets using template polyhedra and support
functions. This method is implemented in the
tool~\textsc{SpaceEx}~\cite{FLD+11}, which can handle dynamical systems with
hundreds of variables.
It performs computations using floating-point numbers: this is a
deliberate choice to boost performance, which, although quite reasonable, is
implemented in a way that is unsound and that does not provide genuine formal
guarantees.
Other approaches use specialised constraint solvers (HySAT~\cite{FH07},
iSAT~\cite{EFH08}), or SMT encodings~\cite{CMT12,GT08} for bounded model
checking of hybrid automata.
The second approach, epitomised in static analysis methods~\cite{HRP94},
explores unboun\-ded-time horizons. It employs conservative
over-approximations to achieve completeness and decidability over infinite
time horizons.
Early work in this area has used implementations of abstract interpretation
and widening~\cite{CC77}, which are still the foundations of most modern tools.
The work in~\cite{HRP94} uses
abstract interpretation with convex polyhedra over piecewise-constant
differential inclusions.
\cite{DG11a} employs optimi\-sation-based (max-strategy iteration) with linear
templates for hybrid systems with linear dynamics.
Relational abstractions \cite{ST11} use ad-hoc ``loop summarisation''
of flow relations,
whilst abstract acceleration focuses on linear relations
analysis~\cite{GH06,GS14}, which is common in program analysis.
Abstract acceleration has been extended from its original version to encompass inputs over
reactive systems~\cite{SJ12} but restricted to subclasses of linear
loops, and later to general linear loops but without
inputs~\cite{JSS14}. This paper lifts these limitations by presenting
abstract acceleration for \emph{general} linear loops \emph{with} inputs.
\section{Preliminaries} \label{sec:prelim}
Abstract acceleration~\cite{GH06,GS14} is a key technique
for the verification of programs with loops. The state of the art for this
technique has reached the level where we can perform abstract acceleration
of general linear loops without inputs~\cite{JSS14}, and of some subclasses
of linear loops with inputs~\cite{SJ10,SJ12}, to an acceptable degree of
precision. We develop an abstract acceleration technique for \emph{general} linear loops \emph{with
bounded inputs}, whilst improving the precision and ease of computation, in
order to overcome the negative effects caused on the over-approximation by
the presence of bounded non-determinism.
\subsection{Model Syntax} \label{sec:syntax}
We are interested in loops expressed in the form:
\begin{displaymath}
\mathit{while}(\mat{G}\vec{x} \leq \vec{h})\ \ \vec{x} := \mat{A}\vec{x}+\mat{B}\vec{u},
\end{displaymath}
where $\vec{x} \in \mathbb{R}^p$ are the state variables,
$\psi := \mat{G}\vec{x} \leq \vec{h}$ is a linear constraint on the states (with
$\mat{G} \in \mathbb{R}^{r \times p}$ and $\vec{h} \in \mathbb{R}^r$),
$\vec{u} \in \mathbb{R}^q$ is a non-deterministic input,
and $\mat{A} \in R^{p \times p}$ and $\mat{B} \in \mathbb{R}^{p \times q}$ are linear
transformations characterising the dynamics of the system.
In particular, the special instance where $\psi = \top$ (i.e., ``while
true'') represents a time-unbounded loop with no guards, for which the
discovery of a suitable invariant (when existing) is paramount.
As evident at a semantical level (see next), this syntax can be
interpreted as the dynamics of a discrete-time LTI model with inputs, under
the presence of a guard set which, for ease of notation, we denote as $G =
\{\vec{x}\mid \mat{G}\vec{x}\leq\vec{h}\}$.
\subsection{Model Semantics} \label{sec:semantics}
The traces of the model starting from an initial set $X_0\subseteq \mathbb{R}^p$,
with inputs restricted to $U \subseteq \mathbb{R}^q$, are sequences
$ \vec{x}_0 \xrightarrow{\vec{u}_0} \vec{x}_1 \xrightarrow{\vec{u}_1} \vec{x}_2 \xrightarrow{\vec{u}_2} \ldots $,
where $ \vec{x}_0 \in X_0$ and $\forall n\geq 0, \vec{x}_{n+1} = \tau(\vec{x}_n,\vec{u}_n) $,
where
\begin{equation}\label{equ:reachtraj}
\tau(\vec{x}_n,\vec{u}_n) =
\big( \mat{A}\vec{x}_n +
\mat{B}\vec{u}_n \mid \mat{G}\vec{x}_n \leq \vec{h} \wedge \vec{u}_n \in U \big) \;.
\end{equation}
We extend the notation above to convex sets of initial conditions and inputs ($X_0$ and $U$),
and write $\tau(X_0,U)$ to denote the set of states $\{\vec{x} \mid \vec{x}_0 \in
X_0 \wedge \vec{u} \in U \wedge \vec{x} = \tau(\vec{x}_0,\vec{u})\}$
reached from $X_0$ by $\tau$ in one step.
We furthermore write $\tau^n(X_0,U)$ to denote the set of states reached from
$X_0$ via $\tau$ in $n$ steps (\emph{$n$-reach set}), i.e.\ for $n\geq 1$
\begin{equation}\label{equ:reachset}
\tau^n(X_0,U) = \{\vec{x}_n \mid \vec{x}_0 \in X_0 \wedge
\forall k\in [0,n-1]: \vec{u}_{k} \in U \wedge \vec{x}_{k+1}=\tau(\vec{x}_{k},\vec{u}_{k}) \} \;.
\end{equation}
Since the transformations $\mat{A}$ and $\mat{B}$ are linear and
vector sums preserve convexity, the sets $X_n = \tau^n(X_0,U)$ are also
convex.
We define the \emph{$n$-reach tube} $\hat{X}_n
=\hat{\tau}^n(X_0,U)=\bigcup_{k\in[0,n]} \tau^k(X_0,U)$ as the union of the
reachable sets over $n$ iterations.
Moreover, $\hat{X}
=\bigcup_{n\geq 0} \tau^n(X_0,U)$
extends the previous notion over an
unbounded time horizon. %
\subsection{Abstract Acceleration}\label{sec:absacc}
Abstract Acceleration~\cite{GS14} is a method to over-approximate the {\it
reach tube} of linear systems over any given time interval, including the
infinite time horizon. \cite{JSS14} discusses this abstraction technique
for systems without inputs, where an \emph{abstract matrix} $\mathcal{A}^n$
is synthesised to encompass the combined dynamics generating all reach
sets up to the $n^{th}$ iteration.
The abstract matrix $\mathcal{A}^n$ over-approximates the set of matrices
$\bigcup_{k\in[0,n]} \mat{A}^k$.
The reach tube $\hat{\tau}^n(X_0)$ (tailoring the notation above to a system {\it without} inputs) can then be over-approximated via the
\emph{abstract matrix multiplication} $\mathcal{A}^n X_0$~\cite{JSS14}.
We will employ the notation $\mathcal{A}$ (rather than $\mathcal{A}^\infty$)
to represent this notion over an infinite time horizon.
In this paper we extend this approach to systems with inputs, so that
\begin{equation}\label{equ:absaccinput0}
\hat{\tau}^n(X_0,U) \subseteq \mathcal{A}^n X_0 \oplus \mathcal{B}^nU,
\end{equation}
where $A \oplus B$ represents the Minkowski sum of two sets, namely $\{a + b\mid a\in A
\wedge b\in B\}$, whereas the abstract matrix $\mathcal{B}^n$
over-approximates the set of matrices $\bigcup_{k\in[0,n]}
(\mat{I}-\mat{A}^k)(\mat{I}-\mat{A})^{-1}\mat{B}$, where $\mat{I}$ is a
properly-sized identity matrix -- this second approximation will be
discussed in detail in Section~\ref{sec:approach}.
\subsection{Support Functions} \label{sec:support}
There exist many abstract domains (namely, over-approximations) to encompass
sets of states that are suitable for systems with linear dynamics, of which
by far the most popular is that of \emph{convex polyhedra}~\cite{CH78}.
Rectangular abstractions are easy to process~\cite{SK03}, but the
over-approximations may be too conservative, which results in an even larger
problem in the presence of non-deterministic inputs.
Abstract acceleration requires two abstract domains:
the first to abstract the model dynamics --
the original approach for abstract
acceleration~\cite{JSS14} uses \emph{logahedra} \cite{howe2009logahedra} --
and the second to represent spatial sets (convex polyhedra in~\cite{JSS14}).
In~\cite{JSS14} the estimation of the number of loop iterations (time steps) leverages abstractions of initial sets as hypercubes,
which is a source of imprecision that our method will not exhibit.
In this work, we use support functions~\cite{DBLP:dblp_journals/cviu/GhoshK98,le2009reachability} for the abstract domains.
Support functions have proven to be one of the most
successful abstractions for the representation of reachability sets for
dynamical and hybrid linear systems.
A general assertion $\mat{C}\vec{x} \leq \vec{d}$ (of which the guard $\mat{G}\vec{x} \leq \vec{h}$ is just an example)
entails a set of states that
is a convex polyhedron, where each row in
$\mat{C}$ is a direction orthogonal to a face in the polyhedron, and the
corresponding value in $\vec{d}$ is the distance of that face to the
origin.
Support functions represent a set by defining the distance of
its convex hull with respect to a number of given directions.
More specifically, the distance from the origin to the hyperplane that is orthogonal to the given
direction and that touches its convex hull at its farthest. Finitely sampled
support functions are template polyhedra in which the directions are not fixed,
which helps avoiding wrapping effects \cite{GLM06}.
The larger the
number of directions provided, the more precisely represented the
set will be.
In more detail,
given a direction $\vec{v} \in \mathbb{R}^p$,
the support function of a non-empty set $X \subseteq
\mathbb{R}^p$ in the direction of $\vec{v}$ is defined as
\begin{displaymath}
\rho_X : \mathbb{R}^p \to \mathbb{R}, \quad \rho_X(\vec{v}) = \sup\{ < \vec{x} , \vec{v} > : \vec{x} \in X\}
\;.
\end{displaymath}
where $< \vec{x} , \vec{v} >$ is the dot product of the two vectors.
Support functions do not exclusively apply to convex polyhedra,
but in fact to any
set $X \subseteq \mathbb{R}^p$ represented by a general assertion $\theta(X)$.
We will restrict ourselves to the use of
convex polyhedra, in which case the support function definition translates to solving the linear program
\begin{equation}
\rho_X(\vec{v}) = \max\{ < \vec{x} , \vec{v} > \mid \mat{C}\vec{x} \leq \vec{d}\} \;.
\end{equation}
Several properties of support functions allow us to reduce operational
complexity. The most significant
are~\cite{DBLP:dblp_journals/cviu/GhoshK98}:
\begin{displaymath}
\begin{array}{lr}
\rho_{kX}(\vec{v}) =\rho_X(k \vec{v}) = k \rho_X(\vec{v}) : k \geq 0 &
\rho_{AX}(\vec{v})=\rho_{X}(A^T\vec{v}) : A \in \mathbb{R}^{p \times p}\\
\rho_{X_1 \oplus X_2}(\vec{v})=\rho_{X_1}(\vec{v})+\rho_{X_2}(\vec{v}) &
\rho_X(\vec{v}_1 + \vec{v}_2) \leq \rho_X({\vec{v}_1}) + \rho_X({\vec{v}_2})\\
\rho_{conv(X_1 \cup X_2)}(\vec{v}) = \max\{\rho_{X_1}(\vec{v}),\rho_{X_2}(\vec{v})\}\;\;\;\;\;\; &
\rho_{X_1 \cap X_2}(\vec{v}) \leq \min\{\rho_{X_1}(\vec{v}),\rho_{X_2}(\vec{v})\}\\
\end{array}
\end{displaymath}
As can be seen by their structure, some of these properties reduce
complexity to lower-order polynomial
or even to constant time, by exchanging matrix-matrix multiplications ($\mathcal{O}(p^3)$) into matrix-vector ($\mathcal{O}(p^2)$),
or into scalar multiplications.
\section{Abstract Acceleration with Inputs} \label{sec:approach}
\subsection{Overview of the Algorithm}
Our algorithm takes as input the set of initial states $X_0$, the set
of bounded inputs $U$, and the dynamics of a linear loop characterised by
$\mat{G},\vec{h}, \mat{A}$, and $\mat{B}$;
and returns as output an over-approximation $\hat{X}^\sharp$ of the reach tube $\hat{X}$ (or corresponding quantities for the bounded-horizon case).
We over- and under-approximate the number of loop iterations $n$ that are required to first intersect and completely go beyond the guard set $G$, respectively,
by means of the reach sets computed with the model dynamics:
we denote these two quantities by $\underline{n}$ and $\overline{n}$.
In the following we employ the notations $\sqcap$ for intersection of polyhedra,
and $\sqcup$ for the convex hull $\mathit{conv}(X_1\cup X_2)$.
If $\underline{n}$ or $\overline{n}$ are unbounded, we compute the abstract
matrices $\mathcal{A}$ and $\mathcal{B}$ (as defined shortly), and return
the quantity
\begin{equation}
\hat{X}^\sharp = X_0\sqcup \left(\mathcal{A}
(X_0\sqcap G)\oplus \mathcal{B} U\right)\sqcap G
\label{reachTube:in}
\end{equation}
as the resulting reach tube, where again $G=\{\vec{x}\mid
\mat{G}\vec{x}\leq\vec{h}\}$. Otherwise, in the finite case, we compute the abstract matrices
$\mathcal{A}^{\underline{n}}$ and $\mathcal{A}^{\overline{n}-\underline{n}}$ and set
\begin{equation}
\hat{X}^\sharp_n = X_0\sqcup \left(\big(\mathcal{A}^{\underline{n}} (X_0\sqcap G)\oplus \mathcal{B}^{\underline{n}}U\big) \sqcap G\right)
\sqcup
\left(\big(\mathcal{A}^{\overline{n}-\underline{n}}
(X_{\underline{n}}\sqcap G) \oplus
(\mathcal{B}^{\overline{n}-\underline{n}} U)\big)\sqcap G\right) \;.
\label{reachTube:out}
\end{equation}
In this formula, the abstract matrices $\mathcal{A}^n$ and $\mathcal{B}^n$
are obtained as an over-approximation of sets of matrices,
as described in Section \ref{sec:absmat_real}.
\subsection{Abstract Acceleration without Guards} \label{sec:noguard}
With reference to \eqref{equ:absaccinput0},
we now detail the abstract acceleration with inputs.
Unfolding \eqref{equ:reachset} we obtain
$$
\vec{x}_{n}=\mat{A}^n\vec{x}_0+\mat{A}^{n-1}\mat{B}\vec{u}_0+\mat{A}^{n-2}\mat{B}\vec{u}_{1}+...+\mat{B}\vec{u}_{n-1}
= \mat{A}^n\vec{x}_0+\sum_{k\in [1,n]} \mat{A}^{n-k}\mat{B}\vec{u}_{k-1}.
$$
Let us now consider the following over-approximation for $\tau$ on sets:
\begin{equation}
\tau^\sharp(X_0,U) = \mat{A}(X_0\cap G)\oplus\mat{B}U.
\end{equation}
Then the reach set (as said, we ignore the presence of the guard set $G$ for the time being) can be computed as
$$
\begin{array}{c}
X_n=\mat{A}^nX_0\oplus\mat{A}^{n-1}\mat{B}U+\mat{A}^{n-2}\mat{B}U\oplus...\oplus\mat{B}U = \mat{A}^nX_0\oplus\sum_{k\in [0,n-1]} \mat{A}^k\mat{B}U. \\
\end{array}
$$%
What is left to do is to further simplify the sum $\sum_{k\in [0,n-1]}
\mat{A}^k\mat{B}U$.
We can exploit the following simple results from linear algebra.
\begin{lemma}
If $\mat{I}-\mat{A}$ is invertible,
then $\sum_{k=0}^{n-1} \mat{A}^k = (\mat{I} -\mat{A}^{n})(\mat{I} - \mat{A})^{-1}$.
If furthermore $\lim_{n\to \infty} \mat{A}^n=0$,
then $\lim_{n \to \infty} \sum_{k=0}^n \mat{A}^k = (\mat{I}-\mat{A})^{-1}$.
\end{lemma}
It is evident that there are some restrictions on the nature of matrix
$\mat{A}$: since we need to calculate the inverse $(\mat{I}-\mat{A})^{-1}$,
$\mat{A}$ must not include the eigenvalue $1$, i.e. $1\notin \sigma(\mat{A})$,
where $\sigma(A)$ is the spectrum (the set of all the eigenvalues) of matrix $\mat{A}$.
In order to overcome this problem,
we introduce the eigen-decomposition of $\mat{A} = \mat{S}\mat{J}\mat{S}^{-1}$,
and setting trivially $\mat{I}=\mat{S}\mat{I}\mat{S}^{-1}$,
by the distributive and transitive property we obtain
\begin{align*}
(\mat{I} -\mat{A}^{n})(\mat{I} - \mat{A})^{-1} & = \mat{S}(\mat{I}-\mat{J}^{n})(\mat{I}-\mat{J})^{-1}\mat{S}^{-1}.
\end{align*}
While this does not directly eliminate the problem of the inverse for eigenvalues equal to 1,
it allows us to set
\begin{equation}
\sum_{k=0}^{n-1} \lambda^k =
\left \{
\begin{array}{cc}
n & \lambda =1 \\
\frac{1-\lambda^n}{1-\lambda} & \lambda \neq 1\\
\end{array}
\right.
\Rightarrow
(\mat{I}-\mat{A}^n)(\mat{I}-\mat{A})^{-1}= \mat{S} \ \ diag \left (
\begin{array}{cc}
n & \lambda_i = 1\\
\frac{1-\lambda_i^n}{1-\lambda_i} & \lambda_i \neq 1 \\
\end{array} \right )
\ \mat{S}^{-1}.
\label{abs:bover}
\end{equation}
In the case of Jordan blocks of size $>1$, the entries in the $k^{th}$ upper diagonal of the block are filled with the value: $\frac{-1^k}{k+1}\frac{1-\lambda^n}{(1-\lambda)^{k+1}}+\sum_{j=1}^{k} \frac{-1^{k-j}}{k-j}\binom{n}{j-1}\frac{\lambda^{n-j-1}}{(1-\lambda)^{k-j}}$.
This result can be only directly applied under restricted conditions, for
instance whenever $\forall k>0: \vec{u}_k=\vec{u}_{k-1}$. In order to
generalise it (in particular to non-constant inputs), we will
over-approximate $\mat{B}U$ over the eigenspace by a spheral enclosure with
centre $\vec{u}_c'$ and radius $U_b'$. To this end, we first rewrite
\begin{displaymath}
U_J' = \mat{S}^{-1}\mat{B}U = \{ \vec{u}_c'\} \oplus U_d',
\end{displaymath}
where
\begin{displaymath}
\mat{u}_c'[i] = \frac{1}{2}(\rho_{U_J'}(\vec{v_i})+\rho_{U_J'}(-\vec{v_i})), \vec{v}_i[j]= \left \{
\begin{array}{cc}
1 & j=i\\
0 & j \neq i
\end{array}
.\right.
\end{displaymath}
We then over-approximate $U_d'$ via $U_b'$, by the maximum radius in
the directions of the complex eigenvalues and non-singular Jordan
blocks, as illustrated in Figure \ref{aa:varinputs}:
\begin{displaymath}
\begin{array}{l}
U_b' \supseteq U_d'\ : \ \forall i,j,\ \ \rho_{U_b'}(\vec{v}) = \\
\left \{
\begin{array}{cl}
\max( \rho_{U_d'}(\vec{v}')) & \text{if }\lambda_i=\lambda_j^* \wedge |\vec{v}'|=|\vec{v}| \wedge (\vec{v}'[j] \neq 0 \vee \vec{v}'[i] \neq 0) \\
\rho_{U_d'}(\vec{v}) & \text{otherwise.}
\end{array}
\right.
\end{array}
\end{displaymath}
Since the description of $U'_b$ is no longer polyhedral,
we will also create a spherical over-approximation $\mat{A}_b$ of
$\mat{A}$ in the directions of the complex eigenvectors, in a
similar way as we generated $U_b'$ for $U_d'\ $. $\mat{A}_b$ is
a matrix such that $\mat{A}_b=\mat{S} \mat{J}_b \mat{S}^{-1}$, where
\begin{equation}
\mat{J}_{bs}=\lambda_{bs}\mat{I} \text{ with } \lambda_{bs}=|| \mat{J}_s ||=
\max_{\vec{u} \subseteq U_b'} \frac{|| \mat{J}_s\vec{u}_s ||}{||
\vec{u}_s ||}
\label{eq:induced}
\end{equation}
$|| \mat{J}_s ||$ is the induced matrix norm, $s$ indicates the index of each Jordan block and $\vec{u}_s$ the
corresponding subvector of $\vec{u}$.
Directly from the definition of the matrix norm, we have
\begin{equation}
||\mat{J}_s\vec{u}_s|| \leq ||\mat{J}_s||\,||\vec{u}_s||
\label{eq:overinduced}
\end{equation}
$\mat{J}_{b} U_b'$ is the smallest ball that over-approximates $\mat{J} U_d'$
The matrix norm of a Jordan block is obtained by computing the maximum singular value of the
block~\cite{LT84}.
The induced norm is equal to the maximum singular value of the matrix~\cite{LT84}, thus
\begin{equation}
|| \mat{J}_s || ={\sigma_s}_{max} = max( {\sigma_s} ) \text{ with } \sigma_s \in \mat{\Sigma}_s \wedge \mat{J}_s=\mat{U}_s\mat{\Sigma}_s\mat{V}_s^T
\label{eq:sigmamax}
\end{equation}
Returning to our original equation for the $n$-reach set, we obtain%
\footnote{Note that $\forall U_b'\ ,U_c'\
,U_d'\ ;\ \exists U_b\ ,U_c\ ,U_d : U_b'=\mat{S}^{-1}BU_b$ so that $U_c'=\mat{S}^{-1}BU_c$ and $U_d'=\mat{S}^{-1}BU_d$. Hence, this inclusion is also valid
in the original state space. }
\begin{equation}\label{equ:accinput2}
X_n \subseteq \mat{A}^nX_0 \oplus (\mat{I}-\mat{A}^n)(\mat{I}-\mat{A})^{-1}\mat{B}U_c \oplus
(\mat{I}-\mat{A}_b^n)(\mat{I}-\mat{A}_b)^{-1}\mat{B}U_b,
\end{equation}
with $U_c= \{ \vec{u}_c \}$.
\begin{SCfigure}[][t]
\centering
\begin{tikzpicture}[scale=0.8]
\begin{axis}[ylabel={$\vec{\lambda}_2$},xlabel={$\vec{\lambda}_1$},xmin=-50,xmax=50,ymin=-40,ymax=40]
\addplot[color=blue,mark=*] table{./Inputs.dat};
\addplot[dashed, color=blue,mark=*] table{./InputsTrans.dat};
\addplot[color=purple,mark=*] table{./InputsCentre.dat};
\draw[color=red] (axis cs:17.9,11.37) circle[radius=260];
\draw[dashed,color=orange] (axis cs:0,0) circle[radius=260];
\node at (axis cs:17.9,11.37) [pin={-10:$\vec{u}_c'$},inner sep=0pt] {};
\node at (axis cs:0,0) [pin={-10:$0,0$},inner sep=0pt] {};
\node at (axis cs:12.1,-23.37) [pin={-10:$U_b'$},inner sep=0pt] {};
\node at (axis cs:8,13) [pin={+10:$U_d'$},inner sep=0pt] {};
\node at (axis cs:32,-4) [pin={-10:$U'$},inner sep=0pt] {};
\end{axis}
\end{tikzpicture}
\caption{Relaxation of an input set in a complex subspace making it
invariant to matrix rotations. The dashed orange line is the red circle
translated onto the origin.}
\label{aa:varinputs}
\end{SCfigure}
Shifting the attention from reach sets to tubes,
we can now over-approximate the {\it reach tube} by abstract acceleration of the three summands in (\ref{equ:accinput2}), as follows.
\begin{theorem}\label{equ:absaccinput}
The abstract acceleration
$\tau^{\sharp n}(X_0,U) =_{\mathrm{def}} \mathcal{A}^nX_0 \oplus \mathcal{B}^n U_c \oplus \mathcal{B}_b^n U_b$
is an over-appro\-xi\-mation of the $n$-reach tube,
namely $\hat{X}_n \subseteq \tau^{\sharp n}(X_0,U)$.
\end{theorem}
We will discuss in the next section how to compute the abstract matrices
$\mathcal{A}^n$, $\mathcal{B}^n$ and $\mathcal{B}_b^n$,
with focus in particular
on~$\mathcal{A}^n$.
\subsection{Computation of Abstract Matrices}\label{sec:absmat_real}
We define the abstract matrix $\mathcal{A}^n$ as an over-approximation
of the union of the powers of matrix $\mat{A}^k$: $\mathcal{A}^n \supseteq
\bigcup_{k\in[0,n]} \mat{A}^k$.
Next we explain how to compute such an abstract matrix.
For simplicity, we first describe this computation for matrices $\mat{A}$ with real eigenvalues,
whereas the extension to the complex case will be addressed in Section~\ref{sec:absmat_complex}.
Similar to \cite{JSS14}, we first have to compute the Jordan normal form of $\mat{A}$.
Let $\mat{A}=\mat{S}\mat{J}\mat{S}^{-1}$ where $\mat{J}$ is the normal Jordan form of $\mat{A}$,
and $\mat{S}$ is made up by the corresponding eigenvectors.
We can then easily compute $\mat{A}^n=\mat{S}\mat{J}^n\mat{S}^{-1}$, where
\begin{equation}
\mat{J}^n= \left [ \begin{array}{ccc}
\mat{J}_1^n & & \\
& \ddots & \\
& & \mat{J}_r^n\\
\end{array} \right ], \ \
\text{with } \mat{J}_s^n= \left [ \begin{array}{cccc}
\lambda_s^n & \binom{n}{1} \lambda_s^{n-1} & \hdots & \binom{n}{p_s-1} \lambda_s^{n-p_s+1} \\
& \lambda_s^n & \binom{n}{1} \lambda_s^{n-1} & \vdots \\
\vdots & & \ddots & \vdots \\
& & &\lambda_s^n \\
\end{array} \right ] \text{ for }s\in[1,r].
\label{jord:pow}
\end{equation}
The abstract matrix $\mathcal{A}^n$ is computed as an abstraction over
a vector $\vec{m}$ of non-constant entries of $\mat{J}^n$.
The vector $\vec{m}$ is obtained by a transformation $\varphi$ such that
$\mat{J}^n = \varphi(\vec{m})$.
If $\mat{J}^n$ is diagonal~\cite{JSS14}, then $\vec{m}$ equals the
vector of powers of eigenvalues $(\lambda_0^n,\ldots,\lambda_r^n)$.
An interval abstraction can thus be simply obtained by computing the
intervals
$[\min\{\lambda_s^0,\lambda_s^n\},$ $\max\{\lambda_s^0,\lambda_s^n\}
], s\in[1,r]$.
We observe that the spectrum of the interval matrix $\sigma(\mathcal{A}^n)$ (defined as intuitively)
is an over-approximation of $\bigcup_{k\in[0,n]} \sigma(\mat{A}^k)$.
In the case of the $s^\mathrm{th}$ Jordan block $\mat{J}_s$ with geometric non-trivial
multiplicity $p_s$ ($\lambda_i = \lambda_{i-1} =\ldots$), observe that
the first row of $\mat{J}_s^n$ contains all (possibly) distinct
entries of $\mat{J}_s^n$. Hence, in general, the vector section $\vec{m}_s$ is
the concatenation of the (transposed) first row vectors
$\left(\lambda_s^n , \binom{n}{1} \lambda_s^{n-1}, \hdots,
\binom{n}{p_s-1} \lambda_s^{n-p_s+1}\right)^T$ of $\mat{J}_s^n$.
Since the transformation $\varphi$
transforms the vector $\vec{m}$ into the shape of \eqref{jord:pow} of $\mat{J}^n$, it is called a \emph{matrix shape} \cite{JSS14}.
We then define the abstract matrix as
\begin{equation}
\mathcal{A}^n = \{\mat{S}\ \varphi(\vec{m})\ \mat{S}^{-1} \mid \mat{\Phi}\vec{m} \leq \vec{f} \} \;,
\label{abs:mat}
\end{equation}
where the constraint $\mat{\Phi}\vec{m} \leq \vec{f}$ is synthesised
from intervals associated to the individual eigenvalues and to their
combinations. More precisely, we compute polyhedral relations:
for any pair of eigenvalues (or binomials) within $\mat{J}$, we find
an over-approximation of the convex hull containing the points $\cup
\{ \vec{m}^k \mid 1 {\leq} k {\leq} n \} \subseteq
\{\vec{m} \mid \mat{\Phi}\vec{m} {\leq} \vec{f} \}$
with component-wise exponentiation $\vec{m}^k$.
\begin{SCfigure}[][t]
\centering
\begin{tikzpicture}[scale=0.8]
\begin{axis}[ylabel={$\lambda_2^n$},xlabel={$\lambda_1^n$}
\addplot[color=blue,mark=*] table{./EigenValues.dat};
\addplot[dash pattern=on 1pt off 3pt , color=gray] coordinates {(5.5,0) (32,0)};
\addplot[dash pattern=on 1pt off 3pt , color=gray] coordinates {(32.5,0) (32.5,33)};
\addplot[dash pattern=on 1pt off 3pt , color=gray] coordinates {(1.5,213) (1.5,247)};
\addplot[dash pattern=on 1pt off 3pt , color=gray] coordinates {(1.5,247) (32.5,247)};
\addplot[dashed, color=red] coordinates {(1.5,0) (1.5,213)};
\addplot[dashed, color=red] coordinates {(1.5,213) (32,247)};
\addplot[dashed, color=red] coordinates {(2,0) (32,30)};
\addplot[dashed, color=red] coordinates {(32.5,33) (32.5,187)};
\addplot[color=purple, line width=1.5pt] coordinates {(2,7) (32,247)};
\addplot[color=purple, line width=1.5pt] coordinates {(5,0) (32.5,187)};
\addplot[color=purple, line width=1.5pt] coordinates {(1.5,0) (5,0)};
\addplot[color=purple, line width=1.5pt] coordinates {(32.5,187) (32.5,247)};
\node at (axis cs:2,3) [pin={+90:$n=1$},inner sep=0pt] {};
\node at (axis cs:4,9) [pin={-10:$n=2$},inner sep=0pt] {};
\node at (axis cs:8,27) [pin={-10:$n=3$},inner sep=0pt] {};
\node at (axis cs:16,81) [pin={-10:$n=4$},inner sep=0pt] {};
\node at (axis cs:32,243) [pin={-170:$n=5$},inner sep=0pt] {};
\end{axis}
\end{tikzpicture}
\caption{Polyhedral faces from an $\mathbb{R}^2$ subspace, where
$(\lambda_1^n, \lambda_2^n)$ so that $\lambda_1{=}2, \lambda_2{=}3, 1{\leq}n{\leq}5$.
Bold purple lines represent supports found by this paper. The dotted grey and dashed
red polytopes show logahedral approximations (box and octagon)
used in \cite{JSS14}. Note the scales (sloped dashed lines are
parallel to the x=y line, and dashed red polytope hides two small sides yielding an octagon).}
\label{aa:supports}
\end{SCfigure}
As an improvement over~\cite{JSS14}, the rows in $\mat{\Phi}$ and $\vec{f}$
are synthesised by discovering support functions in these sets. The freedom
of directions provided by these support functions results in an improvement
over the logahedral abstractions used in previous papers
(see Figure \ref{aa:supports}).
An additional drawback of \cite{JSS14} is that calculating the exact
Jordan form of any matrix is computationally expensive and hard to
achieve for large-dimensional matrices.
We will instead use numerical algorithms in
order to get an approximation of the Jordan normal form
and account for numerical errors. In
particular, if we examine the nature of
\eqref{reachTube:in}--\eqref{reachTube:out}, we find out that the
numerical operations are not iterative, therefore the errors do not
accumulate with time. We use properties of
eigenvalues to relax $\vec{f}$ by finding the maximum error in the
calculations that can be determined by computing the norm
$\delta_{max} = |\mat{A}-\mat{S}\mat{J}_\mathit{est}\mat{S}^{-1}|$.
The constraints $\mat{\Phi} \vec{m} < \vec{f}$ are then computed by
considering the ranges of eigenvalues $\lambda_s \pm \delta_{max}$ (represented in Fig.~\ref{aa:supports} as the diameter of the blue dots). The outward relaxation of the support functions ($\vec{f}$), which follows a principle similar to that introduced in~\cite{gao2012delta}, reduces the tightness of the over-approximation, but ensures the soundness of the abstract matrix $\mathcal{A}^n$ obtained.
One can still use exact arithmetic with a noticeable improvement over
previous work; however, for larger-scale systems the option of using
floating point arithmetic, while taking into account errors and meticulously
setting rounding modes, provides a $100$-fold plus improvement that can
make a difference towards rendering verification practically feasible.
The abstract matrices $\mathcal{B}^n$ and $\mathcal{B}_b^n$ (see
Theorem~\ref{equ:absaccinput}), are defined similarly but using a
similar assertion for the eigenvalues based on the transformations
described in \eqref{abs:bover}.
\subsection{Abstract Acceleration with Guards: Estimation of the number of Iterations} \label{sec:guards}
The most important task remaining is how to calculate the number of iterations dealing with the presence of the guard set $G$.
Given a convex polyhedral guard expressed as the assertion $\{\vec{x} \mid \mat{G}\vec{x} \leq \vec{h}\}$,
we define $G_i$ as the $i^{th}$ row of $\mat{G}$ and $h_i$ as the corresponding
element of $\vec{h}$.
We denote the normal vector to the $i^{th}$ face of the guard as $\vec{g}_i=G_i^T$.
The distance of the guard to the origin is thus $\gamma_i = \frac{h_i}{|\vec{g}_i|}$.
Given a convex set $X$, we may now describe its position with respect to
each face of the guard through the use of its support function alongside the normal
vector of the hyperplane (for clarity, we assume the origin to be inside set $X$):
\begin{displaymath}
\begin{array}{ccl}
\rho_X(\vec{g}_i) \leq \gamma_i, & & \textrm{inside\ the\ hyperplane},\\
-\rho_X(-\vec{g}_i) \geq \gamma_i, & & \textrm{outside\ the\ hyperplane}.
\end{array}
\end{displaymath}
From the inequalities above we can determine up to which number of iterations $\underline{n_i}$ the reach tube remains inside the corresponding hyperplane,
and starting from which iteration $\overline{n_i}$ the corresponding reach set goes beyond the guard:
\begin{eqnarray}
&& \label{equ:underiter} \rho_{X_0}({\mat{A}^{\underline{n_i}}}^T\vec{g}_i)+\rho_{U_a}((\mat{I}-\mat{A}^{\underline{n_i}})^T\vec{g}_i) \leq \gamma_i, \\
&& \rho_{X_0}(-{\mat{A}^{\overline{n_i}}}^T\vec{g}_i)+\rho_{U_a}((\mat{A}^{\overline{n_i}}-\mat{I})^T\vec{g}_i) \leq -\gamma_i. \nonumber
\end{eqnarray}
where $U_a=(\mat{I}-\mat{A})^{-1}\mat{B}U$.
In order for a reach set to be inside the guard it must therefore be inside
all of its faces, and we can ensure it is fully outside of the guard set
when it is fully beyond any of them. Thus, we have $\underline{n} = \min\{\
\underline{ n_i }\ \}$, and $\overline{n} = \min \{\ \overline{ n_i }\ \}$.
\medskip
Computing the maximum $\underline{n_i}$ such that \eqref{equ:underiter} is satisfied is not easy,
because the unknown $\underline{n_i}$ occurs in the exponent of the equation.
However, since an intersection with the guard set will always return a
sound over-approximation, we do not need a precise value. We can over-approximate it by decomposing $\vec{g}_i$ into the generalised eigenspace of $\mat{A}$
Let $\vec{g}_i=\sum_{j=1}^p k_{ij} \vec{v}_j +\mathit{res}(\vec{g}_i)$,
where $\vec{v}_j$ are vectors of $\mat{S}$,
and $\mathit{res}(\vec{g}_i)$ is the component of $\vec{g}_i$ that lies outside the range of $\mat{S}$.
Notice that since $\mat{S}$ has an inverse, it is full rank and therefore $\mathit{res}(\vec{g}_i)=\vec{0}$ and subsequently not relevant.
It is also important to note that $\mat{S}$ is the matrix of generalised eigenvectors of $\mat{A}$ and therefore we are expressing our guard in the generalised eigenspace of $\mat{A}$.
\begin{equation}
\rho_{X_0}({\mat{A}^n}^T \vec{g}_i) = \rho_{X_0}(\sum_{j=1}^p k_{ij} {\mat{A}^n}^T \vec{v}_j) \leq \sum_{j=1}^p k_{ij} \rho_{X_0}({\mat{A}^n}^T \vec{v}_j)
\end{equation}
Using a ball over-approximation over $X_0$ such that
\begin{equation}
\begin{array}{l}
X_{b0} \supseteq X_0\ : \ \forall i,j,\ \ \rho_{X_{b0}}(\vec{v}) = \\
\left \{
\begin{array}{cl}
\max( \rho_{X_0}(\vec{v}')) & \text{if }\lambda_i=\lambda_j^* \wedge |\vec{v}'|=|\vec{v}| \wedge (\vec{v}'[j] \neq 0 \vee \vec{v}'[i] \neq 0) \\
\rho_{X_0}(\vec{v}) & \text{otherwise.}
\end{array}
\right.
\end{array}
\end{equation}
We can use equations \eqref{eq:overinduced} and \eqref{eq:sigmamax} to obtain $\rho_{X_0}(\mat{A}^n \vec{v}_j) \leq {\sigma_j}_{max}\,\rho_{X_{b0}}(\vec{v}_j)$
Therefore
\begin{equation}
\begin{array}{c}
\rho_{X_0}({\mat{A}^n}^T \vec{g}_i) \leq \sum_{j=1}^p k_{ij} {\sigma_j}_{max}^n\,\rho_{X_{b0}}(\vec{v}_j)
\end{array}
\end{equation}
Using the support function properties detailed in
Section~\ref{sec:support}, we obtain for \eqref{equ:underiter}:
\begin{equation}
\begin{array}{ll}
\rho_{X_0}({A^n}^T\vec{g}_i)+\rho_{U_a}((I-A^n)^T\vec{g}_i) & \leq\\
\sum_{j=1}^p {\sigma_j}_{max}^n k_{ij} \rho_{X_{b0}}(\vec{v}_j) + ({\sigma_j}_{max}^n k_{ij} - 1) \rho_{U_b}(-\vec{v}_j) & \leq\\
\gamma_i. &
\end{array}
\end{equation}
In order to solve for $n$ we transfer
the constant terms to one side,
taking into account that $\sum_{j=1}^p -\rho_{U_a}(-\vec{v}_j) =-\rho_{U_a}(-\vec{g}_i)$, as
\begin{equation}
\begin{array}{c}
\sum_{j=1}^p {\sigma_j}_{max}^n k_{ij} (\rho_{X_0}(\vec{v}_j) +
\rho_{U_a}(-\vec{v}_j)) \leq \gamma_i+\rho_{U_a}(-\vec{g}_i) \;.
\end{array}
\end{equation}
To separate the divergent element of the dynamics from the
convergent one, let us define
$k_{ij}'=k_{ij} (\rho_{X_0}(\vec{v}_j) + \rho_{U_a}(-\vec{v}_j))$
and
$ {\sigma}_{max}=max(\sigma_j) \text{ for all } j \in [1,p]$.
This step will allow us to track effectively which trajectories are
likely to hit the guard and when, since it is only the divergent
element of the dynamics that can increase the reach tube in a given
direction.
Replacing, we obtain
\begin{equation}
\begin{array}{c}
{\sigma}_{max}^n\sum_{j=1}^p k_{ij}'\left(\frac{ {\sigma_j}_{max}}{ {\sigma}_{max}}\right)^n \leq
\gamma_i+\rho_{U_a}(-\vec{g}_i) \;,
\end{array}
\end{equation}
which allows to finally formulate an iteration scheme for approximating $n$.
\begin{proposition}\label{prop:real_under_n}
An iterative under-approximation of the number of iterations $n$ can
be computed by starting with $\underline{n_i}=0$ and iterating over
\begin{displaymath}
\begin{array}{c}
\underline{n_i} \geq
\log_{\lambda_m}\left({\gamma_i+\rho_{U_a}(-\vec{g}_i)}\right)-\log_{ {\sigma}_{max}}\left({\sum_{j=1}^p k_{ij}'\left(\frac{ {\sigma_j}_{max}}{ {\sigma}_{max}}\right)^{\underline{n_i}}}\right)
\;,
\end{array}
\end{displaymath}
substituting the value of $n_i$ on the right-hand side and repeating a given number of times or up to convergence. Since $\underline{n_i}$ must be a multiple of $p_j$ we pick the largest multiple by substracting $\underline{n_i} \ mod\ p_j$.
\end{proposition}
\begin{proof}
This follows from the developments unfolded above.
Notice that the sequence $\underline{n_i}$ is monotonically increasing, before it oscillates around the answer.
As such any local minimum represents a sound under-approximation of the number of loop iterations.
\end{proof}
In the case of $\overline{n_i}$ we must invert the eigenvectors and approximate from above, starting at a sufficiently large number (larger than the expected number of time steps until the guard is crossed, or as much as numerically representable --- we use\ $\overline{n_i}=2^{15}$ in our implementation), thus
\begin{displaymath}
\begin{array}{c}
\overline{n_i} \leq \log_{ {\sigma}_{max}}\left({\gamma_i-\rho_{U_a}(\vec{g}_i)}\right)-\log_{ {\sigma}_{max}}\left({\sum_{j=1}^p k_{ij}''\left(\frac{ {\sigma_j}_{max}}{ {\sigma}_{max}}\right)^{\underline{n_i}}}\right).
\end{array}
\end{displaymath}
where $k_{ij}''=k_{ij} (\rho_{X_{b0}}(-\vec{v}_j)-\rho_{U_a}(\vec{v}_j))$. If the
initial $\overline{n_i}$ is not large enough, we simply double the exponent
until the left-hand side yields a smaller number than the one chosen
originally,
and extrapolate to $\infty$
\subsection{Abstract Matrices for Complex Eigenvalues}\label{sec:absmat_complex}
To deal with complex numbers in eigenvalues and eigenvectors,
\cite{JSS14} employs the real Jordan form for conjugate eigenvalues
$\lambda = re^{i\theta}$ and $\lambda^* = re^{-i\theta}$ ($\theta \in [0,\pi]$),
so that
\begin{displaymath}
\left (\begin{array}{cc} \lambda & 0 \\ 0 & \lambda^*\end{array}
\right) \quad \text{ is replaced by } \quad r \left (\begin{array}{cc} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \\ \end{array} \right).
\end{displaymath}
Although this equivalence will be of use once we evaluate the progression of
the system, calculating powers under this notations is often more difficult
than handling directly the original matrices with complex values.
In Section~\ref{sec:absmat_real}, in the case of real eigenvalues we have
abstracted the entries in the power matrix $\mat{J}_s^n$ by ranges of
eigenvalues
$[\min\{\lambda _s^0,\lambda _s^n\}, \max\{\lambda _s^0,\lambda _s^n\} ]$.
In the complex case we can do something similar by rewriting the
eigenvalues into polar form as $\lambda _s = r _s e^{i\theta _s}$,
and abstracting via the formula $[\min\{r_s^0,r_s^n\}\ , \ \max\{r_s^0,r_s^n\} ]e^{i[0\ , \ \min(\theta_s,2\pi)]}$.
What is left to do is to evaluate the effect of complex numbers on
support functions: to the best of the authors' knowledge, there is no
definition in the literature for support functions on complex numbers.
We will therefore extend the manipulations for the real case directly to
the complex one. \pponly{For reasons of restricted space, please refer to extended version \cite{extended-version}.}
\rronly{
\section{Support Functions in Complex Spaces}\label{sec:support_complex}
A support function in a complex vector field is a transformation:
\begin{displaymath}
\rho_X(\vec{v}) : \mathbb{C}^p \to \mathbb{R} = \sup\{<\vec{x} , \vec{v} >: \vec{x} \in X \subseteq \mathbb{C}^p, \vec{v} \in \mathbb{C}^p\}.
\end{displaymath}
The dot product used here is the internal product of the vectors and
which is commonly defined in the complex space as:
\begin{displaymath}
<\vec{a} , \vec{b} > = re(\vec{a} \cdot \vec{b}^*) \textrm{ so that } <\vec{a} , \vec{b} > = <\vec{b} , \vec{a} >.
\end{displaymath}
where $re(x)$ is the real value of $x$.
Returning to our support function properties, we now have:
$\rho_X(r e^{i\theta} \vec{v}) = r \rho_X(e^{i\theta}\vec{v})$,
which is consistent with the real case when $\theta=0$.
The reason why $e^{i\theta}$ cannot be extracted out is because it is
a rotation, and therefore follows the same rules as a matrix
multiplication,
\begin{displaymath}
\rho_X(e^{i\theta}\vec{v}) \triangleq \rho_X
\left (
\left [ \begin{array}{cc}
\cos \theta & \sin \theta\\
-\sin \theta & \cos \theta
\end{array}
\right ]
\vec{v}
\right ).
\end{displaymath}
Since matrices using pseudo-eigenvalues are real, all other properties remain the same.
An important note is that when using pseudo-eigenvalues,
conjugate eigenvector pairs must be also converted into two separate real eigenvectors,
corresponding to the real and the imaginary parts of the pair.
}
\hide{
}
\section{Case Study}
We have selected a known benchmark to illustrate the discussed procedure:
the room temperature control problem \cite{Fehnker04benchmarksfor}.
The temperature (variable \texttt{temp}) of a room is controlled to a user-defined set point (\texttt{set}),
which can be changed at any time through a heating (\texttt{heat}) element,
and is affected by ambient temperature (\texttt{amb}) that is out of the control of the system.
We formalise the description of such a system both via a linear loop and via hybrid dynamics.
To begin with,
observe that since such a system may be software controlled,
we assume that part of the system is coded,
and further assume that it is possible to discretise the physical environment for simulation.
A pseudo-code fragment for the temperature control problem follows:
\begin{verbatim}
temp=5+read(35);
heat=read(1);
while(temp<400 && heat<300)
{
amb=5+read(35);
set=read(300);
temp=.97 temp + .02 amb + .1 heat;
heat=heat + .05(set-temp);
}
\end{verbatim}
We use the \texttt{read} function to represent non-deterministic values
between 0 and the maximum given as argument. Alternatively, this loop
corresponds to the following hybrid dynamical model:
\begin{displaymath}
\left [ \begin{array}{c}
temp\\
heat\\
\end{array}
\right ]_{k+1}
=
\left [ \begin{array}{cc}
0.97 & 0.1\\
-0.05 & 1\\
\end{array}
\right ]
\left [ \begin{array}{c}
temp\\
heat\\
\end{array}
\right ]_{k}
+
\left [ \begin{array}{cc}
0.02 & 0\\
0 & 0.05\\
\end{array}
\right ]
\left [ \begin{array}{c}
amb\\
set\\
\end{array}
\right ]_{k},
\end{displaymath}
$\begin{array}{ll}
$with initial condition$&
\left [ \begin{array}{c}
temp\\
heat\\
\end{array}
\right ]_{0}
\in
\left [ \begin{array}{c}
\left [ 5\ \ 40 \right ]\\
\left [ 0\ \ 1 \right ]\\
\end{array}
\right ],\\
\\
$non-deterministic inputs$\;\;\;&
\left [ \begin{array}{c}
amb\\
set\\
\end{array}
\right ]_{k}
\in
\left [ \begin{array}{c}
\left [ 5\ \ 40 \right ]\\
\left [ 0\ \ 300 \right ]\\
\end{array}
\right ],\\
\\
$and guard set$&
G = \left\{
\left [ \begin{array}{c}
temp\\
heat\\
\end{array} \right ] :
\left [ \begin{array}{cc}
1 & 0\\
0 & 1\\
\end{array}
\right ]
\left [ \begin{array}{c}
temp\\
heat\\
\end{array}
\right ]
<
\left [ \begin{array}{c}
400\\
300\\
\end{array}
\right ] \right\}.
\end{array}$\\
In this model the variables are continuous and take values over the real line,
whereas within the code they are represented as long double precision floating point values, with precision of $\pm 10^{-19}$,
moreover the error of the approximate Jordan form computation results in $\delta_{max}<10^{-17}$.
Henceforth we focus on the latter description, as in the main text of this work.
The eigen-decomposition of the dynamics is (the values are rounded to 3 decimal places):
\begin{displaymath}
A=SJS^{-1} \subseteq
\left [ \begin{array}{cc}
0.798 & 0.173\\
0 & 0.577\\
\end{array}
\right ]
\left [ \begin{array}{cc}
0.985 \pm 10^{-16}& 0.069 \pm 10^{-17}\\
-0.069 \pm 10^{-17}& 0.985 \pm 10^{-16}\\
\end{array}
\right ]
\left [ \begin{array}{cc}
1.253 & - 0.376\\
0 & 1.732\\
\end{array}
\right ].
\end{displaymath}
The discussed over-approximations of the reach-sets indicate that the
temperature variable intersects the guard at iteration $\underline{n}=32$.
Considering the pseudo-eigenvalue matrix (described in the extended version for the case of complex eigenvalues)
along these iterations, we
use Equation~\eqref{abs:mat} to find that the corresponding complex pair
remains within the following boundaries:
\begin{displaymath}
\begin{array}{lr}
\mathcal{A}^{32} =
\left [
\begin{array}{cc}
r & i \\
-i & r\\
\end{array}
\right ]
\left \{
\begin{array}{ccccc}
0.4144 &<& r &< & 0.985\\
0.0691 &<& i &< &0.7651\\
0.1082 &<& r+ i &< &1.247\\
0.9159 &<& i - r &< &0.9389\\
\end{array}
\right.\;\;
&
\mathcal{B}^{32} =
\left [
\begin{array}{cc}
r & i \\
-i & r\\
\end{array}
\right ]
\left \{
\begin{array}{ccccc}
1 &<& r &< & 13.41\\
0 &<& i &< &17.98\\
1 &<& r+ i &< &29.44\\
6.145 &<& i - r &< &6.514\\
\end{array}
\right.
\end{array}
\end{displaymath}
The reach tube is calculated by multiplying these abstract matrices with the
initial sets of states and inputs, as described in
Equation~\eqref{equ:absaccinput0}, by the following inequalities:
\begin{displaymath}
\hat{X}_{32}^\#= \mathcal{A}^{32}
\left [ \begin{array}{c}
\left [5\ \ 40 \right ]\\
\left [0\ \ \ \ 1 \right ]\\
\end{array}
\right ]
+ \mathcal{B}^{32}
\left [ \begin{array}{c}
\left [5\ \ \ 40 \right ]\\
\left [0\ 300 \right ]\\
\end{array}
\right ]
=
\left [
\begin{array}{c}
temp\\
heat\\
\end{array}
\right ]
\left \{
\begin{array}{ccccc}
-24.76 &<& temp &< & 394.5\\
-30.21 &<& heat &< &253\\
-40.85 &<& temp+ heat &< &616.6\\
-86.31 &<& temp - heat &< &843.8\\
\end{array}
\right.
\end{displaymath}
The negative values represent the lack of restriction in the code on the lower side and correspond to system cooling (negative heating).
The set is displayed in Figure \ref{fig:abs}, where for the sake of clarity we display only 8 directions of the 16 constraints.
This results in a rather tight over-approximation that is not much looser than the convex hull of all reach sets obtained by \cite{FLD+11} using the given directions.
In Figure \ref{fig:abs}, we can see the initial set in black colour,
the collection of reach sets in white,
the convex hull of all reach sets in dark blue (as computed by \cite{FLD+11}),
and finally the abstractly accelerated set in light yellow (dashed lines).
The outer lines represent the guards.
\begin{SCfigure}[][t]
\centering
\begin{tikzpicture}[scale=0.9]
\begin{axis}[
height=0.55\textwidth,
ylabel={$heat$},
xlabel={$temp$},]
\addplot[color=red,domain = -20:420] {300};
\node at (axis cs:0,300) [pin={-10:$heat=300$},inner sep=0pt] {};
\addplot[color=red] coordinates {(400,-20) (400,310)};
\addplot[dashed,color=gray,fill=yellow] table{./AAReachTube.dat};
\addplot[color=blue,fill=blue] table{./ReachTube.dat};
\addplot[red] table{./Reach32.dat};
\addplot[blue,fill=white] table{./Reach31.dat};
\addplot[blue,fill=white] table{./Reach30.dat};
\addplot[blue,fill=white] table{./Reach29.dat};
\addplot[blue,fill=white] table{./Reach28.dat};
\addplot[blue,fill=white] table{./Reach27.dat};
\addplot[blue,fill=white] table{./Reach26.dat};
\addplot[blue,fill=white] table{./Reach25.dat};
\addplot[blue,fill=white] table{./Reach24.dat};
\addplot[blue,fill=white] table{./Reach23.dat};
\addplot[blue,fill=white] table{./Reach22.dat};
\addplot[blue,fill=white] table{./Reach21.dat};
\addplot[blue,fill=white] table{./Reach20.dat};
\addplot[blue,fill=white] table{./Reach19.dat};
\addplot[blue,fill=white] table{./Reach18.dat};
\addplot[blue,fill=white] table{./Reach17.dat};
\addplot[blue,fill=white] table{./Reach16.dat};
\addplot[blue,fill=white] table{./Reach15.dat};
\addplot[blue,fill=white] table{./Reach14.dat};
\addplot[blue,fill=white] table{./Reach13.dat};
\addplot[blue,fill=white] table{./Reach12.dat};
\addplot[blue,fill=white] table{./Reach11.dat};
\addplot[blue,fill=white] table{./Reach10.dat};
\addplot[blue,fill=white] table{./Reach9.dat};
\addplot[blue,fill=white] table{./Reach8.dat};
\addplot[blue,fill=white] table{./Reach7.dat};
\addplot[blue,fill=white] table{./Reach6.dat};
\addplot[blue,fill=white] table{./Reach5.dat};
\addplot[blue,fill=white] table{./Reach4.dat};
\addplot[blue,fill=white] table{./Reach3.dat};
\addplot[blue,fill=white] table{./Reach2.dat};
\addplot[blue,fill=white] table{./Reach1.dat};
\addplot[blue,fill=black] table{./Reach0.dat};
\end{axis}
\end{tikzpicture}
\caption{The abstractly accelerated tube (yellow, dashed boundary),
representing an over-approximation of the thermostat reach tube
(dark blue). The set of initial conditions is shown in black, whereas
successive reach sets are shown in white. The guards and the
reach set that crosses them are close to the boundary in red.
} \label{fig:abs}
\end{SCfigure}
\section{Implementation and Experimental Results}\label{sec:sw}
The algorithm has been implemented in C++ using the eigen-algebra package (v3.2),
with double precision floating-point arithmetic,
and has been tested on a 1.6\,GHz core~2 duo computer.
\begin{table*}[t]
\centering
\footnotesize
\begin{tabular}{|l|*{4}{@{\;}c@{\;}}|*{2}{r@{\;\;}}|*{3}{r@{}l@{\;\;}}|*{2}{r@{}l@{\;\;\;}}|}
\hline
& \multicolumn{4}{c|}{characteristics}
& \multicolumn{2}{c|}{improved}
& \multicolumn{6}{c|}{analysis time [sec]} \\
name & type & dim & inputs & bounds & IProc & Sti & \multicolumn{2}{c}{IProc}
& \multicolumn{2}{c}{Sti} & \multicolumn{2}{c|}{J+I}\\ \hline
parabola\_i1& $\neg s$,$\neg c$,$g$ & 2 & 1 & 80 & +25 & +28 & 0&.007 & 237& & 0&.049 \\
parabola\_i2& $\neg s$,$\neg c$,$g$ & 2 & 1 & 80 & +24 & +35 & 0&.008 & 289& & 0&.072 \\
cubic\_i1& $\neg s$,$\neg c$,$g$ & 3 & 1 & 120 & +44 & +50 & 0&.015 & 704& & 0&.097 \\
cubic\_i2& $\neg s$,$\neg c$,$g$ & 3 & 1 & 120 & +35 & +55 & 0&.018 & 699& & 0&.124 \\
oscillator\_i0& $s$,$c$,$\neg g$ & 2 & 0 & 56 & +24 & +24 & 0&.004 & 0&.990 & 0&.021 \\
oscillator\_i1& $s$,$c$,$\neg g$ & 2 & 0 & 56 & +24 & +24 & 0&.004 & 1&.060 & 0&.024 \\
inv\_pendulum& $s$,$c$,$\neg g$ & 4 & 0 & 16 & +8 & +8 & 0&.009 & 0&.920 & 0&.012 \\
convoyCar2\_i0 & $s$,$c$,$\neg g$ & 3 & 2 & 12 & +9 & +9 & 0&.007 & 0&.160 & 0&.043 \\
convoyCar3\_i0 & $s$,$c$,$\neg g$ & 6 & 2 & 24 & +15 & +15 & 0&.010 & 0&.235 & 0&.513 \\
convoyCar3\_i1 & $s$,$c$,$\neg g$ & 6 & 2 & 24 & +15 & +15 & 0&.024 & 0&.237 & 0&.901 \\
convoyCar3\_i2 & $s$,$c$,$\neg g$ & 6 & 2 & 24 & +15 & +15 & 0&.663 & 0&.271 & 1&.416 \\
convoyCar3\_i3 & $s$,$c$,$\neg g$ & 6 & 2 & 24 & +15 & +15 & 0&.122 & 0&.283 & 2&.103 \\ \hline
\end{tabular}\\[0.7ex]
\textbf{type}: \textbf{$s$} -- stable loop, \textbf{$c$} -- complex eigenvalues, \textbf{$g$} -- loops with guard;
\textbf{dim}: system dimension (variables); \textbf{bounds}: nb. of half-planes defining the polyhedral set; \\
\textbf{IProc} is \cite{jeannet2010interproc}; \textbf{Sti} is \cite{colon2003linear}; \textbf{J+I} is this work; \\
\textbf{improved}: number of bounds newly detected by J+I over the existing tools~(IProc,~Sti)
\caption{Experimental comparison of unbounded-time analysis tools with inputs}
\label{tab:exp1}
\end{table*}
\paragraph{Comparison with other unbounded-time approaches.}
In a first experiment we have benchmarked our implementation against the
tools~\textsc{InterProc}~\cite{jeannet2010interproc} and
\textsc{Sting}~\cite{colon2003linear}.
We have tested these tools on
different scenarios, including guarded/unguarded, stable/unstable and
complex/real loops with inputs (details in Table~\ref{tab:exp1}).%
\footnote{The benchmarks are available from \url{https://drive.google.com/file/d/0B22MA57MHHBKX2c3S05pT0d1OHc}.}
It is important to note that in many instances, \textsc{InterProc} \rronly{(due to the limitations of widening)} and
\textsc{Sting} \rronly{(due to the inexistence of tight polyhedral, inductive invariants)} are unable to infer finite bounds at all.
Table~\ref{tab:exp2} shows the comparison
of our implementation using different levels of precision (long
double, 256 bit, and 1024 bit floating point precision) with
the original abstract acceleration for linear
loops without inputs (J)~\cite{JSS14} (where inputs are fixed to
constants).
This shows that our implementation gives tighter over-approximations
on most benchmarks (column `improved').
Whilst on a limited number of instances the current implementation is less precise (Fig.~\ref{aa:supports} gives a hint why this is happening),
the overall increased precision is owed to lifting the limitation on directions caused by the use of logahedral abstractions.%
At the same time, our implementation is faster -- even when used with
1024 bit floating point precision -- than the original abstract
acceleration (using rationals). The fact that many bounds have improved with
the new approach, while speed has increased by several orders of
magnitude, provides evidence of the advantages of the new approach.
The speed-up is due to the faster Jordan form
computation, which takes between 2 and 65 seconds for ~\cite{JSS14} (using the ATLAS
package), whereas our implementation requires at most one second.
For the last two benchmarks, the polyhedral computations blow up in ~\cite{JSS14},
whereas our support function approach shows only moderately increasing runtimes.
The increase of speed is owed to multiple factors, as detailed in Table~\ref{tab:speed}.
The difference of using long double precision floating points vs arbitrary
precision arithmetic is negligible as all results in the given examples match
exactly to 9 decimal places. Note that, as explained above, soundness
can be ensured by correct rounding in the floating point computations.
\begin{table*}[t]
\centering
\footnotesize
\begin{tabular}{|l|lcc|rr|r@{}lr@{}l|@{\;\;}r@{}lr@{}l|@{\;\;}r@{}l|@{\;\;}r@{}l|}
\hline
& \multicolumn{3}{c|}{characteristics}
& \multicolumn{2}{c|}{improved}
& \multicolumn{12}{c|}{analysis time (sec)} \\
name & type & dim & bounds & tighter& loose
& \multicolumn{4}{c}{\quad J\quad (jcf)} &\multicolumn{4}{l}{mpfr+(jcf) }
& \multicolumn{2}{l}{mpfr} & \multicolumn{2}{c|}{ld}\\ \hline
parabola\_i1& $\neg s$,$\neg c$,$g$ & 3 & 80 &+4(5\%) & 0(0\%) & 2&.51 &( 2&.49) & 0&.16&(0&.06) & 0&.097 & 0&.007 \\
parabola\_i2& $\neg s$,$\neg c$,$g$ & 3 & 80 &+4(5\%) & 0(0\%) & 2&.51 &( 2&.49) & 0&.26&(0&.06)& 0&.101 & 0&.008 \\
cubic\_i1& $\neg s$,$\neg c$,$g$ & 4 & 120 & 0(0\%) & 0(0\%) & 2&.47 &( 2&.39) & 0&.27 &(0&.20) & 0&.110 & 0&.013 \\
cubic\_i2& $\neg s$,$\neg c$,$g$ & 4 & 120 & 0(0\%) & 0(0\%) & 2&.49 &( 2&.39) & 0&.32&(0&.20) & 0&.124 & 0&.014 \\
oscillator\_i0& $s$,$c$,$\neg g$ & 2 & 56 & 0(0\%) & -1(2\%) & 2&.53 &( 2&.52) & 0&.12 &(0&.06)& 0&.063 & 0&.007 \\
oscillator\_i1& $s$,$c$,$\neg g$ & 2 & 56 & 0(0\%) & -1(2\%) & 2&.53 &( 2&.52) & 0 &.12 &(0&.06)& 0&.078 & 0&.008 \\
inv\_pendulum& $s$,$c$,$\neg g$ & 4 & 12 & +8(50\%) & 0(0\%) & 65&.78 &(65&.24) & 0&.24 & (0&.13) & 0&.103 & 0&.012 \\
convoyCar2\_i0 & $s$,$c$,$\neg g$ & 5 & 12 & +9(45\%) & 0(0\%) & 5&.46 &( 4&.69) & 3&.58&(0&.22) & 0&.258 & 0&.005 \\
convoyCar3\_i0 & $s$,$c$,$\neg g$ & 8 & 24 & +10(31\%) & -2(6\%) & 24&.62 & (11&.98) & 3&.11&(1&.01) & 0&.552 & 0&.051 \\
convoyCar3\_i1 & $s$,$c$,$\neg g$ & 8 & 24 & +10(31\%) & -2(6\%)& 23&.92 & (11&.98) & 4&.94&(1&.01) & 0&.890 & 0&.121 \\
convoyCar3\_i2 & $s$,$c$,$\neg g$ & 8 & 24 & +10(31\%) & -2(6\%) & 1717&.00 & (11&.98) & 6&.81&(1&.01) & 1&.190 & 0&.234 \\
convoyCar3\_i3 & $s$,$c$,$\neg g$ & 8 & 24 & +10(31\%) & -2(6\%) & 1569&.00 & (11&.98) & 8&.67&(1&.01) & 1&.520 & 0&.377 \\ \hline
\end{tabular}\\[0.7ex]
{\footnotesize\textbf{type}: \textbf{$s$} -- stable loop, \textbf{$c$} -- complex eigenvalues, \textbf{$g$} -- loops with guard;
\textbf{dim}: system dimension (including fixed inputs); \textbf{bounds}: nb. of half-planes defining the polyhedral set;
\textbf{improved}: number of bounds (and percentage) that were tighter (better) or looser (worse) than \cite{JSS14}; \\
\textbf{J} is \cite{JSS14}; \textbf{mpfr+} is this paper using 1024bit
mantissas ($e<10^{-152}$); \textbf{mpfr} uses a 256bit mantissa
($e<10^{-44}$); \textbf{ld} uses a 64bit mantissa ($e<10^{-11}$); here $e$ is
the accumulated error of the dynamical system; \textbf{jcf}: time
taken to compute Jordan form \\[0.5ex]}
\caption{Experimental comparison with previous work}
\label{tab:exp2}
\end{table*}
\begin{table}[b!]
\centering
\footnotesize
\begin{tabular}{|l|*{1}{@{\;\;}c@{\;}}|}
\hline
Optimization & Speed-up \\ \hline \hline
Eigen vs.~ATLAS (http://eigen.tuxfamily.org/index.php?title=Benchmark) & $2$--$10$ \\ \hline
Support functions vs.~generators for abstract matrix synthesis
& $2$--$40$ \\ \hline
long double vs.~multiple precision arithmetic &
$5$--$200$ \\ \hline \hline
Total & $20$--$80000$ \\ \hline
\end{tabular}~\\[0.5ex]
\caption{Performance improvements by feature}
\label{tab:speed}
\end{table}
\paragraph{Comparison with bounded-time approaches.}
In a third experiment, we compare our method with the LGG algorithm~\cite{LG09}
used by \textsc{SpaceEx}~\cite{FLD+11}. In order to set up a fair
comparison we have provided the implementation of the native algorithm
in~\cite{LG09}. We have run both methods on the convoyCar example~\cite{JSS14} with inputs, which presents an unguarded,
scalable, stable loop with complex dynamics, and focused on octahedral
abstractions.
For convex reach sets, the approximations computed by abstract acceleration
are quite tight in comparison to those computed by the LGG algorithm.
However, storing finite disjunctions of convex polyhedra, the LGG algorithm
is able to generate non-convex reach tubes, which are arguably more proper
in case of oscillating or spiralling dynamics.
Still, in many applications abstract acceleration can provide a tight
over-approximation of the convex hull of those non-convex reach sets.
Table~\ref{tab:spaceX} shows the results of this comparison. For simplicity,
we present only the projection of the bounds along the variables of interest.
As expected, the LGG algorithm performs better in terms of tightness,
but its runtime increases with the number of iterations.
Our implementation of LGG using Convex Polyhedra with octagonal
templates is slower than the abstractly accelerated version even for
small time horizons (our implementation of LGG requires $\sim\!4$\,ms
for each iteration on a 6-dimensional problem with octagonal
abstraction). This can be improved by the use of zonotopes, or by
careful selection of the directions along the eigenvectors, but this
comes at a cost on precision. Even when finding combinations that
outperform our approach, this will only allow the time horizon of the
LGG approach to be slightly extended before matching the analysis time
from abstract acceleration, and the reachable states will still
remain unknown beyond the extended time horizon.
The evident advantage of abstract acceleration is its speed over finite horizons without much precision loss,
and of course the ability to prove properties for unbounded-time horizons.
\begin{table}[t]
\centering
\footnotesize
\begin{tabular}{|l|*{2}{@{\;\;\;}c@{\;}}|*{3}{c@{\;\;\;}}|}
\hline
& \multicolumn{2}{c|}{this paper} & \multicolumn{3}{c|}{LGG}\\
name & 100 iterations &\;\;\; unbounded \;\;\;& 100 iterations& 200 iterations & 300 iterations \\ \hline
run time & 5\,ms & 5\,ms & 50\,ms & 140\,ms & 195\,ms\\
car acceleration & [-0.895 1.34] & [-1.038 1.34] &[-0.802 1.31] & [-0.968 1.31] & [-0.968 1.31] \\
car speed & [-1.342 5.27] & [-4.059 5.27] &[-1.331 4.98] & [-3.651 4.98] & [-3.677 4.98] \\
car position & [42.66 83.8] & [42.66 90.3] & [43.32 95.5] & [43.32 95.5] & [43.32 95.6]\\ \hline
\end{tabular}~\\[0.5ex]
\caption{Comparison on convoyCar2 benchmark, between this work and
the LGG algorithm~\cite{LG09}}
\label{tab:spaceX}
\end{table}
\paragraph{Scalability.}
Finally, in terms of scalability, we have an expected
$\mathcal{O}(n^3)$ complexity worst-case bound (from the matrix multiplications in equation \ref{equ:absaccinput0}).
We have parameterised the
number of cars in the convoyCar example~\cite{JSS14} (also seen in
Table~\ref{tab:exp2}), and experimented with up to 33 cars (each car after the
first requires 3 variables, so that for example $(33-1)\times 3= 96$ variables), and
have adjusted the initial states/inputs sets. We report an average of 10 runs
for each configuration. These results demonstrate that our method scales to industrial-size problems.
\begin{center}
\small\begin{tabular}{|l|*{6}{@{\;\;\;}c@{\;}}|}
\hline
\# of variables & 3 & 6 & 12 & 24 & 48 & 96\\
runtime & 4\,ms & 31\,ms & 62\,ms & 477\,ms & 5.4\,s & 56\,s \\ \hline
\end{tabular}~\\[-0.5ex]
\end{center}
\section{Conclusions and Future Work} \label{sec:concl}
We have presented an extension of the Abstract Acceleration paradigm to
guarded LTI systems (linear loops) with inputs, overcoming the limitations
of existing work dealing with closed systems. We have decisively
shown the new approach to over-compete state-of-the-art tools for
unbounded-time reachability analysis in both precision and scalability. The
new approach is capable of handling general unbounded-time safety analysis
for large scale open systems with reasonable precision and fast computation
times. Conditionals inside loops and nested loops are out of the scope of
this paper.
Work to be done is extending the approach to non-linear
dynamics, which we believe can be explored via hybridisation
techniques~\cite{ADG07}, and to formalise the framework for general hybrid
models with multiple guards and location-dependent dynamics, with the aim to
accelerate transitions across guards rather than integrate individual
accelerations on either side of the guards.
\paragraph{\textsc{Acknowledgments}.}
We would like to thank Colas Le Guernic for his
constructive suggestions and comments on the paper.
\bibliographystyle{splncs03}
|
{'timestamp': '2015-08-28T02:13:22', 'yymm': '1506', 'arxiv_id': '1506.05607', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05607'}
|
arxiv
|
\subsection{The exclusive switch model in the case of equal degradation rates}
\subsubsection{Model definition and deterministic dynamics}
Our starting point here are rate equations (2) in the main text, obtained in the limit of fast binding/unbinding compared to other processes in the circuit~\cite{loinger2007stochastic}, see main text. These equations describe the dynamics of the mean number of $A$ and $B$ proteins, denoted by $n_1$ and $n_2$, respectively, and read
\begin{equation} \label{sm_odes}
\dot{n}_1 = \frac{1+kn_1}{1+kn_1+kn_2} - \alpha_1 n_1,\quad \dot{n}_2 = \frac{1+kn_2}{1+kn_1+kn_2} - \alpha_2 n_2.
\end{equation}
Here, we have denoted the repression strength by $k=\kappa_0 / \kappa_1$, which is the ratio between the binding rate $\kappa_0$ and unbinding rate $\kappa_1$ to/from the promoter. In addition, we have taken $g_A=g_B\equiv g$, rescaled time $t\to gt$, and denoted the rescaled degradation rates $\alpha_1=d_A/g$ and $\alpha_2=d_B/g$, see main text for the definition of parameters.
System~\eqref{sm_odes} admits a unique positive stable fixed point. Assuming $\alpha_1=\alpha_2\equiv \alpha$ (we will relax this assumption later on), we find
\begin{equation} \label{nfp}
n^*_1 = n^*_2 = \frac{k -\alpha +\sqrt{\alpha ^2+k^2+6 \alpha k}}{4 k \alpha}.
\end{equation}
From now on we will consider the strong repression limit, $\varepsilon\equiv\alpha/k \ll 1$, meaning that degradation is assumed to occur much slower than inhibition. In this limit, the fixed point~\eqref{nfp} simplifies to $n^*_1 = n^*_2 \simeq 1/(2\alpha)$. As a result, in the strong repression limit we can naturally define an \textit{effective} system size as $\alpha^{-1}$. By additionally defining the protein concentrations $x_i = \alpha n_i$, $i=1,2$, the rate equations~(\ref{sm_odes}) become
\begin{equation}\label{REs}
\dot{x}_1=\frac{x_1+\varepsilon }{x_1+x_2+\varepsilon }- x_1, \quad \dot{x}_2=\frac{x_2+\varepsilon }{x_1+x_2+\varepsilon }- x_2,
\end{equation}
where we have further rescaled time by $t\to \alpha t$. Equations~(\ref{REs}) are governed by a single parameter, $\varepsilon$, although $\alpha$ still appears in the definition of the concentrations, a fact that we shall use to carry out the expansion of the master equation.
\subsubsection{Relationship between model parameters and physical system size and biological relevance of parameter values}
As discussed in the main text, system~\eqref{sm_odes} is obtained by applying an adiabatic approximation of the following system of ODEs:
\begin{eqnarray} \label{sm_ESMrate}
\dot{n}_1 & =& g_A(1-r_B)-d_A n_1 - \kappa_0 n_1(1-r_A-r_B)+\kappa_1 r_A\nonumber\\
\dot{n}_2 & =& g_B(1-r_A)-d_B n_2 - \kappa_0 n_2(1-r_A-r_B)+\kappa_1 r_B\nonumber\\
\dot{r}_A & =& \kappa_0 n_1(1-r_A-r_B) - \kappa_1 r_A\nonumber\\
\dot{r}_B & =& \kappa_0 n_2(1-r_A-r_B) - \kappa_1 r_B,
\end{eqnarray}
where $g_A = g_B = g$ are the maximal production rates of proteins $A$ and $B$, $d_A=d_B=d$ are the corresponding degradation rates, and $r_A$ and $r_B$ the copy numbers of bound repressors. The constant $\kappa_0$ denotes the binding rate of proteins to the promoter while $\kappa_1$ is the dissociation rate. Recall also that these parameters are related to those of system~\eqref{sm_odes} via $k=\kappa_0/\kappa_1$ and $\alpha=d/g$.
Let us denote the physical system size by $N$. Changing the physical system size signifies using a larger reservoir with a larger number of molecules, but without changing the rules between the single interacting molecules. Since some of the terms in system~\eqref{sm_ESMrate} depend on the number of molecules in play (and some others do not), it is the purpose of this section to identify how the parameters in system~\eqref{sm_ESMrate} scale with respect to $N$. Clearly, we expect according to the definition of the system size that $n_i \sim N$ and also, that the degradation rates $d_A$ and $d_B$ do not depend on $N$.
The adiabatic reduction assumes that the variables $r_A$ and $r_B$ evolve faster than $n_1$ and $n_2$. This indicates that the terms on the right hand side of the third and fourth equations of system~\eqref{sm_ESMrate} approximately balance each other, and we find \textit{e.g.}
\begin{equation}
\kappa_0 n_1(1-r_A-r_B) \sim \kappa_1 r_A.
\end{equation}
As a result, since $r_A, r_B\sim \mathcal O(1)$, we find that $k = \kappa_0 / \kappa_1 \sim N^{-1}$. Moreover, close to the fixed point, one can follow a similar argument for the first and second equations of system~(\ref{sm_ESMrate}), and find that $g \sim N^{-1}$, while $\alpha \sim N^{-1}$. Therefore, both the repression strength constant $k$ and the effective degradation rate $\alpha$ are inversely proportional to the physical system size $N$. Yet, in our rescaled model, because of the scaling of the fixed point~\eqref{nfp} on $\alpha$, it is legitimate to define the concentrations variables by $x_i = \alpha n_i$ ($i=1,2$), rather than $x_i = N^{-1} n_i$. Note, that for a given $N$, one can increase/decrease the effective system size $\alpha^{-1}$ by changing the physical degradation rate $d$, while keeping $k$ constant.
We now discuss the biological relevance of the approximations used throughout the paper. We make use of three assumptions: (i) $k$ is assumed to be on the order of one; (ii) the strong repression limit implies that $\epsilon = k/\alpha \ll 1$; (iii) $\alpha$ is assumed to be small so that we can expand the master equation in $\alpha\ll 1$.
Assumption (i) can always be obtained by rescaling time and the copy number variables. If assumption (i) is satisfied, then assumption (iii) follows from (ii). Therefore, we only need to justify assumption (ii) which is the strong repression limit $\varepsilon\ll 1$. As stated, this limit assumes that protein degradation occurs much slower than inhibition. Indeed, this assumption has often been invoked in previous theoretical works~\cite{lipshtat2006genetic, loinger2007stochastic}. Moreover, in Ref.~\cite{gardner2000construction}, the genetic switch model is compared to an experimental switch engineered using \textit{E. Coli}. It is found that in order to have bimodality, the inhibition rate should be $15$ times faster than the degradation rate in one species, and $150$ times faster in the other (see caption of Fig.~5 in Ref.~\cite{gardner2000construction}). This number provides realistic values for $\varepsilon^{-1}$. Furthermore, a similar value of $\varepsilon=0.04$ appears in Ref.~\cite{allen2005sampling}.
\subsubsection{Stochastic dynamics and Fokker-Planck/Langevin approximation}
The stochastic exclusive switch model can be obtained by viewing the terms of system~\eqref{sm_odes} as microscopic rates of production and degradation of transcription factors. Let us denote by $T_1^+$ and $T_2^+$ the production rates, and by $T_1^-$ and $T_2^-$ the degradation rates of proteins of type $A$ and $B$, respectively. Given a state with $n_1$ and $n_2$ particles of type $A$ and $B$ respectively, these transition rates satisfy
\begin{eqnarray} \label{sm_trates}
T_1^+(n_1,n_2) = \frac{1+ k n_1}{1+k n_1+k n_2} , & \quad T_1^-(n_1,n_2) = \alpha n_1,\nonumber\\
T_2^+(n_1,n_2) = \frac{1+ k n_2}{1+k n_1+k n_2} , & \quad T_2^-(n_1,n_2) = \alpha n_2.
\end{eqnarray}
Using these, we can write down the master equation for the evolution of the probability density function (PDF) $P_{n_1, n_2}(t)$ that the system is in state $(n_1, n_2)$ at time $t$:
\begin{eqnarray} \label{sm_me}
\dot{P}_{n_1,n_2}=T_1^+(n_1-1,n_2)P_{n_1-1,n_2}-T_1^+(n_1,n_2)P_{n_1,n_2}+T_2^+(n_1,n_2-1)P_{n_1,n_2-1}-T_2^+(n_1,n_2)P_{n_1,n_2}\nonumber \\
+T_1^-(n_1+1,n_2)P_{n_1+1,n_2}-T_1^-(n_1,n_2)P_{n_1,n_2}+T_2^-(n_1,n_2+1)P_{n_1,n_2+1}-T_2^-(n_1,n_2)P_{n_1,n_2}.
\end{eqnarray}
Equation~\eqref{sm_me} with transition rates~\eqref{sm_trates} defines the stochastic model for the case of equal degradation rates, and can be simulated using the Gillespie algorithm~\cite{Gillespie1977}.
Let us now approximate master equation~(\ref{sm_me}) into a Fokker-Planck equation. We do so by Taylor expanding
\begin{equation}
T_1^\pm(n_1\mp 1,n_2)P_{n_1\mp 1,n_2}\simeq T_1^\pm(n_1,n_2)P_{n_1,n_2}\mp\partial_{n_1}[T_1^\pm(n_1,n_2)P_{n_1,n_2}]+\frac{1}{2}\partial_{n_1}^2[T_1^\pm(n_1,n_2)P_{n_1,n_2}],
\end{equation}
and same for $T_2^\pm$. We now move to the concentration variables $x_i=\alpha n_i$, $i=1,2$, and use the fact that $\partial_{n_i}=\alpha\partial_{x_i}$, which turns the Taylor expansion into a system size expansion. Employing this system size expansion on master equation~(\ref{sm_me}), valid when the system size is large $1/\alpha\gg 1$, we arrive at the following Fokker-Planck equation for $P(x_1,x_2,t)$ -- the probability to find concentrations $x_1$ and $x_2$ of $A$ and $B$ proteins, respectively, at time $t$:
\begin{equation} \label{sm_fpe}
\partial_{\alpha t} P(x_1,x_2,t) = \left[ - \partial_{x_1} \mathcal A_1 - \partial_{x_2} \mathcal A_2 + \frac{\alpha}{2} \sum_{i,j=1}^2 \partial_{x_i} \partial_{x_j} \mathcal B_{ij} \right] P(x_1,x_2,t).
\end{equation}
Here we have neglected $\mathcal{O}(\alpha^3)$ terms or higher, time is measured in $\alpha t$ units, and
\begin{equation}
\mathcal A_i = \frac{x_i+\varepsilon }{x_1+x_2+\varepsilon }-x_i,\quad \text{and}\quad \mathcal B_{ij} = \left(\frac{x_i+\varepsilon }{x_1+x_2+\varepsilon }+x_i \right) \delta_{ij}.
\end{equation}
Equation~\eqref{sm_fpe} is equivalent to the system of Langevin equations defined in the It\={o} sense~\cite{Gardiner2009}:
\begin{equation} \label{sm_xieq}
\begin{split}
\frac{dx_i }{d(\alpha t)} &= \mathcal A_i + \sqrt \alpha \sqrt{\mathcal B_{ii}} \eta_i(\alpha t), \quad i=1,2,
\end{split}
\end{equation}
where $\eta_i(t)$, $i=1,2$, are independent normalized white Gaussian noises.
As a final remark, note that system~\eqref{sm_xieq} is a better approximation to the master equation than the linear noise approximation obtained, e.g, with the van Kampen expansion~\cite{Kampen2007}. In fact, system~\eqref{sm_xieq} captures the multiplicative nature of the noise which, as we shall show, is the main driver of bimodality. The expansion technique that we have used is described in more detail in~\cite{McKane2013}.
\subsubsection{Simplifying the Langevin equations}
We now introduce the new variables
\begin{equation} \label{sm_wu}
w = x_1+x_2,\quad u=\frac{x_1-x_2}{x_1+x_2},
\end{equation}
and change variables in the Fokker-Planck equation~\eqref{sm_fpe} or, equivalently, in system~\eqref{sm_xieq} using the It\={o} formula~\cite{Gardiner2009} (the latter is simpler). Doing so, and neglecting $\mathcal O(\sqrt \varepsilon)$ terms in the noise coefficients, we arrive at
\begin{equation} \label{sm_wsm_ueq}
\frac{dw}{d(\alpha t)} = \frac{-w^2-w \varepsilon +w+2 \varepsilon }{w+\varepsilon } + \sqrt \alpha\sqrt{1+w}\, \eta_{1}(\alpha t), \quad \frac{du}{d(\alpha t)} = - 2 u \varepsilon \frac{w-\alpha}{w^2 (w+\varepsilon )} + \sqrt \alpha\sqrt{(1-u^2)\frac{1+w}{w^2}}\, \eta_{2}(\alpha t). \\
\end{equation}{}
Following the main text, we indicate by $\mathcal P_s(u,w)$ the stationary PDF of Eqs.~\eqref{sm_wsm_ueq}. Equations~\eqref{sm_wsm_ueq} need to be decoupled in order to be analytically tractable. Simulations (lower panel of Fig. 1 in the main text) indicate that the total concentration $w$ fluctuates around the only stable fixed point $\left(1-\varepsilon+\sqrt{1+6 \varepsilon +\varepsilon ^2}\right)/2\,\simeq 1+\varepsilon$, a fact we wish to exploit for decoupling the two variables. We can see this effect by Taylor expanding in $\varepsilon\ll 1$ the deterministic part of the first of Eqs.~\eqref{sm_wsm_ueq},
\begin{equation}
\frac{-w^2-w \varepsilon +w+2 \varepsilon }{w+\varepsilon} \approx w(w-w^*),\quad \text{where } w^*=1+\varepsilon.
\end{equation}
Hence, it is legitimate to linearize the first of Eqs.~\eqref{sm_wsm_ueq} around $w^*$ which, in the leading order of $\varepsilon\ll 1$, becomes
\begin{equation}
\frac{dw}{d(\alpha t)} =-(w-w^*)+\sqrt{2\alpha}\,\eta_1(\alpha t).
\end{equation}
Therefore, the stationary PDF for finding concentration $w$ reads
\begin{equation}
R_s(w)=\frac{1}{\sqrt{2\pi\alpha}} \exp{ \left(-\frac{[w-(1+\varepsilon)]^2}{2\alpha}\right)}.
\end{equation}
This indicates that for $\varepsilon\ll 1$, the total number of $A$'s and $B$'s, represented by $w$, is approximately conserved.
We now approximate the second of Eqs.~\eqref{sm_wsm_ueq} by setting $w$ equal to $w^*$. We further simplify this equation by noting that
\begin{equation} \label{sm_sim}
\frac{w^*-\alpha}{w^{*2}(w^{*}+\varepsilon)}\approx 1,\quad \text{and}\quad \frac{w^*+1}{w^{*2}} \approx 2,
\end{equation}
and by rescaling time by $2 \varepsilon$. As a result, the Langevin equation for $u$ reads
\begin{equation} \label{sm_ueq}
\frac{du}{d\tilde{t}} = -u + \sqrt{k} \sqrt{1-u^2}\,\eta_2(\tilde{t}),
\end{equation}
where $\tilde{t} = 2 \varepsilon \alpha t = (2 \alpha^{2}/k) t$, and $t$ is the time used in Eq.~\eqref{sm_me}. Note that in order to reach Eq.~(\ref{sm_me}) we have already rescaled time $t\to gt$, so the physical time units contain an additional $1/g$ factor, see main text. We denote the stationary PDF of Eq.~(\ref{sm_ueq}) by $P_s(u)$. We have thus established that $\mathcal P_s(u,w) = P_s(u)R_s(w)$. Eq.~(\ref{sm_ueq}) and its stationary solution are further discussed in the main text, where we find that the mean switching time scales polynomially with $\alpha^{-1}$. Yet, verifying this result experimentally is expected to be highly nontrivial, as trapping of single cells over many cell cycles is required (\textit{e.g.} by using a microfluidic device) to carry our such measurements.
\subsection{The exclusive switch model in the case of different degradation rates}
\subsubsection{Model definition and deterministic dynamics}
The exclusive switch model~\eqref{sm_odes} can be generalized to the case of different degradation rates:
\begin{equation} \label{sm_odes2}
\dot{n}_1=\frac{1+ k n_1}{1+k n_1+k n_2}-\alpha_1 n_1,\quad \dot{n}_2=\frac{1+ k n_2}{1+k n_1+k n_2}-\alpha_2 n_2.
\end{equation}
We assume, without loss of generality, $\alpha_2 < \alpha_1$, and denote $\alpha_1\equiv\alpha$ and $\alpha_2\equiv\delta\alpha$, where $\delta \in (0, 1]$. The concentrations of $A$ and $B$ are given respectively by $x_1=\alpha n_1$ and $x_2=\alpha n_2$. Rescaling time $t\to \alpha t$ and using $\varepsilon = \alpha/k$, we arrive at the following rescaled rate equations
\begin{equation} \label{sm_xysys}
\dot{x_1} = \frac{x_1 + \varepsilon}{x_1+x_2+\varepsilon}-x_1,\quad \dot{x_2} = \frac{x_2 + \varepsilon}{x_1+x_2+\varepsilon}-\delta x_2.
\end{equation}
The corresponding stochastic model is described by a master equation given by Eq.~(\ref{sm_me}) with rates~(\ref{sm_trates}) where here $T_2^-(n_1,n_2)=\delta \alpha n_2$.
Note that in this case we keep our original system size definition as $\alpha^{-1}$.
\subsubsection{Derivation of the Langevin equations and analysis}
Expanding master equation~\eqref{sm_me} in a similar way to the previous section, we arrive at the following system of Langevin equations:
\begin{eqnarray}\label{sm_xieq2}
\frac{d x_1}{d (\alpha t)} &=& \frac{x_1+\varepsilon }{x_1+x_2+\varepsilon }-x_1 + \sqrt{\alpha } \sqrt{\frac{x_1+\varepsilon }{x_1+x_2+\varepsilon }+x_1}\; \eta_1(\alpha t),\nonumber\\
\frac{d x_2}{d (\alpha t)} &=& \frac{x_2+\varepsilon }{x_1+x_2+\varepsilon } -\delta x_2 + \sqrt{\alpha } \sqrt{\frac{x_2+\varepsilon }{x_1+x_2+\varepsilon }+\delta x_2}\; \eta_2(\alpha t).
\end{eqnarray}
These equations reduce to system~\eqref{sm_xieq} for $\delta=1$.
We now change variables in system~\eqref{sm_xieq2} using the It\={o} formula~\cite{Gardiner2009}, from $(x_1, x_2)$ to $(w, u)$ defined in Eqs.~\eqref{sm_wu}. We obtain
\begin{equation} \label{sm_wu2}
\frac{dw}{d(\alpha t)} = \mathcal A_w + \mathcal G_{11} \eta_1(\alpha t) + \mathcal G_{12} \eta_1(\alpha t),\quad
\frac{du}{d(\alpha t)} = \mathcal A_u + \mathcal G_{21} \eta_1(\alpha t) + \mathcal G_{22} \eta_2(\alpha t),
\end{equation}
where the deterministic part for $w$ reads
\begin{equation}
\mathcal A_w = \frac{1}{2}\left(\delta u w-u w-\delta w-\frac{2 w}{w+\varepsilon }-w+4\right),
\end{equation}
and the deterministic part for $u$, written as a term independent of $\delta$ plus a correction, is
\begin{equation} \label{sm_au}
\mathcal A_u = - 2 u \varepsilon \frac{w-\alpha}{w^2 (w+\varepsilon )} + (\delta - 1) \frac{\left(1-u^2\right) w^2 (\alpha +w)- u^2 w \varepsilon (\alpha +w)+w \varepsilon (\alpha +w)}{2 w^2 (w+\varepsilon )}.
\end{equation}
In addition, the expression for the noise matrix $\mathcal G$, neglecting $\mathcal O(\sqrt \varepsilon)$ terms, reads
\begin{equation}
\mathcal G = \frac{\sqrt \alpha}{w\sqrt 2}\left(\begin{array}{cc}
\sqrt{w^2 (u+1) (w+1)} & \sqrt{w^2 (1-u) (w \delta +1)} \\
(1-u) \sqrt{(1+u) (w+1)} & -(1+u) \sqrt{(1-u) (w \delta +1)} \\
\end{array}\right).
\end{equation}
As a final remark, note that instead of matrix $\mathcal G$ one can just reabsorb the noise coefficients by defining new noise variables, $\xi_1$ and $\xi_2$, so that Eqs.~\eqref{sm_wu2} become
\begin{equation} \label{sm_wu3}
\frac{dw}{d(\alpha t)} = \mathcal A_w + \xi_1(\alpha t),\quad
\frac{du}{d(\alpha t)} = \mathcal A_u + \xi_2(\alpha t).
\end{equation}
Here, the correlator of the two noise variables reads $\langle \xi_i(t)\xi_j(t')\rangle = \mathcal B_{ij}(u,w) \delta(t-t')$, with $\mathcal B = \mathcal G \mathcal G^T$. This is indeed the result that one arrives at by applying the change of variable~\eqref{sm_wu} to the Fokker-Planck equation rather that using the It\={o} formula on the corresponding Langevin system. Yet, we have pursued the latter approach since it is simpler.
In order to decouple Eqs.~\eqref{sm_wu2}, we compute the single $u$-dependent positive fixed point of the $w$ equation, $w^*(u)$. Taylor expanding this fixed point in $\varepsilon\ll 1$, we arrive at the expression:
\begin{equation} \label{sm_adiab}
w^*(u) \approx \frac{2}{\delta -\delta u+u+1}.
\end{equation}
We now employ an adiabatic elimination~\cite{Assaf2008noise} of $w$ by substituting $w= w^*(u)$ into the $u$ equation. Moreover, we sum the two noise terms using the summation rule for Gaussian variables~\cite{Gardiner2009}
\begin{equation}
\mathcal G_{21} \eta_1(\alpha t) + \mathcal G_{22} \eta_2(\alpha t) = \sqrt{\mathcal G_{21}^2 + \mathcal G_{22}^2}\, \eta(\alpha t) = \sqrt{\mathcal B_{uu}} \eta(\alpha t),\quad \text{where }\; \mathcal B_{uu} = \alpha\left(1 - u^2\right) \left\{\frac{w^*(u) [\delta +(\delta -1) u+1]+2}{2 w^*(u)^2}\right\},
\end{equation}
and $\eta(t)$ is normalized white Gaussian noise. Substituting Eq.~\eqref{sm_adiab} into the expression for $\mathcal B_{uu}$, we arrive at the simple formula
\begin{equation}
\mathcal B_{uu} = \frac{\alpha}{2}(1-u^2) (1+\delta) [\delta +(1-\delta)u +1].
\end{equation}
We now simplify the deterministic part of the $u$-equation, Eq.~\eqref{sm_au}, by neglecting small terms. The first term of Eq.~\eqref{sm_au} is simplified according to Eq.~\eqref{sm_sim}, as done in the previous section. The second $\delta$-dependent term is approximated by taking the leading order result with respect to $\alpha\ll 1$ and $\varepsilon\ll 1$. As a result, we arrive at the final Langevin equation for $u$:
\begin{equation}\label{Langeu}
\frac{du}{d(\alpha t)} = \frac{1}{2} (\delta -1) \left(1-u^2\right)-\frac{1}{2} u \varepsilon(\delta-\delta u +u+1)^2+ \sqrt{\frac{\alpha}{2}}\sqrt{(1-u^2)(1+\delta) [\delta +(1-\delta)u +1]}\;\eta(\alpha t).
\end{equation}
This equation describes the model for the case of different degradation rates and its stationary solution is discussed in the main text. The stationary PDF, $Q_s(u)$, for finding concentration $u$ can be found from Eq.~(\ref{Langeu}) and reads
\begin{equation} \label{pdfSM}
Q_s(u)=\mathcal Z \left(1-u^2\right)^{\frac{1-k}{k}} (1+u+\delta-u\delta)^{-1-\frac{2}{\alpha(1+\delta)}}\exp \left( \frac{1}{k} \left(\frac{1-\delta}{1+\delta}\right) \left[2u+\ln\left(\frac{1-u}{1+u} \right) \right] \right),
\end{equation}
where $\mathcal Z$ is a normalization factor such that $\int_{-1}^{1}Q_s(u)du=1$.
\subsubsection{Investigation of the tilted PDF in the case of different degradation rates}
PDF~\eqref{pdfSM} is a tilted version of the PDF in the equal $\alpha$ case, see Eq.~(6) in the main text. Indeed, the former reduces to the latter for $\delta=1$. To remind the reader, without loss of generality we assume $\delta<1$.
When $k>k_C$ (where $k_C$ is the critical repression strength below which bimodality is lost, see below), both $u=1$ and $u=-1$ are noise-induced metastable states. For $\delta<1$, we find that the system resides most of the time in the metastable mode of $u=-1$ and occasionally jumps to the transiently metastable mode of $u=1$ (the opposite would occur for $\delta>1$). This is because the degradation rate of protein $B$ is smaller in this case. In contrast, as $k$ is decreased below $k_C$, first the mode at $u=1$ and then the mode at $u=-1$ are lost, and eventually the PDF flips, and becomes a unimodal PDF with a peak at $u^*$ which is the mode of Eq.~(\ref{pdfSM}). Differentiating the logarithm of PDF~(\ref{pdfSM}) once and equating to zero, we find the PDF mode at $k<k_C$ to be at
\begin{equation}\label{mode}
u^*\simeq -1+\frac{\delta(\delta+1)\alpha}{k(1-\delta)}\left(\frac{2\delta}{\delta+1}-k\right).
\end{equation}
In order to find $k_C$ in the case of different degradation rates we evaluate $k$ at which $Q_s(u)$ ceases to be bimodal. As $k$ is decreased, the mode at $u=1$ disappears before the mode at $u=-1$ does. As a result, $k_C$ can be found by checking when the concavity at $u=1$ of $Q_s(u)$ changes sign. Alternatively, since for $k>k_C$, $Q_s'(u\to 1)\to \infty$, while for $k<k_C$, $Q_s'(u\to 1)\to -\infty$, we can find $k_C$ by demanding that at $k=k_C$, the first derivative at $u=1$ does not diverge. Using Eq.~(\ref{pdfSM}), we differentiate the logarithm of $Q_s(u)$ once and evaluate the result in the vicinity of $u=1$. In the limit of $\alpha\ll 1$, the result is
\begin{equation}
\frac{d\ln Q_s(u)}{du}=\frac{Q_s'(u)}{Q_s(u)}\simeq \frac{2/[k(1+\delta)]-1}{u-1}+\frac{\delta-1}{\alpha(\delta+1)}+{\cal O}(u-1).
\end{equation}
As stated, at $k=k_C$ the first (diverging) term has to vanish. Therefore, we find
\begin{equation}
k_C = \frac{2}{1+\delta}.
\end{equation}
This result consistently reduces to $k_C=1$, at $\delta\to 1$. Note, that the value of $k$ at which the PDF flips at $u=-1$ is lower than $k_C$ and is obtained at $k=2\delta/(1+\delta)<k_C$. Only for values of $k$ lower than this value, the PDF actually becomes unimodal, and the mode is given by Eq.~(\ref{mode}), which is indeed valid as long as $u_*>-1$ or $k<2\delta/(1+\delta)$.
\bibliographystyle{apsrev4-1}
|
{'timestamp': '2015-10-23T02:08:41', 'yymm': '1506', 'arxiv_id': '1506.05583', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05583'}
|
arxiv
|
\section{\noindent \noindent Introduction}
Regression modeling is ubiquitous in empirical areas of scientific research,
because most research questions can be asked in terms of how a dependent
variable changes as a function of one or more covariates (predictors).
Applications of regression modeling involve either prediction analysis
(e.g., Dension et al., 2002\nocite{DenisonHolmesMallickSmith02}; Hastie et
al. 2009\nocite{HastieTibsFriedman09}), categorical data analysis (e.g.,
Agresti, 2002\nocite{Agresti02}), causal analysis (e.g., Imbens, 2004\nocit
{Imbens04}; Imbens \&\ Lemieux, 2008\nocite{ImbensLemieux2008}; Stuart, 201
\nocite{Stuart10}), meta-analysis (e.g., Cooper, et al. 2009\nocit
{CooperHedgesValentine09}), survival analysis of censored data (e.g., Klein
\&\ Moeschberger, 2010\nocite{KleinMoeschberger10}), spatial data analysis
(e.g., Gelfand, et al., 2010\nocite{GelfandDiggleGuttorpFuentes10}),
time-series analysis (e.g., Prado \&\ West, 2010\nocite{PradoWest2010}),
item response theory (IRT)\ analysis (e.g., van der Linden, 2015\nocit
{vanderLinden15}), and/or other types of regression analyses.
These applications often involve either the normal random-effects
(multi-level) linear regression model (e.g., hierarchical linear model;
HLM). This general model assumes that the mean of the dependent variable
changes linearly as a function of each covariate; the distribution of the
regression errors follows a zero-mean symmetric continuous (e.g., normal)\
distribution; and the random regression coefficients are normally
distributed over pre-defined groups, according to a normal (random-effects)\
mixture distribution. Under the ordinary linear model, this mixture
distribution has variance zero. For a discrete dependent variable, all of
the previous assumptions apply for the underlying (continuous-valued)\
latent dependent variable. For example, a logit model (probit model, resp.)\
for a binary-valued (0 or 1) dependent variable implies a linear model for
the underlying latent dependent variable, with error distribution assumed to
follow a logistic distribution with mean 0 and scale 1 (normal distribution
with mean 0 and variance 1, resp.) (e.g., Dension et al., 2002\nocit
{DenisonHolmesMallickSmith02}).
If data violate any of these linear model assumptions, then the estimates of
regression coefficient parameters can be misleading. As a result, much
research has devoted to the development of more flexible, Bayesian
nonparametric (BNP)\ regression models. Each of these models can provide a
more robust, reliable, and rich approach to statistical inference,
especially in common settings where the normal linear model assumptions are
violated. Excellent reviews of BNP\ models are given elsewhere (e.g.,
Walker, et al., 1999\nocite{WalkerDamienLaudSmith99}; Ghosh \& Ramamoorthi,
2003\nocite{GR03}; M\"{u}ller\ \&\ Quintana, 2004\nocite{MullerQuintana04};
Hjort, et al. 2010\nocite{HjortHolmesMullerWalker10}; Mitra \&\ M\"{u}ller,
2015\nocite{MitraMuller15}).
A BNP\ model is a highly-flexible model for data, defined by an infinite (or
a very large finite)\ number of parameters, with parameter space assigned a
prior distribution with large supports (M\"{u}ller \&\ Quintana, 2004\nocit
{MullerQuintana04}). Typical BNP\ models have an infinite-dimensional,
functional parameter, such as a distribution function. According to Bayes'
theorem, a set of data updates the prior to a posterior distribution, which
conveys the plausible values of the model parameters given the data and the
chosen prior. Typically in practice, Markov chain Monte Carlo (MCMC)
sampling methods (e.g., Brooks, et al. 2011\nocite{BrooksGelmanJonesMeng11})
are used to estimate the posterior distribution (and chosen functionals)\ of
the model parameters.
Among the many BNP models that are available, the most popular models in
practice are infinite-mixture models, each having mixture distribution
assigned a (BNP)\ prior distribution on the entire space of probability
measures (distribution functions). BNP infinite-mixture models are popular
in practice, because they can provide a flexible and robust regression
analysis of data, and provide posterior-based clustering of subjects into
distinct homogeneous groups, where each subject cluster group is defined by
a common value of the (mixed)\ random model parameter(s). A standard BNP\
model is defined by the Dirichlet process (infinite-) mixture (DPM)\ model
(Lo, 1984\nocite{Lo84}), with mixture distribution assigned a Dirichlet
process (DP) (Ferguson, 1973\nocite{Ferguson73}) prior distribution on the
space of probability measures. Also, often in practice, a BNP\ model is
specified as an infinite-mixture of normal distributions. This is motivated
by the well-known fact that any smooth probability density (distribution)\
of any shape and location can be approximated arbitrarily-well by a mixture
of normal distributions, provided that the mixture has a suitable number of
mixture components, mixture weights, and component parameters (mean and
variance).
A flexible BNP\ infinite-mixture model need not be a DPM\ model, but may
instead have a mixture distribution that is assigned another BNP prior,
defined either by a more general stick-breaking process (Ishwaran \&\ James,
2001\nocite{IshwaranJames01}; Pitman, 1996\nocite{Pitman96}), such as the
Pitman-Yor (or Poisson-Dirichlet) process (Pitman, 1996\nocite{Pitman96};
Pitman \&\ Yor, 1997\nocite{PitmanYor97}), the normalized stable process
(Kingman, 1975\nocite{Kingman75}), the beta two-parameter process (Ishwaran
\&\ Zarapour, 2000\nocite{IshwaranZarepour00}); or a process with more
restrictive, geometric mixture weights (Fuentes-Garc\'{\i}a, et al. 2009,
2010\nocite{Fuentes-GarciaMenaWalker09}\nocite{Fuentes-GarciaMenaWalker10});
or defined by the normalized inverse-Gaussian process (Lijoi, et al. 200
\nocite{LijoiMenaPrunster05}), a general type of normalized random measure
(Regazzini et al., 2003\nocite{RegazziniLijoiPrunster03}).
A more general BNP\ infinite-mixture model can be constructed by assigning
its mixture distribution a covariate-dependent BNP\ prior. Such a BNP\
mixture model allows the entire dependent variable distribution to change
flexibly as a function of covariate(s). The Dependent Dirichlet process
(DDP; MacEachern, 1999\nocite{MacEachern99}, 2000\nocite{MacEachern00}, 200
\nocite{MacEachern01}) is a seminal covariate-dependent BNP\ prior. On the
other hand, the infinite-probits prior is defined by a dependent normalized
random measure, constructed by an infinite number of covariate-dependent
mixture weights, with weights specified by an ordinal probits regression
with prior distribution assigned to the regression coefficient and error
variance parameters (Karabatsos \& Walker, 2012a\nocite{KarabatsosWalker12c
).
The applicability of BNP\ models, for data analysis, depends on the
availability of user-friendly software. This is because BNP models typically
admit complex representations, which may not be immediately accessible to
non-experts or beginners in BNP. Currently there are two nice command-driven
R software packages for BNP\ mixture modeling. The \textbf{DPpackage} (Jara,
et al., 2011\nocite{Jara_etal11}) of R (the R Development Core Team, 201
\nocite{Rsoftware15}) includes many BNP models, mostly DPM\ models, that
provide either flexible regression or density estimation for data analysis.
The package also provides BNP\ models having parameters assigned a flexible
mixture of finite P\'{o}lya Trees BNP\ prior (Hanson, 2006\nocite{Hanson06
). The \textbf{bspmma} R package (Burr, 2012\nocite{Burr12}) provides DPM\
normal-mixture models for meta-analysis.
The existing packages for BNP\ modeling, while impressive, still suggest
room for improvements, as summarized by the following points.
\begin{enumerate}
\item While the existing BNP\ packages provide many DPM\ models, they do not
provide a BNP\ infinite-mixture model with mixture distribution assigned any
one of the other important BNP\ priors mentioned earlier. Priors include
those defined by the Pitman-Yor, normalized stable, beta, normalized
inverse-Gaussian process; or defined by a geometric weights or
infinite-probits prior. As an exception, the \textbf{DPpackage} provides a
Pitman-Yor process mixture of regressions model for interval-censored data
(Jara, et al. 2010\nocite{JaraEtAl10}).
\item The \textbf{bspmma} R package (Burr, 2012\nocite{Burr12}), for
meta-analysis, is limited to DPM\ models that do not incorporate covariate
dependence (Burr \&\ Doss, 2005\nocite{Burr_Doss05}).
\item The \textbf{DPpackage} handles interval-censored data, but does not
handle left- or right-censored data.
\item While both BNP\ packages use MCMC\ sampling algorithms to estimate the
posterior distribution of the user-chosen model, each package does not
provide a MCMC\ convergence analysis (e.g., Flegal \&\ Jones, 2011\nocit
{FlegalJones11}). A BNP\ package that provides its own menu options for
MCMC\ convergence analysis would be, for the user, faster and more
convenient, and would not require learning a new package (e.g., \textbf{CODA}
R package; Plummer et al., 2006\nocite{PlummerBestCowlesVines06}) to conduct
MCMC\ convergence analyses.
\item Both BNP\ packages do not provide many options to investigate how the
posterior predictive distribution (and chosen functionals)\ of the dependent
variable, varies as a function of one or more covariates.
\item Generally speaking, command-driven software can be unfriendly,
confusing, and time-consuming to beginners and to experts.
\end{enumerate}
In this paper, we introduce a stand-alone and user-friendly software package
for BNP\ modeling, which the author constructed using MATLAB Compiler
(Natick, MA). This package, named:\ \textbf{Bayesian Regression:\
Nonparametric and Parametric Models}, provides BNP\ data analysis in a fully
menu-driven software environment that resembles SPSS (I.B.M., 2015\nocit
{IBMcorp15}).
\noindent The software allows the user to mouse-click menu options:
\begin{enumerate}
\item To inspect, describe, and explore the variables of the data set, via
basic descriptive statistics (e.g., means, standard deviations,
quantiles/percentiles) and graphs (e.g., scatter plots, box plots, normal
Q-Q plots, kernel density plots, etc.);
\item To pre-process the data of the dependent variable and/or the
covariate(s) before including the variable(s) into the BNP\ regression model
for data analysis. Examples of data pre-processing includes constructing new
dummy indicator (0 or 1) variables and/or two-way interaction variables from
the covariates (variables), along with other options to transform variables;
and performing a nearest-neighbor hot-deck imputation (Andridge \&\ Little,
2010\nocite{AndridgeLittle10}) of missing data values in the variables
(e.g., covariate(s)).
\item To use list and input dialogs to select, in the following order: the
Bayesian model for data analysis; the dependent variable; covariate(s) (if a
regression model was selected); parameters of the prior distribution of the
model; the (level-2 and possibly level-3)\ grouping variables (for a
multilevel model, if selected); the observation weights variable (if
necessary; e.g., to set up a meta-analysis); and the variables describing
the nature of the censored dependent variable observations (if necessary;
e.g., to set up a survival analysis). The observations can either be
left-censored, right-censored, interval-censored, or uncensored. Also, if so
desired, the user can easily use point-and-click to quickly highlight and
select a large list of covariates for the model, whereas command-driven
software requires the user to carefully type (or copy and paste) and
correctly-verify the long list of the covariates.
\end{enumerate}
\noindent After the user make these selections, \noindent the Bayesian
Regression software immediately presents a graphic of the user-chosen
Bayesian model in the middle of the computer screen, along with all of the
variables that were selected for this model (e.g., dependent variables,
covariate(s); see \#3\ above). The explicit presentation of the model is
important because BNP\ models typically admit complex representations. In
contrast, the command-driven packages do not provide immediate on-screen
presentations of the BNP\ model selected by the user.
Then the software user can click a button to run the MCMC\ sampling
algorithm for the menu-selected Bayesian model. The user clicks this button
after entering a number of MCMC\ sampling iterations. Immediately after all
the MCMC\ sampling iterations have completed, the software automatically
opens a text output file that summarizes the basic results of the data
analysis (derived from the generated MCMC\ samples). Results include
point-estimates of the (marginal)\ posterior distributions of the model's
parameters, and summaries of the model's predictive fit to the data. Then,
the user can click other menu options to produce graphical output of the
results. They include density plots, box plots, scatter plots, trace plots,
and various plots of (marginal)\ posterior distributions of model parameters
and fit statistics. For each available BNP\ infinite-mixture model, the
software implements standard slice sampling MCMC\ methods (Kalli,\ et al.
2011\nocite{KalliGriffinWalker11}) that are suitable for making inferences
of the posterior distribution (and chosen functionals)\ of model parameters.
Next, after a few mouse-clicks of appropriate menu options, the user can
perform a detailed MCMC\ convergence analysis. This analysis evaluates
whether a sufficiently-large number of MCMC\ samples (sampling iterations of
the MCMC\ algorithm) has been generated, in order to warrant the conclusion
that these samples have converged to samples from the posterior distribution
(and chosen functionals)\ of the model parameters. More details about how to
use the software to perform MCMC\ convergence analysis is provided in
Sections 3.1 and 5.2.
The software also provides menu options to investigate how the posterior
predictive distribution (and functionals)\ of the dependent variable changes
as a function of covariates. Functionals of the posterior predictive
distribution include: the mean, median, and quantiles to provide a quantile
regression analysis; the variance functional to prove a variance regression
analysis; the probability density function (p.d.f.) and the cumulative
distribution function (c.d.f.) to provide a density regression analysis; and
the survival function, hazard function, and the cumulative hazard function,
for survival analysis. The software also provides posterior predictive
inferences for BNP\ infinite-mixture models that do not incorporate
covariates and only focus on density estimation.
Currently, the \textbf{Bayesian Regression} software provides the user a
choice from 83 Bayesian models for data analysis. Models include 47 BNP\
infinite-mixture regression models, 31 normal linear models for comparative
purposes, and 5 BNP\ infinite normal mixture models for density estimation.
Most of the infinite-mixture models are defined by normal mixtures.
The 47 BNP\ infinite-mixture regression models can each handle a dependent
variable that is either continuous-valued, binary-valued (0 or 1), or
ordinal valued ($c=0,1,\ldots ,m$), using either a probit or logit version
of this model for a discrete dependent variable; with mixture distribution
assigned a prior distribution defined either by the Dirichlet process,
Pitman-Yor process (including the normalized stable process), beta
(2-parameter)\ process, geometric weights prior, normalized inverse-Gaussian
process, or an infinite-probits regression prior; and with mixing done on
either the intercept parameter, or on the intercept and slope coefficient
parameters, and possibly on the error variance parameter. Specifically, the
regression models with mixture distribution assigned a Dirichlet process
prior are equivalent to ANOVA/linear DDP models, defined by an
infinite-mixture of normal distributions, with a covariate-dependent mixture
distribution defined by independent weights (De Iorio, et al. 2004\nocit
{DeIorioMullerRosnerMacEachern04}; M\"{u}ller et al., 2005\nocit
{MullerRosnerDeIorioMacEachern05}). Similarly, the models with mixture
distribution, instead, assigned a different BNP\ prior distribution
(process)\ mentioned above, implies a covariate-dependent version of that
process. See Section 3.1 for more details. Also, some of the
infinite-mixture regression models, with covariate-dependent mixture
distribution assigned a infinite-probits prior, have spike-and-slab priors
assigned to the coefficients of this BNP\ prior, based on stochastic search
variable selection (SSVS) (George \& McCulloch, 1993\nocit
{GeorgeMcCulloch93}, 1997\nocite{GeorgeMcCulloch97}). In addition, the 5
BNP\ infinite normal mixture models, for density estimation, include those
with mixture distribution assigned a BNP\ prior distribution that is defined
by either one of the 5 BNP\ process mentioned above (excluding
infinite-probits).
Finally, the 31 Bayesian linear models of the Bayesian regression software
include ordinary linear models, 2-level, and 3-level normal random-effects
(or HLM)\ models, for a continuous dependent variable; probit and logit
versions of these linear models for\ either a binary (0 or 1) or ordinal (
c=0,1,\ldots ,m$) dependent variable; and with mixture distribution
specified for the intercept parameter, or for the intercept and slope
coefficient parameters.
The outline for the rest of the paper is as follows. Section 2 reviews the
Bayesian inference framework. Appendix A\ reviews the basic probability
theory notation and concepts that we use. In Section 3, we define two key
BNP\ infinite-mixture regression models, each with mixture distribution
assigned a BNP\ prior distribution on the space of probability measures. The
other 50 BNP infinite-mixture models of the \textbf{Bayesian regression}
software are extensions of these two key models, and in that section we give
an overview of the various BNP\ priors mentioned earlier. In that section we
also describe the Bayesian normal linear model, and a Bayesian normal
random-effects linear model (HLM). Section 4 gives step-by-step software
instructions on how to perform data analysis using a menu-chosen, Bayesian
model. Section 5 illustrates the \textbf{Bayesian regression} software
through the analysis of a real data set, using each of the two key BNP\
models, and a Bayesian linear model. Appendix B provides a list of exercises
that the software user can work through in order to practice BNP\ modeling
on several example data sets, available from the software. These
data-analysis exercises address applied problems in prediction analysis,
categorical data analysis, causal analysis, meta-analysis, survival analysis
of censored data, spatial data analysis, time-series analysis, and item
response theory analysis. Section 6 ends with conclusions.
\section{Overview of Bayesian Inference}
In a given research setting where it is of interest to apply a regression
data analysis, a sample data set is of the form $\mathcal{D}_{n}=\{(y_{i}
\mathbf{x}_{i})\}_{i=1}^{n}$. Here, $n$ is the sample size of the
observations, respectively indexed by $i=1,\ldots ,n$, where $y_{i}$ is the
i$th observation of the dependent variable $Y_{i}$, corresponding to an
observed vector of $p$ observed covariates\footnote
For each Bayesian model for density estimation, from the software, we assume
$\mathbf{x}=1$.} $\mathbf{x}_{i}=(1,x_{i1},\ldots ,x_{ip})^{\intercal }$. A
constant (1)\ term is included in $\mathbf{x}$ for future notational
convenience.
A regression model assumes a specific form for the probability density (or
p.m.f.)\ function $f(y\,|\,\mathbf{x};\boldsymbol{\zeta })$, conditionally
on covariates $\mathbf{x}$ and model parameters denoted by a vector,
\boldsymbol{\zeta }\in \Omega _{\boldsymbol{\zeta }}$, where $\Omega _
\boldsymbol{\zeta }}=\{\boldsymbol{\zeta }\}$ is the parameter space. For
any given model parameter value $\boldsymbol{\zeta }\in \Omega _{\boldsymbol
\zeta }}$, the density $f(y_{i}\,|\,\mathbf{x}_{i};\boldsymbol{\zeta })$ is
the likelihood of $y_{i}$ given $\mathbf{x}_{i}$, and $L(\mathcal{D}_{n}\,;\
\boldsymbol{\zeta })=\tprod\nolimits_{i=1}^{n}f(y_{i}\,|\,\mathbf{x}_{i}
\boldsymbol{\zeta })$ is the likelihood of the full data set $\mathcal{D
_{n} $ under the model. A Bayesian regression model is completed by the
specification of a prior distribution (c.d.f.) $\Pi (\boldsymbol{\zeta })$
over the parameter space $\Omega _{\boldsymbol{\zeta }}$, and $\pi
\boldsymbol{\zeta })$ gives the corresponding probability density of a given
parameter $\boldsymbol{\zeta }\in \Omega _{\boldsymbol{\zeta }}$.
According to Bayes' theorem, after observing the data $\mathcal{D
_{n}=\{(y_{i},\mathbf{x}_{i})\}_{i=1}^{n}$, the plausible values of the
model parameter $\boldsymbol{\zeta }$ is given by the posterior
distribution. This distribution defines the posterior probability density of
a given parameter $\boldsymbol{\zeta }\in \Omega _{\boldsymbol{\zeta }}$ by
\begin{equation}
\pi (\boldsymbol{\zeta }\,|\,\mathcal{D}_{n})=\dfrac{\tpro
\nolimits_{i=1}^{n}f(y_{i}\,|\,\mathbf{x}_{i};\boldsymbol{\zeta })\mathrm{d
\Pi (\boldsymbol{\zeta })}{\dint\nolimits_{\Omega _{\boldsymbol{\zeta
}}\tprod\nolimits_{i=1}^{n}f(y_{i}\,|\,\mathbf{x}_{i};\boldsymbol{\zeta }
\mathrm{d}\Pi (\boldsymbol{\zeta })}. \label{Posterior}
\end{equation
Conditionally on a chosen value of the covariates $\mathbf{x
=(1,x_{1},\ldots ,x_{p})^{\intercal }$, the posterior predictive density of
a future observation $y_{n+1}$, and the corresponding posterior predictive
c.d.f. ($F(y\,|\,\mathbf{x})$), mean (expectation, $\mathbb{E}$), variance (
\mathbb{V}$), median, $u$th quantile ($Q(u\,|\,\mathbf{x})$, for some chosen
$u\in \lbrack 0,1]$, with $Q(.5\,|\,\mathbf{x})$ the conditional median),
survival function ($S$), hazard function ($H$), and cumulative hazard
function ($\Lambda $), is given respectively by:
\begin{subequations}
\label{pp all}
\begin{eqnarray}
f_{n}(y\,|\,\mathbf{x}) &=&\dint f(y\,|\,\mathbf{x};\boldsymbol{\zeta }
\mathrm{d}\Pi (\boldsymbol{\zeta }\,|\,\mathcal{D}_{n}), \label{pp pdf} \\
F_{n}(y\,|\,\mathbf{x}) &=&\dint_{Y\leq y}f(y\,|\,\mathbf{x};\boldsymbol
\zeta })\mathrm{d}\Pi (\boldsymbol{\zeta }\,|\,\mathcal{D}_{n}),
\label{pp cdf} \\
\mathbb{E}_{n}(Y\,|\,\mathbf{x}) &=&\dint y\mathrm{d}F_{n}(y\,|\,\mathbf{x}),
\label{pp E} \\
\mathbb{V}_{n}(Y\,|\,\mathbf{x}) &=&\dint \{y-\mathbb{E}_{n}(Y\,|\,\mathbf{x
)\}^{2}\mathrm{d}F_{n}(y\,|\,\mathbf{x}), \label{pp Var} \\
Q_{n}(u\,|\,\mathbf{x}) &=&F_{n}^{-1}(u\,|\,\mathbf{x}), \label{pp q} \\
S_{n}(y\,|\,\mathbf{x}) &=&1-F_{n}(y\,|\,\mathbf{x}), \label{pp surv} \\
H_{n}(y\,|\,\mathbf{x}) &=&f_{n}(y\,|\,\mathbf{x})/\{1-F_{n}(y\,|\,\mathbf{x
)\}, \label{pp haz} \\
\Lambda _{n}(y\,|\,\mathbf{x}) &=&-\log \{1-F_{n}(y\,|\,\mathbf{x})\}.
\label{pp cumhaz}
\end{eqnarray
Depending on the choice of posterior predictive functional from (\ref{pp all
), a Bayesian regression analysis can provide inferences in terms of how the
mean (\ref{pp E}), variance (\ref{pp Var}), quantile (\ref{pp q}) (for a
given choice $u\in \lbrack 0,1]$), p.d.f. (\ref{pp pdf}), c.d.f. (\ref{pp
cdf}), survival function (\ref{pp surv}), hazard function (\ref{pp haz}), or
cumulative hazard function (\ref{pp cumhaz}), of the dependent variable $Y$,
varies as a function of the covariates $\mathbf{x}$. While the mean
functional $\mathbb{E}_{n}(Y\,|\,\mathbf{x})$ is conventional for applied
regression, the choice of functional $\mathbb{V}_{n}(Y\,|\,\mathbf{x})$
pertains to variance regression; the choice of function $Q_{n}(u\,|\,\mathbf
x})$ pertains to quantile regression; the choice of p.d.f. $f_{n}(y\,|\
\mathbf{x})$ or c.d.f. $F_{n}(y\,|\,\mathbf{x})$ pertains to Bayesian
density (distribution)\ regression; and the choice of survival $S_{n}(y\,|\
\mathbf{x})$ or a hazard function ($H_{n}(y\,|\,\mathbf{x})$ or $\Lambda
_{n}(y\,|\,\mathbf{x})$) pertains to survival analysis.
In practice, the predictions of the dependent variable $Y$ (for a chosen
functional from (\ref{pp all})), can be easily viewed (in a graph or table)\
as a function of a subset of only one or two covariates. Therefore, for
practice we need to consider predictive methods that involve such a small
subset of covariates. To this end, let $\mathbf{x}_{\mathcal{S}}$ be a focal
subset of the covariates $(x_{1},\ldots ,x_{p})$, with $\mathbf{x}_{\mathcal
S}}$ also including the constant (1) term. Also,\ let $\mathbf{x}_{\mathcal{
}}$ be the non-focal, complement set of $q$ (unselected) covariates. Then
\mathbf{x}_{\mathcal{S}}\cap \mathbf{x}_{\mathcal{C}}\neq \emptyset $ and
\mathbf{x=x}_{\mathcal{S}}\cup \mathbf{x}_{\mathcal{C}}$.
It is possible to study how the predictions of a dependent variable $Y$
varies as a function of the focal covariates $\mathbf{x}_{\mathcal{S}}$,
using one of four automatic methods. The first two methods are conventional.
They include the \textit{grand-mean centering method}, which assumes that
the non-focal covariates $\mathbf{x}_{\mathcal{C}}$ is defined by the mean
in the data $\mathcal{D}_{n}$, with $\mathbf{x}_{\mathcal{C}}:=\tfrac{1}{n
\tsum\nolimits_{i=1}^{n}\mathbf{x}_{\mathcal{C}i}$; and the \textit
zero-centering method}, which assumes that the non-focal covariates are
given by $\mathbf{x}_{\mathcal{C}}:=\mathbf{0}_{q}$ where $\mathbf{0}_{q}$
is a vector of $q$ zeros. Both methods coincide if the observed covariates
\{\mathbf{x}_{i}=(1,x_{i1},\ldots ,x_{ip})^{\intercal }\}_{i=1}^{n}$ in the
data $\mathcal{D}_{n}$ have average $(1,0,\ldots ,0)^{\intercal }$. This is
the case if the covariate data $\{x_{ik}\}_{i=1}^{n}$ have already been
centered to have mean zero, for $k=1,\ldots ,p$.
The partial dependence method (Friedman, 2001, Section 8.2\nocite{Friedman01
) is the third method for studying how the predictions of a dependent
variable $Y$ varies as a function of the focal covariates $\mathbf{x}_
\mathcal{S}}$. In this method, the predictions of $Y$, conditionally on each
value of the focal covariates $\mathbf{x}_{\mathcal{S}}$, are averaged over
data ($\mathcal{D}_{n}$) observations $\{\mathbf{x}_{\mathcal{C
i}\}_{i=1}^{n}$ (and effects) of the non-focal covariates $\mathbf{x}_
\mathcal{C}}$. Specifically, in terms of the posterior predictive
functionals (\ref{pp all}), the averaged prediction of $Y$, conditionally on
a value of the covariates $\mathbf{x}_{\mathcal{S}}$, is given respectively
by:
\end{subequations}
\begin{subequations}
\label{pd all}
\begin{eqnarray}
f_{n}(y\,|\,\mathbf{x}_{S}) &=&\tfrac{1}{n}\tsum\nolimits_{i=1}^{n}f_{n}(
\,|\,\mathbf{x}_{S},\mathbf{x}_{\mathcal{C}i}), \label{pd pdf} \\
F_{n}(y\,|\,\mathbf{x}_{S}) &=&\tfrac{1}{n}\tsum\nolimits_{i=1}^{n}F_{n}(
\,|\,\mathbf{x}_{S},\mathbf{x}_{\mathcal{C}i}), \label{pd cdf} \\
\mathbb{E}_{n}(Y\,|\,\mathbf{x}_{S}) &=&\tfrac{1}{n}\tsum\nolimits_{i=1}^{n
\mathbb{E}_{n}(Y\,|\,\mathbf{x}_{S},\mathbf{x}_{\mathcal{C}i}), \label{pd E}
\\
\mathbb{V}_{n}(Y\,|\,\mathbf{x}_{S}) &=&\tfrac{1}{n}\tsum\nolimits_{i=1}^{n
\mathbb{E}_{n}(Y\,|\,\mathbf{x}_{S},\mathbf{x}_{\mathcal{C}i}), \label{pd V}
\\
Q_{n}(u\,|\,\mathbf{x}_{S}) &=&\tfrac{1}{n}\tsu
\nolimits_{i=1}^{n}F_{n}^{-1}(u\,|\,\mathbf{x}_{S},\mathbf{x}_{\mathcal{C
i}), \label{pd Q} \\
S_{n}(y\,|\,\mathbf{x}_{S}) &=&\tfrac{1}{n}\tsum\nolimits_{i=1}^{n
\{1-F_{n}(y\,|\,\mathbf{x}_{S},\mathbf{x}_{\mathcal{C}i})\}, \label{pd Surv}
\\
H_{n}(y\,|\,\mathbf{x}_{S}) &=&\tfrac{1}{n}\tsum\nolimits_{i=1}^{n}H_{n}(
\,|\,\mathbf{x}_{\mathcal{S}},\mathbf{x}_{\mathcal{C}i}), \label{pd Haz} \\
\Lambda _{n}(y\,|\,\mathbf{x}_{S}) &=&\tfrac{1}{n}\tsum\nolimits_{i=1}^{n}
\log \{1-F_{n}(y\,|\,\mathbf{x}_{S},\mathbf{x}_{\mathcal{C}i})\}.
\label{pd CumHaz}
\end{eqnarray
The equations above give, respectively, the (partial dependence)\ posterior
predictive density, c.d.f., mean, variance, quantile (at $u\in \lbrack 0,1]
), survival function, hazard function, and cumulative hazard function, of $Y
, conditionally on a value $\mathbf{x}_{S}$ of the focal covariates. As a
side note pertaining to causal analysis, suppose that the focal covariates
include a covariate, denoted $T$, along with a constant (1)\ term, so that
\mathbf{x}_{S}=(1,t)$. Also suppose that the covariate $T$ is a
binary-valued (0,1) indicator of treatment receipt, versus non-treatment
receipt. Then the estimate of a chosen (partial-dependence) posterior
predictive functional of $Y$\ under treatment ($T=1$) from (\ref{pd all}),
minus that posterior predictive functional under control ($T=0$), provides
an estimate of the causal average treatment effect (CATE). This is true
provided that the assumptions of unconfoundedness and overlap hold (Imbens,
2004\nocite{Imbens04}).
The partial-dependence method can be computationally-demanding, as a
function of sample size ($n$), the dimensionality of $\mathbf{x}_{S}$, the
number of $\mathbf{x}_{S}$ values considered when investigating how $Y$\
varies as a function of $\mathbf{x}_{S}$, and the number of MCMC\ sampling
iterations performed for the estimation of the posterior distribution
(density (\ref{Posterior})) of the model parameters. In contrast, the
\textit{clustered partial dependence method}, the fourth method, is less
computationally-demanding. This method is based on forming $K$-means cluster
centroids, $\{\mathbf{x}_{\mathcal{C}t}\}_{t=1}^{K}$, of the data
observations $\{\mathbf{x}_{\mathcal{C}i}\}_{i=1}^{n}$ of the non-focal
covariates $\mathbf{x}_{\mathcal{C}}$, with $K=\sqrt{n/2}$ clusters as a
rule-of-thumb. Then the posterior predictions of $Y$, conditionally on
chosen value of the covariate subset $\mathbf{x}_{\mathcal{S}}$, is given by
any one of the chosen posterior functionals (\ref{pd all}) of interest,
after replacing $\tfrac{1}{n}\tsum\nolimits_{i=1}^{n}$ with $\tfrac{1}{K
\tsum\nolimits_{t=1}^{K}$, and $\mathbf{x}_{\mathcal{C}i}$ with $\mathbf{x}_
\mathcal{C}t}$.
The predictive fit of a Bayesian regression model, to a set of data,
\mathcal{D}_{n}=\{(y_{i},\mathbf{x}_{i})\}_{i=1}^{n}$, can be assessed on
the basis of the posterior predictive expectation (\ref{pp E}) and variance
\ref{pp Var}). First, the standardized residual fit statistics of the model
are defined by:
\end{subequations}
\begin{equation}
r_{i}=\dfrac{y_{i}-\mathbb{E}_{n}(Y\,|\,\mathbf{x}_{i})}{\sqrt{\mathbb{V
_{n}(Y\,|\,\mathbf{x}_{i})}},\text{ \ \ }i=1,\ldots ,n. \label{pp residual}
\end{equation
An observation $y_{i}$ can be judged as an outlier under the model, when its
absolute standardized residual $|\,r_{i}\,|\,$ exceeds 2 or 3. The
proportion of variance explained in the dependent variable $Y$, by a
Bayesian model, is measured by the R-squared statistic
\begin{equation}
R^{2}=1-\left( \dfrac{\tsum\nolimits_{i=1}^{n}(y_{i}-\mathbb{E}_{n}[Y\,|\
\mathbf{x}_{i}])^{2}}{\tsum\nolimits_{i=1}^{n}\left\{ y_{i}-\left( \frac{1}{
}\tsum\nolimits_{i=1}^{n}y_{i}\right) \right\} ^{2}}\right) .
\label{R squared}
\end{equation
Also, suppose that it is of interest to compare $M$ regression models, in
terms of predictive fit to the given data set $\mathcal{D}_{n}$. Models are
indexed by $\underline{m}=1,\ldots ,M$, respectively. For each model
\underline{m}$, a global measure of predictive fit is given by the
mean-squared predictive error criterion
\begin{equation}
D(\underline{m})=\tsum\nolimits_{i=1}^{n}\{y_{i}-\mathbb{E}_{n}(Y\,|\
\mathbf{x}_{i}\mathbf{,}\underline{m})\}^{2}+\tsum\nolimits_{i=1}^{n}\mathbb
V}_{n}(Y\,|\,\mathbf{x}_{i}\mathbf{,}\underline{m}) \label{Dm criterion}
\end{equation
(Laud \&\ Ibrahim, 1995\nocite{LaudIbrahim1995}; Gelfand \&\ Ghosh, 199
\nocite{GelfandGhosh98}). The first term in (\ref{Dm criterion}) measures
model goodness-of-fit to the data $\mathcal{D}_{n}$, and the second term is
a model complexity penalty. Among a set of $M$ regression models compared,
the model with the best predictive fit for the data $\mathcal{D}_{n}$ is
identified as the one that has the smallest value of $D(\underline{m})$.
\subsection{MCMC\ Methods}
In practice, a typical Bayesian model does not admit a closed-form solution
for its posterior distribution (density function of the form (\ref{Posterior
)). However, the posterior distribution, along with any function of the
posterior distribution of interest, can be estimated through the use of
Monte Carlo methods. In practice, they usually involve Markov Chain Monte
Carlo (MCMC) methods (e.g., Brooks et al., 2011\nocit
{BrooksGelmanJonesMeng11}). Such a method aims to construct a discrete-time
Harris ergodic Markov chain $\{\boldsymbol{\zeta }^{(s)}\}_{s=1}^{S}$ with
stationary (posterior)\ distribution $\Pi (\boldsymbol{\zeta }\,|\,\mathcal{
}_{n})$, and ergodicity is ensured by a proper (integrable)\ prior density
function $\pi (\boldsymbol{\zeta })$ (Robert \&\ Casella, 2004, Section
10.4.3\nocite{RobertCasella04}). A realization $\boldsymbol{\zeta }^{(s)}$
from the Markov chain can be generated by first specifying partitions
(blocks) $\boldsymbol{\zeta }_{b}$ ($b=1,\ldots ,B$) of the model's
parameter $\boldsymbol{\zeta }$, and then simulating a sample from each of
the full conditional posterior distributions $\Pi (\boldsymbol{\zeta
_{b}\,|\,\mathcal{D}_{n},\boldsymbol{\zeta }_{c},c\neq b)$, in turn for
b=1,\ldots ,B$. Then, as $S\rightarrow \infty $, the Markov (MCMC)\ chain $\
\boldsymbol{\zeta }^{(s)}\}_{s=1}^{S}$ converges to samples from the
posterior distribution $\Pi (\boldsymbol{\zeta }\,|\,\mathcal{D}_{n})$.
Therefore, in practice, the goal is to construct a MCMC\ chain (samples) $\
\boldsymbol{\zeta }^{(s)}\}_{s=1}^{S}$\ for a sufficiently-large finite $S$.
MCMC\ convergence analyses can be performed in order to check whether a
sufficiently-large number ($S$) of sampling iterations has been run, to
warrant the conclusion that the resulting samples ($\{\boldsymbol{\zeta
^{(s)}\}_{s=1}^{S}$) have converged (practically)\ to samples from the
model's posterior distribution. Such an analysis may focus only on the model
parameters of interest for data analysis, if so desired. MCMC convergence
can be investigated in two steps (Geyer, 2011\nocite{Geyer11}). One step is
to inspect, for each of these model parameters, the univariate trace plot of
parameter samples over the MCMC sampling iterations. This is done to
evaluate MCMC\ mixing, i.e., the degree to which MCMC\ parameter samples
explores the parameter's support in the model's posterior distribution. Good
mixing is suggested by a univariate trace plot that appears stable and
"hairy" over MCMC iterations\footnote
The CUSUM\ statistic, which ranges between 0 and 1, is a measure of the
"hairiness" of a univariate trace plot of a model parameter (Brooks, 199
\nocite{Brooks98}). A CUSUM\ value of .5 indicates optimal MCMC\ mixing.}.
The other step is to conduct, for each model parameter of interest, a batch
means (or subsampling)\ analysis of the MCMC\ samples, in order to calculate
95\%\ Monte Carlo Confidence Intervals (95\%\ MCCIs) of posterior
point-estimates of interest (such as marginal posterior means, variances,
quantiles, etc., of the parameter) (Flegal \&\ Jones, 2011\nocit
{FlegalJones11}). For a given (marginal) posterior point-estimate of a
parameter, the 95\%\ MCCI half-width size reflects the imprecision of the
estimate due to Monte Carlo sampling error. The half-width becomes smaller
as number of MCMC\ sampling iterations grows. In all, MCMC\ convergence is
confirmed by adequate MCMC\ mixing and practically-small 95\%\ MCCIs
half-widths (e.g., .10 or .01)\ for the (marginal)\ posterior
point-estimates of parameters (and chosen functionals)\ of interest. If
adequate convergence cannot be confirmed after a MCMC\ sampling run, then
additional MCMC\ sampling iterations can be run until convergence is
obtained for the (updated) total set of MCMC\ samples.
For each BNP\ infinite-mixture model, the \textbf{Bayesian Regression}
software estimates the posterior distribution (and functionals)\ of the
model on the basis of a general slice-sampling MCMC\ method, which can
handle the infinite-dimensional model parameters (Kalli,\ et al., 2011\nocit
{KalliGriffinWalker11}). This slice-sampling method does so by introducing
latent variables into the likelihood function of the infinite-mixture model,
such that, conditionally on these variables, the model is finite-dimensional
and hence tractable by a computer. Marginalizing over the distribution of
these latent variables recovers the original likelihood function of the
infinite-mixture model.
We now describe the MCMC\ sampling methods that the software uses to sample
from the full conditional posterior distributions of the parameters, for
each model that the software provides. For each DPM\ model, the full
conditional posterior distribution of the unknown precision parameter (
\alpha $) is sampled from a beta mixture of two gamma distributions (Escobar
\&\ West, 1995\nocite{EscobarWest95}). For each BNP\ infinite-mixture model
based on a DP, Pitman-Yor process (including the the normalized stable
process), or beta process prior, the full conditional posterior distribution
of the mixture weight parameters are sampled from appropriate beta
distributions (Kalli,\ et al., 2011\nocite{KalliGriffinWalker11}). Also, for
the parameters of each of the 31 linear models, and for the linear
parameters of each of the BNP\ infinite-mixture models, the software
implements (direct) MCMC\ Gibbs sampling of standard full conditional
posterior distributions, derived from the standard theories of the Bayesian
normal linear, probit, and logit models, as appropriate (Evans, 1965\nocit
{Evans65}; Lindley \&\ Smith, 1972\nocite{LindleySmith72}; Gilks et al., 199
\nocite{Gilks_etal_1993}; Albert \&\ Chib, 1993\nocite{AlbertChib93};
Bernardo \&\ Smith, 1994\nocite{BernardoSmith94}; Denison et al., 2002\nocit
{DenisonHolmesMallickSmith02}; Cepeda \&\ Gamerman, 2001\nocit
{CepedaGamerman01}; O'Hagan \&\ Forster, 2004\nocite{OhaganForster04};
Holmes \&\ Held, 2006\nocite{HolmesHeld06}; George \&\ McCulloch, 1997\nocit
{GeorgeMcCulloch97}; e.g., see Karabatsos \&\ Walker, 2012a,b\nocit
{KarabatsosWalker12a}\nocite{KarabatsosWalker12c}). When the full
conditional posterior distribution of the model parameter(s)\ is
non-standard, the software implements a rejection sampling algorithm.
Specifically, it implements an adaptive random-walk Metropolis-Hastings
(ARWMH) algorithm (Atchad\'{e} \&\ Rosenthal, 2005\nocite{AtchadeRosenthal05
) with normal proposal distribution, to sample from the full conditional
posterior distribution(s) of the mixture weight parameter of a BNP\
geometric weights infinite-mixture model; the mixture weight parameter of a
BNP\ normalized inverse-Gaussian process mixture model, using the equivalent
stick-breaking representation of this process (Favaro, et al. 2012\nocit
{FavaroLijoiPrunster12}). Also, for BNP\ infinite-mixture models and normal
random-effects models that assign a uniform prior distribution to the
variance parameter for random intercepts (or means), the software implements
the slice sampling (rejection)\ algorithm with stepping-out procedure (Neal,
2003\nocite{Neal03b}), in order to sample from the full conditional
posterior distribution of this parameter. Finally, for computational speed
considerations, we use the ARWMH algorithm instead of Gibbs sampling, in
order to sample from the full conditional posterior distributions for the
random coefficient parameters (the intercepts $u_{0h}$; and possibly the
u_{kh},k=0,1,\ldots ,p$, as appropriate, for groups $h=1,\ldots ,H$)\ in a
normal random-effects (or random intercepts)\ HLM; and for the random
coefficients ($\boldsymbol{\beta }_{j}$) or random intercept parameters (
\beta _{0j}$) in a BNP\ infinite-mixture regression model, as appropriate
(Karabatsos \&\ Walker, 2012a,b\nocite{KarabatsosWalker12c}\nocit
{KarabatsosWalker12a}).
The given data set ($\mathcal{D}_{n}$) may consist of censored dependent
variable observations (either left-, right-, and/or interval-censored). If
the software user indicates the censored dependent variable observations
(see Section 4.2, Step\ 6), then the software adds a Gibbs sampling step to
the MCMC\ algorithm, that draws from the full-conditional posterior
predictive distributions (density function (\ref{pp pdf})) to provide
multiple MCMC-based imputations of these missing censored observations
(Gelfand, et al. 1992\nocite{GelfandSmithLee92}; Karabatsos \&\ Walker, 2012
\nocite{KarabatsosWalker12c}).
Finally, the software implements Rao-Blackwellization (RB)\ methods (Gelfand
\&\ Mukhopadhyay, 1995\nocite{GelfandMukhopadhyay95}) to compute estimates
of the linear posterior predictive functionals from (\ref{pp all}) and (\re
{pd all}). In contrast, the quantile functional $Q_{n}(u\,|\,\mathbf{x})$ is
estimated from order statistics of MCMC\ samples from the posterior
predictive distribution of $Y$\ given $\mathbf{x}$. The 95\%\ posterior
credible interval of the quantile functional $Q(u\,|\,\mathbf{x})$ can be
viewed in a PP-plot (Wilk \&\ Gnanadesikan, 1968\nocite{WilkGnanadesikan68})
of the 95\%\ posterior interval of the c.d.f. $F(u\,|\,\mathbf{x})$, using
available software menu options. The hazard functional $H_{n}(y\,|\,\mathbf{
})$ and the cumulative hazard functional $\Lambda _{n}(y\,|\,\mathbf{x})$
are derived from RB estimates of the linear functionals $f_{n}(y\,|\,\mathbf
x})$ and $F_{n}(y\,|\,\mathbf{x})$. The same is true for the
partial-dependence functionals $Q_{n}(u\,|\,\mathbf{x}_{\mathcal{S}})$,
H_{n}(y\,|\,\mathbf{x}_{\mathcal{S}})$, and $\Lambda _{n}(y\,|\,\mathbf{x}_
\mathcal{S}})$.
\section{Key BNP Regression Models}
A BNP infinite-mixture\ regression model has the general form
\begin{equation}
f_{G_{\mathbf{x}}}(y\,|\,\mathbf{x;\,}\boldsymbol{\zeta })=\dint f(y\,|\
\mathbf{x};\boldsymbol{\psi },\boldsymbol{\theta }(\mathbf{x}))\mathrm{d}G_
\mathbf{x}}(\boldsymbol{\theta })=\dsum\limits_{j=1}^{\infty }\,f(y\,|\
\mathbf{x};\boldsymbol{\psi },\boldsymbol{\theta }_{j}(\mathbf{x}))\omega
_{j}(\mathbf{x}), \label{BNP regression}
\end{equation
given a covariate ($\mathbf{x}$) dependent, discrete mixing distribution $G_
\mathbf{x}}$; kernel (component) densities\newline
$f(y\,|\,\mathbf{x};\boldsymbol{\psi },\boldsymbol{\theta }_{j}(\mathbf{x}))$
with component indices $j=1,2,\ldots $, respectively; with fixed parameters
\boldsymbol{\psi }$; and with component parameters $\boldsymbol{\theta }_{j}
\mathbf{x})$ having sample space $\Theta $; and given mixing weights
(\omega _{j}(\mathbf{x}))_{j=1}^{\infty }$ that sum to 1 at every $\mathbf{x
\in \mathcal{X}$, with $\mathcal{X}$ the covariate space.
In the infinite-mixture model (\ref{BNP regression}), the
covariate-dependent mixing distribution is a random probability measure that
has the general form\footnote
Throughout, $\delta _{\boldsymbol{\theta }}(\cdot )$ denotes a degenerate
probability measure (distribution) with point mass at $\boldsymbol{\theta }
, such that $\boldsymbol{\theta }^{\ast }\sim \delta _{\boldsymbol{\theta }}$
and $\Pr (\boldsymbol{\theta }^{\ast }=\boldsymbol{\theta })=1$. Also,
\delta _{\boldsymbol{\theta }}(B)=1$ if $\boldsymbol{\theta }\in B$ and
\delta _{\boldsymbol{\theta }}(B)=0$ if $\boldsymbol{\theta }\notin B$, for
\forall B\in \mathcal{B}(\Theta )$.}
\begin{equation}
G_{\mathbf{x}}(B)=\dsum\limits_{j=1}^{\infty }\omega _{j}(\mathbf{x})\delta
_{\boldsymbol{\theta }_{j}(\mathbf{x})}(B),\text{ \ }\forall B\in \mathcal{B
(\Theta ), \label{MixDist}
\end{equation
and is therefore an example of a species sampling model (Pitman, 1995\nocit
{Pitman95}).
The mixture model (\ref{BNP regression}) is completed by the specification
of a prior distribution $\Pi (\boldsymbol{\zeta })$ on the space $\Omega _
\boldsymbol{\zeta }}=\{\boldsymbol{\zeta }\}$ of the infinite-dimensional
model parameter, given by
\begin{equation}
\boldsymbol{\zeta }=(\boldsymbol{\psi },(\boldsymbol{\theta }_{j}(\mathbf{x
),\omega _{j}(\mathbf{x}))_{j=1}^{\infty },\mathbf{x}\in \mathcal{X}).
\label{BNP reg parameters}
\end{equation
The BNP\ infinite-mixture regression model (\ref{BNP regression})-(\re
{MixDist}), completed by the specification of a prior distribution $\Pi
\boldsymbol{\zeta })$, is very general and encompasses, as special cases:
fixed- and random-effects linear and generalized linear models (McCullagh
\&\ Nelder, 1989\nocite{McCullaghNelder89}; Verbeke \&\ Molenberghs, 200
\nocite{VerbekeMolenberghs2000}; Molenberghs \&\ Verbeke, 2005\nocit
{MolenberghsVerbeke05}), finite-mixture latent-class and hierarchical
mixtures-of-experts regression models (McLachlan \&\ Peel, 2000\nocit
{McLachlanPeel00}; Jordan \&\ Jacobs, 1994\nocite{JordanJacobs94}), and
infinite-mixtures of Gaussian process regressions (Rasmussen \&\ Ghahramani,
2002\nocite{RasmussenGhahramani02}).
In the general BNP\ model (\ref{BNP regression})-(\ref{MixDist}), assigned
prior $\Pi (\boldsymbol{\zeta })$, the kernel densities $f(y\,|\,\mathbf{x}
\boldsymbol{\psi },\boldsymbol{\theta }_{j}(\mathbf{x}))$ may be specified
as covariate independent,\ with: $f(y\,|\,\mathbf{x};\boldsymbol{\psi }
\boldsymbol{\theta }_{j}(\mathbf{x})):=f(y\,|\,\boldsymbol{\psi }
\boldsymbol{\theta }_{j})$; and may not contain fixed parameters
\boldsymbol{\psi }$, in which case $\boldsymbol{\psi }$ is null. Also for
the model, covariate dependence is not necessarily specified for the mixing
distribution, so that $G_{\mathbf{x}}:=G$. No covariate dependence is
specified for the mixing distribution if and only if both the component
parameters and the mixture weights are covariate independent, with
\boldsymbol{\theta }_{j}(\mathbf{x}):=\boldsymbol{\theta }_{j}$ and $\omega
_{j}(\mathbf{x}):=\omega _{j}$. The mixing distribution $G_{\mathbf{x}}$ is
covariate dependent if the component parameters $\boldsymbol{\theta }_{j}
\mathbf{x})$ or the mixture weights $\omega _{j}(\mathbf{x})$ are specified
as covariate dependent.
Under the assumption of no covariate dependence in the mixing distribution,
with $G_{\mathbf{x}}:=G$, the Dirichlet process (Ferguson, 1973\nocit
{Ferguson73}) provides a standard and classical choice of BNP\ prior
distribution on the space of probability measures $\mathcal{G}_{\Theta }$
=\{G\}_{\Theta }$ on the sample space $\Theta $. The Dirichlet process is
denoted $\mathcal{DP}(\alpha ,G_{0})$ with precision parameter $\alpha $ and
baseline distribution\ (measure) $G_{0}$. We denote $G\sim \mathcal{DP
(\alpha ,G_{0})$ when the random probability measure $G$ is assigned a
\mathcal{DP}(\alpha ,G_{0})$ prior distribution on $\mathcal{G}_{\Theta }$.
Under the $\mathcal{DP}(\alpha ,F_{0})$ prior, the (prior)\ mean and
variance of $G$ are given respectively by (Ferguson, 1973\nocite{Ferguson73
):
\begin{subequations}
\begin{eqnarray}
\mathbb{E}[G(B)\,|\,\alpha ,G_{0}] &=&\dfrac{\alpha G_{0}(B)}{\alpha
=G_{0}(B), \label{EG DP} \\
\mathbb{V}[G(B)\,|\,\alpha ,G_{0}] &=&\frac{G_{0}(B)[1-G_{0}(B)]}{\alpha +1}
\text{ \ \ }\forall B\in \mathcal{B}(\Theta ). \label{VarG DP}
\end{eqnarray
For the $\mathcal{DP}(\alpha ,G_{0})$ prior, (\ref{EG DP}) shows that the
baseline distribution $G_{0}$ represents the prior mean (expectation)\ of
G, $ and the prior variance of $G$ is inversely proportional to the
precision parameter $\alpha $, as shown in (\ref{VarG DP}). The variance of
G$ is increased (decreased, resp.) as $\alpha $ becomes smaller (larger,
resp.). In practice, a standard choice of baseline distribution $G_{0}(\cdot
)$ is provided by the normal $\mathrm{N}(\mu ,\sigma ^{2})$ distribution.
The $\mathcal{DP}(\alpha ,G_{0})$ can also be characterized in terms of a
Dirichlet ($\mathrm{Di}$) distribution. That is, if $G\sim \mathcal{DP
(\alpha ,G_{0})$, then:
\end{subequations}
\begin{equation}
(G(B_{1}),\ldots ,G(B_{k}))\,|\,\alpha ,G_{0}\sim \mathrm{Di}(\alpha
G_{0}(B_{1}),\ldots ,\alpha G_{0}(B_{k})),
\end{equation
for every choice of $k\geq 1$ (exhaustive) partitions $B_{1},\ldots ,B_{k}$
of the sample space, $\Theta $.
The $\mathcal{DP}(\alpha ,G_{0})$ can also be characterized as a particular
"stick-breaking"\ stochastic process (Sethuraman, 1994\nocite{Sethuraman94};
Sethuraman \&\ Tiwari, 1982\nocite{SethuramanTiwari82}). A random
probability measure ($G$) that is drawn from the $\mathcal{DP}(\alpha
,G_{0}) $ prior, with $G\sim \mathcal{DP}(\alpha ,G_{0})$, is constructed by
first taking independently and identically distributed (i.i.d.)\ samples of
(\upsilon ,\boldsymbol{\theta })$ from the following distributions:
\begin{subequations}
\label{SB const}
\begin{eqnarray}
&&\upsilon _{j}\,|\,\alpha \sim \mathrm{Be}(1,\alpha ),\text{ \ \
j=1,2,\ldots , \label{betaSB} \\
&&\boldsymbol{\theta }_{j}\,|\,G_{0}\sim G_{0},\text{ \ \ }j=1,2,\ldots ,
\label{atomSB}
\end{eqnarray
and then using the samples $(\upsilon _{j},\boldsymbol{\theta
_{j})_{j=1}^{\infty }$ to construct the random probability measure by:
\begin{equation}
G(B)=\dsum\limits_{j=1}^{\infty }\omega _{j}\delta _{\boldsymbol{\theta
_{j}}(B),\text{ \ \ }\forall B\in \mathcal{B}(\Theta ). \label{G SB}
\end{equation
Above, the $\omega _{j}$s are mixture weights, particularly, stick-breaking
weights constructed by
\begin{equation}
\omega _{j}=\upsilon _{j}\prod_{l=1}^{j-1}(1-\upsilon _{l}),\text{ \ for \
j=1,2,\ldots , \label{SB weights}
\end{equation
and they sum to 1 (i.e., $\tsum\nolimits_{j=1}^{\infty }\omega _{j}=1$).
More in words, a random probability measure, $G$, drawn from a $\mathcal{DP
(\alpha ,G_{0})$ prior distribution on $\mathcal{G}_{\Theta }$
=\{G\}_{\Theta }$, can be represented as infinite-mixtures of degenerate
probability measures (distributions).\ Such a random distribution is
discrete with probability 1, which is obvious because the degenerate
probability measure ($\delta _{\boldsymbol{\theta }_{j}}(\cdot )$) is
discrete. The locations $\boldsymbol{\theta }_{j}$ of the point masses are a
sample from $G_{0}$. The random weights $\omega _{j}$ are obtained from a
stick-breaking procedure, described as follows. First, imagine a stick of
length 1. As shown in (\ref{SB weights}), at stage $j=1$ a piece is broken
from this stick, and then the value of the first weight $\omega _{1}$ is set
equal to the length of that piece, with $\omega _{1}=\upsilon _{1}$. Then at
stage $j=2$, a piece is broken from a stick of length $1-\omega _{1}$, and
then the value of the second weight $\omega _{2}=\upsilon _{2}(1-\upsilon
_{1})$ is set equal to the length of that piece. This procedure is repeated
for\ $j=1,2,3,4,\ldots $, where at any given stage $j$, a piece is broken
from a stick of length $1-\tsum\nolimits_{l=1}^{j-1}\omega _{j}$, and then
the value of the weight $\omega _{j}$ is set equal to the length of that
piece, with $\omega _{j}=\upsilon _{j}\prod_{l=1}^{j-1}(1-\upsilon _{l})$.
The entire procedure results in weights $(\omega _{j})_{j=1}^{\infty }$ that
sum to 1 (almost surely).
The stick-breaking construction (\ref{SB const}) immediately suggests
generalizations of the $\mathcal{DP}(\alpha ,G_{0})$, especially by means of
increasing the flexibility of the prior (\ref{betaSB}) for the random
parameters $(\upsilon _{j})_{j=1}^{\infty }$ that construct the
stick-breaking mixture weights (\ref{SB weights}). One broad generalization
is given by a general stick-breaking process (Ishwaran \&\ James, 2001\nocit
{IshwaranJames01}), denoted $\mathcal{SB}(\mathbf{a},\mathbf{b},G_{0})$ with
positive parameters $\mathbf{a}=(a_{1},a_{2},\ldots )$ and $\mathbf{b
=(b_{1},b_{2},\ldots )$, which gives a prior on $\mathcal{G}_{\Theta }$
=\{G\}_{\Theta }$. This process replaces the i.i.d. beta distribution
assumption in (\ref{betaSB}), with the more general assumption of
independent beta distributions, with
\end{subequations}
\begin{equation}
\upsilon _{j}\,|\,\alpha \sim \mathrm{Be}(a_{j},b_{j}),\text{ \ for
j=1,2,\ldots \text{.} \label{SPpriorbeta}
\end{equation
In turn, there are many interesting special cases of the $\mathcal{SB}
\mathbf{a},\mathbf{b},G_{0})$ process prior, including:
\begin{enumerate}
\item The Pitman-Yor (Poisson-Dirichlet) process, denoted $\mathcal{PY
(a,b,G_{0})$, which assumes $a_{j}=1-a$ and $b_{j}=b+ja$, for $j=1,2,\ldots $
, in (\ref{SPpriorbeta}), with $0\leq a<1$ and $b>-a$ (Perman, et al. 199
\nocite{Perman_Pitman_Yor_92}; Pitman \&\ Yor, 1997\nocite{PitmanYor97}).
\item The beta two-parameter process, which assumes $a_{j}=a$ and $b_{j}=b$
in (\ref{SPpriorbeta}) (Ishwaran \&\ Zarepour, 2000\nocit
{IshwaranZarepour00}).
\item The normalized stable process (Kingman, 1975\nocite{Kingman75}), which
is equivalent to the $\mathcal{PY}(a,0,G_{0})$ process, with $0\leq a<1$ and
$b=0$.
\item The Dirichlet process $\mathcal{DP}(\alpha ,G_{0})$, which assumes
a_{j}=1$ and $b_{j}=\alpha $ in (\ref{SPpriorbeta}), and with is equivalent
to the $\mathcal{PY}(0,\alpha ,G_{0})$ process.
\item The geometric weights prior, denoted $\mathcal{GW}(a,b,G_{0})$, which
assumes in (\ref{SPpriorbeta}) the equality restriction $\upsilon =\upsilon
_{j}$ for $j=1,2,\ldots ,$ leading to mixture weights (\ref{SB weights})
that can be re-written as $\omega _{j}=\upsilon \left( 1-\upsilon \right)
^{j-1}$, for $j=1,2,\ldots $ (Fuentes-Garc\'{\i}a, et al. 2009, 2010\nocit
{Fuentes-GarciaMenaWalker09}\nocite{Fuentes-GarciaMenaWalker10}). These
mixture weights may be assigned a beta prior distribution, with $\upsilon
\sim \mathrm{Be}(a,b)$.
\end{enumerate}
\noindent Another generalization of the $\mathcal{DP}(\alpha ,G_{0})$ is
given by the mixture of Dirichlet process (MDP), defined by the
stick-breaking construction (\ref{SB const}), after sampling from prior
distributions $\alpha \sim \Pi \left( \alpha \right) $ and $\boldsymbol
\vartheta }\sim \Pi \left( \boldsymbol{\vartheta }\right) $ for the
precision and baseline parameters (Antoniak, 1974\nocite{Antoniak74}).
A BNP\ prior distribution on $\mathcal{G}_{\Theta }$ $=\{G\}_{\Theta }$,
defined by a Normalized Random Measure (NRM) process, assumes that a
discrete random probability measure $G$, given by (\ref{G SB}), is
constructed by mixture weights that have the form:
\begin{equation}
\omega _{j}=\dfrac{I_{j}}{\tsum\nolimits_{l=1}^{\infty }I_{l}},\text{ \
j=1,2,\ldots ;\text{ \ }\omega _{j}\geq 0,\text{ }\tsum\nolimits_{l=1}^
\infty }\omega _{l}=1.
\end{equation
The $I_{1},I_{2},I_{3},\ldots $ are the jump sizes of a non-Gaussian L\'{e
vy process whose sum is almost surely finite (see e.g. James et al., 200
\nocite{JamesLijoiPrunster09}), and are therefore stationary independent
increments (Bertoin, 1998\nocite{Bertoin98}). The $\mathcal{DP}(\alpha
,G_{0})$\ is a special NRM\ process which assumes that $\tsu
\nolimits_{j=1}^{\infty }I_{j}\sim \mathrm{Ga}(\alpha ,1)$ (Ferguson, 197
\nocite{Ferguson73}, pp. 218-219).
An important NRM is given by the normalized inverse-Gaussian $\mathcal{NIG
(c,G_{0})$ process (Lijoi et al., 2005\nocite{LijoiMenaPrunster05}), which
can be characterized as a stick-breaking process (Favaro, et al., 2012\nocit
{FavaroLijoiPrunster12}), defined by the stick-breaking construction (\re
{SB const}), after relaxing the i.i.d. assumption (\ref{betaSB}), by
allowing for dependence among the $\upsilon _{j}$ distributions, with:
\begin{subequations}
\label{NIG process stick}
\begin{eqnarray}
\upsilon _{j} &=&\dfrac{\upsilon _{1j}}{\upsilon _{1j}+\upsilon _{0j}},\text{
\ }j=1,2,\ldots \label{favaro pdf} \\
\upsilon _{1j} &\sim &\mathrm{GIG}(c^{2}/\{\tpro
\nolimits_{l=1}^{j-1}(1-V_{l})\}^{\mathbf{1}(j>1)},1,-j/2), \\
\upsilon _{0j} &\sim &\mathrm{IG}(1/2,2).
\end{eqnarray
The random variables (\ref{favaro pdf}) follow normalized generalized
inverse-Gaussian distributions, with p.d.f. given by equation (4)\ in
Favaro, et al. (2012\nocite{FavaroLijoiPrunster12}).
Stick-breaking process priors can be characterized in terms of the
clustering behavior that it induces in the posterior predictive distribution
of $\boldsymbol{\theta }$. Let $\{\boldsymbol{\theta }_{c}^{\ast
}:c=1,\ldots ,k_{n}\leq n\}$ be the $k_{n}\leq n$ unique values (clusters)
among the $n$ observations of a data set. Let $\Upsilon _{n}=\{\mathcal{C
_{1},\ldots ,\mathcal{C}_{c},\ldots ,\mathcal{C}_{k_{n}}\}$ be the random
partition of the integers $\{1,\ldots ,n\}$. Each cluster is defined by
\mathcal{C}_{c}=\{i:\boldsymbol{\theta }_{i}=\boldsymbol{\theta }_{c}^{\ast
}\}\subset \{1,\ldots ,n\},$ and has size $n_{c}=|\mathcal{C}_{c}|$, with
cluster frequency counts $\mathbf{n}_{n}=(n_{1},\ldots ,n_{c},\ldots
,n_{k_{n}})$ and $\tsum\nolimits_{c=1}^{k_{n}}n_{c}=n$.
When $G$\ is assigned a Pitman-Yor $\mathcal{PY}(a,b,G_{0})$ process prior,
the posterior predictive probability of a new observation $\boldsymbol
\theta }_{n+1}$ is defined by:
\end{subequations}
\begin{equation}
P(\boldsymbol{\theta }_{n+1}\in B\,|\,\,\boldsymbol{\theta }_{1},\ldots
\boldsymbol{\theta }_{n})=\dfrac{b+ak_{n}}{b+n}G_{0}(B)+\dsu
\limits_{c=1}^{k_{n}}\dfrac{n_{c}-a}{b+n}\delta _{\boldsymbol{\theta
_{c}^{\ast }}(B),\text{ \ \ }\forall B\in \mathcal{B}(\Theta ).
\label{PY pred}
\end{equation
That is, $\boldsymbol{\theta }_{n+1}$ forms a new cluster with probability
(b+ak_{n})/(b+n)$, and otherwise with probability $(n_{c}-a)/(b+n)$,
\boldsymbol{\theta }_{n+1}$ is allocated to old cluster $\mathcal{C}_{c}$,
for $c=1,\ldots ,k_{n}$. Recall that the normalized stable process (Kingman,
1975\nocite{Kingman75}) is equivalent to the $\mathcal{PY}(a,0,G_{0})$
process with $0\leq a<1$ and $b=0$; and the $\mathcal{DP}(\alpha ,G_{0})$ is
the $\mathcal{PY}(0,b,G_{0})$ process with $a=0$ and $b=\alpha $.
Under the $\mathcal{NIG}(c,G_{0})$ process prior, the posterior predictive
distribution is defined by the probability function,
\begin{subequations}
\label{NIG all}
\begin{equation}
P(y_{n+1}\in B\,|\,\,\boldsymbol{\theta }_{1},\ldots ,\boldsymbol{\theta
_{n})=w_{0}^{(n)}G_{0}(B)+w_{1}^{(n)}\dsum\limits_{c=1}^{k_{n}}(n_{c}-.5
\delta _{y_{c}^{\ast }}(B),\text{ \ \ }\forall B\in \mathcal{B}(\Theta ),
\label{GG pred}
\end{equation
with:\noindent
\begin{equation}
w_{0}^{(n)}=\dfrac{\tsum\limits_{l=0}^{n}\dbinom{n}{l}(-c^{2})^{-l+1}\Gamma
(k_{n}+1+2l-2n\,;\,c)}{2n\tsum\limits_{l=0}^{n-1}\dbinom{n-1}{l
(-c^{2})^{-l}\Gamma (k_{n}+2+2l-2n\,;\,c)}, \label{w0 GG}
\end{equation
\begin{equation}
w_{1}^{(n)}=\dfrac{\tsum\limits_{l=0}^{n}\dbinom{n}{l}(-c^{2})^{-l+1}\Gamma
(k_{n}+2l-2n\,;\,c)}{n\tsum\limits_{l=0}^{n-1}\dbinom{n-1}{l
(-c^{2})^{-l}\Gamma (k_{n}+2+2l-2n\,;\,c)}, \label{w1 GG}
\end{equation
where $\Gamma (\cdot \,;\,\cdot )$ is the incomplete gamma function (Lijoi
et al., 2005, p. 1283\nocite{LijoiMenaPrunster05}). Finally, exchangeable
partition models (e.g., Hartigan, 1990\nocite{Hartigan90}; Barry \&\
Hartigan, 1993\nocite{BarryHartigan93}; Quintana \&\ Iglesias, 2003\nocit
{QuintanaIglesias03}) also give rise to random clustering structures of a
form (\ref{NIG all}), and therefore coincide with the family of Gibbs-type
priors, which include the $\mathcal{PY}(a,b,G_{0})$ and $\mathcal{NIG
(c,G_{0})$ processes and their special cases. More detailed discussions on
the clustering behavior induced by various BNP\ priors are given by De\
Blasi, et al. (2015\nocite{DeBlasiEtAl15}).
So far, we have described only BNP\ priors for the mixture distribution (\re
{MixDist}) of the general BNP\ regression model (\ref{BNP regression}),
while assuming no covariate dependence in the mixing distribution, with $G_
\mathbf{x}}:=G$. We now consider dependent BNP\ processes. A seminal example
is given by the Dependent Dirichlet process ($\mathcal{DDP}(\alpha _{\mathbf
x}},G_{0\mathbf{x}})$) (MacEachern 1999\nocite{MacEachern99}; 2000\nocit
{MacEachern00}; 2001\nocite{MacEachern01}), which models a covariate (
\mathbf{x}$) dependent process $G_{\mathbf{x}}$, by allowing either the
baseline distribution $G_{0\mathbf{x}}$, the stick-breaking mixture weights
\omega _{j}(\mathbf{x})$, and/or the precision parameter $\alpha _{\mathbf{x
}$ to depend on covariates $\mathbf{x}$. In general terms, a random
dependent probability measure $G_{\mathbf{x}}\,|\,\alpha _{\mathbf{x}},G_{
\mathbf{x}}\sim \mathcal{DDP}(\alpha _{\mathbf{x}},G_{0\mathbf{x}})$ can be
represented by Sethuraman's (1994\nocite{Sethuraman94})\ stick-breaking
construction, as
\begin{eqnarray}
G_{\mathbf{x}}(B) &=&\tsum\nolimits_{j=1}^{\infty }\omega _{j}(\mathbf{x
)\delta _{\theta _{j}(\mathbf{x})}(B),\text{ \ \ }\forall B\in \mathcal{B
(\Theta ), \\
\omega _{j}(\mathbf{x}) &=&\upsilon _{j}(\mathbf{x})\tpro
\nolimits_{k=1}^{j-1}(1-\upsilon _{k}(\mathbf{x})), \\
\upsilon _{j}(\mathbf{x}) &:&\mathcal{X}\rightarrow \lbrack 0,1], \\
\upsilon _{j} &\sim &Q_{\mathbf{x}j}, \\
\theta _{j}(\mathbf{x}) &\sim &G_{0\mathbf{x}}.
\end{eqnarray
\noindent Next, we describe an important BNP\ regression model, with a
dependent mixture distribution $G_{\mathbf{x}}$ assigned a specific
\mathcal{DDP}(\alpha _{\mathbf{x}},G_{0\mathbf{x}})$ prior.
\subsection{ANOVA-Linear DDP\ model}
Assume that the data $\mathcal{D}_{n}=\{(y_{i},\mathbf{x}_{i})\}_{i=1}^{n}$
can be stratified into $N_{h}$ groups, indexed by $h=1,\ldots ,N_{h}$,
respectively. For each of group $h$, let $y_{i(h)}$ be the $i$th dependent
observation of group $h$, and let $\mathbf{y
_{h}=(y_{i(h)})_{i(h)=1}^{n_{h}} $ be the column vector of $n_{h}$ dependent
observations, corresponding to an observed design matrix $\mathbf{X}_{h}=
\mathbf{x}_{1(h)}^{\mathbf{\intercal }},\ldots ,\mathbf{x}_{i(h)}^{\mathbf
\intercal }},\ldots ,\mathbf{x}_{n_{h}}^{\mathbf{\intercal }})$ of $n_{h}$
rows of covariate vectors $\mathbf{x}_{i(h)}^{\mathbf{\intercal }}$
respectively. Possibly, each of the $N_{h}$ groups of observations has only
one observation (i.e., $n_{h}=1$), in which case $N_{h}=n$.
The ANOVA-linear DDP model (De Iorio, et al. 2004\nocit
{DeIorioMullerRosnerMacEachern04}; M\"{u}ller et al., 2005\nocit
{MullerRosnerDeIorioMacEachern05}) can be defined as:
\end{subequations}
\begin{subequations}
\label{ANOVA DDP}
\begin{eqnarray}
(y_{i(h)})_{i(h)=1}^{n_{h}}\,|\,\mathbf{X}_{h} &\sim &f(\mathbf{y}_{h}\,|\
\mathbf{X}_{h};\boldsymbol{\zeta }),\text{ \ }h=1,\ldots ,N_{h} \\
f(\mathbf{y}_{h}\,|\,\mathbf{X}_{h};\boldsymbol{\zeta })
&=&\dsum\limits_{j=1}^{\infty }\left\{ \tprod\limits_{i(h)=1}^{n_{h}}\text
\textrm{n}}(y_{i(h)}\,|\,\mathbf{x}_{i(h)}^{\mathbf{\intercal }}\boldsymbol
\beta }_{j},\sigma ^{2})\right\} \omega _{j} \\
\omega _{j} &=&\upsilon _{j}\tprod\nolimits_{l=1}^{j-1}(1-\upsilon _{l})
\label{SB weights DDP} \\
\upsilon _{j}\,|\,\alpha &\sim &\text{\textrm{Be}}(1,\alpha ) \\
\boldsymbol{\beta }_{j}\,|\,\boldsymbol{\mu },\boldsymbol{T} &\sim &\text{
\mathrm{N}$}(\boldsymbol{\mu },\boldsymbol{T}) \\
\sigma ^{2} &\sim &\text{\textrm{IG}}(a_{0}/2,a_{0}/2) \\
\boldsymbol{\mu },\boldsymbol{T} &\sim &\text{$\mathrm{N}$}(\boldsymbol{\mu
\,|\,\mathbf{0},r_{0}\mathbf{I}_{p+1})\text{\textrm{IW}}(\boldsymbol{T
\,|\,p+3,s_{0}\mathbf{I}_{p+1}) \\
\alpha &\sim &\text{$\mathrm{Ga}$}(a_{\alpha },b_{\alpha }).
\end{eqnarray
Therefore, all the model parameters are assigned prior distributions, which
together, define the joint prior p.d.f. for $\boldsymbol{\zeta }\in \Omega _
\boldsymbol{\zeta }}$ by:
\end{subequations}
\begin{subequations}
\label{ANOVA DDP prior pdf}
\begin{eqnarray}
\pi (\boldsymbol{\zeta }) &=&\dprod\limits_{j=1}^{\infty }\text{\textrm{be}
(\upsilon _{j}\,|\,1,\alpha )\mathrm{n}(\boldsymbol{\beta }_{j}\,|\
\boldsymbol{\mu },\boldsymbol{T})\text{\textrm{ig}}(\sigma
^{2}\,|\,a_{0}/2,a_{0}/2) \\
&&\times \mathrm{n}(\boldsymbol{\mu }\,|\,\mathbf{0},r_{0}\mathbf{I}_{p+1}
\text{\textrm{iw}}(\boldsymbol{T}\,|\,p+3,s_{0}\mathbf{I}_{p+1})\mathrm{g
\text{$\mathrm{a}$}(\alpha \,|\,a_{\alpha },b_{\alpha }).
\end{eqnarray
\noindent As shown, the ANOVA-linear DDP\ model (\ref{ANOVA DDP}) is based
on a mixing distribution $G(\boldsymbol{\beta })$ assigned a $\mathcal{DP
(\alpha ,G_{0})$ prior, with precision parameter $\alpha $ and multivariate
normal baseline distribution, $G_{0}(\cdot ):=\mathrm{N}$$(\cdot \,|\
\boldsymbol{\mu },\boldsymbol{T})$. Prior distributions are assigned to
(\alpha ,\boldsymbol{\mu },\boldsymbol{T})$ in order to allow for posterior
inferences to be robust to different choices of the $\mathcal{DP}(\alpha
,G_{0})$ prior parameters.
The ANOVA-linear DDP\ model (\ref{ANOVA DDP}) is equivalent to the BNP\
regression model (\ref{BNP regression}), with normal kernel densities
\textrm{n}$(y_{i}\,|\,\mu _{j},\sigma ^{2})$ and mixing distribution $G_
\mathbf{x}}(\mu )$ (\ref{MixDist}) assigned a $\mathcal{DDP}(\alpha ,G_{
\mathbf{x}})$ prior, where:
\end{subequations}
\begin{equation}
G_{\mathbf{x}}(B)=\tsum\nolimits_{j=1}^{\infty }\omega _{j}\delta _{\mathbf{
}^{\mathbf{\intercal }}\boldsymbol{\beta }\newline
}(B),\ \forall B\in \mathcal{B}(\Theta ), \label{depmix}
\end{equation
with $\boldsymbol{\beta }_{j}\,|\,\boldsymbol{\mu },\boldsymbol{T}\sim
\mathrm{N}$$(\boldsymbol{\mu },\boldsymbol{T})$ and $\sigma ^{2}\sim $
\textrm{IG}$(a_{0}/2,a_{0}/2)$ (i.e., $G_{0}(\cdot )=\mathrm{N}$$
\boldsymbol{\beta }\,|\boldsymbol{\mu },\boldsymbol{T})$\textrm{IG}$(\sigma
^{2}\,|a_{0}/2,a_{0}/2)$), and with the $\omega _{j}$ stick-breaking weights
(\ref{SB weights DDP}) (De Iorio, et al. 2004\nocit
{DeIorioMullerRosnerMacEachern04}).
A menu option in the \textbf{Bayesian regression} software labels the
ANOVA-linear DDP\ model (\ref{ANOVA DDP}) as the "Dirichlet process mixture
of homoscedastic linear regressions model" (for Step 8 of a data analysis;
see next section). The software allows the user to analyze data using any
one of many variations of the model (\ref{ANOVA DDP}). Variations of this
DDP\ model include: "mixture of linear regressions" models, as labeled by a
menu option of the software, with mixing distribution $G(\boldsymbol{\beta
,\sigma ^{2})$ for the coefficients and the error variance parameters;
"mixture of random intercepts" models, with mixture distribution $G(\beta
_{0})$ for only the intercept parameter $\beta _{0},$ and with independent
normal priors for the slope coefficient parameters $(\beta _{k})_{k=1}^{p}$;
mixture models having mixture distribution $G$ assigned either a Pitman-Yor
\mathcal{PY}(a,b,G_{0})$ (including the normalized stable process prior),
beta process, geometric weights, or normalized inverse-Gaussian process
\mathcal{NIG}(c,G_{0})$ prior, each implying, respectively, a dependent BNP\
prior for a covariate-dependent mixing distribution (\ref{depmix}) (using
similar arguments made for the DDP\ model by De Iorio, et al. 2004\nocit
{DeIorioMullerRosnerMacEachern04}); and mixed-logit or mixed-probit
regression models for a binary (0 or 1) or ordinal ($c=0,1,\ldots ,m$)
dependent variable. Also, suppose that the ANOVA-linear DDP\ model (\re
{ANOVA DDP}) is applied to time-lagged dependent variable data (which can be
set up using a menu option in the software; see Section 4.1, Step 3, and
Section 4.3). Then this model is defined by an infinite-mixture of
autoregressions, with mixture distribution assigned a time-dependent DDP (Di
Lucca, et al. 2012\nocite{DiLucca_etal12}). The Help menu of the software
provides a full list of models that are available from the software.
\subsection{Infinite-Probits Mixture Linear Model}
As mentioned, typical BNP infinite-mixture models assume that the mixture
weights have the stick-breaking form (\ref{SB weights}). However, a BNP\
model may have weights with a different form. The infinite-probits model is
a Bayesian nonparametric regression model (\ref{BNP regression})-(\re
{MixDist}), with prior $\Pi (\boldsymbol{\zeta })$, and with mixture
distribution (\ref{MixDist}) defined by a dependent normalized random
measure (Karabatsos \& Walker, 2012\nocite{KarabatsosWalker12c}).
For data, $\mathcal{D}_{n}=\{(y_{i},\mathbf{x}_{i})\}_{i=1}^{n}$, a Bayesian
infinite-probits mixture model can be defined by:
\begin{subequations}
\label{IP mixture reg model}
\begin{eqnarray}
y_{i}\,|\,\mathbf{x}_{i} &\sim &f(y\,|\,\mathbf{x}_{i};\boldsymbol{\zeta })
\text{ \ }i=1,\ldots ,n \\
f(y\,|\,\mathbf{x};\boldsymbol{\zeta }) &=&\tsum\limits_{j=-\infty }^{\infty
}\text{\textrm{n}}(y\,|\,\mu _{j}+\mathbf{x}^{\mathbf{\intercal }
\boldsymbol{\beta },\sigma ^{2})\omega _{j}(\mathbf{x})
\label{IP inf mixture} \\
\omega _{j}(\mathbf{x}) &=&\Phi \left( \dfrac{j-\mathbf{x}^{\mathbf
\intercal }}\boldsymbol{\beta }_{\omega }}{\sigma _{\omega }}\right) -\Phi
\left( \dfrac{j-1-\mathbf{x}^{\mathbf{\intercal }}\boldsymbol{\beta
_{\omega }}{\sigma _{\omega }}\right) \label{IP mix weights} \\
\mu _{j}\,|\,\sigma _{\mu }^{2} &\sim &\text{$\mathrm{N}$}(0,\sigma _{\mu
}^{2}) \\
\sigma _{\mu } &\sim &\text{\textrm{U}}(0,b_{\sigma \mu }) \\
\beta _{0}\,|\,\sigma ^{2} &\sim &\text{$\mathrm{N}$}(0,\sigma ^{2}v_{\beta
0}\rightarrow \infty ) \\
\beta _{k}\,|\,\sigma ^{2} &\sim &\text{$\mathrm{N}$}(0,\sigma ^{2}v),\text{
}k=1,\ldots ,p \\
\sigma ^{2} &\sim &\text{\textrm{IG}}(a_{0}/2,a_{0}/2) \\
\boldsymbol{\beta }_{\omega }\,|\,\sigma _{\omega }^{2} &\sim &\text{
\mathrm{N}$}(\mathbf{0},\sigma _{\omega }^{2}v_{\omega }\mathbf{I}) \\
\sigma _{\omega }^{2} &\sim &\text{\textrm{IG}}(a_{\omega }/2,a_{\omega }/2),
\end{eqnarray
with $\Phi \left( \cdot \right) $ the normal \textrm{N}$(0,1)$ c.d.f., and
model parameters $\boldsymbol{\zeta }=((\mu _{j})_{j=1}^{\infty },\sigma
_{\mu }^{2},\boldsymbol{\beta },\sigma ^{2},\boldsymbol{\beta }_{\omega
},\sigma _{\omega })$ assigned a prior $\Pi (\boldsymbol{\zeta })$ with
p.d.f.:
\end{subequations}
\begin{subequations}
\label{IP prior pdf}
\begin{eqnarray}
\pi (\boldsymbol{\zeta }) &=&\dprod\limits_{j=-\infty }^{\infty }\mathrm{n
(\mu _{j}\,|\,0,\sigma _{\mu }^{2})\text{\textrm{u}}(\sigma _{\mu
}\,|\,0,b_{\sigma \mu })\mathrm{n}(\boldsymbol{\beta }\,|\,\mathbf{0},\sigma
^{2}\mathrm{diag}(v_{\beta 0}\rightarrow \infty ,v\mathbf{J}_{p})) \\
&&\times \text{\textrm{ig}}(\sigma ^{2}\,|\,a_{0}/2,a_{0}/2)\mathrm{n}
\boldsymbol{\beta }_{\omega }\,|\,\mathbf{0},\sigma _{\omega }^{2}v_{\omega
\mathbf{I}_{p+1})\mathrm{ig}(\sigma _{\omega }^{2}\,|\,a_{\omega
}/2,a_{\omega }/2),
\end{eqnarray
where $\mathbf{J}_{p}$ denotes a $p\times 1$ vector of $1$s.
The \textbf{Bayesian Regression} software labels the BNP\ model (\ref{IP
mixture reg model}) as the "Infinite homoscedastic probits regression
model," in a menu option (in Step 8 of a data analysis; see next section).
This model is defined by a highly-flexible robust linear model, an infinite
mixture of linear regressions (\ref{IP inf mixture}), with random intercept
parameters $\mu _{j}$ modeled by infinite covariate-dependent mixture
weights (\ref{IP mix weights}). The model (\ref{IP mixture reg model}) has
been extended and applied to prediction analysis (Karabatsos \&\ Walker,
2012a\nocite{KarabatsosWalker12c}), meta-analysis (Karabatsos et al. 201
\nocite{KarabatsosTalbottWalker15}), (test)\ item-response analysis
(Karabatsos, 2015\nocite{Karabatsos15}), and causal analysis (Karabatsos \&\
Walker, 2015\nocite{KarabatsosWalker15}).
The covariate-dependent mixture weights $\omega _{j}(\mathbf{x})$ in (\re
{IP mix weights}), defining the mixture distribution (\ref{MixDist}), are
modeled by a probits regression for ordered categories $j=\ldots ,-2,-1,0,$
1,2,\ldots $, with latent location parameter $\mathbf{x}^{\mathbf{\intercal
}\boldsymbol{\beta }_{\omega }$, and with latent standard deviation $\sigma
_{\omega }$ that controls the level of modality of the conditional p.d.f.
f(y\,|\,\mathbf{x};\boldsymbol{\zeta })$ of the dependent variable $Y$.
Specifically, as $\sigma _{\omega }\rightarrow 0$, the conditional p.d.f.
f(y\,|\,\mathbf{x};\boldsymbol{\zeta })$ becomes more unimodal. As $\sigma
_{\omega }$ gets larger, $f(y\,|\,\mathbf{x};\boldsymbol{\zeta })$ becomes
more multimodal (see Karabatsos \&\ Walker, 2012a\nocite{KarabatsosWalker12c
).
The \textbf{Bayesian Regression} software allows the user to analyze data
using any one of several versions of the infinite-probits\ regression model
\ref{IP mixture reg model}). Versions include models where the kernel
densities are instead specified by covariate independent normal densities
\textrm{n}$(y\,|\,\mu _{j},\sigma _{j}^{2})$, and the mixture weights are
modeled by:
\end{subequations}
\begin{equation}
\omega _{j}(\mathbf{x})=\Phi \left( \dfrac{j-\mathbf{x}^{\mathbf{\intercal }
\boldsymbol{\beta }_{\omega }}{\sqrt{\exp (\mathbf{x}^{\mathbf{\intercal }
\boldsymbol{\lambda }_{\omega })}}\right) -\Phi \left( \dfrac{j-\mathbf{x}^
\mathbf{\intercal }}\boldsymbol{\beta }_{\omega }-1}{\sqrt{\exp (\mathbf{x}^
\mathbf{\intercal }}\boldsymbol{\lambda }_{\omega })}}\right) ,\text{ \ \
for }j=0,\pm 1,\pm 2,\ldots ; \label{new IP mix weights}
\end{equation
include models where either the individual regression coefficients
\boldsymbol{\beta }$ in the kernels, or the individual regression
coefficients $(\boldsymbol{\beta }_{\omega },\boldsymbol{\lambda }_{\omega })
$ in the mixture weights (\ref{new IP mix weights}) are assigned
spike-and-slab priors using the SSVS method (George \& McCulloch, 1993, 199
\nocite{GeorgeMcCulloch93}\nocite{GeorgeMcCulloch97}), to enable automatic
variable (covariate)\ selection inferences from the posterior distribution;
and include mixed-probit regression models for binary (0 or 1) or ordinal (
c=0,1,\ldots ,m$) dependent variables, each with inverse-link function
c.d.f. modeled by a covariate-dependent, infinite-mixture of normal
densities (given by (\ref{IP inf mixture}), but instead for the continuous
underlying latent dependent variable; see Karabatsos \&\ Walker, 2015\nocit
{KarabatsosWalker15}).
\subsection{Some Linear Models}
We briefly review two basic Bayesian normal linear models from standard
textbooks (e.g., O'Hagan \&\ Forster, 2004\nocite{OhaganForster04}; Denison
et al. 2003\nocite{DenisonHolmesMallickSmith02}).
First, the Bayesian normal linear model, assigned a (conjugate)\ normal
inverse-gamma prior distribution to the coefficients and error variance
parameters, $(\boldsymbol{\beta },\sigma ^{2})$, is defined by:
\begin{subequations}
\label{Bayesian lm}
\begin{eqnarray}
y_{i}\,|\,\mathbf{x}_{i} &\sim &f(y\,|\,\mathbf{x}_{i}),\text{ \ \ \
i=1,\ldots ,n \\
f(y\,|\,\mathbf{x}) &=&\text{\textrm{n}}(y\,|\,\mathbf{x}^{\intercal
\boldsymbol{\beta },\sigma ^{2}) \\
\beta _{0}\,|\,\sigma ^{2} &\sim &\text{$\mathrm{N}$}(0,\sigma ^{2}v_{\beta
0}\rightarrow \infty ) \\
\beta _{k}\,|\,\sigma ^{2} &\sim &\text{$\mathrm{N}$}(0,\sigma ^{2}v_{\beta
}),\text{ \ }k=1,\ldots ,p \\
\sigma ^{2} &\sim &\text{\textrm{IG}}(a_{0}/2,a_{0}/2).
\end{eqnarray
An extension of the model (\ref{Bayesian lm}) is provided by the Bayesian
2-level normal random-effects model (HLM). Again, let the data $\mathcal{D
_{n}=\{(y_{i},\mathbf{x}_{i})\}_{i=1}^{n}$ be stratified into $N_{h}$
groups, indexed by $h=1,\ldots ,N_{h}$. Also, for each group $h$, let
y_{i(h)}$ be the $i$th dependent observation, and let $\mathbf{y
_{h}=(y_{i(h)})_{i(h)=1}^{n_{h}}$ be the column vector of $n_{h}$ dependent
observations, corresponding to an observed design matrix $\mathbf{X}_{h}=
\mathbf{x}_{1(h)}^{\mathbf{\intercal }},\ldots ,\mathbf{x}_{i(h)}^{\mathbf
\intercal }},\ldots ,\mathbf{x}_{n_{h}}^{\mathbf{\intercal }})$ of $n_{h}$
rows of covariate vectors $\mathbf{x}_{i(h)}^{\mathbf{\intercal }}$
respectively. Then a Bayesian 2-level model (HLM)\ can be represented by:
\end{subequations}
\begin{subequations}
\label{Bayesian 2 level}
\begin{eqnarray}
y_{i(h)}\,|\,\mathbf{x}_{i(h)} &\sim &f(y\,|\,\mathbf{x}_{i(h)}),\text{ \
i(h)=1,\ldots ,n_{h} \\
f(y\,|\,\mathbf{x}_{i(h)}) &=&\text{\textrm{n}}(y\,|\,\mathbf{x
_{i(h)}^{\intercal }\boldsymbol{\beta }_{Rh},\sigma ^{2}) \\
\mathbf{x}^{\intercal }\boldsymbol{\beta }_{Rh} &=&\mathbf{x}^{\intercal
\boldsymbol{\beta }+\mathbf{x}^{\intercal }\boldsymbol{u}_{h} \\
\beta _{0}\,|\,\sigma ^{2} &\sim &\text{$\mathrm{N}$}(0,\sigma ^{2}v_{\beta
0}\rightarrow \infty ) \\
\beta _{k}\,|\,\sigma ^{2} &\sim &\text{$\mathrm{N}$}(0,\sigma ^{2}v_{\beta
}),\text{ \ }k=1,\ldots ,p \\
\boldsymbol{u}_{h}\,|\,\boldsymbol{T} &\sim &\text{$\mathrm{N}$}(\mathbf{0}
\boldsymbol{T}),\text{ \ }h=1,\ldots ,N_{h} \label{NormMix} \\
\sigma ^{2} &\sim &\text{\textrm{IG}}(a_{0}/2,a_{0}/2) \\
\boldsymbol{T} &\sim &\text{\textrm{IW}}(p+3,s_{0}\mathbf{I}_{p+1}).
\end{eqnarray
This model (\ref{Bayesian 2 level}), as shown in (\ref{NormMix}), assumes
that the random coefficients $\boldsymbol{u}_{h}$ (for $h=1,\ldots ,N_{h}$)
are normally distributed over the $N_{h}$ groups.
Both linear models above, and the different versions of these models
mentioned in Section 1, are provided by the Bayesian Regression software.
See the Help menu for more details.
\section{Using the Bayesian Regression Software}
\subsection{Installing the\ Software}
The \textbf{Bayesian Regression} software is a stand-alone package for a
64-bit Windows computer\footnote
An older version of the software can run on a 32-bit computer.}. To install
the software on your computer, take the following steps:
\begin{enumerate}
\item Go the \textbf{Bayesian Regression} software web page:\newline
http://www.uic.edu/\symbol{126}georgek/HomePage/BayesSoftware.html.\newline
Then click the link on that page to download the \textbf{Bayesian Regression}
software installation file, named BayesInstaller\_web64bit.exe (or
BayesInstaller\_web32bit.exe).
\item Install the software by clicking the file
BayesInstaller\_webXXbit.exe. This will include a web-based installation of
MATLAB Compiler Runtime, if necessary. As you install, select the option
"Add a shortcut to the desktop," for convenience. (To install, be connected
to the internet, and temporarily disable any firewall or proxy settings on
your computer).
\end{enumerate}
\noindent Then start the software by clicking the icon BayesRegXXbit.exe.
The next subsection provides step-by-step instructions on how to use the
\textbf{Bayesian regression} software to perform a Bayesian analysis of your
data set. The software provides several example data files, described under
the Help menu. You can create them by clicking the File menu option: "Create
Bayes Data Examples file folder." Click the File menu option again to import
and open an example data set from this folder. The next subsection
illustrates the software through the analysis of the example data set
PIRLS100.csv.
The \textbf{Bayesian Regression} software, using your menu-selected Bayesian
model, outputs the data analysis results into space- and comma-delimited
text files with time-stamped names, which can be viewed in free \textit
NotePad++}. The comma-delimited output files include the posterior samples\
(.MC1), model fit residual (*.RES), and the model specification (*.MODEL)
files. The software also outputs the results into graph (figure *.fig)
files, which can then be saved into a EPS\ (*.eps), bitmap (*.bmp), enhanced
metafile (*.emf), JPEG image (*.jpg), or portable document (*.pdf) file
format. Optionally you may graph or analyze a delimited text output file
after importing it into spreadsheet software (e.g., \textit{OpenOffice}) or
into the R software using the command line:\ \texttt{ImportedData =
read.csv(file.choose())}.
\subsection{Running the Software (12 Steps for Data Analysis)}
You can run the software for data analysis using any one of many Bayesian
models of your choice. A data analysis involves running the following 12
basic steps (required or optional).
In short, the 12 steps are as follows:\ \newline
(1)\ \ Import or open the data file (Required);\newline
(2)\ \ Compute basic descriptive statistics and plots of your data
(Optional);\newline
(3)\ \ Modify the data set (e.g., create variables) to set up your data
analysis model (Optional);\newline
(4)\ \ Specify a new Bayesian model for data analysis (Required);\newline
(5)\ \ Specify observation weights (Optional);\newline
(6)\ \ Specify the censored observations (Optional);\newline
(7)\ \ Set up the MCMC\ sampling algorithm model posterior estimation
(Required);\newline
(8)\ \ Click the \textbf{Run Posterior Analysis} button (Required);\newline
(9) \ Click the \textbf{Posterior Summaries} button to output data analysis
results (Required);\newline
(10)\ \ Check MCMC\ convergence (Required);\newline
(11)\ \ Click the \textbf{Posterior Predictive button} to run model
predictive analyses (Optional);\newline
(12)\ \ Click the \textbf{Clear button} to finish your data analysis project
\newline
Then you may run a different data analysis. Otherwise, you may then Exit the
software and return to the same data analysis project later, after
re-opening the software.
Below, we give more details on the 12 steps of data analysis.
\begin{enumerate}
\item \textbf{(Required)} \ Use the \underline{\textbf{File}}\textbf{\ menu}
to \textbf{Import or open the data file} for analysis. Specifically, the
data file that you import must be a comma-delimited file, with name having
the .csv extension. (Or, you may click the File menu option to open an
existing (comma-delimited) data (*.DAT)\ file). In the data file, the
variable names are located in the first row, with numeric data (i.e.,
non-text data) in all the other rows. For each row, the number of variable
names must equal the number of commas minus 1. The software allows for
missing data values, each coded as NaN or as an empty blank. After you
select the data file to import, the software converts it into a
comma-delimited data (*.DAT) file. Figure 1 shows the interface of the
\textbf{Bayesian regression} software. It presents the PIRLS100.DAT\ data
set at the bottom of the interface, after the PIRLS100.csv file has been
imported.
\item \textbf{(Optional)} \ Use the \underline{\textbf{Describe/Plot Data Se
}}\textbf{\ menu} \textbf{option(s)} to compute basic descriptive statistics
and plots of the data variables. Statistics and plots include the sample
mean, standard deviation, quantiles, frequency tables, cross-tabulations,
correlations, covariances, univariate or bivariate histograms\footnote
For the univariate histogram, the bin size ($h$) is defined by the
Freedman-Diaconis (1981\nocite{FreedmanDiaconis81}) rule, with $h=2($IQR)
n^{-1/3}$, where IQR is the interquartile range of the data, and $n$ is the
sample size. For the bivariate histogram, the automatic bin sizes are given
by $h_{k}=3.5\widehat{\sigma }_{k}n^{-1/4}$, where $\widehat{\sigma }_{k}$,
k=1,2$, is the sample standard deviation for the two variables (Scott, 199
\nocite{Scott92}).}, stem-and-leaf plots, univariate or bivariate kernel
density estimates\footnote
The univariate kernel density estimate assumes normal kernels, with
automatic bandwidth ($h$) given by the normal reference rule, defined by
h=1.06\widehat{\sigma }n^{-1/5}$, where $\widehat{\sigma }$ is the data
standard deviation, and $n$ is the sample size (Silverman, 1986\nocit
{Silverman86}, p. 45). The bivariate kernel density estimate assumes normal
kernels, with automatic bandwidth determined by the equations in Botev et
al. (2010\nocite{Botev10}).}, quantile-quantile (Q-Q) plots, two- or
three-dimensional scatter plots, scatter plot matrices, (meta-analysis)\
funnel plots (Egger et al. 1997\nocite{Egger_etal_97}), box plots, and plots
of kernel regression estimates with automatic bandwidth selection\footnote
Kernel regression uses normal kernels, with an automatic choice of bandwidth
($h$) given by $\widehat{h}=\sqrt{\widehat{h}_{x}\widehat{h}_{y}}$, where
\widehat{h}_{x}=\mathrm{med}(\,|\,\mathbf{x}-\mathrm{med}(\mathbf{x
)\,|\,)/c $, and $\widehat{h}_{y}=\mathrm{med}(\,|\,\mathbf{y}-\mathrm{med}
\mathbf{y})\,|\,)/c,$ where $(\mathbf{x,y)}$ give the vectors of $X$ data
and $Y$ data (resp.), $\mathrm{med}(\cdot )$ is the median, $c=.6745\ast
(4/3/n)^{0.2}$, and $n$ is the sample size (Bowman \& Azzalini, 1997, p. 3
\nocite{BowmanAzzalini97})}.
\item \textbf{(Optional)}\ \ Use the \underline{\textbf{Modify Data Set}}
\textbf{menu option(s) }to set up a data analysis. The menu options allow
you to construct new variables, handle missing data, and/or to perform other
modifications of the data set. Then the new and/or modified variables can be
included in the Bayesian model that you select in Step 4. Figure 1 presents
the PIRLS100.DAT data at the bottom of the software interface, and shows the
data of the variables MALE, AGE, CLSIZE, ELL, TEXP4, EDLEVEL, ENROL, and
SCHSAFE in the last 8 data columns, respectively, after taking z-score
transformations and adding "Z:" to each variable name. Such transformations
are done with the menu option: Modify Data Set \TEXTsymbol{>} Simple
variable transformations \TEXTsymbol{>}\ Z score. Section 4.3 provides more
details about the available Modify Data Set menu options.\newline
----- \ FIGURE 1 \ in \texttt{http://www.uic.edu/\symbol{126
georgek/HomePage/Figures.pdf} \ -----
\item \textbf{(Required)} \ \textbf{Click the }\underline{\textbf{Specify
New Model}} button to \textbf{select a Bayesian model} for data analysis,
and then for the model select: the dependent variable; the covariate(s)
(predictor(s)) (if selected a regression model); the level-2 (and possibly
level-3) grouping variables (if a multi-level model); and the model's prior
distribution parameters. Figure 2 shows the software interface, after
selecting the Infinite homoscedastic probits regression model, along with
the dependent variable, covariates, and prior parameters.
\item \textbf{(Optional)}\ \ To weight each data observation (row)\
differently under your selected model, \textbf{click the \underline{\textbf
Observation Weights}} button} to select a variable containing the weights
(must be finite, positive, and non-missing). (This button is not available
for a binary or ordinal regression model). By default, the observation
weights are 1. For example, observation weights are used for meta-analysis
of data where each dependent variable observation $y_{i}$ represents a
study-reported effect size (e.g., a standardized mean difference in scores
between a treatment group and a control group, or a correlation coefficient
estimate). Each reported effect size $y_{i}$ has sampling variance $\widehat
\sigma }_{i}^{2}$, and observation weight $1/\widehat{\sigma }_{i}^{2}$ that
is proportional to the sample size for $y_{i}$. Details about the various
effect size measures, and their sampling variance formulas, are found in
meta-analysis textbooks (e.g., Cooper, et al. 2009\nocit
{CooperHedgesValentine09}). Section 4.3 mentions a Modify Data Set menu
option that computes various effect size measures and corresponding
variances.\newline
----- \ FIGURE 2 \ in \texttt{http://www.uic.edu/\symbol{126
georgek/HomePage/Figures.pdf} \ -----
\item \textbf{(Optional)}\ \ \textbf{Click the \underline{\textbf{Censor
Indicators of Y}}\ button}, if the dependent variable consists of \textbf
censored observations} (not available for a binary or ordinal regression
model). Censored observations often appear in survival data, where the
dependent variable $Y$ represents the (e.g., log) survival time of a
patient. Formally, an observation, $y_{i}$, is \textit{censored} when it is
only known to take on a value from a known interval $[Y_{LBi},Y_{UBi}]$; is
\textit{interval-censored} when $-\infty <Y_{LBi}<Y_{UBi}<\infty $; is
\textit{right censored} when $-\infty <Y_{LBi}<Y_{UBi}\equiv \infty $; and
\textit{left censored} when $-\infty \equiv Y_{LBi}<Y_{UBi}<\infty $ (e.g.,
Klein \&\ Moeschberger, 2010\nocite{KleinMoeschberger10}). After clicking
the \textbf{Censor Indicators of Y\ button}, select the two variables that
describe the (fixed)\ censoring lower-bounds ($LB$) and upper-bounds ($UB$)
of the dependent variable observations. Name these variables $LB$ and $UB$.
Then for each interval-censored observation $y_{i}$, its $LB_{i}$\ and
UB_{i}$ values must be finite, with $LB_{i}<UB_{i}$, $y_{i}\leq UB_{i}$, and
$y_{i}\geq LB_{i}$. For each right-censored observation $y_{i}$, its $LB_{i}
\ value must be finite, with $y_{i}\geq LB_{i}$, and set $UB_{i}=-9999$. For
each left-censored observation $y_{i}$, its $UB_{i}$ value must be finite,
with $y_{i}\leq UB_{i}$, and set $LB_{i}=-9999$. For each uncensored
observation $y_{i}$, set $LB_{i}=-9999$ and $UB_{i}=-9999$.
\item \textbf{(Required)} \ \textbf{Enter: the total number (}$S$\textbf{)
of \underline{\textbf{MC\ Samples}}}, i.e., MCMC sampling iterations
(indexed by $s=1,\ldots ,S$, respectively)\textbf{; }the number ($s_{0}\geq
1 $) of the initial \underline{\textbf{Burn-In}} \textbf{period} samples;
and the \underline{\textbf{Thin}} number $k$, to retain every $k^{\text{th}}$
sampling iterate of the $S$ total MCMC samples. The MCMC\ samples are used
to estimate the posterior distribution (and functionals) of the parameters
of your selected Bayesian model. Entering a thin value $k>1$ represents an
effort to have the MCMC\ samples be (pseudo-) independent samples from the
posterior distribution. The burn-in number ($s_{0}$) is your estimate of the
number of initial MCMC\ samples that are biased by the software's starting
model parameter values used to initiate the MCMC chain at iteration $s=0$.
\item \textbf{(Required)} \ \textbf{Click the \underline{\textbf{Run
Posterior Analysis}} button} to run the MCMC\ sampling algorithm, using the
selected MC Samples, Burn-In, and Thin numbers. A wait-bar will then appear
and display the progress of the MCMC\ sampling iterations. After the MCMC\
sampling algorithm finishes running, the software will create an external:
(a)\ model (*.MODEL)\ text file that describes the selected model and data
set; (b)\ Monte Carlo (*.MC1) samples file which contains the generated
MCMC\ samples; (c)\ residual (*.RES)\ file that contains the model's
residual fit statistics; and (d)\ an opened, text output file of summaries
of (marginal)\ posterior point-estimates of model parameters and other
quantities, such as model predictive data-fit statistics. The results are
calculated from the generated MCMC samples aside from any burn-in or
thinned-out samples. Model fit statistics are calculated from all MCMC
samples instead. The software creates all output files in the same
subdirectory that contains the data (*.DAT) file.
\item \textbf{(Required)} \ Click the \underline{\textbf{Posterior Summaries
}\textbf{\ button} to select menu options for additional data analysis
output, such as: text output of posterior quantile estimates of model
parameters and 95\%\ Monte Carlo Confidence Intervals (see Step 10); trace
plots of MCMC\ samples; 2-dimensional plots and 3-dimensional plots of
(kernel)\ density estimates, univariate and bivariate histograms,
distribution function, quantile function, survival function, and hazard
functions, box plots, Love plots, Q-Q plots, and Wright maps, of the
(marginal) posterior distribution(s) of the model parameters; posterior
correlations and covariances of model parameters; and plots and tables of
the model's standardized fit residuals. The software creates all text output
files in the same subdirectory that contains the data (*.DAT) file. You may
save any graphical output in the same directory.
\item \textbf{(Required)} \ Click the \underline{\textbf{Posterior Summaries
} button for menu options to \textbf{check the MCMC\ convergence of
parameter point-estimates}, for every model parameter of interest for data
analysis. Verify:\ (1) that the univariate trace plots present good mixing
of the generated MCMC\ samples of each parameter; and (2)\ that the
generated MCMC\ samples of that parameter provide sufficiently-small
half-widths of the 95\%\ Monte Carlo Confidence Intervals (95\%\ MCCIs) for
parameter posterior point-estimates of interest (e.g., marginal posterior
mean, standard deviation, quantiles, etc.). If for your model parameters of
interest, either the trace plots do not support adequate mixing (i.e., plots
are not stable and "hairy"), or the 95\%\ MCCI half-widths are not
sufficiently small for practical purposes, then the MCMC samples of these
parameters have not converged to samples from the model's posterior
distribution. In this case you need to generate additional MCMC\ samples, by
clicking the \underline{\textbf{Run Posterior Analysis}} \textbf{button}
again. Then re-check for MCMC\ convergence by evaluating the updated trace
plots and the 95\% MCCI half-widths. This process may be repeated until
MCMC\ convergence is reached.
\item \textbf{(Optional)}\ \ \textbf{Click the \underline{\textbf{Posterior
Predictive}} button}\footnote
This button is not available for Bayesian models for density estimation.
However, for these models, the software provides menu options to output
estimates of the posterior predictive distribution, after clicking the
\textbf{Posterior Summaries} button. They include density and c.d.f.
estimates. See Step 9.} to generate model's predictions of the dependent
variable $Y$, conditionally on selected values of one or more (focal)\
covariates (predictors). See Section 2 for more details.\ Then select the
posterior predictive functionals of $Y$ of interest.\ Choices of functionals
include the mean, variance, quantiles (to provide a quantile regression
analysis), probability density function (p.d.f.), cumulative distribution
function (c.d.f.), survival function, hazard function, the cumulative hazard
function, and the probability that $Y\geq 0$. Then select one or more focal
covariate(s) (to define $\mathbf{x}_{\mathcal{S}}$), and then enter their
values, in order to study how predictions of $Y$ varies as a function of
these covariate values. For example, if you chose the variable Z:CLSIZE as a
focal covariate, then you may enter values like $-1.1,$ $.02,$ $3.1,$ so
that you can make predictions of $Y$\ conditionally on these covariate
values. Or you may base predictions on an equally-spaced grid of covariate
(Z:CLSIZE) values, like $-3,-2.5,-2,\ldots 2,2.5,3$, by entering $-3:.5:3.$
If your data set observations are weighted (optional Step \#5), then specify
a weight value for the $Y$\ predictions. Next, if your selected focal
covariates do not constitute all model covariates, then select among options
to handle the remaining (non-focal) covariates. Options include the \textit
grand-mean centering method}, the \textit{zero-centering method}, the
\textit{partial dependence method}, and the \textit{clustered partial
dependence method. }After you made all the selections, the software will
provide estimates of your selected posterior predictive functionals of $Y$,
conditionally on your selected covariate values, in graphical and text
output files, including comma-delimited files. (The software generates
graphs only if you selected 1 or 2 focal covariates; and generates no output
if you specify more than 300 distinct values of the focal covariate(s)). All
analysis output is generated in the same subdirectory that contains the data
(*.DAT)\ file. You may save any graphical output in the same directory.
\item \textbf{(Required)} \ After completing the Bayesian data analysis, you
may click the \underline{\textbf{Clear}}\textbf{\ button}. Then you may
start a different data analysis with another Bayesian model, or exit the
software. Later, you may return to and continue from a previous Bayesian
data analysis (involving the same model and data set) by using menu options
to generate new MCMC\ samples and/or new data analysis output. To return to
the previous analysis, go to the File menu to open the (relevant)\ data file
(if necessary), and then click the \underline{\textbf{Open\ Model}}\textbf{\
button} to open the old model (*.MODEL) file. Then, the software will load
this model file along with the associated MCMC samples (*.MC1) file and
residual (*.RES) files. (Returning to a previous Bayesian regression
analysis is convenient if you have already stored the data, model, MC
samples, and residual files all in the same file subdirectory). Then after
clicking the \underline{\textbf{Run Posterior Analysis}}\textbf{\ button},
the newly generated MCMC\ samples will append the existing MCMC samples
(*.MC1) file and update the residual (*.RES) file.
\end{enumerate}
\noindent Finally, the software provides a \textbf{Fast Ridge Regression}
menu option that performs a Bayesian data analysis using the ridge (linear)\
regression model (Hoerl \&\ Kennard, 1970\nocite{HoerlKennard70}), with
parameters estimated by a fast marginal maximum likelihood algorithm
(Karabatsos, 2014\nocite{Karabatsos14c}). This menu option can provide a
fast analysis of an ultra-large data set, involving either a very large
sample size and/or number of covariates (e.g., several thousands). At this
point we will not elaborate on this method because it is currently the
subject of ongoing research.
\subsection{Modify Data Set Menu Options}
Some \textbf{Modify Data Set} \textbf{menu} options allow you to construct
new variables from your data. These new variables may be included as either
covariates and/or the dependent variable for your Bayesian data analysis
model. Methods for constructing new variables include: simple
transformations of variables (e.g., z-score, log, sum of variables);
transforming a variable into an effect size dependent variable for
meta-analysis (Borenstein, 2009\nocite{Borenstein09}; Fleiss \&\ Berlin, 200
\nocite{FleissBerlin09}; Rosenthal, 1994\nocite{Rosenthal94}); the creation
of lagged dependent variables as covariates for a Bayesian autoregression
time-series analysis (e.g., Prado \&\ West, 2010\nocite{PradoWest2010});
dummy/binary\ coding of variables; the construction of new covariates from
other variables (covariates), via transformations including:\ polynomials,
two-way interactions between variables, univariate or multivariate
thin-plate splines (Green \&\ Silverman, 1993\nocite{GreenSilverman93}) or
cubic splines (e.g., Denison, et al. 2002\nocite{DenisonHolmesMallickSmith02
); spatial-weight covariates (Stroud, et al. 2001\nocite{StroudMullerSanso01
; or thin-plate splines; Nychka, 2000\nocite{Nychka00}) from\ spatial data
(e.g., from latitude and longitude variables) for spatial data analysis.
Now we briefly discuss Modify Data Set menu options that can help set up a
causal analysis of data from a non-randomized (or randomized) study. First,
a propensity score variable, included as a covariate in a regression model;
or as a dummy-coded covariate that stratifies each subject into one of 10
(or more)\ ordered groups of propensity scores; or as observations weights
(entered as the inverse of the propensity scores); can help reduce selection
bias in the estimation of the causal effect (slope coefficient)\ of a
treatment-receipt (versus non-treatment/control) indicator covariate on a
dependent variable of interest (Rosenbaum \&\ Rubin, 1983\nocit
{RosenbaumRubin83a}, 1984\nocite{RosenbaumRubin84}; Imbens, 2004\nocit
{Imbens04}; Lunceford \&\ Davidian, 2004\nocite{LuncefordDavidian04};
Schafer \&\ Kang, 2008\nocite{SchaferKang08}; Hansen, 2008\nocite{Hansen08
). As an alternative to using propensity scores, we may consider a
regression discontinuity design analysis (Thistlewaite \&\ Campbell, 196
\nocite{ThistlewaiteCampbell60}; Cook, 2008\nocite{Cook08}). This would
involve specifying a regression model, with dependent (outcome)\ variable of
interest regressed on covariates that include an assignment variable, and a
treatment assignment variable that indicates (0 or 1)\ whether or not the
assignment variable exceeds a meaningful threshold. Then under mild
conditions (Hahn, et al. 2001\nocite{HahnToddVanderKlaauw01}; Lee \&\
Lemieux, 2010\nocite{LeeLemieux10}), the slope coefficient estimate for the
treatment variable is a causal effect estimate of the treatment (versus
non-treatment)\ on the dependent variable. For either the propensity score
or regression discontinuity design approach, which can be set up using
appropriate Modify Data Set menu options, causal effects can be expressed in
terms of treatment versus non-treatment comparisons of general posterior
predictive functionals of the dependent variable (e.g., Karabatsos \&\
Walker, 2015\nocite{KarabatsosWalker15}).
In some settings, it is of interest to include a multivariate dependent
variable (multiple dependent variables) in the Bayesian regression model
(Step 4). You can convert a multivariate regression problem into a
univariate regression problem (Gelman, et al., 2004, Ch. 19\nocit
{GelmanCarlinSternRubin04}) by clicking a menu option that "vectorizes" or
collapses the multiple dependent variables into a single dependent variable.
This also generates new covariates in the data set, having a block design
that is suited for the (vectorized) multiple dependent variables. To given
an example involving item response theory (IRT)\ modeling (e.g., van der
Linden, 2015\nocite{vanderLinden15}), each examinee (data set row) provides
data on responses to $J$ items (data columns) on a test (e.g., examination
or questionnaire). Here, a menu option can be used to vectorize (collapse)\
the $J$ item response columns into a single new dependent variable (data
column), and to create corresponding dummy item indicator ($-1$ or $0$)
covariates. In the newly-revised data, each examinee occupies $J$\ rows of
data. Then a Bayesian regression model of the software, which includes the
new dependent variable, item covariates, and the examinee identifier as a
grouping variable (or as dummy (0,1)\ indicator covariates), provides an
Item Response Theory (IRT) model for the data (van der Linden, 2015\nocit
{vanderLinden15}).
Similarly, it may be of interest to include a categorical (polychotomous)
dependent variable in your Bayesian regression model. Assume that the
variable takes on $m+1$ (possibly unordered) categorical values, indexed by
c=0,1,\ldots ,m$, with $c=0$ the reference category. In this case, you may
run a menu option that recodes the categorical dependent variables into $m+1$
binary (e.g., 0 or 1) variables, then vectorizes (collapses)\ these multiple
binary variables (data columns)\ into a single binary\ dependent variable
(column), and reformats the covariate data into a block design suitable for
the multiple binary variables. Then for data analysis, you may specify a
binary regression model that includes the (collapsed) binary dependent
variable and the reformatted covariates (Begg \&\ Gray, 1984\nocit
{BeggGray1984}; also see Wu et al. 2004\nocite{WuLinWeng04}).
The Modify Data Set menu also provides menu options to reduce the number of
variables for dimension reduction, including: principal components,
multidimensional scaling, or scaling by the true score test theory and
Cronbach's alpha reliability analysis of test items, and propensity scoring.
There are also menu options that handle missing data, including:
nearest-neighbor hot-deck imputation of missing data (Andridge \&\ Little,
2010\nocite{AndridgeLittle10}); the processing of multiple (missing data)\
imputations or plausible values obtained externally; and the assignment of
missing (NaN)\ values based on specific missing data codes\ (e.g., 8, 9, or
-99, etc.)\ of variables. Finally, there are Modify Data Set menu options
for more basic data editing and reformatting, including: adding data on a
row-identification (ID) variable; aggregating (e.g., averaging)\ variables
by a group identification variable; the selection of cases (data rows) for
inclusion in a reduced data set, including random selection or selection by
values of a variable; the sorting of cases; the deletion of variables;
changing the variable name; and moving the variables into other columns of
the data file.\newline
\section{Real Data Example}
We illustrate the software through the analysis of data set file
PIRLS100.csv, using the software steps outlined in the previous section. The
data are based on a random sample of 100 students from 21 low-income U.S.
elementary schools, who took part of the 2006 Progress in International
Reading Literacy Study (PIRLS).
\begin{center}
----- \ FIGURE 3 \ in \texttt{http://www.uic.edu/\symbol{126
georgek/HomePage/Figures.pdf} \ -----
\end{center}
The dependent variable is student literacy score (zREAD).\ The eight
covariates are: student male status (Z:MALE) indicator (0 or 1) and age
(AGE); student's class size (SIZE) and class percent English language
learners (ELL); student's teacher years of experience (TEXP4) and education
level (TEXP4 = 5 if bachelor's degree; TEXP4 = 6 if at least master's
degree); student's school enrollment (ENROL) and safety rating (SAFE = 1 is
high; SAFE = 3 is low).\noindent \noindent \noindent\ Figure 3 presents the
univariate descriptive statistics of these variables, from a text output
file obtained by the menu option: Describe/Plot Data Set\textbf{\
\TEXTsymbol{>}} Summaries and Frequencies \TEXTsymbol{>} Univariate
descriptives. Data is also available on a school identifier variable (SCHID).
The data for each of the 8 covariates were transformed into z-scores having
mean 0 and variance 1, using the menu option: Modify Data Set \TEXTsymbol{>
\ Simple variable transformations \TEXTsymbol{>}\ Z-score. These
transformations will make the slope coefficients of the 8 covariates\
(resp.)\ interpretable on a common scale, in a regression analysis.
The BNP\ infinite-probits mixture model (\ref{IP mixture reg model}) was fit
to the PIRLS100 data, using the dependent variable and the 8 z-scored
covariates. For the model's prior density function (\ref{IP prior pdf}), the
following software defaults were specified for the prior parameters:
b_{\sigma \mu }=5$, $v=100$, $a_{0}=0.01$, $v_{\omega }=10$, and $a_{\omega
}=0.01$. This represents an attempt to specify a rather non-informative
prior distribution for the model parameters. In order to estimate the
model's posterior distribution, 50,000 MCMC sampling iterations were run,
using an initial burn-in of 2,000 and thinning interval of 5.
Figure 4 presents the model's predictive data-fit statistics (including
their 95\%\ MCCI\ half-widths), from text output that was opened by the
software immediately after the 50K MCMC sampling iterations were run. The
model obtained a $D(\underline{m})$ statistic of $32$, with an R-squared of
.96$, and had no outliers according to standardized residuals that ranged
within $-2$ and $2$.
\begin{center}
\noindent ----- \ FIGURE 4 \ in \texttt{http://www.uic.edu/\symbol{126
georgek/HomePage/Figures.pdf} \ -----
----- \ FIGURE 5 \ in \texttt{http://www.uic.edu/\symbol{126
georgek/HomePage/Figures.pdf} \ -----
\end{center}
Figure 5 presents the (marginal) posterior point-estimates of all the model
parameters, calculated from the 50K\ MCMC\ samples (aside from the burn-in
and thinned-out MCMC\ samples).\ Estimates include the marginal posterior
mean, median, standard deviation, 50\%\ credible interval (given by the 25\%
(.25 quantile)\ and 75\%\ (.75 quantile)\ output columns), and the 95\%\
credible interval (2.5\%, 97.5\%\ columns). Figure 5 is part of the same
text output that reported the model fit statistics (Figure 4).
Figure 6 is a box plot of the (marginal) posterior quantile point-estimates
of the intercept and slope coefficient parameters for the 8 covariates
(i.e., parameters $\boldsymbol{\beta }=(\beta _{0},\beta _{1},\ldots ,\beta
_{p})^{\intercal }$). A red box (blue box, resp.)\ flags a coefficient
parameter that is (not, resp.)\ significantly different than zero, according
to whether or not the 50\%\ (marginal) posterior interval (box) includes
zero. The box plot menu option is available after clicking the Posterior
Summaries button.
\begin{center}
----- \ FIGURE 6 \ in \texttt{http://www.uic.edu/\symbol{126
georgek/HomePage/Figures.pdf} \ -----
\end{center}
MCMC convergence, for the parameters of interest for data analysis, can be
evaluated by clicking certain menu options after clicking the Posterior
Summaries button. Figure 7 presents the trace plots for the model's
intercept and slope parameters sampled over the 50K MCMC sampling
iterations. The trace plots appear to support good mixing for these
parameters, as each trace plot appears stable and "hairy." Figure 8 presents
the 95\%\ MCCI half-widths of the (marginal) posterior coefficient
point-estimates of Figure 5. The half-widths are nearly all less than .10,
and thus these posterior point-estimates are reasonably accurate in terms of
Monte Carlo standard error. If necessary, the software can re-click the
Posterior Analysis button, to run additional MCMC sampling iterations, to
obtain more precise posterior point-estimates of model parameters (as would
be indicated by smaller 95\%\ MCCI half-widths).
\begin{center}
----- \ FIGURE 7 \ in \texttt{http://www.uic.edu/\symbol{126
georgek/HomePage/Figures.pdf} \ -----
----- \ FIGURE 8 \ in \texttt{http://www.uic.edu/\symbol{126
georgek/HomePage/Figures.pdf} \ -----
----- \ FIGURE 9 \ in \texttt{http://www.uic.edu/\symbol{126
georgek/HomePage/Figures.pdf} \ -----
----- \ FIGURE 10 \ in \texttt{http://www.uic.edu/\symbol{126
georgek/HomePage/Figures.pdf} \ -----
\end{center}
The user can click the Posterior Predictive button to investigate how chosen
features (functionals)\ of the posterior predictive distribution varies as a
function of one or more selected (focal)\ covariates, through graphical and
text output.
Figure 9\ provides a quantile and mean regression analysis, by showing the
estimates of the mean, and the .1, .25, .5 (median), .75, and .9 quantiles
of the model's posterior predictive distribution of zREAD, conditionally on
selected values $-2,-1.5,\ldots ,1,1.5,2$ of the Z:CLSIZE covariate, and on
zero for all the 7 other covariates (using the zero-centering method). It
presents nonlinear relationships between literacy performance (zREAD) and
class size (Z:CLSIZE). In particular, for higher literacy-performing
students (i.e., .75 and .90 quantiles of zREAD), there is a highly nonlinear
relationship between zREAD\ and class size. For lower performing students
(i.e., .1 and .25 quantiles of zREAD), there is a flatter relationship
between zREAD\ and class size. For "middle" performing students (mean and .5
quantiles of zREAD), there is a rather flat relationship between zREAD\ and
class size.
Figure 10 shows a 3-dimensional plot of (Rao-Blackwellized) estimates of the
model's posterior predictive p.d.f. of zREAD, conditionally on the same
values of the 8 covariates mentioned earlier. As shown, both the location
and shape of the zREAD distribution changes as a function of class size. For
each posterior predictive p.d.f. estimate (panel), a homogeneous cluster of
students (in terms of a shared zREAD score)\ is indicated by a bump (or
mode)\ in the p.d.f.
\begin{center}
----- \ FIGURE 11 \ in \texttt{http://www.uic.edu/\symbol{126
georgek/HomePage/Figures.pdf} \ -----
\end{center}
The ANOVA-linear DDP model (\ref{ANOVA DDP}) was fit to the PIRLS100 data.
For this model's prior (\ref{ANOVA DDP prior pdf}), the following parameters
were chosen: $r_{0}=10$, $s_{0}=10$, $a_{0}=2,$ $a_{\alpha }=1,$ and
b_{\alpha }=1$. This was an attempt to specify a rather non-informative
prior distribution for the model parameters. This model was estimated using
50,000 MCMC sampling iterations, with burn-in of 2,000 and thinning interval
of 5. MCMC convergence was confirmed according to univariate trace plots and
small 95\% MCCI half-widths for (marginal)\ posterior point-estimates
(nearly all less than .1). Figure 11 presents the marginal posterior
densities (distributions) of the intercept and slope parameters, from the
mixture distribution of the model. Each of these distributions (densities)\
are skewed and/or multimodal, unlike normal distributions. Each mode (bump)\
in a distribution (density)\ refers to a homogeneous cluster of schools, in
terms of a common value of the given (random) coefficient parameter.
Finally, recall that for the PIRLS100 data, the infinite-probits mixture
model (\ref{IP mixture reg model}) obtained a $D(\underline{m})$ statistic
of $32$, an R-squared of $.96$, and no outliers according to all the
absolute standardized residuals being less than 2 (Figure 4). The
ANOVA-linear DDP\ model (\ref{ANOVA DDP}) obtained a $D(\underline{m})$
statistic of $113$, an R-squared of $.64$, and no outliers. The ordinary
linear model obtained a $D(\underline{m})$ statistic of $139$, an R-squared
of $.24$ and $5$ outliers.\ This linear model assumed rather non-informative
priors, with $\beta _{0}\sim \mathrm{N}(0,v_{0}\rightarrow \infty )$, $\beta
_{k}\sim \mathrm{N}(0,1000)$, $k=1,\ldots ,8$, and $\sigma ^{2}\sim $
\textrm{IG}$(.001,.001)$.
\section{Conclusions}
We described and illustrated a stand-alone, user-friendly and menu-driven
software package for Bayesian data analysis. Such analysis can be performed
using any one of many Bayesian models that are available from the package,
including BNP\ infinite-mixture regression models and normal random-effects
linear models. As mentioned in the data analysis exercises of Appendix B,
the software can be used to address a wide range of statistical applications
that arise from many scientific fields. In the future, new Bayesian mixture
models will be added to the software. They will include mixture models
defined by other kernel density functions, and models with parameters
assigned a mixture of P\'{o}lya Trees prior.
\section{Acknowledgments}
This paper is supported by NSF-MMS research grant SES-1156372.
\newpage
\begin{center}
{\Large References}
\end{center}
\begin{description}
\item Agresti A (2002). \textit{Categorical Data Analysis}. John Wiley and
Sons.
\item Albert J, Chib S (1993). \textquotedblleft Bayesian Analysis of Binary
and Polychotomous Response Data.\textquotedblright\ \textit{Journal of the
American Statistical Association}, \textit{88}, 669--679.
\item Andridge RR, Little R (2010). \textquotedblleft A Review of Hot Deck
Imputation for Survey Non-response.\textquotedblright\ \textit{International
Statistical Review}, \textit{78}, 40--64.
\item Antoniak C (1974). \textquotedblleft Mixtures of Dirichlet Processes
with Applications to Bayesian Nonparametric Problems.\textquotedblright\
\textit{Annals of Statistics}, \textit{2}, 1152--1174.
\item Atchad\'{e} Y, Rosenthal J (2005). \textquotedblleft On Adaptive
Markov chain Monte Carlo Algorithms.\textquotedblright\ \textit{Bernoulli},
\textit{11}, 815--828.
\item Barry D, Hartigan J (1993). \textquotedblleft A Bayesian-Analysis for
Change Point Problems.\textquotedblright\ \textit{Journal of the American
Statistical Association}, \textit{88}, 309--319.
\item Begg C, Gray R (1996). \textquotedblleft Calculation of Polychotomous
Logistic Regression Parameters Using Individualized
Regressions.\textquotedblright\ \textit{Biometrika}, \textit{71}, 11--18.
\item Bernardo J, Smith A (1994). \textit{Bayesian Theory}. Wiley,
Chichester, England.
\item Bertoin J (1998). \textit{L\'{e}vy Processes}. Cambridge University
Press, Cambridge.
\item Borenstein M (2009). \textquotedblleft Effect Sizes for Continuous
Data.\textquotedblright In H Cooper, L Hedges, J Valentine (eds.), \textit
The} \textit{Handbook of Research Synthesis and Meta-Analysis} (2nd Ed.),
pp. 221--235. Russell Sage Foundation, New York.
\item Botev Z, Grotowski J, Kroese D (2010). \textquotedblleft Kernel
Density Estimation via Diffusion.\textquotedblright\ \textit{The Annals of
Statistics}, \textit{38}, 2916--2957.
\item Bowman A, Azzalini A (1997). \textit{Applied Smoothing Techniques for
Data Analysis: The Kernel Approach with S-Plus Illustrations}. Oxford
University Press, Oxford.
\item Brooks S (1998). \textquotedblleft Quantitative Convergence Assessment
for Markov chain Monte Carlo via Cusums.\textquotedblright\ \textit
Statistics and Computing,} \textit{8}, 267--274.
\item Brooks S, Gelman A, Jones G, Meng X (2011). \textit{Handbook of Markov
Chain Monte Carlo}. Chapman and Hall/CRC, Boca Raton, FL.
\item Burr D (2012). \textquotedblleft bspmma: An R package for Bayesian
Semiparametric Models for Meta-Analysis.\textquotedblright\ \textit{Journal
of Statistical Software}, \textit{50}, 1--23.
\item Burr D, Doss H (2005). \textquotedblleft A Bayesian Semiparametric
Model for Random-Effects Meta-Analysis.\textquotedblright\ \textit{Journal
of the American Statistical Association}, \textit{100}, 242--251.
\item Casella G, Berger R (2002). \textit{Statistical Inference (2nd Ed.)}.
Duxbury, Pacific Grove, CA.
\item Cepeda E, Gamerman D (2001). \textquotedblleft Bayesian modeling of
variance heterogeneity in normal regression models.\textquotedblright\
\textit{Brazilian Journal of Probability and Statistics}, \textit{14},
207--221.
\item Cook T (2008). \textquotedblleft Waiting for Life to Arrive: A History
of the Regression-Discontinuity Design in Psychology, Statistics and
Economics.\textquotedblright\ \textit{Journal of Econometrics}, \textit{142
, 636--654.
\item Cooper H, Hedges L, Valentine J (2009). \textit{The Handbook of
Research Synthesis and Meta-Analysis (Second Edition)}. Russell Sage
Foundation, New York.
\item De Iorio M, M\"{u}ller P, Rosner G, MacEachern S (2004).
\textquotedblleft An ANOVA model for dependent random
measures.\textquotedblright\ \textit{Journal of the American Statistical
Association}, \textit{99}, 205--215.
\item DeBlasi P, Favaro S, Lijoi A, Mena R, Pr\"{u}nster I, Ruggiero M
(2015). \textquotedblleft Are Gibbs-Type Priors the Most Natural
Generalization of the Dirichlet Process?\textquotedblright\ \textit{IEEE
Transactions on Pattern Analysis and Machine Intelligence}, \textit{37},
212--229.
\item Denison D, Holmes C, Mallick B, Smith A (2002). \textit{Bayesian
Methods for Nonlinear Classification and Regression}. John Wiley and Sons,
New York.
\item Di Lucca M, Guglielmi A, M\"{u}ller P, Quintana F (2012).
\textquotedblleft A Simple Class of Bayesian Non-parametric Autoregression
Models.\textquotedblright \textit{\ Bayesian Analysis}, \textit{7, }771--796.
\item Egger M, Smith GD, Schneider M, Minder C (1997). \textquotedblleft
Bias in Meta-Analysis Detected by a Simple, Graphical
Test.\textquotedblright\ \textit{British Medical Journal}, \textit{315},
629--634.
\item Escobar M, West M (1995). \textquotedblleft Bayesian Density
Estimation and Inference Using Mixtures.\textquotedblright\ \textit{Journal
of the American Statistical Association}, \textit{90}, 577--588.
\item Evans I (1965). \textquotedblleft Bayesian Estimation of Parameters of
a Multivariate Normal Distribution.\textquotedblright\ \textit{Journal of
the Royal Statistical Society}, \textit{Series B}, \textit{27}, 279--283.
\item Favaro S, Lijoi A, Pr\"{u}nster I (2012). \textquotedblleft On the
Stick-Breaking Representation of Normalized Inverse Gaussian
Priors.\textquotedblright\ \textit{Biometrika}, \textit{99}, 663--674.
\item Ferguson T (1973). \textquotedblleft A Bayesian Analysis of Some
Nonparametric Problems.\textquotedblright\ \textit{Annals of Statistics},
\textit{1}, 209--230.
\item Flegal J, Jones G (2011). \textquotedblleft Implementing Markov Chain
Monte Carlo: Estimating with Confidence.\textquotedblright\ In S Brooks, A
Gelman, G Jones, X Meng (eds.), \textit{Handbook of Markov Chain Monte Carlo
, pp. 175--197. CRC, Boca Raton, FL.
\item Fleiss J, Berlin J (2009). \textquotedblleft Effect Size for
Dichotomous Data.\textquotedblright\ In H Cooper, L Hedges, J Valentine
(eds.), The \textit{Handbook of Research Synthesis and Meta-Analysis} (2nd
Ed.), pp. 237--253. Russell Sage Foundation, New York.
\item Freedman D, Diaconis P (1981). \textquotedblleft On the Histogram as a
Density Estimator: L2 theory.\textquotedblright\ P\textit{robability Theory
and Related Fields}, \textit{57}, 453--476.
\item Friedman J (2001). \textquotedblleft Greedy Function Approximation: A
Gradient Boosting Machine.\textquotedblright\ \textit{Annals of Statistics},
\textit{29}, 1189--1232.
\item Fuentes-Garc\'{\i}a R, Mena R, Walker S (2009). \textquotedblleft A
Nonparametric Dependent Process for Bayesian Regression.\textquotedblright\
\textit{Statistics and Probability Letters}, \textit{79}, 1112--1119.
\item Fuentes-Garc\'{\i}a R, Mena R, Walker S (2010). \textquotedblleft A
New Bayesian Nonparametric Mixture Model.\textquotedblright\ \textit
Communications in Statistics}, \textit{39}, 669--682.
\item Gelfand A, Diggle P, Guttorp P, Fuentes M (2010). \textit{Handbook of
Spatial Statistics}. Chapman and Hall/CRC, Boca Raton.
\item Gelfand A, Ghosh J (1998). \textquotedblleft Model Choice: A Minimum
Posterior Predictive Loss Approach.\textquotedblright\ \textit{Biometrika},
\textit{85}, 1--11.
\item Gelfand A, Mukhopadhyay S (1995). \textquotedblleft On Nonparametric
Bayesian Inference for the Distribution of a Random
Sample.\textquotedblright\ \textit{Canadian Journal of Statistics}, \textit
23}, 411--420.
\item Gelfand A, Smith A, Lee TM (1992). \textquotedblleft Bayesian Analysis
of Constrained Parameter and Truncated Data Problems Using Gibbs
Sampling.\textquotedblright\ \textit{Journal of the American Statistical
Association}, \textit{87}, 523--532.
\item Gelman A, Carlin A, Stern H, Rubin D (2004). \textit{Bayesian Data
Analysis (Second Edition)}. Chapman and Hall, Boca Raton, Florida.
\item George E, McCulloch R (1993). \textquotedblleft Variable Selection via
Gibbs Sampling.\textquotedblright\ \textit{Journal of the American
Statistical Association}, \textit{88}, 881--889.
\item George E, McCulloch R (1997). \textquotedblleft Approaches for
Bayesian Variable Selection.\textquotedblright\ \textit{Statistica Sinica},
\textit{7}, 339--373.
\item Geyer C (2011). \textquotedblleft Introduction to
MCMC.\textquotedblright In S Brooks, A Gelman, G Jones, X Meng (eds.),
\textit{Handbook of Markov Chain Monte Carlo}, pp. 3--48. CRC, Boca Raton,
FL.
\item Ghosh J, Ramamoorthi R (2003). \textit{Bayesian Nonparametrics}.
Springer, New York.
\item Gilks W, Wang C, Yvonnet B, Coursaget P (1993). \textquotedblleft
Random-Effects Models for Longitudinal Data Using Gibbs
Sampling.\textquotedblright\ \textit{Biometrics}, \textit{49}, 441--453.
\item Green P, Silverman B (1993). \textit{Nonparametric Regression and
Generalized Linear Models: A Roughness Penalty Approach}. CRC Press, Los
Altos, CA.
\item Hahn J, Todd P, der Klaauw WV (2001). \textquotedblleft Identification
and Estimation of Treatment Effects with a Regression-Discontinuity
Design.\textquotedblright\ \textit{Econometrica}, \textit{69}, 201--209.
\item Hansen B (2008). \textquotedblleft The Prognostic Analogue of the
Propensity Score.\textquotedblright\ \textit{Biometrika}, \textit{95},
481--488.
\item Hanson T (2006). \textquotedblleft Inference for Mixtures of Finite
\'{o}lya Tree Models.\textquotedblright\ \textit{Journal of the American
Statistical Association}, \textit{101}, 1548--1565.
\item Hartigan J (1990). \textquotedblleft Partition
Models.\textquotedblright\ \textit{Communications in Statistics: Theory and
Methods}, \textit{19}, 2745--2756.
\item Hastie T, Tibshiriani R, Friedman J (2009). \textit{The Elements of
Statistical Learning: Data Mining, Inference, and Prediction (2nd Ed.)}.
Springer-Verlag, New York.
\item Hedges L (1981). \textquotedblleft Distribution Theory for Glass's
Estimator of Effect size and Related Estimators.\textquotedblright\ \textit
Journal of Educational and Behavioral Statistics}, \textit{6}, 107--128.
\item Hjort N, Holmes C, M\"{u}ller P, Walker S (2010). \textit{Bayesian
Nonparametrics}. Cambridge University Press, Cambridge.
\item Hoerl A, Kennard R (1970). \textquotedblleft Ridge Regression: Biased
Estimation for Nonorthogonal Problems.\textquotedblright\ \textit
Technometrics}, \textit{12}, 55--67.
\item Holmes C, Held K (2006). \textquotedblleft Bayesian Auxiliary Variable
Models for Binary and Multinomial Regression.\textquotedblright\ \textit
Bayesian Analysis}, \textit{1}, 145--168.
\item IBM Corp (2015). \textit{IBM SPSS Statistics for Windows, v22.0}. IBM
Corp., Armonk, NY.
\item Imbens G (2004). \textquotedblleft Nonparametric Estimation of Average
Treatment Effects Under Exogeneity: A Review.\textquotedblright\ \textit{The
Review of Economics and Statistics}, \textit{86}, 4--29.
\item Imbens GW, Lemieux T (2008). \textquotedblleft Regression
Discontinuity Designs: A Guide to Practice.\textquotedblright\ \textit
Journal of Econometrics}, \textit{142}, 615--635.
\item Ishwaran H, James L (2001). \textquotedblleft Gibbs Sampling Methods
for Stick-Breaking Priors.\textquotedblright\ \textit{Journal of the
American Statistical Association}, \textit{96}, 161--173.
\item Ishwaran H, Zarepour M (2000). \textquotedblleft Markov chain Monte
Carlo in Approximate Dirichlet and Beta Two-Parameter Process Hierarchical
Models.\textquotedblright\ \textit{Biometrika}, \textit{87}, 371--390.
\item James L, Lijoi A, Pr\"{u}nster I (2009). \textquotedblleft Posterior
Analysis for Normalized Random Measures with Independent
Increments.\textquotedblright \textit{\ Scandinavian Journal of Statistics},
\textit{36}, 76--97.
\item Jara A, Hanson T, Quintana F, M\"{u}ller P, Rosner G (2011).
\textquotedblleft DPpackage: Bayesian Semi- and Nonparametric Modeling in
R.\textquotedblright\ \textit{Journal of Statistical Software}, \textit{40},
1--20.
\item Jara A, Lesaffre E, DeIorio M, Quintana F (2010). \textquotedblleft
Bayesian Semiparametric Inference for Multivariate Doubly-Interval-Censored
Data.\textquotedblright\ \textit{Annals of Applied Statistics}, \textit{4},
2126--2149.
\item Johnson N, Kotz S, Balakrishnan N (1994). \textit{Continuous
Univariate Distributions, Vol. 1}. Wiley, New York.
\item Jordan M, Jacobs R (1994). \textquotedblleft Hierarchical Mixtures of
Experts and the EM Algorithm.\textquotedblright\ \textit{Neural Computation
, \textit{6}, 181--214.
\item Kalli M, Griffin J, Walker S (2011). \textquotedblleft Slice Sampling
Mixture Models.\textquotedblright\ \textit{Statistics and Computing},
\textit{21}, 93--105.
\item Karabatsos G (2014). \textquotedblleft Fast Marginal Likelihood
Estimation of the Ridge Parameter in Ridge Regression.\textquotedblright\
Technical Report 1409.2437, arXiv preprint.
\item Karabatsos G, Talbott E, Walker S (2015). \textquotedblleft A Bayesian
Nonparametric Meta-Analysis Model.\textquotedblright\ \textit{Research
Synthesis Methods}, \textit{6}, 28--44.
\item Karabatsos G, Walker S (2012a). \textquotedblleft Adaptive-Modal
Bayesian Nonparametric Regression.\textquotedblright\ \textit{Electronic
Journal of Statistics}, \textit{6}, 2038--2068.
\item Karabatsos G, Walker S (2012b). \textquotedblleft Bayesian
Nonparametric Mixed Random Utility Models.\textquotedblright\ \textit
Computational Statistics and Data Analysis}, \textit{56}, 1714--1722.
\item Karabatsos G, Walker S (2015). \textquotedblleft Bayesian
Nonparametric Item Response Models.\textquotedblright\ In W. van der Linden
(ed.), \textit{Handbook Of Item Response Theory, Volume 1: Models,
Statistical Tools, and Applications}. Taylor and Francis, New York.
\item Karabatsos G, Walker S (2015, to appear). \textquotedblleft A Bayesian
Nonparametric Causal Model for Regression Discontinuity
Designs.\textquotedblright\ In P M\"{u}ller, R Mitra (eds.), \textit
Nonparametric Bayesian Methods in Biostatistics and Bioinformatics}.
Springer-Verlag, New York. (ArXiv preprint 1311.4482).
\item Kingman J (1975). \textquotedblleft Random Discrete
Distributions.\textquotedblright\ \textit{Journal of the Royal Statistical
Society}, \textit{Series B}, \textit{37}, 1--22.
\item Klein J, Moeschberger M (2010). \textit{Survival Analysis (2nd Ed.)}.
Springer-Verlag, New York.
\item Laud P, Ibrahim J (1995). \textquotedblleft Predictive Model
Selection.\textquotedblright\ \textit{Journal of the Royal Statistical
Society}, \textit{Series B}, \textit{57}, 247--262.
\item Lee D (2008). \textquotedblleft Randomized Experiments from Non-Random
Selection in U.S. House Elections.\textquotedblright\ Journal of
Econometrics, 142, 675--697.
\item Lee D, Lemieux T (2010). \textquotedblleft Regression Discontinuity
Designs in Economics.\textquotedblright\ \textit{The Journal of Economic
Literature}, \textit{48}, 281--355.
\item Lijoi A, Mena R, Pr\"{u}nster I (2005). \textquotedblleft Hierarchical
Mixture Modeling with Normalized Inverse-Gaussian Priors.\textquotedblright\
\textit{Journal of the American Statistical Association}, \textit{100},
1278--1291.
\item Lindley D, Smith A (1972). \textquotedblleft Bayes Estimates for the
Linear Model (with Discussion).\textquotedblright\ \textit{Journal of the
Royal Statistical Society}, \textit{Series B}, \textit{34}, 1--41.
\item Lo A (1984). \textquotedblleft On a Class of Bayesian Nonparametric
Estimates.\textquotedblright\ \textit{Annals of Statistics}, \textit{12},
351--357.
\item Lunceford J, Davidian M (2004). \textquotedblleft Strati\ldots cation
and Weighting Via the Propensity Score in Estimation of Causal Treatment
Effects: A Comparative Study.\textquotedblright\ \textit{Statistics in
Medicine}, \textit{23}, 2937--2960.
\item MacEachern S (1999). \textquotedblleft Dependent Nonparametric
Processes.\textquotedblright\ \textit{Proceedings of the Bayesian
Statistical Sciences Section of the American Statistical Association}, pp.
50--55.
\item MacEachern S (2000). \textquotedblleft Dependent Dirichlet
Processes.\textquotedblright\ Technical report, Department of Statistics,
The Ohio State University.
\item MacEachern S (2001). \textquotedblleft Decision Theoretic Aspects of
Dependent Nonparametric Processes.\textquotedblright\ In E George (ed.),
\textit{Bayesian Methods with Applications to Science, Policy and Official
Statistics}, pp. 551--560. International Society for Bayesian Analysis,
Creta.
\item McCullagh P, Nelder J (1989). \textit{Generalized Linear Models (2nd
Ed.)}. Chapman and Hall, London.
\item McLachlan G, Peel D (2000). \textit{Finite Mixture Models}. John Wiley
and Sons, New York.
\item Mitra R, M\"{u}ller P (2015, to appear). \textit{Nonparametric
Bayesian Methods in Biostatistics and Bioinformatics}. Springer-Verlag, New
York.
\item Molenberghs G, Verbeke G (2005). \textit{Models for Discrete
Longitudinal Data}. Springer-Verlag, New York.
\item M\"{u}ller P, Quintana F (2004). \textquotedblleft Nonparametric
Bayesian Data Analysis.\textquotedblright\ \textit{Statistical Science},
\textit{19}, 95--110.
\item M\"{u}ller P, Rosner G, Iorio MD, MacEachern S (2005).
\textquotedblleft A Nonparametric Bayesian Model for Inference in Related
Studies.\textquotedblright\ \textit{Applied Statistics}, \textit{54},
611--626.
\item Neal R (2003). \textquotedblleft Slice Sampling (with
Discussion).\textquotedblright\ \textit{Annals of Statistics}, \textit{31},
705--767.
\item Nychka D (2000). \textquotedblleft Spatial-Process Estimates as
Smoothers.\textquotedblright\ In \textit{Smoothing and Regression:
Approaches, Computation, and Application}, pp. 393--424. John Wiley and
Sons, New York.
\item O'Hagan A, Forster J (2004). \textit{Kendall's Advanced Theory of
Statistics: Bayesian Inference, volume 2B}. Arnold, London.
\item Perman M, Pitman J, Yor M (1992). \textquotedblleft Size-Biased
Sampling of Poisson Point Processes and Excursions.\textquotedblright\
\textit{Probability Theory and Related Fields}, \textit{92}, 21--39.
\item Pitman J (1995). \textquotedblleft Exchangeable and Partially
Exchangeable Random Partitions.\textquotedblright\ \textit{Probability
Theory and Related Fields}, \textit{102}, 145--158.
\item Pitman J (1996). \textquotedblleft Some Developments of the
Blackwell-MacQueen Urn Scheme.\textquotedblright\ In T Ferguson, L Shapeley,
J MacQueen (eds.), \textit{Statistics, Probability and Game Theory}. Papers
in Honor of David Blackwell, pp. 245--268. Institute of Mathematical
Sciences, Hayward, CA.
\item Pitman J, Yor M (1997). \textquotedblleft The Two-Parameter
Poisson-Dirichlet Distribution Derived from a Stable
Subordinator.\textquotedblright\ \textit{Annals of Probability}, \textit{25
, 855--900.
\item Plummer M, Best N, Cowles K, Vines K (2006). \textquotedblleft CODA:
Convergence Diagnosis and Output Analysis for MCMC.\textquotedblright\
\textit{R News}, \textit{6}, 7--11.
\item Prado R, West M (2010). \textit{Time Series: Modeling, Computation,
and Inference}. Chapman and Hall/CRC.
\item Quintana F, Iglesias P (2003). \textquotedblleft Bayesian Clustering
and Product Partition Models.\textquotedblright\ \textit{Journal of the
Royal Statistical Society}: \textit{Series B}, \textit{65}, 557--574.
\item R Development Core Team (2015). \textit{R: A Language and Environment
for Statistical Computing}. R Foundation for Statistical Computing, Vienna,
Austria.
\item Rasmussen C, Ghahramani Z (2002). \textquotedblleft Infinite of
Mixtures of Gaussian Process Experts.\textquotedblright\ In T Diettrich, S
Becker, Z Ghahramani (eds.), \textit{Advances in Neural Information
Processing Systems}, \textit{volume 14}, pp. 881--888. The MIT Press,
Cambridge, MA.
\item Regazzini E, Lijoi A, Pr\"{u}nster I (2003). \textquotedblleft
Distributional Results for Means of Normalized Random Measures with
Independent Increments.\textquotedblright\ \textit{Annals of Statistics}
\textit{\ 31}, 560--585.
\item Robert C, Casella G (2004). \textit{Monte Carlo Statistical Methods
(2nd Ed.)}. Springer, New York.
\item Rosenbaum P, Rubin D (1983a). \textquotedblleft The Central Role of
the Propensity Score in Observational Studies for Causal
Effects.\textquotedblright\ \textit{Biometrika}, \textit{70}, 41--55.
\item Rosenbaum P, Rubin D (1984). \textquotedblleft Reducing Bias in
Observational Studies Using Subclassification on the Propensity
Score.\textquotedblright\ \textit{Journal of the American Statistical
Association}, \textit{79}, 516--524.
\item Rosenthal R (1994). \textquotedblleft Parametric Measures of Effect
Size.\textquotedblright\ In H Cooper, L Hedges (eds.), \textit{The Handbook
of Research Synthesis}, pp. 231--244. Russell Sage Foundation, New York.
\item Schafer J, Kang J (2008). \textquotedblleft Average Causal Effects
from Nonrandomized Studies: A Practical Guide and Simulated
Example.\textquotedblright\ \textit{Psychological Methods}, \textit{13},
279--313.
\item Schervish M (1995). \textit{Theory of Statistics}. Springer-Verlag,
New York.
\item Scott D (1992). \textit{Multivariate Density Estimation: Theory,
Practice, and Visualization}. John Wiley and Sons, New York.
\item Sethuraman J (1994). \textquotedblleft A Constructive Definition of
Dirichlet Priors.\textquotedblright\ \textit{Statistica Sinica}, \textit{4},
639--650.
\item Sethuraman J, Tiwari R (1982). \textquotedblleft Convergence of
Dirichlet Measures and the Interpretation of Their
Parameters.\textquotedblright\ In S Gupta, J Berger (eds.), \textit
Statistical Decision Theory and Related Topics III: Proceedings of the Third
Purdue Symposium}, Volume, pp. 305--315. Academic Press, New York.
\item Silverman B (1986). \textit{Density Estimation for Statistics and Data
Analysis}. Chapman and Hall, Boca Raton, Florida.
\item Stroud J, M\"{u}ller P, Sans\'{o} B (2001). \textquotedblleft Dynamic
Models for Spatiotemporal Data.\textquotedblright\ \textit{Journal of the
Royal Statistical Society}, \textit{Series B}, \textit{63}, 673--689.
\item Stuart E (2010). \textquotedblleft Matching Methods for Causal
Inference: A Review and a Look Forward.\textquotedblright\ \textit
Statistical Science}, \textit{25}, 1--21.
\item Thistlewaite D, Campbell D (1960). \textquotedblleft
Regression-Discontinuity Analysis: An Alternative to the Ex-post Facto
Experiment.\textquotedblright\ \textit{Journal of Educational Psychology},
\textit{51}, 309--317.
\item Thompson S, Sharp S (1999). \textquotedblleft Explaining Heterogeneity
in Meta-Analysis: A Comparison of Methods.\textquotedblright\ \textit
Statistics in Medicine}, \textit{18}, 2693--2708.
\item van der Linden W (2015). \textit{Handbook of Modern Item Response
Theory (Second Edition)}. CTB McGraw-Hill, Monterey, CA.
\item Verbeke G, Molenbergs G (2000). \textit{Linear Mixed Models for
Longitudinal Data}. Springer-Verlag, New York.
\item Walker S, Damien P, Laud P, Smith A (1999). \textquotedblleft Bayesian
Nonparametric Inference for Random Distributions and Related
Functions.\textquotedblright\ \textit{Journal of the Royal Statistical
Society}, \textit{Series B}, \textit{61}, 485--527.
\item Wilk M, Gnanadesikan R (1968). \textquotedblleft Probability Plotting
Methods for the Analysis of Data.\textquotedblright\ \textit{Biometrika},
\textit{55}, 1--17.
\item Wu TF, Lin CJ, Weng R (2004). \textquotedblleft Probability Estimates
for Multi-Class Classification by Pairwise Coupling.\textquotedblright\
\textit{Journal of Machine Learning Research}, \textit{5}, 975--1005.
\end{description}
\newpage
\begin{center}
{\Large Appendix A:\ Technical Preliminaries}
\end{center}
We use the following notation for random variables and probability measures
(functions) (e.g., Berger \&\ Casella, 2002\nocite{CasellaBerger02};
Schervish, 1995\nocite{Schervish95}). A random variable is denoted by an
italicized capital letter, such as $Y$, with $Y$ a function from a sample
space $\mathcal{Y}$ to a set of real numbers. A realization of that random
variable is denoted by a lower case, with $Y=y$. Also, $F(\cdot )$ (or
P(\cdot )$) is the probability measure (function) that satisfies the
Kolmogorov probability axioms, having sample space domain $\mathcal{Y}$ and
range $(0,1)$. Then $F(B)$ (or $P(B)$) denotes the probability of any event
B\subset \mathcal{Y}$ of interest. Throughout, a probability measure is
denoted by a capital letter such as $F$ (or $G$ or $\Pi $ resp., for
example), and $f(y)$ ($g(y)$ and $\pi (y)$, resp.) is the corresponding
probability density of $y$, if $Y$ is discrete or continuous.
If $Y$ is a continuous random variable, with sample space $\mathcal{Y
\subset \mathbb{R}^{d}$ ($d\in \mathbb{Z}_{+}$) and Borel $\sigma $-field
\mathcal{B}(\mathcal{Y})$, and with a probability density function (p.d.f.)
f$ defined on $\mathcal{Y}$ such that $\tint f(y)\mathrm{d}y=1$, then the
probability measure of $f$ is given by $F(B)=\tint_{B}f(y)\mathrm{d}y$ for
all $B\in \mathcal{B}(\mathcal{Y})$, with $f(y)=\mathrm{d}F(y)/\mathrm{d
y\geq 0$. If $Y$ is a discrete random variable with a countable sample space
$\mathcal{Y}=\{y_{1},y_{2},\ldots \}$ and Borel $\sigma $-field $\mathcal{B}
\mathcal{Y})$, and with probability mass function (p.m.f.) $f$ defined on
\mathcal{Y}$ such that $\tsum\nolimits_{k=1}^{\infty }f(y_{k})=1$, then the
probability measure of $f$ is given by $F(B)=\tsum\nolimits_{\{k:y_{k}\in
B\}}f(y_{k})$ for all $B\in \mathcal{B}(\mathcal{Y})$, with $0\leq
f(y)=P(Y=y)\leq 1\mathrm{.}$ Also, a cumulative distribution function
(c.d.f.) is the probability measure $F(y):=F(B)=P(Y\leq y)$, where
B=\{y^{\prime }:-\infty <y^{\prime }\leq y\}$. The c.d.f. $F(y)$ corresponds
to a p.d.f. $f(y)=\mathrm{d}F(y)/\mathrm{d}y$ if $Y$ is continuous; and
corresponds to a p.m.f. $f(y)=P(Y=y)$ if $Y$ is discrete. A multidimensional
random variable, $\boldsymbol{Y}=(Y_{1},\ldots ,Y_{d})$, has c.d.f.
F(y_{1},\ldots ,y_{d})=P(Y_{1}\leq y_{1},\ldots ,Y_{k}\leq y_{d})$.
$Y\sim F$ means that the random variable $Y$ has a distribution defined by
the probability measure $F$. Thus $F$ is also called a distribution.
Notation such a $Y\sim F(y\,|\,x)$ (or $Y\sim F(y\,|\,\mathbf{x})$, resp.)
means that the random variable $Y\,|\,x$ (the random variable, $Y\,|\
\mathbf{x}$, resp.) has a distribution defined by a probability measure
F(\cdot \,|\,x)$ conditionally on the value $x$ of a variable $X$ (or has a
distribution $F(\cdot \,|\,\mathbf{x})$ conditionally on the value $\mathbf{
}=(x_{1},\ldots ,x_{p})$ of $p$ variables). Sometimes a probability
distribution (measure) is notated without the $\cdot \,|$ symbol.
We denote \textrm{N}$(\cdot \,|\,\mu ,\sigma ^{2})$, $\Phi (\cdot )=$
\textrm{N}$(\cdot \,|\,0,1)$, \textrm{Ga}$(\cdot \,|\,a,b)$, \textrm{IG}
(\cdot \,|\,a,b)$, \textrm{U}$(\cdot \,|\,a,b)$, \textrm{Be}$(\cdot
\,|\,a,b) $, \textrm{GIG}$(\cdot \,|\,a,b,q)$, \textrm{N}$(\cdot \,|\
\boldsymbol{\mu },\boldsymbol{\Sigma })$, \textrm{IW}$(\cdot \,|\,d
\boldsymbol{S})$, and \textrm{Di}$(\cdot \,|\,\boldsymbol{\alpha })$, as the
probability measures of a normal distribution with mean and variance
parameters $(\mu ,\sigma ^{2})$; the standard normal distribution; the gamma
distribution with shape and rate parameters $(a,b)$; the inverse-gamma
distribution with shape and rate parameters $(a,b)$; the uniform
distribution with minimum and maximum parameters $(a,b)$; the beta
distribution with shape parameters $(a,b)$; the inverse-Gaussian
distribution with mean $\mu >0$ and shape $\lambda >0$; the generalized
inverse-Gaussian distribution with parameters $(a,b,q)\in \mathbb{R
_{+}\times \mathbb{R}_{+}\times \mathbb{R}$; the multivariate normal
distribution for a random vector $(Y_{1},\ldots ,Y_{d})$, with mean
\boldsymbol{\mu }=(\mu _{1},\ldots ,\mu _{d})^{\intercal }$ and $d\times d$
variance-covariance matrix $\boldsymbol{\Sigma }$; the inverted-Wishart
distribution with degrees of freedom $d$ and scale matrix $\boldsymbol{S}$;
and of the Dirichlet distribution with precision parameters $\boldsymbol
\alpha }$, respectively. These distributions are continuous and define
p.d.f.s\ denoted by lower-case letters, with \textrm{n}$(\cdot \,|\,\mu
,\sigma ^{2})$, \textrm{n}$(\cdot \,|\,0,1)$, \textrm{ga}$(\cdot \,|\,a,b)$,
\textrm{ig}$(\cdot \,|\,a,b)$, \textrm{u}$(\cdot \,|\,a,b)$, \textrm{be}
(\cdot \,|\,a,b)$, \textrm{gig}$(\cdot \,|\,a,b,q)$, \textrm{n}$(\cdot \,|\
\boldsymbol{\mu },\boldsymbol{\Sigma })$, \textrm{iw}$(\cdot \,|\,d
\boldsymbol{S})$, and \textrm{di}$(\cdot \,|\,\boldsymbol{\alpha })$,
respectively. The p.d.f. equations are found in statistical distribution
textbooks (e.g., Johnson et al., 1994\nocite{JohnsonKotzBalkrishnan94}).
\bigskip \newpage
\begin{center}
{\Large Appendix B:\ BNP Data Analysis Exercises}
\end{center}
You may use the Bayesian regression software to answer the following data
analysis exercises. Relevant data sets are available from the software, and
are described under the Help menu.
\begin{enumerate}
\item \textbf{(Regression) \ }Perform regression analyses of the
PIRLS100.csv data from the 2006 Progress in International Reading Literacy
Study (PIRLS). Data are from a random sample of 100 students who each
attended one of 21 U.S. low income schools. The dependent variable, zREAD,
is a continuous-valued student literacy score. Also, consider eight
covariates\ (predictors):\ a binary (0,1) indicator of male status (MALE),
student age (AGE), size of student's class (CLSIZE), percent of English
language learners in the student's classroom (ELL), years of experience of
the student's teacher (TEXP), years of education of the student's teacher
(EDLEVEL), the number of students enrolled in the student's school (ENROL),
and a 3-point rating of the student's school safety (SCHSAFE = 1 is highest;
SCHSAFE = 3 is lowest). There is also data on a school ID\ (SCHID) grouping
variable.\newline
Analyze the data set using the regression models listed below, after
performing a z-score transformation of the 8 covariates using the menu
option: Modify Data Set \TEXTsymbol{>}\ Simple variable transformations
\TEXTsymbol{>}\ Z-score. The SCHID grouping variable may be included in a
multi-level regression model.\newline
-- \ ANOVA/linear DDP\ model (Dirichlet process (DP)\ mixture of linear
regressions).\newline
-- \ An infinite-probits model.\newline
-- \ Another Bayesian nonparametric (infinite) mixture of regression models
\newline
(a)\ Now, describe (represent)\ each of the models, mathematically and in
words.\newline
(b) Summarize the results of your data analyses, while focusing on the
relevant results. Describe the relationship between the dependent variable
and each covariate. For the infinite-probits model, describe the clustering
behavior in the posterior predictive distribution (density)\ of the
dependent variable, conditionally on values of one or two covariates of your
choice. For the DDP\ model, graphically describe the clustering behavior of
the random intercept and slope parameters.\newline
(c)\ Evaluate how well the data support the assumptions of other parametric
models, such as the linearity of regression, the normality of the regression
errors, and the normality of the random intercept and slope coefficients.
Fit a normal linear regression and normal random-effects (multi-level HLM)\
models to the data, and compare the predictive fit between the linear
model(s) and the Bayesian nonparametric models above.
\item \textbf{(Binary Regression) \ }Analyze the data using the following
binary regression models, with binary (0,1)\ dependent variable READPASS,
and the 8 z-scored covariates.\newline
-- \ ANOVA/linear DDP\ logit (or probit) model (a DP mixture of regressions)
\newline
-- \ An infinite-probits model for binary regression.\newline
-- \ Another Bayesian nonparametric (infinite) mixture of regression models
\newline
(a)\ Describe (represent)\ each of the models, mathematically and in words
\newline
(b) Summarize the results of your data analyses, while focusing on the
relevant results. Describe the relationship between the dependent variable
and each covariate. For the infinite-probits model, describe the clustering
behavior in the posterior predictive distribution (density)\ of the
(latent)\ dependent variable, conditionally on values of 1 or 2 covariates
of your choice. For the DDP\ model, graphically describe the clustering
behavior of the random intercept and slope parameters.\newline
(c)\ Evaluate how well the data support assumptions of other parametric
models, namely, the unimodality of the (latent)\ regression errors, and the
normality of the random intercept and slope coefficients. This will require
fitting a probit (or logit)\ linear and/or random-effects regression model
to the data. Compare the fit between the probit (or logit)\ model(s) and the
Bayesian nonparametric models listed above.
\item (\textbf{Causal Analysis}) \ Analyze the PIRLS100.csv data using a
Bayesian nonparametric regression model.\ Investigate the causal effect of
large (versus small) class size (\textbf{CLSIZE}) on reading performance
\textbf{zREAD}), in the context of a regression discontinuity design (e.g.,
Cook, 2008\nocite{Cook08}). For the data set, use a Modify Data Set menu
option to construct a new (treatment)\ variable defined by a (0,1) indicator
of large class size, named \textbf{LARGE}, where \textbf{LARGE }= 1 if
\textbf{CLSIZE}\ $\geq $ 21, and zero otherwise. Perform a regression of
\textbf{zREAD} on the predictors (\textbf{LARGE}, \textbf{CLSIZE}), in order
to infer the causal effect of large class size (\textbf{LARGE }= 1) versus
small class size (\textbf{LARGE }= 0), on the variable \textbf{zREAD},
conditionally on \textbf{CLSIZE }= 21. Do so by inferring the coefficient
estimates of the covariate \textbf{LARGE}, and by performing posterior
predictive inferences of \textbf{zREAD}, conditionally on \textbf{LARGE }= 1
versus \textbf{LARGE }= 0. Under relatively mild conditions, such
comparisons provide inferences of causal effects (of large versus small
class size), as if the treatments were randomly assigned to subjects
associated with class sizes in a small neighborhood around \textbf{CLSIZE }=
21. A key condition (assumption)\ is that students have imperfect control
over the \textbf{CLSIZE }variable, around the value of \textbf{CLSIZE }= 21
(Lee, 2008\nocite{Lee08}; Lee\ \&\ Lemieux, 2010\nocite{LeeLemieux10}).
\item (\textbf{3-level data)} \ Analyze the Classroom data set
(classroom300.csv) using a Bayesian nonparametric regression model. In the
data, students (Level 1) are nested within classrooms (Level 2) nested
within schools (Level 3). A classroom identifier (classid) provides a
level-2 grouping variable. A school identifier (schoolid) provides a level-3
grouping variable. Model mathgain as the dependent variable, defined by
student gain in mathematical knowledge. Also, for the model, include at
least three covariates: student socioeconomic status (ses), the level of
experience of the student's teacher (yearsteaching), and student house
poverty level (housepov).
\item \textbf{(Longitudinal Data Analysis) } Fit a Bayesian nonparametric
regression model to analyze the GPA.csv data. Investigate the relationship
between gpa and the covariates of time, job type, gender status, and
possibly student ID. Consider performing an auto-regressive time-series
analysis of the data, using the model. For this, you can use a Modify Data
Set menu option to construct lag-terms of the dependent variable (for
selected lag order) and then include them as additional covariates in the
regression model.
\item \textbf{(Meta Analysis)} \ Fit a Bayesian nonparametric regression
model to perform a meta-analysis of the Calendar.csv data. The dependent
variable is \textbf{Effect} size, here defined by the unbiased standardized
difference (Hedges, 1981\nocite{Hedges81}) between mean student achievement
in schools that follow a year-round calendar, and (minus)\ the mean student
achievement in schools that follow the traditional nine-month calendar. The
covariates are standard error of the effect size (\textbf{SE\_ES}), and
study publication \textbf{Year}; and the observation weights are given by
the variable \textbf{weight} (= 1/\textbf{Var}). The overall effect-size,
over studies, is represented by the model's intercept parameter. In your
report of the data analysis results, common on the impact of publication
bias on estimates of the overall effect size. Publication bias may be
assessed by inferring the slope coefficient estimate of the \textbf{SE\_ES}
covariate; and/or by posterior predictive inferences of the Effect dependent
variable, conditionally over a range of values of \textbf{SE\_ES}. Such
inferences provide regression analyses for a funnel plot (Thompson \&\
Sharp, 1999\nocite{ThompsonSharp99}).
\item \textbf{(Survival Analysis of censored data) \ }Use a Bayesian
nonparametric regression model to perform a survival analysis of the
larynx.csv data or the bcdeter.csv data. The larynx data set has dependent
variable \textbf{logyears}; and covariates of patient \textbf{age}, cancer
\textbf{stage}, and diagnosis year (\textbf{diagyr}). The observations of
\textbf{logyears} are either right-censored or uncensored, as indicated by
the variables \textbf{LB} and \textbf{UB}. The bcdeter data set has
dependent variable\textbf{\ logmonths}, and treatment type indicator
covariates (\textbf{radioth}, \textbf{radChemo}). The \textbf{logmonths
observations are either right-censored, interval-censored, or uncensored, as
indicated by the variables \textbf{logLBplus1} and \textbf{logUBplus1}.
\item (\textbf{Item Response Analysis}) Use a BNP model to perform an item
response (IRT)\ analysis of either the NAEP75.csv data set, or the
Teacher49.csv data set. The NAEP75 data has binary item-response scores (0 =
Incorrect, 1 = Correct). The Teacher49 data has ordinal item response scores
(0, 1, or 2). Each data set has information about an examinee, per data row,
with examinee item responses in multiple data columns. For either data set,
use a "vectorize"\ Modify Data Set menu option, to collapse the multiple
item response variables (columns)\ into a single column dependent variable,
and to construct item dummy (0 or $-$1) covariates. Report the (marginal)\
posterior estimates of examinee ability, item difficulty (for each test
item), as well as the estimates of the other model parameters.
\end{enumerate}
\end{subequations}
\end{document}
|
{'timestamp': '2015-07-15T02:12:44', 'yymm': '1506', 'arxiv_id': '1506.05435', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05435'}
|
arxiv
|
\section{Introduction}
\citet{GW81} introduced the Capacitated Arc Routing{} Problem (CARP{})
in order to model the search for minimum-cost routes
for vehicles of equal capacity
that are initially located in a vehicle depot
and have to serve all ``customer'' demands.
Applications of CARP{} include
snow plowing, waste collection, meter reading,
and newspaper delivery \citep{CL14}.
Herein, the customer demands require
that roads of a road network are served.
The road network is modeled as a graph
whose edges represent roads
and whose vertices can be thought of as road intersections.
The customer demands are modeled as positive integers
assigned to edges.
Moreover, each edge has a cost for traveling along it.
\optprob{Capacitated Arc Routing{} {Problem} (CARP{})}%
{An undirected graph~$G=(V,E)$, a \emph{depot} vertex~$v_0\in V$, travel costs~$\cost\colon E\to \mathbb N\cup\{0\}$, edge demands~$d\colon E\to\mathbb N\cup\{0\}$, and a vehicle capacity~$\ensuremath{Q}{}$.}
{Find a set~$\W{}$ of closed walks in~$G$, each corresponding to the route of one vehicle and passing through the depot vertex~$v_0$, and find a serving function~$s\colon \W{}\to 2^E$ determining for each closed walk~$w\in\W{}$ the subset~$s(w)$ of edges \emph{served} by~$w$ such that
\begin{compactitem}
\item $\sum_{w\in\W{}}\cost(w)$ is minimized, where $\cost(w):=\sum_{i=1}^\ell \cost(e_i)$ for a walk~$w=(e_1,e_2,\dots,e_\ell)\in E^\ell$,
\item $\sum_{e\in s(w)}d(e)\leq \ensuremath{Q}{}$, and
\item each edge~$e$ with $d(e)>0$ is served by exactly one walk in~$\W{}$.
\end{compactitem}
}
\noindent
Note that vehicle routes may traverse
each vertex or edge of the input graph
multiple times.
Well-known special cases of CARP{}
are the NP-hard Rural Postman Problem (RPP) \citep{LR76},
where the vehicle capacity is unbounded and, hence,
the goal is to find a shortest possible route
for one vehicle that visits all positive-demand edges,
and the pol\-y\-no\-mi\-al-time{} solvable Chinese Postman Problem (CPP)
\citep{Edm65,EJ73},
where additionally \emph{all} edges have positive demand.
\subsection{Mixed and windy variants}
CARP{} is polynomial-time constant-factor approximable
\citep{BHNS14,Jan93,Woe08}.
However, as noted by \citet[Challenge~5]{BNSW14} in a recent survey
on the computational complexity
of arc routing problems,
the polynomial-time approximability of CARP{}
in directed, mixed, and windy graphs is open.
Herein, a \emph{mixed} graph may contain directed arcs
in addition to undirected edges
for the purpose of modeling one-way roads or
the requirement of servicing a road
in a \emph{specific} direction or
in \emph{both} directions.
In a \emph{windy} graph,
the cost for traversing an undirected edge~$\{u,v\}$
in the direction from~$u$ to~$v$
may be different from the cost
for traversing it in the opposite direction
(this models sloped roads, for example).
In this work, we study ap\-prox\-i\-ma\-tion{} algorithms
for mixed and windy variants of CARP{}.
To formally state these problems, we need some terminology
related to mixed graphs.
\begin{definition}[Walks in mixed and windy graphs]\label[definition]{def:walks}
A \emph{mixed graph} is a triple~$G=(V,E,A)$, where $V$~is a set of \emph{vertices}, $E\subseteq\{\{u,v\}\mid u,v\in V\}$ is a set of \emph{(undirected) edges}, $A\subseteq V\times V$~is a set of \emph{(directed) arcs} (that might contain loops), and no pair of vertices has an arc \emph{and} an edge between them. The \emph{head} of an arc~$(u,v)\in V\times V$ is~$v$, its \emph{tail} is~$u$.
A \emph{walk in~$G$} is a sequence~$w=(a_1,a_2,\dots,a_\ell)$
such that,
for each~$a_i=(u,v)$, $1\leq i\leq\ell$,
we have $(u,v)\in A$ or~$\{u,v\}\in E$,
and such that the tail of~$a_i$ is the head of~$a_{i-1}$
for $1<i\leq\ell$.
If $(u, v)$~occurs in~$w$, then we say that
$w$~\emph{traverses} the arc~$(u,v)\in A$
or the edge~$\{u,v\}\in E$.
If the tail of~$a_1$ is the head of~$a_\ell$,
then we call~$w$ a \emph{closed walk}.
Denoting by~$\cost\colon V\times V\to\mathbb N\cup\{0,\infty\}$
the \emph{travel cost} between vertices of~$G$,
the \emph{cost of a walk~$w=(a_1,\dots,a_\ell)$} is
$\cost(w):=\sum_{i=1}^\ell \cost(a_i)$.
The \emph{cost of a set~$\W{}$ of walks} is
$\cost(\W{}):=\sum_{w\in\W{}}\cost(w)$.
\end{definition}
\noindent
We study ap\-prox\-i\-ma\-tion{} algorithms for the following problem.
\optprob{Mixed and windy CARP ({MWCARP}{})}%
{A mixed graph~$G=(V,E,A)$, a depot vertex~$v_0\in V$, travel costs~$\cost\colon V\times V\to\mathbb N\cup\{0,\infty\}$, demands~$d\colon E\cup A\to\mathbb N\cup\{0\}$, and a vehicle capacity~$\ensuremath{Q}{}$.}%
{Find a minimum-cost set~$\W{}$ of closed walks in~$G$,
each passing through the depot vertex~$v_0$,
and a serving function~$s\colon \W{}\to 2^{E\cup A}$ determining
for each walk~$w\in\W{}$ the subset~$s(w)$ of the edges and arcs it \emph{serves} such that
\begin{compactitem}
\item $\sum_{e\in s(w)}d(e)\leq \ensuremath{Q}{}$, and
\item each edge or arc~$e$ with $d(e)>0$ is served
by exactly one walk in~$\W{}$.
\end{compactitem}
}
\noindent
For brevity, we use the term ``arc'' to refer
to both undirected edges and directed arcs.
Besides studying the approximability of {MWCARP}{},
we also consider the following special cases.
If the vehicle capacity~\(Q\) in MWCARP is unlimited
(that is, larger than the sum of all demands)
and the depot~\(v_0\) is incident to a positive-demand arc,
then one obtains the
mixed and windy Rural Postman Problem (MWRPP):
\optprob{Mixed and windy RPP ({MWRPP})}%
{A mixed graph~$G=(V,E,A)$
with travel costs~$\cost\colon V\times V\to\mathbb N\cup\{0,\infty\}$
and a set~$R\subseteq E\cup A$ of \emph{required arcs}.}
{Find a minimum-cost closed walk in~$G$ traversing all arcs in~$R$.}
\noindent
If, furthermore, $E=\emptyset$ in MWRPP,
then we obtain the directed Rural Postman Problem ({DRPP}) and
if $R=E\cup A$, then we obtain the mixed Chinese Postman Problem (MCPP).
\subsection{An obstacle: approximating metric asymmetric TSP}
\label{sec:reltotsp}
Aiming for good approximate solutions for {MWCARP}{},
we have to be aware of the strong relation
of its special case~{DRPP}{}
to the following variant of
the Traveling Salesperson Problem (TSP):
\pagebreak[3]
\optprob{Metric asymmetric TSP ($\triangle$-ATSP{})}%
{A set $V$~of vertices and travel costs~$\cost \colon V\times V\to\mathbb N\cup\{0\}$ satisfying the triangle inequality $\cost(u,v)\leq \cost(u,w)+\cost(w,v)$ for all $u,v,w\in V$.}%
{Find a minimum-cost cycle that visits every vertex in~$V$ exactly once.}
\noindent
Already \citet{CCCM86} observed that
DRPP is a generalization of $\triangle$-ATSP{}.
In fact, DRPP is at least as hard to approximate as $\triangle$-ATSP{}:
Given a $\triangle$-ATSP{} instance,
one obtains an equivalent {DRPP}{} instance
by simply adding a zero-cost loop to each vertex and
by adding these loops to the set~$R$ of required arcs.
This leads to the following observation.
\begin{observation}\label[observation]{obs:conn-to-tatsp}
Any $\alpha(n)$-ap\-prox\-i\-ma\-tion{} for \(n\)-vertex {DRPP}{}
yields an $\alpha(n)$-ap\-prox\-i\-ma\-tion{} for \(n\)-vertex $\triangle$-ATSP{}.
\end{observation}
\noindent
Interestingly, the constant-factor approximability of $\triangle$-ATSP{}
is a long-standing open problem and the
$O(\log n/\log \log n)$-ap\-prox\-i\-ma\-tion{} by \citet{AGMOS10}
from~\citeyear{AGMOS10}
is the first asymptotic improvement over
the $O(\log n)$-ap\-prox\-i\-ma\-tion{} by \citet{FGM82} from~\citeyear{FGM82}.
Thus, the constant-factor approximations
for (undirected) CARP \citep{BHNS14,Jan93,Woe08}
and MCPP \citep{RV99}
cannot be simply carried over
to MWRPP or MWCARP.
\subsection{Our contributions}
As discussed in \cref{sec:reltotsp},
any $\alpha(n)$-ap\-prox\-i\-ma\-tion{} for \(n\)-vertex {DRPP}{}
yields an $\alpha(n)$-ap\-prox\-i\-ma\-tion{} for \(n\)-vertex $\triangle$-ATSP{}.
We first contribute the following theorem
for the converse direction.
\begin{theorem}\label{ourthm}
If $n$-vertex $\triangle$-ATSP{} is $\alpha(n)$-approximable in $t(n)$~time,
then
\begin{enumerate}[(i)]
\item\label{ourthm1} $n$-vertex {DRPP}{} is
$(\alpha(\comps)+1)$-approximable
in $t(\comps)+O(n^3\log n)$~time,
\item\label{ourthm2} $n$-vertex {MWRPP}{} is
$(\alpha(\comps)+3)$-approximable
in $t(\comps)+O(n^3\log n)$~time,
and
\item\label{ourthm3} $n$-vertex {MWCARP}{} is
$(8\alpha(C+1)+27)$-approximable in
$t(\comps+1)+O(n^3\log n)$~time,
\end{enumerate}
\noindent
where $\comps$~is the number of weakly connected components
in the subgraph induced by the positive-demand arcs and edges.
\end{theorem}
\noindent
The approximation factors in \cref{ourthm}\eqref{ourthm3}
and \cref{cor:fpt-apx} below are rather large.
Yet in the experiments described in \cref{sec:experiments},
the relative error of the algorithm was always below~5/4.
We prove \cref{ourthm}(\ref{ourthm1}--\ref{ourthm2}) in \cref{sec:rpp} and \cref{ourthm}\eqref{ourthm3} in \cref{sec:carp}.
Given \cref{ourthm} and \cref{obs:conn-to-tatsp},
the solution quality achievable in polynomial time appears to
mainly depend on the number~$\comps$. %
The number~$\comps$~is small in several applications, for example, when routing street sweepers and snow plows.
Indeed, we found \(C=1\)
in all but one instance of the benchmark sets
\texttt{mval} and \texttt{lpr} of \citet{BBLP06}
and \texttt{egl-large} of \citet{BE08}.
This makes
the following corollary particularly interesting.
\begin{corollary}\label[corollary]{cor:fpt-apx}
{MWCARP}{} is 35-approximable in $O(2^{\comps}\comps^2+n^3\log n)$~time, that is, constant-factor approximable
in polynomial time for $\comps\in O(\log n)$.
\end{corollary}
\noindent
\cref{cor:fpt-apx}
follows from \cref{ourthm} and the exact $O(2^nn^2)$-time algorithm
for $n$-vertex $\triangle$-ATSP{} by \citet{Bell62} and \citet{HelK62}.
It is ``tight'' in the sense that
finding polynomial-time constant-factor ap\-prox\-i\-ma\-tion{}s
for {MWCARP}{} in general
would, via \cref{obs:conn-to-tatsp}, answer a question
open since \citeyear{FGM82} and that
computing \emph{optimal} solutions of {MWCARP}{}
is NP-hard even if~$C=1$ \citep{BNSW14}.
In \cref{sec:experiments},
we evaluate our algorithm on
the \texttt{mval}, \texttt{lpr}, and \texttt{egl-large} benchmark sets
and find that
it outperforms many previous polynomial-time heuristics.
Some instances are solved to optimality.
Moreover, since we found that the solution quality
achievable in polynomial time
appears to crucially depend on the parameter~\(C\)
and almost all of the above benchmark instances have~\(C=1\),
we propose a method
for generating benchmark instances
that simulate cities
separated into few components
by a river, resulting in the \texttt{Ob} benchmark set.
\subsection{Related work}
Several polynomial-time heuristics for variants of CARP
are known \citep{GW81,MA05,BBLP06,BE08} and, in particular,
used for computing initial solutions
for more time-consuming local search
and genetic algorithms \citep{BBLP06,BE08}.
Most heuristics are improved variants of three basic approaches:
\begin{description}
\item[Augment and merge] heuristics start out with small vehicle tours,
each serving one positive-demand arc,
then successively grow and merge these tours
while maintaining capacity constraints \citep{GW81}.
\item[Path scanning] heuristics grow vehicle tours
by successively augmenting them with
the ``most promising'' positive-demand arc \citep{GDB83},
for example,
by the arc that is closest to the previously added arc.
\item[Route first, cluster second] approaches
first construct a \emph{giant tour}
that visits all positive-demand arcs,
which can then be split \emph{optimally} into subsegments
satisfying capacity constraints \citep{Bea83,Ulu85}.
\end{description}
The giant tour for the ``route first, cluster second'' approach
can be computed heuristically \citep{BBLP06,BE08},
yet when computing it
using a constant-factor approximation for the undirected RPP,
one can split it to obtain a constant-factor approximation
for the undirected CARP \citep{Jan93,Woe08}.
Notably, the ``route first, cluster second'' approach
is the only one known to yield
solutions of guaranteed quality for CARP in polynomial time.
One barrier for generalizing this result to MWCARP is that
already approximating MWRPP is challenging (see \cref{sec:reltotsp}).
Indeed, the only polynomial-time algorithms
with guaranteed solution quality
for arc routing problems in mixed graphs
are for variants to which \cref{obs:conn-to-tatsp} does not apply
since \emph{all} arcs and edges have to be served
\citep{RV99,DLL14}.
Our algorithm follows the ``route first, cluster second'' approach:
We first compute an approximate giant tour
using \cref{ourthm}\eqref{ourthm2} and
then, analogously to the approximation algorithms
for undirected CARP \citep{Jan93,Woe08},
split it to obtain \cref{ourthm}\eqref{ourthm3}.
However, since the analyses
of the approximation factor for undirected CARP
rely on symmetric distances between vertices \citep{Jan93,Woe08},
our analysis is fundamentally different.
Our experiments show that
computing the giant tour using \cref{ourthm}\eqref{ourthm2}
is beneficial
compared to computing it heuristically
like \citet{BBLP06} and \citet{BE08}.
Notably,
the approximation factor of \cref{ourthm} depends
on the number~\(C\) of connected components
in the graph
induced by positive-demand arcs.
This number~\(C\) is small in many applications and benchmark data sets, a fact that inspired the development of exact exponential-time algorithms for RPP which are efficient when~\(C\) is small
\citep{Fre77, GWY16, SBNW11,SBNW12}.
\citet{Orl76} noticed already in \citeyear{Orl76}
that the number~\(C\) is a determining factor
for the computational complexity of RPP.
\cref{ourthm} shows that it is also a determining factor
for the solution quality achievable in polynomial time.
In terms of parameterized complexity theory \citep{DF13,CFK+15},
one can interpret \cref{cor:fpt-apx} as
a fixed-parameter constant-factor approximation algorithm \citep{Mar08}
for MWCARP parameterized by~\(C\).
\section{Preliminaries}\label{sec:preliminaries}
Although we consider problems on mixed graphs
as defined in \cref{def:walks},
in some of our proofs
we use more general mixed \emph{multigraphs}~$G=(V,E,A)$
with a set~$V =: V(G)$ of \emph{vertices},
a multiset~$E =: E(G)$ over $\{\{u,v\}\mid u,v\in V\}$
of \emph{(undirected) edges},
a multiset~$A =: A(G)$ over $V\times V$
of \emph{(directed) arcs} that may contain self-loops,
and \emph{travel costs}~$\cost\colon V\times V\to\mathbb N\cup\{0,\infty\}$.
If $E=\emptyset$, then $G$~is a \emph{directed multigraph}.
From \cref{def:walks}, recall the definition of walks in mixed graphs.
An \emph{Euler tour for~$G$} is a closed walk that traverses
each arc and each edge of~$G$
exactly as often as it is present in~$G$.
A graph is \emph{Eulerian} if it allows for an Euler tour. Let $w=(a_1,a_2,\dots,a_\ell)$ be a walk. The \emph{starting point of~$w$} is the tail of~$a_1$, the \emph{end point of~$w$} is the head of~$a_\ell$. A \emph{segment} of~$w$ is a consecutive subsequence of~$w$. Two segments~$w_1=(a_i,\dots,a_j)$ and $w_2=(a_{i'},\dots,a_{j'})$ of the walk~$w$ are \emph{non-overlapping} if $j<i'$ or $j'<i$. Note that two segments of~$w$ might be non-overlapping yet share arcs if $w$~contains an arc several times. The \emph{distance}~$\text{dist}_G(u,v)$ from vertex~$u$ to vertex~$v$ of~$G$ is the minimum cost of a walk in~$G$ starting in~$u$ and ending in~$v$.
The \emph{underlying undirected (multi)graph} of~$G$ is obtained by replacing all directed arcs by undirected edges. Two vertices~$u,v$ of~$G$ are \emph{(weakly) connected} if there is a walk starting in~$u$ and ending in~$v$ in the underlying undirected graph of~$G$. A \emph{(weakly) connected component} of~$G$ is a maximal subgraph of~$G$ in which all vertices are mutually (weakly) connected.
For a multiset~$R\subseteq V\times V$ of arcs, $G[R]$ is the directed multigraph consisting of the arcs in~$R$ and their incident vertices of~$G$. We say that $G[R]$~is the graph \emph{induced by the arcs in~$R$}. For a walk~$w=(a_1,\dots,a_\ell)$ in~$G$, $G[w]$ is the directed multigraph consisting of the arcs~$a_1,\dots,a_\ell$ and their incident vertices, where $G[w]$~contains each arc with the multiplicity it occurs in~$w$. Note that $G[R]$ and~$G[w]$ might contain arcs with a higher multiplicity than~$G$ and, therefore, are not necessarily sub(multi)graphs of~$G$. Finally, the cost of a multiset~$R$ is $\cost(R):=\sum_{a\in R}\mathbb \nu(a)\cost(a)$, where $\mathbb \nu(a)$~is the multiplicity of~$a$ in~$R$.
\section{Rural Postman}
\label{sec:rpp}
This section presents our ap\-prox\-i\-ma\-tion{} algorithms for {DRPP}{} and {MWRPP}{},
thus proving \cref{ourthm}\eqref{ourthm1} and \eqref{ourthm2}.
\cref{sec:eulerian-comps} shows an algorithm
for the special case of {DRPP}{}
where the required arcs induce a subgraph
with Eulerian connected components.
\cref{sec:drpp,sec:mwrpp} subsequently generalize this algorithm
to {DRPP}{} and {MWRPP}{}
by adding to the set of required arcs an arc set of minimum weight
so that the required arcs induce a graph
with Eulerian connected components.
\subsection{Special case: Required arcs induce Eulerian components}
\label{sec:eulerian-comps}
To turn $\alpha(n)$-ap\-prox\-i\-ma\-tion{}s for $n$-vertex $\triangle$-ATSP{}
into $(\alpha(\comps)+1)$-ap\-prox\-i\-ma\-tion{}s for this special case of {DRPP}{},
we use \cref{alg:eulerian-rp}. The two main steps of the algorithm are illustrated in~\Cref{fig:eulerian-rp}:
The algorithm first computes an Euler tour
for each connected component of the graph~\(G[R]\)
induced by the set~\(R\) of required arcs and
then connects them using an approximate $\triangle$-ATSP{} tour
on a vertex set~\(V_R\)
containing (at least) one vertex
of each connected component of~\(G[R]\).
\begin{figure*}[tb]
\centering
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics{dar-1}
\caption{Input: Only required arcs~$R$ are shown, vertices in~$V_R$ are black.}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics{dar-2}
\caption{Compute Euler tours~$T_i$ (dashed)
for each connected component of~{$G[R]$}.}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics{dar-3}
\caption{Add closed walk~$T_G$ with the vertices in~\(V_R\)
to get a feasible solution~$T$ (dashed).}
\end{subfigure}
\caption{Steps of \cref{alg:eulerian-rp}
to compute feasible solutions for {DRPP}{}
when all connected components of~$G[R]$ are Eulerian.}
\label{fig:eulerian-rp}
\end{figure*}
The following \cref{lem:eulerian-rp} gives a bound
on the cost of the solution returned by \cref{alg:eulerian-rp}.
\cref{alg:eulerian-rp} and \cref{lem:eulerian-rp}
are more general than necessary for this special case of DRPP.
In particular, we will not exploit yet
that they allow $R$~to be a \emph{multi}set and
$V_R$~to contain more than one vertex
of each connected component of~$G[R]$.
This will become relevant in \cref{sec:drpp},
when we use \cref{alg:eulerian-rp}
as a subprocedure to solve the general {DRPP}{}.
\begin{algorithm*}
\KwIn{A directed graph~$G$ with travel costs~$\cost{}$,
a multiset~$R$ of arcs of~$G$ such that
$G[R]$~consists of~$\comps$ Eulerian connected components,
and a set~$V_R\subseteq V(G[R])$ containing
at least one vertex of each connected component of~$G[R]$.}
\KwOut{A closed walk traversing all arcs in~$R$.}
\For{$i=1,\dots,\comps$}{
$v_i\gets{}$any vertex of~$V_R$ in component~$i$ of~$G[R]$\;
$T_i\gets{}$Euler tour of connected component~$i$ of~$G[R]$ starting and ending in~$v_i$\nllabel{a1:comptours}\;}
$(V_R,\cost')\gets{}$$\triangle$-ATSP{} instance on the vertices~$V_R$, where $\cost'(v_i,v_j):=\text{dist}_G(v_i,v_j)$\nllabel{a1:buildtsp}\;
$T_{V_R}\gets\alpha(|V_R|)$-approximate $\triangle$-ATSP{} solution for~$(V_R,\cost')$\nllabel{a1:joincomps}\;
$T_G\gets{}$closed walk for~$G$ obtained by replacing each arc~$(v_i,v_j)$ on~$T_{V_R}$ by a shortest path from \(v_i\) to \(v_j\) in~$G$\nllabel{a1:tg}\;
$T\gets{}$closed walk obtained by following~$T_G$ and taking a detour~$T_i$ whenever reaching a vertex~$v_i$\nllabel{a1:buildtour}\;
\Return{$T$}\nllabel{a1:rettour}\;
\caption{Algorithm for the proof of \cref{lem:eulerian-rp}}
\label[algorithm]{alg:eulerian-rp}
\end{algorithm*}
\begin{lemma}\label[lemma]{lem:eulerian-rp}
Let $G$~be a directed graph with travel costs~$\cost{}$, let $R$~be a multiset of arcs of~$G$ such that $G[R]$~consists of~$\comps$ Eulerian connected components, let $V_R\subseteq V(G[R])$ be a vertex set containing at least one vertex of each connected component of~$G[R]$, and let~$\tilde T$ be any closed walk containing the vertices~$V_R$.
If $n$-vertex $\triangle$-ATSP{} is $\alpha(n)$-approximable in $t(n)$~time, then \cref{alg:eulerian-rp} applied to~$(G,c,R)$ and~$V_R$ returns a closed walk of cost at most $\cost(R)+\alpha(|V_R|)\cdot \cost(\tilde T)$ in $t(|V_R|)+O(n^3)$~time that traverses all arcs of~$R$.
\end{lemma}
\begin{proof}
We first show that the closed walk~$T$ returned by \cref{alg:eulerian-rp} visits all arcs in~$R$. Since the $\triangle$-ATSP{} solution~$T_{V_R}$ constructed in \cref{a1:joincomps} visits all vertices~$V_R$, in particular~$v_1,\dots,v_\comps$, so does the closed walk~$T_G$ constructed in \cref{a1:tg}. Thus, for each vertex~$v_i$, $1\leq i\leq\comps$, $T$~takes Euler tour~$T_i$ through the connected component~$i$ of~$G[R]$ and, thus, visits all arcs in~$R$.
We analyze the cost~$\cost(T)$. The closed walk~$T$ is composed of the Euler tours~$T_i$ computed in \cref{a1:comptours} and the closed walk~$T_G$ computed in \cref{a1:tg}. Hence, $\cost(T)=\cost(T_G)+\sum_{i=1}^{\comps}\cost(T_i)$.
Since each~$T_i$ is an Euler tour for some connected component~$i$ of~$G[R]$, each~$T_i$ visits each arc of component~$i$ as often as it is contained in~$R$. Consequently, $\sum_{i=1}^{\comps}\cost(T_i)=\cost(R)$.
It remains to analyze $\cost(T_G)$.
Observe first that
the distances in the $\triangle$-ATSP{} instance~$(V_R,\cost')$
correspond to shortest paths in~$G$
and thus
fulfill the triangle inequality.
We have $\cost(T_G)=\cost'(T_{V_R})$ by
construction of the $\triangle$-ATSP{} instance~$(V_R,\cost')$ in
\cref{a1:buildtsp} and by construction of~$T_G$ from~$T_{V_R}$ in
\cref{a1:tg}. Let $\tilde T$~be any closed walk containing~$V_R$ and let
$T^*_{V_R}$ be an optimal solution for the $\triangle$-ATSP{}
instance~$(V_R,\cost')$. If we consider the closed
walk~$\tilde T_{V_R}$ that visits the vertices~$V_R$ of the $\triangle$-ATSP{}
instance~$(V_R,\cost')$ in the same order as~$\tilde T$, we get
$\cost'(T^*_{V_R})\leq\cost'(\tilde T_{V_R})\leq \cost(\tilde T)$.
Since the closed walk~$T_{V_R}$ computed in \cref{a1:joincomps} is an
$\alpha(|V_R|)$-approximate solution to the $\triangle$-ATSP{}
instance~$(V_R,\cost')$, it finally follows that
$\cost(T_G)=\cost'(T_{V_R})\leq\alpha(|V_R|)\cdot
\cost'(T^*_{V_R})\leq\alpha(|V_R|)\cdot \cost(\tilde T)$.
Regarding the running time, observe that the instance~$(V_R,\cost')$ in \cref{a1:buildtsp} can be constructed in $O(n^3)$~time using the Floyd-Warshall all-pair shortest path algorithm \citep{Flo62}, which dominates all other steps of the algorithm except for, possibly, \cref{a1:joincomps}.
\end{proof}
\noindent
\cref{lem:eulerian-rp} proves \cref{ourthm}\eqref{ourthm1}
for {DRPP}{}~instances $I=(G,c,R)$ when $G[R]$~consists of Eulerian connected components: Pick~$V_R$ to contain exactly one vertex
of each of the $\comps$~connected components of~$G[R]$.
Since an optimal solution~$T^*$ for~$I$
visits the vertices~$V_R$ and satisfies $\cost(R)\leq \cost(T^*)$,
\cref{alg:eulerian-rp} yields a solution
of cost at most $\cost(T^*)+\alpha(C)\cdot \cost(T^*)$.
\subsection{Directed Rural Postman}\label{sec:drpp}
In the previous section,
we proved \cref{ourthm}\eqref{ourthm1} for
the special case of {DRPP}{} when
$G[R]$~consists of Eulerian connected components.
We now transfer this result to the general DRPP.
To this end,
observe that a feasible solution~$T$ for a {DRPP}{} instance~$(G,c,R)$
enters each vertex~$v$ of~$G$ as often as it leaves. Thus, if we
consider the multigraph~$G[T]$ that contains
each arc of~$G$ with same multiplicity as~$T$, then $G[T]$ is a
supermultigraph of~$G[R]$ in which every vertex is \emph{balanced}
\citep{DMNW13,SBNW12}:
\begin{definition}[Balance]
We denote the \emph{balance} of a vertex~$v$ in a graph~$G$ as
\[\balance_G(v):=\indeg_G(v)-\outdeg_G(v).\]
We call a vertex~$v$ \emph{balanced} if $\balance_G(v)=0$.
\end{definition}
\noindent Since $G[T]$ is a supergraph of~$G[R]$ in which all vertices are balanced and since a directed connected multigraph is Eulerian if and only if all its vertices are balanced, we immediately obtain the below observation. Herein and in the following, for two (multi-)sets~$X$ and~$Y$, $X \uplus Y$ is the multiset obtained by adding the multiplicities of each element in~$X$ and~$Y$.
\begin{observation}\label[observation]{obs:eulerize}
Let $T$~be a feasible solution for a {DRPP}{} instance~$(G,c,R)$ such that~$G[R]$ has $\comps$~connected components and let $R^*$ be a minimum-cost multiset of arcs of~$G$ such that every vertex in~$G[R\uplus R^*]$ is balanced.
Then, $\cost(R\uplus R^*)\leq \cost(T)$ and $G[R\uplus R^*]$ consists of at most~$\comps$ Eulerian connected components.
\end{observation}
\begin{algorithm*}
\KwIn{A {DRPP}{} instance~$I=(G,\cost,R)$ such that $G[R]$~has $\comps$~connected components and a set~$V_R$ of vertices, one of each connected component of~$G[R]$.}
\KwOut{A feasible solution for~$I$.}
$f\gets{}$minimum-cost flow for the {UMCF}{} instance~$(G,\balance_{G[R]},c)$\nllabel{a2:computeflow}\;
\lForEach(\nllabel{a2:buildrprime}){$a\in A(G)$}
{add arc~$a$ with multiplicity~$f(a)$ to (initially empty) multiset~$R^*$}
$T\gets{}$closed walk computed by \cref{alg:eulerian-rp} applied to~$(G,c,R\uplus R^*)$ and~$V_R$\nllabel{a2:computetour}\;
\Return{$T$}\;
\caption{Algorithm for the proof of \cref{lem:drpp}.}
\label[algorithm]{alg:drpp}
\end{algorithm*}
\noindent \cref{alg:drpp} computes an $(\alpha(\comps)+1)$-ap\-prox\-i\-ma\-tion{} for a
{DRPP}{} instance~$(G,c,R)$ by first computing a minimum-cost arc
multiset~$R^*$ such that~$G[R\uplus R^*]$ contains only balanced
vertices and then applying \cref{alg:eulerian-rp}
to~$(G,c,R\uplus R^*)$.
It is well known that the first step can be modeled
using the {Uncapacitated Minimum-Cost Flow}{} Problem \citep{CCCM86,CMR00,DMNW13,EJ73,Fre79}:
\optprob{{Uncapacitated Minimum-Cost Flow}{} ({UMCF}{})}%
{A directed graph~$G=(V,A)$ with \emph{supply} $s\colon V\to\mathbb Z$ and \emph{costs}~$\cost\colon A\to\mathbb N\cup\{0\}$.}
{Find a \emph{flow} $f\colon A\to\mathbb N\cup\{0\}$ minimizing $\sum_{a\in A}\cost(a)f(a)$ such that, for each~$v\in V$,
\begin{align}
\smashoperator{\sum_{(v,w)\in A}}f(v,w)-\smashoperator{\sum_{(w,v)\in A}}f(w,v)&=s(v).\tag{FC}\label{fc}
\end{align}
}
\noindent
\cref{fc} is known as the \emph{flow conservation} constraint:
For every vertex~$v$ with~$s(v)=0$,
there are as many units of flow entering the node as leaving it.
Nodes~$v$ with~$s(v)>0$ ``produce'' $s(v)$~units of flow,
whereas nodes~$v$ with~$s(v)<0$ ``consume'' $s(v)$~units of flow.
For our purposes, we will use \(s(v):=\balance_{G[R]}(v)\).
{UMCF}{} is solvable in $O(n^3\log n)$~time \citep[Theorem~10.34]{AMO93}.
\begin{lemma}\label[lemma]{lem:drpp}
Let $I:=(G,c,R)$~be a {DRPP}{} instance such that $G[R]$~has $\comps$~connected components, and let~$V_R$ be a vertex set containing exactly one vertex of each connected component of~$G[R]$. Moreover, consider two closed walks in~$G$:
\begin{itemize}
\item Let $\tilde T$
be any closed walk containing the vertices~$V_R$, and
\item let $\hat T$~be any feasible solution for~$I$.
\end{itemize}
If $n$-vertex $\triangle$-ATSP{} is $\alpha(n)$-approximable in $t(n)$~time, then \cref{alg:drpp} applied to~$I$ and~$V_R$ returns a feasible solution of cost at most $\cost(\hat T)+\alpha(\comps)\cdot \cost(\tilde T)$ in $t(\comps)+O(n^3\log n)$~time.
\end{lemma}
\begin{proof}
For the sake of self-containment,
we first prove that \cref{alg:drpp} in \cref{a2:buildrprime}
indeed computes a minimum-cost arc set~$R^*$
such that all vertices in~$G[R\uplus R^*]$ are balanced.
This follows from the one-to-one correspondence
between arc multisets~$R'$ such that
$G[R\uplus R']$~has only balanced vertices
and flows~$f$ for the {UMCF}{} instance $I':=(G,\balance_{G[R]},c)$:
%
%
%
%
%
Each vertex~$v$ has $\balance_{G[R]}(v)$
more incident in-arcs than out-arcs in~$G[R]$ and, thus,
in order for $\balance_{G[R\uplus R']}(v)=0$ to hold,
$R'$~has to contain $\balance_{G[R]}(v)$ more out-arcs
than in-arcs incident to~$v$.
Likewise, by \eqref{fc}, in any feasible flow for~$I'$,
there are $\balance_{G[R]}(v)$~more units of flow leaving~$v$
than entering~$v$.
%
%
Thus,
from a multiset~$R'$ of arcs such that~$G[R\uplus R']$ is balanced,
we get a feasible flow~$f$ for~$I'$ by setting~$f(v,w)$
to the multiplicity of the arc~$(v,w)$ in~$R'$.
From a feasible flow~$f$ for~$I'$,
%
%
%
%
%
we get a multiset~$R'$ of arcs such that~$G[R\uplus R']$ is balanced
by adding to~$R'$ each arc~$(v,w)$ with multiplicity~$f(v,w)$.
We conclude that the arc multiset~$R^*$
computed in \cref{a2:buildrprime} is a minimum-cost set
such that~$G[R\uplus R^*]$ is balanced:
A set of lower cost would yield a flow cheaper
than the optimum flow~$f$ computed in \cref{a2:computeflow}.
We use the optimality of~$R^*$ to give an upper bound on the cost of the closed walk~$T$ computed in \cref{a2:computetour}. Since $V_R$~contains exactly one vertex of each connected component of~$G[R]$, it contains at least one vertex of each connected component of~$G[R\uplus R^*]$. Therefore, \cref{alg:eulerian-rp} is applicable to~$(G,c,R\uplus R^*)$ and, by \cref{lem:eulerian-rp}, yields a closed walk in~$G$ traversing all arcs in~$R\uplus R^*$ and having cost at most~$\cost(R\uplus R^*)+\alpha(|V_R|)\cdot\cost(\tilde T)$. This is a feasible solution for~$(G,c,R)$ and, since by \cref{obs:eulerize}, we have $\cost(R\uplus R^*)\leq\cost(\hat T)$, it follows that this feasible solution has cost at most $\cost(\hat T)+\alpha(C)\cdot\cost(\tilde T$).
Finally, the running time of \cref{alg:drpp} follows from the fact that the minimum-cost flow in \cref{a2:computeflow} is computable in $O(n^3\log n)$~time \citep[Theorem~10.34]{AMO93} and that \cref{alg:eulerian-rp} runs in $t(\comps)+O(n^3)$~time (\cref{lem:eulerian-rp}).
\end{proof}
\noindent
We may now prove \cref{ourthm}\eqref{ourthm1}.
\begin{proof}[Proof of \cref{ourthm}(\ref{ourthm1})]
Let $(G,c,R)$~be an instance of {DRPP}{} and let~$V_R$ be a set of vertices containing exactly one vertex of each connected component of~$G[R]$. An optimal solution~$T^*$ for~$I$ contains all arcs in~$R$ and all vertices in~$V_R$ and hence, by \cref{lem:drpp}, \cref{alg:drpp} computes a feasible solution~$T$ with $\cost(T)\leq \cost(T^*)+\alpha(\comps)\cdot \cost(T^*)$ for~$I$.
\end{proof}
\noindent
Before generalizing \cref{alg:drpp} to MWRPP,
we point out two design choices in the algorithm
that allowed us to prove an approximation factor.
\cref{alg:drpp} has two steps:
It first adds a minimum-weight set~\(R^*\) of required arcs
so that \(G[R\uplus R^*]\)~has Eulerian connected components.
Then, these connected components
are connected using a cycle via \cref{alg:eulerian-rp}.
In the first step, it might be tempting
to add a minimum-weight set~\(R'\) of required arcs
so that each connected component of~\(G[R]\)
becomes an Eulerian connected component of~\(G[R\uplus R']\).
However,
this set \(R'\) might be more expensive than~\(R^*\):
Multiple non-Eulerian connected components of~\(G[R]\)
might be contained in one Eulerian connected component
of~\(G[R\uplus R^*]\).
In the second step, it is crucial to connect
the connected components of~\(G[R\uplus R^*]\)
using a \emph{cycle}.
\citet{CCCM86} and \citet{CMR00}, for example,
reverse the two phases of the algorithm
and first join the connected components of~\(G[R]\)
using a minimum-weight arborescence or spanning tree,
respectively.
This, however, may increase the imbalance of vertices
and, thus,
the weight of the arc set~\(R^*\) that has to be added
in their second phase
in order to balance the vertices of~\(G[R\uplus R^*]\).
Interestingly, the heuristic of \citet{CMR00} aims to find
a minimum-weight connecting arc set so that the resulting
graph can be balanced at low extra cost
and already \citet{PW95} pointed out that,
in context of the (undirected) RPP,
reversing the steps
in the algorithm of \citet{CCCM86}
can be beneficial.
\subsection{Mixed and windy Rural Postman}\label{sec:mwrpp}
In the previous section,
we presented \cref{alg:drpp} for {DRPP}{}
in order to prove \cref{ourthm}\eqref{ourthm1}.
We now generalize it to MWRPP
in order to prove \cref{ourthm}\eqref{ourthm2}.
To this end,
we replace each undirected edge~$\{u,v\}$
in an {MWRPP}{} instance by two directed arcs~$(u,v)$ and~$(v,u)$,
where we force the undirected \emph{required} edges
of the {MWRPP}{} instance
to be traversed in the cheaper direction:
\begin{lemma}\label[lemma]{lem:direct-edges}
Let $I:=(G,c,R)$~be an~{MWRPP}{} instance and let $I':=(G',c,R')$~be the {DRPP}{} instance obtained from~$I$ as follows:
\begin{itemize}
\item $G'$ is obtained by replacing each edge~$\{u,v\}$ of~$G$ by two arcs~$(u,v)$ and~$(v,u)$,
\item $R'$ is obtained from~$R$ by replacing each edge~$\{u,v\}\in R$ by an arc~$(u,v)$ if~$\cost(u,v)\leq \cost(v,u)$ and by~$(v,u)$ otherwise.
\end{itemize}
Then,
\begin{enumerate}[(i)]
\item\label{de1} each feasible solution~\(T'\) for~$I'$
is a feasible solution of the same cost for~$I$ and,
\item\label{de2} for each feasible solution~$T$ for~$I$, there
is a feasible solution~$T'$ for~$I'$ with~$\cost(T')< 3\cost(T)$.
\end{enumerate}
\end{lemma}
\begin{proof}
Statement \eqref{de1} is obvious
since each required edge of~$I$ is served by~$T'$
in at least one direction.
Moreover, the cost functions in~$I$ and~$I'$ are the same.
Towards \eqref{de2}, let $T$~be a feasible solution for~$I$,
that is,
\(T\)~is a closed walk that traverses all required arcs and edges of~\(I\).
We show how to transform~\(T\) into a feasible solution for~\(I'\).
Let \((u,v)\) be an arbitrary required arc of~\(I'\)
that is not traversed by~\(T\).
Then, \(I\)~contains a required edge~\(\{u,v\}\)
and \(T\)~contains arc~\((v,u)\) of~\(I'\).
Moreover, \(c(u,v)\leq c(v,u)\).
Thus, we can replace \((v,u)\) on~\(T\) by
the sequence of arcs $(v,u),(u,v),(v,u)$.
This sequence serves the required arc~\((u,v)\) of~\(I'\)
and costs
$\cost(v,u)+\cost(u,v)+\cost(v,u)\leq 3\cost(u,v)$.
\end{proof}
\noindent Using \cref{lem:direct-edges}, it is easy to prove \cref{ourthm}\eqref{ourthm2}.
\begin{proof}[Proof of \cref{ourthm}(\ref{ourthm2})]
Given an {MWRPP}{} instance~$I=(G,c,R)$, compute a {DRPP}{} instance~$I':=(G',c,R')$ as described in \cref{lem:direct-edges}. This can be done in linear time.
Let $V_R$~be a set of vertices containing exactly one vertex of each connected component of~$G'[R']$ and let $T^*$ be an optimal solution for~$I$. Observe that $T^*$~is not necessarily a feasible solution for~$I'$, since it might serve required arcs of~$I'$ in the wrong direction. Yet $T^*$~is a closed walk in~$G'$ visiting all vertices of~$V_R$. Moreover, by \cref{lem:direct-edges}, $I'$~has a feasible solution~$T'$ with~$\cost(T')\leq 3\cost(T^*)$.
Thus, applying \cref{alg:drpp} to~$I'$ and~$V_R$ yields a feasible solution~$T$ of cost at most~$\cost(T')+\alpha(C)\cdot \cost(T^*)\leq 3\cost(T^*)+\alpha(C)\cdot \cost(T^*)$ due to \cref{lem:drpp}. Finally, $T$~is also a feasible solution for~$I$ by \cref{lem:direct-edges}.
\end{proof}
\begin{remark}
\label{rem:orientation}
If a required edge~\(\{u,v\}\) has \(c(u,v)=c(v,u)\),
then we replace it by two arcs \((u,v)\) and \((v,u)\)
in the input graph~\(G\)
and replace~\(\{u,v\}\) by an arbitrary one of them
in the set~\(R\) of required arcs
without influencing the approximation factor.
This gives a lot of room for experimenting with heuristics
that ``optimally'' orient undirected required edges
when converting MWRPP to DRPP \citep{MA05,CMR00}.
Indeed, we will do so in \cref{sec:experiments}.
\end{remark}
\section{Capacitated Arc Routing}
\label{sec:carp}
\noindent
We now present our ap\-prox\-i\-ma\-tion{} algorithm for MWCARP, thus proving \cref{ourthm}\eqref{ourthm3}.
Our algorithm follows the ``route first, cluster second''-approach
\citep{Bea83,Ulu85,FHK78,Jan93,Woe08}
and exploits the fact that joining all vehicle tours of a solution gives an {MWRPP}{} tour
traversing all positive-demand arcs and the depot.
Thus,
in order to approximate {MWCARP}{}, the idea is to
first compute an approximate {MWRPP}{} tour
and then split it into subtours,
each of which can be served by a vehicle of capacity~$\ensuremath{Q}{}$.
Then we close each subtour by shortest paths via the depot.
We now describe our ap\-prox\-i\-ma\-tion{} algorithm for MWCARP in detail. For convenience, we use the following notation.
\begin{definition}[Demand arc]
For a mixed graph~\(G=(V,A,E)\)
with demand function~$d \colon E \cup A \to \mathbb{N} \cup \{0\}$,
we define \[R_d := \{a \in E \cup A \mid d(a) > 0\}\] to be
the set of \emph{demand arcs}.
\end{definition}
\noindent
We construct {MWCARP}{} solutions from what we call \emph{feasible splittings}
of {MWRPP}{} tours~\(T\).
\begin{definition}[Feasible splitting]\label[definition]{def:admsplit}
For an {MWCARP}{} instance~$I = (G,v_0,c,d,\ensuremath{Q}{})$, let $T$~be a
closed walk containing all arcs in~$R_d$ and
$\W{}=(w_1,\ldots,w_\ell)$ be a tuple of segments of~$T$. In the
following, we abuse notation and refer by~\W{} to both the tuple and
the set of walks it contains.
Consider a serving function $s \colon \W{} \to 2^{R_d}$
that assigns to each walk~\(w\)
the set~\(s(w)\) of arcs in~$R_d$ that it serves.
We call $(\W, s)$ a \emph{feasible splitting{} of~$T$}
if the following conditions hold:
\begin{enumerate}[(i)]\label{admsplit}
\item\label{nonoverlap} the walks in~$\W$ are mutually non-overlapping segments of~$T$,
\item when concatenating the walks in~$\W$ in order, we obtain a subsequence of~$T$,\label{as:order}
\item each $w_i \in \W$ begins and ends with an arc in $s(w_i)$,\label{as:short}
\item $\{s(w_i) \mid w_i \in \W\}$ is a partition of~$R_d$, and\label{as:partition}
\item for each $w_i \in \W$, we have $\sum_{e\in s(w_i)}d(e) \leq \ensuremath{Q}{}$ and, if %
$i<\ell$, then $\sum_{e\in s(w_i)}d(e)+d(a) > \ensuremath{Q}{}$, where~$a$ is the first arc served by~$w_{i+1}$.\label{as:full}
\end{enumerate}
\end{definition}
\paragraph{Constructing feasible splittings.}
Given an {MWCARP}{} instance~$I=(G,v_0,c,d,\ensuremath{Q}{})$,
a feasible splitting{}~$(\W,s)$ of a closed walk~$T$
that traverses all arcs in~$R_d$
can be computed in linear time
using the following greedy strategy.
We assume that each arc
has demand at most~$\ensuremath{Q}{}$
since otherwise $I$~has no feasible solution.
Now, traverse~$T$, successively
defining subwalks~$w \in \W$ and the corresponding sets~$s(w)$
one at a time.
The traversal starts with the first arc~$a \in R_d$ of~$T$ and by
creating a subwalk~$w$ consisting only of~$a$ and $s(w) = \{a\}$. On
discovery of a still unserved arc
$a \in R_d \setminus (\bigcup_{w' \in \W}s(w'))$ do the following. If
$\sum_{e\in s(w)}d(e)+d(a) \leq \ensuremath{Q}{}$, then add~$a$ to~$s(w)$ and
append to~$w$ the subwalk of~$T$ that was traversed since discovery of
the previous unserved arc in~$R_d$. Otherwise, mark $w$ and $s(w)$ as
finished, start a new tour~$w \in \W$ with $a$ as the first arc, set
$s(w)=\{a\}$, and continue the traversal of~$T$. If no such arc $a$ is found,
then stop. It is not hard to verify that $(\W, s)$~is indeed a
feasible splitting{}.
\begin{algorithm*}
\KwIn{An {MWCARP}{} instance~$I = (G,v_0,c,d,\ensuremath{Q}{})$ such that $(v_0,v_0)\in R_d$ and such that $G[R_d]$~has $\comps$~connected components.}
\KwOut{A feasible solution for $I$.}
\tcc{Compute a base tour containing all demand arcs and the depot}
$I' \leftarrow{}${MWRPP}{} instance~$(G,c,R_d)$\nllabel{alg:carp:drpinst}\;
$T \leftarrow\beta(\comps)$-approximate {MWRPP}{} tour for~$I'$ starting and ending in~$v_0$\nllabel{alg:carp:basetour}\;
\tcc{Split the base tour into one tour for each vehicle}
$(\W, s) \leftarrow $ a feasible splitting{} of~$T$\nllabel{alg:carp:split}\;
\ForEach{$w \in \W$}{%
close $w$ by adding shortest paths from $v_0$ to $s$ and from $t$ to $v_0$ in~$G$, where $s, t$ are the start and endpoints of $w$, respectively\nllabel{alg:carp:close}\; } \Return{$(\W, s)$}\;
\caption{Algorithm for the proof of \cref{lem:carp}.}
\label[algorithm]{alg:carp}
\end{algorithm*}
\paragraph{The algorithm.}
\cref{alg:carp} constructs an {MWCARP}{} solution from an approximate
{MWRPP}{} solution~$T$ containing all demand arcs and the depot~$v_0$.
In order to ensure that $T$~contains~$v_0$, \cref{alg:carp} assumes that
the input graph has a demand loop~$(v_0,v_0)$: If this loop is not
present, we can add it with zero cost. Note that, while this does not
change the cost of an optimal solution, it might increase the number of
connected components in the subgraph induced by demand arcs by one. To
compute an {MWCARP}{} solution from~$T$, \cref{alg:carp} first computes a
feasible splitting{}~$(\W,s)$ of~$T$. To each walk~$w_i\in\W$, it then adds a
shortest path from the end of~$w_i$ to the start of~$w_i$ via the
depot. It is not hard to check that \cref{alg:carp} indeed outputs a
feasible solution by using the properties of feasible splittings and the
fact that $T$~contains all demand arcs.
\begin{remark}
\label{rem:split}
Instead of computing a feasible splitting of~\(T\) greedily,
\cref{alg:carp} could compute a splitting of~\(T\)
into pairwise non-overlapping segments
that provably minimizes the cost of the resulting MWCARP solution
\citep{Ulu85,BBLP06,Woe08,Jan93}.
Indeed, we will do so in our experiments in \cref{sec:experiments}.
For the analysis of the approximation factor, however,
the greedy splitting is sufficient and more handy,
since the analysis can exploit that two consecutive segments
of a feasible splitting serve more than \(Q\)~units of demand
(excluding, possibly, the last segment).
\end{remark}
\noindent
The remainder of this section is
devoted to the analysis of the solution cost,
thus proving the following proposition, which,
together with \cref{ourthm}\eqref{ourthm2},
yields \cref{ourthm}\eqref{ourthm3}.
\begin{proposition}\label[proposition]{lem:carp}
Let $I = (G, v_0, c, d, \ensuremath{Q}{})$ be an {MWCARP}{} instance
and let $I'$~be the instance obtained from~$I$ by adding a zero-cost demand arc~$(v_0,v_0)$ if it is not present.
If {MWRPP}{} is $\beta(\comps)$-approximable in $t(n)$~time, then \cref{alg:carp} applied to~$I'$ computes a $(8\beta(\comps + 1)+3)$\nobreakdash-ap\-prox\-i\-ma\-tion{} for~$I$ in $t(C+1)+O(n^3)$~time. Herein, $\comps$~is the number of connected components in~$G[R_d]$.
\end{proposition}
\noindent
The following lemma follows from the fact
that the concatenation of all vehicle tours
in any {MWCARP}{} solution
yields an {MWRPP}{} tour containing all demand arcs and the depot.
\begin{lemma}\label[lemma]{lem:shortsplitting}
Let $I = (G, v_0, c, d, \ensuremath{Q}{})$ be an {MWCARP}{} instance with $(v_0,v_0)\in R_d$ and an optimal solution~$(\W^*,s^*)$. The closed walk~$T$ and its feasible splitting{}~$(\W,s)$ computed in \cref{alg:carp:basetour,alg:carp:split} of \cref{alg:carp} satisfy $\cost(\W) \leq \cost(T)\leq \beta(\comps)\cost(\W^*)$, where $\comps$~is the number of connected components in~$G[R_d]$.
\end{lemma}
\begin{proof}
Consider an optimal solution~$(\W^*, s^*)$ to~$I$. The closed walks
in~$\W^*$ visit all arcs in~$R_d$. Concatenating them to a closed
walk~$T^*$ gives a feasible solution for the {MWRPP}{}
instance~$I'=(G,c,R_d)$ in \cref{alg:carp:drpinst} of \cref{alg:carp}.
Moreover, $\cost(T^*)=\cost(\W^*)$. Thus, we have
$\cost(T) \leq \beta(\comps)\cost(T^*)$ in \cref{alg:carp:basetour}.
Moreover, by \cref{def:admsplit}\eqref{nonoverlap}, one has
$\cost(\W)\leq\cost(T)$. This finally implies
$\cost(\W)\leq\cost(T) \leq
\beta(\comps)\cost(T^*)=\beta(\comps)\cost(\W^*)$ in
\cref{alg:carp:split}.
\end{proof}
\noindent
For each~$w_i\in\W$, it remains to analyze the length of the shortest paths from~$v_0$ to~$w_i$ and from~$w_i$ to~$v_0$ added in \cref{alg:carp:close} of \cref{alg:carp}. We bound their lengths in the lengths of an auxiliary walk~$A(w_i)$ from~$v_0$ to~$w_i$ and of an auxiliary walk~$Z(w_i)$ from~$w_i$ to~$v_0$. The auxiliary walks~$A(w_i)$ and~$Z(w_i)$ consist of arcs of~$\W$, whose total cost is bounded by \cref{lem:shortsplitting}, and of arcs of an optimal solution~$(\W^*,s^*)$. We show that, in total, the walks~$A(w_i)$ and~$Z(w_i)$ for \emph{all}~$w_i\in\W$ use each subwalk of~$\W$ and~$\W^*$ at most a constant number of times. To this end, we group the walks in~$\W$ into consecutive pairs, for each of which we will be able to charge the cost of the auxiliary walks to a distinct vehicle tour of the optimal solution.
\begin{definition}[Consecutive pairing]
For a feasible splitting~$(\W,s)$ with~$\W=(w_1,\dots,w_\ell)$,
we call
\[\W^2{} :=
\{(w_{2i-1}, w_{2i}) \mid
i \in \{1, \ldots, \lfloor {\ell}/{2} \rfloor\}\}\]
a \emph{consecutive pairing}.
\end{definition}
\noindent We can now show, by applying Hall's theorem \citep{Hal35}, that each pair traverses an arc from a \emph{distinct} tour of an optimal solution.
\begin{lemma}\label[lemma]{lem:assignment}
Let $I=(G,v_0,c,d,\ensuremath{Q}{})$~be an {MWCARP}{} instance with an optimal solution~$(\W^*,s^*)$ and let $\W^2{}$ be a consecutive pairing of some feasible splitting~$(\W,s)$. Then, there is an injective map $\phi \colon \W^2{} \to \W^*,(w_i,w_{i+1})\mapsto w^*$ such that $(s(w_i) \cup s(w_{i+1})) \cap s^*(w^*)\ne\emptyset$.
\end{lemma}
\begin{proof}
Define an undirected bipartite graph~$B$ with the partite
sets~$\W^2{}$ and~$\W^*$. A pair~$(w_i, w_{i+1}) \in \W^2{}$
and a closed walk~$w^* \in \W^*$ are adjacent in~$B$ if
$(s(w_i) \cup s(w_{i+1})) \cap s^*(w^*)\ne\emptyset$. We prove that
$B$~allows for a matching that matches each vertex of~$\W^2{}$ to
some vertex in~$\W^*$.
To this end, by Hall's theorem \citep{Hal35},
it suffices to prove that, for each subset~$S \subseteq \W^2{}$,
it holds that $|N_B(S)| \geq |S|$,
where $N_B(S):=\bigcup_{v\in S}N_B(v)$
and $N_B(v)$~is the set of neighbors of a vertex~$v$ in~$B$.
Observe that,
by \cref{def:admsplit}\eqref{as:full} of feasible splittings,
for each pair~$(w_i, w_{i+1}) \in \W^2{}$, we have
$d(s(w_i) \cup s(w_{i+1})) \geq \ensuremath{Q}{}$.
Since the pairs serve pairwise disjoint sets of demand arcs
by \cref{def:admsplit}\eqref{as:partition},
the pairs in~$S$ serve a total demand of at
least~$\ensuremath{Q}{}\cdot |S|$ in the closed walks~$N_B(S)\subseteq\W^*$.
Since each closed walk in~$N_B(S)$ serves demand at most~$\ensuremath{Q}{}$,
the set~$N_B(S)$ is at least as large as~$S$, as required.
\end{proof}
\noindent
In the following, we fix
an arbitrary arc in~$(s(w_i) \cup s(w_{i+1})) \cap s^*(w^*)$
for each pair~\((w_i,w_{i+1})\in\W^2{}\)
and call it the \emph{pivot{} arc} of~$(w_i,w_{i+1})$.
Informally, the auxiliary walks~$A(w_i)$, $Z(w_i)$ mentioned before are constructed as follows for each walk~$w_i$. To get from the endpoint of~$w_i$
to~$v_0$, walk along the closed walk~$T$ until traversing the first
pivot{} arc~$a$, then from the head of~$a$ to~$v_0$
follow the tour of~\(W^*\) containing~$a$.
To get
from~$v_0$ to~$w_i$, take the symmetric approach: walk backwards on~$T$
from the start point of~$w_i$ until traversing a pivot{} arc~\(a\)
and then follow the tour of~$\W^*$ containing~$a$.
The formal definition of the auxiliary walks~$A(w)$ and~$Z(w)$
is given below and illustrated in \cref{fig:auxpaths}. %
\begin{figure}
\centering
\begin{tikzpicture}[x=0.7cm,y=0.85cm]
%
%
\draw[{|->}] (0,0) -- (3,0) node[above,pos=0.7] {$w_{i-1}$};
\draw[{|->}] (3,0) -- (6,0) node[above,pos=0.5] {$w_{i}$};
\draw[{|->}] (6,0) -- (9,0) node[above,pos=0.5] {$w_{i+1}$};
\draw[{|->}] (9,0) -- (12,0) node[above,pos=0.3] {$w_{i+2}$};
\draw[ultra thick, ->] (1,0)--(2,0);
\draw[ultra thick, ->] (10,0)--(11,0);
\draw [decorate,decoration={brace},thick] (6,-3.2)--(0,-3.2) node [midway,below] {$p(i)$};
\draw [decorate,decoration={brace},thick] (12,-3.2)--(6,-3.2) node [midway,below] {$q(i)$};
\draw[->, shorten >= 2pt] (1,-3) -- (1,0) node [midway,above,rotate=90] {$A^*(w_{i-1},w_{i})$};
\draw[->, shorten >= 2pt] (10,-3) -- (10,0) node [midway,above,rotate=90] {$A^*(w_{i+1},w_{i+2})$};
\draw[->] (2,0) -- (2,-3) node [midway,above,rotate=-90] {$Z^*(w_{i-1},w_{i})$};
\draw[->] (11,0) -- (11,-3) node [midway,above,rotate=-90] {$Z^*(w_{i+1},w_{i+2})$};
\draw[->] (1,0.6) -- (3,0.6) node [midway,above] {$A'(w_{i})$};
\draw[->] (6,0.6) -- (11,0.6) node [midway,above] {$Z'(w_i)$};
\draw[dotted] (0,0)--(0,-3.5);
\draw[dotted] (1,0)--(1,0.6);
\draw[dotted] (1,0.6)--(1,0.6);
\draw[dotted] (3,0)--(3,0.6);
\draw[dotted] (6,-3.5)--(6,0.6);
\draw[dotted] (9,0)--(9,0.6);
\draw[dotted] (11,0)--(11,0.6);
\draw[dotted] (12,0)--(12,-3.5);
\end{tikzpicture}
\caption{Illustration of \cref{def:auxpaths}. Dotted lines are
ancillary lines. Thin arrows are walks. The braces along the
bottom show a consecutive pairing of
walks~$w_{i-1},\dots,w_{i+2}$. Bold
arcs are pivot{} arcs. Here, $p(i)$
is exactly the pair that contains~$w_i$ and~$q(i)$ is the next
pair.}
\label{fig:auxpaths}
\end{figure}
\begin{definition}[Auxiliary walks]\label[definition]{def:auxpaths}
Let $I=(G,v_0,c,d,\ensuremath{Q}{})$~be an {MWCARP}{} instance, $(\W^*,s^*)$ be an optimal solution, and $\W^2{}$ be a consecutive pairing of some feasible splitting~$(\W,s)$ of a closed walk~$T$ containing all arcs~$R_d$ and~$v_0$, where $\W{} = (w_1, \ldots, w_\ell)$.
Let $\phi \colon \W^2{} \to \W^*$ be an injective map as in \cref{lem:assignment} and, for each pair~$(w_i, w_{i+1}) \in \W^2$, let
\begin{itemize}[$A^*(w_i,w_{i+1})$]
\item[$A^*(w_i,w_{i+1})$] be a subwalk of~$\phi(w_i,w_{i+1})$ from~$v_0$ to the tail of the pivot{} arc %
of $(w_i,w_{i+1})$,
\item[$Z^*(w_i,w_{i+1})$] be a subwalk of~$\phi(w_i,w_{i+1})$ from the head of the pivot{} arc %
of $(w_i,w_{i+1})$ to~$v_0$.
\end{itemize}
\noindent For each walk~$w_i\in\W$ with $i\geq 3$ (that is, $w_i$ is not in the first pair of~$\W^2{}$), let
\begin{itemize}[$A'(w_i)$]
\item[$p(i){}$] be the index of the pair whose pivot{} arc is traversed first when walking~$T$ backwards starting from the starting point of~$w_i$,
\item[$A'(w_i)$] be the subwalk of~$T$ starting at the end point of $A^*(w_{2p(i){}-1}, w_{2p(i){}})$ %
and ending at the start point of~$w_i$, and
\item[$A(w_i)$] be the walk from~$v_0$ to the start point of~$w_i$ following first $A^*(w_{2p(i){}-1}, w_{2p(i){}})$ and then~$A'(w_i)$.
\end{itemize}
\noindent For each walk~$w_i\in\W$ with $i \leq \ell-3$ (that is, $w_i$ is not in the last pair of~$\W^2{}$, where $w_\ell$ might not be in any pair if~$\ell$ is odd), let
\begin{itemize}[$A'(w_i)$]
\item[$q(i){}$] be the index of the pair whose pivot{} arc is traversed first when following~$T$ starting from the end point of~$w_i$,
\item[$Z'(w_i)$] be the subwalk of~$T$ starting at the end point of~$w_i$ and ending at the start point of~$Z^*(w_{2q(i){}-1}, w_{2q(i){}})$, and
\item[$Z(w_i)$] be the walk from the end point of~$w_i$ to~$v_0$ following first~$Z'(w_i)$ and then $Z^*(w_{2q(i){}-1}, w_{2q(i){}})$.
\end{itemize}
\end{definition}
\noindent We are now ready to prove \cref{lem:carp}, which also concludes our proof of \cref{ourthm}.
\begin{figure*}
\centering
\begin{tikzpicture}[x=0.75cm,y=0.85cm]
\draw[{|->}] (-6,0) -- (-3,0) node[above,pos=0.6] {$w_{i-2}$};
\draw[{|->}] (-3,0) -- (0,0) node[above,pos=0.5] {$w_{i-1}$};
\draw[{|->}] (0,0) -- (3,0) node[above,pos=0.5] {$w_i$};
\draw[{|->}] (3,0) -- (6,0) node[above,pos=0.5] {$w_{i+1}$};
\draw[{|->}] (6,0) -- (9,0) node[above,pos=0.5] {$w_{i+2}$};
\draw[{|->}] (9,0) -- (12,0) node[above,pos=0.4] {$w_{i+3}$};
\draw[ultra thick, ->] (1,0)--(2,0);
\draw[ultra thick, ->] (-5,0)--(-4,0);
\draw[ultra thick, ->] (10,0)--(11,0);
\draw [decorate,decoration={brace},thick] (0,-3.2)--(-6,-3.2) node [midway,below] {$p(i)$};
\draw [decorate,decoration={brace},thick] (6,-3.2)--(0,-3.2);
\draw [decorate,decoration={brace},thick] (12,-3.2)--(6,-3.2) node [midway,below] {$q(i)$};
\draw[->, shorten >= 2pt] (-5,-3) -- (-5,0) node [midway,above,rotate=90] {$A^*(w_{i-2},w_{i-1})$};
\draw[->, shorten >= 2pt] (1,-3) -- (1,0) node [midway,above,rotate=90] {$A^*(w_{i},w_{i+1})$};
\draw[->, shorten >= 2pt] (10,-3) -- (10,0) node [midway,above,rotate=90] {$A^*(w_{i+2},w_{i+3})$};
\draw[->] (-4,0) -- (-4,-3) node [midway,above,rotate=-90] {$Z^*(w_{i-2},w_{i-1})$};
\draw[->] (2,0) -- (2,-3) node [midway,above,rotate=-90] {$Z^*(w_{i},w_{i+1})$};
\draw[->] (11,0) -- (11,-3) node [midway,above,rotate=-90] {$Z^*(w_{i+2},w_{i+3})$};
\draw[->] (-5,0.6) -- (-0.05,0.6) node [pos=0.6,above] {$A'(w_i)$};
\draw[->] (1,1.7) -- (3,1.7) node [midway,above] {$A'(w_{i+1})$};
\draw[->] (1,2.4) -- (6,2.4) node [midway,above] {$A'(w_{i+2})$};
\draw[->] (1,1.5) -- (9,1.5) node [midway,above] {$A'(w_{i+3})$};
\draw[->] (-3,1.3) -- (2,1.3) node [midway,above] {$Z'(w_{i-2})$};
\draw[->] (0,0.6) -- (2,0.6) node [midway,above] {$Z'(w_{i-1})$};
\draw[->] (3,0.6) -- (11,0.6) node [midway,above] {$Z'(w_i)$};
\draw[dotted] (0,0.6)--(0,-3.5);
\draw[dotted] (-5,0.6)--(-5,0);
\draw[dotted] (-3,1.2)--(-3,0);
%
\draw[dotted] (1,0)--(1,0.8);
\draw[dotted] (1,1.1)--(1,2.4);
\draw[dotted] (2,0)--(2,1.3);
\draw[dotted] (3,0)--(3,1.6);
\draw[dotted] (6,-3.5)--(6,2.4);
\draw[dotted] (9,0)--(9,1.5);
\draw[dotted] (11,0)--(11,0.6);
\draw[dotted] (-6,0)--(-6,-3.5);
\draw[dotted] (12,0)--(12,-3.5);
\end{tikzpicture}
\caption{Illustration of the situation in which a maximum number of five different walks in~$\W$ traverse the same pivot{} arc (the bold arc of~$w_i$) in their respective auxiliary walks. }
\label{fig:auxpaths2}
\end{figure*}
\begin{proof}[Proof of \cref{lem:carp}]
Let $I = (G, v_0, c, d, \ensuremath{Q}{})$ be an {MWRPP}{} instance and~$(\W^*,s^*)$ be an optimal solution. If there is no demand arc~$(v_0,v_0)$ in~$I$, then we add it with zero cost in order to make \cref{alg:carp} applicable. This clearly does not change the cost of an optimal solution but may increase the number of connected components of~$G[R_d]$ to~$\comps+1$.
In \cref{alg:carp:basetour,alg:carp:split}, \cref{alg:carp} computes a tour~$T$ and its feasible splitting{}~$(\W,s)$,
which works in $t(C+1)+O(n^3)$~time by \cref{ourthm}\eqref{ourthm2}.
Denote $\W=(w_1,\dots,w_\ell)$. The solution returned by \cref{alg:carp} consists, for each~$1\leq i\leq\ell$, of a tour starting in~$v_0$, following a shortest path to the starting point of~$w_i$, then~$w_i$, and a shortest path back to~$v_0$.
For $i\geq 3$, the shortest path from~$v_0$ to the starting point of~$w_i$ has length at most~$\cost(A(w_i))$. For $i\leq \ell-3$, the shortest path from the end point of~$w_i$ to~$v_0$ has length at most~$\cost(Z(w_i))$. This amounts to $\sum_{i=3}^{\ell}\cost(A(w_i))+\sum_{i=1}^{\ell-3}\cost(Z(w_i))$. To bound the costs of the shortest paths attached to~$w_i$ for $i\in\{1,2,\ell-2,\ell-1,\ell\}$, observe the following. For each~$i\in\{1,2\}$, the shortest paths from~$v_0$ to the start point of~$w_i$ and from the end point of~$w_{\ell-i}$ to~$v_0$ together have length at most~$\cost(T)$. The shortest path from the end point of~$w_{\ell}$ to~$v_0$ has length at most~$\cost(T)-\cost(\W{})$.
Thus, the solution returned by \cref{alg:carp} has cost at most%
\begin{align*}\allowdisplaybreaks
&\sum_{i=1}^\ell \cost(w_i)+\sum_{i=3}^{\ell}\cost(A(w_i))+\sum_{i=1}^{\ell-3}\cost(Z(w_i))+3\cost(T)-\cost(\W{})\\
={}&\sum_{i=3}^{\ell}\cost(A(w_i))+\sum_{i=1}^{\ell-3}\cost(Z(w_i))+3\cost(T)\\={}&3\cost(T)+{}\\
&+\sum_{i=3}^{\ell}\cost(A^*(w_{2p(i){}-1}, w_{2p(i){}}))+\sum_{i=1}^{\ell-3}\cost(Z^*(w_{2q(i){}-1}, w_{2q(i){}}))+{}\tag{S1}\label{s2}\\
&+\sum_{i=3}^{\ell}\cost(A'(w_i))+\sum_{i=1}^{\ell-3}\cost(Z'(w_i)).\tag{S2}\label{s1}
\end{align*}
Observe that, for a fixed~$i$, one has $p(i)=p(j)$ only for~$j\leq i+2$ and $q(i)=q(j)$ only for~$j\geq i-2$.
Moreover, by \cref{lem:assignment} and \cref{def:auxpaths},
if $p(i)\neq p(j)$, then $A^*(w_{2p(i)-1}, w_{2p(i)})$ and $A^*(w_{2p(j)-1}, w_{2p(j)})$ are subwalks of distinct walks of~$\W^*$. Similarly, $Z^*(w_{2q(i)-1}, w_{2q(i)})$ and $Z^*(w_{2q(j)-1}, w_{2q(j)})$ are subwalks of distinct walks of~$\W^*$ if~$q(i)\neq q(j)$. Hence, sum~\eqref{s2} counts each arc of~$\W^*$ at most three times and is therefore bounded from above by~$3\cost(\W^*)$.
Now, for a walk~$w_i$, let $\mathcal{A}_i$~be the set of walks~$w_j$
such that any arc $a$ of~$w_i$~is contained in~$A'(w_j)$ and let
$\mathcal{Z}_i$~be the set of walks such that any arc~$a$ of~$w_i$~is
contained in~$Z'(w_j)$. Observe that~$A'(w_j)$ and~$Z'(w_j)$
cannot completely contain two walks of the same pair of the consecutive
pairing~$\W^2{}$ of~$\W$ since, by \cref{lem:assignment}, each pair
has a pivot{} arc and~$A'(w_j)$ and~$Z'(w_j)$ both stop after
traversing a pivot{} arc. Hence, the walks
in~$\mathcal{A}_i\cup \mathcal{Z}_i$ can be from at most three pairs
of~$\W^2{}$: the pair containing~$w_i$ and the two neighboring
pairs. Finally, observe that~$w_i$ itself is not contained
in~$\mathcal{A}_i\cup \mathcal{Z}_i$. Thus,
$\mathcal{A}_i\cup \mathcal{Z}_i$ contains at most five walks
(\cref{fig:auxpaths2} shows a worst-case example). Therefore, sum~\eqref{s1}
counts every arc of~$\W{}$ at most five times and is bounded
from above by~$5\cost(\W{})$.
Thus, \cref{alg:carp} returns a solution of cost $3\cost(T)+5\cost(\W{})+3\cost(\W^*)$ which, by \cref{lem:shortsplitting}, is at most
$8\cost(T)+3\cost(\W^*)\leq 8\beta(\comps+1)\cost(\W^*)+3\cost(\W^*)\leq (8\beta(\comps+1)+3)\cost(\W^*)$.
\end{proof}
\section{Experiments}
\label{sec:experiments}
Our approximation algorithm for MWCARP is one of many
``route first, cluster second''-approaches,
which was first applied to CARP by \citet{Ulu85}
and led to constant-factor approximations for
the undirected CARP \citep{Woe08,Jan93}.
Notably,
\citet{BBLP06} implemented \citeauthor{Ulu85}'s heuristic \citep{Ulu85}
for the mixed CARP
by computing the base tour using path scanning heuristics.
Our experimental evaluation will show that
\citeauthor{Ulu85}'s heuristic can be substantially improved
by computing the base tour
using our \cref{ourthm}\eqref{ourthm2}.
For the evaluation,
we use the \texttt{mval} and \texttt{lpr} benchmark sets
of \citet{BBLP06}
for the mixed (but non-windy) CARP
and the \texttt{egl-large} benchmark set
of \citet{BE08} for the (undirected) CARP.
We chose these benchmark sets because relatively good lower bounds
to compare with are known \citep{GMP10,BI15}.
Moreover,
the \texttt{egl-large} set is of particular interest
since it contains large instances derived from real road networks
and the \texttt{mval} and \texttt{lpr} sets
are of particular interest
since \citet{BBLP06} used them to evaluate
their variant of \citeauthor{Ulu85}'s heuristic \citep{Ulu85},
which is very similar to our algorithm.
In the following, \cref{sec:impl} describes some
heuristic enhancements of our algorithm,
\cref{sec:expres} interprets our experimental results,
and \cref{sec:ob} describes an approach to transform
instances of existing benchmark sets
into instances whose positive-demand arcs induce a moderate number
of connected components.
\subsection{Implementation details}
\label{sec:impl}
Since our main goal is evaluating the solution quality
rather than the running time of our algorithm,
we sacrificed speed for simplicity
and implemented it in Python.\footnote{Source code
available at \url{http://gitlab.com/rvb/mwcarp-approx}}
Thus, the running time of our implementation is not competitive
to the implementations by \citet{BBLP06} and \citet{BE08}.%
\footnote{We do not provide running time measurements
since we processed many instances in parallel,
which does not yield reliable measurements.}
However, it is clear that a careful implementation
of our algorithm in C++
will yield competitive running times:
The most expensive steps of our algorithm
are the Floyd-Warshall all-pair shortest path algorithm \citep{Flo62},
which is also used by \citet{BBLP06} and \citet{BE08},
and the computation of an uncapacitated minimum-cost flow,
algorithms for which are contained
in highly optimized C++ libraries
like LEMON.\footnote{\url{http://lemon.cs.elte.hu/}}
In the following, we describe heuristic improvements
over the algorithms presented in \cref{sec:rpp,sec:carp},
which were described there so as
to conveniently prove upper bounds
rather than focusing on good solutions.
\subsubsection{Joining connected components}
\label{sec:connectbf}
We observed that,
in all but one instance of the \texttt{egl-large}, \texttt{lpr},
and \texttt{mval} benchmark sets,
the set of positive-demand arcs induce only one connected component.
Therefore, connecting them is usually not necessary and
the call to \cref{alg:eulerian-rp} in \cref{alg:drpp}
can be skipped completely.
If not, then, contrary to the description of \cref{alg:eulerian-rp},
we do \emph{not} arbitrarily select one vertex
from each connected component and join them using an approximate
$\triangle$-ATSP{} tour as in \cref{alg:eulerian-rp} or using an optimal
$\triangle$-ATSP{} tour as for \cref{cor:fpt-apx}.
Instead, using brute force,
we try all possibilities of choosing one vertex
from each connected component and connecting them using a cycle
and choose the cheapest variant.
If the positive-demand arcs induce \(C\)~connected components,
then this takes \(O(n^C\cdot C!+n^3)\)~time in an \(n\)-vertex graph.
That is, for \(C\leq 3\), implementing \cref{alg:eulerian-rp}
in this way does not increase its asymptotic time complexity.
\subsubsection{Choosing service direction}
\label{sec:serdir}
The instances in the \texttt{egl-large}, \texttt{lpr}, and \texttt{mval}
benchmark sets are not windy.
Thus, as pointed out in \cref{rem:orientation},
when computing the MWRPP base tour,
we are free to choose whether to replace
a required undirected edge~\(\{u,v\}\)
by a required arc~\((u,v)\) or
a required arc~\((v,u)\)
(and adding the opposite non-required arc)
without increasing the approximation factor
in \cref{ourthm}\eqref{ourthm2}.
We thus implemented several heuristics for choosing what we call
the \emph{service direction} of the undirected edge~\(\{u,v\}\).
Some of these heuristics choose the service direction independently
for each undirected edge, similarly to \citet{CMR00},
others choose it for whole undirected paths and cycles,
similarly to \citet{MA05}.
We now describe these heuristics in detail. To this end,
let \(G\)~denote our input graph and
\(R\)~be the set of required arcs.
\begin{itemize}[EO(R)]
\item[EO(R)] assigns one of the two possible service directions
to each undirected edge uniformly at random.
\item[EO(P)] replaces each undirected edge~\(\{u,v\}\in R\)
by an arc~\((u,v)\in R\) if \(\balance_{G[R]}(v)<\balance_{G[R]}(u)\),
by an arc~\((v,u)\in R\) if \(\balance_{G[R]}(v)>\balance_{G[R]}(u)\),
and chooses a random service direction otherwise.
\item[EO(S)] randomly chooses one endpoint~\(v\)
of each undirected edge~\(\{u,v\}\in R\) and replaces
it by an arc~\((u,v)\in R\) if \(\balance_{G[R]}(v)<0\)
and by~\((v,u)\in R\) otherwise.
\end{itemize}
Herein, ``EO'' is for ``edge orientation''.
The ``R'' in parentheses is for ``random'',
the ``P'' for ``pair''
(since it levels the balances of pairs of vertices),
and the ``S'' is for ``single''
(since it minimizes~\(|\balance(v)|\) of a single
random endpoint~\(v\) of the edge).
In addition, we experiment with three heuristics
that do not orient independent edges but long undirected paths.
Herein, the aim is that a vehicle will be able to
serve all arcs resulting from such a path
in one run.
First, the heuristics repeatedly search for undirected cycles in~\(G[R]\)
and replace them by directed cycles in~\(R\).
When no undirected cycle is left, then
the undirected edges of~\(G[R]\)~form a forest.
The heuristics then repeatedly search for a
longest undirected path in~\(G[R]\)
and choose its service direction as follows.
\begin{itemize}[PO(R)]
\item[PO(R)] assigns the service direction randomly.
\item[PO(P)] assigns the service direction by leveling the balance
of the endpoints of the path, analogously to EO(P).
\item[PO(S)] assigns the service direction so as to minimize
\(|\balance(v)|\) for a random endpoint~\(v\) of the path,
analogously to EO(S).
\end{itemize}
\noindent
Generally, we observed that these heuristics
first find three or four long paths
with lengths from~5 up to~15.
Then, the length of the found paths quickly decreases:
In most instances,
at least half of all found paths have length one,
at least 3/4 of all found paths have length at most two.
We now present experimental results for each of these six heuristics.
\subsubsection{Tour splitting}
\label{sec:optsplit}
As pointed out in \cref{rem:split},
the MWRPP base tour initially computed in \cref{alg:carp}
can be split into pairwise non-overlapping subsequences
so as to minimize the total cost of the resulting vehicle tours.
To this end, we apply an approach of
\citet{Bea83} and \citet{Ulu85},
which by now can be considered folklore \citep{BBLP06,Woe08,Jan93} and works as follows.
Denote the positive-demand arcs on the MWRPP base tour
as a sequence~\(a_1,\dots,a_\ell\).
To compute the optimal splitting,
we create an auxiliary graph with the vertices~\(1,\dots,\ell+1\).
Between each pair~\((i,j)\) of vertices,
there is an edge whose weight is the cost for serving
all arcs~\(a_i,a_{i+1},\dots,a_{j-1}\) in this order
using one vehicle.
That is, its cost is~\(\infty\) if the demands of the arcs
in this segment exceed the vehicle capacity~\(Q\) and
otherwise it is the cost
for going from the depot~\(v_0\) to the tail of~\(a_i\),
serving arcs~\(a_i\) to~\(a_{j-1}\),
and returning from the head of~\(a_{j-1}\) to the depot~\(v\).
Then, a shortest path from vertex~\(1\) to~\(\ell+1\)
in this auxiliary graph
gives an optimal splitting of the MWRPP base tour
into mutually non-overlapping subsequences.
Additionally, we implemented a trick of \citet{BBLP06}
that takes into account that a vehicle may serve
a segment~\(a_i,\dots,a_k,a_{k+1}\dots,a_{j-1}\)
by going to the tail of~\(a_{k+1}\),
serving arcs~\(a_{k+1}\) to~\(a_{j-1}\),
going from the head of~\(a_{j-1}\) to the tail of~\(a_i\),
serving arcs~\(a_i\) to~\(a_k\),
and finally returning from the head of~\(a_k\) to the depot~\(v_0\).
Our implementation tries all such~\(k\)
and assigns the cheapest resulting cost
to the edge between the pair~\((i,j)\) of vertices
in the auxiliary graph.
Of course one could compute the optimal order
for serving the arcs of a segment~\(a_i,\dots,a_{j-1}\)
from the depot~\(v_0\),
but this would again be the NP-hard DRPP.
\subsection{Experimental results}
\label{sec:expres}
Our experimental results
for the \texttt{lpr}, \texttt{mval}, and \texttt{egl-large} instances
are presented in \cref{tab:lpr,tab:egl}.
We grouped the results for the \texttt{lpr} and \texttt{mval} instances
into one table and subsection
since our conclusions about them are very similar.
We explain and interpret the tables in the following.
\begin{table*}[p]
\caption{Known results \citep{BBLP06,GMP10} and our results
for the \texttt{lpr} and \texttt{mval} instances.
See \cref{sec:lpr-mval} for a description of the table. The best polynomial-time computed upper bound
is written in boldface, the second best is underlined,
names of instances solved optimally by our algorithms
are also written in boldface.}
\label{tab:lpr}
\centering
\begin{tabular}{l|rr|rrr|rrrrrr}
\toprule
& \multicolumn{5}{c|}{Known results} & \multicolumn{6}{c}{Our results} \\
Instance & LB & UB & PSRC & IM & IURL & EO(R) & EO(P) & EO(S) & PO(R) & PO(P) & PO(S) \\
\midrule
\bestsol{lpr-a-01} & 13\,484 & 13\,484 & 13\,600 & 13\,597 & \secsol{13\,537} & \bestsol{13\,484} & \bestsol{13\,484} & \bestsol{13\,484} & \bestsol{13\,484} & \bestsol{13\,484} & \bestsol{13\,484} \\
lpr-a-02 & 28\,052 & 28\,052 & 29\,094 & 28\,377 & 28\,586 & \bestsol{28\,225} & 28\,381 & 28\,356 & \secsol{28\,239} & 28\,381 & 28\,356 \\
lpr-a-03 & 76\,115 & 76\,155 & 79\,083 & 77\,331 & 78\,151 & 77\,019 & \bestsol{76\,783} & 76\,964 & 76\,951 & \bestsol{76\,783} & \secsol{76\,820} \\
lpr-a-04 & 126\,946 & 127\,352 & 133\,055 & \bestsol{128\,566} & 131\,884 & 130\,470 & \secsol{130\,137} & 130\,255 & 130\,198 & 130\,171 & 130\,186 \\
lpr-a-05 & 202\,736 & 205\,499 & 215\,153 & \bestsol{207\,597} & 212\,167 & 210\,328 & \secsol{209\,980} & 210\,265 & 210\,235 & 210\,139 & 210\,344 \\
\bestsol{lpr-b-01} & 14\,835 & 14\,835 & 15\,047 & 14\,918 & \secsol{14\,868} & 14\,869 & 14\,869 & \bestsol{14\,835} & \bestsol{14\,835} & \bestsol{14\,835} & \bestsol{14\,835} \\
lpr-b-02 & 28\,654 & 28\,654 & 29\,522 & 29\,285 & 28\,947 & 28\,749 & \bestsol{28\,689} & \bestsol{28\,689} & 28\,757 & 28\,790 & \secsol{28\,727} \\
lpr-b-03 & 77\,859 & 77\,878 & 80\,017 & 80\,591 & 79\,910 & \bestsol{78\,428} & 78\,745 & 78\,853 & \secsol{78\,645} & 78\,810 & 78\,743 \\
lpr-b-04 & 126\,932 & 127\,454 & 133\,954 & \bestsol{129\,449} & 132\,241 & \secsol{130\,024} & \secsol{130\,024} & \secsol{130\,024} & 130\,076 & \secsol{130\,024} & \secsol{130\,024} \\
lpr-b-05 & 209\,791 & 211\,771 & 223\,473 & \bestsol{215\,883} & 219\,702 & 217\,024 & 216\,769 & \secsol{216\,459} & 217\,079 & 216\,639 & 216\,659 \\
lpr-c-01 & 18\,639 & 18\,639 & 18\,897 & 18\,744 & \secsol{18\,706} & 18\,943 & \bestsol{18\,695} & 18\,732 & 18\,708 & 18\,752 & 18\,752 \\
lpr-c-02 & 36\,339 & 36\,339 & 36\,929 & \bestsol{36\,485} & 36\,763 & 37\,177 & \secsol{36\,649} & 36\,856 & 36\,723 & 36\,711 & 36\,662 \\
lpr-c-03 & 111\,117 & 111\,632 & 115\,763 & \bestsol{112\,462} & 114\,539 & 115\,399 & 114\,438 & 114\,888 & 114\,336 & 114\,335 & \secsol{114\,290} \\
lpr-c-04 & 168\,441 & 169\,254 & 174\,416 & \bestsol{171\,823} & 173\,161 & 174\,088 & \secsol{172\,089} & 172\,902 & 172\,637 & 172\,172 & 172\,365 \\
lpr-c-05 & 257\,890 & 259\,937 & 268\,368 & \bestsol{262\,089} & 266\,058 & 266\,637 & \secsol{263\,989} & 264\,947 & 264\,911 & 264\,263 & 264\,665 \\
\midrule
Instance & LB & UB & PSRC & IM & IURL & EO(R) & EO(P) & EO(S) & PO(R) & PO(P) & PO(S) \\
\midrule
\bestsol{mval1A} & 230 & 230 & 243 & 243 & \secsol{231} & 245 & \bestsol{230} & 238 & 234 & 239 & 234 \\
mval1B & 261 & 261 & 314 & \bestsol{276} & 292 & 298 & \secsol{285} & \secsol{285} & 307 & 307 & 307 \\
mval1C & 309 & 315 & 427 & \bestsol{352} & \secsol{357} & 367 & 362 & 362 & 367 & 372 & 370 \\
\bestsol{mval2A} & 324 & 324 & 409 & 360 & 374 & 397 & \secsol{353} & \bestsol{324} & 369 & 369 & 368 \\
mval2B & 395 & 395 & 471 & \bestsol{407} & 434 & 431 & \secsol{424} & \secsol{424} & \secsol{424} & \secsol{424} & \secsol{424} \\
mval2C & 521 & 526 & 644 & \bestsol{560} & 601 & 621 & 622 & 592 & \secsol{600} & 624 & 594 \\
mval3A & 115 & 115 & 133 & \bestsol{119} & 128 & 131 & 129 & 125 & 122 & \secsol{121} & \secsol{121} \\
mval3B & 142 & 142 & 162 & 163 & 150 & 151 & \secsol{148} & 151 & 149 & \bestsol{147} & \bestsol{147} \\
mval3C & 166 & 166 & 191 & \bestsol{174} & 192 & 194 & 190 & \secsol{189} & 194 & 200 & 200 \\
mval4A & 580 & 580 & 699 & 653 & 684 & 648 & \bestsol{622} & \secsol{645} & 651 & 647 & 647 \\
mval4B & 650 & 650 & 775 & 693 & 737 & 709 & 687 & 709 & 690 & \bestsol{674} & \secsol{682} \\
mval4C & 630 & 630 & 828 & \bestsol{702} & 740 & 750 & 721 & 736 & \secsol{714} & 722 & 722 \\
mval4D & 746 & 770 & 1015 & \bestsol{810} & 905 & 875 & 871 & \secsol{852} & 872 & 879 & 870 \\
mval5A & 597 & 597 & 733 & 686 & 683 & 672 & \secsol{619} & 652 & \bestsol{614} & 649 & 644 \\
mval5B & 613 & 613 & 718 & 677 & 677 & 687 & 662 & 685 & \bestsol{653} & \bestsol{653} & \secsol{654} \\
mval5C & 697 & 697 & 809 & \bestsol{743} & 811 & 788 & \secsol{773} & 778 & 783 & 804 & 783 \\
mval5D & 719 & 739 & 883 & \bestsol{821} & 855 & 859 & 840 & 854 & 845 & 840 & \secsol{836} \\
mval6A & 326 & 326 & 392 & 370 & 367 & 348 & \secsol{347} & 348 & \bestsol{344} & 351 & 350 \\
mval6B & 317 & 317 & 406 & 346 & 354 & 345 & \bestsol{331} & 354 & 351 & \secsol{343} & 347 \\
mval6C & 365 & 371 & 526 & \bestsol{402} & 444 & 455 & \secsol{435} & \secsol{435} & 461 & 454 & 454 \\
mval7A & 364 & 364 & 439 & \bestsol{381} & 390 & 428 & \secsol{386} & 411 & 404 & 398 & 398 \\
mval7B & 412 & 412 & 507 & 470 & 491 & 474 & \bestsol{435} & 463 & 460 & 460 & \secsol{454} \\
mval7C & 424 & 426 & 578 & \bestsol{451} & 504 & 507 & 474 & 483 & 489 & \secsol{482} & \secsol{482} \\
mval8A & 581 & 581 & 666 & 639 & 651 & 648 & \secsol{635} & \secsol{635} & 639 & \bestsol{627} & 641 \\
mval8B & 531 & 531 & 619 & \bestsol{568} & 611 & 616 & \secsol{582} & 592 & 596 & 598 & 600 \\
mval8C & 617 & 638 & 842 & \bestsol{718} & 762 & 799 & 737 & \secsol{729} & 776 & 764 & 779 \\
mval9A & 458 & 458 & 529 & 500 & 514 & 503 & \bestsol{486} & 493 & 496 & \secsol{490} & 498 \\
mval9B & 453 & 453 & 552 & 534 & \bestsol{502} & 518 & 504 & \secsol{503} & \secsol{503} & 523 & 506 \\
mval9C & 428 & 429 & 529 & 479 & 498 & 509 & \bestsol{468} & 488 & 485 & 479 & \secsol{474} \\
mval9D & 514 & 520 & 695 & \bestsol{575} & 622 & 627 & \secsol{603} & 610 & 612 & 613 & 608 \\
mval10A & 634 & 634 & 735 & 710 & 705 & 669 & 663 & 661 & 667 & \bestsol{658} & \secsol{659} \\
mval10B & 661 & 661 & 753 & 717 & 714 & 708 & \bestsol{687} & \secsol{693} & 703 & 703 & 698 \\
mval10C & 623 & 623 & 751 & \bestsol{680} & 714 & 709 & 689 & 697 & 698 & 695 & \secsol{687} \\
mval10D & 643 & 649 & 847 & \bestsol{706} & 760 & 778 & 739 & 763 & 775 & 743 & \secsol{722} \\
\bottomrule
\end{tabular}
\end{table*}
\begin{table*}
\centering
\caption{Known results \citep{BE08,BI15} and our results
for the \texttt{egl-large} instances.
See \cref{sec:egl} for a description of the table. The best polynomial-time computed upper bound
is written in boldface.}
\begin{tabular}{l|rrr|rrrrrr}
\toprule
& \multicolumn{3}{c|}{Known results} & \multicolumn{6}{c}{Our results} \\
Instance & LB & UB & PS & EO(R) & EO(P) & EO(S) & PO(R) & PO(P) & PO(S) \\
\midrule
egl-g1-A & 976\,907 & 1\,049\,708 & 1\,318\,092 & 1\,258\,206&1\,181\,928&1\,209\,108&1\,153\,029&1\,158\,233&\bestsol{1\,141\,457}\\
egl-g1-B & 1\,093\,884 & 1\,140\,692 & 1\,483\,179 & 1\,367\,979&1\,306\,521&1\,328\,250&1\,293\,095&1\,308\,350&\bestsol{1\,297\,606}\\
egl-g1-C & 1\,212\,151 & 1\,282\,270 & 1\,584\,177 & 1\,523\,183&1\,456\,305&1\,463\,009&1\,432\,281&\bestsol{1\,424\,722}&1\,430\,841\\
egl-g1-D & 1\,341\,918 & 1\,420\,126 & 1\,744\,159 & 1\,684\,343&1\,609\,822&1\,609\,537&1\,586\,294&1\,601\,588&\bestsol{1\,580\,634}\\
egl-g1-E & 1\,482\,176 & 1\,583\,133 & 1\,841\,023 & 1\,829\,244&1\,769\,977&1\,780\,089&1\,716\,612&\bestsol{1\,748\,308}&1\,755\,700\\
egl-g2-A & 1\,069\,536 & 1\,129\,229 & 1\,416\,720 & 1\,372\,177&1\,276\,871&1\,304\,618&1\,263\,263&\bestsol{1\,249\,293}&1\,255\,120\\
egl-g2-B & 1\,185\,221 & 1\,255\,907 & 1\,559\,464 & 1\,517\,245&1\,410\,385&1\,449\,553&1\,398\,162&1\,405\,916&\bestsol{1\,404\,533}\\
egl-g2-C & 1\,311\,339 & 1\,418\,145 & 1\,704\,234 & 1\,661\,596&1\,594\,147&1\,597\,266&1\,538\,036&\bestsol{1\,532\,913}&1\,544\,214\\
egl-g2-D & 1\,446\,680 & 1\,516\,103 & 1\,918\,757 & 1\,812\,309&1\,728\,840&1\,741\,351&1\,695\,333&\bestsol{1\,694\,448}&1\,704\,080\\
egl-g2-E & 1\,581\,459 & 1\,701\,681 & 1\,998\,355 & 1\,962\,802&1\,883\,953&1\,908\,339&\bestsol{1\,851\,436}&1\,861\,134&1\,861\,469\\
\bottomrule
\end{tabular}
\label{tab:egl}
\end{table*}
\subsubsection{Results for the lpr and mval instances}
\label{sec:lpr-mval}
\cref{tab:lpr} presents known results and our results
for the \texttt{lpr} and \texttt{mval} instances.
Each column for our results was obtained by running
our algorithm with
the corresponding service direction heuristic described in \cref{sec:serdir}
on each instance 20~times and reporting the best result.
The number 20 has been chosen so that our results are comparable with
those of \citet{BBLP06}, who
used the same number of runs
for their path scanning heuristic (column PSRC)
and their ``route first, cluster second'' heuristic (column IURL),
which computes the base tour using a path scanning heuristic
and then splits it using all tricks described in \cref{sec:optsplit}.
Columns LB and UB report the best
lower and upper bounds computed by \citet{BBLP06} and \citet{GMP10}
(usually not using polynomial-time algorithms).
Finally, column IM shows the result that \citet{BBLP06} obtained
using an improved variant of the ``augment and merge'' heuristic
due to \citet{GW81}.
\cref{tab:lpr} shows
that our algorithm with the EO(S) service direction heuristic
solved three instances optimally,
which other polynomial-time heuristics did not.
The EO(P) heuristic solved one instance optimally,
which also other polynomial-time heuristics did not.
Moreover, whenever no variant of our algorithm finds the best result,
then some variant yields the second best.
It is outperformed only by IM in 26 out of 49 instances
and by IURL in only one instance.
Apparently, our algorithm outperforms PSRC and IURL.
Notably, IURL differs from our algorithm only
in computing the base tour heuristically
instead of using our \cref{ourthm}\eqref{ourthm2}.
Thus, ``route first, cluster second'' heuristics
seem to benefit from computing the base tour
using our MWRPP approximation algorithm.
Remarkably,
when our algorithm yields the best result
using one of
the service direction heuristics described in \cref{sec:serdir},
then usually other service direction heuristics also find
the best or at least the second best solution.
Thus, the choice of the service direction heuristic
does not play a strong role.
Indeed, we also experimented with repeating our algorithm
20~times on each instance,
each time choosing the service direction heuristic randomly.
The results come close to choosing the best heuristic for each instance.
\subsubsection{Results for the egl-large instances}
\label{sec:egl}
\cref{tab:egl} reports known results and our results
for the \texttt{egl-large} benchmark set.
Again, each column for our results was obtained
by running our algorithm with the corresponding
service direction heuristic
described in \cref{sec:serdir} on each instance 20~times.
The column LB reports lower bounds by \citet{BI15},
the column UB shows the upper bound that \citet{BE08}
obtained using their tabu-search algorithm
(which generally does not run in polynomial time).
The column PS shows the cost of the initial solution that \citet{BE08}
computed for their tabu-search algorithm
using a path scanning heuristic.
\citet{BE08} implemented several polynomial-time heuristics
for computing these initial solution.
Among them, ``route first, cluster second'' approaches
and ``augment and merge'' heuristics.
In their work, path scanning yielded the best initial solutions.
In \cref{tab:egl}, we see that
our algorithm clearly outperforms it.
Moreover, we see that especially our PO service direction heuristics
are successful.
This is because the \texttt{egl-large} instances
are undirected and, thus,
contain many cycles consisting of undirected positive-demand
arcs that can be directed by our PO heuristics
without increasing the imbalance of vertices.
\begin{figure*}[tb]
\begin{subfigure}[b]{0.4\textwidth}
\includegraphics[width=\textwidth]{{ob-egl-g2-E.dot}.pdf}
\caption{ob-egl-g2-E}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.2\textwidth}
\includegraphics[width=\textwidth]{{ob-Lpr-b-03.dot}.pdf}
\caption{ob-lpr-b-03}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth]{{ob2-Lpr-b-05.txt}.pdf}
\caption{ob2-lpr-b-05}
\end{subfigure}
\caption{Three instances from the \texttt{Ob} benchmark set.}
\label{fig:obinst}
\end{figure*}
\subsection{The Ob benchmark set}
\label{sec:ob}
Given our theoretical work in \cref{sec:rpp,sec:carp},
the solution quality achievable in polynomial time
appears to mainly depend on the number~\(C\) on connected components
in the graph induced by the positive-demand arcs.
However, we noticed that widely used benchmark instances for
variants of CARP have~\(C=1\).
In order to motivate a more representative evaluation
of the quality
of polynomial-time heuristics for variants of CARP,
we provide the \texttt{Ob} set of instances derived from the
\texttt{lpr} and \texttt{egl-large} instances with
\(C\)~from 2 to 5. The approach can be easily used to create more
components.
The \texttt{Ob} instances%
\footnote{Available at \url{http://gitlab.com/rvb/mwcarp-ob}
and named after the river Ob,
which bisects the city Novosibirsk.}
simulate cities that are divided by a river
that can be crossed via a few bridges without demand.
The underlying assumption is that, for example,
household waste does not have to be collected from bridges.
We generated the instances as follows.
As a base, we took sufficiently large instances from the \texttt{lpr} and \texttt{egl-large} sets
(it made little sense to split
the small \texttt{mval} or \texttt{lpr} instances
into several components).
In each instance,
we chose one or two random edges or arcs as ``bridges''.
Let \(B\)~be the set of their end points.
We then grouped all vertices of the graph into clusters:
For each \(v\in B\), there is one cluster containing all vertices
that are closer to~\(v\) than to all other vertices of~\(B\).
Finally,
we deleted all but a few edges between the clusters,
so that usually two or three edges
remain between each pair of clusters.
The demand of the edges remaining between clusters is set to zero,
they are our ``bridges'' between the river banks.
The intuition is that, if one of our initially chosen edges or arcs~\((u,v)\) was a bridge
across a relatively straight river,
then indeed every point on \(u\)'s side of the river would be closer
to~\(u\) than to~\(v\).
We discarded and regenerated instances
that were not strongly connected or had
river sides of highly imbalanced size
(three times below the average component size).
\cref{fig:obinst} shows three of the resulting instances.
Note that this approach can yield instances
where \(C\)~exceeds the number of clusters
since deleting edges between the clusters may create
more connected components in the graph
induced by the positive-demand arcs.
The approach straightforwardly applies to generating instances
with even larger~\(C\):
One simply chooses more initial ``bridges''.
As a starting point,
\cref{tab:obres} shows the number~\(C\),
a lower bound (LB) computed using an ILP relaxation of \citet{GMP10},
and the best upper bound obtained using our approximation algorithm
for each of the \texttt{Ob} instances
using any of the service direction heuristics in \cref{sec:serdir}.
The ``ob-'' instances were generated by choosing one initial bridge,
the ``ob2-'' instances were generated by choosing two initial bridges.
\begin{table*}[tb]
\centering
\caption{First upper and lower bounds for the \texttt{Ob} instances described in \cref{sec:ob}.}
\label{tab:obres}
\begin{tabular}{l|rrr||l|rrr}
\toprule
Instance & $C$ & LB & UB & Instance & $C$ & LB & UB \\
\midrule
ob-egl-g1-A & 2 & 817\,223 & 1\,152\,093 & ob2-egl-g1-A & 4 & 736\,899 & 1\,073\,386\\
ob-egl-g1-B & 2 & 1\,180\,105 & 1\,627\,305 & ob2-egl-g1-B & 5 & 840\,773 & 1\,221\,424\\
ob-egl-g1-C & 2 & 1\,018\,890 & 1\,405\,024 & ob2-egl-g1-C & 5 & 992\,974 & 1\,405\,836\\
ob-egl-g1-D & 3 & 1\,354\,671 & 1\,810\,306 & ob2-egl-g1-D & 4 & 1\,056\,593& 1\,491\,387\\
ob-egl-g1-E & 3 & 1\,486\,033 & 1\,955\,945 & ob2-egl-g1-E & 4 & 1\,175\,241& 1\,609\,377\\
ob-egl-g2-A & 2 & 922\,853 & 1\,286\,986 & ob2-egl-g2-A & 4 & 854\,823 & 1\,202\,379\\
ob-egl-g2-B & 2 & 1\,015\,013 & 1\,388\,809 & ob2-egl-g2-B & 4 & 906\,415 & 1\,259\,017\\
ob-egl-g2-C & 2 & 1\,308\,463 & 1\,701\,004 & ob2-egl-g2-C & 4 & 1\,154\,372& 1\,574\,762\\
ob-egl-g2-D & 2 & 1\,315\,717 & 1\,720\,548 & ob2-egl-g2-D & 4 & 1\,361\,397& 1\,782\,335\\
ob-egl-g2-E & 2 & 1\,677\,109 & 2\,139\,982 & ob2-egl-g2-E & 4 & 1\,295\,704& 1\,747\,883\\
\midrule
ob-lpr-a-03 & 3 & 71\,179 & 73\,055 & ob2-lpr-a-03 & 5 & 67\,219 & 69\,307 \\
ob-lpr-a-04 & 2 & 119\,759 & 123\,838 & ob2-lpr-a-04 & 4 & 115\,110 & 119\,550 \\
ob-lpr-a-05 & 2 & 195\,518 & 203\,832 & ob2-lpr-a-05 & 5 & 189\,968 & 197\,748 \\
ob-lpr-b-03 & 2 & 73\,670 & 75\,052 & ob2-lpr-b-03 & 5 & 67\,924 & 69\,518 \\
ob-lpr-b-04 & 2 & 122\,079 & 127\,020 & ob2-lpr-b-04 & 4 & 112\,104 & 116\,696 \\
ob-lpr-b-05 & 2 & 204\,389 & 213\,593 & ob2-lpr-b-05 & 5 & 191\,138 & 197\,878 \\
ob-lpr-c-03 & 2 & 105\,897 & 109\,913 & ob2-lpr-c-03 & 4 & 98\,244 & 102\,270 \\
ob-lpr-c-04 & 2 & 161\,856 & 167\,336 & ob2-lpr-c-04 & 4 & 155\,894 & 161\,615 \\
ob-lpr-c-05 & 2 & 250\,636 & 258\,396 & ob2-lpr-c-05 & 4 & 238\,299 & 246\,368 \\
\bottomrule
\end{tabular}
\end{table*}
\section{Conclusion}
\label{sec:conc}
Since our algorithm outperforms many other polynomial-time heuristics,
it is useful for computing good solutions in instances
that are still too large to be attacked
by exact, local search, or genetic algorithms. Moreover, it might be useful to use our solution as initial solution for local search algorithms.
Our theoretical results show that
one should not evaluate polynomial-time heuristics
only on instances whose positive-demand arcs induce
a graph with only one connected component,
because the solution quality achievable
in polynomial time is largely determined
by this number of connected components.
Therefore, it would be interesting to see
how other polynomial-time heuristics,
which do not take into account
the number of connected components in the graph
induced by the positive-demand arcs,
compare to our algorithm
in instances where this number is larger than one.
Finally, we conclude with a theoretical question:
It is easy to show a 3-approximation
for the Mixed Chinese Postman problem
using the approach in \cref{sec:mwrpp},
yet \citet{RV99} showed a $3/2$-ap\-prox\-i\-ma\-tion{}.
Can our
$(\alpha(\comps)+3)$-ap\-prox\-i\-ma\-tion{} for {MWRPP}{} in
\cref{ourthm}\eqref{ourthm2} be improved to an
$(\alpha(\comps)+3/2)$-ap\-prox\-i\-ma\-tion{} analogously?
\paragraph{Acknowledgments.}
This research was initiated during a research retreat
of the algorithms and complexity theory group of TU Berlin,
held in Rothenburg/Oberlausitz, Germany, in March~2015.
We thank Sepp Hartung, Iyad Kanj, and André Nichterlein
for fruitful discussions.
{
\setlength{\bibsep}{0pt}
\bibliographystyle{abbrvnat}
|
{'timestamp': '2016-10-18T02:06:00', 'yymm': '1506', 'arxiv_id': '1506.05620', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05620'}
|
arxiv
|
\section{Introduction}
Android is the most popular mobile OS, with nearly 80\% of the market share \cite{IDCReport}. This attracts malware attacks such as leakage of sensitive information and sending SMS to premium-rate numbers \cite{FSecureReport, APFeltSurvey}. These attacks can be implemented by well-crafted malicious apps, or advertisement libraries used by Android apps \cite{adLibraries}. To combat such attacks, researchers have developed static analysis, dynamic analysis, and permission-based techniques. Static analysis detects malicious behaviors by analyzing the app code without execution \cite{LeakMiner, FlowDroid, AppoScopy, myDroid, Chex}. The aim is to represent program logic in some models (such as control flow graphs) and analyze such models to detect possible attacks. Dynamic analyses typically force the program to execute a set of carefully selected paths and analyze the results to detect malware attacks \cite{TaintDroid, VetDroid, DroidScope, DroidPF}. In addition to these, Android provides a permission-based mechanism \cite{permissions}, which requires user approval to access resources such as deviceID and internet.
This paper focuses on static analysis. It is motivated by recent success of \cite{LeakMiner, FlowDroid, DroidSafe, AppoScopy, Chex, myDroid} in detecting Android malware. All of these techniques perform analysis based on the Android-supplied life cycle models, which can be represented by a set of state machines. The state machines model the state-dependent behaviors of Android components, that is, Activity, Service, BroadcastReceiver, and ContentProvider. A state represents the status of a component; a transition represents a callback invoked by Android. In particular, LeakMiner \cite {LeakMiner} and FlowDroid \cite{FlowDroid} derive a control flow graph (CFG) based on life cycle model. The nodes of the CFG represent callbacks in the life cycle model and the edges define the order that the callbacks can be invoked. Taint analysis is then performed on paths of the CFG to detect information leakage. Unlike LeakMiner and FlowDroid, DroidSafe \cite{DroidSafe} performs flow-insensitive taint analysis and analyzes all possible orderings of callbacks in the life cycle model to detect information-flows in Android apps.
An Android-supplied life cycle model provides a high-level abstraction of the Android component behavior. However, this abstraction is also a limitation because it does not capture all states and transitions implemented in Android. Furthermore, the life cycle model does not specify guard conditions that govern the invocation of a callback. Thus, an analysis method based on an Android-supplied life cycle model may not detect attacks that exploit such omissions (the motivating example presented in the next section illustrates this). To fill this gap, we perform reverse-engineering to reconstruct the life cycle models that capture the omitted states and transitions, as well as the guard conditions. We then propose the Dexteroid framework. This framework systematically derives event sequences from the reverse-engineered life cycle models, obtains callback sequences from the event sequences, and performs taint analysis on the callback sequences to detect malicious behaviors.
The contributions of this paper are summarized as follows. First, Dexteroid detects attacks that are missed by existing tools, due to the inclusion of omitted states and transitions in the life cycle models. Second, to the best of our knowledge, this research is the first that uses event sequences (derived from a life cycle model) to generate callback sequences for analysis. Although callback sequences are considered in previous studies, most of such sequences will not occur in real apps because they do not satisfy the guard conditions. As a consequence, this could lead to a high false positive rate. Third, our research is also the first to systematically generate and analyze permutations of event sequences. This is because certain attacks can only be detected by analyzing more than one event sequences in a given order. Finally, we have designed and implemented a prototype of Dexteroid and conducted extensive experiments. The results show that the proposed framework significantly improves both precision and recall.
The rest of the paper is organized as follows. Section 2 provides background on Android components, and a motivating example to show the limitation of an Android-supplied life cycle model of a component. Section 3 presents Dexteroid framework. Section 4 provides the implementation details of Dexteroid and Section 5 presents experimental evaluation. Section 6 describes the related work. The last section concludes the paper and discusses future work.
\section {Background and Motivating Example}
Android defines four basic components to develop Android applications: (1) \emph{Activity} implements the application logic as well as provides an interactive screen to the user; (2) \emph{Service} performs long-running operations and runs in the background; (3) \emph{BroadcastReceiver} responds to system-wide notifications; and (4) \emph{ContentProvider} manages structured data.
Each component has a life cycle. That is, it goes through a series of phases, possibly iterates some of the phases, during its life time. For example, an activity goes through three phases when it becomes visible, partially visible and completely hidden to the user. The transitions of a component from one phase to another are caused by the occurrences of events, which trigger the invocations of callback methods or callbacks in short. In the following sections, we define important concepts shown in italic font in the sentences that define them. These concepts will be used throughout the paper.
\subsection{Basic Definitions}
An \emph{event} is some happening of interest; it can be an external event, or an internal event. An \emph{external event} occurs when the app user submits a request, or performs an action, such as tapping a button on an activity's user interface. The device hardware captures such events and delivers them to the operating system. An \emph{internal event} is generated by the operating system when certain condition, such as low on memory, becomes true. Such events are captured by the operating system. Whenever an external or internal event occurs, the operating system calls functions of the components. These are \emph{callback functions} or \emph{callback methods}. More specifically, a \emph{callback method} is a method of a component that is invoked by the operating system in response to an internal or external event. Table \ref{tabEventsCallbacks} shows example user operations, the corresponding events, and callback sequences that are invoked by the OS in an activity.
\begin{table}[ht]
\caption{Sample User Operations, Triggered Events, and Invoked Callbacks in An Activity}
\centering
\scriptsize
\begin{tabular}{l l l}
\hline
Operation performed & Triggered event & Invoked callback sequences\\
\hline
(1) Tap on app icon to start an activity & createActivity & {\ttfamily onCreate()}, {\ttfamily onStart()}, {\ttfamily onResume()} \\
(2) After (1), press Back button on the device & backPress & {\ttfamily onPause()}, {\ttfamily onStop()}, {\ttfamily onDestroy()} \\
(3) After (1), press Home button on the device & overlapActivity & {\ttfamily onPause()}, {\ttfamily onStop()} \\
(4) After (3), start the app from launcher menu & restartActivity & {\ttfamily onRestart()}, {\ttfamily onStart()}, {\ttfamily onResume()} \\
\hline
\end{tabular}
\label{tabEventsCallbacks}
\end{table}
\subsection{Android-Supplied Activity Life Cycle Model}
The life cycle of a component can be modeled by a state machine. The phases of the component are represented by states, and transitions between phases are represented by state transitions. Figure \ref{coreLifeCycle} shows the Android-supplied activity life cycle model \cite{activityLifeCycle} which describes the state-dependent behavior of an Android activity. It contains eight states including one initial state (Android robot icon) and nine state transitions. Each state transition in the model is caused by the invocation of a callback by the operating system. These callbacks are called \emph{life cycle callbacks}. For example, when a user opens or starts a new activity, createActivity event is triggered as shown in first operation of Table \ref{tabEventsCallbacks}. The system invokes the callback sequence (e.g., {\ttfamily onCreate()}, {\ttfamily onStart()} and {\ttfamily onResume()}) in the activity and in response, the activity makes transitions to Created, Started and Resumed state, respectively. Activity waits for user interaction in the Resumed state. A user can trigger many events in this state which can make activity visit different states.
\begin{comment}
\begin{figure
\centering
\epsfig{file=coreLifeCycle.eps, width=12cm}
\caption{Android-Supplied Activity Life Cycle Model}
\label{coreLifeCycle}
\end{figure}
\end{comment}
\begin{figure}[ht!]
\centering
\includegraphics[width=12cm]{coreLifeCycle-eps-converted-to.pdf}
\caption{Android-Supplied Activity Life Cycle Model \cite{activityLifeCycle}}
\label{coreLifeCycle}
\end{figure}
Activity states are classified into static states and transient states \cite{activityLifeCycle}. A \emph{static state} requires an external event to cause the invocation of a callback method which in turn triggers a state transition. Thus, an activity can stay in a static state indefinitely, depending upon when the external event arrives. The state transition for a \emph{transient state} takes place automatically and immediately after its associated callback method is invoked. For example, when the activity visits Created state, it automatically moves to Started state (both are transient states) and then moves to Resumed state (a static state). Figure \ref{coreLifeCycle} shows both static states (with bold border lines) and transient states. According to this model, the user can interact with the activity only when it is visible to the user in Resumed state.
There are seven life cycle callbacks in activity life cycle model shown in Figure \ref{coreLifeCycle}. In addition to these callbacks, other types of methods which are defined in Android applications are activity user-interface (AUI) callbacks, miscellaneous callbacks and developer-defined methods. \emph{Activity user-interface callbacks} or \emph{AUI callbacks} are invoked by the operating system in response to external events on AUI elements. For example, a typical user interaction of clicking a button triggers an event which causes the system to invoke its registered callback (e.g., {\ttfamily onButtonClicked()}). Since only an activity can provide user-interface for an application, AUI callbacks are defined in the activity code. However, they can be registered with a layout xml file or dynamically within the activity code. \emph{Miscellaneous callbacks} can be invoked by internal or external events and are not part of life cycle model of a component. For example, a user tap on the screen causes the system to invoke {\ttfamily onUserInteraction()} callback. Similarly, the system can trigger a `lowMemory' event to invoke {\ttfamily onLowMemory()} callback in both activity and service components. A \emph{developer-defined method} is a method which is executed by the system only when there is an explicit call to such a method. Such methods can be invoked from callback methods or other developer-defined methods.
The life cycle models of BroadcastReceiver and ContentProvider components are straightforward: each contains one state and a callback method ({\ttfamily onReceive()} and {\ttfamily onCreate()}, respectively). Activity is prevalent in Android apps and handles all types of (above-defined) methods which makes its life cycle model more complex compared to other components. Thus, we first discuss activity component and then service component in detail in this paper.
\subsection {Motivating Example}
An attacker can launch a targeted attack using program flows overlooked by the analysis tools. The motivating example shows that an attack can be designed to launch by invoking a set of callbacks in a specific order. It further shows that Android-supplied activity life cycle model can be exploited to launch such attacks due to its omission of certain states and transitions. The example is a calculator app shown in Figure \ref{fig:calc}, in which a user can perform different operations, and then view their history in a dialog activity as shown in Figure \ref{fig:hist}. Listing \ref{listing1} shows the app code. To save space, non-essential code such as calls to super class functions and exception handling is omitted.
\begin{figure}[ht]
\centering
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=30mm, height=37mm]{newApp1-eps-converted-to.pdf}
\scriptsize
\caption{A user can perform many calculations here}
\label{fig:calc}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=30mm, height=37mm]{newApp2-eps-converted-to.pdf}
\caption{Calculations history is shown in a dialog activity}
\label{fig:hist}
\end{subfigure}
\caption{A Calculator Application}
\label{motivatingExample}
\end{figure}
Consider the following sequence of operations performed by the user: (1) User starts an activity for the first time. (2) The user performs a few calculations and taps History button. History dialog activity is displayed as shown in Figure \ref{fig:hist}. The user taps Back button on the device to get back to {\ttfamily MainActivity}. (3) The user presses Home button on the device and later opens the app again from launcher menu. (4) The user rotates the device from portrait view to landscape view for better view of the app layout.
Each of the above user operations triggers a sequence of one or more events which causes the system to invoke a sequence of callback methods in the activity. The respective callback sequences for these operations are: (1) {\ttfamily onCreate()} and {\ttfamily onResume()}. (2) {\ttfamily onBtnClicked()}, {\ttfamily onUserLeaveHint()}, {\ttfamily onSaveInstanceState()}. This callback sequence obtains deviceID (line 18 of Listing \ref{listing1}) and stores it in {\ttfamily d1} variable. Upon returning to the activity, {\ttfamily onResume()} is invoked by the operating system. (3) {\ttfamily onUserLeaveHint()}, {\ttfamily onSaveInstanceState()}, and {\ttfamily onResume()}. This callback sequence copies deviceID to {\ttfamily d2} variable (line 16) and then stores it into the {\ttfamily outState} bundle (line 21). (4) Upon rotation of the device, the activity is destroyed and recreated. Upon destroying, {\ttfamily onSaveInstanceState()} is invoked which stores the deviceID in the {\ttfamily outState} bundle again. Three callbacks ({\ttfamily onCreate()}, {\ttfamily onRestoreInstanceState()}, and {\ttfamily onResume()}) are invoked upon recreating the activity. This callback sequence obtains deviceID from the {\ttfamily state} object (line 9) and leaks it by sending a text message (line 13) to a number given in {\ttfamily recpNo} variable.
\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}
\lstset{language=Java, basicstyle=\scriptsize\ttfamily , numbers=left, stepnumber=1, numbersep=5pt, keywordstyle=\color{blue}, commentstyle=\color{mygreen},
frame=single, showspaces=false, numberstyle=\tiny\color{black}, rulecolor=\color{black}, stringstyle=\color{mymauve},
showstringspaces=false, showtabs=false, tabsize=2,
breaklines=true, breakatwhitespace=false, caption={Motivating Example} , label={listing1}}
\begin{comment}
\begin{minipage}{0.94\linewidth}
\lstinputlisting{MotiveActivity3.java}
\end{minipage}
\end{comment}
\noindent\begin{minipage}{14cm}
\begin{lstlisting}
public class MainActivity extends Activity {
String d1 = ""; String d2 = "";
String d3 = ""; String recpNo = "1066156686";
void onCreate(Bundle instance){
setContentView(R.layout.activity_main);
}
void onRestoreInstanceState(Bundle state){
this.d3 = state.getString("myData");
}
void onResume(){
if(!d3.equals(""))
SmsManager.getDefault().sendTextMessage(recpNo, null, d3, null, null);
}
void onUserLeaveHint(){
this.d2 = this.d1;
TelephonyManager tMgr = (TelephonyManager) getApplicationContext().getSystemService(TELEPHONY_SERVICE);
this.d1 = tMgr.getDeviceId();
}
void onSaveInstanceState(Bundle outState){
outState.putString("myData", this.d2);
}
void onBtnClicked(View v){
if(v.getId() == R.id.add){ ... }
... //calculator code here.
}
}
\end{lstlisting}
\end{minipage}
The above attack leaks sensitive information when a set of callbacks are invoked in a specific order. The {\ttfamily onUserLeaveHint()} callback is invoked twice by two different events to obtain and store the deviceID. While these two events can occur in any order, they must be followed by a device-rotation event to successfully launch the attack. These events can be triggered easily in real-world scenarios because pressing Back or Home button is commonly used to switch between the activities and the apps. However, their invoked callback sequences must be analyzed in the given order to detect this attack. Moreover, the example involves callbacks such as {\ttfamily onUserLeaveHint()} and {\ttfamily onSaveInstanceState()} to launch the attack. The system invokes these callbacks in response to different events upon activity. Android-supplied activity life cycle model omits these callbacks and their associated states, and hence, it will not be able to detect the above attack. Therefore, a better activity life cycle model is required.
\section{Dexteroid Framework}
This section presents the Dexteroid framework, as shown in Figure \ref{framework}. It uses reverse-engineered life cycle models that include states and transitions previously omitted in Android-supplied life cycle models. Dexteroid inputs an Android Application Package (APK) file and decompiles it using Androguard \cite{Androguard} to extract Dalvik bytecode and its manifest file. It identifies registered components from the manifest file and analyzes these components iteratively. For each component, the framework systematically derives event sequences from the reverse-engineered life cycle model and then derives callback sequences from these event sequences. These callback sequences are guaranteed to be feasible because they are derived from the event sequences which themselves are derived from the component life cycle model. Dexteroid then generates permutations of callback sequences and performs taint analysis on them to detect malicious behaviors. The following sections describe the reverse-engineering of these life cycle models, and derivation of callback sequences in detail.
\begin{comment}
\begin{figure}[ht!]
\centering
\epsfig{file=framework.eps, width=120mm}
\caption{Dexteroid Framework}
\label{framework}
\end{figure}
\end{comment}
\begin{figure}[ht!]
\centering
\includegraphics[width=120mm]{framework-eps-converted-to.pdf}
\caption{Dexteroid Framework}
\label{framework}
\end{figure}
\subsection {Reverse-Engineering of Activity Life Cycle Model} \label{activityLCM}
We follow \cite{Franke2011} to reverse-engineer the activity life cycle model. An Android app is developed in which each activity contains all life cycle callbacks, extracted from Android API documentation. We add {\ttfamily Log.v()} API call in all the callbacks of the activity. When a callback is invoked, the API call records that information. An extensive set of operations are performed upon an activity to trigger events which an activity can possibly receive during its execution. Table \ref{activityTable} shows a subset of user and system operations which we use to trigger events upon an activity. When an event is triggered, a set of life cycle callbacks are invoked in a specific order. For example, when a user opens an activity for the first time, createActivity event is triggered. This event causes the system to invoke a sequence of callbacks in the activity as shown in Table \ref{activityTable}. Using triggered events and the observed activity behavior, we reconstruct activity life cycle model as shown in Figure \ref{activitySM}. We use UML state diagram with composite sequential states (CSS) \cite{BoochUML} to present the proposed model and refer to it as the CSS model (of an Android activity). This model contains new states (e.g., PostCreated) as well as all the states (e.g., Created) shown in the Figure \ref{coreLifeCycle}.
\begin{ThreePartTable}
\begin{scriptsize}
\begin{longtable}{P{3.2cm} P{1.5cm} P{5.9cm}}
\caption[User or System Operations and Resultant Triggered Events and Callbacks]{User or System Operations and Resultant Triggered Events and Callbacks} \label{activityTable} \\
\hline \hline {\multirow{2}{*}{User or System Operation}} & Triggered Event$^{a}$ & {\multirow{2}{*}{Invoked Activity Life Cycle Callbacks}} \\ \hline \hline
\endfirsthead
\multicolumn{3}{c}%
{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\hline \hline {\multirow{2}{*}{User or System Operation}} &
Triggered Event$^{a}$ &
{\multirow{2}{*}{Invoked Activity Life Cycle Callbacks}} \\ \hline \hline
\endhead
\multicolumn{3}{|r|}{{Continued on next page}} \\ \hline
\endfoot
\hline \hline
\endlastfoot
1) Tap on app icon or start from another activity & createActivity${^\ast}$ & {\ttfamily onCreate()}, {\ttfamily onStart()}, {\ttfamily onPostCreate()}, {\ttfamily onResume()}, {\ttfamily onPostResume()}\\ \hline
(2) After (1), press Back button on the device & backPress & {\ttfamily onPause()}, {\ttfamily onStop()}, {\ttfamily onDestroy()}\\ \hline
(3) After (2), tap on app icon to start activity & createActivity${^\ast}$ & {\ttfamily onCreate()}, {\ttfamily onStart()}, {\ttfamily onPostCreate()}, {\ttfamily onResume()}, {\ttfamily onPostResume()}\\ \hline
(4) After (1), rotate the device (e.g., from vertical to horizontal) & confPR & {\ttfamily onPause()}, {\ttfamily onSaveInstanceState()}, {\ttfamily onStop()}, {\ttfamily onDestroy()}, {\ttfamily onCreate()}, {\ttfamily onStart()}, {\ttfamily onRestoreInstanceState()}, {\ttfamily onPostCreate()}, {\ttfamily onResume()}, {\ttfamily onPostResume()}\\ \hline
(5) After (1), alarm goes off & stopActivity${^\star}$ & {\ttfamily onPause()}, {\ttfamily onCreateDescription()}, {\ttfamily onSaveInstanceState()}, {\ttfamily onStop()}\\ \hline
(6) After (5), snooze or stop the alarm & restartActivity${^\dagger}$ & {\ttfamily onRestart()}, {\ttfamily onStart()}, {\ttfamily onResume()}, {\ttfamily onPostResume()}\\ \hline
(7) After (5), rotate device and snooze or stop the alarm & confPOS${^\ddagger}$ & {\ttfamily onDestroy()}, {\ttfamily onCreate()}, {\ttfamily onStart()}, {\ttfamily onRestoreInstanceState()}, {\ttfamily onPostCreate()}, {\ttfamily onResume()}, {\ttfamily onPostResume()}\\ \hline
(8) After (1), press Home button on phone & overlapActivity${^\circ}$ & {\ttfamily onUserLeaveHint()}, {\ttfamily onPause()}, {\ttfamily onCreateDescription()}, {\ttfamily onSaveInstanceState()}, {\ttfamily onStop()}\\ \hline
(9) After (8), start the app from launcher menu & restartActivity${^\dagger}$ & {\ttfamily onRestart()}, {\ttfamily onStart()}, {\ttfamily onResume()}, {\ttfamily onPostResume()}\\ \hline
(10) After (8), rotate device and start the app from launcher menu & confPOS${^\ddagger}$ & {\ttfamily onDestroy()}, {\ttfamily onCreate()}, {\ttfamily onStart()}, {\ttfamily onRestoreInstanceState()}, {\ttfamily onPostCreate()}, {\ttfamily onResume()}, {\ttfamily onPostResume()}\\ \hline
(11) After (8) or (5), the system kills the process to recover resources & killProcess${^\bullet}$ & {\ttfamily onDestroy()}\\ \hline
(12) After (1), tap on add to bookmark icon on the device (e.g., Nexus 5 phone) & overlapActivity${^\circ}$ & {\ttfamily onUserLeaveHint()}, {\ttfamily onPause()}, {\ttfamily onCreateDescription()}, {\ttfamily onSaveInstanceState()}, {\ttfamily onStop()}\\ \hline
(13) After (12), remove the app from bookmarks list & killProcess${^\bullet}$ & {\ttfamily onDestroy()}\\ \hline
(14) After (1), start a dialog activity from this activity & hideActivityPartially${^\diamond}$ & {\ttfamily onUserLeaveHint()}, {\ttfamily onPause()}, {\ttfamily onCreateDescription()}, {\ttfamily onSaveInstanceState()}\\ \hline
(15) After (14), press Back button & gotoActivity${^\triangle}$ & {\ttfamily onResume()}, {\ttfamily onPostResume()} \\ \hline
(16) After (14), press Home button & savStop${^\wedge}$ & {\ttfamily onStop()}\\ \hline
(17) After (16), start the app from launcher menu & savRestart & {\ttfamily onRestart()}, {\ttfamily onStart()}\\ \hline
(18) After (17), press Home button & savStop${^\wedge}$ & {\ttfamily onStop()}\\ \hline
(19) After (17), press Back button & gotoActivity${^\triangle}$ & {\ttfamily onResume()}, {\ttfamily onPostResume()}\\ \hline
(20) After (14) or (17) , rotate the device & confSTP & {\ttfamily onStop()}, {\ttfamily onDestroy()}, {\ttfamily onCreate()}, {\ttfamily onStart()}, {\ttfamily onRestoreInstanceState()}, {\ttfamily onPostCreate()}, {\ttfamily onResume()}, {\ttfamily onPostResume()}, {\ttfamily onPause()}\\ \hline
(21) After (20), press Back button & gotoActivity${^\triangle}$ & {\ttfamily onResume()}, {\ttfamily onPostResume()}\\ \hline
(22) After (20), press Home button & gotoStop & {\ttfamily onCreateDescription()}, {\ttfamily onSaveInstanceState()}, {\ttfamily onStop()}\\ \hline
(23) After (20), rotate the device & confPAU & {\ttfamily onSaveInstanceState()}, {\ttfamily onStop()}, {\ttfamily onDestroy()}, {\ttfamily onCreate()}, {\ttfamily onStart()}, {\ttfamily onRestoreInstanceState()}, {\ttfamily onPostCreate()}, {\ttfamily onResume()}, {\ttfamily onPostResume()}, {\ttfamily onPause()}\\ \hline
(24) After (22), rotate device and start the app & confSTO & {\ttfamily onDestroy()}, {\ttfamily onCreate()}, {\ttfamily onStart()}, {\ttfamily onRestoreInstanceState()}, {\ttfamily onPostCreate()}, {\ttfamily onResume()}, {\ttfamily onPostResume()}, {\ttfamily onPause()}\\ \hline
(25) After (13), open the app & createActivity${^\ast}$ & {\ttfamily onCreate()}, {\ttfamily onStart()}, {\ttfamily onPostCreate()}, {\ttfamily onResume()}, {\ttfamily onPostResume()}\\ \hline
(26) After (1), start another activity & overlapActivity${^\circ}$ & {\ttfamily onUserLeaveHint()}, {\ttfamily onPause()}, {\ttfamily onCreateDescription()}, {\ttfamily onSaveInstanceState()}, {\ttfamily onStop()}\\ \hline
(27) After (1), open notification bar and tap on a notification & overlapActivity${^\circ}$ & {\ttfamily onUserLeaveHint()}, {\ttfamily onPause()}, {\ttfamily onCreateDescription()}, {\ttfamily onSaveInstanceState()}, {\ttfamily onStop()} \\ \hline
(28) After (1), lock phone by pressing Power button & stopActivity${^\star}$ & {\ttfamily onPause()}, {\ttfamily onCreateDescription()}, {\ttfamily onSaveInstanceState()}, {\ttfamily onStop()}\\ \hline
(29) After (28), unlock the device & restartActivity${^\dagger}$ & {\ttfamily onRestart()}, {\ttfamily onStart()}, {\ttfamily onResume()}, {\ttfamily onPostResume()}\\ \hline
(30) After (1), receive the phone call & stopActivity${^\star}$ & {\ttfamily onPause()}, {\ttfamily onCreateDescription()}, {\ttfamily onSaveInstanceState()}, {\ttfamily onStop()}\\ \hline
(31) After (30), accept and finish the call or reject the call & restartActivity${^\dagger}$ & {\ttfamily onRestart()}, {\ttfamily onStart()}, {\ttfamily onResume()}, {\ttfamily onPostResume()}\\ \hline
(32) After (1), message preview notification is received (e.g., from Viber \cite{viber} app) & hideActivityPartially${^\diamond}$ & {\ttfamily onUserLeaveHint()}, {\ttfamily onPause()}, {\ttfamily onCreateDescription()}, {\ttfamily onSaveInstanceState()}
\end{longtable}
\begin{tablenotes}
\item[$^{a}$]{Different user or system operations can trigger the same event---marked with the same symbol---in the above table. For example, user operations (8), (12), (26), and (27) trigger overlapActivity event and invoke the same callback sequence for the activity.}
\end{tablenotes}
\end{scriptsize}
\end{ThreePartTable}
\newcommand*\mycircle{\textcircled{\textbullet}}
\newcommand\bulletarrow{{\ooalign{\raise0.01ex\hbox{\scalebox{2}{$\bullet$}}}}}
\subsection{Our Proposed CSS Model} \label{cssModel}
This section describes elements of the CSS model and its interpretation in detail.
{\noindent \bf Composite Sequential State:} A CSS is a region of states which are related by state transitions and only one of its states can be active at any given time \cite{BoochUML}. When a CSS is entered, the activity makes a transition from its pseudo-initial state (represented with \bulletarrow) to the default state automatically. Similarly, a final state (represented with \mycircle) shows that no more state transitions are possible within this CSS. A CSS is a static CSS if any of the substates is static, otherwise it is a transient CSS. In Figure \ref{activitySM}, three life cycle states (Started, Resumed and Paused) are decomposed into their respective CSS states (Started-CSS, Resumed-CSS and Paused-CSS). At a higher level, the activity shows similar behavior both in a CSS and its counterpart non-CSS state but CSS contains additional states to characterize more detailed behavior of the activity.
\begin{comment}
\begin{figure*}
\centering
\epsfig{file=activitySM.eps, width=140mm}
\caption{Composite Sequential State Model (The Reverse-engineered Activity Life Cycle Model)}
\label{activitySM}
\end{figure*}
\end{comment}
\begin{figure*}
\centering
\includegraphics[width=140mm]{activitySM-eps-converted-to.pdf}
\caption{Composite Sequential State Model (The Reverse-engineered Activity Life Cycle Model}
\label{activitySM}
\end{figure*}
{\noindent \bf Guard Conditions:} An activity can receive different types of events in a static state. Based on the current and/or previously triggered events, the activity can make a specific sequence of state transitions. The event-related information required to make a transition is shown using guard conditions, enclosed in `[' and `]' in Figure \ref{activitySM}. A transition from a static state requires new event to be triggered. Guard condition for such a transition indicates the new (and now current) event which needs to be triggered for this transition. However, transition from a transient state does not require new event to be triggered from this state. Guard condition for such a transition is evaluated for the current triggered event from the last-visited static state. The activity makes a transition when guard condition is true or no guard condition is shown (which means always true). In a case, when a transition can occur in response to multiple events, it is represented by `[else]' branch, which is evaluated after all \emph{if} conditions have been evaluated to false.
{\noindent \bf Dual State Behavior:} An activity stays only in a static state. However, depending upon the triggered event, the static state may also behave like a transient state. In that case, the activity visits the static state and moves to the next state immediately. To distinguish between specific behaviors of a state, we present such static state as two states. For instance, Stopped state which shows dual state behavior is shown as TransientStopped state and StaticStopped state in Figure \ref{activitySM}. Both states have the same callback method ({\ttfamily onStop()}) for the activity to reach these states.
{\noindent \bf Explanation:} All of the CSS states shown in Figure \ref{activitySM} are static CSS. The Resumed-CSS state is reached with a call to {\ttfamily onResume()} callback method and it contains Resumed, StaticPostResumed, TransientPostResumed and UserLeaveHint states. When createActivity event is triggered from the initial state (Android robot icon), the activity goes through different states to reach Resumed-CSS state. Upon entrance to this state, the activity makes a transition from its pseudo-initial state (\bulletarrow) to Resumed state automatically. Depending upon the triggered event, it moves to StaticPostResumed state or TransientPostResumed state. When reached its StaticPostResumed state, the activity waits for user-interaction in this state and requires a trigger to make next transition. This indicates that Resumed state itself is a transient state as opposed to what is shown in Figure \ref{coreLifeCycle} while StaticPostResumed state is a static state.
A triggered event in a static state can make activity go through a sequence of transient states until it reaches its next static state. The specific sequence of states that it goes through is dependent upon the triggered event. For example, rotating a device from portrait view to landscape view in StaticPostResumed state triggers a confPR event ((4) in Table \ref{activityTable}). This event indicates the change in configuration for the current app and the system destroys current activity in response and recreates it in accord with the new configuration. The activity visits a sequence of transient states in the CSS model to reach back to its StaticPostResumed state. Specifically, it visits TransientPaused, TransientSavedInstanceState, TransientStopped, TransientDestroyed, Created, TransientStarted, RestoredInstanceState, PostCreated, Resumed, and StaticPostResumed states. In StaticPostResumed state, the user can trigger the same or other event regardless of the previously triggered event. However, in some case, the next state transition from a static state may be dependent upon the previously triggered event from a static state. This scenario is shown with additional guard conditions (\&\&) in Figure \ref{activitySM}. For example, consider the state transition from StaticStopped state to Restarted state under the same operation: the savRestart event is triggered only if the previously triggered event is savStop, otherwise the restartActivity event is triggered. Though both events bring activity to Restarted state but the future transitions between the transient activity states are dependent upon the triggered event. The activity visits Restarted and StaticStarted states for savRestart while it visits Restarted, TransientStarted, Resumed, and StaticPostResumed states for the restartActivity event.
Table \ref{activityTable} shows that one single event can be triggered by many different operations. For example, user operations (8), (12), (26), and (27) trigger overlapActivity event and cause the system to invoke the same callback sequence for the activity. Thus, Figure \ref{activitySM} shows only one triggered event from StaticPostResumed state for all these user operations. We perform reverse-engineering on Android 4.4 (alias KitKat) version which is the most widely used Android platform installed by the users\footnote{Around 40\% of the users are using Android KitKat at the time of publication (\url{https://developer.android.com/about/dashboards/index.html}).}. The reverse-engineered life cycle model in Figure \ref{activitySM} is much closer (if not completely same) to the real life cycle than the Android-supplied activity life cycle model. This is due to use of an extensive set of input events, which cover most of the events that can be triggered in day-to-day app usage. This results in high coverage of callback flows in the activity life cycle. However, like all other dynamic analysis approaches, our method may miss some callback flows present in the real activity life cycle. In the future, we will define test-adequacy code coverage criteria, and utilize automatic testing tools as well as code coverage tools to substantially increase code coverage of the activity life cycle.
{\noindent \bf Example:} The motivating example contains four operations. The first operation triggers createActivity event and the activity reaches its StaticPostResumed state. The second operation triggers hideActivityPartially and gotoActivity events and in response, the activity moves to StaticSaveInstanceState and then StaticPostResumed state. The third operation triggers overlapActivity and gotoActivity events while the fourth operation triggers confPR event. The activity visits many states against these events before it reaches StaticPostResumed state.
\subsection {Deriving Event Sequences} \label{secMalBhvrDetction}
A motivated attacker can design a targeted attack which is launched only by a specific ordering of the life cycle callback methods. Existing techniques such as \cite{DroidSafe} analyze all possible orderings of callbacks to detect such attacks. However, such an approach may lead to many false positives because most of the callback sequences will not occur in a real Android app. For example, given an activity that contains all callbacks given in the CSS model, an ordering sequence containing {\ttfamily onCreate()} right after {\ttfamily onStart()} would violate the activity life cycle model and cannot occur in an app.
\subsubsection {Event Sequence-based Analysis} An activity waits for user interaction in its StaticPostResumed state. It can receive different events in this sate. A triggered event can cause the activity to visit a specific sequence of states. Following a visited state sequence in the CSS model, one can derive callback sequence that the system invokes for a particular event. Thus, performing analysis at event level becomes promising to analyze activity component because all event-generated callback sequences follow activity life cycle model and can occur in an Android app. To detect attacks that are launched by specific ordering of events, an analysis tool can consider permutation of events (i.e., their generated callback sequences) for analysis. However, such an approach can lead to false positives because some of the events in the CSS model occur only in a specific order. For example, in a StaticPostResumed state, a user tap on Home button of the device triggers overlapActivity event ($e_1$) which moves current activity to its StaticStopped state and hides the activity and the app into background. The user cannot interact with the activity in this state unless an event is triggered which brings activity back to its StaticPostResumed state. Thus, reopening the app triggers restartActivity event ($e_2$) and the activity reaches its StaticPostResumed state. These two events ($e_1$ and $e_2$) can occur only in this specific order. Similarly, other events such as hideActivityPartially and gotoActivity can be triggered only in the given order. Thus, analysis of event permutations can produce false positives because some event sequences generated by the event permutation may not occur in an app.
A key observation from the above discussion is that the event sequence ($e_1$-$e_2$) makes the activity visit a combined sequence of states which starts from, and ends with StaticPostResumed state. The user cannot directly interact with the activity (e.g., on UI elements) in the intermediate states except triggering an $e_2$ event. Such an event sequence behaves like an individual event. Before and after execution of the event sequence, the activity stays in its StaticPostResumed state where it can receive new events, independent of previously triggered events. One can derive such event sequences from the CSS model which implies that the order of events in the sequences is guaranteed to be feasible. Thus, considering event sequences in place of individual events becomes very promising to accurately analyze activity component in Android apps. The following section presents an algorithm to derive such event sequences from the CSS model.
\algnewcommand\algorithmicinput{\textbf{Input:}}
\algnewcommand\INPUT{\item[\algorithmicinput]}
\def\therule{\makebox[\algorithmicindent][l]{\hspace*{.5em}\vrule height .75\baselineskip depth .25\baselineskip}}%
\makeatother
\setlength{\algorithmwidth}{.9\textwidth}
\begin{algorithm}[ht]
\begin{algorithmic}[1]
\INPUT
\Statex $M$ \Comment State transition model
\Procedure{ActivityEventSequences} {$M$}
\State $s$ = $M$.getInitialState() \Comment{$s$ gets initial state}
\State $e$ = NIL \Comment{$e$ gets current triggered event}
\State $z$ = StaticPostResumed \Comment{$z$ gets a goal state}
\State $T$ = NIL \Comment{$T$ gets the running event sequence}
\ForAll {State $q$ $\in$ $M$}
\State $q$.$color$ = WHITE
\EndFor
\State {\Call{EventSequenceDerivation}{$M, s, e, z,T$}}
\EndProcedure
\end{algorithmic}
\caption{Driving Event Sequences from the Activity Life Cycle Model}\label{eventDerivationActivity}
\end{algorithm}
\subsubsection{Event Sequence Derivation Algorithm}
The CSS model shown in Figure \ref{activitySM} is a compact representation of the activity life cycle model. To facilitate the formulation and implementation of the event sequence derivation algorithm, the CSS model is converted into a flat state diagram using the semantics presented in Section \ref{cssModel}. The resulting state transition model $M$ retains the static and transient states, while eliminates the CSS states. In addition, a transition with a disjunctive guard condition "[$e_1$ || $e_2$ || ... || $e_n$]" is replaced by $n$ transitions, which can be triggered by the $n$ events, respectively.
More formally, the model $M$ is a 5-tuple ($S$, $S_0$, $\Sigma$, $\Lambda$, $\delta$):
\begin{itemize}
\item $S$ is a set of static and transient states (e.g., Created state)
\item $S_0$ is an initial state (Android robot)
\item $\Sigma$ is a set of input events (e.g., createActivity)
\item $\Lambda$ is a set of callbacks (e.g., {\ttfamily onCreate()})
\item $\delta$: $S$ $\times$ $\Sigma$ $\rightarrow$ $S$ $\times$ $\Lambda$ is a state transition function, which returns the next state and a callback function.
\end{itemize}
Algorithm \ref{eventDerivation} describes an algorithm for deriving event sequences from state model $M$ by extending Depth First Search (DFS) algorithm described in \cite{Cormen}. It explores all the events which can be triggered from a given static state and makes state transitions based upon triggered events. It builds event sequences along the way which make activity reach its goal state (i.e., StaticPostResumed for the CSS model). The algorithm is passed five parameters: (1) a state model $M$, (2) current state $s$, (3) current triggered event $e$ (guard condition based on which next state transition is determined), (4) goal state $z$, and (5) the running event sequence $T$.
Algorithm \ref{eventDerivationActivity} takes the state model $M$ as an input and performs initializations. It then invokes Algorithm \ref{eventDerivation} to generate event sequences for activity life cycle model. Starting from the initial state, Android robot (which is a static state), the algorithm explores all possible transitions against different events which can occur from a static state (line 14). In each iteration of the loop, a transition against a specific event is extracted and that event information is passed to future invocations of the algorithm. The algorithm traverses a sequence of transient states based on the triggered event (line 22) until it reaches the next static state. The algorithm returns when it reaches the StaticPostResumed state because this state is already being explored in earlier invocation of the algorithm.
\setlength{\algorithmwidth}{.95\textwidth}
\begin{algorithm}[ht!]
\begin{algorithmic}[1]
\INPUT
\Statex $M$ \Comment State transition model
\Statex $s$ \Comment Current state
\Statex $e$ \Comment Current triggered event
\Statex $z$ \Comment Goal state
\Statex $T$ \Comment Running event sequence
\Procedure{EventSequenceDerivation} {$M, s, e, z,T$}
\If{$s$.$color$ $\neq$ WHITE $\&\&$ $s$.$name$ $==$ $z$}
\State print $T$ \Comment{$T$ is an event sequence, starting from createActivity}
\State \Return
\ElsIf {$s$.$color$ $==$ RED $\&\&$ $s$.$type$ $==$ STATIC}
\State \Return
\Else
\If{$s$.$type$ $==$ STATIC}
\State currStateColor = $s$.$color$
\If {$s$.$color$ $==$ WHITE}
\State{$s$.$color$ $=$ GREY}
\Else
\State{$s$.$color$ $=$ RED}
\EndIf
\ForAll {Transition $tr$ $\in$ $M$.nextTransitions($s$, $e$)}
\State $n$ $=$ $M$.getTriggeredEvent($tr$,$e$)
\State $s'$ $=$ $M$.getDestination($tr$)
\State $tempT$ $=$ $T$
\If{$s' \neq s$} \Comment{avoid self-loop}
\State Append $n$ to $tempT$
\State{\Call{EventSequenceDerivation}{$M,s',n,z,tempT$}}
\EndIf
\EndFor
\State $s$.$color$ $=$ currStateColor
\ElsIf {$s$.$type$ $==$ TRANSIENT}
\State $tr$ $=$ $M$.getTransition($s$,$e$)
\State $s'$ $=$ $M$.getDestination($tr$)
\If{$s' \neq s$} \Comment{avoid self-loop}
\State{\Call{EventSequenceDerivation}{$M,s',e,z,T$}}
\EndIf
\EndIf
\EndIf
\EndProcedure
\end{algorithmic}
\caption{Event Sequence Derivation From A State Model}
\label{eventDerivation}
\end{algorithm}
{\noindent \bf{Handling Loops:}} The $color$ attribute for a state is introduced to show its visited status by the algorithm. Initially, all the states are set to WHITE. When events are explored from a static state for first time, its $color$ is set to GREY; upon another visit, its $color$ is set to RED. The three values for $color$ attribute are introduced to capture all possible flows (at least once) among the activity states. For example, the state transitions between StaticStopped and StaticStarted states form a loop in Figure \ref{activitySM} and it is desired to capture the flow from end of loop to start of the loop at least once. Upon first visit, the $color$ of StaticStopped state (start of the loop) is set to GREY and savRestart event is explored. The activity reaches its StaticStarted state. A savRestart event from this state brings activity back to StaticStopped state. The $color$ of StaticStopped is set to RED and all events are explored again but the algorithm returns if StaticStopped is seen again (line 5-6). The algorithm ignores self-loops while making state transitions between the states. The $color$ of transient states is not set or used because they do not introduce new events to the sequences and just make transitions based on an already triggered event.
{\noindent \bf{Derived Event Sequences:}} All event sequences produced by the algorithm are shown in Figure \ref{activityEvents}. When createActivity event is triggered for the first time, the activity reaches its StaticPostResumed state and can then follow any of the 26 event sequences presented in Figure \ref{activityEvents}. After the createActivity event, all other events in a sequence move the activity from StaticPostResumed state and bring it back to StaticPostResumed state.
\begin{figure}[ht]
\centering
\includegraphics[width=0.90\textwidth]{FigActivityEvents.pdf}
\caption{Twenty-six derived event sequences for the reverse-engineered activity life cycle model}
\label{activityEvents}
\end{figure}
\tikzset{>=latex}
\forestset{
stepwise/.style n args=2{
edge path={
\noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) |- +(#1,#2) |- (.child anchor)\forestoption{edge label};
}
},
my shading/.style={
for tree={
text/.wrap pgfmath arg={black!##1!#1}{10*level()},
edge/.wrap pgfmath arg={->, draw=black!##1!#1}{10*level()},
},
},
}
\subsection{Service Life Cycle Model} \label{serviceLCM}
\subsubsection{Android-Supplied Service Life Cycle Model}
A service performs long running operations in the background and does not provide a user interface. The life cycle of a service \cite{service} depends upon how a service is run. A service started by another application component (e.g., activity) using {\ttfamily startService()} can run indefinitely, even if the component itself is destroyed later. The service is in Started state now and should stop itself after the desired operations are completed. On the other hand, a service bound to another component using {\ttfamily bindService()} runs as long as the component is bound to it. The service can be bound to many components simultaneously but it is unbound when any of the binding components calls {\ttfamily unbindService()} API.
\subsubsection{The Reverse-Engineered Service Life Cycle Model}
Like activity, the Android-supplied service life cycle model omits some states and transitions between the states. We apply the above mentioned technique (also described in \cite{serviceLCMFrank}) to reverse-engineer the service life cycle model. Static and transient states are used to model the service life cycle as shown in Figure \ref{serviceSM}. The service is initially in Shutdown state (static state). With events triggered from this state, the service can reach its Started or Bound state. However, the service can be bound as well as started simultaneously to make it reach its BoundAndStarted state. In a Started state, if a service is being bound for the first time or after the {\ttfamily onUnbind()} invocation has returned false, the system invokes {\ttfamily onBind()} callback otherwise it invokes {\ttfamily onRebind()} callback. This has been shown using guard conditions in Figure \ref{serviceSM}. The other API calls such as {\ttfamily startForeground()} are not shown in Figure \ref{serviceSM} because they do not cause any interesting state transition or callback invocation for the security analysis purpose. The completeness verification of the life cycle model is left as part of our future work.
\begin{comment}
\begin{figure*}[ht!]
\centering
\epsfig{file=serviceSM.eps, width =120mm}
\caption{The Reverse-Engineered Service Life Cycle Model}
\label{serviceSM}
\end{figure*}
\end{comment}
\begin{figure*}[ht!]
\centering
\includegraphics[width=120mm]{serviceSM-eps-converted-to.pdf}
\caption{The Reverse-Engineered Service Life Cycle Model}
\label{serviceSM}
\end{figure*}
\subsubsection{Driving Event Sequences}
Algorithm \ref{eventDerivation} derives event sequences from a state transition model which is based on static and transient states. When applied to service life cycle model shown in Figure \ref{serviceSM} with initial state as Shutdown and goal state as Destroyed state, the algorithm produces 15 event sequences as shown in Figure \ref{serviceEvents}.
\subsection {Generating Permutation of Callback Sequences}
This section first describes how callback sequences are derived from the event sequences and then presents the logic to generate permutation of these callback sequences, and other callbacks (e.g., AUI callbacks).
\subsubsection{Deriving Callback Sequences}
Sections \ref{activityLCM}-\ref{serviceLCM} present activity and service life cycle models and the event sequences derived from these models. Each event in these sequences causes the system to invoke a specific sequence of callbacks in the respective component. Using Table \ref{activityTable}, Dexteroid obtains callback sequences for the 26 activity event sequences and then derives callback sequences using the life cycle callbacks defined in the activity code. It further removes duplicate callback sequences from the list. Similarly, Dexteroid obtains callback sequences for 15 event sequence of the service life cycle model. It removes duplicate event sequences which can produce the same callback sequence. For example, these two event sequences (createAndBind, start, unbind, stopAndDestroy; createAndBind, start, stop, unbindAndDestroy) produce the same callback sequence. It obtains 10 unique callback sequences from the 15 service event sequences shown in Figure \ref{serviceSM} and then derives callback sequences for analysis, given the actual service callbacks.
\begin{figure}[ht]
\centering
\includegraphics[width=0.90\textwidth]{FigServiceEvents.pdf}
\caption{15 Derived Event Sequences for the Reverse-Engineered Service Life Cycle Model}
\label{serviceEvents}
\end{figure}
{\noindent \bf Example:} \label {scenariosExample} For the motivating example, Dexteroid identifies one activity and obtains the 26 callback sequences for the activity. With the given five activity callbacks, Dexteroid derives 12 unique callback sequences for the analysis.
\newcommand*{\permcomb}[4][0mu]{{{}^{#3}\mkern#1#2_{#4}}}
\newcommand*{\perm}[1][-3mu]{\permcomb[#1]{P}}
\subsubsection {Generating Permutation Sequences}
The callback sequences are derived from event sequences for both activity and service life cycle models. They capture most of the callback orderings that can occur in Android applications. However, a motivated attacker can still launch an attack using a specific ordering of callback-sequences, in place of individual callbacks. A callback sequence may be invoked more than once to launch the attack. Given the nature of a typical user interaction with an Android app, a user can invoke these callback sequences various times during the app life cycle. Thus, it is desired to analyze different orderings of callback sequences to detect targeted attacks hidden in the obscure program flows. Dexteroid uses permutation to obtain all possible orderings of these callback sequences.
{\noindent \bf Permutation Unit:} After a createActivity event at the start in the activity event sequences in Figure \ref{activityEvents}, the remaining subsequences move activity from, and bring it back to its StaticPostResumed state. Since they can be repeated randomly in any order in this state, Dexteroid considers callback sequences derived from these event subsequences as permutation units. Similarly, the AUI-callbacks and miscellaneous callbacks can be invoked randomly in a StaticPostResumed state and are considered as permutation units. Dexteroid generates permutation of all permutation units and obtains the permutation callback sequences. It further prefixes these permutation callback sequences with a callback sequence from the createActivity event. This ensures that only feasible flows are generated during permutation (e.g., a createActivity event from a StaticPostResumed state would be an infeasible flow). The service does not have AUI callbacks but can have miscellaneous callbacks (e.g., {\ttfamily onLowMemory()}), Dexteroid generates permutation sequences for all permutation units.
\subsection {Detecting Malicious Behavior} \label{secMalBehavior}
Dexteroid can analyze all components iteratively in any order. For each component, it obtains permutation of callback sequences and analyzes them one by one. It performs static taint analysis on them to detect malicious behaviors (see Section \ref{taintAnalysisSec} for implementation of taint analysis).
{\noindent \bf Threat Model:} Dexteroid currently produces warnings for two types of attacks: (1) leakage of sensitive information, and (2) sending SMS to premium-rate numbers. It tracks sensitive information produced by any of the pre-defined source APIs through callback sequences and reports a warning if such information is passed to any of the sink APIs. Additional warnings are reported if an app sends SMS to hard-coded number or automatically replies to incoming SMS messages. The warnings may reflect the legitimate functionality of the app, the determination of which is beyond scope of this work. Dexteroid does not detect attacks based on implicit flows \cite{implicitFlows}, Java reflection, native code, or dynamically loaded-libraries. It further does not consider attacks for detection that could be launched by exploiting system-level vulnerabilities \cite{dissectingAndroid, perils}.
{\noindent \bf $m$-way Permutation:} A permutation of all permutation units can provide thorough analysis of the app code but it might be very resource-exhaustive task. Dexteroid instead considers $m$-way permutation of $N$ permutation units (i.e., $\perm{N}{m}$) where $m$ is $1\leq m\leq N$. An $m$-way permutation generates sequences by taking $m$ permutation units at a time out of $N$ permutation units. Dexteroid incrementally chooses $m$ values (starting from 1) for the analysis until it detects an attack. If an attack is found with lower $m$ values (e.g., $1$-way permutation), it can stop the analysis on the current app, and move to the next app.
With $1$-way permutation, Dexteroid separately analyzes the 12 derived callback sequences and {\ttfamily onBtnClicked()} method of the motivating example but does not detect any attack. It then uses $2$-way permutation for the analysis and detects that many callback sequences can leak the deviceID. The $2$-way permutation detects the attack because the permutation sequences can contain {\ttfamily onUserLeaveHint()} method twice to transmit the deviceID to other variables. Specifically, all those callback sequences can detect the attack that contain ({\ttfamily onUserLeaveHint()}, {\ttfamily onUserLeaveHint()}, {\ttfamily onSaveInstanceState()}, {\ttfamily onRestoreInstanceState()}, {\ttfamily onResume()}) callbacks in the given order. This attack seems difficult to launch because it demands three event sequences to be triggered in a specific order but all of them are triggered often during a typical user interaction with the Android apps.
\section{Implementation}
We have implemented a prototype of Dexteroid in Java. The tool works on Dalvik bytecode of Android applications. We chose Dalvik bytecode \cite{dalvikForm, DalvikByteCode} so that our analysis does not get affected by inaccuracies which are introduced during decompilation of an Android app into higher level languages \cite{BadAndroidDecompiler, Georgiev2012}. The following sections explain the major components which Dexteroid uses to detect malicious behaviors in Android apps.
\begin{algorithm}
\caption{Analysis Algorithm for an Activity}\label{activityAnalyzer}
\begin{algorithmic}[1]
\INPUT
\Statex $a$ \Comment Input activity for analysis
\Procedure{activityAnalyzer} {$a$}
\State $S_{per} \leftarrow$ Get callback sequences from $m$-way permutation of $a$
\ForAll {Sequence $P_{seq} \in S_{per} $}
\ForAll {Method $d \in P_{seq}$}
\State{\Call{methodAnalyzer}{$d$}}
\EndFor
\EndFor
\EndProcedure
\end{algorithmic}
\end{algorithm}
\subsection {Taint Analysis} \label{taintAnalysisSec}
We call system defined APIs which produce sensitive data as source APIs and the APIs which can potentially leak sensitive data out as sink APIs. A set of source and sink APIs are specified in a configuration file which Dexteroid uses during analysis. It marks a variable tainted if it obtains output of a source API. It performs forward taint flow analysis while keeping a track of source APIs and reports a warning if a sink API consumes data from a tainted variable. The reported warning contains specific sources that can potentially be leaked by a sink API. For each source, Dexteroid reports its data as well as its location in the code.
\begin{algorithm}
\begin{algorithmic}[1]
\INPUT
\Statex $d$ \Comment Input method for analysis
\Statex $S_c$ \Comment Context stack
\Statex $S_m$ \Comment Method call stack
\Procedure{methodAnalyzer} {$d$, $S_c$, $S_m$}
\State Remove back edges from CFG of $d$ and add new edges if needed
\State $B_{rpo} \leftarrow$ Get basic blocks of $d$ in reverse post order\;
\ForAll {BasicBlock $bb \in B_{rpo}$}
\ForAll {Instruction $i \in bb$}
\If{$i$ is a source API}
\State Mark output as tainted
\ElsIf {$i$ is a sink API}
\State Report information leakage if an input variable is tainted
\ElsIf{$i$ invokes a method $d_{new}$ and $d_{new}$ is not on stack $S_m$ }
\State Save current context of symbol space on context stack $S_c$
\State Save $d_{new}$ information on call stack $S_m$
\State Set relevant context for $d_{new}$
\State returnValue $\leftarrow${\Call{methodAnalyzer}{$d_{new}$}}
\State Pop call stack $S_m$
\State Pop context stack $S_c$ and set output to current context
\State Update symbol space with returnValue
\ElsIf{$i$ is a return statement}
\State Set return value for the caller method
\Else
\State Perform taint propagation on involved registers
\EndIf
\EndFor
\EndFor
\EndProcedure
\end{algorithmic}
\caption{High-level Analysis Algorithm for a Method $d$}\label{methodAnalyzer}
\end{algorithm}
Dexteroid considers all components for analysis and handles them in an iterative manner. For a component such as activity, Dexteroid derives the callback sequences from the event sequences generated by $m$-way permutation. It then analyzes the callback sequences as shown in Algorithm \ref{activityAnalyzer}. For a callback sequence, it analyzes each callback in the sequence using Algorithm \ref{methodAnalyzer}. For each method $d$, Androguard \cite{Androguard} produces a control flow graph (CFG) consisting of basic blocks and directed edges between them. Dexteroid detects natural loops and back edges in the CFG using dominators \footnote{This loop detection technique does not work for irreducible CFGs which are rarely generated, however, in our day-to-day programming \cite{AhoCompilers}} \cite{AhoCompilers} and removes back edges from the CFG (line 2 in Algorithm \ref{methodAnalyzer}) . A back edge typically forms a loop, and goes from end of \emph{true} branch of the loop to the loop header. To combine results at merge point from both branches (paths) of the loop, Dexteroid adds new edge from end of \emph{true} branch to \emph{false} branch of the loop, as long as new edge does not introduce a new loop in the CFG. Dexteroid then analyzes each basic block in an order obtained by reverse-post-order (RPO) traversal of the CFG \cite{RPOTraversal}. During traversal, it maintains all analysis related information about predecessors and successors of a basic block which it later incorporates to perform path-insensitive analysis. It combines tainted data from different paths (predecessors) at merge points in the CFG \cite{staticAnalysis}. This path-insensitive approach is more practical and less expensive as compared to path-sensitive analysis, though it may produce false positives or false negatives in some cases.
\subsubsection{Context-Sensitive Analysis} \label{secContextSensitive}
Dexteroid analyzes each (callback) method $d$ using Algorithm \ref{methodAnalyzer}. It iterates over instructions of each basic block where an instruction contains one of the 246 Dalvik opcodes \cite{DalvikByteCode}. Dexteroid implements opcode-specific parsers and handlers which perform analysis on respective instructions. During the analysis, Dexteroid maintains a symbol space (consisting of symbol tables at multiple levels) to keep up-to-date information about variables (registers) such that an instruction gets access to only those variables which have been defined at current basic block, method, or class level, and at global level (e.g., static fields).
Dalvik bytecode provides five {\ttfamily invoke-}\emph{kind} instructions (e.g., {\ttfamily invoke-virtual}) to invoke all types of APIs and methods \cite{DalvikByteCode}. If an instruction invokes a developer-defined method or a library method for which definition exists in the app code (line 10 in Algorithm \ref{methodAnalyzer}), its opcode-specific handler saves current context of symbol space on context stack, finds the callee method by its signature, sets up context for the callee method and invokes analysis on it. After completing analysis on the callee method, the analysis execution automatically returns back to the caller-instruction handler which retrieves old context from the context stack and continues its analysis (line 10-17). Dexteroid obtains \emph{call-site context sensitivity} by maintaining context automatically through the instruction-specific handlers.
{\noindent \emph{Handling recursive-functions}:} In addition to context stack, Dexteroid also maintains a function or method call stack which it consults with before making the context-switch for a callee method. If a method call with a matching signature does not exist in the stack, it adds its entry into the stack and makes context switch otherwise it ignores the method call. After a callee method returns, its entry from the stack is removed and analysis of the caller method continues. Such an approach may not be completely sound to analyze recursive functions but this does help Dexteroid avoid winding up in an infinite loop, especially in two cases: (1) direct recursion in which a method calls itself to implement the desired functionality, and (2) indirect recursion in which multiple methods call each other to form recursion (e.g., method $a$ calls method $b$ and method $b$ calls method $a$).
\subsubsection{Object and Field Sensitivity} \label{objSensitivity}
To achieve high level accuracy, one important problem is how to obtain object-level sensitivity to resolve aliasing during the analysis. In Dalvik bytecode, objects are manipulated using variables (registers). Corresponding to each such variable, Dexteroid maintains one unique entry in the symbol tables. Each entry instance consists of a \emph{name} field and a \emph{details} field of type `EntryDetails'. To resolve aliasing issues, Dexteroid obtains shallow copy of a symbol table entry such that all changes made later to shallow-copied object are automatically reflected in all aliases of that object. A shallow-copied entry's \emph{details} object keeps pointing to the same \emph{details} object of original entry while a deep-copied entry's \emph{details} object gets a new copy of original \emph{details} object at a different memory location. During analysis, when one shallow-copied entry is assigned a new object, other aliases still keep pointing to the original entry in the memory. For primitive data types and immutable objects (e.g., {\ttfamily String}), Dexteroid considers deep copy of symbol table entries for manipulations. This kind of heap abstraction ensures that all aliases are always pointing to the same object. Thus, when a new method is called and context-switch happens, Dexteroid sets up formal parameters by making shallow copy and deep copy of the actual parameters (depending upon their data types). Similarly, Dexteroid obtains field sensitivity by storing each field within `fieldList' of each symbol table entry's \emph{details} object. Each field in the `fieldList' is itself a symbol table entry, and recursively has its own `fieldList'. Dalvik bytecode \cite{DalvikByteCode} provides a set of {\ttfamily iget} and {\ttfamily iput} instructions to access individual fields of an object. Using these instructions, Dexteroid theoretically can maintain fields of any depth during the analysis. This helps in performing very precise taint analysis for user-defined classes with different fields (e.g., linked list). Consider an example in which a linked list of objects of a user-defined class 'Node' (with 'next' and 'value' fields) is defined, and a specific node of the linked list (e.g., \emph{head.next.next.value}) is set to tainted. Dalvik bytecode uses {\ttfamily iput} and {\ttfamily iget} instructions to set and get these fields while to perform analysis, instruction-specific handlers of Dexteroid recursively obtain, and store \emph{next} and \emph{value} fields in 'fieldList' of the \emph{head} entry. Thus, when a specific node is accessed, Dexteroid obtains the node and reports a warning if its \emph{value} field is tainted.
{\noindent \bf Example:} Listing \ref{listing:objSenstvty} shows an object-sensitivity example, derived from example given in \cite{FlowDroid}. The code creates {\ttfamily x1} and {\ttfamily y1} instances (line 2-3) for which Dexteroid creates two symbol table entries and stores {\ttfamily x1} symbol table entry into `fieldList' of {\ttfamily y1}'s \emph{details} object. The variable {\ttfamily x2} gets reference of instance {\ttfamily x1} from {\ttfamily y1} at line 4. Correspondingly, Dexteroid makes shallow copy of the original symbol table entry \emph{pointing to} {\ttfamily x1} and renames it for {\ttfamily x2}. At line 5, Dexteroid invokes {\ttfamily foo()} and passes a copy of {\ttfamily y1} symbol table entry as {\ttfamily yP}. Thus, when {\ttfamily xT.val} is assigned a source value (line 11), Dexteroid taints its corresponding symbol table entry object in the memory. Upon return from analysis of {\ttfamily foo()}, changes made to {\ttfamily x1} entry are automatically reflected in {\ttfamily x2} entry. Line 6 passes tainted value obtained from {\ttfamily x2.getVal()} to the sink API for which Dexteroid reports an information leakage warning.
\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}
\lstset{language=Java, basicstyle=\scriptsize\ttfamily, numbers=left, stepnumber=1, keywordstyle=\color{blue},
frame=single, numbersep=5pt, showspaces=false, numberstyle=\scriptsize\color{black}, stringstyle=\color{mymauve},
showstringspaces=false, showtabs=false, tabsize=2,
breaklines=true, breakatwhitespace=false, caption={Object-Sensitivity Example} , label={listing:objSenstvty}}
\begin{comment}
\begin{minipage}{0.25\linewidth}
\lstinputlisting{ObjectSensitivity.java}
\end{minipage}
\end{comment}
\noindent\begin{minipage}{7cm}
\begin{lstlisting}
void main(){
x1 = new X();
y1 = new Y(x1);
x2 = y1.getX();
foo(y1);
sink(x2.getVal());
}
void foo(Y yP){
xT = yP.getX();
w = source();
xT.setVal(w);
}
\end{lstlisting}
\end{minipage}
{\noindent \emph{Taint preservation along paths of a CFG:}} Dexteroid analyzes basic blocks of a CFG in a fixed RPO order and conservatively combines results at merge points of the CFG. It maintains an {\ttfamily OUT} symbol table for each basic block after completing its analysis. An {\ttfamily OUT} symbol table reflects the method state after analysis of a basic block and is used as an input by its successor basic blocks. At a merge-point basic block of a CFG, results are combined (conservatively) from {\ttfamily OUT} symbol tables of all its immediate predecessors. This means that if a tainted variable gets untainted along one path of CFG but propagates taint on the other path, it will contain tainted information at the merge point. However, since Dexteroid maintains shallow-copied entries corresponding to heap objects, the first analyzed path may untaint a tainted object and cause the analysis to modify, and untaint its corresponding symbol table entry in the memory. When the second path is analyzed, it gets shallow-copy of the entry which would be untainted now (caused by analysis of the first path). This will cause losing taints at the merge point. To address this issue, Dexteroid sets a separate \emph{deep-copied} duplicate of whole {\ttfamily OUT} symbol table ({\ttfamily OUT$_d$}) for each basic block after its analysis. Thus, if an entry is modified and untainted along one path, the entries in {\ttfamily OUT$_d$} are not modified, and still contain taints for propagation along the other paths. An entry on any path can now get preserved taints from the {\ttfamily OUT$_d$} and propagate them to the merge point. The above discussion assumed only one merge point in the CFG but in practice, there might be many merge points for different predicates or loops. Another issue may arise during the analysis in which an object can point-to different objects along different paths of a CFG. A path-sensitive analysis can help Dexteroid to analyze separate program paths, and resolve this issue but such an analysis is known to be a very expensive analysis.
\subsubsection{Flow-Sensitivity}
As shown in Algorithm \ref{methodAnalyzer}, Dexteroid sequentially analyzes instructions in a basic block while maintaining all up-to-date information about the variables. It performs on-demand updates on the variables and hence automatically maintains flow-sensitivity during the analysis.
{\noindent \bf Example:} Listing \ref{listing:flowSensitivity} shows an example (derived from an example in \cite{FlowDroid}) where flow-insensitive analysis would have reported two information leakage warnings at line 4 and line 6. At line 4, {\ttfamily x2.getVal()} is not tainted yet, Dexteroid does not report anything but {\ttfamily x1} gets tainted at line 5, Dexteroid then correctly reports information leakage warning at line 6.
\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}
\lstset{language=Java, basicstyle=\scriptsize\ttfamily, numbers=left, stepnumber=1, keywordstyle=\color{blue},
frame=single, numbersep=5pt, showspaces=false, numberstyle=\scriptsize\color{black}, stringstyle=\color{mymauve},
showstringspaces=false, showtabs=false, tabsize=2,
breaklines=true, breakatwhitespace=false, caption={Flow-Sensitivity Example} , label={listing:flowSensitivity}}
\begin{comment}
\begin{minipage}{0.94\linewidth}
\lstinputlisting{FlowSensitivity.java}
\end{minipage}
\end{comment}
\noindent\begin{minipage}{7cm}
\begin{lstlisting}
void main(){
x1 = new X();
x2 = x1;
sink(x2.getVal());
x1.setVal(source());
sink(x2.getVal());
}
\end{lstlisting}
\end{minipage}
\subsection {Handling APIs} \label{apiHandlingSection}
While source and sink APIs are handled to produce and consume sensitive data respectively, other set of APIs may play their part in taint propagation. These APIs belong to different libraries such as Android, Java, and Apache etc. We have implemented specific handlers for most frequently invoked APIs, extracted from our evaluation dataset. For example, call to an API such as {\ttfamily Ljava/lang/StringBuilder;->append} is delegated to its specific handler which makes relevant variables tainted or untainted based on information obtained from the symbol tables and API documentation. Similarly, some native APIs such as {\ttfamily Ljava/lang/System;->arraycopy} have specific handlers for performing analysis on them. For remaining large set of APIs, Dexteroid has default {\ttfamily invoke} handlers which mark a caller object or returned value as tainted if any of its input parameters or the caller object is tainted. However, the analysis by default handlers is potentially unsound and may produce false positives because output from an object containing sensitive information may not always be sensitive. For example, for an {\ttfamily ArrayList} API ({\ttfamily Ljava/util/ArrayList;->isEmpty()Z}), even if the list contains sensitive data, the returned boolean value from the list may not provide any useful or sensitive information in most of the cases.
Dexteroid defines default handlers for all kinds of {\ttfamily invoke} instructions \cite{DalvikByteCode}. If definition for the instruction-invoked method or API does not exist in the code, one of the default {\ttfamily invoke-}\emph{kind} handlers (e.g., InvokeStaticDefaultHandler) performs taint analysis on it. For example, {\ttfamily invoke-static} makes calls to static methods and APIs and does not need any caller or receiver object to invoke a method or API but {\ttfamily invoke-virtual} typically requires it. When analyzing an API or a method call, the {\ttfamily invoke}-specific handlers mark output value or caller object as tainted or not-tainted based on input parameters and the caller object, if any. For collection objects (e.g., array, hashtable), Dexteroid considers the object as tainted if any of its elements gets tainted. The object stays tainted even if the tainted element (specific indexed value) in the object becomes untainted. However, it becomes untainted when a \emph{new} untainted object is assigned to it. For collection objects, it is difficult to statically get exact index values, so marking the whole object as tainted ensures that we do not miss any attack, though it may generate false alarms in some cases.
\subsection {Handling Static Flow Discontinuity} \label{handlingAPIs}
Dexteroid handles static flow discontinuity issue \cite{staticDiscontinuity} during the analysis which arises when a component or method is invoked using a prototype which does not match with its original prototype definition. For example, {\ttfamily run()} method of a thread is executed when a call to its {\ttfamily start()} method is made. Android dynamically resolves such issues but a static analysis tool must handle such discontinuity issues during the analysis. Similarly, an {\ttfamily AsyncTask} \cite{asynchTask} is started by making a call to {\ttfamily execute()} method but such a method is not defined for a task. In fact, following its life cycle, Android invokes its four callbacks ({\ttfamily onPreExecute()}, {\ttfamily doInBackground()}, {\ttfamily onProgressUpdate()}, and {\ttfamily onPostExecute()}) in the given order. Dexteroid handles both component and method discontinuities by precisely making context switch during the analysis. During preprocessing phase before the analysis, Dexteroid determines type of a class (e.g., task, thread) based on its parent class or defined (callback) methods. Using this information, it determines if a caller to an {\ttfamily execute()} method is an {\ttfamily AsyncTask}, and if so, it delegates analysis to the task-specific handler by making a context-switch (as described in Section \ref{secContextSensitive}). The task handler analyzes all callbacks following its life cycle model before returning back to the task-executor (or caller) method. Similarly, a call to {\ttfamily start()} method is delegated to a thread handler which analyzes its {\ttfamily run()} method before returning back to the caller method.
\subsection{Comparison with Other Tools} \label{secComparison}
This section compares the analysis approach of Dexteroid with those of other static analysis tools such as FlowDroid \cite{FlowDroid} and DroidSafe \cite{DroidSafe}, as below.
\begin{itemize}
\item \emph{Analysis-methodologies for event-triggered callbacks:} Dexteroid analyzes permutation of callback sequences which are systematically derived from the event sequences, and are guaranteed to be valid callback sequences. In comparison, FlowDroid builds a CFG of the callbacks (i.e., a \emph{dummy main} method) and performs analysis on paths of the CFG. This CFG-based approach may not accurately model and analyze Android applications because they are event-driven programs by nature. Events can invoke specific callback sequences in the program and can themselves be triggered multiple times during the program execution. The CFG of callbacks, however, lacks guard conditions and does not reflect conditional flows between the callbacks. A path-insensitive approach (such as FlowDroid) combines results at merge points of the CFG which affects both accuracy as well as precision. Thus, to bypass such an analysis, an attacker can design attacks that are launched by specific ordering of event sequences, such as given in the motivating example. In comparison, DroidSafe \cite{DroidSafe} considers all possible orderings of callbacks for the analysis. The all possible ordering of callbacks violates the activity life cycle model and can cause false positives in the analysis results \cite{DroidSafe}.
\item \emph{Techniques for maintaining flow-sensitivity and call-site context-sensitivity:} Dexteroid is inherently flow-sensitive and context-sensitive which leads to higher accuracy and higher precision in the analysis results. It performs taint analysis by analyzing callbacks guided by the callback sequences and within a (callback) method, it analyzes all instructions in a sequential order, maintaining flow-sensitivity. Similarly, call-site context-sensitivity is ensured by an on-demand analysis of the invoked method, as described in Section \ref{secContextSensitive}. In comparison, FlowDroid uses \emph{context-injection} in forward-analysis and backward-analysis to maintain context-sensitivity. Furthermore, it relies on \emph{activation-statements} to achieve flow-sensitivity. Such an approach might be error-prone if all cases are not handled carefully (We found in our experiments that FlowDroid is not able to maintain flow-sensitivity for globally-defined objects, and can cause false positives. In one case, for a globally-defined object {\ttfamily o1}, a call to method {\ttfamily m1()} initializes {\ttfamily o1}, sets {\ttfamily o1.f=deviceID}, and then sets {\ttfamily o1.f=""}. A call to method {\ttfamily m2()} after {\ttfamily m1()} invokes {\ttfamily o1.p()} which gets {\ttfamily f} and passes it to a sink API. FlowDroid reports an information leakage warning for this. This false positive arises probably because of an on-demand backward analysis which is invoked when a heap object is tainted. The backward analysis later causes forward analysis to map back to the caller of {\ttfamily m1()} from where it then spawns a forward analysis. This forward-analysis analyzes {\ttfamily m2()} which then leads to reporting of information leakage (i.e., a false positive)). Analysis of DroidSafe \cite{DroidSafe} is context-sensitive but flow-insensitive. Its context-sensitivity is specific to object-sensitivity: for a given method, it can accurately compute the receiver heap object on which the method is called. However, it is unclear from the paper that how the call-site context-sensitivity is maintained for static and direct method calls.
\item \emph{Alias-analysis approaches:} Alias-analysis determines if two pointer variables or references can point-to the same memory location during the program execution. Corresponding to heap objects, Dexteroid maintains symbol table entries in the symbol tables. Dexteroid resolves aliasing through shallow-copied entries such that both entries point-to the same memory location (see Section \ref{objSensitivity}). Whenever a heap object is tainted, FlowDroid spawns backward-analysis to taint its aliases which can further spawn new forward and backward analyses and so on. It uses access-paths of specific length to track objects and their fields, and propagates access-paths during the analyses. Our experiments show that alias-analysis for global-level objects also gets affected by backward and forward analyses, as discussed above. DroidSafe, in comparison, is very accurate in resolving-aliases for object-sensitive analysis. It maintains \emph{k-}level deep object-sensitivity for the analysis.
\item \emph{API-handling techniques:} In addition to source and sink APIs, other APIs can be involved in taint propagation. Dexteroid implements specific handlers and default handlers to analyze such APIs (see Section \ref{handlingAPIs} for details). Similarly, FlowDroid has a concept of \emph{taint-wrappers} to model and analyze these APIs. However, both Dexteroid and FlowDroid do not analyze the internal code of these APIs and may cause inaccuracy during the analysis. In comparison, DroidSafe's accurate analysis stubs provide highly accurate execution model of Android for a static analysis tool. Furthermore, it maintains deep object-sensitivity for those API calls to perform highly accurate analysis of the program.
\end{itemize}
\section{Experimental Evaluation}
To evaluate the effectiveness of Dexteroid, we perform a series of experiments to detect two types of attacks: (1) information leakage attack, and (2) SMS-sending attack. An information leakage attack leaks sensitive or private information and in an SMS-sending attack, an application can send SMS to premium-rate numbers.
\subsection{Detection of Information Leakage}
We evaluate Dexteroid against real-world Android applications from Google Play (GPlay) and Genome Malware (Genome) \cite{dissectingAndroid}, and further validate its effectiveness against a benchmark suite of Android apps called DroidBench \cite{FlowDroid}. In addition, we compare our results, where applicable, with previous open-source, state-of-the-art static analysis tool called FlowDroid \cite{FlowDroid}. FlowDroid becomes an ideal candidate for comparison because like Dexteroid, it performs life-cycle aware, context, object, flow, and field-sensitive taint analysis to detect privacy leaks. Furthermore, both tools do not handle inter-component and inter-app communication for the analysis. We use FlowDroid's source code version \cite{FDWiki} obtained on September 9, 2014 in all our experiments, unless specified otherwise. All experiments are run with default options set by FlowDroid, using {\ttfamily -Xmx12g} with no performance-improving arguments.
\subsubsection{Evaluation on Real-World Android Apps} \label{evalReadWorld}
{\noindent \bf Experimental Setup:} We run both tools on top free 1526 GPlay apps and 1259 Genome apps \cite{dissectingAndroid}. Each experiment for both tools is run with Dexteroid-provided source and sink API set. Both tools derive these API sets from Susi project \cite{Susi}. However, to avoid missing any privacy leak, FlowDroid uses over-approximation in selection of source and sink APIs which may cause many false warnings. For example, it assumes output from APIs related to different collection objects as source APIs (e.g., {\ttfamily bundle.getDouble()}), even if the object contains non-sensitive data. Similarly, a flow to an API such as {\ttfamily intent.setClassName()} is reported as information leakage. Dexteroid-provided source and sink API set (68 sources and 75 sinks) does not contain such APIs. Moreover, under time constraints, all our experiments with Dexteroid are run with $1$-way permutation, unless specified otherwise. However, it might be interesting to analyze applications with all-way permutation (i.e., considering $m$=$N$ in $\perm{N}{m}$). An analysis time for an app is heuristically chosen to be 10 minutes.
{\noindent \bf Evaluation Criteria:} Android apps from Google Play (GPlay) are assumed to be benign apps with no defined set of true information leakage warnings. Similarly, Genome samples are known malware and have reported malicious behaviors \cite{dissectingAndroid} but to the best of our knowledge, the number of unique information leakage warnings produced by each sample are not known. Thus, to evaluate analysis results, we first formally define the number of warnings for an app set. We denote a set of maximum number of unique true warnings an app set can theoretically have with $W_{T}$, a set of combined true warnings detected by existing tools (such as Dexteroid and FlowDroid) with $W_{CO}$, and a set of unique true warnings produced by Dexteroid and FlowDroid with $W_{DT}$ and $W_{FD}$, respectively.
\begin{align}
W_{CO} & = W_{DT} \cup W_{FD}\label{eq1}\\
W_{CO} & \subseteq W_{T} \label{eq2}
\end{align}
We use $W_{CO}$ to evaluate analysis results (e.g., recall calculations) of both tools and consider it as a reasonable assumption, given the fact that no set of true warnings are available for existing apps. Hopefully, as true warning sets of other tools are added, the $W_{CO}$ approaches $W_{T}$. A unique warning for an app must meet two criteria: (1) it has a unique combination of a set of source APIs and a sink API, (2) for another warning with the same sink API, its source API set is not subsumed by that of the other. In our evaluation, we consider only unique warnings produced by both tools.
{\noindent \bf Evaluation on Google Play Apps:} When applied on GPlay apps, both tools report many applications leaking sensitive information as shown in Figure \ref{gplaySrcSink}. The x-axis shows the top 20 source API data which are leaked and y-axis shows the number of apps which leak the specific sensitive data (obtained from a source API). For example, Dexteroid reports that `deviceID' and `country' information can be leaked by 97 and 96 apps, respectively. Similarly, 14 apps are reported to leak phone number obtained using {\ttfamily getLine1Number()} API.
\begin{figure*}[ht]
\centering
\includegraphics[width=120mm]{srcSinkGPlay.pdf}
\caption{Information Leakage Detection by Dexteroid and FlowDroid in 1526 Google Play Apps}
\label{gplaySrcSink}
\end{figure*}
For 1526 GPlay apps, Dexteroid produced 661 warnings and FlowDroid produced 201 information leakage warnings. The manual verification of such a large number of warnings is a very time consuming task. It took us one hour on average to verify a warning produced by either tool because a warning may use many (e.g., more than 20) deep level method calls to obtain, and leak sensitive information. The manual verification becomes more difficult by obfuscation techniques used by developers to save their code from stealing. Thus, to evaluate our approach in a meaningful manner, we perform sampling at applications level and then apply both tools on the same set of sampled apps. A random sampling is performed to pick 10\% of the apps (152 apps). Table \ref{expResults} shows experimental setup, and evaluation results for both tools. In experiment\#1, Dexteroid produces 68 unique information leakage warnings; 8 of them are false positives. The false alarms are raised because of the default handlers as well as marking collection objects (e.g., {\ttfamily HashMap}) as tainted, even when value at a specific index is tainted only (see Section \ref{apiHandlingSection}). FlowDroid produces 16 warnings for the 152 apps which however include 5 false positives. Dexteroid detects all the remaining 11 warnings produced by FlowDroid and overall achieves 100\% recall and 88.2\% precision. Its recall is 100\% because (1) all experiments are run independently with their specific configurations, (2) in experiment\#1, Dexteroid detects all the true warnings detected by other tools (i.e., FlowDroid in this case) (see Section \ref{evalReadWorld}). In comparison, FlowDroid achieves 18.3\% recall and 68.7\% precision.
\begin{table*}[ht]
\caption{Evaluation of Dexteroid and FlowDroid on Sampled Google Play Apps}
\centering
\scriptsize
\begin{tabular}{l | l | m{.5cm} m{.5cm} | m{.5cm} m{0.5cm} m{.9cm} | m{.5cm} m{0.6cm} m{.9cm}}
\hline
&{\multirow{2}{*}{Item}} & \multicolumn{2}{c|}{Experiment\#1} & \multicolumn{3}{c|}{Experiment\#2} & \multicolumn{3}{c}{Experiment\#3}\\ \cline{3-10}
& & DT & FD & DT & FD & FD-RE & DT & FD' & FD'-RE \\
\hline
\parbox[t]{0.1mm}{\multirow{4}{*}{\rotatebox[origin=c]{90}{Setup}}} & \#Test Apps & 152 & 152 & 158 & 158 & 158 & 158 & 158 & 158\\
& $m$-way Permutation & $1$ & N/A & $1$ & N/A & N/A & $1$ & N/A & N/A \\
&Max Time (min) & 10 & 10 & 30 & 30 & 30 & 30 & 30 & 30\\
&Source \& Sink API Set & DT & DT & DT & DT & DT & DT & DT & DT\\
&Warning Type & I & I & I & I & I & I & I & I \\
\hline
\parbox[t]{2mm}{\multirow{8}{*}{\rotatebox[origin=c]{90}{Results}}} &\#Reported Warnings & 68 & 16 & 155 & 26 & 27 & 155 & 140 & 145 \\
&\#True Warnings & 60 & 11 & 138 & 9 & 8 & 138 & 85 & 89 \\
&\#Combined Warnings ($W_{CO}$) & 60 & 60 & 138 & 138 & 138 & 157 & 157 & 157\\
&Recall(\%) & 100 & 18.3 & 100 &6.52 & 5.8 & 87.8 & 54.14 & 56.68 \\
&Precision(\%) & 88.2 & 68.7 & 89.03 & 34.6 & 30.76 & 89.03 & 60.7 & 61.3 \\
&F-1 Score & 0.93 & 0.29 & 0.94 & 0.11 & 0.1 & 0.88 & 0.57 & 0.59 \\
&\#Killed(\%) & 24 &39 & 0 & 0 & 3.16 & 0 & 0 & 1.89 \\
&\#Finished(\%) & 76 & 61 & 100 & 100 & 96.84 & 100 & 100 & 98.11 \\
\hline
\multicolumn{10}{l}{
\begin{minipage}{11cm}
\scriptsize DT=Dexteroid, FD=FlowDroid, FD-RE= FlowDroid with flows from reverse-engineered life cycle models, FD'=FlowDroid's latest source code, FD'-RE= FD' with flows from reverse-engineered life cycle models, I=Information leakage
\end{minipage}
}\\
\end{tabular}
\label{expResults}
\end{table*}
FlowDroid reports 11 out of 60 true warnings in experiment\#1. This low-detection could be due to FlowDroid's inaccurate modeling of Android components, or its incomplete taint tracking process for the analysis. The analysis results of both tools can be further affected by limited time or memory for the experiment \cite{FDMailing}(e.g., FlowDroid's analysis is not completed under 10 minutes for 39\% of the apps). To address these issues, we first randomly pick 158 apps based on the experiment\#1 such that both tools do not run out of time or memory during the analysis. We then modify FlowDroid's source code to include additional callback flows from our reverse-engineered activity and service life cycle models. We add seven flows for an activity (e.g., from {\ttfamily onStart()} to {\ttfamily onStop()}) and three flows for a service (e.g., from {\ttfamily onStartCommand()} to {\ttfamily onUnbind()}) in the modified code (FD-RE for short). Experiment\#2 is run on 158 apps and evaluation results are shown in Table \ref{expResults}. Dexteroid reports 155 warnings while FlowDroid reports 26 warnings. Dexteroid reports false alarms because of default handlers and false positives for FlowDroid arise mostly due to its over-approximations for intent-communication (e.g., considering an incoming intent as a source). FD-RE reports one additional warning which is false positive but interestingly, it misses also one true warning reported by FlowDroid. The missed warning is reported by {\ttfamily com.fingersoft.nightvisioncamera} app for which FD-RE is not able to complete its analysis under 30 minutes due to additional callback flows for activity and service components.
FlowDroid has been under active development since its release as an open source tool\footnote{FlowDroid's Android develop branch alone has 567 commits on its Github account at the time of publication.}. Thus, to examine how Dexteroid's prototype implementation would perform against FlowDroid's updated version, we obtain FlowDroid's latest source code (FD' for short) \cite{FDWiki} on August 28, 2015, and add flows from our component life cycle models in the modified FD' (FD'-RE for short). For high precision, none of the performance-improving options is used for FD' and FD'-RE. Experiment\#3 is run on 158 apps of experiment\#2 and evaluation results are shown in Table \ref{expResults}. FD' produces 140 warnings of which 55 warnings are false positives. FD'-RE reports five additional warnings of which one is false positive and four are true positives. Even with additional callback flows, FD'-RE's recall (57\%) remains low than Dexteroid's recall (88\%). This could be due to its dummy-main method based approach or incomplete taint tracking during the analysis or both (see Section \ref{secComparison}). Dexteroid also misses some of the true warnings reported by FD' and FD'-RE. They are missed because Dexteroid's prototype implementation lacks complete modeling of different Android APIs and components. With future improvements, we hope to detect all the missed warnings reported by FD' and FD'-RE. In addition, we are interested to perform more experiments in the future in which we could run both tools (Dexteroid, and FlowDroid's latest code with additional callback flows) on all 1526 GPlay apps and 1259 Genome apps for at least 10 hours per app with a reasonable amount of memory. In our earlier experiments with 1526 GPlay apps, FlowDroid's analysis was killed after ten minutes for 42\% of the apps (see Section \ref{performanceEvaluation}). Similarly, in some cases, FlowDroid may need more than 500 GB of memory to complete its analysis \cite{FDMailing}. Thus, ideally we would like to run our new experiments with enough amount of time and memory so that both tools can complete their analyses for all the apps. These experiments may take a few months while FlowDroid is continuously being updated in parallel; we will pick one specific version of FlowDroid (such as FD'-RE) and run experiments with it.
{\noindent \emph{Phone-Number Leaking Apps}:} The experiments in Table \ref{expResults} report information leakage warnings for all type of source APIs. Some APIs produce more sensitive data (e.g., phone number) than others (e.g., country). The leakage of phone number may expose users to receive unwanted (e.g., advertisement) phone calls, and spam messages. To detect such phone number leakage attacks, both tools are run on 1526 GPlay apps. Dexteroid reports that 14 apps can potentially leak user's phone number as shown in Table \ref{phoneNoLeakingAppsTab} while FlowDroid does not report any warning. Most of the apps send phone number using {\ttfamily http} connection or SMS while 2 apps (\#1 and \#2) write phone number into a "device\_info.txt" file on external memory card. Two apps (\#3 and \#4), apparently from the same developer, contain same (non-advertisement) code and produce the same four warnings each. They start threads from four different activities ({\ttfamily FirstRun}, {\ttfamily Login}, {\ttfamily PaidReturn}, {\ttfamily Subscription}), obtain information such as deviceID, phoneNo and subscriberID and send it to a hard-coded URL starting with {\url{http://www.surveynotify.com}}. The {\ttfamily FirstRun} activity is started when user opens the app for the first time and the activity leaks the sensitive information in plain text. Similarly, app\#5 obtains phoneNo in the {\ttfamily onStartCommand()} method of its {\ttfamily SimCardCheck} service and leaks this information by sending a text message (SMS) in {\ttfamily sendSMS()} method of a {\ttfamily GF} class.
All 14 apps produce 20 warnings: two of them are false positives. Dexteroid reports that the app\#14 in Table \ref{phoneNoLeakingAppsTab} leaks phone number and device information at two places but our investigation reveals that they are false positives. The string contains phone number and other device information but later device information is extracted and passed to the sink APIs. Dexteroid's default handlers pass tainted data from a string (operation) as it is and hence lead to producing the false positives. The customized handlers or stubs for specific APIs (e.g., {\ttfamily String.split()}) may help in eliminating such false alarms.
\begin{table}[ht]
\caption{Detection of Phone-Number Leaking Apps By Dexteroid in Google Play Apps}
\centering
\scriptsize
\begin{tabular}{l l l c c }
\hline
\# & App ID& Version & True Positive & False Positive\\
\hline
1 & cz.aponia.bor3 & 3.10.16 & \checkmark & \\
2 &cz.aponia.bor3.truck & 3.10.28987 & \checkmark & \\
3 & thecouponsapp.coupon & 9.52 & \checkmark & \\ %
4 & gas.coupons & 9.15 & \checkmark & \\
5& com.alienmanfc6.wheresmyandroid & 5.2.1 & \checkmark & \\
6 &com.fatsecret.android & 3.1.1 & \checkmark & \\
7 &com.meraki.sm & 0.9.51 & \checkmark & \\
8 &com.tma.frontflip & 5.0.37 & \checkmark & \\
9 & ipnossoft.rma.free & 2.3.3 & \checkmark & \\
10 &com.facetime\_plus.trendy & 1.0.1 & \checkmark & \\
11 & kst.DailyTextLite2 & 1.3.3 & \checkmark & \\
12 & com.gau.go.launcherex & 5.02.1 & \checkmark & \\
13 & com.yinzcam.nfl.seahawks & 1.1.1 & \checkmark & \\
14 & com.unionbank.ecommerce.mobile.android & 2.10.0.2 & &\checkmark \\
\hline
\end{tabular}
\label{phoneNoLeakingAppsTab}
\end{table}
{\noindent \emph{Supplementary Callbacks}:} The CSS model of activity life cycle includes six supplementary callbacks in addition to seven callbacks shown in Figure \ref{coreLifeCycle}. With 1526 GPlay apps, Dexteroid reports one information leakage warning which is triggered from a supplementary callback method. One app {\ttfamily com.pelmorex.WeatherEyeAndroid} ("The Weather Network") starts an asynchronous task from a supplementary callback {\ttfamily onRestoreInstanceState()}. The task obtains geo-location coordinates, and deviceID and makes a request to a third party server using a sink API. Dexteroid passes parameters to the asynchronous task and performs context-sensitive analysis to successfully detect this information flow.
{\noindent \emph{$2$-way Permutation}:} To find out real-world Android apps that use event permutation to leak information, we run Dexteroid on 1526 GPlay apps with $2$-way permutation and maximum allowed time per app to 30 minutes. We did not find any app which exhibits specific malicious behavior using event permutation. However, we find one such information flow in a `Virtual Zippo Lighter' app which uses combination of a miscellaneous callback method ({\ttfamily onGeocodeTaskComplete()}), and an AUI callback method ({\ttfamily onEditorAction()}) to pass sensitive information to a sink API. With this information flow, the app passes geo-location address to obtain geo-location coordinates from Google servers. Dexteroid detects only one such information flow using $2$-way permutation. However, it might be interesting to see evaluation results with higher order permutation orders (e.g., all-way).
{\noindent \bf Evaluation on Genome Malware Apps:} Genome app set \cite{dissectingAndroid} consists of 49 malware families (with total of 1259 samples) where all members of a family exhibit similar malicious behaviors (with minor variations). Both Dexteroid and FlowDroid are applied on 49 families and their detection results are summarized in Figure \ref{genomeSrcSink}. The x-axis shows the top 20 sources which are leaked while y-axis shows the number of families which can leak that specific source data. The family here indicates that at least one of its members leaks the specific information. Dexteroid reports that the deviceID and location coordinates are leaked by 27 and 21 apps, respectively.
\begin{figure*}[ht]
\centering
\includegraphics[width=120mm]{srcSinkGenome.pdf}
\caption{Information Leakage Detection by Dexteroid and FlowDroid in 49 Genome Families}
\label{genomeSrcSink}
\end{figure*}
\begin{table*}[ht]
\caption{Experimental Evaluation of Dexteroid and FlowDroid on 49 Genome Samples}
\centering
\scriptsize
\begin{tabular}{l | l | l l }
\hline
& Item & DT & FD \\
\hline
\parbox[t]{0.1mm}{\multirow{4}{*}{\rotatebox[origin=c]{90}{Setup}}} & \#Test Apps & 49 & 49 \\
& $m$-way Permutation & $1$ & N/A\\
&Max Time (min) & 10 & 10 \\
&Source \& Sink API Set & DT & DT \\
&Warning Type & I & I \\
\hline
\parbox[t]{2mm}{\multirow{8}{*}{\rotatebox[origin=c]{90}{Results}}} &\#Reported Warnings & 111 & 66 \\
&\#True Warnings & 94 & 49 \\
&\#Combined Warnings ($W_{CO}$) & 101 & 101\\
&Recall(\%) & 93.1 & 48.5 \\
&Precision(\%) & 84.7 & 74.2 \\
&F-1 Score & 0.87 & 0.59 \\
&\#Killed(\%) & 4 & 4 \\
&\#Finished(\%) & 96 & 96 \\
\hline
\multicolumn{4}{l}{
\begin{minipage}{6cm}
\scriptsize DT=Dexteroid, FD=FlowDroid, I=Information leakage
\end{minipage}
}\\
\end{tabular}
\label{expResultsGenome}
\end{table*}
For 1259 Genome samples, Dexteroid produces 4352 warnings while FlowDroid produces 2621 warnings. To reduce the number of warnings to a reasonably verification level, we perform sampling at malware family level because of two reasons: (1) all members of a family exhibit similar malicious behaviors (with minor variations). (2) it removes biasness of a tool towards a specific family in the evaluation results. For example, AnserverBot has 187 samples while GGTracker has only 1 sample. Sampling at family level ensures that all samples are unique in nature and calculations are not affected by the family size. One sample is randomly picked from each family and 49 samples are collected. Table \ref{expResultsGenome} shows the experimental setup and the evaluation results for both tools. Dexteroid achieves high recall (93.1\%) and high precision (84.7\%) compared with FlowDroid's recall (48.5\%) and precision (74.2\%). Most of the apps for both tools are analyzed completely within 10 minutes. Dexteroid does not report any additional attack with $2$-way permutation or which starts from any supplementary callback.
{\noindent \emph{SMS And Phone-Number Leaking Malware}:} The 49 Genome families leak various kind of information (as shown in Figure \ref{genomeSrcSink}). However, many families are reported to leak highly-sensitive data such as user phone number and SMS messages \cite{dissectingAndroid}. Table \ref{smsPhoneAttacks} shows a list of malware families in which at least one member of the family leaks the specific information. Dexteroid detects reported SMS-leakage attacks for most of the families (9 out of 13), in addition to additional attacks for four other families. It misses detection for four families which use intent-communication (CoinPirate, NickyBot) or read data from SMS-content providers (Gone60, Nickyspy). Dexteroid's default handlers do not resolve input parameters for content provider APIs to find out the database name pointed by a Uri and hence lead to the missed attacks. Moreover, one false positive is produced for BeanBot malware. Similarly, Dexteroid detects phone number leaks for 10 out of 15 families (with no false positive) and further reports new (previously-unreported) leaks for 4 families (AnserverBot, BaseBridge, DroidKungFu4, RogueLemon). Five leaks are missed because of intent-communication or incomplete prototype implementation of components such as adapter. FlowDroid reports 5 malware families leaking SMS and 8 malware families leaking phone number as shown in Figure \ref{genomeSrcSink}.
\begin{table}[ht]
\scriptsize
\caption{Detection of SMS And Phone-Number Leaking Families by Dexteroid in Genome Malware}
\centering
\begin{tabular}{p{2cm} | p{1.2cm} p{1.2cm} p{1.2cm} p{1.2cm} }
\hline
{\multirow{2}{*}{Malware}} & \multicolumn{2}{c}{Sms Leakage} & \multicolumn{2}{c}{Phone No Leakage} \\ \cline{2-5}
& Reported & Detected & Reported & Detected \\
\hline
ADRD & - & \checkmark& - & - \\
AnserverBot & - & \checkmark & -& \checkmark \\
BaseBridge & - & \checkmark & -& \checkmark \\
BeanBot & -& -& \checkmark & \checkmark \\
BgServ & - & - & \checkmark & \checkmark\\
CoinPirate & \checkmark & -& - & - \\
Crusewin & \checkmark & \checkmark & - & - \\
DroidKungFu1 & - & - & \checkmark & \checkmark \\
DroidKungFu2 & - & - & \checkmark & -\\
DroidKungFu3 & - & -& \checkmark & \checkmark \\
DroidKungFu4 & - & - & -& \checkmark \\
DroidKungFu5 & - & - & \checkmark & -\\
Endofday & - & - & \checkmark & \checkmark \\
GamblerSMS & \checkmark & \checkmark & -& -\\
Geinimi & \checkmark & \checkmark & \checkmark & -\\
GGTracker & \checkmark & \checkmark & \checkmark & \checkmark \\
GingerMaster & - & - & \checkmark & \checkmark \\
GoldDream & \checkmark & \checkmark & \checkmark & \checkmark \\
Gone60 & \checkmark & -& - & - \\
jSMSHider & - & - & \checkmark & -\\
NickyBot & \checkmark & -& -& - \\
Nickyspy & \checkmark & -& -& - \\
Pjapps & - & \checkmark & \checkmark & \checkmark \\
RogueLemon & \checkmark & \checkmark & -& \checkmark \\
SMSReplicator & \checkmark & \checkmark & - & - \\
Spitmo & \checkmark & \checkmark & \checkmark & \checkmark \\
YZHC & -& - & \checkmark & -\\
Zitmo & \checkmark & \checkmark & - & - \\
\hline
\end{tabular}
\label{smsPhoneAttacks}
\end{table}
\subsubsection{Evaluation on DroidBench} \label{evalDroidBench}
DroidBench \cite{FlowDroid} is a suite of Android applications developed to evaluate correctness and completeness of an analysis tool such as Dexteroid. Most of the apps leak sensitive information such as deviceID. The apps evaluate a tool for both accuracy and precision against different challenges such as object and field sensitivity, life cycle callbacks, anonymous classes, AUI and miscellaneous callbacks, loops, inactive activity, and storing data into arrays and lists. We use latest version (2.0) of DroidBench apps. Since Dexteroid does not analyze intent-communication, Java reflection or implicit flows (see Section \ref{secMalBehavior}), applications that leak information using these features are removed from the evaluation set. Many benchmark apps contain flow to logging APIs (e.g., {\ttfamily Log.e()}), we add such APIs to our sink API set for the evaluation. Table \ref{droidBench} shows the evaluation results when both tools are run on the remaining 90 apps. Dexteroid achieves higher accuracy and precision as compared to FlowDroid. It accurately detects all the flows related to life cycle models of different components such as event (e.g., life cycle callback) ordering and multiple calls to {\ttfamily onStartCommand()} of the service component. It misses 11 leaks because of incomplete modeling of functionalities such as {\ttfamily Serialization}, {\ttfamily Parcel}, and {\ttfamily SharedPreferenceChanged}. These flows can be captured by implementing specific handlers for such APIs in the Dexteroid framework. Also, Dexteroid produces five false warnings: four for marking the whole collection objects (e.g., array, list and hashmap) as tainted (even if a value at a specific index is tainted only) and one for an invalid control flow in the exception handling. In comparison, FlowDroid misses flows because of incomplete handling of features such as static initializations, saved activity state in {\ttfamily onSaveInstanceState()} and {\ttfamily Arrays.toString()} API, in addition to the flows missed by the Dexteroid. Similarly, FlowDroid produces 8 false positives because of collection objects, invalid flows in exception handling, unregistered callbacks, and incorrect resolving of aliases in {\ttfamily Merge1} app.
\begin{table}[ht]
\caption{Evaluation of Dexteroid and FlowDroid on DroidBench Apps}
\centering
\scriptsize
\begin{tabular}{ l | l l l l l }
\hline
Tool & Total Flows & False Negatives & False Positives & Accuracy & Precision\\
\hline
Dexteroid & 79 & 11 & 5 & 83.7\% & 93.1\% \\
FlowDroid & 79 & 22 & 8 & 69.3\% & 87.6\% \\
\hline
\end{tabular}
\label{droidBench}
\end{table}
{\noindent \bf Additional Test Cases:} We develop six test apps based on event sequences derived from the reverse-engineered activity and service life cycle models and add these apps to the DroidBench suite. The apps evaluate if an analysis tool correctly models the component life cycle behaviors such as conditional flows between the callbacks, event-generated callbacks and different orderings of the event sequences. The evaluation results for both tools are shown in Table \ref{testcases}. Dexteroid accurately detects all the privacy leaks while FlowDroid detects one of them, but misses five privacy leaks. Moreover, the {\ttfamily ActivityEveSeq3} app in Table \ref{testcases} contains an attack given in the above motivating example. Dexteroid detects this attacks with $2$-way permutation but FlowDroid does not detect this attack.
\begin{table}[ht]
\caption{Evaluation of Dexteroid and FlowDroid on Six Additional Test Case Apps}
\centering
\scriptsize
\begin{tabular}{l P{1.7cm} P{6.7cm} P{.7cm} P{.7cm} }
\hline
\# &App Name & Event Sequence For The Attack & DT & FD\\
\hline
1 & ActivityEveSeq1 & createActivity & \checkmark & $\times$ \\
2 & ActivityEveSeq2 & createActivity $\rightarrow$ hideActivityPartially $\rightarrow$ savStop $\rightarrow$ savRestart $\rightarrow$ savStop & \checkmark & $\times$\\
3 & ActivityEveSeq3 & createActivity $\rightarrow$ hideActivityPartially $\rightarrow$ gotoActivity $\rightarrow$ overlapActivity $\rightarrow$restartActivity $\rightarrow$ confPR & \checkmark & $\times$\\
4 & ServiceEveSeq1 & createAndStart $\rightarrow$ bind $\rightarrow$ start & \checkmark & $\times$ \\
5 & ServiceEveSeq2 & createAndStart $\rightarrow$ bind $\rightarrow$ unbind $\rightarrow$ bind & \checkmark & $\times$ \\
6 & ServiceEveSeq3 & createAndBind $\rightarrow$ unbindAndDestroy & \checkmark & \checkmark\\
\hline
\multicolumn{5}{l}{
\begin{minipage}{8cm}
\scriptsize DT=Dexteroid, FD=FlowDroid, \checkmark=detects, $\times$= does not detect
\end{minipage}
}\\
\end{tabular}
\label{testcases}
\end{table}
\subsubsection{Evaluation on Additional Callback Flows from Other Tools} \label{EdgeMinerGator}
Experiments in Sections \ref{evalReadWorld}-\ref{evalDroidBench} show that Dexteroid can detect information leakages with high precision and high recall as compared to the existing tools such as FlowDroid. It considers life cycle callback sequences, UI callbacks and miscellaneous callbacks for the analysis. However, the manually-compiled list of UI and miscellaneous callbacks is potentially incomplete and may lead to many missed detections of malicious behaviors. For example, a call to {\ttfamily sort()} method (a registration method) of {\ttfamily Collections} class causes Android framework to implicitly invoke {\ttfamily compare()} method (a callback method) implemented by its {\ttfamily Comparator} class. The Android framework implicitly transfers program control flow from a registration method to its associated callback method. However, Dexteroid has only a limited mapping of such implicit control flow transitions (ICFT) (e.g., from {\ttfamily sort()} to {\ttfamily compare()} method) and may miss many detections during the analysis. Similarly, Dexteroid currently does not analyze callback sequences invoked by opening or dismissing dialog windows or menu items. In this section, we incorporate implicit control-flow transitions from EdgeMiner \cite{EdgeMiner} and callback sequences from Gator \cite{GATORWTG} into Dexteroid to evaluate their impact on Dexteroid's analysis results.
{\noindent \bf Integrating ICFTs from EdgeMiner:} EdgeMiner \cite{EdgeMiner} statically analyzes Android framework to automatically identify a complete set of implicit control flow transitions (ICFTs) which can occur in Android application space (and framework space). Each ICFT consists of a callback method and its associated registration method. An ICFT can be of two types: (1) synchronous, and (2) asynchronous. In a synchronous ICFT, a callback method (e.g., {\ttfamily compare()} method) is invoked synchronously as soon as its registration method (e.g., {\ttfamily sort()} method) is invoked while in an asynchronous ICFT, the callback method (e.g., {\ttfamily onClick()} method) is invoked after some delay to the invocation of its registration method (e.g., {\ttfamily setOnClickListener} method). EdgeMiner's analysis, however, does not aim to identify life cycle callbacks of Android components.
We apply EdgeMiner tool, thanks to its open-source nature, on Android 4.4 to generate 5,655,548 ICFTs (i.e., registration and callback method pairs). We further use EdgeMiner to separate synchronous and asynchronous ICFTs and modify Dexteroid to incorporate callbacks of these ICFTs. Upon identifying a registration method of a synchronous ICFT during analysis, Dexteroid analyze its callback method, if present in the program, using Algorithm \ref{methodAnalyzer} (see Section \ref{taintAnalysisSec}). For asynchronous ICFTs, it considers their callbacks as permutation units and analyzes them separately after the callback sequence of createActivity event. This is because all such asynchronous callbacks can be invoked randomly when activity is in a StaticPostResumed state. It should be noted that in both cases, Dexteroid matches method-signatures to identify registrations and callbacks for the analysis, instead of just relying upon the method name which may lead to imprecise analysis results.
We perform two experiments with Dexteroid after integrating ICFTs from EdgeMiner. The first experiment aims to confirm that after integration, Dexteroid can detect attacks launched by synchronous and asynchronous ICFTs. Due to unavailability of six sample applications used by EdgeMiner \cite{YCao}, we develop four testbed applications that leak sensitive information using synchronous and asynchronous ICFTs. Dexteroid successfully detects all privacy leaks in these testbed applications.
In the second experiment, we further evaluate impact of EdgeMiner ICFTs on analysis results by running Dexteroid on 158 apps of experiment\#2 in Table \ref{expResults}. Each app is analyzed with 1-way permutation for a maximum of 30 minutes. Dexteroid reports 9 new warnings by 6 apps, in addition to the 155 warnings reported earlier in experiment\#2 of Table \ref{expResults}. The new warnings leak information such as deviceID, geo-location coordinates, and network operator name using callbacks such as {\ttfamily onKeyUp()}, {\ttfamily onViewCreated()}, {\ttfamily onExit()}, and {\ttfamily onAttachedToWindow()}. After manual verification, we find seven of these warnings are true positives. Moreover, all apps are analyzed completely within the time limit of 30 minutes.
{\noindent \bf Handling Callback Sequences from Gator:} Gator \cite{GATORWTG} performs static analysis to build a window transition graph (WTG) of an Android application. The nodes in WTG represent windows (e.g., activity, dialog) and edges represent transitions between the windows, triggered by callbacks executed in the main UI thread. It accurately models Android's "back stack" \cite{BackStack} to determine possible valid transitions among the windows. Using widget events, and five default events (back, rotate, power, home, menu), it determines callback sequences which are invoked by Android for windows, and their transitions. Since the WTG is aimed to be primarily used for GUI-testing, it generates callback sequences only for GUI-elements (e.g., activity, dialog and menu). It does not derive callback sequences for other components such as service, broadcast receiver and asynchronous task.
To perform experiments with Dexteroid, we use authors' \cite{ARountev} recommended implementation of Gator (version 3.0) to obtain callback sequences from the WTG because it handles more events and more of the Android semantics as compared to its predecessor version 2.0 \cite{GatorICSE} (see Section \ref{relatedWork}). Furthermore, we implement a parser to extract callback sequences for individual components from the WTG output because due to inter-component communication analysis, the produced callback sequences for a component (e.g., activity) contain callbacks from other components. With Gator callback sequences, we perform two types of experiments: (1) by replacing Dexteroid callback sequences with Gator's callback sequences, and (2) by integrating Gator callback sequences into Dexteroid callback sequences.
For the first type of experiment (i.e., with Gator callback sequences alone), Dexteroid is first run with 2-way permutation on six additional test case apps discussed in Section \ref{evalDroidBench}. It reports warning for only one app (ActivityEveSeq1) which uses one callback sequence to launch the attack. We then run Dexteroid with 1-way permutation on 158 apps of experiment\#2 in Table \ref{expResults}. The experiment is run with 30 minutes each per application so that all apps are analyzed completely within the time limit. Dexteroid reports a total of 120 warnings which all are reported earlier in 155 warnings of experiment\#2 of Table \ref{expResults}. This reduction in warnings is because (1) Gator's callback sequences are specific to GUI-elements only (e.g., activity, dialog and menu). Out of 155 warnings, a total of 27 warnings were earlier contributed by service and broadcast receiver components. Gator does not produce callback sequences for these components. (2) For the activity component, Dexteroid now reports 120 warnings (as compared to earlier-reported 128 warnings) because of reduced number of Gator callback sequences for the analysis.
For the second type of experiment (i.e., with Gator callback sequences integrated into Dexteroid), we repeat the above experiment on 158 apps. Dexteroid reports the same 155 warnings without any new warning. This is partly because most of the events used by Gator to derive callback sequences for activities are already covered by the Dexteroid. For Dexteroid, the new callback sequences for analysis come only from dialogs, option menus and context menus for which it does not report any new warning. All apps are completely analyzed under 30 minutes in the above experiments.
\subsection{Detection of SMS-Sending Attacks}
An app can send SMS to premium-rate numbers which may cost users a lot in their monthly bills. Dexteroid reports warnings for apps which can send SMS to hard-coded numbers defined in the app code, or send automatic reply to an incoming SMS message. FlowDroid does not aim to detect such attacks. Thus, we present our evaluation with Dexteroid in the following sections.
{\noindent \bf Evaluation on Google Play Apps:} Dexteroid analyzes 1526 GPlay apps with $1$-way permutation and 10 minutes per app configuration to detect SMS-sending attacks. During the analysis, it reports a warning if a hard-coded number or SMS sender's phone number obtained from an API such as {\ttfamily SmsMessage.getOriginatingAddress} API is passed to the recipient parameter of an SMS sending API (e.g., first parameter of {\ttfamily sendTextMessage()} API). Dexteroid reports that two Google Play apps ({\ttfamily com.metropcs.service.vvm} and {\ttfamily com.saavn.android}) can send SMS to hard-coded numbers. We manually verified that both warnings are part of legitimate functionality of the apps. Furthermore, Dexteroid successfully detects that three apps ({\ttfamily com.blendr.mobile}, {\ttfamily com.badoo.mobile}, and {\ttfamily com.hotornot.app}) can send automatic reply to an incoming SMS in {\ttfamily onReceive()} method of a broadcast receiver. These apps contain the same in-app billing library which contains this functionality.
{\noindent \bf Evaluation on Genome Malware Apps:} Many of the Genome malware families are reported to launch SMS-sending attacks \cite{dissectingAndroid}. Table \ref{smsAttacks} shows analysis results of Dexteroid on Genome malware. It successfully detects SMS-sending attacks to hard-coded numbers in FakePlayer, HippoSMS, and Zsone malware, and SMS-reply to incoming messages in Endofday, GPSSMSSpy, and GGTracker malware. Moreover, Dexteroid finds that Pjapps, CoinPirate, Nickyspy, Geinimi and DogWars malware send SMS to hard-coded numbers but these behaviors were not reported in \cite{dissectingAndroid}. However, Dexteroid detects only those attacks which obtain their recipient numbers from within the app code. For example, it does not detect attacks in Jifake and Crusewin malware because their hard-coded numbers are given in configuration files. Similarly, SMSReplicator and Walkinwat obtain hard-coded numbers from a {\ttfamily cursor} object. Other malware such as NickyBot, Nickyspy, Pjapps, and YZHC malware communicate with command and control (C\&C) server to obtain recipient numbers. Such attacks are harder to detect by a static analysis tool because the required information is not available in the app code.
\begin{table}[ht]
\scriptsize
\caption{Detection of SMS-Sending Attacks by Dexteroid in Genome Malware}
\centering
\begin{tabular}{p{2cm} | p{.9cm} p{.9cm} p{.9cm} p{.9cm} }
\hline
{\multirow{2}{*}{Malware}} & \multicolumn{2}{l}{Sms to Hard-coded } & \multicolumn{2}{c}{Sms Reply to} \\
& \multicolumn{2}{c}{Numbers} & \multicolumn{2}{c}{Incoming Messages}\\ \cline{2-5}
& Reported & Detected & Reported & Detected \\
\hline
CoinPirate & - & \checkmark & - & - \\
Crusewin & - & - & \checkmark & - \\
DogWars & - & \checkmark & \checkmark & - \\
Endofday & - & - & \checkmark & \checkmark \\
FakePlayer & \checkmark & \checkmark & - & -\\
Geinimi & - & \checkmark & - & - \\
GGTracker & \checkmark & - & - & \checkmark \\
GPSSMSSpy & - &- & \checkmark & \checkmark \\
HippoSMS & \checkmark & \checkmark & - & - \\
Jifake & \checkmark & - & - & - \\
NickyBot & - & -& \checkmark & -\\
Nickyspy & - & \checkmark & \checkmark & - \\
Pjapps & - & \checkmark & - & \checkmark \\
RogueSPPush & \checkmark & - & - & \checkmark\\
SMSReplicator & - & - & \checkmark & - \\
Walkinwat & - & - & \checkmark & -\\
YZHC & \checkmark & - & - & - \\
Zsone & \checkmark & \checkmark & - & -\\
\hline
\end{tabular}
\label{smsAttacks}
\end{table}
\subsection{Performance Evaluation} \label{performanceEvaluation}
All of our experiments are run on a desktop machine running Ubuntu 14.04 with AMD Phenom II quad core processor, and 16 GB of memory. We run both tools on 1526 GPlay apps with maximum allowed time of 10 minutes per app. Dexteroid is not able to complete its analysis for 30\% of the apps (470 apps) while FlowDroid's analysis is killed for 42\% of the apps (640 apps). The killed apps by both tools can be different and can adversely affect the performance evaluations. To make an accurate comparison, we choose only those applications for which both tools complete their analyses without running out of time or memory. We use 158 GPlay apps from Table \ref{expResults} and 47 Genome apps from Table \ref{expResultsGenome}. Table \ref{perfrmEvaluation} shows the experimental setup and evaluation results. It shows total CPU time in minutes for each experiment and average CPU time per app in seconds taken by each tool for the analysis. We measure CPU time in place of wall-time because CPU time measures the amount of time for which CPU has been used to process all instructions of a program. The CPU time of a multi-thread program (such as FlowDroid) can be significantly greater than its wall-time. For example, for 158 GPlay apps shown in Table \ref{perfrmEvaluation}, FlowDroid's CPU time is 195.49 minutes while its wall-time is only 86.8 minutes. In comparison, Dexteroid's CPU time for 158 apps is 105.5 minutes. For both sets of apps, Dexteroid takes less time for analysis as compared to FlowDroid. However, we expect Dexteroid to take more time for higher order $m$-way permutation analysis.
\begin{table}[ht]
\caption{Performance Evaluation of Dexteroid and FlowDroid}
\centering
\scriptsize
\begin{tabular}{ l | l | p{.85cm} p{.85cm} | p{.85cm} p{.85cm} }
\hline
& {\multirow{2}{*}{Item}} & \multicolumn{2}{c|}{Experiment\#1} & \multicolumn{2}{c}{Experiment\#2} \\ \cline{3-6}
& & DT & FD & DT & FD \\
\hline
\parbox[t]{0.1mm}{\multirow{2}{*}{\rotatebox[origin=c]{90}{Setup}}} & \#Test Apps & 158\dag & 158\dag & 47$\star$ & 47$\star$ \\
& $m$-value & 1 & N/A & 1 & N/A \\
& Max Analysis Time/App (min) & 10 & 10 & 10 & 10 \\
\hline
\parbox[t]{2mm}{\multirow{3}{*}{\rotatebox[origin=c]{90}{Results}}} &Total CPU Time (min) & 105.5 & 195.49 & 20.08 & 38.69 \\
&Avg. CPU Time/App (sec) & 40.06 & 75.23 & 25.63 & 49.39 \\
&\#Killed(\%) & 0 & 0 & 0 & 0 \\
&\#Finished(\%) & 100 & 100 & 100 & 100 \\
\hline
\multicolumn{6}{l}{
\begin{minipage}{6cm}
\scriptsize FD=FlowDroid, DT=Dexteroid, \dag =GPlay, $\star$=Genome
\end{minipage}
}\\
\end{tabular}
\label{perfrmEvaluation}
\end{table}
\section{Related Work} \label{relatedWork}
There is a large body of work on Android security including static analysis \cite{LeakMiner, FlowDroid, AppoScopy, myDroid, Chex, DroidSafe, AndroidLeaks, Elish2015255, ScanDal, AAPL, EdgeMiner, Anadroid, ICCTAFD, cmuICCTA, AppIntent} and dynamic analysis \cite{TaintDroid, VetDroid, DroidScope, DroidPF, DroidBox} but we discuss only closely-related work.
FlowDroid \cite{FlowDroid} and DroidSafe \cite{DroidSafe} are static taint analysis tools to detect privacy leakages in Android apps, and have been discussed in detail in Section \ref{secComparison}. In addition, DroidSafe analyzes inter-component communication also. However, given the reverse-engineered life cycle models, we need more careful approach to model and analyze inter-component communication which we leave as part of our future work. LeakMiner \cite{LeakMiner} builds a dummy main method (like FlowDroid \cite{FlowDroid}) and uses static taint analysis to detect information leaks. It includes supplementary callbacks in the CFG but it does not consider the guard conditions for the accurate analysis. Moreover, its context-insensitive approach can produce many false alarms. AndroidLeaks \cite{AndroidLeaks} performs static taint analysis based on System Dependence Graph (SDG) of WALA \cite{WALA}. It uses context-insensitive overlaying for heap dependencies in the SDG which leads to object-insensitive analysis. CHEX \cite{Chex} defines app \emph{split} as the app code reachable from an \emph{entry point} (e.g., life cycle callback). It performs data flow analysis on permutation of app \emph{splits} to detect component hijacking vulnerabilities, which can be extended to detect information leakage in Android apps. As expected, this app \emph{split} permutation may produce false positives because of the infeasible sequences \cite{Chex}. ScanDal \cite{ScanDal} is an abstract interpretation framework which works on Dalvik bytecode of the apps to find privacy leaks. It performs context-sensitive (with context depth=1) and hybrid of flow-sensitive and flow-insensitive analysis. In \cite{Elish2015255}, authors profile statically-extracted \emph{user-trigger dependence} to detect Android malware. AAPL \cite{AAPL} uses enhanced data flow analysis techniques to find privacy disclosures and then uses peer-voting mechanism to validate warnings reported for an application.
Other techniques such as \cite{myDroid, ICCTAFD, cmuICCTA, AppIntent, ICCDamien} analyze inter-component communication for the analysis. ScanDroid \cite{myDroid} finds inter-component and inter-app data flows in the application. Based on WALA \cite{WALA}, however, it requires source code or JVML bytecode of the applications to perform analysis. IccTA \cite{ICCTAFD} and DidFail \cite{cmuICCTA} combine FlowDroid \cite{FlowDroid} and Epicc \cite{Epicc} to detect inter-component privacy leaks. Most of these techniques rely on Android-supplied life cycle models which lack possible flows between the callbacks and the guard conditions to prevent infeasible flows. We plan to extend the above reverse-engineered life cycle models to handle inter-component communication for analysis in our future work.
Dynamic analysis tools perform analysis by executing apps either in an instrumented Android OS \cite{TaintDroid, VetDroid} or in a virtualization-based environment \cite{DroidScope, DroidPF, DroidBox}. TaintDroid \cite{TaintDroid} performs taint flow analysis at multiple levels in Android OS and apps to detect potential information leakage in Android apps. DroidScope \cite{DroidScope} provides APIs to facilitate custom analysis at different levels: hardware, OS, and application level. DroidPF \cite{DroidPF} applies model checking techniques in a mocked-up Android OS to verify security and privacy properties of Android apps. Andromaly \cite{Andromaly} employs host-based anomaly detection to detect Android malware.
In the realm of application life cycle models, Franke et al \cite{Franke2011, serviceLCMFrank} use same technique as discussed above to perform reverse-engineering on Android, iOS and Java ME applications. Their activity life cycle model developed for Android 2.2---a pre-Honeycomb version---contains some flows between the callbacks which do not occur in the Android's post-Honeycomb versions. AndroLift \cite{AndroLift} helps developers to monitor, implement and test life cycle related properties of Android applications. While Dexteroid relies on input events and dynamic monitoring to discover callback flows, Gator \cite{GatorICSE} performs context-sensitive static analysis to determine control-flow between callbacks of an Android app. It builds a callback control-flow graph (CCFG) which precisely captures both intra-component and inter-component callback flows in the code. However, Gator is specific to only user-driven components such as activities, dialogs, and menus. It does not handle other components such as service and broadcast receiver. Furthermore, from an activity life cycle, Gator considers only two callbacks ({\ttfamily onCreate()} and {\ttfamily onDestroy()}) in the CCFG, and identifies other flows (e.g., {\ttfamily onClick()}) between these two callbacks. Authors' most recent version of Gator implementation \cite{GATORWTG}, however, includes more life cycle callbacks and uses many widget and default events to produce window transition graph (WTG). This WTG can be used to derive callback sequences for security analysis purposes (see Section \ref{EdgeMinerGator}).
\section{Conclusion and Future Work}
In this paper, we demonstrated that attacks can be designed to bypass early approaches, which are developed based on Android-supplied life cycle models. We perform reverse-engineering to reconstruct activity and service life cycle models and systematically derive event sequences from these models. In addition, the high-level event sequences offer great value in selecting callback sequences for the taint analysis. A series of experiments performed on Google Play apps and known Genome Malware apps show better performance in terms of precision and recall as compared with previous static analysis tool. Further experiments on DroidBench apps and six additional test case apps validate the effectiveness of the approach.
Dexteroid also has some limitations. First, as it does not handle inter-component or inter-app communication. Given the above reverse-engineered life cycle models, a careful modeling approach is required to handle inter-component communication for the analysis which we leave for our future work. Second, Dexteroid currently does not detect attacks based on implicit flows, Java reflection and native code. We would like to improve Dexteroid to detect such attacks in the future. Third, our current model detects only two types of attacks: (1) information leakage, and (2) sending SMS to premium-rate numbers. In the future, we are interested in detecting other attacks such as leaking a recorded voice call or making unintended phone calls.
\section*{Acknowledgements}
We thank the two anonymous reviewers whose constructive and valuable feedback helped improve quality of our paper. We appreciate Yinzhi Cao and Atanas Rountev for providing us great help in using EdgeMiner and Gator tools, respectively. We also thank Xuxian Jiang for sharing Android malware dataset with us for our experiments.
\renewcommand{\thesection}{}
\makeatletter
\def\@seccntformat#1{\csname #1ignore\expandafter\endcsname\csname the#1\endcsname\quad}
\let\sectionignore\@gobbletwo
\let\latex@numberline\numberline
\def\numberline#1{\if\relax#1\relax\else\latex@numberline{#1}\fi}
\makeatother
\bibliographystyle{elsarticle-num}
\section{}
\label{}
FlowDroid \cite{FlowDroid} haha
\bibliographystyle{elsarticle-num}
|
{'timestamp': '2016-04-11T02:12:50', 'yymm': '1506', 'arxiv_id': '1506.05217', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05217'}
|
arxiv
|
\section{Introduction}
Computational simulation and analysis have become integral parts of
scientific research in many disciplines.
Research using large scale simulations is often a collaborative effort
among scientists and engineers, and tends to require the combined use
of multiple software packages developed by different groups. These
efforts often involve a range of algorithmic fields such as
discretization, mesh generation/pre-processing, domain decomposition,
scalable algebraic solvers, statistical analysis, and visualisation.
Given this reliance on software from multiple groups and specialities,
it is important that the user of the software has confidence that the
outcome of the computation is an accurate proxy for the system being
modelled and that it delivers reproducible results. A rigorous quality
assurance system, which helps deliver accuracy and reproducibility, is
a common requirement for software deployment in industry, and it is
increasingly recognised as an essential practice for scientific
software development. Software engineering approaches form part of a
quality assurance system, and may include methods such as waterfall,
prototyping, iterative and incremental development, spiral
development, rapid application development, and extreme programming
\cite{DeGrace-Stahl:1990,McConnell:1996,Schwaber-Beedle:2001,McConnell:2004}.
Software development practices in academia differ from those in the
commercial sector. In the authors' experience, this is in part due to
the relatively small and transient development teams found in academic
settings, to project-focused development, and to the fact that
academics are incentivized to attract funding and create publications,
and usually care less about financial profit than commercial development. In
addition, academic software development is rarely performed by full
time code developers, and if so, these members are typically hired on
short-term contracts with a focus on a specific subset of the
code. Most scientific software is developed by researchers such as PhD
students and PDRAs (post-docs) who split their time between code development
and research activity. This dichotomy has led to a somewhat reluctant
and heterogeneous adoption of rigorous software engineering practices
in academic contexts.
A survey conducted by Hannay et al.~\cite{Hannay:2009} reveals that
developers of scientific software rely mostly on education from peers
and self-study, and they have relatively little formal training in
software engineering. Moreover, Hannay et al. found that scientists
tend to rank standard software engineering practices higher when they
work on larger software projects.
Heroux et al.~\cite{Heroux:2009} list a number of software practices
which they believe would be easy to adapt and would benefit most
scientific software development teams. They also note that in the
project under consideration, some practices were
only applied to particularly challenging sections of code and relied
on check-lists to make repetitive development and release operations
less error-prone.
Jalali and Wohlin~\cite{Jalali:2010} investigate the adoption of agile
practices in distributed software engineering and find that similar
problems in distributed development have been reported in multiple
articles, possibly pointing to a need to better interpret the context
of different experiences in software development.
Recently, Naguib et al.~\cite{Naguib:2012} note fundamental
differences between software in academia and in industry, i.e.,
academic software is more engineered to achieve high accuracy and
stability, and less so to achieve comprehensibility, maintainability,
and extensibility.
Joppa et al.~\cite{Joppa:2013} have surveyed the attitude towards
scientific software among species distribution modelers, and they
find the ``troubling trend'' that scientists tend to make choices
based on scientifically misplaced factors (e.g., the popularity of the
software-based journal publication, while the software itself has not been
formally been peer-reviewed). They concluded that learning from and
acting on efforts in scientific software development will form an
integral part of delivering models and software that meets high
scientific standards.
In this work, we investigate development practices for four
open-source scientific codes; Chaste\footnote{Chaste:
\url{http://www.cs.ox.ac.uk/chaste/}}~\cite{PittFrancis:2009,
Mirams:2013}, HemeLB\footnote{HemeLB:
\url{https://github.com/UCL/hemelb}}~\cite{Mazzeo:2008,Groen:2013,Groen:2013-3,Nash:2014}
, Fluidity\footnote{Fluidity:
\url{http://fluidityproject.github.io/}}~\cite{Pain2005,Gorman2004_a,Davies:2011},
and ESPResSo\footnote{ESPResSo:
\url{http://espressomd.org/}}~\cite{Limbach:2006,Arnold:2013}. These
are codes with which the authors have had development roles, allowing
us to analyse certain aspects of the development process which would
not be accessible otherwise. In our investigation we review the
evolution of the applied practices over the life-time of the codes and
relate them to changes in the development team. We also discuss
typical practices, such as agile methods with test driven development
and code review, to what extent they have proven effective and have
required modifications over time. Furthermore, we analyse the output
in terms of publications generated using respective software packages
in relation to other factors. In particular, we explore how invested
effort in software development, and adopted practises, translate to
scientific outputs.
To the best of our knowledge, the impact of software development practices on
scientific publication output has not been investigated systematically before,
and our analysis based on the four study cases is the first account in this
direction. Our findings indicate a need to take software development efforts
specifically into account when evaluating the output of science projects that
rely on dedicated software development.
The remainder of this paper is organised as follows; in Section 2 we introduce the
four case studies, along with their specific development practises. In Section 3, we present the methods used to collect the
data on development practices, development team and code size and
publications, and in Section 4 we discuss the changes in development
practices over time. Finally, in Section 5 we investigate the
relationship between code output and expended development effort.
\section{Case Studies}
\subsection{Development, test, and profiling practices}
We briefly summarise the development practices encountered in the four
scientific software projects considered in this work. The purpose here
is not to give a comprehensive overview of software engineering
techniques, but to describe the specific practices that are applied in
the case studies investigated below. The encountered practices also
mirror the prevalent tension between the organizational culture in
academia and the needs of sustainable software development and
maintenance. In the authors' experience, long-term development efforts
are sometimes hampered by short-term funding decisions which typically
do not adequately reflect the potential impact of sustainable
scientific software. The development and testing practices applied in
the studied scientific software projects thus reflect specific ways
chosen by the respective teams to overcome the aforementioned
obstacles.
\subsubsection*{Development tools}
The first step towards sustainable software development typically is
the adoption of tools for version control and release management,
automated build systems, and continuous integration tests. While this
is arguably a rudimentary approach to software engineering, it can
nevertheless lead to considerable improvements in the maintenance of
scientific software.
Version control, or revision control, is used to keep track of all the
modifications made to components of the software project over
time. Revisions can be reviewed, compared, merged and restored
whenever it becomes necessary at a later stage of the project. Version
control systems allow members of the development team to work on the
same files simultaneously, and provide mechanisms to resolve conflicts
that arise from concurrent changes. A variety of modern revision
control systems are available as free software, for example, Mercurial\footnote{\url{https://mercurial.selenic.com}}, SVN\footnote{\url{http://subversion.apache.org/}}, and Git\footnote{\url{https://git-scm.com/}}.
Due to the heterogeneity of modern computing systems and software
environments, compiling source code and linking to the necessary
libraries has become an increasingly involved and time-consuming
task. Build management tools such as the GNU Autotools\footnote{\url{http://www.gnu.org/software/autoconf/}} or CMake\footnote{\url{http://www.cmake.org/}} provide a remedy by offering
automated generation of the necessary steps of the build process, thus
enabling developers to provision their software package on a variety
of different hard- and software platforms.
Continuous integration~\cite{Duvall:2007} involves automated and
periodic execution of unit tests and functional tests, ideally on a
variety of platforms to ensure ease of deployment and correctness of
the software on different platforms.
Scientific software often aims for HPC applications where parallel
performance is of critical importance. Hence performance tuning and
analysis are essential elements of the software development process.
Whereas such aspects are typically not addressed by conventional
software engineering strategies, it becomes increasingly obvious that
scientific codes require performance profiling to be an integral part
of the development and testing process. The Tuning and Analysis
Utilities (TAU)~\cite{Shende:2006} are an example of instrumentation
and measurement techniques that are useful for regular and automated
performance regression tests, which can be referred to as ``continuous
profiling''.
\subsubsection*{Agile methods}
Agile software engineering provides a set of lightweight software
development techniques which are well suited for scientific software
projects due to the flexibility offered and a close connection between
development and usage aspects.
One specific agile methodology referred to in this work is derived
from 'eXtreme programming' \cite{Beck:2004} comprising test-driven
development and pair programming.
Test-driven development involves writing a failing test for a desired
functionality, prior to implementing any source code. Functionality is
then added to the source code until the test passes. This ensures a
good degree of test coverage for the code.
In this work we distinguish between unit tests and functional tests.
Unit tests cover small units of the code, for example individual
classes and methods, while functional tests are more involved scripts
that use the code as a black box to verify correctness of a certain
functionality. The latter can also be useful to identify sudden
regressions in overall accuracy.
Pair programming~\cite{Cockburn:2000,Williams:2001} is a form of code
review in which two developers simultaneously work on the same code,
and workstation. One developer writes code and the other reviews
it. This helps to capture errors efficiently and also helps less
experienced developers learn the code and development practices.
Another agile methodology that is adopted partially in one of the case
studies is \emph{Scrum} \cite{Schwaber-Beedle:2001}. A key element of
scrum are the basic development units called sprints. Sprints involve
a planned program of work that is then implemented by the developers
during a period of a week up to a month, followed by a review
process. The main objective of a sprint is completion of the work into
a deployable state, including tests and documentation of the
implemented features.
\subsection{Scientific software projects}
\subsubsection*{Chaste}
Chaste (Cancer Heart and Soft Tissue Environment) is a suite of object-oriented
C++ libraries for simulating multiscale processes in biology. Chaste has been
in development, primarily at the University of Oxford, since 2005.
There are two main applications for Chaste: the first comprises a cardiac
simulation package which provides a way to use electrophysiology models
in tissue simulations using high performance computing. This package has
for example been used to predict a 2-lead human body surface electrocardiogram
(ECG) and its changes following drug administration \citep{Zemzemi:2013}.
The second application is a multiscale cell based modeling framework which
allows the user to develop simulations of multiple interacting cells using a
variety of agent-based methods including: cellular automata, cell-centre-based
(on and off mesh), cell vertex and cellular Potts models. This framework has
primarily been used for studying cancer in the intestinal crypt, including a
representation of cell mechanics (see e.g.,~\cite{Leeuwen2009Integrative,Osborne2010Hybrid,Dunn2012TwoDimensional}).
For further applications see the overview paper by Mirams et
al.~\cite{Mirams:2013}.
At present, Chaste contains approximately 500,000 lines of C++ code, with seven
regularly (defined in the Methods section) committing developers. The
development team primarily consists of academic researchers (PhD students,
post-docs and research fellows), with dedicated developers occasionally hired
on a per-project basis.
The development team primarily aim to apply elements of Agile methods
and eXtreme programming. The rationale for the application of these
methods in Chaste is described in Pitt-Francis et
al.~\cite{PittFrancis:2008}, along with a detailed description of each
method.
\subsubsection*{HemeLB}
HemeLB is an open source lattice-Boltzmann simulation environment
which has been largely developed by PhD students and post-doctoral
researchers at University College London. It has been used to model
flow in both cerebral arteries~\cite{Itani:2015} and in retinal
vasculature~\cite{Bernabeu:2014}, and it has six regularly committing
developers as of 2015.
The code was first developed in 2005. From 2010 onward, it was
extended with a host of new features and refactored into a more
systematic structure thereby improving its clarity, accuracy and
performance. This effort included the analysis of performance
characteristics in great detail~\cite{Groen:2013,Groen:2013-3} and the
comparison of the accuracy of several boundary conditions and
collision kernels~\cite{Nash:2014}. Current efforts on HemeLB focus on
improving the load balancing of the code, embedding support for deformable
particles, and enhancing the inflow and outflow
conditions~\cite{Itani:2015}.
The software is currently in use across about half a
dozen institutions, primarily in the United Kingdom.
At present, HemeLB
contains approximately 180,000 lines of code, written largely in heavily
object-oriented and sophisticated C++, though some of the auxiliary tools have
been written in Python.
The development team uses Scrum and employs test-driven development
including unit testing and functional testing within continuous integration.
\subsubsection*{Fluidity}
Fluidity~\cite{Pain2005,Gorman2004_a,piggott2007,Davies:2011} is a
general purpose, multiphase computational fluid dynamics code capable of
numerically solving the Navier-Stokes equation and accompanying field equations
on arbitrary unstructured finite element meshes in one, two and three
dimensions. It is primarily developed at Imperial College London and has been
in development since 1999.
Fluidity is used in a number of different scientific areas including
geophysical fluid dynamics~\cite{Davies:2011}, computational fluid
dynamics, ocean modeling and mantle convection
(e.g.,~\cite{Pain2005,Hunt:2012}). Fluidity's partial differential
equation simulator employs various finite element and finite volume
discretization methods on unstructured anisotropic adaptive
meshes. The software is parallelized using MPI/OpenMP and is capable
of scaling to tens of thousands of
processors~\cite{Guo2015227,Lange:2013}. Other useful features are a
user-friendly GUI and a Python interface which can be used to validate
the user input, calculate diagnostic fields, set prescribed fields or
user-defined initial and boundary conditions.
At present, Fluidity consists of approximately 500,000 lines of code,
with 12 regularly committing developers. The developers employ
test-driven development~\cite{pfarrell2011}, and the developement team is currently
integrating TAU~\cite{Shende:2006}
in the agile development process. This serves to obtain performance
feedback for each revision of the code.
\subsubsection*{ESPResSo}
ESPResSo ({\bf E}xtensible {\bf S}imulation {\bf P}ackage for {\bf
Res}earch on {\bf So}ft Matter~\cite{Limbach:2006,Arnold:2013}) is a
highly versatile software package for performing many-particle
molecular dynamics simulations, with special emphasis on
coarse-grained models as they are used in soft matter research
\cite{Grass:2008,Deserno:2009}. Its development started in 2001 at the
Max Planck Institute for Polymer Research, Mainz, Germany. Since 2010
the ESPResSo project is maintained at the Institute of Computational
Physics, University of Stuttgart, Germany.
ESPResSo is commonly used to simulate systems such as polymers,
colloids, ferro-fluids and biological systems, for example DNA or
lipid membranes. ESPResSo also contains a unique selection of
efficient algorithms for treating Coulomb interactions
\cite{Arnold:2013b,Fahrenberger:2014}. More recently, several grid
based algorithms such as lattice Boltzmann and an electro-kinetic
solver have been implemented as well.
ESPResSo is free, open-source software published under the GNU General Public
License (GPL). It is parallelized using MPI and CUDA and can be employed on
desktop machines, convenience clusters as well as on supercomputers with
hundreds of CPUs/GPUs. The flexibility of the software is enhanced through a
Tcl and Python interface, which allows the user to specify bespoke simulation
protocols.
At the time of writing, ESPResSo consists of approximately 220,000
lines of code with 24 regularly committing developers. The
contributors are distributed all over the world and the adoption of
software engineering practices depends largely on individual
commitment. The successful maintenance of ESPResSo relies on the use
of software development tools, e.g., version control, an automated
build system, and continuous integration.
\section{Methods}
\label{Sec:methods}
We collected data for the number of developers and lines of code using
the version control systems of each software. We retrieved this data
from http://www.openhub.net for Chaste, HemeLB and ESPResSo (the
project names there are respectively Chaste, HemeLB and ESPResSo\_MD)
and from legacy version control databases in the case of Fluidity (and
partially for ESPResSo).
We distinguish between three types of developers for each
project. ``Full Time Developers'' are people hired specifically to
develop the software full-time, ``Frequet Research Developers'' are
researchers who have made more than one commit per month, and
``Occasional Research Developers'' are researchers who have made less
than one commit per month, but have made more than one commit in a
given year.
This data was collected from 2005 onwards for Chaste and HemeLB, from 2006
onwards for Fluidity, and from 2001 onwards for ESPResSo.
We assessed the development practices based on our experience working with the
respective codes (JMO and JG with Chaste, DG with HemeLB, XG with Fluidity and
US with ESPResSo) and in consultation with the other members of the respective
development teams. We categorised practices as being: i) regularly or strictly
applied, ii) occasionally or partially applied or iii) rarely or not applied.
We opted for generic descriptions that allow general changes in development
practices to be identified over time and with changes in the size of the
development team, without being overly prescriptive.
The number of publications are based on the number of publications
that could be identified to be directly using the code within a
calender year, with the aim of reflecting a publication list that a
code's website may display. For Chaste and Fluidity a publication list
was available on the code's website. For HemeLB and ESPResSo, the
publications were identified through literature searches on Google
Scholar and Web of Science, followed by manual inspection to filter
out irrelevant results. For ESPResSo, the filtering resulted in
between 50\%-75\% of the Google search results actually being included
in the publication count. The number of publications was collected
from 2005 onwards for Chaste and HemeLB (only data from 2006 onwards
is shown below), from 2006 onwards for ESPResSo and Fluidity.
\section{Results}
\subsection{Development Practices}
The adopted development practices in relation to the size of the
development teams are shown for the four case studies in
Figure~\ref{Fig:develcomparison}. Green glyphs correspond to regularly or strictly
applied practices, amber to occasionally or partially applied and red
to rarely or not applied practices.
\begin{figure}[p]
\centering
\subfigure[%
Chaste.
]{%
\includegraphics[width=0.48\linewidth]{chaste}
\label{Fig:chaste}
}\hfill%
\subfigure[%
HemeLB.
]{%
\includegraphics[width=0.48\linewidth]{hemelb}
\label{Fig:hemelb}
}\\
\subfigure[%
Fluidity.
]{%
\includegraphics[width=0.48\linewidth]{fluidity}
\label{Fig:fluidity}
}\hfill%
\subfigure[%
ESPResSo.
]{%
\includegraphics[width=0.48\linewidth]{espresso}
\label{Fig:espresso}
}
\caption{Changes in development practices with the size and composition of the development teams over the last nine years of development. Key: TDD-Test Driven Development; PP-Pair Programming; UT-Unit Testing; FT- Functional Testing; CI-Continuous Integration; PT-Profiling Testing; SS-Scrum Sessions; and CR-Code Review. Green corresponds to 'always applied', amber is 'partially applied' and red is 'rarely or never applied'.}
\label{Fig:develcomparison}
\end{figure}
Figure~\ref{Fig:chaste} shows the change in practices for Chaste. The
development team of Chaste strongly emphasises software engineering
practices \cite{PittFrancis:2008}, and aims to apply a consistent set
of engineering practices at all times. The only practice that
sometimes is not applied in full is pair programming. In smaller
development teams, pair programming can become challenging as there
are fewer experts at hand and it can be difficult to find suitable
programmers for a specific pair programming task. However, code
written by a single developer is often reviewed by another developer
before being added to the repository.
Figure~\ref{Fig:hemelb} shows the change in practices for HemeLB. The development team of HemeLB is considerably smaller than those of the other applications and comprises many contributors with a relatively short stay in the team. When several new members joined in 2010 and 2011, the development team was able to adopt a range of well-known engineering practices. Nevertheless, the presence of a large legacy code-base has resulted in various parts not being fully test-covered to this day. In 2014, the development team shrank considerably which resulted in a more loose application of the Scrum system, while many of the testing and development practices are maintained to ensure continued code stability.
Figure~\ref{Fig:fluidity} shows the change in practices for Fluidity. Fluidity is developed and maintained by a large and distributed development team. Besides one constantly hired full time developer since 2006, the Fluidity development team has constantly more than dozens "Frequent Research Developers" until 2011. From 2011 on wards, the "Frequent Research Developers" start turn to "Occasional Research Developers" as the result of Fluidity getting mature. Since 2006, the Fluidity developers start to adapt the automated test-driven development approach, this including systematic unit and functional testing, and continuous integration.
Figure~\ref{Fig:espresso} shows the change in practices for ESPResSo. ESPResSo has a relatively large development team. Besides a core team of three research developers, there is a considerable number of regular contributors and ``remote'' developers. In addition, the research group that maintains ESPResSo relocated twice since the first release. Therefore, it has proven difficult to install consistent software engineering practices, and the extent to which engineering principles are applied depends strongly on personal commitment of the individual developers. Generally, the ESPResSo developers aim to cover every feature by at least one functional test, and since 2010 continuous integration is employed.
\subsection{Developer Input and Output}
It is interesting to investigate the publication output of research
software packages in relation to development
effort. Figure~\ref{Fig:io} shows the number of
published papers, code size and the number of active developers
(``Frequent Research Developers'' and ``Full Time Developers'') for
each year from 2006 to 2014. Where applicable, we also provide
information on the number of help tickets raised as a reflection of
code development and use.
\begin{figure}[p]
\subfigure[
Chaste.
]{%
\includegraphics[width=0.49\linewidth]{chaste-io}
\label{Fig:chaste-io}
}\hfill%
\subfigure[
HemeLB.
]{%
\includegraphics[width=0.49\linewidth]{hemelb-io}
\label{Fig:hemelb-io}
}\\
\subfigure[
Fluidity.
]{%
\includegraphics[width=0.49\linewidth]{fluidity-io}
\label{Fig:fluidity-io}
}\hfill%
\subfigure[
ESPResSo.
]{%
\includegraphics[width=0.49\linewidth]{espresso-io}
\label{Fig:espresso-io}
}
\caption{Changes in the size of the development team, code base, number of submitted tickets, and publications over the last nine years of development.}
\label{Fig:io}
\end{figure}
For the case of Chaste (Fig.~\ref{Fig:chaste-io}) the number of active
developers has been reasonably constant. The number of
publications per active developer largely increased over the first four years,
decreasing thereafter. The number of tickets raised
shows a behaviour similar to the number of publications.
For the case of HemeLB (Fig.~\ref{Fig:hemelb-io}) the code base size has been closely linked to the size of the development team. In addition, increases in the size of the development team and the introduction of a ticketing system in 2011 are followed by a delayed increase in the number of publications.
For Fluidity in (Fig.~\ref{Fig:fluidity-io}) the code size has been closely related to the active developers and the publications, the code size become more stable when the actively developers and publications goes down.
For ESPResSo (Fig.~\ref{Fig:espresso-io}) the number of active developers has increased considerably between 2009 and 2011, while the number of publications has remained roughly constant. This is in part a consequence of a considerable number of PhD theses and Faraday discussions that were written in 2009 and 2010, prior to the increase in developers. Therefore, the data points in these years lie higher and subsequently screen the increase expected based on the number of active developers.
\subsubsection{Development Effort and Publications}
In order to investigate the impact of software development efforts, we
analyze the publication output in relation to the accumulated
development effort. In Fig.~\ref{Fig:pubdev}, we present the number of
publications in a given year as a function of the cumulative number of
developers over the last last five years (a) and three years
(b), respectively, for the four case studies. The scatter plots
show that an increased commitment to software development efforts, as
measured by number of developers, results in more publications based
on these software packages. We performed a linear regression resulting
in a slope of $y = 0.71 \times x$ for the five year data and $y = 0.49
\times x$ for the three year data. Both regressions have $P<0.0001$,
although the regression on the three year data resulted in a higher
R-value ($R=0.86$) than the one on the five year data ($R=0.78$).
Note that in Fig.~\ref{Fig:pubdev} we included the maximum number of
data points available in each case study, which varies between the
software packages due to the different time span for which developer
and publication data was collected (see Sec.~\ref{Sec:methods} for details).
We have also related the number of publications in a given year to the
number of developers in each of the five preceding years,
respectively, and performed a similar regression analysis for all five
relations with results as shown in Tab.~\ref{Tab:pubhist}. We find
that there is a strong effect of the number of developers on the
number of publications which only levels off after three years. In
other words, the software development efforts of our case studies
reveal a lasting impact which can not be appropriately reflected by
measuring publication output on a short term basis. The full merit of
a software project may thus not be accessible until at least three
years after the conclusion of development.
A number of factors have not been taken into account here, such as the
impact of the venues of each publication (e.g., Chaste publications
tend to be less numerous, but quite highly cited) and the exact effort
invested by individual developers (i.e., all contributors are treated
at equal value in this assessment). In order to address the latter, we
have also performed the analysis using a weighting system for
development effort (1.0 for full-time developers, 0.5 for
researcher-developer, and 0.25 for occasional developers) which
resulted in an outcome very similar to the un-weighted assessment
shown here.
\begin{figure}[ht!]
\centering\includegraphics[width=0.45\linewidth]{pubdev-1}
\includegraphics[width=0.45\linewidth]{pubdev-5}
\caption{Scatter plot of the number of publications in a given year as a function of the cumulative number of developers in the preceding five years (left) and three years (right). Data points are plotted for Chaste (red), HemeLB (in white), Fluidity (green) and Espresso (blue). The black lines are the result of a linear regression on the data sets.}
\label{Fig:pubdev}
\end{figure}
\begin{table}[ht!]
\caption{Relation of historical development effort to publication
output shown for individual years, ranging from the first year prior
to publication (first data row) to the fifth year prior to
publication. For each year we report the slope of the correlation
found (in publications per active developer that year) in the second
column, and the obtained P-values, R-values and standard errors
respectively in the third, fourth and fifth column.}
\label{Tab:pubhist}
\centering
\begin{tabular}{lllll}
\hline
Years ago & slope & P-value & R-value & stderr\\
\hline
1 & 1.11 & 1.7e-11 & 0.879 & 0.11 \\
\hline
2 & 1.07 & 4.2e-10 & 0.884 & 0.10 \\
\hline
3 & 0.99 & 3.8e-8 & 0.824 & 0.13 \\
\hline
4 & 0.71 & 3.0e-4 & 0.652 & 0.17 \\
\hline
5 & 0.73 & 2.1e-3 & 0.607 & 0.21 \\
\end{tabular}
\end{table}
\section{Discussion}
We conducted and compared four case studies of software development
practices in academia, and analysed the adoption of software
engineering practices, the development effort invested, and the
publication output over a period of at least nine years. We find that
the publication output of the four scientific codes correlates
strongest with the development effort invested in the three years
prior to publication, and that each of these years of effort appear to
contribute equally to the publication output. The correlations become
noticeably weaker when we compare the publication rate with the
development effort invested four or five years earlier.
Based on our results, we conclude that the four considered software
projects should ideally have been reviewed three years after
development efforts have been concluded. This conclusion may be
inconvenient given that performing a final scientific review three
years after the conclusion of a research project can be impractical,
in particular since a large number of academic software development
grants are less than three years in duration. In fact even the
initial efforts of shorter projects cannot be fully assessed by the
final review if the evaluation takes place directly upon the
conclusion of such a project.
There are several ways to mitigate this problem. Firstly, by funding
software projects for at least 3 years reviewers can accurately assess
the scientific publication impact of the initial efforts at the time
when the project finishes. Secondly, review panels could choose to
base their review not directly on peer-reviewed publications, but take
into consideration important preliminary components, such as new
documented code features, simulation data sets and preprints or paper
drafts. Thirdly, for long-running development on academic software,
reviewers could choose to limit their review of the project at hand to
the technical aspects, and judge the academic software on its
scientific potential in a wider context, taking into account the
publication impact of preceding comparable projects.
Although development effort invested in these projects have resulted
in a publication boost, many of the resultant publications do not
feature the original developers as (prominent) authors. For example,
two major contributors to HemeLB only featured on a single
first-author paper each, after investing three years of development
effort. Similarly, a developer contributed the lattice Boltzmann
implementation to ESPResSo which has enabled a host of subsequent
publications of other authors directly using this code. Therefore, the
correlations we presented can not (and must not) be used to assess
individual contributions to the publication output, or to the software
more generally.
Indeed, publication numbers only partially describe the impact of an
individual developer or even a short-term project effort, as they
indirectly reflect more fundamental impact, such as technical quality,
ease-of-reuse and the presence of valuable new features (these metrics
are arguably more difficult to quantify, measure and compare). In
addition, although we find these correlations for our four case
studies, a much larger investigation is required to assess the
relationship between invested development effort and scientific impact
for academic software in general.
In terms of adopted software development practices we find that, in
particular for HemeLB and ESPResSo, new practices are typically
adopted when a development team has recently increased in size. In the
case of HemeLB and Chaste, the application of individual practices was
slightly reduced when the respective development teams became smaller,
but this effect seems to be more limited. More generally, software
development practices, once first applied, appear unlikely to be
abandoned later on. This could indicate a high level of satisfaction
from the development team regarding the adoption of these
practices.
While a larger study will be required to assess the efficacy of
software engineering practices in computationally oriented research
communities in general, our study indicates that the use of software
engineering principles improves the quality of the research software
and leads to a concomitant increase of the publication output.
\section*{Acknowledgements}
The authors would like to thank: Dr. Tim Greaves, Dr. Matthew Piggott and Dr. Gerard Gorman for help with data collection and interpretation of the Fluidity software package; the Chaste development team for discussions regarding data collection for the Chaste package; and Axel Arnold and Olaf Lenz for valuable
discussions regarding collection and interpretation of data for the
ESPResSo software package. This work was spawned as a collaborative
project during the first 2020 Science \& Software Sustainability
Institute Paper Hackathon which took place in Flore, Northamptonshire,
United Kingdom in September 2014. This work has been funded by the
Computational Horizons in Cancer (CHIC) project under EU FP7 grant
agreement number 600841 (JG), the CRESTA
project under EU FP7 grant agreement number 287703 (DG,US), and the UK
Engineering and Physical Sciences Research Council under grant numbers
EP/I017909/1 (www.2020science.net, DG,JG,JMO) and EP/I034602/1 (US).
\section*{References}
|
{'timestamp': '2015-06-18T02:12:14', 'yymm': '1506', 'arxiv_id': '1506.05272', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05272'}
|
arxiv
|
\section{Introduction\label{Introduction}}
There has been substantial research carried out on partial identification
since the seminal work of Manski. For example, see monographs by Manski
(2003, 2007), a recent review by Tamer (2010), and references therein for
extensive details. In its general form, identification results are typically
expressed as nonparametric bounds via moment inequalities or other similar
population quantities. When these unknown population quantities are
high-dimensional (e.g. the dimension of covariates is high in conditional
moment inequalities), there is a curse of dimensionality problem in that a
very large sample is required to achieve good precision in estimation and
inference (see, e.g. Chernozhukov et al.\thinspace (2013)). In this paper,
we propose a method for inference that avoids the curse of dimensionality by
exploiting the model structure. We illustrate our idea in the context of
commonly used discrete choice models.
To explain this issue, suppose that one is interested in identifying a
structural parameter in a binary choice model. In this model, it is quite
common to assume that an individual's utility function is parametric while
making weak assumptions regarding underlying unobserved heterogeneity.
Specifically, consider the following model
\begin{equation}
Y=1\{X^{\prime }\beta \geq \varepsilon \}, \label{RUM}
\end{equation}%
where $Y$ is the binary outcome, $X$ is an observed $d$ dimensional random
vector, $\varepsilon $ is an unobserved random variable, $\beta \in \Gamma$
is a vector of unknown true parameters, and $\Gamma \subset \mathbb{R}^d$ is
the parameter space for $\beta$.
Without sufficient exogenous variation from covariates, $\beta$ is only
partially identified. The resulting identification region is characterized
by expressions involving nonparametric choice probabilities conditional on
covariates. For example, under the assumption that the conditional median of
$\varepsilon$ is independent of $X$ and other regularity conditions that
will be given in Section \ref{Model}, $\beta$ is partially identified by
\begin{equation}
\Theta =\{b\in \Gamma :X^{\prime }b\left[ P(Y=1|X)- 0.5 \right] \geq 0\text{
almost surely}\}. \label{theta-median}
\end{equation}%
Recently, Komarova (2013) and Blevins (2015) use this type of
characterization to partially identify $\beta$. Both papers consider
estimation and inference of the identified set $\Theta$ using a maximum
score objective function; however, they do not develop inference methods for
the parameter value $\beta$ based on the conditional moment inequalities in %
\eqref{theta-median}. Unlike theirs, we focus on inference for $\beta$ as
well as the issue of dimension reduction in the context of conditional
moment inequalities.
When $X$ contains several continuous covariates yet their support is not
rich enough to ensure point identification, we can, for instance, construct
a confidence region for $\beta $ by inverting the test of Chernozhukov et
al.\thinspace (2013, henceforth CLR), who plug in nonparametric (kernel or
series based) estimators to form one-sided Kolmogorov-Smirnov type statistic
for testing the conditional moment inequalities. In order to conduct
inference based on the CLR method, we need to estimate conditional
expectation $E(Y|X)=P(Y=1|X)$ nonparametrically. In this context, it is
difficult to carry out inference in a fully nonparametric fashion when $d$
is large. One may attempt to use parametric models to fit the choice
probabilities. However, that can lead to misspecification which may
invalidate the whole partial identification approach. Hence, it is important
to develop dimension reduction methods that avoid misspecification but
improve the precision of inference, compared to fully nonparametric methods.
In this paper, we establish an alternative characterization of $\Theta$ that
is free from the curse of dimensionality. One of the main results of this
paper (Lemma \ref{Lemma 1} in Section \ref{Model}) is that $\Theta =%
\widetilde{\Theta }$, where
\begin{equation} \label{theta-tilde-median}
\widetilde{\Theta }\equiv \{b \in \Gamma:X^{\prime }b\left[ P(Y=1|X^{\prime
}b,X^{\prime }\gamma )-0.5 \right] \geq 0\text{ almost surely for all }%
\gamma \in \Gamma \}.
\end{equation}%
This characterization of the identified set $\Theta$ enables us to break the
curse of dimensionality since we now need to deal with the choice
probability conditional on only two indexing variables. The benefit of using
the characterization in $\widetilde{\Theta }$, as opposed to $\Theta$, is
most clear when we estimate the conditional expectation functions directly.
The local power of a Kolmogorov-Smirnov type test decreases as the dimension
of conditional variables gets large (for example, see CLR and Armstrong
(2014a, 2014b, 2015)). If the method of CLR is utilized with %
\eqref{theta-median}, the dimension of nonparametric smoothing is $d$.
Whereas, if the same method is combined with \eqref{theta-tilde-median},
note that the dimension of nonparametric smoothing is always 2. This is true
even if $d$ is large. Therefore, the latter method is free from the curse of
dimensionality.
The remainder of the paper is organized as follows. In Section \ref{Model},
we provide a formal statement about the binary choice model \eqref{RUM}. In
Section \ref{Extensions}, we show that our approach can be extended to the
class of semiparametric models under which the sign of conditional
expectation of a certain transformation of the outcome is the same as that
of the indexing variable. This extension covers a variety of discrete choice
models in the literature. Section \ref{sec:inference-CLR} describes how to
construct a confidence set based on CLR and Section \ref{sec:MC} presents
some results of Monte Carlo simulation experiments that illustrate
finite-sample advantage of using the dimension reducing approach. Section %
\ref{sec:conclusions} concludes and Section \ref{sec:appendix} contains the
proofs and some further results.
\section{Conditional moment inequalities for a binary choice model\label%
{Model}}
To convey the main idea of this paper in a simple form, we start with a
binary choice model. Recall that in the binary choice model \eqref{RUM}, we
have that $Y=1\{X^{\prime }\beta \geq \varepsilon \}$, where the
distribution of $\varepsilon $ conditional on $X$ is unknown. Let $\Gamma
_{X}$ denote the support of $X$. Write $X=(X_{1},\widetilde{X})$ where $%
\widetilde{X}$ is the subvector of $X$ excluding its first element. Let $%
\Gamma $ be the parameter space that contains the true parameter vector
value $\beta $. Let $b$ denote a generic element of $\Gamma $. Let $Q_{\tau
}(U|V)$ denote the $\tau $ quantile of the distribution of a random variable
$U$ conditional on a random vector $V$. We study inference of the model
under the following assumptions.
\begin{condition}
\label{continuous covariate}(i) $\left\vert b_{1}\right\vert =1$ for all $%
b\in \Gamma $. (ii) The distribution of $X_{1}$ conditional on $\widetilde{X}%
=\widetilde{x}$ is absolutely continuous with respect to the Lebesgue
measure for almost every realization $\widetilde{x}$.
\end{condition}
\begin{condition}
\label{condition 1}(i) For some $\tau \in \left( 0,1\right) $ and for all $%
x\in \Gamma _{X}$, $Q_{\tau }(\varepsilon |X=x)=0$. (ii) For all $x\in
\Gamma _{X}$, there is an open interval containing zero such that the
distribution of $\varepsilon $ conditional on $X=x$ has a density that is
everywhere positive on this interval.
\end{condition}
The event $X^{\prime }\beta \geq \varepsilon $ determining the choice is
invariant with respect to an arbitrary positive scalar multiplying both
sides of the inequality. Therefore, parameter scale is not identified;
following the literature (e.g., Horowitz\thinspace (1992)), we assume
Condition \ref{continuous covariate} (i) for scale normalization. Condition %
\ref{continuous covariate} (i) and (ii) together imply that the model admits
at least one continuous covariate. Condition \ref{condition 1} (i), due to
Manski\thinspace (1985, 1988), is a quantile independence assumption and
allows for nonparametric specification of the preference shock with a
general form of heteroskedasticity. Condition \ref{condition 1} (ii) implies
that, for all $x\in \Gamma _{X}$, $P(\varepsilon \leq t|X=x)$ is strictily
increasing in $t$ around the neighborhood of the point $t=0$. This is a
fairly weak restriction which includes yet is not confined to the case where
the distribution of $\varepsilon $ conditional on $X$ has a density that is
everywhere positive on $\mathbb{R}$.
Under Condition \ref{condition 1}, Manski\thinspace (1988, Proposition 2)
established that the necessary and sufficient condition for point
identification of $\beta $ is\thinspace that, for $b\neq \beta $,
\begin{equation}
P\left( X^{\prime }b<0\leq X^{\prime }\beta \text{ or }X^{\prime }b\geq
0>X^{\prime }\beta \right) >0. \label{identification condition}
\end{equation}%
Given the scale normalizing assumption, the condition (\ref{identification
condition}) effectively requires that the covariates $X$ should be observed
with sufficient variation. Hence, lack of adequate support of the
distribution of $X$ may result in non-identification of $\beta $. For
example, Manski\thinspace (1988) and Horowitz\thinspace (1998, Section
3.2.2) constructed non-identification cases for which all covariates take
discrete values. Admitting continuous covariates does not guarantee
identification either. As indicated by Manski\thinspace (1985, Lemma 1),
non-identification also arises when the covariates are distributed over a
bounded support such that one of the choices is observed with probability
well below $\tau $ for almost every realized value of $X$. In empirical
applications of the discrete choice model, it is quite common to include
continuous variables in the covariate specification. Therefore, the present
paper addresses and develops the method for inference of $\beta $ in the
presence of continuous covariates for the model where the support of data
may not be rich enough to fulfill the point-identifying condition (\ref%
{identification condition}).
Though Conditions \ref{continuous covariate} and \ref{condition 1} do not
suffice for point identification of $\beta $, it still induces restrictions
on possible values of data generating preference parameters, which results
in set identification of $\beta $. To see this, note that Condition \ref%
{condition 1} implies that for all $x\in \Gamma _{X}$,
\begin{eqnarray}
P(Y &=&1|X=x)>\tau \Leftrightarrow x^{\prime }\beta >0, \label{a1} \\
P(Y &=&1|X=x)=\tau \Leftrightarrow x^{\prime }\beta =0, \label{a2} \\
P(Y &=&1|X=x)<\tau \Leftrightarrow x^{\prime }\beta <0. \label{a3}
\end{eqnarray}%
Given Condition \ref{continuous covariate}, $X^{\prime }b$ is continuous for
any $b\in \Gamma $. Thus $P(Y=1|X)=\tau $ occurs with zero probability. The
set of observationally equivalent preference parameter values that conform
with Condition \ref{condition 1} can hence be characterized by%
\begin{equation}
\Theta =\{b\in \Gamma :X^{\prime }b\left[ P(Y=1|X)-\tau \right] \geq 0\text{
almost surely}\}. \label{theta}
\end{equation}%
Given (\ref{a1}), (\ref{a2}) and (\ref{a3}), we also have that
\begin{equation}
\Theta =\{b\in \Gamma :b^{\prime }XX^{\prime }\beta \geq 0\text{ almost
surely}\}\text{.} \label{theta_sign}
\end{equation}%
Namely, the vector $b$ is observationally equivalent to $\beta $ if and only
if the indexing variables $X^{\prime }b$ and $X^{\prime }\beta $ are of the
same sign almost surely.
Operationally, one could make inference on $\beta $ by pointwise inverting a
test of the conditional moment inequalities given in (\ref{theta}). However,
as discussed in Section \ref{Introduction}, there is a curse of
dimensionality in nonparametric inference of the conditional expectation
when the dimension of continuous covariates is high. By exploiting the
restrictions implies by Conditions \ref{continuous covariate} and \ref%
{condition 1}, we now present below a novel set of conditional moment
inequalities that can equivalently characterize the set $\Theta $ yet enable
inference to be performed free from the curse of dimensionality.
Note that the restrictions (\ref{a1}), (\ref{a2}) and (\ref{a3}) imply that
\begin{equation*}
Q_{1-\tau }(Y|X)=1\{X^{\prime }\beta >0\}=Q_{1-\tau }(Y|X^{\prime }\beta )%
\text{ almost surely.}
\end{equation*}%
In other words, we have that with probability 1,%
\begin{equation}
\func{sgn}[P(Y=1|X)-\tau ]=\func{sgn}[P(Y=1|X^{\prime }\beta )-\tau ]=\func{%
sgn}[X^{\prime }\beta ], \label{sign}
\end{equation}%
where $\func{sgn}(\cdot )$ is the sign function such that $\func{sgn}(u)=1$
if $u>0$; $\func{sgn}(u)=0$ if $u=0$; $\func{sgn}(u)=-1$ if $u<0$. The sign
equivalence (\ref{sign}) motivates use of indexing variables instead of the
full set of covariates as the conditioning variables in nonparametric
estimation of the conditional expectation, thereby breaking the curse of
dimensionality as raised in the discussion above. To be precise, let
\begin{equation*}
\widetilde{\Theta }\equiv \{b:X^{\prime }b\left[ P(Y=1|X^{\prime
}b,X^{\prime }\gamma )-\tau \right] \geq 0\text{ almost surely for all }%
\gamma \in \Gamma \}.
\end{equation*}%
The first key result of our approach is the following lemma showing that the
identified set $\Theta $ can be equivalently characterized by $\widetilde{%
\Theta }$, which is based on the choice probabilities conditional on two
indexing variables.
\begin{lemma}
\label{Lemma 1}Under Conditions \ref{continuous covariate} and \ref%
{condition 1}, we have that $\Theta =\widetilde{\Theta }$.
\end{lemma}
To explain the characterization result of Lemma \ref{Lemma 1}, note that the
model (\ref{RUM}) under Condition \ref{condition 1} implies that for any $%
\gamma \in \Gamma $,
\begin{equation}
\func{sgn}[P(Y=1|X^{\prime }\beta ,X^{\prime }\gamma )-\tau ]=\func{sgn}%
[X^{\prime }\beta ]\text{ almost surely.} \label{d}
\end{equation}%
Thus, intuitively speaking, for any $b$ that is observationally equivalent
to $\beta $, equation (\ref{d}) should also hold for $b$ in place of $\beta $
in the statement. Define%
\begin{eqnarray}
\underline{\Theta } &\equiv &\{b:X^{\prime }b\left[ P(Y=1|X^{\prime }\gamma
)-\tau \right] \geq 0\text{ almost surely for all }\gamma \in \Gamma \},
\label{theta_lower_bar} \\
\overline{\Theta } &\equiv &\{b:X^{\prime }b\left[ P(Y=1|X^{\prime }b)-\tau %
\right] \geq 0\text{ almost surely}\}. \label{theta_upper_bar}
\end{eqnarray}%
By similar arguments used in the proof of Lemma \ref{Lemma 1}, it is
straightforward to show that
\begin{equation}
\underline{\Theta }\subset \Theta =\widetilde{\Theta }\subset \overline{%
\Theta }. \label{e}
\end{equation}%
It is interesting to note that the set inclusion in (\ref{e}) can be strict
as demonstrated in the examples of Appendix \ref{Appendix A}. Namely, the
set $\underline{\Theta }$ is too restrictive and a test of the inequalities
given by (\ref{theta_lower_bar}) may inadequately reject the true parameter
value $\beta $ with probability approaching unity. Moreover, the set $%
\overline{\Theta }$ is not sharp and thus a test of inequalities given by (%
\ref{theta_upper_bar}) would not be consistent against some $b$ values that
are incompatible with the inequality restrictions given by (\ref{theta}).
The identifying relationship in (\ref{e}) can be viewed as a conditional
moment inequality analog of well-known index restrictions in semiparametric
binary response models (e.g., Cosslett (1983), Powell et al.\thinspace
(1989), Han\thinspace (1987), Ichimura (1993), Klein and Spady (1993),
Coppejans (2001)). The main difference between our setup and those models\
is that we allow for partial identification as well as a general form of
heteroskedasticty. It is also noted that to ensure equivalent
characterization of the set $\Theta $, we need two indices unlike ones in
the point-identified cases.
\section{General results for a class of semiparametric models under sign
restrictions \label{Extensions}}
In this section, we extend the dimension reducing characterization approach
of the previous section to a variety of semiparametric models under which
the sign of conditional expectation of a certain transformation of the
outcome is the same as that of the indexing variable. We treat univariate
and multivariate outcome models in a unified abstract setting given as
follows.
Let $\left( Y,X\right) $ be the data vector of an individual observation
where $Y$ is a vector of outcomes and $X$ is a vector of covariates. The
econometric model specifying the distribution of $Y$ conditional on $X$
depends on a finite dimensional parameter vector $\beta $ and is
characterized by the following sign restrictions.
\begin{assumption}
\label{same-sign assumption}For some set $C$ and some known functions $G$
and $H$, and for all $c\in C$, the following statements hold with
probability 1. That is, with probability 1,
\begin{eqnarray}
G(X,c,\beta ) &>&0\Longleftrightarrow E\left( H(Y,c)|X\right) >0,
\label{same_sign g} \\
G(X,c,\beta ) &=&0\Longleftrightarrow E\left( H(Y,c)|X\right) =0,
\label{same_sign e} \\
G(X,c,\beta ) &<&0\Longleftrightarrow E\left( H(Y,c)|X\right) <0.
\label{same_sign s}
\end{eqnarray}
\end{assumption}
Let $\beta $ be the true data generating parameter vector. Assume $\beta \in
$ $\Gamma $ where $\Gamma $ denotes the parameter space. Let $b$ be a
generic element of $\Gamma $. Note that the functions $G$ and $H$ in
Assumption \ref{same-sign assumption} are determined by the specification of
the given model. For example, for the binary choice model of Section \ref%
{Model}, Assumption \ref{same-sign assumption} is fulfilled by taking $%
G(X,c,b)=X^{\prime }b$ and $H(Y,c)=Y-\tau $, both being independent of $c$.
Other examples satisfying Assumption \ref{same-sign assumption} are
presented below.
Define
\begin{equation*}
\Theta _{0}=\{b\in \Gamma :(\ref{same_sign g}),(\ref{same_sign e})\text{ and
}(\ref{same_sign s})\text{ hold with }b\text{ in place of }\beta \text{
almost surely for all }c\in C\}.
\end{equation*}%
Note that $\Theta _{0}$ consists of observationally equivalent parameter
values that conform with the sign restrictions of Assumption \ref{same-sign
assumption}. We impose the following continuity assumption.
\begin{assumption}
\label{continuity}For all $c\in C$ and for all $b\in \Gamma $, the event
that $G(X,c,b)=0$ occurs with zero probability.
\end{assumption}
Under Assumptions \ref{same-sign assumption} and \ref{continuity}, we can
reformulate the identified set $\Theta _{0}$ using weak conditional moment
inequalities given by the set
\begin{equation}
\Theta \equiv \{b\in \Gamma :G(X,c,b)E\left( H(Y,c)|X\right) \geq 0\text{
almost surely for all }c\in C\}. \label{theta general}
\end{equation}
We now derive the equivalent characterization of the set $\Theta $ using
indexing variables. Define
\begin{equation*}
\widetilde{\Theta }\equiv \{b:G(X,c,b)E(H(Y,c)|G(X,c,b),G(X,c,\gamma ))\geq
0\;\text{almost surely for all }\left( \gamma ,c\right) \in \Gamma \times
C\}.
\end{equation*}
The following theorem generalizes the result of Lemma \ref{Lemma 1}.
\begin{theorem}
\label{dimension reducing characterization}Given Assumptions \ref{same-sign
assumption} and \ref{continuity}, we have that $\Theta _{0}=\Theta =%
\widetilde{\Theta }$.
\end{theorem}
We now discuss other examples of semiparametric models that also fit within
the setting of sign restrictions of Assumption \ref{same-sign assumption}.
\subsection*{Example 1: Ordered choice model under quantile independence
restriction}
Consider an ordered response model with $K+1$ choices. Let $\{1,...,K+1\}$
denote the choice index set. The agent chooses alternative $c$ if and only
if
\begin{equation}
\lambda _{c-1}<X^{\prime }\theta +\varepsilon \leq \lambda _{c}
\end{equation}%
where $\lambda _{0}=-\infty <\lambda _{1}<....<\lambda _{K}<\lambda
_{K+1}=\infty $. Let $\lambda \equiv (\lambda _{1},...,\lambda _{K})$ be the
vector of threshold parameters. Let $Y$ be the observed choice. We are
interested in inference of $\beta \equiv (\theta ,\lambda )$. Lee (1992) and
Komarova (2013) studied inference of the ordered response model under
quantile independence restriction. Assume the distribution of $\varepsilon $
conditional on $X$ satisfies Condition \ref{condition 1}. Using this
restriction, we see that Assumption \ref{same-sign assumption} holds with $%
C=\{1,...,K\}$, $H(Y,c)=1\{Y\leq c\}-\tau $ and $G(X,c,b)=\widetilde{X}%
_{c}^{\prime }b$ where $\widetilde{X}_{c}\equiv (-X^{\prime },l_{c}^{\prime
})^{\prime }$ with $l_{c}$ being the $K$ dimensional vector $\left(
l_{c,1},...,l_{c,K}\right) $ such that $l_{c,j}=1$ if $j=c$ and $l_{c,j}=0$
otherwise.
\subsection*{Example 2: Multinomial choice model}
Consider a multinomial choice model with $K$ alternatives. Let $\{1,...,K\}$
denote the choice index set. The utility from choosing alternative $j$ is
\begin{equation}
U{}_{j}=X_{j}{}^{\prime }\beta +\varepsilon {}_{j}
\end{equation}%
where $X_{j}\in \mathbb{R}^{q}$ is a vector of observed choicewise
covariates and $\varepsilon {}_{j}$ is a choicewise preference shock. {The{\
agent chooses alternative }}$k${\ if }$U{}_{k}>U{}_{j}$ for all $j\neq k$.
Let $X$ denote the vector $(X_{1},...,X_{K})$ and $Y$ denote the observed
choice. We assume that the unobservables $\varepsilon \equiv \left(
\varepsilon _{1},...,\varepsilon _{K}\right) $ should satisfy the following
rank ordering property.
\begin{condition}
\label{condition 3}For any pair $\left( s,t\right) $ of choices, we have
that with probability 1,
\begin{equation}
X_{s}{}^{\prime }\beta >X_{t}^{\prime }\beta \text{ }\Longleftrightarrow
\text{ }P(Y=s|X)>P(Y=t|X). \label{rank ordering property}
\end{equation}
\end{condition}
Manski (1975), Matzkin (1993) and Fox (2007) used Condition \ref{condition 3}
as an identifying restriction in the multinomial choice model to allow for
nonparametric unobservables with unknown form of heteroskedasticity. Goeree
et.\thinspace al. (2005, Proposition 5, p.\thinspace 359) showed that it
suffices for Condition \ref{condition 3} to assume that the joint
distribution of $\varepsilon $ conditional on $X$ for almost every
realization of $X$ is exchangeable and has a joint density that is
everywhere positive on $\mathbb{R}^{K}$.
Under Condition \ref{condition 3}, Assumption \ref{same-sign assumption}
holds for this example by taking $C\equiv \{\left( s,t\right) \in
\{1,...,K\}^{2}:s<t\}$, $G(X,s,t,b)=(X_{s}-X_{t})^{\prime }b$ and $%
H(Y,s,t)=1\{Y=s\}-1\{Y=t\}$.
\subsection*{Example 3: Binary choice panel data with fixed effect}
Consider the following binary choice panel data model%
\begin{equation}
Y_{t}=1\{X_{t}^{\prime }\beta +v\geq \varepsilon _{t}\},\text{ }t\in
\{1,...,T\} \label{panel binary choice}
\end{equation}%
where $X_{t}\in \mathbb{R}^{q}$ is a vector of per-period covariates and $v$
is an unobserved fixed effect. Let $X$ be the vector $(X_{1},...,X_{T})$.
Let $Y=(Y_{1},...,Y_{T})$ denote the vector of outcomes. Manski (1987)
imposed the following restrictions on the transitory shocks $\varepsilon
_{t} $.
\begin{condition}
\label{condition 2}The distribution of $\varepsilon _{t}$ conditional on $%
(X,v)$ is time invariant and has a density that is everywhere positive on $%
\mathbb{R}$ for almost every realization of $(X,v)$.
\end{condition}
Under Condition \ref{condition 2} and by Lemma 1 of Manski\thinspace (1987),
Assumption \ref{same-sign assumption} holds for this example by taking $%
C\equiv \{\left( s,t\right) \in \{1,...,T\}^{2}:s<t\}$, $%
G(X,s,t,b)=(X_{s}-X_{t})^{\prime }b$ and $H(Y,s,t)=Y_{s}-Y_{t}$.
\subsection*{Example 4: Ordered choice panel data with fixed effect}
This example is concerned with the ordered choice model of Example 1 in the
panel data context. Let $\{1,...,K+1\}$ denote the choice index set. For
each period $t\in \{1,...,T\}$, we observe the agent's ordered response
outcome $Y_{t}$ that is generated by
\begin{equation}
Y_{t}=\dsum\limits_{j=1}^{K+1}j1\{\lambda _{j-1}<X_{t}^{\prime }\beta
+v+\varepsilon _{t}\leq \lambda _{j}\},
\end{equation}%
where $v$ is an unobserved fixed effect and $\lambda _{0}=-\infty <\lambda
_{1}<....<\lambda _{K}<\lambda _{K+1}=\infty $. Let $X$ and $Y$ denote the
covariate vector $(X_{1},...,X_{T})$ and outcome vector $(Y_{1},...,Y_{T})$,
respectively. Suppose the shocks $\varepsilon _{t}$ also satisfy Manski
(1987)'s stationarity assumption given by Condition \ref{condition 2}. Under
this restriction and by applying the law of iterated expectations, we see
that Assumption \ref{same-sign assumption} holds for this example by taking $%
C=\{\left( k,s,t\right) :k\in \{1,...,K\}$, $\left( s,t\right) \in
\{1,...,T\}^{2}$ such that $s<t\}$, $G(X,k,s,t,b)=(X_{t}-X_{s})^{\prime }b$
and $H(Y,k,s,t)=1\{Y_{s}\leq k\}-1\{Y_{t}\leq k\}$.
\section{The $\left( 1-\protect\alpha \right) $ level confidence set}
\label{sec:inference-CLR}
This section describes how to construct a confidence set \`{a} la CLR. Let $%
v\equiv (x,\gamma ,c)$ and $\mathcal{V}\equiv \{(x,\gamma ,c):x\in \Gamma
_{X},\gamma \in \Gamma ,c\in C\}$. Assume the set $\mathcal{V}$ is nonempty
and compact.\ Define
\begin{eqnarray*}
m_{b}(v) &\equiv &E\left( G(X,c,b)H(Y,c)|G(X,c,b)=G(x,c,b),G(X,c,\gamma
)=G(x,c,\gamma )\right) \\
&&\times f_{b,c,\gamma }\left( G(x,c,b),G(x,c,\gamma )\right),
\end{eqnarray*}%
where the function $f_{b,c,\gamma }$ denotes the joint density function of
the indexing variables $\left( G(X,c,b),G(X,c,\gamma )\right) $. Note that
for all $v\in \mathcal{V}$,
\begin{align*}
& m_{b}(v)\geq 0 \\
& \Longleftrightarrow E\left( G(X,c,b)H(Y,c)|G(X,c,b)=G(x,c,b),G(X,c,\gamma
)=G(x,c,\gamma )\right) \geq 0\text{.}
\end{align*}%
Thus we have that%
\begin{equation}
\widetilde{\Theta }=\{b:m_{b}(v)\geq 0\text{ for all }v\in \mathcal{V}\}.
\label{f}
\end{equation}%
Assume that we observe a random sample of individual outcomes and covariates
$\left( Y_{i},X_{i}\right) _{i=1,...,n}$. For inference on the true
parameter value $\beta $, we aim to construct a set estimator $\widehat{%
\Theta }$ at the $\left( 1-\alpha \right) $ confidence level such that%
\begin{equation}
\liminf_{n\longrightarrow \infty }P(\beta \in \widehat{\Theta })\geq
1-\alpha \text{.} \label{size-result}
\end{equation}
We now delineate an implementation of the set estimator $\widehat{\Theta }$
based on a kernel version of CLR. Let $K(.,.)$ denote a bivariate kernel
function and $h_{n}$ be a bandwidth sequence. To estimate the function $%
m_{b} $, we consider the following kernel type estimator:
\begin{equation}
\widehat{m}_{b}(v)\equiv \left( nh_{n}^{2}\right)
^{-1}\sum\limits_{i=1}^{n}G(X_{i},c,b)H(Y_{i},c)K_{n}(X_{i},v,b), \label{m}
\end{equation}%
where%
\begin{equation}
K_{n}(X_{i},v,b)\equiv K\left( \frac{G(x,c,b)-G(X_{i},c,b)}{h_{n}},\frac{%
G(x,c,\gamma )-G(X_{i},c,\gamma )}{h_{n}}\right) . \label{Kn(X,v,b)}
\end{equation}%
Define
\begin{equation}
T(b)\equiv \inf\nolimits_{v\in \mathcal{V}}\frac{\widehat{m}_{b}(v)}{%
\widehat{\sigma }_{b}(v)}, \label{T(tau)}
\end{equation}%
where
\begin{eqnarray*}
\widehat{\sigma }_{b}^{2}(v) &\equiv &n^{-2}h_{n}^{-4}\sum\limits_{i=1}^{n}%
\widehat{u}_{i}^{2}(b,c,\gamma )G^{2}(X_{i},c,b)K_{n}^{2}(X_{i},v,b), \\
\widehat{u}_{i}\left( b,c,\gamma \right) &\equiv &H(Y_{i},c)-\left[
\sum\limits_{j=1}^{n}K_{n}(X_{j},(X_{i},\gamma ,c),b)\right]
^{-1}\sum\limits_{j=1}^{n}H(Y_{j},c)K_{n}(X_{j},(X_{i},\gamma ,c),b).
\end{eqnarray*}%
For a given value of $b$, we compare the test statistic $T(b)$ to a critical
value to conclude whether there is significant evidence that the
inequalities in (\ref{f}) are violated for some $v\in \mathcal{V}$. By
applying the test procedure to each candidate value of $b$, the estimator $%
\widehat{\Theta }$ is then the set comprising those $b$ values not rejected
under this pointwise testing rule.
Based on the CLR method, we estimate the critical value using simulations.
Let $B$ be the number of simulation repetitions. For each repetition $s\in
\{1,...,B\}$, we draw an $n$ dimensional vector of mutually independently
standard normally distributed random variables which are also independent of
the data. Let $\eta (s)$ denote this vector. For any compact set $\mathsf{V}%
\subseteq \mathcal{V}$, define%
\begin{equation}
T_{s}^{\ast }(b;\mathsf{V})\equiv \inf\nolimits_{v\in \mathsf{V}}\left[
\left( nh^{2}\widehat{\sigma }_{b}(v)\right) ^{-1}\sum\limits_{i=1}^{n}\eta
_{i}(s)\widehat{u}_{i}\left( b,c,\gamma \right) G(X_{i},c,b)K_{n}(X_{i},v,b)%
\right] .
\end{equation}%
We approximate the distribution of $\inf\nolimits_{v\in \mathsf{V}}\left[ (%
\widehat{\sigma }_{b}(v))^{-1}\widehat{m}_{b}(v)\right] $ over $\mathsf{V}%
\subseteq \mathcal{V}$ by that of the simulated quantity $T_{s}^{\ast }(b;%
\mathsf{V})$. Let $\widehat{q}_{p}(b,\mathsf{V})$ be the $p$ level empirical
quantile based on the vector $\left( T_{s}^{\ast }(b,\mathsf{V})\right)
_{s\in \{1,...,B\}}$. One could use $\widehat{q}_{p}(b,\mathcal{V})$ as the
test critical value. However, following CLR,\ we can make sharper inference
by incorporating the data driven inequality selection mechanism in the
critical value estimation. Let
\begin{equation}
\widehat{V}_{n}(b)\equiv \left\{ v\in \mathcal{V}:\widehat{m}_{b}(v)\leq -2%
\widehat{q}_{\gamma _{n}}(b,\mathcal{V})\widehat{\sigma }_{b}(v)\right\} ,
\label{contact set}
\end{equation}%
where $\gamma _{n}\equiv 0.1/\log n$. Compared to $\widehat{q}_{p}(b,%
\mathcal{V})$, use of $\widehat{q}_{\alpha }(b,\widehat{V}_{n}(b))$ as the
critical value results in a test procedure concentrating the inference on
those points of $v$ that are more informative for detecting violation of the
non-negativity hypothesis on the function $m_{b}(v)$. In fact, the CLR test
based on the set $\widehat{V}_{n}(b)$ is closely related to the power
improvement methods such as the contact set idea (e.g.,\thinspace Linton,
Song and Whang\thinspace (2010) and Lee, Song and Whang\thinspace (2014)),
the generalized moment selection approach (e.g.,\thinspace Andrews and
Soares\thinspace (2010), Andrews and Shi\thinspace (2013), and
Chetverikov\thinspace (2011)), and the iterative step-down approach (e.g.,
Chetverikov\thinspace (2013)) employed in the literature on testing moment
inequalities.\medskip
Assume that $0<\alpha \leq 1/2$. Then we construct the $(1-\alpha )$
confidence set $\widehat{\Theta }$ by setting
\begin{equation}
\widehat{\Theta }\equiv \left\{ b\in \Gamma :T(b)\geq \widehat{q}_{\alpha
}(b,\widehat{V}_{n}(b))\right\} . \label{pointwise test}
\end{equation}%
We can establish regularity conditions under which \eqref{size-result} holds
by utilizing the general results of CLR. Since the main focus of this paper
is identification, we omit the technical details for brevity.
\section{Simulation results\label{sec:MC}}
The main purpose of this simulation study is to compare finite-sample
performance of the approach of conditioning on indexing variables with that
of conditioning on full covariates. We use the binary response model set
forth in Section \ref{Model} for the simulation design. The data is
generated according to the following setup:%
\begin{equation}
Y=1\{X^{\prime }\beta \geq \varepsilon \},
\end{equation}%
where $X=(X_{1},...,X_{d})$ is a $d$ dimensional covariate vector with $%
d\geq 2$, and%
\begin{equation*}
\varepsilon =\left[ 1+\sum\nolimits_{k=1}^{d}X_{k}^{2}\right] ^{1/2}\xi
\end{equation*}%
where $\xi $ is standard normally distributed and independent of $X$. Let $%
\widetilde{X}=(X_{2},...,X_{d})$ be a $\left( d-1\right) $ dimensional
vector of mutually independently and uniformly distributed random variables
on the interval $[-1,1]$. The covariate $X_{1}$ is specified by%
\begin{equation*}
X_{1}=\func{sgn}(X_{2})U,
\end{equation*}%
where $U$ is a uniformly distributed random variable on the interval $[0,1]$
and is independent of $(\widetilde{X},\xi )$. We set $\beta _{1}=1$ and $%
\beta _{k}=0$ for $k\in \{2,...,d\}$. The preference parameter space is
specified to be%
\begin{equation}
\Gamma \equiv \{b\in \mathbb{R}^{d}:b_{1}=1,\left( b_{2},...,b_{d}\right)
\in \lbrack -1,1]^{d-1}\}.
\end{equation}%
Under this setup, the sign of the true index $X^{\prime }\beta =X_{1}$ is
determined by $X_{2}$. By inspecting the formulation (\ref{theta_sign}), the
identified set $\Theta $ is thus given by%
\begin{equation}
\Theta =\{b\in \Gamma :b_{2}\geq 0\text{ and }b_{k}=0\text{ for }k\in
\{3,...,d\}\}\text{.} \label{identified set}
\end{equation}
Recall that this simulation design also satisfies the general framework of
Section \ref{Extensions} by taking $G(X,c,b)=X^{\prime }b$ and $H(Y,c)=Y-0.5$%
. Let $Index$ and $Full$ be shorthand expressions for the index formulated
and full covariate approaches, respectively. We implement the $Index$
approach using the inference procedure of Section \ref{sec:inference-CLR}.
We compute the term $K_{n}(X,v,b)$ using%
\begin{equation*}
K_{n}(X,v,b)=\widetilde{K}\left( \frac{x^{\prime }b-X^{\prime }b}{\widehat{s}%
(X^{\prime }b)h_{n}}\right) \widetilde{K}\left( \frac{x^{\prime }\gamma
-X^{\prime }\gamma }{\widehat{s}(X^{\prime }\gamma )h_{n}}\right)
\end{equation*}%
where $v=(x,\gamma )$, $\widetilde{K}(\cdot )$ is the univariate biweight
kernel function defined by
\begin{equation*}
\widetilde{K}(u)\equiv \frac{15}{16}\left( 1-u^{2}\right) ^{2}1\left\{
\left\vert u\right\vert \leq 1\right\} ,
\end{equation*}%
and $\widehat{s}(W)$ denotes the estimated standard deviation for the random
variable $W$. The bandwidth sequence $h_{n}$ is specified by
\begin{equation}
h_{n}=c_{Index}n^{-1/5} \label{h_index}
\end{equation}%
where $c_{Index}$ is a bandwidth scale. The rate considered in (\ref{h_index}%
) corresponds to the undersmoothing specification under the assumption that
the true conditional expectation function is twice continuously
differentiable.
The $Full$ approach is based on inversion of the kernel-type CLR test for
the inequalities that $m_{b,Full}(x)\geq 0$ for all $x\in \Gamma _{X}$,
where
\begin{equation}
m_{b,Full}(x)\equiv E\left( X^{\prime }b\left( Y-0.5\right) |X=x\right)
f_{X}\left( x\right) \label{moment inequality for full covariates}
\end{equation}%
and $f_{X}$ denotes the joint density of $X$. As in the $Index$ approach, we
consider the kernel type estimator
\begin{equation}
\widehat{m}_{b,Full}(x)\equiv \left( nh_{n}^{d}\right)
^{-1}\sum\limits_{i=1}^{n}X_{i}^{\prime }b\left( Y_{i}-0.5\right)
K_{n,Full}(X_{i},x),
\end{equation}%
where%
\begin{equation}
K_{n,Full}(X_{i},x)\equiv \prod\nolimits_{k=1}^{d}\widetilde{K}_{Full}\left(
\frac{x_{k}-X_{i,k}}{\widehat{s}(X_{i,k})h_{n,Full}}\right) ,
\end{equation}%
$\widetilde{K}_{Full}(\cdot )$ is the univariate $p$th order biweight kernel
function (see Hansen\thinspace (2005)), and $h_{n,Full}$ is a bandwidth
sequence specifying by
\begin{equation}
h_{n,Full}=c_{Full}n^{-r} \label{bandwidth rate under Full approach}
\end{equation}%
where $c_{Full}$ and $r$ denote the bandwidth scale and rate, respectively.
The test statistic for the $Full$ approach is given by
\begin{equation}
T_{Full}(b)\equiv \inf\nolimits_{x\in \Gamma _{X}}\frac{\widehat{m}%
_{b,Full}(x)}{\widehat{\sigma }_{b,Full}(x)},
\end{equation}%
where%
\begin{eqnarray*}
\widehat{\sigma }_{b,Full}^{2}(x) &\equiv
&n^{-2}h_{n,Full}^{-2d}\sum\limits_{i=1}^{n}\widehat{u}_{i,Full}^{2}\left(
X_{i}^{\prime }b\right) ^{2}K_{n,Full}^{2}(X_{i},x), \\
\widehat{u}_{i,Full} &\equiv &Y_{i}-\left[ \sum%
\limits_{j=1}^{n}K_{n,Full}(X_{j},X_{i})\right] ^{-1}\sum%
\limits_{j=1}^{n}Y_{j}K_{n,Full}(X_{j},X_{i}).
\end{eqnarray*}%
We computed the simulated CLR test critical value that also embedded the
inequality selection mechanism. By comparing $T_{Full}(b)$ to the test
critical value, we constructed under the $Full$ approach the confidence set
that also satisfies (\ref{size-result}).
The nominal significance level $\alpha $ was set to be 0.05. Let $\widehat{%
\Theta }_{Index}$ and $\widehat{\Theta }_{Full}$ denote the $\left( 1-\alpha
\right) $ level confidence sets constructed under the $Index$ and $Full$
approaches, respectively. For $s\in \{Index,Full\}$ and for a fixed value of
$b$, we calculated $\widehat{P}_{s}(b)$, which is the simulated
finite-sample probability of the event $b\notin \widehat{\Theta }_{s}$ based
on 1000 simulation repetitions. For each repetition, we generated $n\in
\left\{ 250,500,1000\right\} $ observations according to the data generating
design described above. We used 4000 simulation draws to calculate $\widehat{%
q}_{\alpha }(b,\widehat{V}_{n}(b))$ for the $Index$ approach and to estimate
the CLR test critical value for the $Full$ approach. We implemented for the $%
Full$ approach the minimization operation based on grid search over 1000
grid points of $x$ randomly drawn from the joint distribution of $X$. For
the $Index$ approach, the minimization was implemented by grid search over
1000 grid points of $(x,\gamma )$ for which $x$ was also randomly drawn from
the distribution of $X$, and $\gamma $ was drawn from uniform distribution
on the space $\Gamma $ and independently of the search direction in $x$.
We conducted simulations for $d\in \{3,4,5,10\}$. For the $Full$ approach,
both the bandwidth rate $r$ and the order $p$\ of $\widetilde{K}_{Full}$
depend on the covariate dimension. These were specified to fulfill the
regularity conditions for the CLR kernel type conditional moment inequality
tests (see discussions on Appendix F of CLR\thinspace (pp.\thinspace 7-9,
Supplementary Material)). Note that for $b\in \Theta $, $\widehat{P}%
_{Index}\left( b\right) $ ($\widehat{P}_{Full}\left( b\right) $) is
simulated null rejection probability of the corresponding CLR test under the
$Index$ ($Full$) approach, whereas for $b\notin \Theta $, it is the CLR test
power. For simplicity, we computed $\widehat{P}_{Index}(b)$ and $\widehat{P}%
_{Full}(b)$ for $b$ values specified as $b=\left(
b_{1},b_{2},...,b_{d}\right) $ where $b_{1}=1$, $b_{2}\in \{0,0.5,-1\}$, $%
b_{k}=0$ for $k\in \{3,..,d\}$. For these candidate values of $b$, we
experimented over various bandwidth scales to determine the value of $%
c_{Index}$ ($c_{Full}$) with which the $Index$ ($Full$) approach exhibits
the best overall performance in terms of its corresponding CLR test size and
power. Table 1 presents the settings of $r$ and $p$ and the chosen bandwidth
scales $c_{Index}$ and $c_{Full}$ in the simulation.
\begin{center}
\begin{tabular}{lllll}
\multicolumn{5}{c}{Table 1: Settings of $r,p,c_{Index}$ and $c_{Full}$} \\
\hline\hline
$d$ & 3 & 4 & 5 & 10 \\
$r$ & 11/70 & 1/9 & 21/220 & 1/21 \\
$p$ & 2 & 4 & 4 & 6 \\
\multicolumn{5}{c}{sample size $250$} \\
$c_{Index}$ & 3.05 & 3.45 & 3.7 & 4.1 \\
$c_{Full}$ & 2.65 & 4.8 & 5.6 & 8.35 \\
\multicolumn{5}{c}{sample size $500$} \\
$c_{Index}$ & 2.55 & 2.95 & 3.05 & 3.75 \\
$c_{Full}$ & 2.35 & 4.3 & 4.9 & 8 \\
\multicolumn{5}{c}{sample size $1000$} \\
$c_{Index}$ & 2 & 2.5 & 2.75 & 3.5 \\
$c_{Full}$ & 2.15 & 3.95 & 4.45 & 7.7 \\ \hline
\end{tabular}
\end{center}
Tables 2 and 3 present the simulation results that compare performance of
the $Index$ and $Full$ approaches.
\begin{center}
\begin{tabular}{lllllllll}
\multicolumn{9}{l}{Table 2: Simulated null rejection probabilities} \\
\hline\hline
$d$ & 3 & 4 & 5 & 10 & 3 & 4 & 5 & 10 \\ \hline
& \multicolumn{4}{c}{$b_{2}=0$} & \multicolumn{4}{c}{$b_{2}=0.5$} \\ \hline
\multicolumn{9}{c}{sample size $250$} \\
$\widehat{P}_{Index}$ & .034 & .029 & .034 & .050 & .051 & .054 & .052 & .052
\\
$\widehat{P}_{Full}$ & .031 & .043 & .046 & .050 & .050 & .053 & .052 & .055
\\
\multicolumn{9}{c}{sample size $500$} \\
$\widehat{P}_{Index}$ & .030 & .036 & .039 & .042 & .051 & .054 & .052 & .050
\\
$\widehat{P}_{Full}$ & .032 & .034 & .043 & .044 & .049 & .048 & .054 & .053
\\
\multicolumn{9}{c}{sample size $1000$} \\
$\widehat{P}_{Index}$ & .047 & \multicolumn{1}{c}{.045} & .041 & .048 & .054
& \multicolumn{1}{c}{.053} & .051 & .054 \\
$\widehat{P}_{Full}$ & .029 & .044 & .041 & .042 & .046 & .051 & .047 & .051
\\ \hline
\end{tabular}
\bigskip
\begin{tabular}{llll|lll|lll}
\multicolumn{10}{l}{Table 3: Simulated test power for $b_{2}=-1$ ($\mathit{%
ratio\equiv }\widehat{P}_{Index}/\widehat{P}_{Full}$)} \\ \hline\hline
$d$ & $\widehat{P}_{Index}$ & $\widehat{P}_{Full}$ & $\mathit{ratio}$ & $%
\widehat{P}_{Index}$ & $\widehat{P}_{Full}$ & $\mathit{ratio}$ & $\widehat{P}%
_{Index}$ & $\widehat{P}_{Full}$ & $\mathit{ratio}$ \\
& \multicolumn{3}{c|}{$n=250$} & \multicolumn{3}{|c|}{$n=500$} &
\multicolumn{3}{|c}{$n=1000$} \\
3 & .583 & .601 & .970 & .771 & .731 & 1.05 & .927 & .828 & 1.11 \\
4 & .541 & .530 & 1.02 & .733 & .653 & 1.12 & .868 & .758 & 1.14 \\
5 & .500 & .393 & 1.27 & .699 & .624 & 1.12 & .806 & .738 & 1.09 \\
10 & .409 & .216 & 1.89 & .474 & .212 & 2.23 & .520 & .225 & 2.31 \\ \hline
\end{tabular}
\end{center}
From Table 2, we can see that all $\widehat{P}_{Index}$ and $\widehat{P}%
_{Full}$ values in all the simulation cases are either below or close to the
nominal level 0.05 with the maximal value being 0.055 and occurring for the $%
Full$ approach with sample size 250 under the setup of $d=10$ and $b_{2}=0.5$%
. For both methods, there is slight over-rejection for the case of $%
b_{2}=0.5 $. At the true data generating value ($b_{2}=0$), both $\widehat{P}%
_{Index}$ and $\widehat{P}_{Full}$ are well capped by 0.05 and the
confidence sets $\widehat{\Theta }_{Index}$ and $\widehat{\Theta }_{Full}$
can hence cover the true parameter value with probability at least 0.95 in
all simulations.
For the power of the test, we compare the $Index$ and $Full$ approaches
under the same covariate configuration. Table 3 indicates that power of the $%
Index$ approach dominates that of the $Full$ approach in almost all
simulation configurations. Moreover, at larger sample size ($n=1000$), power
of the $Index$ approach exceeds 0.8 in almost all cases whereas that of the $%
Full$ approach does so only for the case of $d=3$. The power difference
between these two approaches tends to increase as either the sample size or
the covariate dimension increases. For the case of $d=10$, it is noted that
there is substantial power gain from using the $Index$ approach. For this
covariate specification, the curse of dimensionality for the $Full$ approach
is quite apparent because the corresponding $\widehat{P}_{Full}$ values vary
only slightly across sample sizes. In short, the simulation results suggest
that the $Index$ approach may alleviate the problem associated with the
curse of dimensionality and we could therefore make sharper inference by
using the $Index$ approach for a model with a high dimensional vector of
covariates.
\section{Conclusions\label{sec:conclusions}}
This paper studies inference of preference parameters in semiparametric
discrete choice models when these parameters are not point identified and
the identified set is characterized by a class of conditional moment
inequalities. Exploring the semiparametric modeling restrictions, we show
that the identified set can be equivalently formulated by moment
inequalities conditional on only two continuous indexing variables. Such
formulation holds regardless of the covariate dimension, thereby breaking
the curse of dimensionality for nonparametric inference of the underlying
conditional moment functions. We also extend this dimension reducing
characterization result to a variety of semiparametric models under which
the sign of conditional expectation of a certain transformation of the
outcome is the same as that of the indexing variable.
We note that moment inequalities (\ref{theta general}) for the general
framework of Section \ref{Extensions} can also be applied to monotone
transformation models (e.g., see Abrevaya\thinspace (1999, 2000),
Chen\thinspace (2010) and Pakes and Porter\thinspace (2014, Section 2)).
Hence, our dimension reducing approach would also be useful in that context.
There is a growing number of inference methods for conditional moment
inequalities. The instrumental variable approach of Andrews and
Shi\thinspace (2013) does not rely on nonparametric estimation of
conditional expectation. Nevertheless, the instruments required to convert
the conditional moment inequalities to unconditional ones increase with the
covariate dimension. In addition to the Andrews-Shi and CLR approaches,
other existing inference procedures include Armstrong and Chan (2013),
Armstrong (2014a, 2015), Chetverikov (2011), Lee, Song, and Whang\thinspace
(2013, 2014) and Menzel\thinspace (2014) among others. The performance of
all of these methods are related to the dimension of conditioning variables.
Armstrong (2014b, see Tables 1 and 2) gives the local power properties of
popular approaches in the literature and shows that the local power
decreases as the dimension of conditional variables increases in each case
that he considers. Thus, the curse of dimensionality problem is not limited
to a particular test statistic. It will be an interesting further research
topic to incorporate these alternative methods with the dimension reducing
characterization result for set inference of the class of semiparametric
models studied in Section \ref{Extensions} of this paper.
|
{'timestamp': '2016-04-12T02:15:57', 'yymm': '1506', 'arxiv_id': '1506.05275', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05275'}
|
arxiv
|
\section{Introduction}
Swing-twist decomposition of rotations is commonly used in context of humanoid motion planning. Consider movement of an arm reaching some predefined position. In order to displace it properly, a controller calculates twist factor of the corresponding rotation. Having this factor computed, a controller is then able to apply some corrections to the motion so that the arm is not unnaturally twisted during the motion. \textbf{Swing-twist decomposition} is an inherent part of a correction algorithm. It allows one to decompose an arbitrary rotation into a swing part (tilt of a given axis) and a twist part (rotation around a given axis). In this paper the decomposition is derived and discussed in terms of Clifford algebra.
Swing-twist decomposition has already been considered for a few decades. Different authors have obtained equivalent formulas, in particular for quaternion algebra. Current literature tends to neglect a deeper consideration on the spin-twist decomposition. There is wide range of publications on humanoid motion planning. Most of these works relate to swing-twist decomposition in some way. In the paper, the most revelant approaches to swing-twist decomposition are quoted and compared. Starting from the recent PhD dissertation by Huyghe (\cite{huyghe}, 2011), the swing-twist decomposition is introduced in quaterion algebra by a proposed therein projection operator. Unfortunately, the origin of the projection operator is not enough explained. In two previous papers, Baerlocher (\cite{baerlocher}, 2001) and Baerlocher, Boulic (\cite{baerlocher_boulic}, 2000) investigate joint boundaries for ball-and-socket joints using swing-twist decomposition. Grassia (\cite{grassia}, 1998) discusses features of a swing-twist decomposition in terms of \textbf{an exponential map}. However, the author does not present any related formula for the decomposition. A classic work by Korein (\cite{korein}, 1984) contains most of the initial results on body positioning and joint motion. Among others the work uses swing-twist decomposition of rotations to constrain movement of an elbow.
None of these are generalized to Clifford or geometric algebras which has deeper consequences than previous results. In this paper the swing-twist decomposition is derived as an inverse of a formula expressing the set of rotations which move a given initial vector to cover a given terminal one.
\section{Existing and related solutions}
\label{section_existing_and_related_solutions}
Swing-twist decomposition splits a given rotation in two parts: a swing part and a twist part. A schematic view of a limb rotating with a ball joint is presented in figure \ref{img:joint}.
\begin{figure}[ht]
\centering
\includegraphics[width=8cm]{joint}
\caption{A limb with a ball joint}
\label{img:joint}
\end{figure}
By \textbf{zero twist reference vector} one refers to a base vector with respect to which the swing-twist decomposition is performed. Usually, this is the bone of a rotating limb.
There are several existing approaches. These solutions differ in terms of performance, complexity and result exactness.
\subsection{Direct method}
For quaternions one can make the following argument. Let $q \in \mathbb{H}$ be a quaternion and $v$ be a zero-twist reference vector. In case of twist-after-swing type of decomposition (see section \ref{sec:two_st_decompositions}) the initial vector becomes the given $v$ vector and the terminal vector is $w = q v q^*$. Schematic view is presented in figure \ref{img:direct_decomposition}.
\begin{figure}[ht]
\centering
\includegraphics[width=3cm]{direct_decomposition}
\caption{A direct decomposition of a quaternion}
\label{img:direct_decomposition}
\end{figure}
Swing quaternion can be calculated with an axis angle representation of the quaternion. Here, the axis is a normalized vector perpendicular to $v$ and $w$ and the angle is equal to the angle between $v$ and $w$ so:
\begin{align*}
& n = \frac{v \times w}{\|v \times w\|} \\
& \cos(\alpha) = v \cdot w \\
& q_s = \cos(\alpha / 2) + \sin(\alpha / 2) (n_x \mathbf{i} + n_y \mathbf{j} + n_z \mathbf{k})
\end{align*}
Twist quaternion is calculated by the following inversion formula:
\begin{align*}
& q = q_t q_s \Longrightarrow q_t = q q_s^{-1} \\
& q_t = q (\cos(\alpha / 2) - \sin(\alpha / 2) (n_x \mathbf{i} + n_y \mathbf{j} + n_z \mathbf{k}))
\end{align*}
In this formulation both trigonometric and inverse trigonometric functions are used. It is a practical disadvantage since it requires computationally expensive functions which can also face some accuracy issues.
\subsection{Huyghe's method}
Huyghe uses swing-after-twist decomposition type. First a simplified formula is derived which is a decomposition of an arbitrary quaternion $q$ into a product
\begin{equation*}
q = q_s q_t
\end{equation*}
with respect to a constant Z-axis aligned zero-twist reference vector (called there "a twist axis"). With the following coordinates
\begin{align*}
q & = w + x \textbf{i} + y \textbf{j} + z \textbf{k} \\
q_t & = w_t + z_t \textbf{k} \\
q_s & = w_s + x_s \textbf{i} + y_s \textbf{j}
\end{align*}
the author shows using some algebraic transformations that the decomposition is
\begin{align*}
w_t & = \frac{\pm w}{\sqrt{w^2 + z^2}} \\
z_t & = \frac{\pm z}{\sqrt{w^2 + z^2}} \\
w_s & = w_t w + z_t z \\
x_s & = w_t x - z_t y \\
y_s & = w_t y + z_t x
\end{align*}
It must be noted that some of the results were not rigorously stated. It particular, scenarios when some coefficients are equal to zero are not discussed separately which leads to possible division by zero.
In the second part of the thesis, Huyghe derives a generalized formula for swing-twist decomposition. Assume that axis-angle representation of quaternions is
\begin{align*}
q_s = [w_s, v_s] = [\cos(\frac{\sigma}{2}), u_s \sin(\frac{\sigma}{2})] \\
q_t = [w_t, v_t] = [\cos(\frac{\tau}{2}), u_t \sin(\frac{\tau}{2})]
\end{align*}
Multiplying both quaternions one writes
\begin{equation} \label{eqn:huyghe_formula_one}
q = q_s q_t = [ w_s w_t - v_t \cdot v_s, w_s v_t + w_t v_s + v_s \times v_t ]
\end{equation}
Huyghe notes that the axes $v_s$ and $v_t$ are perpendicular so formula \eqref{eqn:huyghe_formula_one} simplifies to
\begin{equation} \label{eqn:huyghe_formula_two}
q = [ w_s w_t, w_s v_t + w_t v_s + v_s \times v_t ]
\end{equation}
Next, the author introduces a new quaternion $q_p$ (no origin is provided) which is "a projected version of the initial quaternion $q$ onto the twist axis" (\cite{huyghe})
\begin{align*}
q_p & = [w, (v \cdot u_t) u_t] \\
& = [w_s w_t, (w_s v_t \cdot u_t + w_t v_s \cdot u_t + (v_s \times v_t) \cdot u_t ) u_t ] \\
& = [w_s w_t, w_s \|u_t\|^2 \sin(\frac{\tau}{2}) u_t] \\
& = [w_s w_t, w_s v_t]
\end{align*}
Normalization of quaternion $q_p$ gives
\begin{equation*}
\frac{q_p}{\|q_p\|} = \frac{[w_s w_t, w_s v_t]}{\sqrt{w_s^2 w_t^2 + w_s^2 \|v_t\|^2}} = \frac{w_s [w_t, v_t]}{w_s \sqrt{w_t^2 + \|v_t\|^2}} = q_t
\end{equation*}
which in result turns out to be twist quaternion. Note that in the above equation Huyghe does not consider $w_s = 0$ which is a drawback. Remaining swing quaternion is calculated from
\begin{equation*}
q_s = q q_t^*
\end{equation*}
which completes the decomposition.
\section{Preliminaries}
The presented results relate to $\mathrm{C}\ell_3 := \mathrm{C}\ell_{3,0}(\R)$ - Clifford algebra of 3-dimensional real space. Herein, a spinor is given by $s = a + b \mathbf{e}_{12} + c \mathbf{e}_{23} + d \mathbf{e}_{31} \in \Spin(3)$ and a vector is given by $v = x \mathbf{e}_0 + y \mathbf{e}_1 + z \mathbf{e}_2$. A rotation of a vector is given by Clifford multiplication:
\begin{equation*}
v' = s v s^{-1}
\end{equation*}
for an arbitrary vector $v$ and a spinor $s$.
In this paper ${\square}^{-1}$ denotes the inverse of a spinor. In case of $\Spin(3)$ it is equivalent to conjugation:
\begin{equation*}
s^{-1} = \tilde{s} = a - b \mathbf{e}_{12} - c \mathbf{e}_{23} - d \mathbf{e}_{31}
\end{equation*}
A spinor can be written as a sum of its scalar and bivector parts:
\begin{equation*}
s = [s]_0 + [s]_2
\end{equation*}
where $\quad [s]_0 \in \bigwedge_0 \R^3$ and $[s]_2 \in \bigwedge_2 \R^3$. In several places the Hodge star $\star$ operator is used. In an orthonormal basis it is defined as
\begin{equation*}
\star (\mathbf{e}_1 \wedge \mathbf{e}_2 \wedge \cdots \wedge \mathbf{e}_k) = \mathbf{e}_{k+1} \wedge \mathbf{e}_{k+2} \wedge \cdots \wedge \mathbf{e}_n
\end{equation*}
but in this paper it is used only in relation to the bivector part of a spinor. In this case the formula can be simplified to:
\begin{equation*}
\star [s]_2 = -\mathbf{e}_{123} [s]_2 \in \bigwedge_1 \R^3
\end{equation*}
A convenient notation is used for normalized vectors. For a given non-zero vector $v \ne 0$, the \textbf{normalization function} is defined as:
\begin{equation*}
\N(v) = \frac{v}{\|v\|}
\end{equation*}
where $\|v\| = \sqrt{v \cdot v} = \sqrt{v v}$ is the length of vector $v$. Note that it is impossible to define a normalized zero vector. Let $s$ be a spinor and $v$ be a vector in $\mathrm{C}\ell_3$. The rotation $s v s^{-1}$ of the vector $v$ by the spinor $s$ gives a rotated vector $v' = x' \mathbf{e}_0 + y' \mathbf{e}_1 + z' \mathbf{e}_2$ which is equal to:
\begin{align} \label{eqn:spinor_rotation_formula}
\left\{
\begin{aligned}
& x' = (a^2 - b^2 + c^2 - d^2) x + 2 y (a b + c d) + 2 z (b c - a d) \\
& y' = (a^2 - b^2 - c^2 + d^2) y + 2 x (c d - a b) + 2 z (b d + a c) \\
& z' = (a^2 + b^2 - c^2 - d^2) z + 2 x (b c + a d) + 2 y (b d - a c)
\end{aligned}
\right.
\end{align}
This paper if organized as follows: first we obtain the complete set of spinors which do not rotate a given non-zero vector. Next we derive a spinor which rotates a given initial vector to cover a given terminal vector. By combining these two formulas we derive a formula which represents an arbitrary rotation by initial and terminal vectors (swing factor) together with axis rotation (twist factor). Finally swing-twist representation is inversed for an arbitrary rotation and a unique swing-twist decomposition of a spinor is obtained. In conclusion some applications of the proposed decomposition are presented.
\section{The set of spinors which do not rotate a given vector}
In this section we assume that $v$ is a non-zero vector. The set of all spinors $s \in \Spin(3)$ which do not rotate the given vector $v$ will be called an invariant set of spinors for a given vector. The following theorem will be proved:
\begin{proposition}[The set of spinors which do not rotate a given vector] \label{thm:proposition_twist_formula}
Let $v$ be a non-zero vector in $\mathrm{C}\ell_3$. The complete set of spinors $s$ such that $s v s^{-1} = v$ is determined by:
\begin{equation*}
s = \exp(\mathbf{e}_{123} \alpha \N(v))
\end{equation*}
for all $\alpha \in [0; 2 \pi)$. For a given element $a \in \mathrm{C}\ell_3$ exponential of $a$ is defined as:
\begin{equation*}
\exp(a) := \sum_{k=0}^\infty \frac{a^k}{k!}
\end{equation*}
\end{proposition}
\begin{proof}
The proof will use the coordinate expansion of spinor rotation formula and the normalization identity giving the following set of equations:
\begin{align} \label{eqn:spinor_automorphism_set}
\left\{
\begin{aligned}
& (a^2 - b^2 + c^2 - d^2 -1) x + 2 y (a b + c d) + 2 z (b c - a d) = 0 \\
& (a^2 - b^2 - c^2 + d^2 -1) y + 2 x (c d - a b) + 2 z (b d + a c) = 0 \\
& (a^2 + b^2 - c^2 - d^2 -1) z + 2 x (b c + a d) + 2 y (b d - a c) = 0 \\
& a^2 + b^2 + c^2 + d^2 - 1 = 0
\end{aligned}
\right.
\end{align}
The key idea is to extract simple relations from \ref{eqn:spinor_automorphism_set} yet avoiding high order equations. Denote $Q_i$ as the left side of $i$th equation of \ref{eqn:spinor_automorphism_set}. A valid solution $(a, b, c, d)$ must satisfy the following equation:
\begin{equation} \label{eqn:spinor_automorphism_set_resolving_equation}
x Q_1 + y Q_2 + z Q_3 - (x^2 + y^2 + z^2) Q_4 = 0
\end{equation}
formula \eqref{eqn:spinor_automorphism_set_resolving_equation} can be expanded:
\begin{align*}
& (a^2 - b^2 + c^2 - d^2 - 1) x^2 + 2 x y (a b + c d) + 2 x z (b c - a d) \\
& + (a^2 - b^2 - c^2 + d^2 - 1) y^2 + 2 x y (c d - a b) + 2 y z (b d + a c) \\
& + (a^2 + b^2 - c^2 - d^2 - 1) z^2 + 2 x z (b c + a d) + 2 y z (b d - a c) \\
& - (x^2 + y^2 + z^2) (a^2 + b^2 + c^2 + d^2 - 1) = 0 \\
& (a^2 - b^2 + c^2 - d^2 - 1 - a^2 - b^2 - c^2 - d^2 + 1) x^2 + 2 x y c d + 2 x z b c \\
& + (a^2 - b^2 - c^2 + d^2 - 1 - a^2 - b^2 - c^2 - d^2 + 1) y^2 + 2 x y c d + 2 y z b d \\
& + (a^2 + b^2 - c^2 - d^2 - 1 - a^2 - b^2 - c^2 - d^2 + 1) z^2 + 2 x z b c + 2 y z b d = 0 \\
& (b^2 + d^2) x^2 + (b^2 + c^2) y^2 + (c^2 + d^2) z^2 - 2 x y c d - 2 x z b c - 2 y z b d = 0 \\
& (b x - c z)^2 + (d x - c y)^2 + (b y - d z)^2 = 0
\end{align*}
which implies that the three identities must hold:
\begin{equation} \label{eqn:spinor_automorphism_set_identities}
b x = c z, \quad d x = c y, \quad b y = d z
\end{equation}
Next, identities \eqref{eqn:spinor_automorphism_set_identities} are plugged into the first equation of \ref{eqn:spinor_automorphism_set} and simplified using the identity $a^2 + b^2 + c^2 + d^2 = 1$:
\begin{align*}
& 2 (a^2 + c^2 - 1) x + 2 y a b + 2 y c d + 2 z b c - 2 z a d = 0 \\
& 2 (a^2 + c^2 - 1) x + 2 z a d + 2 y c d + 2 z b c - 2 z a d = 0 \\
& (a^2 + c^2 - 1) x + y c d + z b c = 0
\end{align*}
When $x \ne 0$ there is
\begin{align}
& (a^2 + c^2 - 1) x + y c d + z b c = 0 \notag \\
& (a^2 + c^2 - 1) x + y c \frac{c y}{x} + z \frac{c z}{x} c = 0 \notag \\
& (a^2 + c^2 - 1) x^2 + y^2 c^2 + z^2 c^2 = 0 \notag \\
& c^2 (x^2 + y^2 + z^2) = x^2 (1 - a^2) \notag \\
& c = \sigma x \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}} \label{eqn:spinor_automorphism_set_general_c}
\end{align}
for $\sigma \in \{-1, 1\}$. In the other case, when $x = 0$ is is easy to observe from \eqref{eqn:spinor_automorphism_set_identities} that
\begin{align*}
c y = 0, \quad c z = 0
\end{align*}
plugging the above to \eqref{eqn:spinor_automorphism_set}:
\begin{align} \label{eqn:spinor_automorphism_set_extract_for_z_0}
\left\{
\begin{aligned}
& y a b - z a d = 0 \\
& (a^2 - b^2 - c^2 + d^2 -1) y + 2 z b d = 0 \\
& (a^2 + b^2 - c^2 - d^2 -1) z + 2 y b d = 0 \\
& a^2 + b^2 + c^2 + d^2 - 1 = 0
\end{aligned}
\right.
\end{align}
replace in the second and the third equation of \eqref{eqn:spinor_automorphism_set_extract_for_z_0} with $b y = d z$:
\begin{align} \label{eqn:spinor_automorphism_set_extract_for_z_0_simplified}
& \left\{
\begin{aligned}
& (a^2 - b^2 - c^2 + d^2 -1) y + 2 b^2 y = 0 \\
& (a^2 + b^2 - c^2 - d^2 -1) z + 2 d^2 z = 0
\end{aligned}
\right. \\
& \left\{
\begin{aligned}
& (a^2 + b^2 - c^2 + d^2 -1) y = 0 \\
& (a^2 + b^2 - c^2 + d^2 -1) z = 0
\end{aligned}
\right.
\end{align}
it is impossible that both $y = 0$ and $z = 0$ since in this case $x = 0$ and $\|v\| \ne 0$ by assumption. Hence, from any of the above equations there must be:
\begin{equation*}
a^2 + b^2 - c^2 + d^2 -1 = 0
\end{equation*}
subtracting from both sides of this equation the fourth equation of \eqref{eqn:spinor_automorphism_set_extract_for_z_0} one gets immediately:
\begin{align} \label{eqn:spinor_automorphism_set_when_x_0_then_c_0}
& (a^2 + b^2 - c^2 + d^2 -1) - (a^2 + b^2 + c^2 + d^2 - 1) = -2 c^2 = 0 \\
& \Longrightarrow c = 0
\end{align}
which is also covered by the general solution \eqref{eqn:spinor_automorphism_set_general_c} thus it can be assumed that \eqref{eqn:spinor_automorphism_set_general_c} is the only solution. Remaining spinor components are derived as follows. When $x \ne 0$ one writes using identities \eqref{eqn:spinor_automorphism_set_identities}:
\begin{align}
b & = \frac{z}{x} \sigma x \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}} = \sigma z \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}} \label{eqn:spinor_automorphism_set_general_b} \\
d & = \frac{y}{x} \sigma x \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}} = \sigma y \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}} \label{eqn:spinor_automorphism_set_general_d}
\end{align}
in the case when $x = 0$ from \eqref{eqn:spinor_automorphism_set_when_x_0_then_c_0} there is $c = 0$. To calculate $b$ and $d$ one rewrites \eqref{eqn:spinor_automorphism_set_extract_for_z_0}:
\begin{align} \label{eqn:spinor_automorphism_set_x_0}
\left\{
\begin{aligned}
& y a b - z a d = 0 \\
& (a^2 - b^2 + d^2 -1) y + 2 z b d = 0 \\
& (a^2 + b^2 - d^2 -1) z + 2 y b d = 0 \\
& a^2 + b^2 + d^2 - 1 = 0
\end{aligned}
\right.
\end{align}
Consider the case $y \ne 0$ then from \eqref{eqn:spinor_automorphism_set_identities} there is $b = \frac{z}{y} d$. Plugging this identity into the fourth equation of \eqref{eqn:spinor_automorphism_set_x_0} one obtains:
\begin{align*}
& a^2 - 1 + (\frac{z^2}{y^2} + 1) d^2 = 0 \\
& (a^2 - 1) y^2 + (x^2 + y^2 + z^2) d^2 = 0 \\
& d = \sigma y \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}}
\end{align*}
and from $b = \frac{z}{y} d$ there is:
\begin{equation*}
b = \frac{z}{y} \sigma y \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}} = \sigma z \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}}
\end{equation*}
In the case when $y = 0$ there must be $z \ne 0$ since $\|v\| \ne 0$. Thus, from \eqref{eqn:spinor_automorphism_set_identities} there is $d = \frac{y}{z} b$. Plugging this identity into the fourth equation of \eqref{eqn:spinor_automorphism_set_x_0} one obtains:
\begin{align*}
& a^2 - 1 + (\frac{y^2}{z^2} + 1) b^2 = 0 \\
& (a^2 - 1) z^2 + (x^2 + y^2 + z^2) b^2 = 0 \\
& b = \sigma z \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}}
\end{align*}
and from $b = \frac{z}{y} d$ there is:
\begin{equation*}
d = \frac{y}{z} \sigma z \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}} = \sigma y \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}}
\end{equation*}
In all cases a general solution to \eqref{eqn:spinor_automorphism_set} in coordinates is:
\begin{align} \label{eqn:spinor_rotation_formula_solution_in_coordinates}
& a \in [-1; 1], \quad \sigma \in \{ -1, 1 \} \\
& b = \sigma z \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}}, \quad c = \sigma x \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}}, \quad d = \sigma y \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}}
\end{align}
There are two parametrized solutions to the set of equations \eqref{eqn:spinor_automorphism_set}:
\begin{align*}
s = & a + \sigma z \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}} e_{12} + \\
& \sigma x \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}} e_{23} + \sigma y \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}} e_{31} \\
s = & a + \sigma \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}} (z e_{12} + x e_{23} + y e_{31}) \\
s = & a + \sigma \frac{\sqrt{1 - a^2}}{\sqrt{x^2 + y^2 + z^2}} \mathbf{e}_{123} (z e_3 + x e_1 + y e_2) \\
s = & a + \sigma \frac{\sqrt{1 - a^2}}{\|v\|} \mathbf{e}_{123} v \\
s = & a + \sigma \mathbf{e}_{123} \sqrt{1 - a^2} \N(v)
\end{align*}
Finally, since many of the operations were reductions, all solutions are plugged into the original set of equations to check their validity. It can be seen that:
\begin{align*}
s v s^{-1} & = (a + \sigma \mathbf{e}_{123} \sqrt{1-a^2} \N(v)) v (a + \sigma \mathbf{e}_{123} \sqrt{1-a^2} \N(v))^{-1} \\
& = (a + \sigma \mathbf{e}_{123} \sqrt{1-a^2} \N(v)) v (a - \sigma \mathbf{e}_{123} \sqrt{1-a^2} \N(v)) \\
& = (a v + \sigma \mathbf{e}_{123} \sqrt{1-a^2} \N(v) v) (a - \sigma \mathbf{e}_{123} \sqrt{1-a^2} \N(v)) \\
& = (a v + \sigma \mathbf{e}_{123} \sqrt{1-a^2} \|v\|) (a - \sigma \mathbf{e}_{123} \sqrt{1-a^2} \N(v)) \\
& = a v a + a v (- \sigma \mathbf{e}_{123} \sqrt{1-a^2} \N(v)) + (\sigma \mathbf{e}_{123} \sqrt{1-a^2} \|v\|) a + \\
& \quad (\sigma \mathbf{e}_{123} \sqrt{1-a^2} \|v\|) (-\sigma \mathbf{e}_{123} \sqrt{1-a^2} \N(v)) \\
& = a v a + a v (-\sigma \mathbf{e}_{123} \sqrt{1-a^2} \N(v)) + a v (\sigma \mathbf{e}_{123} \sqrt{1-a^2} \N(v)) + \\
& \quad \sigma (- \sigma) \mathbf{e}_{123} \mathbf{e}_{123} \sqrt{1-a^2} \sqrt{1-a^2} \|v\| \N(v) \\
& = a v a + (1 - a^2) v = a^2 v + v - a^2 v = v
\end{align*}
which confirms that all the solutions are valid. Now we obtain the following formula:
\begin{equation*}
s = a + \sigma \mathbf{e}_{123} \sqrt{1-a^2} \N(v)
\end{equation*}
for $a \in [-1; 1]$. Now it is further simplified by using trigonometric and exponential series converging for all arguments. We substitute $a = \cos(\alpha)$ to obtain:
\begin{equation*}
a + \sigma \mathbf{e}_{123} \sqrt{1-a^2} \N(v) = \cos(\alpha) + \sin(\alpha) \mathbf{e}_{123} \N(v)
\end{equation*}
where $\alpha \in [0; 2 \pi)$. Then, we express the trigonometry using exponential function. We use series expansions which are valid for all $\alpha$. Note that $(-1)^k = (\mathbf{e}_{123} \mathbf{e}_{123})^k = (\mathbf{e}_{123})^{2k}$ and $(\N(v))^{2 k} = 1$.
\begin{align*}
& \cos(\alpha) + \sin(\alpha) \mathbf{e}_{123} \N(v) = \sum_{k=0}^\infty \frac{(-1)^k}{(2 k)!} \alpha^{2 k} + \mathbf{e}_{123} \N(v) \sum_{k=0}^\infty \frac{(-1)^k}{(2 k + 1)!} \alpha^{2 k + 1} \\
& = \sum_{k=0}^\infty \frac{(\mathbf{e}_{123})^{2k}}{(2 k)!} \alpha^{2 k} (\N(v))^{2 k} + \mathbf{e}_{123} \N(v) \sum_{k=0}^\infty \frac{(\mathbf{e}_{123})^{2k}}{(2 k + 1)!} \alpha^{2 k + 1} (\N(v))^{2 k} \\
& = \sum_{k=0}^\infty \frac{(\mathbf{e}_{123})^{2k}}{(2 k)!} \alpha^{2 k} (\N(v))^{2 k} + \sum_{k=0}^\infty \frac{(\mathbf{e}_{123})^{2k + 1}}{(2 k + 1)!} \alpha^{2 k + 1} (\N(v))^{2 k + 1} \\
& = \sum_{k=0}^\infty \frac{(\mathbf{e}_{123} \alpha \N(v))^{2k}}{(2 k)!} + \sum_{k=0}^\infty \frac{(\mathbf{e}_{123} \alpha \N(v))^{2k + 1}}{(2 k + 1)!} \\
& = \sum_{k=0}^\infty \frac{(\mathbf{e}_{123} \alpha \N(v))^{k}}{k!} = \exp(\mathbf{e}_{123} \alpha \N(v))
\end{align*}
which is precisely the stated general formula. This completes the proof.
\end{proof}
\section{A spinor which rotates a given vector}
The following lemma states what is a spinor which rotates a given vector to be equal to a target one. In literature it is sometimes called \textit{direct rotation}, as in \cite{baerlocher_boulic}. Schematic view is presented in figure \ref{img:direct_rotation}.
\begin{figure}[ht]
\centering
\includegraphics[width=3cm]{direct}
\caption{A direct rotation of $AB$ to $AB'$}
\label{img:direct_rotation}
\end{figure}
The lemma is required to prove a general theorem about the set of spinors which rotate a given initial vector to a given target vector. We start with the following initial lemma which applies to the Clifford algebra of $\R^2$. At first the following basic property of $\mathrm{C}\ell_2$ is proved:
\begin{lemma} \label{thm:lemma_external_product}
The external product of two given vectors $v$ and $w$ in $\mathrm{C}\ell_2$ can be written as:
\begin{equation*}
w \wedge v = \frac{1}{2} \sgn(v \wedge w \mathbf{e}_{12}) \|v - w\| \|v + w\|\mathbf{e}_{12}
\end{equation*}
\end{lemma}
\begin{proof}
Assume that $v = x \mathbf{e}_1 + y \mathbf{e}_2$ and $w = p \mathbf{e}_1 + q \mathbf{e}_2$. In special case when $w = \pm v$ both sides of the equation are equal to zero therefore the equation holds. In general case $w \ne \pm v$ and one can rewrite both sides in coordinates. Left-hand side is equal to:
\begin{align*}
w \wedge v & = \frac{1}{2} ( w v - v w ) = \frac{1}{2} \left( (p \mathbf{e}_1 + q \mathbf{e}_2)(x \mathbf{e}_1 + y \mathbf{e}_2) - (x \mathbf{e}_1 + y \mathbf{e}_2)(p \mathbf{e}_1 + q \mathbf{e}_2) \right) \\
& = \frac{1}{2} \left( 2 p y \mathbf{e}_{12} - 2 q x \mathbf{e}_{12} \right) = (p y - q x) \mathbf{e}_{12}
\end{align*}
Right-hand side is equal to:
\begin{align*}
& \frac{1}{2} \sgn(v \wedge w \mathbf{e}_{12}) \|v - w\| \|v + w\|\mathbf{e}_{12} \\
& = \frac{1}{2} \sgn(\frac{1}{2} ( v w - w v ) \mathbf{e}_{12}) \sqrt{(v - w)^2} \sqrt{(v + w)^2} \mathbf{e}_{12} \\
& = \frac{1}{2} \sgn(( (x \mathbf{e}_1 + y \mathbf{e}_2)(p \mathbf{e}_1 + q \mathbf{e}_2) \\
& \quad - (p \mathbf{e}_1 + q \mathbf{e}_2)(x \mathbf{e}_1 + y \mathbf{e}_2) ) \mathbf{e}_{12}) \sqrt{(v - w)^2 (v + w)^2 } \mathbf{e}_{12} \\
& = \frac{1}{2} \sgn(( 2 q x \mathbf{e}_{12} - 2 p y \mathbf{e}_{12} ) \mathbf{e}_{12}) \\
& \quad \sqrt{ ((x - p)^2 + (y - q)^2)((x+p)^2+(y+q)^2)} \mathbf{e}_{12} \\
& = \frac{1}{2} \sgn(p y - q x) \sqrt{ 4 (p y - q x)^2 } \mathbf{e}_{12} = \sgn(p y - q x) |p y - q x| \mathbf{e}_{12} \\
& = (p y - q x) \mathbf{e}_{12}
\end{align*}
Both sides are equal so it completes the proof.
\end{proof}
\begin{lemma}
Let $v$ and $w$ be a pair of non-zero vectors of equal length in $\mathrm{C}\ell_2$ such that $v \ne -w$. Then there exist a pair of spinors $\pm s \in \Spin(2)$ which rotate $v$ so that the rotated vector is equal to $w$:
\begin{equation*}
s v s^{-1} = w
\end{equation*}
then the pair of spinors is equal to:
\begin{equation*}
s = \pm \N(v + w) \N(v)
\end{equation*}
\end{lemma}
\begin{proof}
Let $s = a + b \mathbf{e}_{12} \in \Spin(2)$ be a spinor and $v = x \mathbf{e}_1 + y \mathbf{e}_2$, $w = p \mathbf{e}_1 + q \mathbf{e}_2$ be a pair of given vectors. The equation can be expressed in coordinates with the following set of equations:
\begin{align} \label{eqn:rotating_spinor_lemma_initial_set}
\left\{
\begin{aligned}
& (a^2 - b^2) x + 2 a b y = p \\
& (a^2 - b^2) y - 2 a b x = q
\end{aligned}
\right.
\end{align}
From the assumption it is impossible that both $x$ and $y$ are simultaneously zero. When $x \ne 0$ we solve the set of equations:
\begin{align*}
\left\{
\begin{aligned}
& a^2 - b^2 = \frac{p - 2 a b y}{x}\\
& \frac{p - 2 a b y}{x} y - 2 a b x = q
\end{aligned}
\right.
\end{align*}
The second equation is then simplified:
\begin{align*}
& (p - 2 a b y) y - 2 a b x^2 - q x = 0 \\
& 2 a b = \frac{p y - q x}{x^2 + y^2}
\end{align*}
Which is then plugged into the first equation of \eqref{eqn:rotating_spinor_lemma_initial_set}:
\begin{align*}
& (a^2 - b^2) x + \frac{p y - q x}{x^2 + y^2} y = p \\
& (2 a^2 - 1) x = p - \frac{p y^2 - q x y}{x^2 + y^2} \\
& 2 a^2 = \frac{p x^2 + p y^2 - p y^2 + q x y}{x (x^2 + y^2)} + 1 = \frac{p x + q y}{x^2 + y^2} + 1 \\
& a = \pm \sqrt{\frac{x^2 + y^2 + p x + q y}{x^2 + y^2} }
\end{align*}
The same result can be obtained when we consider the other case $y \ne 0$:
\begin{align*}
\left\{
\begin{aligned}
& a^2 - b^2 = \frac{q + 2 a b x}{y}\\
& \frac{q + 2 a b x}{y} x + 2 a b y = p
\end{aligned}
\right.
\end{align*}
The second equation can be simplified:
\begin{align*}
& (q + 2 a b x) x + 2 a b y^2 - p y = 0 \\
& 2 a b = \frac{p y - q x}{x^2 + y^2}
\end{align*}
Which is then plugged into the second equation of \eqref{eqn:rotating_spinor_lemma_initial_set}:
\begin{align*}
& (a^2 - b^2) y - \frac{p y - q x}{x^2 + y^2} x = q \\
& (2 a^2 - 1) y = q + \frac{p x y - q x^2}{x^2 + y^2} \\
& 2 a^2 = \frac{q x^2 + q y^2 + p x y - q x^2}{y (x^2 + y^2)} + 1 = \frac{p x + q y}{x^2 + y^2} + 1 \\
& a = \pm \sqrt{\frac{x^2 + y^2 + p x + q y}{2 (x^2 + y^2)} }
\end{align*}
We obtained one general solution which is correct for all $x, y$. Now, for each $\sigma \in \{ -1, 1 \}$ of $a = \sigma \sqrt{\frac{x^2 + y^2 + p x + q y}{2 (x^2 + y^2)} }$ we have exactly one corresponding solution $b$. It can be calculated by plugging it into $2 a b = \frac{p y - q x}{2 (x^2 + y^2)}$ valid for all $x, y$. When $a \ne 0$ then:
\begin{align*}
& b = \frac{p y - q x}{2 a (x^2 + y^2)} \\
& b = \frac{(p y - q x) \sqrt{2 (x^2 + y^2)}}{2 \sigma \sqrt{x^2 + y^2 + p x + q y} (x^2 + y^2)} \\
& b = \sigma \frac{p y - q x}{\sqrt{x^2 + y^2 + p x + q y} \sqrt{2 (x^2 + y^2)}} \\
& b = \sigma \frac{(p y - q x)\sqrt{x^2 + y^2 - p x - q y}}{\sqrt{(x^2 + y^2)^2 - (p x + q y)^2} \sqrt{2 (x^2 + y^2)}} \\
& b = \sigma \frac{(p y - q x)\sqrt{x^2 + y^2 - p x - q y}}{\sqrt{(x^2 + y^2)^2 - (p x + q y)^2} \sqrt{2 (x^2 + y^2)}} \\
& b = \sigma \frac{(p y - q x)\sqrt{x^2 + y^2 - p x - q y}}{\sqrt{x^4 + y^4 + 2 x^2 y^2 - p^2 x^2 - q^2 y^2 - 2 p q x y} \sqrt{2 (x^2 + y^2)}} \\
& b = \sigma \frac{(p y - q x)\sqrt{x^2 + y^2 - p x - q y}}{\sqrt{x^4 + y^4 + 2 x^2 y^2 - (x^2 + y^2 - q^2) x^2 - (x^2 + y^2 - p^2) y^2 - 2 p q x y}} \cdot \\
& \frac{1}{\sqrt{2 (x^2 + y^2)}} \\
& b = \sigma \frac{p y - q x}{\sqrt{(p y - q x)^2}} \sqrt{\frac{x^2 + y^2 - p x - q y}{2 (x^2 + y^2)}}
\end{align*}
note that $(p y - q x) \mathbf{e}_{12} = w \wedge v$ but it is assumed that $v$ is not parallel to $w$ therefore $p y - q x \ne 0$. Since $\mathbf{e}_{12}^2 = -1$ the following applies:
\begin{equation*}
\frac{p y - q x}{\sqrt{(p y - q x)^2}} = \sgn(v \wedge w \mathbf{e}_{12})
\end{equation*}
and $b$ is equal to:
\begin{equation*}
b = \sigma \sgn(v \wedge w \mathbf{e}_{12})\sqrt{\frac{x^2 + y^2 - p x - q y}{2 (x^2 + y^2)}}
\end{equation*}
When $a = 0$ then from $b^2 = 1 - a^2$ we know that $b = \pm 1$ which is also a special case of the general solution.
Finally, we simplify the formula to a coordinate-free solution. For each $\sigma \in \{ -1, 1 \}$ there is a solution:
\begin{align*}
& s = \sigma \sqrt{\frac{x^2 + y^2 + p x + q y}{2 (x^2 + y^2)} } + \sigma \sgn(v \wedge w \mathbf{e}_{12})\sqrt{\frac{x^2 + y^2 - p x - q y}{2 (x^2 + y^2)}} \mathbf{e}_{12} \notag \\
& s = \frac{\sigma}{\sqrt{2 (x^2 + y^2)}} ( \sqrt{x^2 + y^2 + p x + q y} + \\
& \sgn(v \wedge w \mathbf{e}_{12}) \sqrt{x^2 + y^2 - p x - q y} \mathbf{e}_{12} ) \\
& s = \frac{\sigma}{\sqrt{2 (x^2 + y^2)}} ( \sqrt{\frac{1}{2} (x^2 + y^2 + p^2 + q^2 + 2 (p x + q y) )} + \\
& \sgn(v \wedge w \mathbf{e}_{12}) \sqrt{\frac{1}{2} (x^2 + y^2 + p^2 + q^2 - 2 (p x + q y) ) } \mathbf{e}_{12} ) \\
& s = \frac{\sigma}{2 \sqrt{x^2 + y^2}} ( \sqrt{x^2 + y^2 + p^2 + q^2 + 2 (p x + q y)} + \\
& \sgn(v \wedge w \mathbf{e}_{12}) \sqrt{x^2 + y^2 + p^2 + q^2 - 2 (p x + q y) } \mathbf{e}_{12} ) \\
& s = \frac{\sigma}{2 \|v\|} ( \sqrt{v v + w w + v w + w v} + \\
& \sgn(v \wedge w \mathbf{e}_{12}) \sqrt{v v + w w - v w - w v } \mathbf{e}_{12} ) \\
& s = \frac{\sigma}{2 \|v\|} ( \sqrt{(v + w)^2} + \sgn(v \wedge w \mathbf{e}_{12}) \sqrt{(v - w)^2} \mathbf{e}_{12} ) \\
& s = \frac{\sigma}{2 \|v\|} ( \|v + w\| + \sgn(v \wedge w \mathbf{e}_{12}) \|v - w\| \mathbf{e}_{12} ) \\
\end{align*}
From the assumptions, there is $\|v + w\| \ne 0$ so:
\begin{equation*}
s = \frac{\sigma}{2 \|v\| \|v + w\|} ( \|v + w\|^2 + \sgn(v \wedge w \mathbf{e}_{12}) \|v - w\| \|v + w\|\mathbf{e}_{12} )
\end{equation*}
Next, the basic identity from lemma \ref{thm:lemma_external_product} is used so the formula can be rewritten with only external product:
\begin{equation*}
w \wedge v = \frac{1}{2} \sgn(v \wedge w \mathbf{e}_{12}) \|v - w\| \|v + w\|\mathbf{e}_{12}
\end{equation*}
It reads that the external product is equal to a bivector whose area is equal to the half of the area of the parallelogram spanned by the both vectors and with the sign adjusted to the sign of the external product. Using the above identity, the following further simplifications are possible:
\begin{align*}
& s = \frac{\sigma}{2 \|v\| \|v + w\|} ( \|v + w\|^2 + 2 v \wedge w ) \\
& s = \frac{\sigma}{2 \|v\| \|v + w\|} ( v v + w w + 2 v \cdot w + 2 v \wedge w ) \\
& s = \frac{\sigma}{\|v\| \|v + w\|} ( v v + w v ) \\
& s = \frac{\sigma}{\|v\| \|v + w\|} (v + w ) v \\
& s = \pm \N(v + w) \N(v)
\end{align*}
Which is precisely the stated formula.
\end{proof}
We observe that the same vector formula applies to any Clifford algebra of $n$-dimensional real space. Thus, we propose the following:
\begin{proposition} \label{thm:proposition_swing_formula}
Let $v$ and $w$ be a pair of non-zero vectors of equal length in $\mathrm{C}\ell_n$ such that $v \ne -w$. Then there exist a pair of spinors each of which rotate $v$ so that it is equal to $w$:
\begin{equation*}
s v s^{-1} = w
\end{equation*}
the pair of spinors is equal to:
\begin{equation*}
s = \pm \N(v + w) \N(v)
\end{equation*}
\end{proposition}
\begin{proof}
Instead of the original equation $s v s^{-1} = w$ an equivalent equation will be proved:
\begin{equation*}
s v = w s
\end{equation*}
Let $v$ and $w$ are the given vectors. Start with:
\begin{equation*}
v - v = v - v
\end{equation*}
since $vv = ww > 0$ each element can be multiplied by the scalar $vv$ or $ww$:
\begin{align*}
& v v v - w w v = w v v - w v v \\
& v v v + w v v = w v v + w w v \\
& (v + w) v v = w (v + w) v
\end{align*}
it is assumed that $v \ne -w$ so $\|v + w\| > 0$ and both sides can be divided by $\|v + w\| \|v\|$:
\begin{equation*}
\N(v + w) \N(v) v = w \N(v + w) \N(v)
\end{equation*}
To ensure that $s$ is a spinor it is sufficient to check whether it is a direct product of a scalar and a bivector and whether its norm is equal to 1. Indeed:
\begin{align*}
s = \N(v + w) \N(v) = \frac{vv + wv}{\|v + w\|\|v\|} = \frac{\|v\|^2 + wv}{\|v + w\|\|v\|} \in \bigwedge_0 \R^3 \otimes \bigwedge_2 \R^3
\end{align*}
and since
\begin{align*}
& s^{-1} = \N(\|v\|^2 + w \cdot v + w \wedge v)^{-1} \\
& = \N(\|v\|^2 + v \cdot w + v \wedge w) = \N(vv + vw) = \N(v) \N(v + w)
\end{align*}
the norm is:
\begin{equation*}
s s^{-1} = \N(v + w) \N(v) \N(v) \N(v + w) = \| \N(v+w) \|^2 \| \N(v) \|^2 = 1
\end{equation*}
Which completes the proof.
\end{proof}
Since the theorem is valid for $\mathrm{C}\ell_n$ it is also valid for $\mathrm{C}\ell_3$. In more general conclusion, for any dimension there exists a simple formula giving a pair of spinors rotating a given vector so that it covers another given vector of the same length.
\section{The set of spinors which rotate a given initial vector to a given target vector}
\label{sec:two_st_decompositions}
There are two ways of defining a swing-twist representation (composition or decomposition):
\begin{itemize}
\item twist $q$ is done \textbf{before} swing $p$; for a given spinor $r$ we have: $s = p q$. \\
This is the \textbf{swing-after-twist} representation.
\item twist $q$ is done \textbf{after} swing $p$; for a given spinor $r$ we have: $s = q p$. \\
This is the \textbf{twist-after-swing} representation.
\end{itemize}
The swing-after-twist representation is used in \cite{huyghe} while the twist-after-swing representation is usually used in the direct method. Since in practice both conventions are used (the first one is slightly less common) in this paper both decompositions will be presented and proved. The following theorem is a general solution to Clifford product equation:
\begin{equation*}
s v s^{-1} = w
\end{equation*}
We prove the following
\begin{proposition} \label{thm:proposition_st_representation}
Let $v$ and $w$ be a pair of non-zero vectors of equal length in $\mathrm{C}\ell_3$ such that $v \ne -w$. The set of spinor solutions $s \in \Spin(3)$ to
\begin{equation*}
s v s^{-1} = w
\end{equation*}
in the case of swing-after-twist representation is equal to:
\begin{equation*}
s = \pm \N(v + w) \N(v) \exp(\mathbf{e}_{123} \alpha \N(v))
\end{equation*}
and in the case of twist-after-swing representation is equal to:
\begin{equation*}
s = \pm \exp(\mathbf{e}_{123} \alpha \N(w)) \N(v + w) \N(v)
\end{equation*}
\end{proposition}
\begin{proof}
The solution is the set of all possible rotations which swing axis from initial $v$ to terminal $w$ with any possible twist during the movement. Using propositions \ref{thm:proposition_twist_formula} and \ref{thm:proposition_swing_formula} one composes swing and twist according to the order used in a given representation. In the case of swing-after-twist representation twist $q = \exp(\mathbf{e}_{123} \alpha \N(v))$ factor (around $v$ axis) is applied at first and only after it, swing factor $p = \N(v + w) \N(v)$ is applied (swinging the axis from $v$ to $w$). In the other case of twist-after-swing representation swing $p = \N(v + w) \N(v)$ is applied first (swinging the axis from $v$ to $w$) and after that twist factor $q = \exp(\mathbf{e}_{123} \alpha \N(w))$ is applied with respect to the terminal axis $w$.
\end{proof}
\section{Swing-twist decomposition of a spinor}
This is the main result of this paper. In this section the inverse of formulas given in proposition \ref{thm:proposition_st_representation} is derived. Given a spinor it is possible to calculate its decomposition into twist and swing factors in respect to a given non-zero vector. Since there are two different swing-twist representations, there are also two swing-twist decompositions for swing-after-twist and twist-after-swing representation respectively. In this section, the initial vector will be called a base vector.
\begin{theorem}[Swing-twist decomposition of a spinor in swing-after-twist representation] \label{thm:swing_twist_decomposition_sat_type}
Assume that $s \in \Spin(3)$ is a spinor. For any non-zero base vector $v \in \mathrm{C}\ell_3$ such that $s v s^{-1} \ne -v$ there exist \textbf{a unique up to the sign} swing-twist decomposition in swing-after-twist representation
\begin{equation*}
s = \pm p q
\end{equation*}
where swing spinor $p$ and twist spinor $q$ are equal to:
\begin{align*}
& p = \pm s \tilde{\sigma}_v(s) \\
& q = \pm \sigma_v(s)
\end{align*}
where $\sigma_v(s): \Spin(3) \longrightarrow \Spin(3)$ is a function of spinor $s$:
\begin{equation*}
\sigma_b(s) = \N(v (v \cdot s))
\end{equation*}
the reversion $\tilde{\sigma}_v(s)$ is equal to:
\begin{equation*}
\tilde{\sigma}_v(s) = \N(v (v \cdot \tilde{s}))
\end{equation*}
The function $\sigma_v(s)$ will be called \textbf{a twist projection function}.
\end{theorem}
\begin{proof}
The proof is divided into several steps. At first the problem is reformulated in coordinates. Then, twist angle is calculated and twist spinor and finally swing spinor. Denote the following:
\begin{align*}
& s = a + b \mathbf{e}_{12} + c \mathbf{e}_{23} + d \mathbf{e}_{31} \\
& v = v_x \mathbf{e}_1 + v_y \mathbf{e}_2 + v_z \mathbf{e}_3 \\
& w = w_x \mathbf{e}_1 + w_y \mathbf{e}_2 + w_z \mathbf{e}_3
\end{align*}
The angle $\alpha$ will be described implicitly by:
\begin{align*}
& \cos(\alpha) = k \\
& \sin(\alpha) = l \\
& k^2 + l^2 = 1
\end{align*}
Vector $w$ exists on the assumption that $s v s^{-1} \ne -v$. What does this assumption require about the base vector and the spinor is explained in the appendix of this paper. At first, the equation is rewritten in coordinates. The swing factor is equal to:
\begin{align*}
p & = \N(w + v) \N(v) \\
& = \frac{( (w_x + v_x) \mathbf{e}_1 + (w_y + v_y) \mathbf{e}_2 + (w_z + v_z) \mathbf{e}_3)(v_x \mathbf{e}_1 + v_y \mathbf{e}_2 + v_z \mathbf{e}_3)}{\sqrt{(w_x + v_x)^2 + (w_y + v_y)^2 + (w_z + v_z)^2}\sqrt{v_x^2 + v_y^2 + v_z^2}} \\
& = ((w_x + v_x)^2 + (w_y + v_y)^2 + (w_z + v_z)^2)^{-\frac{1}{2}}(v_x^2 + v_y^2 + v_z^2)^{-\frac{1}{2}} \cdot \\
& [ (w_x + v_x) v_x + (w_y + v_y) v_y + (w_z + v_z) v_z + \\
& ((w_x + v_x) v_y - (w_y + v_y) v_x) \mathbf{e}_{12} + ((w_y + v_y) v_z - (w_z + v_z) v_y) \mathbf{e}_{23} + \\
& ((w_z + v_z) v_x - (w_x + v_x) v_z) \mathbf{e}_{31} ]
\end{align*}
Twist factor is equal to:
\begin{equation} \label{eqn:general_formula_for_twist}
q = \cos(\alpha) + \mathbf{e}_{123} \N(v) \sin(\alpha) = k + \frac{l}{\sqrt{v_x^2 + v_y^2 + v_z^2}} (b_z \mathbf{e}_{12} + b_x \mathbf{e}_{23} + b_y \mathbf{e}_{31})
\end{equation}
Combining the above formulas there is:
\begin{align*}
pq & = ((w_x + v_x)^2 + (w_y + v_y)^2 + (w_z + v_z)^2)^{-\frac{1}{2}}(v_x^2 + v_y^2 + v_z^2)^{-\frac{1}{2}} \cdot \\
& [ (w_x + v_x) v_x + (w_y + v_y) v_y + (w_z + v_z) v_z + \\
& ((w_x + v_x) v_y - (w_y + v_y) v_x) \mathbf{e}_{12} + ((w_y + v_y) v_z - (w_z + v_z) v_y) \mathbf{e}_{23} + \\
& ((w_z + v_z) v_x - (w_x + v_x) v_z) \mathbf{e}_{31} ] \cdot \\
& [k + \frac{l}{\sqrt{v_x^2 + v_y^2 + v_z^2}} (b_z \mathbf{e}_{12} + b_x \mathbf{e}_{23} + b_y \mathbf{e}_{31}) ] \\
& = ((w_x + v_x)^2 + (w_y + v_y)^2 + (w_z + v_z)^2)^{-\frac{1}{2}}(v_x^2 + v_y^2 + v_z^2)^{-\frac{1}{2}} \cdot \\
& [ k ( (w_x + v_x) v_x + (w_y + v_y) v_y + (w_z + v_z) v_z) + \\
& ( k (w_x v_y - w_y v_x) + l \sqrt{v_x^2 + v_y^2 + v_z^2} (w_z + v_z) ) \mathbf{e}_{12} + \\
& ( k (w_y v_z - w_z v_y) + l \sqrt{v_x^2 + v_y^2 + v_z^2} (w_x + v_x) ) \mathbf{e}_{23} + \\
& ( k (w_z v_x - w_x v_z) + l \sqrt{v_x^2 + v_y^2 + v_z^2} (w_y + v_y) ) \mathbf{e}_{31} ]
\end{align*}
Two spinors are equal if and only if corresponding coefficients are equal. Therefore the following set of equations determines the solution:
\begin{equation} \label{eqn:set_of_equations_decomposition}
\begin{cases}
a = [ k ( (w_x + v_x) v_x + (w_y + v_y) v_y + (w_z + v_z) v_z) ] \Delta \\
b = [ k (w_x v_y - w_y v_x) + l \sqrt{v_x^2 + v_y^2 + v_z^2} (w_z + v_z) ] \Delta \\
c = [ k (w_y v_z - w_z v_y) + l \sqrt{v_x^2 + v_y^2 + v_z^2} (w_x + v_x) ] \Delta \\
d = [ k (w_z v_x - w_x v_z) + l \sqrt{v_x^2 + v_y^2 + v_z^2} (w_y + v_y) ] \Delta \\
k^2 + l^2 = 1 \\
w_x^2 + w_y^2 + w_z^2 = v_x^2 + v_y^2 + v_z^2 \\
a^2 + b^2 + c^2 + d^2 = 1
\end{cases}
\end{equation}
Where $\Delta = ((w_x + v_x)^2 + (w_y + v_y)^2 + (w_z + v_z)^2)^{-\frac{1}{2}}(v_x^2 + v_y^2 + v_z^2)^{-\frac{1}{2}}$. By substituting variables in the set of equations \eqref{eqn:set_of_equations_decomposition} it is easy to rise unfavourably the degree of involved polynomials. Thus the following careful operations are performed. First, note that it is easy to obtain variable $k$ from the first equation:
\begin{equation} \label{eqn:deomcposition_first_equation_unsimplified}
a = \frac{k (w + v) \cdot v}{\|w + v\| \|v\|}
\end{equation}
Observe that:
\begin{equation*}
\|w + v\|^2 = (w + v)(w + v) = w w + v v + w v + v w = 2 ( v \cdot v + v \cdot w) = 2 v \cdot (w + v)
\end{equation*}
Using this, one simplifies \eqref{eqn:deomcposition_first_equation_unsimplified} to:
\begin{equation*}
a = \frac{k (w + v) \cdot v}{\|w + v\| \|v\|} = \frac{k \|w + v\|^2}{\|w + v\| \|v\|} = k \frac{\|w + v\|}{2 \|v\|}
\end{equation*}
From that one obtains the value of $k$:
\begin{equation} \label{eqn:formula_for_k}
k = a \frac{2 \|v\|}{\|w + v\|}
\end{equation}
The value of $k$ is now put into the set of equations \eqref{eqn:set_of_equations_decomposition} which then can be simplified to:
\begin{equation} \label{eqn:set_of_equations_decomposition_simplified}
\begin{cases}
b \|w + v\| = 2 a \frac{1}{\|w + v\|} (w_x v_y - w_y v_x) + l (w_z + v_z) \\
c \|w + v\| = 2 a \frac{1}{\|w + v\|} (w_y v_z - w_z v_y) + l (w_x + v_x) \\
d \|w + v\| = 2 a \frac{1}{\|w + v\|} (w_z v_x - w_x v_z) + l (w_y + v_y)
\end{cases}
\end{equation}
It is a set of three linear equations with three unknowns $M [w_x, w_y, w_z]^T = N$. The characteristic matrix $M$ is:
\begin{equation*}
M =
\begin{vmatrix}
2 a \frac{1}{\|w + v\|} v_y & -2 a \frac{1}{\|w + v\|} v_x & l \\
l & 2 a \frac{1}{\|w + v\|} v_z & -2 a \frac{1}{\|w + v\|} v_y \\
-2 a \frac{1}{\|w + v\|} v_z & l & 2 a \frac{1}{\|w + v\|} v_x
\end{vmatrix}
\end{equation*}
and the vector $N$ is equal to:
\begin{equation*}
N = [b \|w + v\| - l v_z, c \|w + v\| - l v_x, d \|w + v\| - l v_y]^T
\end{equation*}
Any known method can be used to compute the determinant of $M$ which is equal to:
\begin{equation*}
det(M) = l
\end{equation*}
The case $l = 0$ needs special care and will be now discussed separately. In this case, from \eqref{eqn:general_formula_for_twist} twist factor is equal to:
\begin{equation*}
q = k + \frac{l}{\sqrt{v_x^2 + v_y^2 + v_z^2}} (b_z \mathbf{e}_{12} + b_x \mathbf{e}_{23} + b_y \mathbf{e}_{31}) = k
\end{equation*}
Since $q$ is a spinor, its component $k$ must be equal to:
\begin{align*}
k = \pm 1
\end{align*}
which then implies that twist and swing factors are equal to:
\begin{align*}
p & = \pm s \\
q & = \pm 1
\end{align*}
It is a special case of the general formula. It holds for all vector $v$ and spinors $s$ such that $\alpha = z \pi, \, z \in \mathbb{Z}$. In the case of $l \ne 0$ there exist exactly one solution to \eqref{eqn:set_of_equations_decomposition_simplified}. After having the matrix inverted and solution calculated, one gets:
\begin{align*}
& w_x = [4 a^2 (v_x^2 + v_y^2 + v_z^2) l + \|w + v\|^2 l^3]^{-1} \\
& [ 2 a (b v_y - d v_z) \|w + v\|^2 l + \\
& \|w + v\|^2 l^2 (c \|w + v\| - v_x l) + 4 a^2 v_x ((b v_z + v_x c + v_y d) \|w + v\| - (v_x^2 + v_y^2 + v_z^2) l) ] \\
& w_y = [4 a^2 (v_x^2 + v_y^2 + v_z^2) l + \|w + v\|^2 l^3]^{-1} \\
& [ 2 a (-b v_x + c v_z) \|w + v\|^2 l + \\
& \|w + v\|^2 l^2 (d \|w + v\| - v_y l) + 4 a^2 v_y ((b v_z + v_x c + v_y d) \|w + v\| - (v_x^2 + v_y^2 + v_z^2) l) ] \\
& w_z = [4 a^2 (v_x^2 + v_y^2 + v_z^2) l + \|w + v\|^2 l^3]^{-1} \\
& [ 2 a (c v_y + d v_x) \|w + v\|^2 l + \\
& \|w + v\|^2 l^2 (b \|w + v\| - v_z l) + 4 a^2 v_z ((b v_z + v_x c + v_y d) \|w + v\| - (v_x^2 + v_y^2 + v_z^2) l) ]
\end{align*}
All three denominators are equal and can be simplified:
\begin{align*}
& 4 a^2 (v_x^2 + v_y^2 + v_z^2) l + \|w + v\|^2 l^3 \\
& = l (4 a^2 \|v\|^2 + \|w + v\|^2 (1 - a^2 \frac{4 \|v\|^2}{\|w+v\|^2})) = l \|w + v\|^2
\end{align*}
A compact form is achieved with the following simplifications:
\begin{align*}
\begin{vmatrix} w_x \\ w_y \\ w_z \end{vmatrix} & = \frac{1}{l \|w + v\|^2} ( 2 a \begin{vmatrix} b v_y - d v_z \\ c v_z - b v_x \\ d v_x - c v_y \end{vmatrix} \|w + v\|^2 l + \|w + v\|^2 l^2 \begin{vmatrix} c \|w + v\| - v_x l \\ d \|w + v\| - v_y l \\ b \|w + v\| - v_z l \end{vmatrix} + \\
& 4 a^2 \begin{vmatrix} v_x \\ v_y \\ v_z \end{vmatrix} ( ( b v_z + c v_x + d v_y) \|w + v\| - \|v\|^2 l ) ) \\
& = 2 a \begin{vmatrix} v_x \\ v_y \\ v_z \end{vmatrix} \times \begin{vmatrix} c \\ d \\ b \end{vmatrix} + l \|w + v\| \begin{vmatrix} c \\ d \\ b \end{vmatrix} \\
& - l^2 \begin{vmatrix} v_x \\ v_y \\ v_z \end{vmatrix} + \frac{4 a^2}{l \|w + v\|^2} \begin{vmatrix} v_x \\ v_y \\ v_z \end{vmatrix} ( \|w + v\| \begin{vmatrix} v_x \\ v_y \\ v_z \end{vmatrix} \cdot \begin{vmatrix} c \\ d \\ b \end{vmatrix} - \|v\|^2 l )
\end{align*}
Vector $[c, d, b]^T$ can be formulated with coefficients of spinor $s$:
\begin{equation*}
\star [s]_2 = -\mathbf{e}_{123} [s]_2 = -\mathbf{e}_{123} (b \mathbf{e}_{12} + c \mathbf{e}_{23} + d \mathbf{e}_{31} ) = c \mathbf{e}_1 + d \mathbf{e}_2 + b \mathbf{e}_3
\end{equation*}
With this substitution further simplification is possible:
\begin{equation*}
w = 2 a v \times \star[s]_2 + l \|w + v\| \star[s]_2 - l^2 v + \frac{4 a^2}{l \|w + v\|^2} v (\|w + v\| v \cdot \star[s]_2 - \|v\|^2 l)
\end{equation*}
but form previous equations there is:
\begin{equation} \label{eqn:formula_ll}
l^2 = 1 - a^2 \frac{4 \|v\|^2}{\|w + v\|^2}
\end{equation}
so after substitution one obtains:
\begin{equation*}
w = 2 a v \times \star[s]_2 + l \|w + v\| \star[s]_2 - v + \frac{4 a^2 v}{l \|w + v\|} v \cdot \star[s]_2
\end{equation*}
The above formula is useful to compute $\|w + v\|$. Note that one can move $-v$ to the left hand side of the equation and compute lengths of both sides.
\begin{align*}
\|w + v\|^2 & = (2 a v \times \star[s]_2 + l \|w + v\| \star[s]_2 + \frac{4 a^2 v}{l \|w + v\|^2} v \cdot \star[s]_2)^2 \\
& = (2 a v \times \star[s]_2)^2 + (l \|w + v\| \star[s]_2)^2 + (\frac{4 a^2 v}{l \|w + v\|^2} v \cdot \star[s]_2)^2 \\
& + 2 [ (2 a v \times \star[s]_2) \cdot (l \|w + v\| \star[s]_2) + (2 a v \times \star[s]_2) \cdot (\frac{4 a^2 v}{l \|w + v\|^2} v \cdot \star[s]_2) \\
& + (l \|w + v\| \star[s]_2) \cdot (\frac{4 a^2 v}{l \|w + v\|^2} v \cdot \star[s]_2) ] \\
& = 4 a^2 (b \times \star[s]_2)^2 + l^2 \|w + v\|^2 (\star[s]_2)^2 + \frac{16 a^4 \|v\|^2}{l^2 \|w+v\|^2}(v\cdot \star[s]_2)^2 + 8 a^2 (v\cdot \star[s]_2)^2
\end{align*}
From the property that $(b \times \star[s]_2)^2 + (b \cdot \star[s]_2)^2 = \|b\|^2 (\star[s]_2)^2$ the following formula is obtained:
\begin{equation*}
\|w + v\|^2 = 4 a^2 \|b\|^2 (\star[s]_2)^2 + l^2 \|w + v\|^2 (\star[s]_2)^2 + 4 a^2 (v\cdot \star[s]_2)^2 + \frac{16 a^4 \|v\|^2}{l^2 \|w+v\|^2}(v\cdot \star[s]_2)^2
\end{equation*}
There is:
\begin{equation} \label{eqn:subst_llwv}
l^2 \|w + v\|^2 = \left(1 - \frac{4 a^2 \|v\|^2}{\|w+v\|^2} \right) \|w + v\|^2 = \|w + v\|^2 - 4 a^2 \|v\|^2
\end{equation}
So one can write the following equivalent formula:
\begin{align*}
\|w + v\|^2 & = 4 a^2 \|b\|^2 (\star[s]_2)^2 + (\|w + v\|^2 - 4 a^2 \|v\|^2) (\star[s]_2)^2 + \\
& 4 a^2 (v\cdot \star[s]_2)^2 + \frac{16 a^4 \|v\|^2}{l^2 \|w+v\|^2}(v\cdot \star[s]_2)^2 \\
& = \|w + v\|^2 (\star[s]_2)^2 + 4 a^2 (v\cdot \star[s]_2)^2 + \frac{16 a^4 \|v\|^2}{l^2 \|w+v\|^2}(v\cdot \star[s]_2)^2
\end{align*}
Substituting $(\star[s]_2)^2 = 1 - a^2$ and once again \eqref{eqn:subst_llwv} one obtains:
\begin{equation*}
\|w + v\|^2 = \|w + v\|^2 (1 - a^2) + (v \cdot \star[s]_2)^2 \left( \frac{4 a^2 (\|w + v\|^2 - 4 a^2 \|v\|^2) + 16 a^4 \|v\|^2}{l^2 \|w+v\|^2} \right)
\end{equation*}
Which can be simplified to:
\begin{align*}
& a^2 \|w + v\|^2 = (v \cdot \star[s]_2)^2 \frac{4 a^2}{l^2} \\
& a^2 (\|w + v\|^2 - 4 a^2 \|v\|^2) = 4 a^2 (v \cdot \star[s]_2)^2
\end{align*}
There are two cases. When $a \ne 0$ the following equation applies:
\begin{equation*}
\|w + v\|^2 = 4 (v \cdot \star[s]_2)^2 + 4 a^2 \|v\|^2
\end{equation*}
Using the above identity, there is:
\begin{align*}
l^2 \|w + v\|^2 & = \|w + v\|^2 - 4 a^2 \|v\|^2 = 4 (v \cdot \star[s]_2)^2 + 4 a^2 \|v\|^2 - 4 a^2 \|v\|^2 \\
l^2 \|w + v\|^2 & = 4 (v \cdot \star[s]_2)^2
\end{align*}
Modifying the identity \eqref{eqn:formula_ll} there is:
\begin{align*}
l^2 & = 1 - a^2 \frac{4 \|v\|^2}{\|w + v\|^2} \\
\|w + v\|^2 - 4 a^2 \|v\|^2 & = l^2 \|w + v\|^2 \\
\|w + v\|^2 - 4 a^2 \|v\|^2 & = 4 (v \cdot \star[s]_2)^2 \\
\|w + v\|^2 & = 4 (v \cdot \star[s]_2)^2 + 4 a^2 \|v\|^2 \\
\|w + v\| & = 2 \sqrt{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}
\end{align*}
Using the formula \eqref{eqn:formula_for_k} one obtains the value of $k$:
\begin{equation} \label{eqn:geneal_k_solution}
k = a \frac{2 \|v\|}{\|w+v\|} = a \frac{2 \|v\|}{2 \sqrt{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}} = \frac{a \|v\|}{\sqrt{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}}
\end{equation}
Again from \eqref{eqn:formula_ll} it is possible to calculate $l$:
\begin{align*}
l^2 & = 1 - a^2 \frac{4 \|v\|^2}{\|w + v\|^2} = 1 - \frac{4 a^2 \|v\|^2}{4 [ (v \cdot \star[s]_2)^2 + a^2 \|v\|^2]} \\
& = \frac{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2} - \frac{a^2 \|v\|^2}{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2} = \frac{(v \cdot \star[s]_2)^2}{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}
\end{align*}
It is possible to take the square root and abandon sign. This comes from the fact that when $s$ is a given spinor then the solution represented by variable $l$ must include the solution for $-s$ as well. In that case the numerator is negated, so also $-l$ is a solution automatically.
\begin{equation} \label{eqn:geneal_l_solution}
l = \frac{v \cdot \star[s]_2}{\sqrt{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}}
\end{equation}
In the case when $a = 0$ from \eqref{eqn:formula_ll} there is:
\begin{align*}
l^2 & = 1 \\
k^2 & = 1 - l^2 = 0
\end{align*}
The same argumentation as above can be used to select any solution of $l^2 = 1$. Both cases are special cases of \eqref{eqn:geneal_k_solution} and \eqref{eqn:geneal_l_solution} so it is sufficient to consider only those general solutions. The twist factor equal to:
\begin{align*}
q & = k + \mathbf{e}_{123} \N(v) l = \\
& = \frac{a \|v\|}{\sqrt{(v \cdot \star[s]_2)^2 + 4 a^2 \|v\|^2}} + \frac{ \mathbf{e}_{123} \N(v) (v \cdot \star[s]_2)}{\sqrt{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}} \\
& = \frac{a \|v\| + \N(v) (v \cdot \star[s])}{\sqrt{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}} = \frac{a \|v\| + \N(v) (v \cdot s) - \N(v) (v \cdot [s]_0)}{\sqrt{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}} \\
& = \frac{a \|v\| + \N(v) (v \cdot s) - a \|v\|}{\sqrt{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}} = \frac{\N(v) (v \cdot s)}{\sqrt{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}}
\end{align*}
Define a norm of a pinor $p = p_0 + p_{12} \mathbf{e}_{12} + p_{23} \mathbf{e}_{23} + p_{31} \mathbf{e}_{31} \in \Pin(3)$:
\begin{equation*}
\N(p) := \frac{p}{\sqrt{p \tilde{p}}} = \frac{p_0 + p_{12} \mathbf{e}_{12} + p_{23} \mathbf{e}_{23} + p_{31} \mathbf{e}_{31}}{\sqrt{p_0^2 + p_{12}^2 + p_{23}^2 + p_{31}^2}} \in \Spin(3)
\end{equation*}
where $\tilde{p} = p_0 - p_{12} \mathbf{e}_{12} - p_{23} \mathbf{e}_{23} - p_{31} \mathbf{e}_{31}$.
Using the fact that $s = a + \mathbf{e}_{123} \star [s]_2$ the numerator of twist factor can be written as:
\begin{align} \label{eqn:numerator_twist}
& \N(v) (v \cdot s) = \N(v) (v \cdot (a + \mathbf{e}_{123} \star [s]_2) = \N(v) (v a + \mathbf{e}_{123} v \cdot \star [s]_2) \notag \\
& = a \|v\| + \mathbf{e}_{123} \N(v) v \cdot \star [s]_2
\end{align}
the norm of the numerator of twist factor is equal to:
\begin{align*}
& \sqrt{(a \|v\| + \mathbf{e}_{123} \N(v) v \cdot \star [s]_2)(a \|v\| - \mathbf{e}_{123} \N(v) v \cdot \star [s]_2)} \\
& = \sqrt{a^2 \|v\|^2 + (\mathbf{e}_{123} \N(v) v \cdot \star [s]_2)^2} = \sqrt{a^2 \|v\|^2 + (v \cdot \star [s]_2)^2}
\end{align*}
one notices that it is equal to the denominator. In result, it is possible to write simply:
\begin{equation*}
q = \N(v (v \cdot s))
\end{equation*}
The swing factor is calculated by modifying the original equation:
\begin{align*}
s & = p q \\
p & = s q^{-1}
\end{align*}
by using \eqref{eqn:numerator_twist} twist inverse can be easily calculated:
\begin{align*}
& q^{-1} = \tilde{q} = \tilde{\sigma}_v(s) = \widetilde{a \|v\| + \mathbf{e}_{123} \N(v) v \cdot \star [s]_2} = a \|v\| - \mathbf{e}_{123} \N(v) v \cdot \star [s]_2 \\
& = a \|v\| + \mathbf{e}_{123} \N(v) v \cdot \star [-s]_2 = \N(v) (v a + \mathbf{e}_{123} v \cdot \star [-s]_2) \\
& = \N(v) (v \cdot (a + \mathbf{e}_{123} \star [-s]_2)) = \N(v) (v \cdot \tilde{s})
\end{align*}
so
\begin{equation*}
p = s \tilde{\sigma}_v(s)
\end{equation*}
where $\tilde{\sigma}_v(s) = \N(v) (v \cdot \tilde{s})$. Both swing and twist factors can be negated as a given spinor and its negation define the same rotation:
\begin{align*}
& p = \pm s \tilde{\sigma}_v(s) \\
& q = \pm \sigma_v(s)
\end{align*}
which completes the proof.
\end{proof}
The following dual theorem can be easily proved with the previous theorem \eqref{thm:swing_twist_decomposition_sat_type}:
\begin{theorem}[Swing-twist decomposition of a spinor in twist-after-swing representation] \label{thm:swing_twist_decomposition_tas_type}
Assume that $s \in \Spin(3)$ is a spinor. For any non-zero base vector $v \in \mathrm{C}\ell_3$ such that $s v s^{-1} \ne -v$ there exist \textbf{a unique up to the sign} swing-twist decomposition in twist-after-swing representation
\begin{equation*}
s = \pm q p
\end{equation*}
where swing spinor $p$ and twist spinor $q$ are equal to:
\begin{align*}
& p = \pm \tilde{\sigma}_v(s) s \\
& q = \pm \sigma_v(s)
\end{align*}
where $\sigma_v(s)$ is a twist projection function.
\end{theorem}
\begin{proof}
Assume that $u = s^{-1}$. According to theorem \ref{thm:swing_twist_decomposition_tas_type} there exists a swing-twist decomposition of spinor $u$ in swing-after-twist representation:
\begin{equation*}
u = \pm p q
\end{equation*}
where $p$ is a swing factor and $q$ is a twist factor of $u$ in respect to the base vector $v$. Taking inverse of both sides one obtains:
\begin{equation*}
u^{-1} = s = \pm q^{-1} p^{-1}
\end{equation*}
which is a twist-after-swing decomposition of spinor $s$. Swing and twist factors can be rewritten as:
\begin{align*}
p^{-1} & = (u \tilde{\sigma}_v(u))^{-1} = (s^{-1} \tilde{\sigma}_v(s^{-1}))^{-1} = \tilde{\sigma}_v(s^{-1})^{-1} s = \tilde{\sigma}_v(s) s \\
q^{-1} & = \sigma_v(u)^{-1} = \sigma_v(s^{-1})^{-1} = \sigma_v(s)
\end{align*}
which completes the proof.
\end{proof}
\section{Twist projection function}
In this section basic properties of the twist projection function are discussed. Intuitively, twist projection function takes a spinor and returns its twist factor in respect to a given vector. In this paper the following definition was assumed
\begin{equation*}
\sigma_v(s) := \N(v (v \cdot s))
\end{equation*}
This is algebraically equivalent to projecting it onto a vector in the sense of Clifford algebra. This an improvement over the work of Huyghe \cite{huyghe} where the author introduces similar projection operator artificially in quaternion algebra. Twist projection function is a projection due to the following
\begin{proposition}
A twist projection function is a projection.
\end{proposition}
\begin{proof}
It is enough to prove that $\sigma_v(\sigma_v(s)) = \sigma_v(s)$ for any vector $v$ and any spinor $w$:
\begin{align*}
& \sigma_v(\sigma_v(s)) = \N(v (v \cdot \N(v (v \cdot s)))) = \N(v (v \cdot \frac{a \|v\| + \mathbf{e}_{123} \N(v) (v \cdot \star [s]_2)}{\sqrt{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}})) \\
& = \N(v \frac{v \cdot a \|v\| + \mathbf{e}_{123} (v \cdot \N(v)) (v \cdot \star [s]_2)}{\sqrt{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}}) = \N(v \frac{v \cdot a \|v\| + \mathbf{e}_{123} \|v\| v \cdot \star [s]_2}{\sqrt{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}}) \\
& = \N(v \frac{(\|v\| v) \cdot (a + \star [s]_2)}{\sqrt{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}}) = \N(\|v\|^2 \frac{\N(v) (v \cdot s)}{\sqrt{(v \cdot \star[s]_2)^2 + a^2 \|v\|^2}}) \\
& = \N(v (v \cdot s)) = \sigma_v(s)
\end{align*}
which completes the proof.
\end{proof}
\section{Applications}
In this section an exemplary application of the proposed theoretical results is presented. It is a fast, concise and numerically stable algorithm for calculating swing-twist decomposition of a spinor.
\subsection{An efficient algorithm for swing-twist decomposition of a spinor}
To propose an efficient method of calculating swing-twist decomposition the following formula is used for twist projection function:
\begin{align*}
& \sigma_v(s) = \N(v (v \cdot s)) = \N(v (v \cdot (a + \mathbf{e}_{123} \star [s]_2)) = \\
& = \N(v (v a + \mathbf{e}_{123} v \cdot \star [s]_2)) = \N(a \|v\|^2 + \mathbf{e}_{123} v (v \cdot \star [s]_2))
\end{align*}
If a rotation is represented by a pinor normalization can be omitted. In case of spinor representation normalization is needed and requires square root computation or equivalently requires arithmetic with square root extension. The proposed method uses swing-after-twist representation and is presented in algorithm \ref{algorithm_main}.
\begin{algorithm}
\caption{Compute swing-twist decomposition of a spinor $s = p q$}
\label{algorithm_main}
\begin{algorithmic}
\REQUIRE $v = x \mathbf{e}_1 + y \mathbf{e}_2 + z \mathbf{e}_3$, $s = a + b \mathbf{e}_{12} + c \mathbf{e}_{23} + d \mathbf{e}_{31}$
\ENSURE $\|v\| \neq 0$
\STATE $u \leftarrow x c + y d + z b$
\STATE $n \leftarrow x^2 + y^2 + z^2$
\STATE $m \leftarrow a n$
\STATE $l \leftarrow \sqrt{m^2 + u^2 n}$
\STATE $q \leftarrow \frac{m}{l} + \frac{z u}{l} \mathbf{e}_{12} + \frac{x u}{l} \mathbf{e}_{23} + \frac{y u}{l} \mathbf{e}_{31}$
\STATE $p \leftarrow s \tilde{q}$
\RETURN p, q
\end{algorithmic}
\end{algorithm}
Because of its simplicity the proposed method favourably compares to existing methods for computing swing-twist decomposition (as presented in section \ref{section_existing_and_related_solutions}.
|
{'timestamp': '2015-06-19T02:01:07', 'yymm': '1506', 'arxiv_id': '1506.05481', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05481'}
|
arxiv
|
\section{Estimation Algorithm}\label{sec:algo}
We now present an algorithm to estimate the parameters $\left\{\left(\left|g_l\right|, \bm{\omega}^t_l\right), l = 1,\dots, K\right\}$ characterizing the mm-wave channel as seen from the basestation. The same algorithm applies for both forms of feedback discussed in Section~\ref{sub-sec:channel_feedback}: the entire measured virtual MIMO matrix $\mathbf{Y}$ or the dominant weighted left singular vectors $\mathbf{D}$.
The $k$th column of $\mathbf{Y}$ is given by
\begin{equation}\label{eq:measurements_all}
\mathbf{y}_k = \sum_{l=1}^{l=K} h_{l, k} \bm{A}\mathbf{x}_t\left( \bm{\omega}^t_l \right) + \mathbf{z}_k,~k = 1,\dots,L
\end{equation}
where $\mathbf{z}_k\sim\mathcal{CN}\left(\mathbf{0}, \sigma^2\eye{M}\right)$ denotes the $k$-th column of $\mathbf{Z}$ and $h_{l, k} = \sqrt{P_e}g_l \mathbf{b}_k^T\mathbf{x}_r\left(\bm{\omega}^r_l\right)$. We assume the weight sequence $\left\{\mathbf{b}_k\right\}$ used to construct the receive virtual antennas at the receive antenna array is not available at the transmitter, and hence cannot jointly estimate $\bm{\omega}^t_l$ and $\bm{\omega}^r_l$. However, since $\{\mathbf{b}_k,~k=1,\dots,L\}$ were picked in an i.i.d manner, we have that $\left\{h_{l, k},~k=1,\dots,L\right\}$ are i.i.d realizations of a random variable with $\mathbb{E}\left|h_{l, k}\right|^2= {P_e}\mathbb{E}\left|g_l\mathbf{b}_k^T\mathbf{x}_r\left(\bm{\omega}^r_l\right)\right|^2 = {P_e}N_{r,1D}^2\left|g_l\right|^2$. This allows us to estimate $\left|g_l\right|^2$ as follows:
$$
{P_e}\abs{\hat{g}_l}^2 = \left(\fracc{1}{\left(LN_{r,1D}^2\right)}\right)\sum_{k=1}^{k=L}\abs{\hat{h}_{l,k}}^2.
$$
From here on, in Section~\ref{sec:algo}, we use the notation $\bm{\omega}_l$ to refer to $\bm{\omega}^t_l$ and $\mathbf{x}(\bm{\omega}_l)$ to refer to $\bm{A}\mathbf{x}_t(\bm{\omega}^t_l)$. Thus, the measurements can be written as
\begin{equation} \label{eq:measurements_simple}
\mathbf{y}_k = \sum_{l=1}^{l=K} h_{l, k} \mathbf{x}\left( \bm{\omega}_l \right) + \mathbf{z}_k,~k = 1,\dots,L.
\end{equation}
We now provide an algorithm to estimate $\{\bm{\omega}_l,\{h_{l,k}\}\}$.
\subsection{Single path}\label{sub-sec:algo-single:path}
We first present an algorithm for estimating a single path $K=1$, which forms the basis for our sequential estimation algorithm for $K>1$. Omitting the path index $l$ in \eqref{eq:measurements_simple}, we have
\begin{equation*}
\mathbf{y}_k = h_{k} \mathbf{x}\left( \bm{\omega} \right) + \mathbf{z}_k,~k = 1,\dots,L.
\end{equation*}
Given that $\{\mathbf{z}_l\}$ are independent realizations of $\mathcal{CN}\left(\mathbf{0}, \sigma^2\eye{M}\right)$, the maximum likelihood (ML) estimates of $\bm{\omega}, \left\{h_{k}\right\}$ are given by:
\begin{equation}\label{eq:ML_est}
\hat{\bm{\omega}}, \left\{\hat{h}_{k}\right\} = \underset{\bm{\omega}, \left\{h_{k}\right\}}{\arg\min}\sum_{k = 1}^{k=L} \left\Vert \mathbf{y}_k - h_{k}\mathbf{x}\left( \bm{\omega} \right) \right\Vert^2.
\end{equation}
For any $\bm{\omega}$, the optimal $h_{k}$-s are given by least-squares estimates:
\begin{equation}\label{eq:opt_gains}
h^{\star}_{k}\left(\bm{\omega}\right) = \fracc{\innerProd{\mathbf{x}\left( {\bm{\omega}}\right)}{\mathbf{y}_k}}{\norm{\mathbf{x}\left( {\bm{\omega}} \right)}^2}
\end{equation}
where $\langle x,y \rangle$ denotes $x^H y$. Plugging into \eqref{eq:ML_est}, the ML estimate of $\bm{\omega}$ is given by:
\begin{align}
\hat{\bm{\omega}} & = \underset{\bm{\omega}}{\arg\max} ~~ \frac{1}{\left\Vert\mathbf{x}\left( \bm{\omega} \right)\right\Vert^2}\sum_{k = 1}^{k=L} \left|\left<\mathbf{x}\left( \bm{\omega} \right), \mathbf{y}_k \right>\right|^2\label{eq:GLRT_omega}
\end{align}
and the ML estimate of $h_{k}$ is given by $h^{\star}_{k}\left(\hat{\bm{\omega}}\right)$. We employ a two-step algorithm to arrive the ML estimates: a ``detection'' phase followed by a ``refinement'' phase.
\vspace{1.5pt}\\
\noindent\textbf{Detection phase:} Using $M$ two-dimensional FFT computations, we precompute $\mathbf{x}(\bm{\omega})$ for frequencies of the form $\bm{\omega} \in \Phi \equiv \left\{ \left(2\pi k/T, 2\pi l / T\right),~0\leq k,l\leq T-1\right\},~T = RN_{1D,t}$, where $R$ is the oversampling factor. We pick the frequency $\hat{\bm{\omega}}$ from $\Phi$ which maximizes \eqref{eq:GLRT_omega}. The corresponding gains are given by $\hat{h}_{k} = {h}^{\star}_{k}\left(\hat{\bm{\omega}}\right)$. We remove the contribution of the newly detected sinusoid from the measured channel response and this residual measurement is given by
\begin{equation}\label{eq:residue_single}
\mathbf{r}_{k} = \mathbf{y}_k - \hat{h}_{k} \mathbf{x}\left(\hat{\bm{\omega}}\right).
\end{equation}
(This residue is used for sequential detection for $K>1$, as discussed shortly.)
\vspace{1.5pt}
\noindent\textbf{Refinement phase:} Our estimate from the detection phase is restricted to the discrete set $\Phi$ and consequently we do not expect $\hat{\bm{\omega}}$ to be equal to the ML estimate given by \eqref{eq:GLRT_omega} (where the maximization is over $[-2\pi d/\lambda,2\pi d/\lambda]^2$ with $d$ being the spacing between transmitter antennas). However, if we make the grid fine enough, the best estimate of $\bm{\omega}$ in $\Phi$ is expected to be close enough to the optimal solution to allow refinement via local optimization. In order to do this, we first \emph{fix} the gain estimates $\{\hat{h}_{k}\}$ and refine only the estimate of the spatial frequency $\bm{\omega}$ by seeking the minimizer of the ML cost function
\begin{equation*}
C(\bm{\omega}) = \sum_{k = 1}^{k=L} \left\Vert \mathbf{y}_k - \hat{h}_{k}\mathbf{x}\left( \bm{\omega} \right) \right\Vert^2
\end{equation*}
in the neighborhood of the current estimate $\hat{\bm{\omega}}$ using the Newton method. This involves evaluating the gradient vector $\mathcal{G}\left(\bm{\omega}\right)$ and the Hessian matrix $\mathcal{H}(\bm{\omega})$ of $C(\bm{\omega})$ at the current estimate $\hat{\bm{\omega}}$. The corresponding expressions are given by:
\begin{align*}
\mathcal{G}_i(\bm{\omega}) & =\frac{\partial C(\bm{\omega})}{\partial\omega_i} = - 2 \sum_{k = 1}^{k=L} \Re\left\{ \innerProd{ \mathbf{r}_k }{ \hat{h}_{k}\frac{\partial \mathbf{x}(\bm{\omega})}{\partial\omega_i} }\right\},\\
\mathcal{H}_{ij}(\bm{\omega}) & =\frac{\partial^2 C(\bm{\omega})}{\partial\omega_i\partial\omega_j} = - 2 \sum_{k = 1}^{k=L} \Re\Bigg\{ \innerProd{ \mathbf{r}_k }{ \hat{h}_{k}\frac{\partial^2 \mathbf{x}(\bm{\omega})}{\partial\omega_i\partial\omega_j}} - \\
&~~~~~~~ \abs{\hat{h}_{k}}^2 \innerProd{ \frac{\partial \mathbf{x}(\bm{\omega})}{\partial\omega_i} }{ \frac{\partial \mathbf{x}(\bm{\omega})}{\partial\omega_j} }\Bigg\},~1\leq i,j\leq 2
\end{align*}
where $\bm{\omega} = [\omega_1,\omega_2]$. $\{\mathbf{r}_k\}$-s are the residual measurements given by \eqref{eq:residue_single}. The Newton update for $\hat{\bm{\omega}}$ is
\begin{equation}\label{eq:refine_omega}
\hat{\bm{\omega}} \gets \hat{\bm{\omega}} - \mathcal{H}^{-1} \left(\hat{\bm{\omega}}\right) \mathcal{G}\left(\hat{\bm{\omega}}\right).
\end{equation}
We follow this up by updating our estimates $\left\{\hat{h}_{k}\right\}$ by plugging the new value of $\hat{\bm{\omega}}$ in \eqref{eq:opt_gains}, i.e.,
\begin{equation}\label{eq:update_gain}
\hat{h}_{k} \gets h^{\star}_k\left(\hat{\bm{\omega}}\right) = \fracc{ \innerProd{\mathbf{x}\left(\hat{\bm{\omega}} \right) }{ \mathbf{y}_k } }{ \norm{ \mathbf{x}\left( \hat{\bm{\omega}} \right) }^2 }
\end{equation}
and modifying the residues ($\{\mathbf{r}_k\}$) accordingly using \eqref{eq:residue_single}. The algorithm alternates between the updates in \eqref{eq:refine_omega} and \eqref{eq:update_gain} for a few iterations.
\subsection{Multiple paths}\label{sub-sec:algo-multiple:paths}
We now build on the preceding single path algorithm for the general setting of $K \geq 1$. Suppose that our current estimate of the sinusoids/paths is given by $\mathcal{P}_{K} = \left\{\left(\hat{\bm{\omega}}_l, \{\hat{h}_{l, k}\}\right),~l=1,\dots,K\right\}$. The residual measurements corresponding to a set of estimated parameters $\mathcal{P}$ is given by:
$$ \textstyle
\mathbf{v}_k(\mathcal{P}) = \mathbf{y}_k - \sum_{{\bm{\omega}}_l, \{{h}_{l, k}\} \in \mathcal{P}} {h}_{l, k} \mathbf{x}\left({\bm{\omega}}_l\right).
$$
\noindent\textbf{Detect a new path:} Assuming that the measurements $\mathbf{y}_k$ are given by the current residue $\mathbf{v}_k(\mathcal{P}_{q})$ (corresponding to the $q$ detected paths), we use the single path algorithm in Section~\ref{sub-sec:algo-single:path} to detect and refine a new sinusoid $(\hat{\bm{\omega}}_{q+1}, \{\hat{h}_{q+1, k}\})$. Let $\mathcal{P}_{q+1}$ denote the new set of estimated parameters $\mathcal{P}_q \cup \{(\hat{\bm{\omega}}_{q+1}, \{\hat{h}_{q+1, k}\})\}$.
\vspace{1.5pt}
\noindent\textbf{Refine existing paths:} Once we add this new path, we refine the parameters of \emph{all} $q+1$ sinusoids in $\mathcal{P}_{q+1}$ one by one. Consider the parameters $(\hat{\bm{\omega}}_{l}, \{\hat{h}_{l, k}\})$ of the $l$-th sinusoid. We use the refinement algorithm in Section~\ref{sub-sec:algo-single:path} to refine $(\hat{\bm{\omega}}_{l}, \{\hat{h}_{l, k}\})$ by assuming that the measurements $\mathbf{y}_k$ are given by the residual measurements after excluding the sinusoid of interest. i.e, $\mathbf{v}_k(\mathcal{P}_{q+1}\setminus \{(\hat{\bm{\omega}}_{l}, \{\hat{h}_{l, k}\})\})$. Sinusoids are refined in a round robin manner, and the process is repeated for a few rounds: $1\rightarrow 2\rightarrow\dots\rightarrow(q+1)\rightarrow 1\rightarrow\dots\rightarrow(q+1)$.
\vspace{1.5pt}
\noindent\textbf{Stopping criterion:} The algorithm continues to add newly detected paths as long as the payoff, determined by the total amount by which the residue decreases is above a threshold $\tau$. i.e., if
\begin{equation}\label{eq:stopping_criterion}
\sum_{k = 1}^{k = L} \left( \norm{ \mathbf{v}_k(\mathcal{P}_{q}) }^2 - \norm{ \mathbf{v}_k(\mathcal{P}_{q+1}) }^2 \right) > \tau,
\end{equation}
the $(q+1)$-th path is added and the algorithm proceeds by searching for a new path. On the contrary, if the reduction in total residue is smaller than $\tau$, the algorithm terminates and returns the prior estimate of the parameters $\mathcal{P}_{q}$. For the stopping criterion, we use $\tau = 30 \sigma^2 \log\left(20N_{t,1D}\right)$ in our simulations. This stopping criterion is empirically determined, such that the signal energy $\tau$ is large enough to comfortably cross the ZZB threshold (so that we can expect the frequency estimate to be accurate).
\subsection{Tracking}\label{sub-sec:algo-tracking}
We sound the channel often enough so that between any two successive channel estimation cycles, the \emph{geometry} of the mm-wave channel, given by the spatial frequencies $\{\bm{\omega}_l\}$ of the paths, do not change ``significantly,'' even if the path gains $\{g_l\}$ do. This ensures that angle of departure estimates from the prior sounding round do not become stale over the course of the communication phase during which they are needed for beamforming purposes. For example, if we do not wish to tolerate a beamforming loss of $3$dB or more, then our estimate from the previous round $\hat{\bm{\omega}}$ should be close enough to the current $\bm{\omega}$ so that
$$
\fracc{\abs{\innerProd{\mathbf{x}\left(\hat{\bm{\omega}}\right)}{\mathbf{x}\left({\bm{\omega}}\right)}}^2}{\norm{\mathbf{x}\left({\bm{\omega}}\right)}^2} > 0.5
$$
over the entire communication phase. This condition is met if $\norm{{\bm{\omega}}-\hat{\bm{\omega}}}_\infty < 0.5 \times \left(\fracc{2\pi}{N_{t, 1D}}\right)$. Therefore, the estimates of spatial frequencies from the previous sounding round are good approximations of their current true value (within a DFT spacing of $\frac{2\pi}{N_{t, 1D}}$). We exploit this by using $\{\hat{\bm{\omega}}_l,~l=1,\dots, K\}$ from the prior round to initialize our algorithm (as opposed to using the empty set $\{\}$). We do this by constructing the matrix $\mathbf{X} = \left[ \mathbf{x}\left(\hat{\bm{\omega}}_1\right)~\dots~\mathbf{x}\left(\hat{\bm{\omega}}_K\right) \right]$ and setting $\hat{h}_{i,j}$ to be the $(i,j)$-th entries of $\left(\mathbf{X}^H\mathbf{X}\right)^{-1}\mathbf{X}^H\mathbf{Y}$, where $\mathbf{Y} = [\mathbf{y}_1~\dots~\mathbf{y}_L]$. We refine all parameters in $\mathcal{P}_K = \{(\hat{\bm{\omega}}_{i}, \{\hat{h}_{i, j}\}),~i=1,\dots, K\}$ using the refinement algorithm in Section~\ref{sub-sec:algo-multiple:paths} before proceeding to seek for new paths using the algorithm in Section~\ref{sub-sec:algo-multiple:paths}.
\noindent\textit{Deleting weak paths:} Paths estimated in prior rounds may not be viable at the current time instant (e.g, because of blockage). Therefore, we need means to remove such stale paths. We use the stopping criterion \eqref{eq:stopping_criterion} as a means to delete weak paths. If deleting the path under question and optimizing other parameters increases the residue by an amount smaller than $\tau$, we delete the path permanently. Otherwise we keep the path.
\section{Conclusions} \label{sec:conclusions}
We have shown that it is possible to super-resolve mm wave spatial channels with a relatively small number of compressive measurements, in a manner that is compatible with coarse phase-only control and RF beamforming. This allows scaling to a very large number of antenna elements without relying on channel reciprocity. While our discussion of system design issues such as link budget and inter-cell beacon interference is tailored to outdoor 60 GHz picocellular networks, the basic approach is broadly applicable (e.g., to other bands, and to indoor environments). An important topic for future work is comprehensive experimental validation of our compressive approach, which is based on a simple channel model including only the dominant rays. At the network level, there are a host of design issues (e.g., see discussion in \cite{Zhu_Mobicom2014}). The compressive approach allows each base station to build up an inventory of viable paths to nearby mobiles, but there is a huge design space to be explored on how base stations coordinate using this information to alleviate the effects of blockage (mobiles in urban environments can be routinely blocked by pedestrians, automobiles, trees and other obstacles), and to manage inter- and intra-cell interference. Optimization of arrays of subarrays in base station ``faces'' for communicating with multiple users, as well as for handling channel dispersion, presents interesting design challenges.
\section{Introduction}
\label{sec:intro}
The explosive growth in demand for wireless mobile data, driven by the proliferation of ever more sophisticated handhelds creating and consuming rich multimedia, calls for orders of magnitude increases in the capacity of cellular data networks \cite{mobiledata}. Millimeter wave communication from picocellular base stations to mobile devices is a particularly promising approach for meeting this challenge because of two reasons. First, there are huge amounts of available spectrum, enabling channel bandwidths of the order of GHz, 1-2 orders of magnitude higher than those in existing systems at lower carrier frequencies. Indeed, channel bandwidths could potentially increase even further with advances in transceiver technology such as bandwidth/power consumption/linearity tradeoffs for ultra high-speed analog electronics, and speed/precision/power consumption tradeoffs for analog-to-digital converters. Second, the small carrier wavelength enables the realization of highly directive steerable arrays, with a large number of antenna elements, in compact form factors, thus significantly enhancing spatial reuse. In this paper, we address fundamental signal processing challenges associated with channel estimation and tracking for such large arrays, placed within the context of system design for a mm wave picocellular network.
While the signal processing and system design concepts presented here are of rather general applicability, our numerical results are for a particular setting that we feel has great promise, as also discussed in some of our prior publications \cite{ramasamy_allerton12,Zhu_Mobicom2014}. We propose to employ the 60 GHz unlicensed band for base station to mobile communication in outdoor picocells. The base stations can be deployed on lampposts, rooftops or ledges, and have multiple ``faces,'' with each face containing one or more antenna arrays. An example deployment on lampposts in a zig-zag configuration (successive base stations on opposite sides of the street) along an urban canyon is shown in Figure \ref{fig:urban}. At the base station, we consider very large $32 \times 32$ arrays (such 1000-element arrays are still only palm-sized at a carrier wavelength of 5 mm) targeting the long term, as well as ``moderately sized'' $8 \times 8$ arrays (which can fit within an area of about half a square inch) which are currently realizable. Note that 16-element arrays were reported several years ago \cite{Valdes_2010}, and are already deployed in existing 60 GHz products, while 32-element arrays have been prototyped \cite{Cohen_2012}. We assume that mobile devices are equipped with smaller $4 \times 4$ antenna arrays. We focus on 60 GHz in order to leverage the significant advances that have occurred over the past few years targeting indoor wireless networks: once 60 GHz transceivers are embedded in mobile devices, one could use them to extend coverage to outdoor picocells, albeit with different approaches to medium access than in standard indoor wireless networking protocols. We focus on downlink 60 GHz communication, with the goal of enabling base station arrays to perform transmit beamforming towards mobile devices, despite the challenges posed by mobility and blockage (which occurs more easily at smaller wavelengths). We do not count on reciprocity. The uplink could be a standard LTE or WiFi link at lower carrier frequencies, used both for uplink data (not modeled here) and feedback for enabling spatial channel estimation at the transmitter.
\begin{figure}
\begin{center}
\includegraphics[width=3.5in]{street}
\caption{Picocellular network deployed along an urban canyon}
\label{fig:urban}
\end{center}
\end{figure}
Multiple antenna systems at lower carrier frequencies have a relatively small number of elements, each with its own radio frequency (RF) chain. This provides control of the individual baseband signals associated with each element, enabling sophisticated adaptation, including frequency-selective spatiotemporal processing (e.g., per subcarrier beamforming in OFDM systems). This approach does not scale when we have a large number of antenna elements packed into a tiny form factor. Instead, we consider RF beamforming, in which a common baseband signal is routed to/from the antenna elements, and we can only control the amplitude and phase for each element. Indeed, we go even further, assuming that the amplitude for each element is fixed, and that we can only apply coarse four-phase control for each element. Standard least squares array adaptation and channel estimation techniques, which require access to the baseband signals associated with each element, do not apply in this setting. Instead, we consider here a {\it compressive} approach which exploits the sparsity of the mm wave channel, so that relatively few measurements are required for channel estimation despite the large number of array elements.
\begin{figure
\centering
\includegraphics[width=0.9\columnwidth]{feedBackCompressiveNew2}
\caption{Channel sounding scheme: The transmitter repeats the $M$ transmit beacons $L$ times so that receivers can measure the channel $v_{i,j}$ between every virtual transmit-receive pair}
\label{fig:channel_sounding}
\end{figure}
\noindent
{\bf Contributions:} Our contributions are summarized as follows:\\
{\it Architecture:} We propose a novel architecture in which base stations send out compressive beacons, with a different set of pseudorandom phases used to transmit each beacon. Each mobile measures the complex gains associated with each beacon compressively, using pseudorandom control of the phases of its receive array. The scheme, described in more detail later, is depicted in Figure \ref{fig:channel_sounding}: the base station sends $M$ beacons, repeated $L$ times, which permits the mobile to use $L$ different settings of its own array to measure the associated complex gains. Each mobile feeds back appropriately chosen functions of its measurements to the base stations on the uplink (which can be a standard LTE link). Each base station use this information to estimate and track the dominant paths to each mobile that it receives feedback from. \\
{\it Algorithms:} For the regular two-dimensional (2D) arrays considered here, directions of arrival/departure map to 2D spatial frequencies. The base station estimates the spatial frequencies to each mobile using a simple sequential algorithm, shown to be near-optimal (in terms of approaching the Cramer-Rao Bound) in related publications. The algorithm exploits the geometric continuity of the channel across successive beaconing intervals to reduce the required number of compressive measurements.\\
{\it System Design:} While we do not provide a complete system design centered around our compressive strategy, we do provide preliminary results addressing some of the most important issues. We show that the overhead incurred by our beaconing scheme is very small (less than 1\%). Furthermore, while compressive beacons are essentially omnidirectional (in contrast to the highly directive beams employed for communication), the link budget suffices for accurate channel estimation, and a simple beacon reuse strategy suffices to control inter-beacon interference across picocells.
\section{Background and Related Work}
There is a significant body of recent literature on the potential for mm wave communication for next generation mobile cellular networks \cite{Rajagopal_Globecom_2011, Heath_asilomar2012, Rappaport_38G, Rappaport_WCNC2012, Rappaport_JSAC2014, Zhu_Mobicom2014}. For these outdoor settings, most of the attention has focused on bands other than 60 GHz; for example, \cite{Rappaport_JSAC2014} studies blockage probabilities and achievable throughput based on measurements in the 28, 38, 71-76 and 81-86 GHz bands. However, as pointed out in our prior work \cite{Zhu_Mobicom2014}, 60 GHz has immense potential at the relatively short ranges of interest in urban picocells, with the oxygen absorption characteristic of this band only having a marginal impact on the link budget (e.g., only 1.6 dB at 100m). While studies such as \cite{Heath_asilomar2012, Rappaport_38G, Rappaport_WCNC2012, Rappaport_JSAC2014} focus on coarse-grained channel statistics (and their implications on system design and performance), our focus here is on signal processing for fine-grained channel estimation.
We assume that the channel is well described by a relatively small number of discrete rays with delays and angles of arrival/departure taking values in a continuum. The key contribution of this paper is to provide a super-resolution framework for estimating and tracking these rays, with model-based estimation allowing us to go beyond (spatial) bandwidth based resolution limits. To the best of our knowledge, the existing literature on mm wave measurements does not attempt to super-resolve channels in this fashion, hence we do not know, for example, whether the continuous power-delay profiles reported in \cite{Rappaport_JSAC2014} are consistent with a parsimonious channel model such as ours. However, preliminary experimental results \cite{Berraki_WCNC2014}, which use compressive measurements to successfully recover power-angle profiles for a controlled experiment (a small number of reflectors in an anechoic chamber), indicate that a simple ray-based model like ours may well suffice. Validating this assertion would require application of the more sophisticated compressive estimation techniques discussed here, as opposed to the standard basis pursuit algorithms employed in \cite{Berraki_WCNC2014}. Note that existing models for simulation-based evaluations, such as the channel models standardized for IEEE 802.11ad indoor 60 GHz channels, typically {\it assume} more complex models which are variants of the Saleh-Valenzuela model, with a number of clusters, each consisting of multiple closely spaced rays. Such cluster-based models could be motivated by the roughness of reflecting surfaces such as walls, but they have not been experimentally demonstrated. While these issues fall beyond the scope of the present paper, which aims to make a fundamental contribution to signal processing for sparse spatial channels, a sustained effort in measurement-based validation of our model and approach is a critically important topic for future work.
Alternative approaches to spatial channel estimation with RF beamforming include codebook-based techniques; in an indoor WPAN setting, it was shown in \cite{Junyi_JSAC2009} that the minimum number of scanning beams for RF beamforming to get beamforming gains close to (within a dB) that of exhaustive search is twice the number of antenna elements. This approach does not scale to the large arrays of interest to us. Hierarchical codebook search \cite{david_love} is more efficient, but still requires far more overhead than our scheme, since it does not exploit channel sparsity.
A hardware enhancement to pure RF beamforming as considered here (where a single RF chain serves all antenna elements) is to employ hybrid analog-digital beamforming, with a number of RF chains smaller than the number of antenna elements. We may term this an {\it array of subarrays,} with RF-level control for subarrays, and digital processing of subarray outputs. Such an approach is used in \cite{Heath_JSTSP2014,Heath_SPAWC_2014} for spatial channel estimation. Our work shows, however, that a single RF beamformed array suffices for this purpose. Of course, arrays of subarrays are certainly required for more advanced functionalities such as multiuser MIMO \cite{Tadilo_Globecom2014}, spatial multiplexing \cite{torkildson,Gaojian2014,Singh_Globecom2014,Heath_ICC2012,Heath_SPAWC2012}, and spatial diversity \cite{Singh_Globecom2014,zhang2010statistical,zhang2010channel}. Integrating the compressive approach proposed in this paper within an array of subarrays architecture is an interesting area for future work.
The present paper builds on our prior conference papers on compressive array adaptation \cite{ramasamy_ita12,ramasamy_allerton12}, but goes well beyond them in several respects. In addition to a more detailed development of the analytical framework underlying our estimation algorithm, we now explicitly model the receive array at the mobile, which requires a generalization of the beaconing and feedback strategy. We also address system level design for compressive tracking in far greater detail, discussing link budget and overhead, and accounting for inter-cell beacon interference. Our initial work on compressive array adaptation \cite{ramasamy_ita12} subsequently led to a general framework for compressive estimation \cite{ramasamy_asilomar12,Ramasamy_TSP_2014}, which identify the isometries required to preserve fundamental bounds such as the Ziv-Zakai (ZZB) and Cramer-Rao (CRB), and use the relationship between these bounds to provide criteria for determining the minimum number of compressive measurements required to preserve geometry and to permit accurate parameter estimation based on a signal corrupted by an AWGN. We now adapt these general results here to develop guidelines for system-level parameter choices.
\section{System design}\label{sec:link_budget}
We now discuss some key aspects of downlink system design related to our compressive architecture. We start by choosing basestation transmit power based on rules set by regulatory authorities, and then filling in the other details of the protocol according to the prescriptions laid out in Section~\ref{sec:protocol_choice}. Fixing the mobile array to be $4 \times 4$ ($N_{r,1D} = 4$), we consider two different choices for the base station array size: $8 \times 8$ ($N_{t,1D} = 8$) and $32 \times 32$ ($N_{t,1D} = 32$). All arrays are $d = \lambda/2$-spaced. The total available bandwidth for communication and sounding is $2$GHz.
\subsection{Transmit power}
We fix the effective isotropically radiated power (EIRP) to $40$dBm, consistent with Federal Communications Commission (FCC) regulations for 60 GHz unlicensed transmission. Accounting for transmit beamforming gain using an $N_{t,1D} \times N_{t,1D}$ array, the total transmit power
\begin{equation} \label{eq:transmit_power}
P = 40 - 20 \log N_{t,1D}~\text{dBm}
\end{equation}
which evaluates to $22$dBm and $10$dBm for $N_{t,1D} = 8$ and $N_{t,1D} = 32$ respectively. Assuming that this power is evenly split among the $N_{t,1D}^2$ transmit elements, the power per transmit element is given by $P_e = P - 20 \log N_{t,1D}~\text{dBm} = 40 -20 \log N_{t,1D}~\text{dBm}$, which evaluates to $4$dBm and $-20$dBm, respectively. Assuming that we design each element to operate at a fixed power, this is also the power per element used in the beaconing phase, even though the latter does not get the benefit of transmit beamforming.
\subsection{Communication range}
In order to ensure that the SNR for compressive estimation is adequate over a picocell, we first determine the picocell size using a nominal communication link budget, and then calculate the overhead required for successful estimation at that range. Standard link budget calculations, assuming oxygen absorption of 16 dB/km, an EIRP of $40$dBm and a $4 \times 4$ receive array providing directivity gains of 12 dBi, can be used to show that we can attain a per-symbol SNR of $6$dB at a link margin of $10$dB for a symbol rate of $2$GHz at a range of $200$m. For omnidirectional free space propagation, the power gain in dB as a function of range $r$ is given by
$$
G_{dB} (r) =- \mu r + 20 \log_{10} \frac{\lambda}{4 \pi r} ~~{\rm (dB)}
$$
where $\mu = 0.016$dB/m to account for oxygen absorption. Note that $\mu$ can be increased in order to account for rain. However, since our purpose is to ensure that channel estimation is successful whenever communication is successful, the contribution due to $G_{dB} (r)$ cancels out, as we show shortly. Thus, while the particular value of $\mu$ determines picocell size, we shall see that it does not affect the overhead for channel estimation.
The SNR per symbol is given by
\begin{align} \label{eq:snrc}
\texttt{SNR}_{\text{c}} {\rm (dB)} &= {\rm EIRP ~(dBm)} + G_{dB} (r) + 20 \log_{10} N_{r,1D} \\ \nonumber
& - 10\log_{10} \left(\text{N}_0 W_c\right) - L_{margin} (comm)
\end{align}
where $L_{margin} (comm)$ is the link margin (dB) for communication. Note that $10 \log_{10} N_0 = -174 + NF$ dBm over a bandwidth of 1 Hz, where $NF$ denotes the receiver noise figure in dB. Plugging in $W_c = 2$GHz, $N_{r, 1D} = 4$, and $NF=6$dB, we obtain a per symbol SNR of 7 dB at a range of $r=100$ meters.
\subsection{Channel sounding protocol}\label{sub-sec:sounding-protocol}
Our channel sounding protocol is specified by four parameters: (i) bandwidth used by each basestation when sounding the channel, which we denote by $W_s$ (ii) number of transmit beacons (or virtual transmit antennas) $M$ (iii) number of receive measurements per transmit beacon (or virtual receive antennas) $L$ and (iv) sounding rate $f_B$ which determines how often the channel is sounded. The parameters $M,L$ and $W_s$ together determine the effective sounding SNR. This must exceed the ZZB threshold SNR for successful channel estimation. This gives rise to the condition in \ref{eq:sounding_time}. Imposing an estimation link margin $L_{margin} (est)$ (dB) and going to the dB domain, we have
\begin{align} \label{eq:sounding_time_with_distance}
10\log_{10} \left(\fracc{ML}{W_s}\right) & \geq \texttt{SNR}_{\text{th}} + L_{margin} (est) \\
& +10 \log_{10} N_0 - P - G_{dB} (r) \nonumber
\end{align}
Adding (\ref{eq:sounding_time_with_distance}) and (\ref{eq:snrc}) and simplifying, we obtain
\begin{align*}
10\log_{10} \left(\fracc{ML}{W_s}\right) &\geq \texttt{SNR}_{\text{th}} - \texttt{SNR}_{\text{c}} + L_{margin} (est) \\
&- L_{margin} (comm) + 20 \log_{10} N_{t,1D} \\
& + 20 \log_{10} N_{r,1D} - 10 \log_{10} W_c
\end{align*}
The key take-away is that $ML/W_s$ must be large enough to compensate for the fact that we do not have the benefit of beamforming during the sounding phase. Notice that the range $r$ (i.e., the dependence on picocell size) has cancelled out. Setting $L_{margin} (est)= 16$dB (we use a higher link margin for channel sounding to account for power losses due to randomness of $\bm{A}$ and $\bm{B}$),
we obtain
\begin{equation}\label{eq:sounding_time_with_power}
\text{Time taken} = \frac{ML}{W_s} \geq \begin{cases} 16.34~\mu \text{s} & N_{t,1D}=8\\ 0.2669 ~\text{ms}& N_{t,1D}=32. \end{cases}
\end{equation}
We choose the number of transmitter beacons for the $8 \times 8$ and $32 \times 32$ transmitter arrays based on the geometry preservation criterion for the transmitter's spatial channel estimation problem discussed in Section~\ref{sub-sec:geometry_M}. We use $M=24$ for $N_{t,1D} = 8$ and $M = 30$ for $N_{t,1D} = 32$ by numerically evaluating the worst-case distortion of pairwise distances relevant for the channel estimation problem (in Figure~\ref{fig:choice_of_M} we plot the worst-case distortion as a function of $L$ for a random instance of $\bm{A}$ and $N_{t,1D} = 32$). Using the receive energy preservation criterion given in Section~\ref{sub-sec:geometry_L}, we choose the number of receive weights for the $4\times 4$ receive array as $L = 6$. Using these values for $M$ and $L$ in \eqref{eq:sounding_time_with_power}, we obtain that the channel sounding bandwidth must satisfy
$$
W_s \leq \begin{cases} 8.8124~\text{MHz} & N_{t,1D}=8\\ 674.34~\text{KHz} & N_{t,1D}=32. \end{cases}
$$
We choose $W_s = 8.8124$ MHz for $N_{t,1D}=8$ and $W_s = 674.34$ KHz for $N_{t,1D}=32$ so as to minimize the overhead in time, given by $\fracc{ML}{W_s}$. Our specification of the channel sounding protocol will be complete when we give $f_B$, the rate at which we sound the channel (see Figure~\ref{fig:sound_and_comm}) which must satisfy \eqref{eq:sounding_rate}. Assuming that the closest user is at a distance of $R = 20$m and that the maximum speed of a user in the picocell $v_{\max}$ is $45$ miles per hour ($20$ m/s), we have that: $f_B \geq 8$ Hz for $N_{t,1D}=8$ and $f_B \geq 32$ Hz for $N_{t,1D}=32$. Choosing the minimum value for $f_B$, we have that the overhead for our channel sounding protocol is $\fracc{ML f_B}{W_s} = 0.0131\%$ for $N_{t,1D}=8$ and $0.8542 \%$ for $N_{t,1D}=32$.
\begin{figure
\centering
\includegraphics[width=0.95\columnwidth]{soundingOverhead}
\caption{Channel sounding and communication phases of the proposed system}
\label{fig:sound_and_comm}
\end{figure}
\section*{Acknowledgement}
This work was supported by the National Science Foundation through the grant CNS-1317153, by the Institute for Collaborative Biotechnologies through the grant W911NF-09-0001 from the U.S. Army Research Office and by the Systems on Nanoscale Information fabriCs (SONIC), one of six centers supported by the STARnet phase of the Focus Center Research Program (FCRP), a Semiconductor Research Corporation program sponsored by MARCO and DARPA. The content of the information does not necessarily reflect the position or the policy of the Government, and no official endorsement should be inferred
\bibliographystyle{IEEEtran}
\section{Protocol Parameter Choices}\label{sec:protocol_choice}
In this section, we give a principled approach to choosing parameters of the compressive channel estimation protocol, namely the number of unique transmit beacons $M$, the number of receive measurement weights $L$ and the minimum effective Signal to Noise Ratio (SNR) needed for channel estimation, which we use to choose the sounding bandwidth $W_s$. We then turn to the question of how frequently the channel has to be sounded. In Section~\ref{sec:sims}, we take two scenarios and apply this recipe to arrive at system level parameters for the protocol.
\subsection{Number of compressive transmit beacons}\label{sub-sec:geometry_M}
Our goal is to estimate the spatial frequencies $\{\bm{\omega}^t_l\}$ from measurements of the form
$$
\mathbf{y}_k = \sum_{l=1}^{l=K} h_{l, k} \bm{A}\mathbf{x}_t\left( \bm{\omega}^t_l \right) + \mathbf{z}_k,~k = 1,\dots,L.
$$
The algorithm in Section~\ref{sec:algo} aims to estimate parameters $\left\{{h}_{i,j}, {\bm{\omega}}_i\right\}$ by minimizing the ML cost function:
\begin{align*}
&\textstyle\!\!\!\sum_{j=1}^{j=L} \norm{\mathbf{y}_j - \sum_{i=1}^{i={K}} \hat{h}_{i,j}\bm{A}\mathbf{x}_t\left(\hat{\bm{\omega}}_i\right)}^2\\
&\textstyle= \sum_{j=1}^{j=L} \norm{\bm{A} \times \sum_{i=1}^{i={K}} \left({h}_{i,j}\mathbf{x}_t\left({\bm{\omega}}^t_i\right) - \hat{h}_{i,j}\mathbf{x}_t\left(\hat{\bm{\omega}}^t_i\right)\right) + \mathbf{z}_j}^2,
\end{align*}
where $\hat{p}$ denotes an estimate of parameter $p$. If the compressive measurement matrix $\bm{A}$ ensures that
\begin{align}
&\textstyle\!\!\!\norm{\bm{A}\times \sum_{i=1}^{i={K}} \left( {h}_{i,j} \mathbf{x}_t\left({\bm{\omega}}^t_i\right) - \hat{h}_{i,j}\mathbf{x}_t\left(\hat{\bm{\omega}}^t_i\right) \right)}^2\label{eq:geometry_preservation}\\
&\textstyle\quad \approx M \norm{\sum_{i=1}^{i={K}}\left( {h}_{i,j}\mathbf{x}_t\left({\bm{\omega}}^t_i\right) - \hat{h}_{i,j}\mathbf{x}_t\left(\hat{\bm{\omega}}^t_i \right) \right)}^2,~\forall {h}_{i,j}, \hat{h}_{i,j}, \nonumber
\end{align}
for relevant $(\{{\bm{\omega}}_i\}, \{\hat{\bm{\omega}}_i\})$-pairs, the cost structure of the estimation problem is roughly preserved. Therefore, estimation using compressive measurements is similar to estimation with all $N_{t,1D}^2$ measurements (except for an SNR gain, given by $M$) \cite{Ramasamy_TSP_2014}. The main idea behind compressive sensing is that a ``small'' number of random projections can ensure that the \emph{geometry preservation} condition in \eqref{eq:geometry_preservation} is met with high probability. Such results build on the celebrated Johnson-Lindenstrauss Lemma (JL Lemma).
\vspace{1.5pt}
\noindent\textit{JL lemma}\cite{achlioptas_database-friendly_2001}:~Consider a \emph{finite} collection of points $S \subset \mathbb{R}^n$ and an $m\times n$ matrix $\Phi$ with its entries chosen in an i.i.d. manner from $\textrm{Uniform}\{\pm 1\}$ with $m \geq \fracc{(4+2\beta)\log |S|}{\left(\epsilon^2/2 - \epsilon^3/3\right)}$, then with probability at least $1-|S|^{-\beta}$:
\begin{equation}\label{eq:JL:lemma}
m(1-\epsilon) \leq \frac{\norm{\Phi\mathbf{u} - \Phi\mathbf{v}}^2}{\norm{\mathbf{u} - \mathbf{v}}^2} \leq m(1+\epsilon)~\forall \mathbf{u},\mathbf{v}\in S.
\end{equation}
It can be shown that this result extends to the setting where $S \subset \mathbb{C}^{n}$ and the entries of $\Phi$ are chosen from $\textrm{Uniform}\{\pm 1,\pm j\}$.
\begin{figure
\centering
\includegraphics[width=0.7\columnwidth]{pairwise_isometry_32}
\caption{Maximum and minimum values of $\fracc{\norm{\bm{A}\mathbf{X}\mathbf{u}}^2}{(M\norm{\mathbf{X}\mathbf{u}}^2)}$ for different values of $M$, the number of transmitter beacons, across $5\times10^6$ random realizations of $8$-sparse $\mathbf{u}$. The basis $\mathbf{X}$ corresponds to the responses for a $32 \times 32$ array evaluated uniformly over a $R = 64\times 32^2$-sized grid}
\label{fig:choice_of_M}
\end{figure}
Returning to the geometry preservation condition in \eqref{eq:geometry_preservation}, we see that when spatial frequencies are restricted to an oversampled DFT grid $G$ of size $R = O(N_{t,1D}^2)$, this condition reduces to a $2K$-\emph{isometry property} of the measurement matrix $\bm{A}$ relative to the basis $\mathbf{X}$, where $\mathbf{X}$ is the $N_{t,1D}^2 \times R$ matrix with its columns given by $\{\mathbf{x}_t\left(\bm{\omega}\right) : \bm{\omega}\in G\}$. For some fixed $\epsilon$, the matrix $\Phi\in\mathbb{C}^{m\times p}$ is said to enjoy the $s$-isometry property for the basis $B$ (of size $p \times n$) if there exists a constant $C > 0$ such that
$$
C(1-\epsilon) \leq \fracc{\norm{\Phi B \mathbf{u}}^2}{\norm{B \mathbf{u}}^2} \leq C(1+\epsilon),
$$
for all $s$-sparse $\mathbf{u}$ in $\mathbb{C}^n$. It can be shown using the JL lemma (with arguments similar to those in \cite{baraniuk_simple_RIP_2008}) that if $m = O(s\epsilon^{-2} \log n)$, a randomly picked $\Phi$ satisfies this isometry property with high probability (w.h.p). Therefore, when the number of unique transmitter beacons scales as $M = O\left(K\epsilon^{-2}\log R \right) = O\left(K\epsilon^{-2}\log N_{t,1D} \right)$, then the $2K$-pairwise isometry criterion w.r.t the basis $\mathbf{X}$ is met by the randomly picked sounding matrix $\bm{A}$ (it can be shown that $C = M$ for our choice of scale), thereby ensuring that the geometry of the spatial frequency estimation problem is preserved.
We consider the example of the $32 \times 32 $ transmitter array and plot the maximum and minimum values of $(1/M)\fracc{\norm{\bm{A} \mathbf{X} \mathbf{u}}^2}{\norm{\mathbf{X} \mathbf{u}}^2}$ from $5\times 10^6$ random realizations of a $2K=8$-sparse $\mathbf{u}$ in Figure~\ref{fig:choice_of_M} using the $64$-times oversampled DFT grid as the choice of basis $\mathbf{X}$. We see that this ratio is within $[-5,3]$ dB when $M \geq 30$. This illustrates that for estimating $K = 4$ paths using a $32 \times 32$ array, measuring the response corresponding to $M=30$ random beacons approximates the effect of measuring all $32 \times 32 = 1024$ antenna elements individually.
\subsection{Number of compressive receive measurements}\label{sub-sec:geometry_L}
\begin{figure
\centering
\includegraphics[width=0.7\columnwidth]{maxSNRdeg}
\caption{Maximum SNR degradation $\min_{\bm{\omega}} \fracc{\norm{\bm{B}\mathbf{x}_r(\bm{\omega})}^2}{(L\norm{\mathbf{x}_r(\bm{\omega})}^2)}$ for the most favorable realization (from $10^4$ runs) of an $L \times N_{r,1D}^2$ matrix $\bm{B}$ with $N_{r,1D} = 4$}
\label{fig:choice_of_L}
\end{figure}
While we do not track $\{\bm{\omega}^r_i,~i=1,\dots,K\}$, the spatial frequencies at the receiver, we need to ensure that the set of measurements made at the receiver have sufficient information to estimate transmitter spatial frequencies. Suppose that $\norm{\bm{B}\mathbf{x}_r\left(\bm{\omega}^r_i\right)}\approx 0$, it follows from $h_{i, j} = g_i\sqrt{P_e} \mathbf{b}_j^T\mathbf{x}_r\left(\bm{\omega}^r_i\right)$ that all $L$ measurements $\{\mathbf{y}_j,1\leq j\leq L\}$ will have very small contributions from the $i$-th path. i.e., $\abs{h_{i,j}}\approx 0,1\leq j\leq L$. To see this observe that
\begin{equation}\label{eq:relate_h_B}
\sum_{j=1}^{j=L}\abs{h_{i,j}}^2 = {P_e}\abs{g_i}^2\sum_{j=1}^{j=L} \abs{\mathbf{b}_j^T\mathbf{x}_r\left(\bm{\omega}^r_i\right)}^2 = {P_e}\abs{g_i}^2\norm{\bm{B}\mathbf{x}_r\left(\bm{\omega}^r_i\right)}^2.
\end{equation}
When we restrict the receive spatial frequencies to an oversampled DFT grid $G$ of size $R = O(N_{r,1D}^2)$, it can be shown that for $L = O\left( \log R\right) = O\left( \log N_{r, 1D} \right)$, $\norm{\bm{B} \mathbf{x}_r\left(\bm{\omega}\right)}^2 \approx L \norm{ \mathbf{x}_r\left(\bm{\omega}\right)}^2 = L N_{r,1D}^2$ w.h.p (a direct application of the JL lemma \eqref{eq:JL:lemma} with the set $S$ being $\{\mathbf{x}_r\left(\bm{\omega}\right):\bm{\omega}\in G\}\cup\{\mathbf{0}\}$, where $\mathbf{0}$ denotes the zero-vector). This ensures that
\begin{equation*}
\sum_{j=1}^{j=L}\abs{h_{i,j}}^2 \approx {P_e}LN_{r,1D}^2\abs{g_i}^2~\text{w.h.p},
\end{equation*}
thereby capturing power along the $i$-th path. We perform computations for the maximum power lost across spatial frequencies when using a $4\times 4$ array and plot the results in Figure~\ref{fig:choice_of_L}. This shows that around $5$ carefully chosen projections (we pick the best measurement matrix from $10^4$ random instances) suffice to ensure that SNR degradation (relative to the nominal value of $L$) is no greater than $3$dB for a $4\times 4$ receive array.
\subsection{SNR for successful estimation}\label{sub-sec:SNR_needed}
\begin{figure
\centering
\includegraphics[width=0.7\columnwidth]{thresholdSNR}
\caption{ZZB threshold SNR $\texttt{SNR}_{\text{th}}$ for estimating the frequency of a $N_{t,1D} \times N_{t,1D}$ sinusoid as a function of $N_{t,1D}$}
\label{fig:threshold_SNR}
\end{figure}
The preceding criteria delineate the regime in which the \emph{geometry} of the estimation problem is preserved approximately. We now turn to another factor which affects estimation performance, namely the SNR. Consider measurements of the form
\begin{equation}\label{eq:measurements_ZZB}
y_{m,n} = e^{j\left(\omega_1 m + \omega_2 n + \phi\right)} + z_{m,n},~0\leq m,n\leq N_{t,1D}-1,
\end{equation}
where $z_{m,n}$ are i.i.d. $\mathcal{CN}(0,\sigma^2)$ and spatial frequencies $\omega_1, \omega_2$ and phase $\phi$ are parameters to be estimated. The Cram\'er Rao Bound\cite{VanTrees:Bell:Book:Bounds} (CRB) for estimating $\omega_1$ from measurements \eqref{eq:measurements_ZZB} is given by $C(\sigma^2) = \fracc{6}{\left(\texttt{SNR}\left(N_{t,1D}^2-1\right)\right)}$, where $\texttt{SNR} = \fracc{\norm{\mathbf{x}_t(\bm{\omega})}^2}{\sigma^2} = \fracc{N_{t,1D}^2}{\sigma^2}$ (same expression holds for $\omega_2$). Assuming an uniform prior over $[0,2\pi)^3$ for the parameters $(\omega_1, \omega_2, \phi)$, the Ziv Zakai Bound (ZZB) with periodic distortion\cite{Basu::ZZB::Periodic::2000} for estimating $\omega_1$ evaluates to:
$$
Z(\texttt{SNR}) = \int_0^\pi Q\left( \sqrt{ \texttt{SNR} \left(1 - \abs{\frac{\sin\left(N_{t,1D}h/2\right)}{N_{t,1D}\sin\left(h/2\right)}}\right)} \right) h\text{d}h.
$$
An indicator of the $\texttt{SNR}$ needed for successful estimation is the convergence of the ZZB to the CRB\cite{Ramasamy_TSP_2014}. We use the $\texttt{SNR}$ beyond which the ZZB is within $0.1$dB of the CRB as a measure of this convergence. We plot this ZZB \emph{threshold} SNR for different values of $N_{t,1D}$ in Figure~\ref{fig:threshold_SNR}. e.g, $\texttt{SNR}_\text{th} = 16.04$dB for an $8 \times 8$ array and $\texttt{SNR}_\text{th} = 16.13$dB for a $32 \times 32$ array.
The total energy $\texttt{E}_\text{tot}$ corresponding to the $i$-th path collected across the $ML$ measurements $\{\mathbf{y}_j,1\leq j\leq L\}$ is given by:
\begin{align*}
\texttt{E}_\text{tot} & = \norm{\bm{A}\mathbf{x}_t\left(\bm{\omega}_i^t\right)}^2 \times \sum_{j = 1}^{j = L} \abs{h_{i,j}}^2.
\end{align*}
Using \eqref{eq:relate_h_B} in the above, we have that
\begin{align*}
\texttt{E}_\text{tot} & = \norm{\bm{A}\mathbf{x}_t\left(\bm{\omega}_i^t\right)}^2 \norm{\bm{B}\mathbf{x}_r\left(\bm{\omega}_i^r\right)}^2 {P_e}\abs{g_i}^2\\
&\approx M L N_{t,1D}^2 N_{r,1D}^2 {P_e} \abs{g_i}^2\\
& = M L P N_{r,1D}^2 \abs{g_i}^2,
\end{align*}
where $P = N_{t,1D}^2 P_e$ is the total transmit power supplied to the $N_{t,1D} \times N_{t,1D}$ antenna array. The above approximation holds when $M$ and $L$ satisfy the preceding geometry preservation criteria in Sections~\ref{sub-sec:geometry_M}~and~\ref{sub-sec:geometry_L} respectively. The effective SNR of the $i$-th path is given by $ \texttt{SNR}_\text{eff} = \fracc{\texttt{E}_\text{tot}}{\sigma^2}$. It is important to note that the per-measurement noise variance $\sigma^2$ is given by $\sigma^2 = N_{r,1D}^2 \sigma^2_{e}$, where $\sigma_e^2$ is the noise variance per antenna element. Assuming no interference (which we account for in Section~\ref{sec:reuse}), $\sigma_e^2 = \text{N}_0 W_s$ with $W_s$ denoting the sounding bandwidth and $\text{N}_0$ the thermal noise floor. The reason for the scale factor $N_{r,1D}^2$ in the expression for $\sigma^2$ is the following: Our measurement process consists of multiplying the received signal at each antenna (of which there are $N_{r,1D}^2$) by phasors $b(m,n,k)\in\{\pm 1,\pm j\}$ and \emph{adding} the resultant signal (as per \eqref{eq:receive_antenna-construction}). Since thermal noise seen by the $N_{r,1D}^2$ isolated receive antennas are independent random variables, we have that $\sigma^2 = N_{r,1D}^2 \times \left(\text{N}_0 W_s\right)$. Therefore, the effective SNR of the $i$-th sinusoid is given by:
$$
\texttt{SNR}_\text{eff} = ML P \fracc{\abs{g_i}^2}{\text{N}_0 W_s}.
$$
This must exceed the ZZB threshold $\texttt{SNR}_{\text{th}}$ for successful estimation. Noting that $\fracc{ML}{W_s}$ is the time taken for channel sounding, the ZZB threshold $\texttt{SNR}_\text{th}$ gives us the means to evaluate the minimum overhead in time to estimate the channel for a given path gain $\abs{g_i}^2$:
\begin{equation}\label{eq:sounding_time}
\text{Time taken} = \fracc{ML}{W_s} \geq \fracc{ \texttt{SNR}_\text{th} ~ \text{N}_0}{P \abs{g_i}^2}
\end{equation}
The size of the picocell gives us a lower bound on $\abs{g_i}^2$ and we later use this to guide us in choosing the sounding bandwidth $W_s$ using \eqref{eq:sounding_time}.
\subsection{Sounding rate}
We round off the discussion on choice of protocol parameters by giving a rule of thumb for the rate/frequency $f_B$ at which the spatial channel $\{\bm{\omega}_i\}$ needs to be \emph{reestimated}. We use the estimated spatial frequency $\hat{\bm{\omega}}$ for beamforming purposes in the time period between two channel sounding rounds (communication phase sandwiched between consecutive sounding phases; see Figure~\ref{fig:sound_and_comm}). Following the discussion in Section~\ref{sub-sec:algo-tracking}, we have that if $\norm{\bm{\omega}(t) - \hat{\bm{\omega}}}_\infty < \fracc{\pi}{N_{t,1D}}$ throughout the communication phase, where $\bm{\omega}(t)$ denotes the true spatial frequency and $\hat{\bm{\omega}}$ the estimate from the prior sounding round, then the \emph{loss} in SNR, given by $\fracc{\norm{\mathbf{x}_t(\bm{\omega}(t))}^2}{\innerProd{\mathbf{x}_t\left(\hat{\bm{\omega}}\right)}{\mathbf{x}_t\left({\bm{\omega}(t)}\right)}}$, is smaller than $3$dB. If we assume that the closest user to the basestation array is at a distance $R$ meters and that the maximum speed of a user in the picocell is given by $v_{\max}$ meters per second, then the maximum change (in terms of the $\ell_\infty$-norm) in spatial frequency $\Delta\omega$ between consecutive sounding phases, spaced $\fracc{1}{f_B}$ apart, is given by $\fracc{2\pi d v_{\max}}{f_B R \lambda}$. The worst-case geometry which achieves this bound is when the user is at a distance $R$ along the bore-sight of the array and heading in a direction aligned with the one of the array axes. For this worst-case geometry (plotted in Figure~\ref{fig:how_often_sound}), we have that:
\begin{align*}
\Delta\omega & \leq (\fracc{2\pi d}{\lambda})\sin\Delta\theta \approx \frac{2\pi d v_{\max}}{f_B \lambda R}.
\end{align*}
Assuming that the estimate $\hat{\bm{\omega}}$ from the previous sounding phase is accurate, if we ensure that $\fracc{2\pi d v_{\max}}{f_B R \lambda} \leq \fracc{\pi}{N_{t,1D}}$, we have that the beamforming losses in the intervening period are smaller than $3$dB. This tells us that channel needs to be sounded often enough so that
\begin{equation}\label{eq:sounding_rate}
f_B \geq \fracc{ 2 d v_{\max} N_{t,1D}}{ R \lambda}.
\end{equation}
In the following discussions, we use the preceding in conjunction with \eqref{eq:sounding_time} to determine the overhead incurred in estimating the channel using the compressive architecture proposed herein.
\begin{figure
\centering
\includegraphics[width=0.7\columnwidth]{HowOftenSounding}
\caption{Geometry corresponding to maximum change in $\omega_z$: The user moves along the $z$ axis at a speed of $v_{\max}$ in the time interval $\fracc{1}{f_B}$ between two consecutive channel sounding rounds}
\label{fig:how_often_sound}
\end{figure}
\subsection{Reuse analysis for channel sounding}\label{sec:reuse}
We investigate how a sequence of basestations employed in an urban canyon environment can share resources when estimating the spatial channel to users in their respective cells. The envisioned mm-wave system involves alternating between channel estimation and communication phases as shown in Figure~\ref{fig:sound_and_comm}. We assume that channel sounding rounds across basestations are aligned in time. We now characterize how the $2$GHz spectrum is to be shared in space so as to limit the effect of interference from neighboring picocells on channel estimation performance. Such interference management is essential in the sounding phase; unlike the highly directive beams used in the communication phase, compressive sounding beacons are essentially omnidirectional. To see this, consider the average transmit power along any direction $\bm{\omega}$. This is given by $P_e\fracc{\norm{\bm{A}\mathbf{x}_t(\bm{\omega})}^2}{L}\approx P_e \norm{\mathbf{x}_t(\bm{\omega})}^2 = P_e N_{t,1D}^2 = P$, the total transmit power. The approximation $\fracc{\norm{\bm{A}\mathbf{x}_t(\bm{\omega})}^2}{L}\approx {\norm{\mathbf{x}_t(\bm{\omega})}^2}$ holds when the number of beacons $L$ is large enough. Therefore, the average energy \emph{per-measurement} received by an antenna at a distance $r$ from a transmitter sending compressive beacons is given by $P G(r)$, where $G(r) = 10^{G_{dB}(r)/10} = \fracc{\lambda^2}{\left(16 \pi^2 r^2\right)} e^{- \nu r}$ ($\nu = \left(\fracc{\mu}{10}\right) \ln 10$) is the omnidirectional power gain at range $r$. We assume that basestations are deployed regularly as shown in Figure~\ref{fig:FR} and that the inter-basestation separation (along the street) is given by $S$. Suppose that the reuse factor is $R$ (i.e, every $R$th basestation uses the same slice of the frequency spectrum to estimate downlink spatial channels). We assume that for narrow urban canyons, the distance between a user and all interfering basestations (those that are allocated the same sounding BW) are well approximated by $\{kR_f S,~ k\in \mathbb{Z}\setminus\{0\}\}$. Thus, the interference power seen by a single antenna is given by
\begin{equation*}
I = 2 \times \sum_{k=1}^{k=\infty} \sum_{\text{paths}} P G(k R_f S) = 8 P \sum_{k=1}^{k=\infty} G(k R_f S),
\end{equation*}
where we have assumed that there are 4 viable paths between the interfering basestation and user, each introducing the same amount of interference as the LoS path. This is a pessimistic assumption, since NLOS paths are attenuated by larger path lengths and reflection losses. Plugging in the expression for $G(r)$, we have that
\begin{align*}
I &= \left(\fracc{P \lambda^2 }{2 \pi^2 R_f^2S^2}\right) \sum_{k=1}^{k=\infty} \fracc{e^{-\nu R_f S k}}{k^2}\\
& = \left(\fracc{P \lambda^2 }{2 \pi^2 R_f^2S^2}\right) \text{Li}_2\left(e^{-\nu R_f S}\right),
\end{align*}
where $\text{Li}_2(z) = \sum_{k=1}^{k=\infty} \fracc{z^k}{k^2}$ is the dilogarithm function. The interference seen per antenna adds to thermal noise to give an effective per-element noise level of $\sigma_e^2 = \text{N}_0 W_s + I$. Assuming a worst-case geometry for the user of interest (distance of $S$ from the basestation) and proceeding as in Section~\ref{sub-sec:SNR_needed}, we see that effective Signal to Interference and Noise Ratio $\texttt{SINR}_{\text{eff}}$ is given by
$$
\texttt{SINR}_{\text{eff}} = \fracc{MLP G(S)}{\sigma_e^2}.
$$
This can be rewritten as
$$
\fracc{1}{\texttt{SINR}_{\text{eff}}} = \fracc{1}{\texttt{SNR}_{\text{eff}}} + \fracc{1}{\texttt{SIR}_{\text{eff}}},
$$
where $\texttt{SNR}_{\text{eff}} =\fracc{MLP G(S)}{\text{N}_0 W_s}$ and the Signal to Interference Ratio $\texttt{SIR}_{\text{eff}} =\fracc{MLP G(S)}{I} = \fracc{ML R_f^2 e^{-\mu S}}{8 \text{Li}_2\left(e^{-\mu R_f S}\right)}$. We need to ensure that $\texttt{SINR}_{\text{eff}}$ exceeds the ZZB SNR threshold for successful estimation. We choose the reuse factor $R_f$ so that we are in the noise-limited regime by setting
$$
\fracc{1}{\texttt{SIR}_{\text{eff}}} < 0.1 \times \left(\fracc{1}{\texttt{SNR}_{\text{th}}}\right) \approx -10 - 16~\text{dB}.
$$
Assuming that protocol parameters are chosen so that $\texttt{SNR}_{\text{eff}}$ exceeds $\texttt{SNR}_{\text{th}}$, we can ignore interference in $\texttt{SINR}_{\text{eff}}$ calculations when
$$
\texttt{SIR}_{\text{eff}} > \texttt{SNR}_{\text{th}} + 10 \approx 26\text{dB for }N_{t,1D}=8,32.
$$
In Figure~\ref{fig:FR}, we plot achievable effective SIRs as a function of frequency reuse factor $R_f$ for two example systems in Section~\ref{sub-sec:sounding-protocol}: i.e, $8 \times 8$ and $32 \times 32 $ arrays with total number of measurements given by $ML = 24\times 6$ and $ML = 30 \times 6$ respectively. As the picocell size $S$ grows, exponential attenuation due to oxygen absorption (the $e^{-\nu S}$ term in the expression for $\texttt{SIR}_{\text{eff}}$) helps in attenuating interference and improving SIR for same reuse factor $R_f$. To illustrate this we plot SIR as a function of $R_f$ for three cell sizes $S = 50,100,200$m in Figure~\ref{fig:FR}. We observe that, in order to ensure $\texttt{SIR}_{\text{eff}} > 26$dB, a reuse factor of $R_f = 4$ is needed for $S=50$m, while $R_f=3$ suffices for $S=200$m. Plugging in the per-basestation sounding bandwidth $W_s$ calculations in Section~\ref{sub-sec:sounding-protocol}, we see that the overall \emph{system-level} channel sounding bandwidth $W_s \times R_f$ for a $S=50$m picocell is as small as $8.8124\text{MHz} \times 4 = 35.2$MHz and $674.34\text{KHz} \times 4 = 2.7$MHz for $N_{t,1D} = 8, 32$, respectively, which is dwarfed by the total available bandwidth ($2$GHz).
\begin{figure}
\centering
\includegraphics[width=0.9\columnwidth]{Geometry_new}
\caption{Reuse of frequency resources for reuse factor $R_f = 3$}
\label{fig:cells}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=3.2in]{FRnew}
\caption{Effective Signal to Interference Ratio ${\texttt{SIR}_{\text{eff}}}$ for $ML = 24 \times 6$ ($8 \times 8$ scenario) and $ML = 30 \times 6$ ($32 \times 32$ scenario; dashed) as a function of reuse factor $R_f$}
\label{fig:FR}
\end{figure}
\section{Simulation results}\label{sec:sims}
We perform simulations for the two example systems considered in Section~\ref{sec:link_budget} ($8 \times 8$ and $32 \times 32$ transmit arrays). We report results for the algorithm proposed in Section~\ref{sec:algo} and two feedback strategies: (i) `full': users feedback the measured virtual channel matrix $\mathbf{Y}$ ($M \times L$ matrix; $L=6$ for both systems) and (ii) `svd': users feedback the $2$ dominant left singular vectors of $\mathbf{Y}$, scaled by their corresponding singular values ($M \times 2 $ matrix; one-third feedback overhead).
We consider $6$ mobile users moving in the urban canyon at speeds of $20$, $3$, $15$, $1.5$, $2.1$ and $10$ meters per second (covering both vehicular and pedestrian settings). The height at which each mobile device is held is in the $1.3 - 1.4$m range. The basestation is mounted on a lamppost on the pavement ($7$ meters from a canyon wall), at a height of $6$ meters. The basestation antenna array is tilted by about $7.5^{\circ}$ in both the azimuth and elevation directions so that the boresight of the array points towards middle of the corresponding cell. This helps in more accurate spatial frequency estimation: since a change in direction near the boresight of the array results in larger changes in spatial frequencies than far away from the boresight, resolving paths is easier when the array points towards a direction in which we are likely to see more paths. We do not model blockage in these simulations, assuming that the LoS path and the three first order reflections are all available. Our goal is to estimate and track the $K=4$ paths to all $6$ users.
\begin{figure
\centering
\includegraphics[width=0.7\columnwidth]{sim_scenario}
\caption{Six users in the urban canyon moving over the duration of the $7$ second simulation interval. Their positions at time $t = 0$ is marked using a $\bm{\square}$-symbol}
\label{fig:sim_scenario}
\end{figure}
\noindent\textbf{Estimation error:}~Let $T = \{\bm{\omega}_m~:~ m =1,\dots,K\}$ denote the true spatial frequencies and $P = \{\hat{\bm{\omega}}_n~:~n=1,\dots,\hat{K}\}$ denote the set of estimated spatial frequencies. When the base station uses one of the estimates in $P$, say $\hat{\bm{\omega}}$, to form a beam, we do not realize the full $20\log N_{t,1D}$ dB beamforming gain. A measure of the sub-optimality is the estimation error $\norm{\bm{\omega} - \hat{\bm{\omega}}}_2$, which we normalize by the DFT spacing of $\fracc{2 \pi}{N_{t,1D}}$ to define the following error metric:
\begin{equation}\label{eq:est_errors}
\Delta\omega(m) = \fracc{\min_n \norm{\bm{\omega}_m - \hat{\bm{\omega}}_n}_2}{\left(\fracc{2 \pi}{N_{t,1D}}\right)}.
\end{equation}
When no true spatial frequency exists near an estimate $\hat{\bm{\omega}}$, i.e, when $\hat{\bm{\omega}}$ is a ``phantom estimate'', we will quickly be able to discard it when we beamform in the direction of $\hat{\bm{\omega}}$ and find that the mobile does not receive power commensurate to what it expects with the $20\log N_{t,1D}$ beamforming gain.
We plot the Complementary Cumulative Distribution Function (CCDF) of estimation errors \eqref{eq:est_errors} for the two systems ($N_{t,1D} = 8, 32$) in Figure~\ref{fig:sim_errors} and the Probability Distribution Function (PDF) of the number of paths estimated $\hat{K}$ (correct value is $K = 4$) in Figure~\ref{fig:sim_errors_support_size}. From Figure~\ref{fig:sims}, we see that feedback of dominant singular vectors is an efficient feedback strategy which performs just as well as feeding back the entire matrix $\mathbf{Y}$, while using only a third of uplink resources.
\begin{figure*}[t!
\centering
\begin{subfigure}[t]{0.48\textwidth}
\centering
\includegraphics[width=0.49\columnwidth]{errors_all_8}~ \includegraphics[width=0.49\columnwidth]{errors_all_32}
\caption{CCDF of frequency estimation errors \eqref{eq:est_errors} for $N_{t,1D} = 8$ (left) and $N_{t,1D} = 32$ (right)}
\label{fig:sim_errors}
\end{subfigure}
~~
\begin{subfigure}[t]{0.48\textwidth}
\centering
\includegraphics[width=0.485\columnwidth]{support_all_8}~ \includegraphics[width=0.485\columnwidth]{support_all_32}
\caption{PDF of \# of estimated paths $\hat{K}$ ($K = 4$) for $N_{t,1D} = 8$ (left) and $N_{t,1D} = 32$ (right)} .
\label{fig:sim_errors_support_size}
\end{subfigure}
\caption{Two feedback strategies considered: (i) $M \times 6$ matrix $\mathbf{Y}$ (`full') and (ii) top two dominant singular vectors (one-third overhead)}
\label{fig:sims}
\end{figure*}
Next, in order to evaluate the effect of errors in spatial frequency estimation on beamforming performance, we simulate a simple scenario in which the transmitter beamforms toward the strongest estimated path. Figure \ref{fig:BeamformingGain8x8} shows the CDF of the achievable beamforming gain for an $8 \times 8$ array. While ideal beamforming requires adjustment of both gains and phases, suboptimal approaches for RF beamsteering with severely quantized phase-only control (four phases) have been studied in our earlier conference paper \cite{ramasamy_ita12}. We see from Figure \ref{fig:BeamformingGain8x8} that if ideal beamforming were performed with our estimates, then the SNR loss is less than 0.3 dB. If four-phase control is used based on our estimates, then the SNR loss is less than 1 dB. The results for $32 \times 32$ arrays are entirely similar, and are therefore not plotted here..
Thus far, we have not said anything about channel frequency selectivity. Our proposed algorithm uses a small segment of the band to estimate the spatial channel, and the problem of channel dispersion is not addressed. However, we note that beamforming using a large array should reduce the effect of undesired paths, which simplifies the task of equalization. Figure \ref{fig:Impulseresponse} shows the channel impulse responses for the $32\times 32$ and $8 \times 8$ antenna arrays for a typical snapshot, when the transmitter beamforms towards the strongest estimated path. In our simulated setting, the LoS and ground reflection are close to each other in terms of both delays and angles of departure. We see that $8\times 8$ array fails to resolve them, with both paths falling into the antenna's main lobe, while the $32 \times 32$ antenna array, which has smaller beamwidth ($4^{\circ}$ half power beamwidth), attenuates the undesired tap down to one-ninth of the desired path. Of course, it is possible to utilize the channel estimates far more intelligently, potentially with nulls directed both at strong undesired paths for the mobile of interest, and at the dominant paths for other nearby mobiles. The latter can be particularly useful for combating intra-cell interference when a base station face has multiple antenna arrays, each communicating with a different mobile.
\begin{figure}
\begin{center}
\includegraphics[width=3.2in]{BFgain}
\caption{Beamforming gain achieved by an $8\times8$ antenna array for ideal and quantized beamforming techniques}
\label{fig:BeamformingGain8x8}
\end{center}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=1.7in]{IR_8x8}~\includegraphics[width=1.7in]{IR_32x32}
\caption{Channel impulse response with quantized beamforming towards estimated strongest path for the $8 \times 8$ (left) and $32 \times 32$ (right) scenarios}
\label{fig:Impulseresponse}
\end{figure}
\section{System Model}
Given the high demand for wireless data in dense urban environments, we focus our modeling and performance evaluation on the urban canyon setting depicted in Figure \ref{fig:urban}, with streets flanked by buildings on both sides. Picocellular base stations are deployed on lampposts in a zig-zag pattern on both sides of the street. We consider mm wave transmission on the downlink (for beaconing and downlink data) and LTE or WiFi at lower carrier frequencies on the uplink (for feedback and uplink data). In terms of channel estimation and tracking, this could be viewed as a worst-case assumption, since two-way transmission on the same mm wave band could potentially be exploited using channel reciprocity. For the east-west street shown, each base station has two faces, facing east and west, respectively. Each face can have multiple antenna arrays, but for simplicity, we consider a single antenna array for each face, used for both compressive beaconing and downlink data communication. Mobile stations are modeled as either pedestrians walking along sidewalks, or cars moving along the street.
In our simulations, we model $K=4$ dominant paths from base station to mobile in our simulations: the line of sight (LoS), and the single bounce reflections from the ground or the side walls. Some of these paths may be blocked by obstacles (diffraction around obstacles is limited for small carrier wavelengths). We ignore multiple bounces, since such paths get attenuated significantly, especially because each bounce sees a smaller angle of incidence than a typical single bounce. However, our compressive estimation algorithm does not use the preceding assumptions on number of dominant paths as prior information, and automatically discovers and tracks paths.
For a regular $d$-spaced square $N_{1D} \times N_{1D}$ antenna array and a point transmitter in the far-field, the channel seen by the array is a mixture of 2D sinusoids, each corresponding to a propagation path, and is given by
\begin{equation*}
h_{m,n} = \sum_{l = 1}^{l = K} g_l e^{j \left(\omega_{x, l} m + \omega_{z,l} n\right)},~ g_l \in \mathbb{C},~ 1 \leq m,n, \leq N_{1D},
\end{equation*}
where $g_l$ is the propagation gain of the $l$-th path, $\bm{\omega}_l = \left(\omega_{x,l}, \omega_{z,l}\right)$ are the spatial frequencies corresponding to the $l$-th path (w.l.o.g. we have assumed that the square array is placed in the $x$-$z$ plane, with its sides aligned to the coordinate axes) and $h_{m,n}$ refers the channel seen by the $m,n$-th antenna element,. The spatial frequencies of the {$l$-th} path are given by $\omega_{x,l} = 2\pi (d/\lambda) \sin\theta_l\cos\phi_l$ and $\omega_{z,l} = 2\pi (d/\lambda) \sin\theta_l\sin\phi_l$, where $d$ denotes the array spacing, $\lambda$ the carrier wavelength and $\left(\theta_{l}, \phi_{l}\right)$ the inclination and azimuthal angles of the $l$-th path relative to $x-z$ plane. We vectorize the 2D sinusoid $\left[e^{j \left(\omega_{x} m + \omega_{z} n\right)},~0\leq m,n\leq N_{1D}-1\right]$ and denote the resulting $N_{1D}^2$ long vector by $\mathbf{x}(N_{1D}, \bm{\omega})$, where $\bm{\omega} = \left(\omega_{x}, \omega_{z}\right)$ is the frequency of the 2D sinusoid. Vectorizing $\left[h_{m,n},~1\leq m,n\leq N_{1D}\right]$ in an identical manner gives us
\begin{equation*}
\mathbf{h} = \sum_{l = 1}^{l = K} g_l \mathbf{x}(N_{1D}, \bm{\omega}_l).
\end{equation*}
Now, consider a base station transmitter with a regularly spaced 2D array of size $N_{t,1D}\times N_{t,1D}$, and a mobile receiver with a regular 2D antenna array of size $N_{r,1D}\times N_{r,1D}$. Let $\mathbf{H}$ denote the corresponding $N_{t, 1D}^2 \times N_{r, 1D}^2$ channel matrix. Denoting by $\mathbf{h}_i$ the $i$th row of this matrix, $\mathbf{h}_i^T$ is the response of the receive antenna array to the $i$th transmit antenna. Denoting $\mathbf{x}\left(N_{t, 1D}, \bm{\omega} \right)$ by $\mathbf{x}_t\left(\bm{\omega} \right)$ and $\mathbf{x}\left(N_{r, 1D}, \bm{\omega} \right)$ by $\mathbf{x}_r\left(\bm{\omega} \right)$, under the far-field assumption, it can be shown that
\begin{equation}\label{eq:channel_matrix}
\mathbf{H} = \sum_{l = 1}^{l = K} g_l \mathbf{x}_t\left(\bm{\omega}^{t}_{l}\right) \mathbf{x}_r^T\left(\bm{\omega}^{r}_{l}\right),~ g_l\in\mathbb{C}.
\end{equation}
Since we know the array geometries (in this case, a regularly spaced 2D array), an estimate of the $N_{t, 1D}^2 \times N_{r, 1D}^2$ MIMO channel matrix $\mathbf{H}$ can be efficiently arrived at by estimating the spatial frequencies and the associated gains: $\left\{\left(g_l, \bm{\omega}^{t}_{l}, \bm{\omega}^{r}_{l}\right),~l=1,\dots,K\right\}$. Such a parametric approach is far more efficient that direct estimation of individual entries of $\mathbf{H}$, and enables us to drastically reduce the number of measurements required.
\section{Compressive channel estimation}\label{sec:channel_est}
We now describe our compressive approach for spatial channel estimation, which consists of a channel sounding strategy and an estimation algorithm which allows a base station to estimate the propagation gains $\left\{ \left|g_l\right| \right\}$ and the spatial frequencies $\left\{ \bm{\omega}^{t}_{l} \right\}$ in parallel for \emph{all} mobiles in the picocell.
\subsection{Channel sounding} \label{sub-sec:channel_sounding}
The basestation sounds the channel using $M$ compressive beacons. Each beacon is a known signal sent using a different set of transmit weights. The weights are chosen uniformly and independently at random from a small set of coarse phase shifts (for e.g. from the set $\{\pm 1, \pm j\}$, where $j = \sqrt{-1}$). We may therefore view each beacon as being transmitted from a different ``virtual antenna'' with a quasi-omnidirectional pattern. Each of the $M$ transmit beacons are repeated $L$ times by the basestation (see Figure~\ref{fig:channel_sounding}). For each of these $M$ transmit beacons, a mobile receiver employs $L$ ``virtual antennas'' to measure the channel response, using receive weights chosen uniformly at random from $\{\pm 1, \pm j\}$. Let $y(m,n)$ denote the response at the $(m,n)$th receive element due to a given transmit beacon. Letting $b({m,n,k}) \in \{\pm 1, \pm j\}$ denote the weight for $(m,n)$th receive element for the $k$th virtual receive antenna, the response seen by the $k$th virtual receive antenna is given by
\begin{equation}\label{eq:receive_antenna-construction}
r(k) ~= \!\sum_{1\leq m, n\leq N_{r,1D}} \!\!b({m,n,k}) \times y({m,n}),~1\leq k\leq L.
\end{equation}
These measurements are used to construct the $M \times L$ Multiple Input Multiple Output (MIMO) ``virtual channel'' matrix $\mathbf{V}$ between the virtual transmit and receive antennas. Note that we do not require that the base station know the receive weights used by the mobile, or that the mobile know the transmit weights used by the base station.
Denoting the vectorized version of weights of the $i$-th virtual transmit antenna by $\mathbf{a}_i$ (a vector of shape $N_{t, 1D}^2 \times 1$) and that of the $j$-th virtual receive antenna by $\mathbf{b}_j$ ($N_{r, 1D}^2 \times 1$), the $i,j$-th element of $\mathbf{V}$ (the channel between the {$(i,j)$-th} virtual transmit-receive pair) is given by $v_{i,j} = \mathbf{a}_i^T\mathbf{H}\mathbf{b}_j$. Letting $\bm{A} = [\mathbf{a}_1~\dots~\mathbf{a}_{M}]^T$ and $\bm{B} = [\mathbf{b}_1~\dots~\mathbf{b}_{L}]^T$, it is easy to see that $\mathbf{V} = \bm{A} \mathbf{H} \bm{B}^T$. Using \eqref{eq:channel_matrix}, we have that
\begin{equation}\label{eq:virtual_channel_matrix}
\mathbf{V} = \sum_{l = 1}^{l = K} g_l \left(\bm{A}\mathbf{x}_t\left(\bm{\omega}^{t}_{l}\right)\right) \left(\bm{B} \mathbf{x}_r\left(\bm{\omega}^{r}_{l}\right)\right)^T.
\end{equation}
The channel measurements are perturbed by i.i.d measurement noise, and are given by
\begin{equation*}
y_{i,j} = \sqrt{P_e} v_{i,j} + z_{i,j},~z_{i,j}\sim\mathcal{CN}(0, \sigma^2),
\end{equation*}
where ${P_e}$ is the per-element transmit power. Letting $\mathbf{Y}$ and $\mathbf{Z}$ denote $M\times L$ matrices with their $i,j$-th entries given by $y_{i,j}$ and $z_{i,j}$ respectively, the ``measured virtual channel'' is given by
\begin{equation}\label{eq:virtual_channel_meas}
\mathbf{Y} = \sqrt{P_e}\mathbf{V} + \mathbf{Z} = \sqrt{P_e}\sum_{l = 1}^{l = K} g_l \left(\bm{A}\mathbf{x}_t\left(\bm{\omega}^{t}_{l}\right)\right) \left(\bm{B} \mathbf{x}_r\left(\bm{\omega}^{r}_{l}\right)\right)^T + \mathbf{Z}.
\end{equation}
\subsection{Feedback strategies} \label{sub-sec:channel_feedback}
Our goal is to track the mm-wave spatial channel as seen from the basestation, described by the parameters $P=\left\{\left(\left|g_l\right|, \bm{\omega}^t_l\right), l = 1,\dots, K\right\}$. To this end, every mobile in the picocell needs to feed back a portion of the measured virtual channel $\mathbf{Y}$ to the basestation. From \eqref{eq:virtual_channel_meas}, we see that the information regarding the spatial channel as seen from the basestation, given by $P$, is available in the \emph{column space} of $\mathbf{Y}$. Building on this observation, we propose two feedback strategies:\\
\noindent$~~$(i) The receiver feeds back the entire matrix $\mathbf{Y}$.\\
\noindent$~~$(ii) A more elaborate strategy involves feeding back $Q\leq L$ strongest left singular vectors of $\mathbf{Y}$ scaled by their corresponding singular values. i.e., if $\mathbf{Y} = \sum_{l=1}^{l=L}\sigma_l\mathbf{u}_l\mathbf{v}_l^H$ with $\sigma_1 \geq \sigma_2\geq\cdots\geq\sigma_L\geq 0$, the receivers feed back $\mathbf{D} \equiv\left[\sigma_1\mathbf{u}_1~\cdots~\sigma_Q\mathbf{u}_Q\right]$. This strategy identifies the $Q$-dimensional \emph{subspace} of the column space of $\mathbf{Y}$ with maximum energy.
|
{'timestamp': '2015-06-18T02:15:42', 'yymm': '1506', 'arxiv_id': '1506.05367', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05367'}
|
arxiv
|
\section{Introduction}
\label{sec:intro}
Distributed representations of words have been shown to benefit a diverse set of NLP tasks including
syntactic parsing \cite{lazaridou:2013,bansal:2014}, named
entity recognition \cite{guo2014revisiting} and sentiment
analysis \cite{socher:2013}. Additionally, because they can be induced directly from unannotated corpora, they are likewise available in domains and languages where traditional linguistic resources do not exhaust.
Intrinsic evaluations on various tasks are helping refine vector learning methods to discover representations that captures many facts about lexical
semantics \cite{Turney:2001:MWS:645328.650004,Turney10fromfrequency}.
Yet induced word vectors do not look anything like the representations described in
most lexical semantic theories, which focus on identifying classes of words
\cite{verb-classes.levin.1993,baker:1998,Schuler:2005:VBC:1104493,miller:1995}.
Though expensive to construct,
conceptualizing word meanings symbolically is important
for theoretical understanding and interpretability is desired in computational
models.
Our contribution to this discussion is a new technique that constructs
task-independent word vector representations using linguistic knowledge derived
from pre-constructed linguistic resources like WordNet \cite{miller:1995},
FrameNet \cite{baker:1998}, Penn Treebank \cite{marcus1993building} etc.
In such word vectors every
dimension is a linguistic feature and 1/0 indicates the presence or absence of
that feature in a word, thus the vector representations are binary while being
highly sparse ($\approx 99.9\%$). Since these vectors do not encode any word
cooccurrence information, they are non-distributional.
An additional benefit of constructing such
vectors is that they are fully interpretable i.e, every dimension of these
vectors maps to a linguistic feature unlike distributional
word vectors where the vector dimensions have no interpretability.
Of course, engineering feature vectors from linguistic resources is established
practice in many applications of discriminative learning; e.g., parsing
\cite{mcdonald2006online,nivre2008algorithms} or part of
speech tagging \cite{ratnaparkhi1996maximum,collins2002discriminative}.
However, despite a certain common inventories of features that re-appear across
many tasks, feature engineering tends to be seen as a task-specific problem,
and engineered feature vectors are not typically evaluated independently of the
tasks they are designed for. We evaluate the quality of our linguistic
vectors on a number of tasks that have been proposed for evaluating
distributional word vectors. We show that linguistic word vectors are
comparable to current state-of-the-art distributional word
vectors trained on billions of words as evaluated on a battery of semantic and
syntactic evaluation benchmarks.\footnote{Our vectors can be downloaded at:
\url{https://github.com/mfaruqui/non-distributional}}
\section{Linguistic Word Vectors}
\begin{table}[!tb]
\centering
\small
\begin{tabular}{|l|c|c|}
\hline
Lexicon & Vocabulary & Features \\
\hline
WordNet & 10,794 & 92,117 \\
Supersense & 71,836 & 54\\
FrameNet & 9,462 & 4,221\\
Emotion & 6,468 & 10\\
Connotation & 76,134 & 12\\
Color & 14,182 & 12\\
Part of Speech & 35,606 & 20\\
Syn. \& Ant. & 35,693 & 75,972\\
\hline
Union & 119,257 & 172,418\\
\hline
\end{tabular}
\caption{Sizes of vocabualry and features induced from different
linguistic resources.}
\label{tab:size}
\end{table}
\begin{table*}[!tb]
\centering
\small
\begin{tabular}{|l|c|c|c|c|c|c|c|}
\hline
Word & \textsc{Pol.Pos} & \textsc{Color.Pink} & \textsc{SS.Noun.Feeling} & \textsc{PTB.Verb} & \textsc{Anto.Fair} & $\cdots$ & \textsc{Con.Noun.Pos} \\
\hline
love & 1 & 1 & 1 & 1 & 0 & & 1\\
hate & 0 & 0 & 1 & 1 & 0 & & 0\\
ugly & 0 & 0 & 0 & 0 & 1 & & 0\\
beauty & 1 & 1 & 0 & 0 & 0 & & 1\\
refundable & 0 & 0 & 0 & 0 & 0 & & 1\\
\hline
\end{tabular}
\caption{Some linguistic word vectors. 1 indicates presence and 0 indicates absence of a linguistic feature.}
\label{tab:ling}
\end{table*}
We construct linguistic word vectors by extracting word level information
from linguistic resources. Table~\ref{tab:size} shows the size of
vocabulary and number of features induced from every lexicon.
We now describe various linguistic resources that we use for
constructing linguistic word vectors.
\paragraph{WordNet.} WordNet \cite{miller:1995} is an English lexical database
that groups words
into sets of synonyms called synsets and records a number of relations among
these synsets or their members. For a word we look up its synset for all
possible part of speech (POS) tags that it can assume.
For example, \textit{film} will have \textsc{Synset.Film.V.01} and
\textsc{Synset.Film.N.01} as features as it can be both a verb and a noun.
In addition to synsets, we include the hyponym (for ex.
\textsc{Hypo.CollageFilm.N.01}), hypernym (for ex. \textsc{Hyper:Sheet.N.06})
and holonym synset of the word as features. We also collect antonyms and
pertainyms
of all the words in a synset and include those as features in the linguistic
vector.
\paragraph{Supsersenses.} WordNet partitions nouns and verbs into semantic field
categories known as supsersenses \cite{Ciaramita:2006,nastase:2008}.
For example, \textit{lioness} evokes the supersense \textsc{SS.Noun.Animal}.
These supersenses were further extended to adjectives
\cite{tsvetkov:2014}.\footnote{\url{http://www.cs.cmu.edu/~ytsvetko/adj-supersenses.tar.gz}}
We use these supsersense tags for nouns, verbs and adjectives as features in the
linguistic word vectors.
\paragraph{FrameNet.} FrameNet \cite{baker:1998,fillmore-ua-2003} is a rich
linguistic resource that
contains information about lexical and predicate-argument semantics in English.
Frames can be realized on the surface by many different word types,
which suggests that the word types evoking the same frame should be semantically
related. For every word, we use the frame it evokes along with the roles of the
evoked frame as its features. Since, information in FrameNet is
part of speech (POS) disambiguated, we couple these feature with the
corresponding POS tag of
the word. For example, since \textit{appreciate} is a verb, it will have
the following features: \textsc{Verb.Frame.Regard}, \textsc{Verb.Frame.Role.Evaluee} etc
\paragraph{Emotion \& Sentiment.}
\newcite{mohammad:2013} constructed two different
lexicons that associate words to sentiment polarity and to emotions resp. using
crowdsourcing. The polarity is either positive or negative but there are eight
different kinds of emotions like anger, anticipation, joy etc. Every word in the
lexicon is associated with these properties.
For example, \textit{cannibal} evokes \textsc{Pol.Neg},
\textsc{Emo.Disgust} and \textsc{Emo.Fear}. We use these properties as
features in linguistic vectors.
\paragraph{Connotation.} \newcite{feng:2013} construct a lexicon that contains
information about connotation of words that are seemingly objective but often
allude nuanced sentiment. They assign positive, negative and neutral
connotations to these words. This lexicon differs from
\newcite{mohammad:2013} in
that it has a more subtle shade of sentiment and it extends to many more words.
For example, \textit{delay} has a negative connotation \textsc{Con.Noun.Neg}, \textit{floral} has a positive connotation \textsc{Con.Adj.Pos} and
\textit{outline} has a neutral connotation \textsc{Con.Verb.Neut}.
\paragraph{Color.} Most languages have expressions involving color, for example
\textit{green with envy} and \textit{grey with uncertainly} are phrases used in
English. The word-color associtation lexicon produced by
\newcite{mohammad:2011}
using crowdsourcing lists the colors that a word
evokes in English. We use every color in this lexicon as a feature in the
vector. For example, \textsc{Color.Red} is a feature evoked by the word
\textit{blood}.
\paragraph{Part of Speech Tags.} The Penn Treebank \cite{marcus1993building}
annotates naturally
occurring text for linguistic structure. It contains syntactic parse trees and
POS tags for every word in the corpus. We collect all the possible POS tags
that a word is annotated with and use it as features in the linguistic vectors.
For example, \textit{love} has \textsc{PTB.Noun}, \textsc{PTB.Verb} as features.
\paragraph{Synonymy \& Antonymy.} We use Roget's thesaurus \cite{Roget11} to
collect sets of synonymous words.\footnote{\url{http://www.gutenberg.org/ebooks/10681}}
For every word, its synonymous word is used
as a feature in the linguistic vector. For example, \textit{adoration} and
\textit{affair} have a feature \textsc{Syno.Love}, \textit{admissible} has
a feature \textsc{Syno.Acceptable}. The synonym lexicon contains 25,338 words
after removal
of multiword phrases. In a similar manner, we also use antonymy
relations between words as features in the word vector. The antonymous words
for a given word were collected from
\newcite{ordway1913synonyms}.\footnote{\url{https://archive.org/details/synonymsantonyms00ordwiala}}
An example
would be of \textit{impartiality}, which has features \textsc{Anto.Favoritism}
and \textsc{Anto.Injustice}. The antonym lexicon has 10,355 words. These
features are different from those induced from WordNet as the former encode
word-word relations whereas the latter encode word-synset relations.
After collecting features from the various linguistic resources described above
we obtain linguistic word vectors of length 172,418 dimensions. These vectors
are 99.9\% sparse i.e, each vector on an average
contains only 34 non-zero features out of 172,418 total features.
On average a linguistic feature (vector dimension) is active for 15 word types.
The linguistic word vectors contain 119,257 unique word types.
Table~\ref{tab:ling} shows linguistic vectors for
some of the words.
\section{Experiments}
We first briefly describe the evaluation tasks and then present
results
\begin{table*}[!tb]
\centering
\small
\begin{tabular}{|l|l|l|l||c|c|c||c|c|}
\hline
Vector & Length ($D$) & Params. & Corpus Size & WS-353 & RG-65 & SimLex & Senti & NP \\
\hline
Skip-Gram & 300 & $D\times N$& 300 billion & 65.6 & 72.8 & 43.6 & \textbf{81.5} & 80.1\\
Glove & 300 & $D\times N$ & 6 billion & 60.5 & 76.6 & 36.9 & 77.7 & 77.9\\
LSA & 300 & $D\times N$ & 1 billion & \textbf{67.3} & 77.0 & 49.6 & 81.1 & 79.7 \\
\hline
Ling Sparse & 172,418 & -- & -- & 44.6 & \textbf{77.8} & 56.6 & 79.4 & \textbf{83.3}\\
Ling Dense & 300 & $D\times N$ & -- & 45.4 & 67.0 & \textbf{57.8} & 75.4 & 76.2\\
\hline\hline
Skip-Gram $\oplus$ Ling Sparse & 172,718 & -- & -- & 67.1 & 80.5 & 55.5 & 82.4 & 82.8\\
\hline
\end{tabular}
\caption{Performance of different type of word vectors on evaluation tasks
reported by Spearman's correlation (first 3 columns) and Accuracy (last 2
columns). Bold shows the best performance for a task.}
\label{tab:eval}
\end{table*}
\subsection{Evaluation Tasks}
\paragraph{Word Similarity.}
We evaluate our word representations on three different benchmarks to measure
word similarity. The first one is the widely used WS-353 dataset
\cite{citeulike:379845}, which contains 353 pairs of English words that have
been assigned similarity ratings by humans. The second is the RG-65 dataset
\cite{Rubenstein:1965} of 65 words pairs. The third dataset is SimLex
\cite{HillRK14} which has been constructed to overcome the shortcomings of
WS-353 and contains 999 pairs of adjectives, nouns and verbs.
Word similarity is computed using cosine similarity between two words and
Spearman's rank correlation is reported
between the rankings produced by vector model against the human rankings.
\paragraph{Sentiment Analysis.}
\newcite{socher:2013} created a treebank containing sentences
annotated with fine-grained sentiment labels on phrases and sentences
from movie review excerpts.
The coarse-grained treebank of positive and negative
classes has been split into training, development, and test datasets
containing 6,920, 872, and 1,821 sentences, respectively.
We use average of the word vectors of a given sentence as features in
an $\ell_2$-regularized logistic regression for classification. The classifier
is tuned on the dev set and accuracy is reported on the test set.
\paragraph{NP-Bracketing.} \newcite{lazaridou:2013}
constructed a dataset from the Penn TreeBank \cite{marcus1993building} of
noun phrases (NP) of length three words, where the first can be an adjective or
a noun and the other two are nouns. The task is to predict the correct
bracketing in the parse tree for a given noun phrase. For example,
\textit{local (phone company)} and \textit{(blood pressure) medicine} exhibit
\textit{left} and \textit{right} bracketing respectively.
We append the word vectors
of the three words in the NP in order and use them as features in an
$\ell_2$-regularized logistic regression classifier.
The dataset contains 2,227 noun phrases split into 10 folds.
The classifier is tuned on the first fold and cross-validation accuracy
is reported on the remaining nine folds.
\subsection{Linguistic Vs. Distributional Vectors}
In order to
make our linguistic vectors comparable to publicly available distributional
word vectors, we perform singular value decompostion (SVD) on
the linguistic matrix to obtain word vectors of lower dimensionality. If
$\vect{L} \in \{0,1\}^{N\times D}$ is the linguistic matrix with $N$ word types
and $D$ linguistic features, then we can obtain
$\vect{U} \in \mathbb{R}^{N\times K}$ from the SVD of
$\vect{L}$ as follows: $\vect{L} = \vect{U}\vect{\Sigma}\vect{V}^{\top}$, with
$K$ being the desired length of the lower dimensional space.
We compare both sparse and dense linguistic vectors to three widely used
distributional word vector models. The first two are the pre-trained Skip-Gram
\cite{mikolov:2013}\footnote{\url{https://code.google.com/p/word2vec}} and
Glove
\cite{glove:2014}\footnote{\url{http://www-nlp.stanford.edu/projects/glove/}}
word vectors each of length 300, trained on 300 billion and 6 billion words
respectively. We used latent semantic analysis (LSA) to obtain word vectors from
the SVD decomposition of a word-word cooccurrence matrix
\cite{Turney10fromfrequency}. These were trained on 1 billion words of
Wikipedia with vector length 300 and context window of 5 words.
\subsection{Results}
Table~\ref{tab:eval} shows the performance of different word vector types on the
evaluation tasks. It can be seen that although Skip-Gram, Glove \& LSA perform
better than
linguistic vectors on WS-353, the linguistic vectors outperform them
by a huge margin on SimLex.
Linguistic vectors also perform better at RG-65.
On sentiment analysis, linguistic vectors are competitive with Skip-Gram vectors
and on the NP-bracketing task they outperform all distributional vectors with a
statistically significant margin (p $<$ 0.05, McNemar's test
\newcite{Dietterich98}). We append the sparse linguistic vectors to Skip-Gram
vectors and evaluate the resultant vectors as shown in the bottom row of Table
\ref{tab:eval}. The combined vector outperforms Skip-Gram on all tasks,
showing that linguistic vectors contain useful information orthogonal to
distributional information.
It is evident from the results that linguistic vectors are
either competitive or better to state-of-the-art distributional vector models.
Sparse linguistic word vectors are high dimensional but they are
also sparse, which makes them computationally easy to work with.
\section{Discussion}
Linguistic resources like WordNet have found extensive applications in lexical
semantics, for example, for word sense disambiguation, word similarity etc.
\cite{Resnik:1995,agirre:2009}.
Recently there has been interest in using linguistic resources to enrich word
vector representations. In these approaches, relational information among words
obtained from WordNet, Freebase etc. is used as a constraint to encourage words
with similar properties in lexical ontologies to have similar word vectors
\cite{xu:2014,Yu:2014,yan-ecml14,fried:2014,faruqui:2015}. Distributional
representations have also been shown to improve by using experiential data in
addition to distributional context \cite{andrews2009integrating}.
We have shown that
simple vector concatenation can likewise be used to improve representations
(further confirming the established finding that lexical resources and
cooccurrence information provide somewhat orthogonal information), but it is
certain that more careful combination strategies can be used.
Although distributional word vector dimensions cannot, in general, be
identified with linguistic properties, it has been shown that some vector
construction strategies yield dimensions that are relatively more interpretable
\cite{murphy:2012,fyshe:2014,fyshe:2015,faruqui:2015:sparse}. However, such
analysis is difficult to generalize across models of representation. In
constrast to distributional word vectors, linguistic word vectors have
interpretable dimensions as every dimension is a linguistic property.
Linguistic word vectors require no training as there are no parameters to be
optimized, meaning they are computationally
economical. While good quality
linguistic word vectors may only be obtained for languages with rich
linguistic resources, such resources do exist in many languages and should not
be disregarded
\section{Conclusion}
We have presented a novel method of constructing word vector representations
solely using linguistic knowledge from pre-existing linguistic resources.
These non-distributional, linguistic word vectors are competitive
to the current models of distributional word vectors as evaluated
on a battery of tasks. Linguistic vectors are fully interpretable as every
dimension is a linguistic feature and are highly sparse, so they are
computationally easy to work with.
\section*{Acknowledgement}
We thank Nathan Schneider for giving comments on an earlier draft
of this paper and the anonymous reviewers for their feedback.
\bibliographystyle{acl}
|
{'timestamp': '2015-06-18T02:10:15', 'yymm': '1506', 'arxiv_id': '1506.05230', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05230'}
|
arxiv
|
\section{Introduction}
The advent of RNA-seq technique has revolutionized the study of transcriptomics as it promises a comprehensive transcriptional landscape. Compared to microarrays, RNA-seq can be used to annotate novel genes \cite{roberts2011identification, trapnell2010transcript}, refine the 5$'$ and 3$'$ ends of genes \cite{graveley2008haplo}, identify the boundary of exons and introns and analyze differential gene and transcript expression \cite{jiang2009statistical, rapaport2013comprehensive, trapnell2012differential, xia2011nsmap}. Further, RNA-seq can be applied to construct the whole set of expressed transcripts, which is one of the computational challenges in the field \cite{garber2011computational, martin2011next, nagarajan2013sequence}. Several reference-based assemblers (i.e., mapping assemblers) \cite{garber2011computational, guttman2010ab, trapnell2012differential, yassour2009ab} are developed to reconstruct the full set of expressed mRNAs. With high-quality references, even some erroneous reads can be correctly mapped and thus, expressed transcripts can be accurately reconstructed. \\
However, a high-quality reference genome is not always availa-ble. In fact we do not have reference genomes for the majority of the organisms. Further, due to the genomic difference among the sub-populations within one organism \cite{bryc2010genome, weir1984estimating}, the sample under assembly may be quite different from its reference at some regions. That is, sometimes we cannot rely on the reference even if it does exist. Therefore, de novo assemblers, which do not rely on references, are needed for transcript assembly. A few de novo assemblers \cite{birol2009novo, chu2013ebardenovo, grabherr2011full, koren2012hybrid, peng2013idba, robertson2010novo, schulz2012oases, surget2010optimization, xie2014soapdenovo} have been developed, but they still underperform mapping assemblers (e.g., Cufflinks \cite{trapnell2012differential}) when a good reference is available.
\subsection{Challenges of de novo transcript assembly}
Although significant advance has been made to de novo genome assembly \cite{ariyaratne2011pe, butler2008allpaths, nagarajan2013sequence, zerbino2008velvet}, de novo transcriptome assembly is quite different from genome assembly and faces the following challenges.
\begin{figure*}[!Ht]
\centering
\includegraphics[width=0.9\textwidth]{1.png}
\caption{Illustration of challenges of de novo transcript assembly. (A) isoform deconvolution. Five exons (A, B, C, D and E) form a splicing graph and [$r_1$(gap)$r_2$], [$a_1$(gap)$a_2$], [$b_1$(gap)$b_2$], [$c_1$(gap)$c_2$] and [$d_1$(gap)$d_2$] are all paired-end short reads. (B) Read coverage ($y$-axis) at each position ($x$-axis) of exon AT3G12580-E.2. Only those reads of SRR391052 that can align to this exon with at least 140 matched bases are considered. (C) Impact of $k$-mer size to de Bruijn graph.}
\label{Intro_Fig_1}
\end{figure*}
\subsubsection{Isoform identification}
Isoforms pose challenge to both de novo and mapping based assembly \cite{heber2002splicing, xing2004multiassembly}. Due to alternative splicing in the genome of eukaryotes, one gene may be spliced into multiple transcripts (i.e., isoforms) sharing exons. Paired-end sequencing, which has been applied in the study of genome sequences \cite{ariyaratne2011pe, campbell2008identification, chaisson2009novo, korbel2007paired}, can help resolve isoforms by making use of sequential order (or even sequential distance) of two short reads in the same molecule. In Figure \ref{Intro_Fig_1}A, the read [$r_1$(gap)$r_2$] clearly conveys the information that exon \textbf{A} is a prefix of exon \textbf{D} in some transcript. However, since the insert size (i.e., genomic distance between the $5'$ and $3'$ sequences of one paired-end read) is usually limited, merely utilizing paired-end information may not resolve isoforms. For example, still shown in Figure 1A, \textbf{ACD} and \textbf{BCE} are two isoforms. Suppose that two paired-end reads [$a_1$(gap)$a_2$] and [$b_1$(gap)$b_2$] are sequenced from \textbf{ACD} and two paired-end reads [$c_1$(gap)$c_2$] and [$d_1$(gap)$d_2$] are from \textbf{BCE} respectively. Only based upon these four reads we cannot infer that '\textbf{A}' must connect to '\textbf{D}' and '\textbf{B}' to '\textbf{E}'. Instead, '\textbf{ACE}' and '\textbf{BCD}' may also be feasible transcripts.
\subsubsection{Uneven expression levels}
RNA-seq data has unevenly distributed coverage on transcripts under assembly due to a large range of expression. This leads to:
\begin{itemize}
\item It is challenging to select a good $k$-mer size for a de Bruijn graph assembler to conduct assembly. Highly-expressed transcripts or isoform-shared exons tend to have higher coverage while lowly-expressed transcripts lower coverage. De Bruijn graphs of a single $k$-mer size may not be suitable for the reconstruction of transcripts with varied expression levels. The reads for the transcripts with low expression tend to have less overlap and thus, these transcripts are less likely to be represented as a connected path in a de Bruijn graph of a large $k$-mer size. However, a smaller $k$ may reduce the assembly specificity. As shown in Figure \ref{Intro_Fig_1}C, there is a one-to-one correspondence between the sequence \textbf{ACGAACGCACGGACG} and the $4$-mer de Bruijn graph, but this is not true for the $3$-mer de Bruijn graph.
\item It is very challenging to correct sequencing errors. Ideally, the full set of expressed transcripts can be represented as many small disconnected de Bruijn graphs \cite{peng2013idba}, each connected graph may correspond to isoforms of one gene. However, due to the existence of erroneous $k$-mer nodes, these disconnected components may be coupled together, and traversing such a graph with chimeric edges may generate chimeric transcripts. Most de Bruijn graph genome assemblers, such as Velvet \cite{zerbino2008velvet} and ALLPATHS \cite{butler2008allpaths}, correct erroneous nodes by simply removing those $k$-mers with low support since they are very likely to be erroneous. However, such a method is not suitable for RNA-seq due to uneven expression levels. The support of an erroneous $k$-mer from a highly-expressed transcript may be higher than that of a correct $k$-mer from a lowly-expressed transcript. Therefore, simply removing $k$-mers with weak support will not only remove errors, but also many correct $k$-mers extracted from lowly-expressed transcripts.
\end{itemize}
\subsubsection{Coverage variation within a single transcript}
To better handling the uneven coverage on transcripts, some transcriptome assemblers conduct multiple runs of assembly, and apply a single but different $k$-mer de Bruijn graph at each run \cite{birol2009novo, peng2013idba, schulz2012oases}. However, this strategy cannot deal well with coverage variation in a single transcript. Coverage variation not only exists among transcripts, but also appears within even a single transcript. As shown in Figure \ref{Intro_Fig_1}B, the coverage of the exon AT3G12580-E.2 shows big variation. Actually, the sequencing process can be understood as a random process \cite{dohm2008substantial, mcintyre2011rna}, and each base pair can be hit by the random sequencing process with a certain probability in one run. Thus, for those transcripts with not very high expression levels, the variance of coverage would probably be more significant.
\subsection{Related work}
Several de novo transcript assemblers have been developed, including the Trinity \cite{grabherr2011full}, Oases-M \cite{schulz2012oases}, Trans-ABySS \cite{robertson2010novo}, IDBA-Tran \cite{peng2013idba} and SOAPdenovo-Trans \cite{xie2014soapdenovo}. All these assemblers are de Bruijn graph assemblers.\\
Trinity is developed to assemble highly-expressed transcripts with large support. Trinity uses a simple clustering-based error correction method and thus, may remove many correct $k$-mers sequenced from the transcripts with low expression. Further, Trinity uses only one de Bruijn graph of single and large-sized $k$-mer and thus, may miss the transcripts with low expression.\\
SOAPdenovo-Trans is another de Bruijn graph based assembler derived from the SOAPdenovo2 assembler \cite{luo2012soapdenovo2}, with an effective scaffolding module for transcript assembly. SOAP denovo-Trans utilizes the Trinity error correction strategy, a carefully designed de Bruijn graph simplification method and the Oases graph traversal strategy to generate high quality transcript candidates.\\
Unlike Trinity and SOAPdenovo-Trans, both Trans-ABySS and Oases-M use multiple de Bruijn graphs of different-sized $k$-mers to conduct assembly in multiple runs. In each run only one graph is used and the assembly results of all the runs are combined by a consensus method. Since they still use a single graph to construct each transcript fragment, they may not deal well with a transcript with large coverage variation across different regions \cite{dohm2008substantial, mcintyre2011rna}. Further, after combining the reconstructed transcripts from all the runs, they may produce duplicated (but different) copies of the same transcript and thus, generate many more transcripts than expected.\\
Similar to Oases-M, IDBA-Tran also uses multiple de Bruijn graphs with distinct $k$ to handle transcripts with different expression levels. IDBA-Tran employs a probabilistic progressive approach to iteratively remove erroneous $k$-mers with local thresholds. In each run, IDBA-Tran deals with the output of last round rather than the raw reads, which is different from Oases-M and Trans-ABySS, but IDBA-Tran still uses single $k$-mer de Bruijn graph to handle a group of transcripts.\\
All the methods described above can be regarded as "transcript-level" methods. That is, in each run of assembly, a single $k$-mer size is applied globally to all the transcripts.
\subsection{Contribution}
In this study, we present a new de novo transcript assembler Ber-muda with the following features:
\begin{itemize}
\item Bermuda uses dynamic $k$-mer sizes to assemble different regions of a single transcript fragment in a single run. Consequently, it can deal with not only uneven expression levels among transcripts, but also coverage bias along a single transcript resulting from sequencing at random positions. By contrast, existing methods use single strategy (e.g. a single $k$-mer graph) to assemble the whole set of transcripts in one run. To the best of our knowledge, Bermuda is the first assembler that employs dynamic strategies for transcript assembly in a single run.
\item Bermuda uses de Bruijn graphs for only pre-assembly error correction and then directly joins overlapping short reads into transcripts, as opposed to existing methods that search connected paths in the graphs as the assembly results. By doing so, we can significantly reduce false positives (e.g., chimeric paths) introduced by de Bruijn graphs.
\item Bermuda uses a bi-directional assembly process to join overlapping short reads, which can significantly reduce the impact of insert size.
\end{itemize}
\section{MAERIALS AND METHODS}
\begin{figure}[!Ht]
\centering
\includegraphics[width=0.5\textwidth]{2.png}
\caption{Illustration of applying multiple $k$-mer sizes to assemble a single transcript. (A) The reads. (B) The corresponding $4$-mer de Bruijn graph built from reads. (C) The $3$,$4$-mer de Bruijn graph. (D) Applying four $k$ $(k_1>k_2>k_3>k_4)$ to assemble a transcript with varied coverage.}
\label{Intuition}
\end{figure}
\begin{figure}[!Ht]
\centering
\includegraphics[width=0.45\textwidth]{3.png}
\caption{Workflow of Bermuda.}
\label{Work_Flow}
\end{figure}
\subsection{New insights}
Existing de Bruijn graph assemblers either apply a de Bruijn graph of a carefully-chosen $k$-mer size to assemble the full set of transcripts, or conduct multiple runs of assembly and use a single-sized $k$-mer graph in each run. However, in some situations, it is not easy to find such a single $k$ so that high-quality assembly can be conducted using that $k$-mer graph. \\
As shown in Figure \ref{Intuition}A, supposing there are four reads for the sequence \textbf{ACGAACGCACGGACG}. Although the $3$-mer graph built from these reads is connected, it contains a few loops (see Figure \ref{Intro_Fig_1}C), which makes it hard to identify the true sequence among so many possible paths without extra information. If $4$-mers are used, as shown in Figure \ref{Intuition}B, it will result in four disconnected small de Bruijn graphs (marked by four different colors). That is, there is no single $k$ suitable for this case. However, if we use both $3$-mers and $4$-mers, then we can build a simple, linear and connected graph from the four reads, as shown in Figure \ref{Intuition}C.\\
The intuition is that we shall choose a $k$-mer size considering the read coverage at each position \cite{bankevich2012spades}. In particular, given a sequence $\{a_1,a_2,...,a_N\}$ and $M$ reads, the optimal $k$ for $a_i$ shall be the maximum number $s$, such that there exists a path $[a_{i-s},...,a_{i-1}] \to [a_{i-s+1},...,a_i ] \to [a_{i-s+2},...,a_{i+1}]$ in the $s$-mer de Bruijn graph. The larger read coverage at one point, it is more likely we can use a larger $k$-mer size.\\
Due to read coverage variation, it is infeasible to choose a specific $k$-mer size optimal for all positions. Instead, we may choose several distinct $k$-mer sizes, and adaptively choose one based on the local read coverage. In particular, we may divide the whole coverage range into four levels and at each level, we use a specific $k$, as shown in Figure \ref{Intuition}D. Generally speaking, larger $k$ is used for regions with higher coverage and smaller $k$ for regions with low coverage.
\subsection{Overview of Bermuda}
Figure \ref{Work_Flow} illustrates the overall flowchart of Bermuda. Bermuda first corrects errors in reads, then it directly joins reads to build fragments. Afterwards, Bermuda links these fragments to form splicing graphs, each of which may correspond to isoforms of one or several genes, and finally traverses the graphs to generate candidate transcripts. To correct errors in reads, Bermuda first builds de Bruijn graphs, and conduct graph reduction in each graph. Then Bermuda maps reads back to the reduced de Bruijn graphs to correct sequencing errors in the reads. By default, Bermuda builds four types of de Bruijn graphs of $30-$, $25-$, $20-$, and $15-$mers, respectively. After read correction, Bermuda bi-directionally constructs transcript fragments one by one. For each transcript fragment under construction, Bermuda adaptively uses graphs of different $k$-mer sizes to join overlapping paired-end reads until the whole fragment has been constructed or no compatible reads are available. Bi-direction construction helps with low expression regions of a transcript and also isoform detection. Bermuda repeats the above construction procedure for each possible transcript fragment and also builds (alternative) splicing graphs for isoform detection. A splicing graph encodes all expressed isoforms of one gene or all transcripts of some similar genes. Finally, Bermuda employs the graph traversal algorithm of Oases \cite{schulz2012oases} to identify transcripts.
\begin{figure*}[!Ht]
\centering
\includegraphics[width=0.9\textwidth]{4.png}
\caption{Illustration of transcript fragment construction and splicing graph building. (A) Illustration of fragment growth process ($5'$ to $3'$). (B) Forks tracking (C) An example of reverse direction construction. (D) Illustration of two forms of forks. In Form $I$, node $B$ directly connects to three branches of the fork. In Form $II$, a gap exists between node $C$ and the three branches.}
\label{Construct}
\end{figure*}
\subsection{De Bruijn graphs construction and reduction}
Bermuda uses four types of $k$-mer de Bruijn graphs where $k$ equals to $15$, $20$, $25$, and $30$. A $k$-mer graph is represented as a set of $(k+1)$-mers, each representing an edge in the $k$-mer graph. For example, an edge \textbf{ACG} $\to$ \textbf{CGT} in a $3$-mer graph can be represented by a $4$-mer \textbf{ACGT}. The graph edges are stored in hash tables and balanced trees. See Supplementary Method for more technical details. \\
After building the de Bruijn graphs, Bermuda starts the graph reduction process to remove erroneous nodes in each of the de Bruijn graphs. Typically, a graph reduction process includes removing short tips and parallel paths that share the same start and end nodes with a true path \cite{kelley2010quake, koren2012hybrid, medvedev2011error, pevzner2001eulerian, robertson2010novo, schulz2012oases}. \\
However, a typical parallel path search algorithm may detect an erroneous path that sharing only its start and end nodes with a true path. It would be time-consuming to detect an erroneous path that shares its internal nodes with other true paths. Such kind of parallel paths may be more easily detected in a de Bruijn graph of larger $k$-mers as the internal nodes in an erroneous path may no longer match with nodes in other true paths when $k$ increases. Also, it would be impossible to correct errors in an isolated short path. However, in de Bruijn graph of small $k$-mers, such kind of isolated path may become either a short tip or an erroneous path parallel to some true path if the isolated short path is erroneous. So, by simultaneously examining multi-$k$-mer graphs, we can better remove erroneous nodes. For each single graph, we use a heuristic method to efficiently define the parallel paths. See Supplementary Method for more technical details about our parallel path searching algorithm for a de Bruijn graph.
\subsection{Read error correction}
We correct errors in the $5'$ and $3'$ sequences of one raw paired-end read separately, but with the same procedure. We borrow the ideas from existing error correction methods \cite{le2013probabilistic,schroder2009shrec,ilie2011hitec} but use multiple $k$-mers. To correct errors in a $5'$ or $3'$ sequence, we use the reduced $k$-mer de Bruijn graphs in the decreasing order of $k$ ($k=30$, $25$, $20$, and $15$) and execute the following two steps.
\begin{itemize}
\item If the first $k$-mer of the $5'$ sequence appears in the reduced $k$-mer graph, in the graph find the most similar path starting with this $k$-mer node for the sequence. Replace the $5'$ sequence by the path if they differ from each other by $1$ or $2$ positions. Otherwise, go to the next step.
\item Randomly select one $k$-mer (other than the first one) from the $5'$ sequence and use it as seed to find the most similar path for the sequence. Replace the $5'$ sequence by the path if they differ from each other by $1$ or $2$ bases. Otherwise, use reduced graph with smaller $k$-mer size and goes to step one.
\end{itemize}
\subsection{Transcript fragment construction}
Here we use "transcript fragment" to denote the concatenation of some compatible reads. A fragment may correspond to a single transcript, or multiple isoforms.
\subsubsection{Basic fragment construction procedure}
We construct transcript fragments in both directions: from $5'$ to $3'$ and from $3'$ to $5'$. We grow a fragment by gradually adding and aligning compatible reads, using paired-end information and the context of both the $5'$ and $3'$ sequences. In the $5'$ to $3'$ direction, we say that one read is compatible with one node in the fragment under construction if the $5'$ sequence of this read starts from this node. Similarly, in the $3'$ to $5'$ direction, a read is compatible with one node if its $3'$ sequence starts from this node.\\
Since fragment construction in both directions is quite similar, we only describe the construction procedure from $5'$ to $3'$, as shown in Figure \ref{Construct}A. A fragment under construction consists of two parts: Source and Target. The Source and Target are initially formed by a pair of $5'$ and $3'$ sequences, respectively. They are disconnected and may become connected as the construction goes on. Each node in the Source has one of the three colors: black, red and blue, indicating the status of the reads compatible with the node. A black, red and blue node indicates that the compatible reads have been examined for the fragment growth, are currently under examination and are yet to be examined, respectively. At any time there is at most one red node. When current red node is done, we move to the blue node right next to the red and set its color to red if blue nodes exist.
As shown in Figure \ref{Construct}A, if the $5'$ and $3'$ sequences of one read compatible with the red node can be exactly aligned to the Source and Target respectively, the fragment can be linearly extended. By "exact alignment" we mean that the prefix of one sequence is exactly same as the suffix of the Source or Target. Otherwise, alternative paths (i.e., branches) are introduced to the Source or/and the Target, which results in a nonlinear structure called fork. The branches in a fork may stand for a true path or erroneous/chimeric paths. We merge a pair of branches if they differ by at most $2$ bases. Assume $x$ is the branch with the largest support, and let $|x|$ denote its support. Then any other branch with supports at least $0.05\times |x|$ is treated as a true path. Otherwise, it is treated as an erroneous path and accordingly removed. A fork with true branches encodes isoforms or paralogous genes. \\
Note that all the new nodes added to the Source are marked as blue. After examining all the nodes in the Source, we will also examine the nodes in the Target and continue fragment construction.
\subsubsection{Using multiple k-mer size}
To handle transcripts with uneven expression levels or coverage bias along a single transcript, Bermuda makes use of four types of $k$-mer sizes, say $30-$, $25-$, $20-$, and $15-$mers, respectively and by default. Bermuda always chooses larger $k$-mers when there is sufficient coverage. Otherwise, it uses a smaller $k$-mers to increase sensitivity. More specifically, let $K$ denotes the size of the $k$-mers currently used. Whenever Bermuda finishes examining one red node (see Figure \ref{Construct}A), supposing that there are $x$ blue nodes right after the red node, Bermuda switches to the $k_1$-mer de Bruijn graph where $k_1$ is the largest integer (among $15$, $20$, $25$, and $30$) smaller than $K+x-1$. When $K=15$, and $x=0$, our construction algorithm terminates because we believe that overlapping smaller than 15 base pairs are not reliable. In such kind of case, fragment construction in reverse direction may be applied to continue the fragment construction as described in the following section.
\subsubsection{Fragment construction in reverse direction}
Fragment growth in reverse direction can help detect isoforms since fragment construction along a single direction may not be able to fully capture the complex structure of isoforms. For example, as in Figure \ref{Construct}B(i), we have a de Bruijn graph representation of three transcripts, which share a blue path in the middle. If we only use $5'$ to $3'$ construction starting from the green path, then we can only build a transcript fragment shown in Figure 4B(ii), which misses the red and yellow paths in the $5'$ side (see Figure \ref{Construct}B(i)). Nevertheless, if we conduct the construction along both directions, we may build the three transcripts shown in Figure \ref{Construct}B(i).
Transcript construction in reverse direction is also useful when the Source and Target of one fragment under construction is still disconnected after the $5'$ to $3'$ construction is done. As shown in Figure \ref{Construct}C, assume that there is one read (in green) overlapping with both the Source and Target. Due to the large variation of the insert size, the $5'$ sequence of this read overlaps with the Source by only $6$ bases (the $6$ bases overlap can be identified by brute force search or applying suffix tree), which is not a strong evidence indicating that the $5'$ sequence shall be joined to the Source. By contrast, the $3'$ sequence overlaps with the Target by many more bases. Therefore, if we extend the fragment from the Target to Source, the Source and Target may be connected. That is, reverse direction construction may help connect the Source to the Target or reduce the gap size between them.
\subsection{Building splicing graphs}
As mentioned before, we use splicing graphs for isoform de-convolution. We build splicing graphs after constructing one transcript fragment in both directions ($5'$ to $3'$ and $3'$ to $5'$). When there is no fork in the constructed transcript fragment, there are no isoforms and hence, it is easy to deal with.
If there are branches in either the Source or Target, there may be two types of forks, as shown in Figure \ref{Construct}D. When there is a common junction node connecting the branches as shown in Form I, we split the fragment at this junction node. The boundary of one fragment is defined by junction node. As in Figure \ref{Construct}D, node $B$ is the junction node for Form I and it defines the boundary for the sequence marked by yellow. When there is a gap (the blank nodes in Figure \ref{Construct}D) as shown in Form II of Figure \ref{Construct}D, we do not have a junction node as in Form I. As such, we find the nearest node (e.g., node $C$ in Form II) such that the reads passing through it would support at least two branches. We treat the nearest node as the junction node. Form II appears due to lack of reads to support the two blank nodes as shown in the graph. Finally, we split the frag-ment at all the junction nodes, treat each resultant linear segment as a vertex of the splicing graph and add one directed edge (from $5'$ to $3'$) between two segments that share a junction node and may belong to the same transcript.
\section{RESULTS}
\begin{table*}[!Ht]
\caption{Statistics of assembly results by five assemblers.}
\centering
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
& $\#$Recovered & $\#$Candidates & $\#$Corrects & Pre1($\%$) & Aligned length & Unaligned length & Pre2 \\
\hline
\multicolumn{8}{|c|}{SRR364830 (human)}\\
\hline
Bermuda & $10171$ & $89032$ & $34233$ & $36.4$ & $101445435$ & $28502762$ & $3.56$ \\
Trinity & $8330$ & $120974$ & $34484$ & $28.5$ & $104505218$ & $33668196$ & $3.56$ \\
Oases &- &- &- &- &- &- &- \\
IDBA & $9194$ & $87483$ & $26898$ & $30.7$ & $93398029$ & $26190201$ & $3.57$ \\
SOAP & $7017$ & $65562$ & $37902$ & $57.8$ & $59375913$ & $24522156$ & $2.42$ \\
\hline
\multicolumn{8}{|c|}{SRR391051 (thaliana)}\\
\hline
Bermuda & $5752$ & $38043$ & $18071$ & $47.5$ & $27854983$ & $15119906$ & $1.84$ \\
Trinity & $4658$ & $48128$ & $20692$ & $43.0$ & $22169248$ & $13177044$ & $1.68$ \\
Oases & $3642$ & $112009$ & $62435$ & $55.7$ & $33887243$ & $14028743$ & $2.42$ \\
IDBA & $5439$ & $34121$ & $15893$ & $46.6$ & $23212486$ & $12599930$ & $1.84$ \\
SOAP & $4123$ & $60918$ & $21528$ & $35.3$ & $20793459$ & $14103059$ & $1.47$ \\
\hline
\multicolumn{8}{|c|}{SRR404355 (mouse)}\\
\hline
Bermuda & $1943$ & $18876$ & $13207$ & $69.9$ & $20032435$ & $3132349$ & $6.40$ \\
Trinity & $973$ & $24570$ & $16746$ & $68.2$ & $13514258$ & $1986079$ & $10.09$ \\
Oases & $1277$ & $80359$ & $57983$ & $71.1$ & $25825409$ & $2443274$ & $10.57$ \\
IDBA & $1788$ & $17733$ & $10984$ & $61.9$ & $17046935$ & $3253578$ & $5.24$ \\
SOAP & $1443$ & $35051$ & $16529$ & $47.2$ & $15978392$ & $4930091$ & $3.24$ \\
\hline
\end{tabular}
\label{table:stat}
\end{table*}
\subsection{Datasets}
We benchmark our algorithm using the Human, Mouse and Arabidopsis Thaliana data sets. In total we have tested our method on $12$ datasets. However, due to space limit, here we present experimental results on three real data sets: SRR364830 (human), SRR391051 (thaliana) and SRR404355 (mouse). We compare our method Bermuda with four popular de novo transcript assemblers, including Trinity, Oases-M, IDBA-Tran and SOAPdenovo-Trans. To save space, we denote Oases-M as Oases, IDBA-Tran as IDBA, and SOAPdenovo-Trans as SOAP. All these assemblers use default or recommended parameter settings. We ran Oases using the supplied python pipeline (oases$\_$pipeline.py) with $k_{min}=23$ and $k_{max} = 31$. Such a pipeline will conduct a postprocessing to reduce redundancy in the results. For Bermuda, we use the $30$, $25$, $20$ and $15$-mer for error correction and fragment construction.
We pre-process all the raw reads by removing the reads containing little information evaluated as follows: for a continuous segment of 'N's, we assign a score of 20 to the first 'N' and a score of $2$ to each of the remaining 'N's. We assign a score of $1$ to each base other than 'N'. Let $P(N)$, $P(A)$, $P(C)$, $P(G)$ and $P(T)$ denote the total scores over 'N', 'A', 'C', 'G' and 'T' respectively, and $S$ be $P(A)+P(C)+P(G)+P(T)+P(N)$. We calculate the information content of one sequence as follows:
\begin{align}
&\frac{P(A)}{S}\ln{\frac{S}{P(A)}}+\frac{P(C)}{S}\ln{\frac{S}{P(C)}}\nonumber \\
&+\frac{P(G)}{S}\ln{\frac{S}{P(G)}}+\frac{P(T)}{S}\ln{\frac{S}{P(T)}}+\frac{P(N)}{S}\ln{\frac{S}{P(N)}}
\end{align}
We remove a paired-end read if either its $5'$ or $3'$ sequence has information content less than $0.5$. Some assemblers use the insert size information to assist transcript assembly, but we do not do so because the insert size may vary a lot.
\begin{table}[ht]
\caption{Performance (i.e., $\#$Recovered) with respect to expression levels.}
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
& [0-20] & [20-40] & [40-60] & [60-80] & [80-100] \\
\hline
\multicolumn{6}{|c|}{SRR364830 (human)}\\
\hline
Bermuda & 632 & 2462 & 4637 & 4455 & 1032 \\
Trinity & 417 & 1847 & 3571 & 3948 & 1019 \\
Oases & - & - & - & - & - \\
IDBA & 524 & 2155 & 4001 & 4263 & 952 \\
SOAP & 350 & 1536 & 3047 & 3531 & 886 \\
\hline
\multicolumn{6}{|c|}{SRR391051 (thaliana)}\\
\hline
Bermuda & 15 & 102 & 1403 & 3112 & 3478 \\
Trinity & 2 & 51 & 710 & 2422 & 3211 \\
Oases & 3 & 60 & 730 & 2317 & 3102 \\
IDBA & 3 & 92 & 1228 & 3052 & 3428 \\
SOAP & 1 & 42 & 794 & 2613 & 2897 \\
\hline
\multicolumn{6}{|c|}{SRR404355 (mouse)}\\
\hline
Bermuda & 6 & 61 & 261 & 912 & 1723 \\
Trinity & 1 & 9 & 60 & 362 & 1191 \\
Oases & 1 & 17 & 92 & 491 & 1528 \\
IDBA & 1 & 33 & 234 & 879 & 1693 \\
SOAP & 0 & 26 & 215 & 828 & 1545 \\
\hline
\end{tabular}
\label{table:Performance_EXP}
\end{table}
\subsection{Experiment design and performance metrics }
To evaluate the predicted transcripts, we use BLAST \cite{altschul1997gapped} to align them to the corresponding cDNA databases. Human and mouse cDNA databases are downloaded from \hyperref{url}{http://useast.ensembl.org/index.html}, and Arabidopsis Thaliana cDNA database is from \hyperref{url}{http://plants.ensembl.org/index.html}. Only the best BLAST match for a predicted transcript is used to evaluate the performance.\\
We consider both completeness of a real transcript and correctness of a constructed candidate transcript. The completeness of one constructed candidate transcript is defined as the number of matched bases normalized by the length of the most similar cDNA. The completeness of one cDNA is the maximum completeness value of all the related alignments. The correctness of one constructed candidate is defined as the number of matched bases normalized by its length.\\
To further evaluate the performance of Bermuda, we analyze the constructed candidate transcripts at a given completeness level. Let $A$ denotes the set of candidates with completeness level larger than a given threshold. For each element $x\in A$, denote the best match of $x$ as $M(x)$. For one real cDNA $t$, if there are $r$ elements ${a_1,a_2,...,a_r}$ in $A$, such that $M(a_i)=t$ for $1\leq i \leq r$, then the redundancy of $t$ with respect to $A$ is $r-1$. Then the redundancy of $A$ is calculated by summing over the redundancy of all the cDNAs in the database.\\
To examine the performance of Bermuda at different expression levels, we align each RNA-Seq read set to the corresponding gene database using the Burrows-Wheeler Alignment tool \cite{li2009fast} and calculate the coverage of each gene as described in \cite{jiang2009statistical}. We divide all the expression levels into $5$ quantiles: $[0,20\%]$, $[20,40\%]$, $[40,60\%]$, $[60, 80\%]$, and $[80, 100\%]$, and calculate the number of recovered real transcripts in each quantile.
\begin{table}[ht]
\caption{Computational resources.}
\centering
\begin{tabular}{c c c c c}
\hline
\multicolumn{5}{c}{SRR364830 (human)}\\
\hline
& \multicolumn{3}{c}{Time (seconds)} & Memory \\
& 1 core & 2 cores & 4 cores & GB \\
\hline
Bermuda & 35982 & 21337 & 11023 & 20.3 \\
Oases & >86400 & >86400 & >86400 & > 126 \\
IDBA & 107520 & 60323 & 32234 & 16.3 \\
SOAP & 32880 & 17141 & 8823 & 24 \\
\hline
\multicolumn{5}{c}{SRR391051 (thaliana)}\\
\hline
& \multicolumn{3}{c}{Time (seconds)} & Memory \\
& 1 core & 2 cores & 4 cores & GB \\
\hline
Bermuda & 9157 & 6231 & 4075 & 14.2 \\
Oases & 140400 & 80565 & 49978 & 57.5 \\
IDBA & 22380 & 14640 & 7680 & 8.5 \\
SOAP & 10175 & 5973 & 3998 & 8.2 \\
\hline
\multicolumn{5}{c}{SRR404355 (mouse)}\\
\hline
& \multicolumn{3}{c}{Time (seconds)} & Memory \\
& 1 core & 2 cores & 4 cores & GB \\
\hline
Bermuda & 1395 & 832 & 510 & 0.5 \\
Oases & 1875 & 1043 & 605 &
30.9 \\
IDBA & 6135 & 3857 & 2713 & 2.1 \\
SOAP & 1081 & 669 & 491 &7.0 \\
\hline
\end{tabular}
\label{table:Resources}
\end{table}
\subsection{Statistics of assembly results}
Table 1 lists the statistic information on the output of the five assemblers. Meanwhile, "$\#$Recovered" is the number of real transcripts that can be covered by some candidates at $\geq 90\%$ completeness level. Since the cDNA databases are fixed, so "$\#$Recovered" can be interpreted as the recall. "$\#$Candidates" is the number of the constructed candidate transcripts and "$\#$Corrects" is the number of candidates with $95\%$ correctness. The contig level precision (Pre$1$) is defined as "$\#$Corrects" normalized by "$\#$Candidates". "Aligned length" is the total number of bases in the predicted transcripts that can be aligned to the cDNA database using BLAST and "Unaligned length" is the number of bases that cannot be aligned. The nucleotide level precision (Pre2) is defined as aligned length normalized by unaligned length. Oases failed to run on the SRR364830 (human) data set because it consumes more than $126G$ RAM, which is unavailable on all the computers to which we can access. \\
As shown in Table 1, Bermuda outperforms all the other assemblers in terms of the number of reconstructed transcripts (i.e., "$\#$Recovered"). Oases has the best performance in terms of the contig and nucleotide level precision, but very low recall. This may be because Oases generates many short contigs, which can be easily aligned to cDNA databases very well and thus increase both the contig and nucleotide level precision. SOAP also shows very high contig level precision in the human dataset because it generates many very short candidates on this dataset. SOAP in total generates $153618$ predicted transcripts, but only $65562$ of them are longer than $100bps$. Excluding these exceptions, Bermuda has better precision than the other three assemblers (Trinity, IDBA and SOAP) at both contig and nucleotide levels.
\subsection{Completeness distribution of predicted transcripts}
\begin{figure}[!Ht]
\centering
\includegraphics[width=0.46\textwidth]{5.png}
\caption{Redundancy at different completeness levels. The nine figures show the comparison of redundancy of the five assemblers over human, thaliana and mouse data sets at completeness levels of $0.7$, $0.8$ and $0.9$, respectively.}
\label{Completeness}
\end{figure}
Figure \ref{Completeness} shows the redundancy of assembly results at three different completeness levels: 0.7, 0.8 and 0.9. In this figure, red color indicates the number of redundant occurrences, and the blue color indicates the total number of candidates excluding redundancy. As show in Fig 5, Bermuda outperforms the other assemblers in generating non-redundant candidates at each completeness level (marked by blue color). This also indicates that Bermuda outperforms the other assemblers in terms of recovering a real transcript to a better completeness level.
\subsection{Relationship with expression level}
Table 2 shows the number of reconstructed real transcripts (with completeness level $0.8$) by the five assemblers with respect to expression levels. As described in $3.2$, we divide all the cDNAs into five groups according to their expression levels: $0-20\%$, $20-40\%$, $40-60\%$, $60-80\%$ and $80-100\%$. As shown in Table 2, Bermuda outperforms all the other assemblers at each expression level on all the three data sets. This shows that Bermuda can deal with unevenly distributed RNA-Seq data pretty well.
\subsection{Computational Resources}
Table 3 shows the running time and peak memory usage of the four assemblers, tested on three datasets SRR364830 (human), SRR391051 (thaliana) and SRR404355 (mouse). All the assemblers are run with 1, 2 and 4 cores, respectively, on the same Linux compute node with 126G RAM. As shown in Table 3, Bermuda is slightly slower than SOAP, but much faster than the others. Bermuda consumes moderate amount of memory while Trinity and Oases consume too much memory, which may not be available to many users. The memory consumption by SOAP and IDBA also increase fast along with data size.
\section{Discussion}
This paper has presented a new method Bermuda for de novo transcript assembly. This method is designed to handle transcripts with uneven and low expression levels as well as biased read coverage. Experimental results show that our method not only outperforms a few popular de novo assemblers in terms of the number of recovered transcripts, but also has favorable running time and moderate memory usage. \par
We will extend our work along two lines. One is to design a better method for isoform de-convolution by better utilizing the quantification information (i.e., the observed number of reads mapping to each node of the splicing graph) and formulating it as a regularized network flow problem. We will study an efficient algorithm that can decompose the flow of one splicing graph into several paths, each corresponding to one transcript, subject to the sparsity constraint. Currently our method is mainly designed for short read assembly, we will develop a new method that can combine both short and long reads \cite{koren2012hybrid} to further increase assembly accuracy.
\section{Acknowledgments}
This work was financially supported by the National Science Foundation CAREER award (to JX) and the Alfred P. Sloan Fel-lowship (to JX). \\
Conflict of interest statement. None declared.
\bibliographystyle{abbrv}
|
{'timestamp': '2015-06-19T02:07:29', 'yymm': '1506', 'arxiv_id': '1506.05538', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05538'}
|
arxiv
|
\section{Introduction} \label{sec:intro}
There has been a rapid increase in petabyte-scale data sources across
a range of industry, government, and academic applications. Many of
these sources include data tagged with both geospatial and temporal
attributes. Website HTTP request logs, along with geocoded IP addresses,
are a common example where even modestly sized sites can quickly produce
large-scale datasets. Inexensive embedded GPS devices are another common
source, and are typically found in everything from automobiles to cellphones.
Sensor data from Radio-frequency identification (RFID) devices, which have
been readily adapted to monitor complex supply-chain management operations,
amongst other applications, also generate large datasets with both location
and time-based features.
General purpose distributed filesystems such as the Google Filesystem \cite{ghemawat2003google}
and the Hadoop Filesystem \cite{shvachko2010hadoop}, provide adequate
support for the raw storage of geospatial data sources. These alone however only
provide minimal support for querying file chunks. Analysis, aggregations, and filtering
often require processing through a large subset of the raw data. Database functionality
is provided by additional software, often modelled off of Google's
BigTable \cite{chang2008bigtable} design. Data are stored lexicographically
by a primary key; queries take the form of a scan over a range of contiguous
primary keys along with optional, additional query filters.
Popular open source implementations of this form include Amazon's DynamoDB \cite{decandia2007dynamo},
Apache Accumulo \cite{fuchs2012accumulo}, Apache HBase \cite{taylor2010overview},
and Apache Cassandra \cite{lakshman2010cassandra}.
For geospatial data sources which are typically queried on an entity--by--entity basis, the
standard distributed database applications are straightforward to implement. A uniquely
identifying serial number for each entity can be used as the primary key, with spatial
and temporal filtering accomplished with a combination of in-database filters; a single
entity will typically constitute only a negligable proportion of the overall data volume.
This application model for example would satisfy the needs of a user-facing supply chain
system in which end-users search for the current location of an expected delivery.
Unfortunately, more complex spatial queries do not fit neatly into the distributed database
design. A single primary key is natively one-dimensional, whereas geospatial data
is typically two-dimensional and, with the addition of a temporal component, generally
no less than three. A common method for alleviating the dimensionality problem of having a single primary
index is through the use of a space-filling curves such as Peano, Gosper, and Dragon
curves. A geohash is a particular algorithm which uses a space-filling curve for
encoding latitude and longitude tuples as a single string. It has had fairly wide adoption
for this purpose; for example, it has been included as a core functionality in the popular
distributed document store MongoDB \cite{chodorow2013mongodb}.
The geohash concept adapts well for purely geospatial distributed datasets, allowing for
querying spatial regions of vastly different scales through the use of a single index; larger
regions specify a longer range of geohashes whereas smaller regions specify a shorter range.
A temporal component can be incorporated into the space-filling curve underlying a standard
geohash, however this requires an unavoidable, fixed database design decision as to the
appropriate scaling factor between space and time. For instance: should a square kilometre
bucket in space coorispond to a month, day, or hour bucket in time? The decision has
important performance implications as spatial queries take the form of a collection of
range queries of primary keys. If the buckets are not appropriately sized queries will either
include many false positives (data returned outside of the area of interest) or require
stitching together a large number of small scans. Either of these can cause significant
performance deterioration, due to additional I/O time in the case of false positives and
additional overhead in running a large number of small jobs.
In many cases the question of how to balance space and time into a single key is complicated
by the fact that data are distributed very unevenly over the spatial dimensions. Sources
which are generated roughly proportional to population density will produce 4 orders of
magnitude or more in urban environments compared to rural ones. In these common cases, it
is often more natural to scale the spatial buckets to be proprotional to the data volume.
In this case, we instead only need to decide: should a bucket with 1 million data points
coorispond to month, day, or hour bucket in time? This question will typically have a more
natural answer for a given database system than the previous one, particularly when the
query results are used as inputs to complex algorithms such as recommender systems or
anomaly detection routines.
In order to implement a data balanced alternative to the standard space filling curves,
we present a novel entropy maximizing geohash. Our method is necessarily model based and
learned from a small subset of spatial data. It is robust both to random noise and
model drift. It can implemented with only a modest increase in computational complexity
and is generic enough to be implemented as-is in conjuction with several recently
proposed geohash based schemes for storing large geospatial--temporal datasets. As a
side effect of the entropy based encoding it has also reduces the size of the raw database
files; this has been observed even after applying aggressive compression techniques.
The remainder of this article is organized as follows: Section~\ref{sec:form}
provides a specific formulation of the problems we are trying to solve and the
deficiencies of addressing them using a the standard geohash.
Section~\ref{sec:related} provides a brief literature review of geospatial
database techniques with a particular focus on how these can be used in conjuction
with our methods.
In Section~\ref{sec:geohash} we give a thorough mathematical description of the standard
geohash algorithm and present the formulation for entropy maximizing geohash.
In particular, a theoretical result establishes an upper bound on how well the
maximized geohash can be learnt from a sample of spatial data. Section~\ref{sec:census} applies the
entropic geohash to data from the US Census Bureau, empirically
demonstrating how robust the method is to model drift and Section~\ref{sec:future}
provides avenues for future extensions.
\section{Problem Formulation} \label{sec:form}
Consider partitioning an area of space into equally sized square boxes. If these
regions were given a unique identifier, a basic geospatial-temporal index can be constructed
by concatinating the box id with a timestamp. Querying a region in spacetime, assuming
that the time dimension of the query is small compared to the time window of the database,
would be done by calculating a minimal covering of the spatial region with the square boxes.
Then a range query could be placing for each box id between the desired start and end timestamps.
Several inefficencies may result from this method:
\begin{enumerate}
\item If the boxes are too small relative the query area, the number of queries (each
of which will lead to increased overhead) may be very large. While these can be placed
in parallel, there will eventually be an I/O bottleneck on the machines storing
the database when the number of parallel queries is large.
\item If the query area is smaller than the size of a box, the resultant queries
will have a large number of false positives: points returned which are not in the
desired query region. This leads to significant increases in both computational and I/O costs.
\item Even when the number of covering boxes is neither too small nor too large, the parallel
execution of the queries over each box will not necessarily be balanced. The speedup will be
sub-linear, with the query time driven by the densest box which commonly has an order of
magnitude more data than the average data volume per block.
\end{enumerate}
Issues (1) and (2) are dual to one another, and if all queries have similarly sized
spatial regions the database can be constructed to use boxes with an area optimized
for these queries. However, in the typical case that queries of varying sizes must be
supported, any choice will run into one of these problems. Regardless, the load
balancing associated with (3) continues to be a problem for any dataset with significant
spatial bias.
As a solution to these problems, we propose a method for partitioning space as regions
with equal data volumes rather than boxes with equally sized volumes. This is done by
modifying the standard geohash algorithm without sacrificing any main benefits of the
geohash algorithm or substantially increasing the computation burden of encoding or
decoding input data points.
\section{Related Work} \label{sec:related}
There is a long history of work on data structures for
optimizing geospatial and geospatial-temporal queries such
as $k$-nearest neighbors and spatial joins. Common examples
include R-trees \cite{guttman1984r},
$R^{*}$-trees \cite{beckmann1990r}, and quadtrees \cite{samet1985storing}.
These algorithms often offer superior performance to simple space filling
curves by replicating the true dimensionality of the problem by an abstraction
of trees structures as linked lists. Unfortunately linked lists do not fit into
the primary key design scheme of the distributed databases mentioned in
the previous section, making these more sophisticated algorithms out of
reach for productionalized systems.
Some research has been done towards producing a distributed database which would
be able to natively implement the geospatial temporal database structures which have been successful
on single machine scale applications. These include VegaGiStore \cite{zhong2012towards},
VegaCache \cite{zhong2013vegacache} and VegaCI \cite{zhong2012distributed}, \cite{zhong2012elastic}.
However at this time these remain merely theoretical as no distribution of any of these
has even been publicly distributed, let alone developed to the maturity needed for a
production system.
The simplier approach of adapting geohashes by interleavings spatial and temporal dimensions
has also been explored. Given that these can be quickly implemented on top of existing industry
standard databases this is the approach we have choosen to augment with our work. Fox et al.
developed a generic approach for blending these two dimensions, along with methods for
extending to lines and polygons and for producing fast queries in Apache Accumulo \cite{fox2013spatio}.
The HGrid data model is a similar application which takes advantage of the specific secondary
indicies and related optimizations present in HBase \cite{han2013hgrid}. Both rely on
specifying the relative resolution of the spatial and temporal dimensions, and are able to
use our entropy maximizing geohash with no major changes.
Finally, we note that the desire for a data balanced design which motivated our work is a
natural parallel to the problems associated with efficent query design in the
related tree-based work. Red–-black trees \cite{bayer1972symmetric} and the
Day–-Stout–-Warren algorithm for binary trees \cite{stout1986tree} are important examples
of load balancing used in relation to tree-based data structures.
In this context, the entropy maximizing geohash can be thought of as the curve filling
analogue to balanced trees.
\section{Entropy Balanced Geohash} \label{sec:geohash}
\subsection{A Formulation of the Standard Geohash Encoding}
As mentioned, a geohash is a simple scheme for mapping two-dimensional coordinates into a
hierarchical, one-dimensional encoding. It is explained in several other sources, but we
re-construct it here in a format which will be most conducive to generalizations.
The first step is to map latitude and longitude coordinates in a
standard unit square; this is done by the following linear mapping:
\begin{align}
x &= \frac{\text{lon} + 180}{360} \\
y &= \frac{\text{lat} + 90}{180}
\end{align}
This choice is by convention, and any other method for mapping coordinantes
into the unit square is equally viable.
The $x$ and $y$ coordinates need to be expressed in as a binary decimals.
Formally, we define the $x_i \in \{0,1 \}$ and $y_i \in \{0,1\}$
(with the restriction that neither is allowed to have an infinite trailing
tail with all `1's, for uniqueness) such that
\begin{align}
x &= \sum_{i=1}^{\infty} \frac{x_i}{2^i},\\
y &= \sum_{i=1}^{\infty} \frac{y_i}{2^i}.
\end{align}
A geohash representation of $(x,y)$ is constructed by interleaving these
binary digits. The $q$-bit geohash $g_q(\cdot,\cdot)$ can symbolically
be defined as
\begin{align}
g_q(x,y) &:= \sum_{i=1}^{\lceil q/2 \rceil} \frac{x_i}{2^{2i-1}} +
\sum_{i=1}^{\lfloor q/2 \rfloor} \frac{y_i}{2^{2i}}.
\end{align}
It is fairly easy to show that the geohash function is monotone increasing
in $q$, with the growth strictly bounded by $2^{-q}$, so that
\begin{align}
0 \leq g_{q+m}(x,y) - g_{q}(x,y) < \frac{1}{2^q}
\end{align}
For all $m$ greater than zero.
\subsection{Entropy}
A geohash is typically used as an index in the storing and querying of large
spatial processes. A simple theoretical model for a stream of spatial data can
be constructed by assuming that each observation is an independent identically
distributed random variable $\mathfrak{F}$ from some distribution over space.
Borrowing a concept from information theory, we can define the entropy of a geohash
over a given spatial distribution by the equation
\begin{align}
H(g_q) &:= -1 \sum_{v \in \mathcal{R}(g_q)} \mathbb{P} \left[ g_q(\mathfrak{F}) = v\right] \cdot
\log_2 \left\{ \mathbb{P} \left[ g_q(\mathfrak{F}) = v\right] \right\} \label{entropyDef}
\end{align}
Where $\mathcal{R}(g_q)$ is the range of the $q$-bit geohash. It is a standard result
that the entropy of a discrete distribution is maximized by the uniform distribution.
Therefore we can use the entropy per bit as a proxy for how balanced a geohash is
for a given distribution of spatial data.
\subsection{The Generalized Geohash}
As the $q$-bit geohash function is bounded and monotonic in $q$, we can define the infinite
precision geohash, which we denote as simply $g(\cdot, \cdot)$, to be the limit
\begin{align}
\lim_{q \rightarrow \infty} g_q(x,y) &:= g(x,y).
\end{align}
With this continuous format, one can see that if we compose $g$ with an appropriate new function
$h$, the composition $h \circ g(x,y)$ can be thought of as a rescaled version of the
traditional geohash. To be precise, we would like a function $h$ to have the following properties:
\begin{align}
&h: [0,1] \rightarrow [0,1], \label{hDef} \\
&h(0) = 0, \\
&h(1) = 1, \\
&x < y \iff h(x) < h(y). \label{monotoneEq}
\end{align}
Note that Equation~\ref{monotoneEq} implies that $h$ is also continuous. From here, we can define
the analogue to a $q$-bit geohash by truncating the binary representation of $h(z) = w$,
\begin{align}
h(z) &= \sum_{i=1}^{\infty} \frac{w_i}{2^i}
\end{align}
To the its first $q$-bits
\begin{align}
h_q(z) &:= \sum_{i=1}^{q} \frac{w_i}{2^i}.
\end{align}
In the remainder of this paper, we refer to $h_q \circ g(x,y)$ as a {\it generalized geohash}.
\subsection{The Empirical Entropic Geohash}
We have introduced the concept of a generalized geohash in order to construct a spatial encoding
scheme which better optimizes the entropy as defined in Equation~\ref{entropyDef}.
Assume $\{z_i\}_{i=0}^N$ is a set of independent samples from realizations of the random variable
$\mathfrak{F}$. The empirical cumulative distribution function $G$ of the standard geohash function
$g(\cdot, \cdot)$ is given by
\begin{align}
G(t) &:= \frac{1}{N} \cdot \sum_{i=0}^{N} 1_{g(z_i) \leq t}, \, t \in [0,1]. \label{empGeohash}
\end{align}
From Equation~\ref{empGeohash} we can define the {\it entropy maximizing geohash} function
$b$ (balanced), assuming that every point $z_i$ has a geohash $g(z_i)$ strictly between $0$ and
$1$, to be
\begin{align}
b^q(t) :=
\begin{cases}
0 &\mbox{if } t = 0\\
1 &\mbox{if } t = 1\\
\frac{N}{N+2} \cdot G^{-1}(t) &\mbox{if } \, \exists \, i \in \mathbb{Z} \, \text{s.t.} \, t = i / 2^{q} \\
\text{linear interpolation of the above points} & \text{else}
\end{cases} \label{balancedHash}
\end{align}
The balanced geohash is essentialy the inverse of the empirical function $G$, with some minor
variations to satisfy Equations~\ref{hDef}-\ref{monotoneEq}.
If the points $\{z_i\}$ are unique, and $N$ is sufficently large, the $q$-bit analogue $b_q^q$
of Equation~\ref{balancedHash} will have an entropy $H(b_q^q)$ of approximately equal to $q$.
More formally, we can prove the following bound on the entropy of the balanced geohash:
\begin{thm} \label{entropyThm}
Let $b_q^q$ be the entropy balanced geohash estimated from a sample of $N$ unique data points. Then,
with probability at least $1 - 2 e^{-0.49 \cdot 2^{-2q} N \cdot [1 - A]^2}$ the entropy
$H(b_q^q)$ is bounded by the following simultaneously for all values $A \in [0,1]$:
\begin{align}
H(b_q^q) &\geq q \cdot \frac{N}{N+2} \cdot A
\end{align}
\end{thm}
\begin{proof}
Let $F(\cdot)$ be the true cumulative distribution function of the variable $\mathfrak{F}$,
and $F_N(\cdot)$ be the empirical cumulative distribution function from a sample of $N$
independent observations. Setting $\epsilon = [1 - A] \cdot \frac{N}{N+2} \cdot 2^{-(q+1)}$,
the Dvoretzky–-Kiefer–-Wolfowitz inequality states \cite{dvoretzky1956asymptotic} that
the following holds for all values
$A \in [0,1]$ with probability $1 - e^{-2N\epsilon}$:
\begin{align}
|F(x) - F_n(x)| \leq [1 - A] \cdot \frac{N}{N+2} \cdot 2^{-(q+1)}
\end{align}
Therefore, the empirical entropy should be bounded as follows:
\begin{align}
H(b_q^q) &\geq -1 \cdot \sum_{i=0}^{2^q-1} \left[F(i/2^q) - F((i+1)/2^q)\right] \times
\log_2 \left[F(i/2^q) - F((i+1)/2^q)\right] \\
&\geq -1 \cdot \sum_{i=0}^{2^q-1} \left[F_n(i/2^q) - F_n((i+1)/2^q) - 2\epsilon \right] \times
\log_2 \left[F_n(i/2^q) - F_n((i+1)/2^q) - 2\epsilon \right] \\
&= -2^{q} \cdot \left[\frac{N}{N+2} \cdot \frac{1}{2^q} - 2 \epsilon \right] \times
\log_2 \left[\frac{N}{N+2} \cdot \frac{1}{2^q} - 2 \epsilon \right] \\
&= -1 \cdot \frac{N}{N+2} A \times \log_2 \left[\frac{N}{N+2} \cdot \frac{1}{2^q} \cdot A \right] \\
&\geq q \cdot \frac{N}{N+2} A
\end{align}
Which, plugging in the appropriate $\epsilon$ into the probablity bound, yields the desired result.
\end{proof}
Plugging in $A=2/3$, the bound in Theorem~\ref{entropyThm} holds with probability greater than $0.99$
for a 5-bit balanced geohash when $N$ is at least $1e5$ and for a 10-bit geohash when $N$ is at
least $1e8$. We will see in the our empirical examples that the rate of convergence of the entropy
to $q$ is typically much faster.
\section{Census Data Example} \label{sec:census}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{fig02}
\caption{Example entropy balanced geohash buckets (those which have a common prefix)
of $3$,$4$,$5$, and $6$-bits learned from population data in the state of Ohio.
Numbers are sequentially ordered from the smallest to the largest geohash buckets,
and the buckets were truncated to the state boundaries to increase readability
even though they theoretically extend outside as well.}
\label{fig:ohioHash}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=6in]{fig03}
\caption{Average entropy for population and rental household data in Ohio. The green
line is the standard geohash; dashed lines are balanced geohashes, and the overlaid
numbers give the number of bits to which is is balanced. The rental unit balanced
geohashes are balanced on population data rather than the rental data.}
\label{fig:ohioEntropy}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=6in]{fig04}
\caption{Plots of entropy per bit for population (x-axis) versus rental units (y-axis)
for 5,10, and 15-bit balanced geohashes. Only 34 states (and the District of Columbia)
are shown because overplotting otherwise made the image too difficult to read.}
\label{fig:allStatesEntropy}
\end{figure}
Many large geospatial datasets are distributed roughly proportional to population. Log files
geocoded by ip addresses for instance will tend to have more activity in dense urban areas
and less in rural regions. We use aggregate count data from the US Census data as a natural
example for exploring the balanced geohash because these counts are also proportional to
population (exactly equal, in fact). The Census Bureau distributes decennial aggregate
counts across thousands of attributes at various levels of grainularity. The smallest region
with un-sampled counts are
census blocks, small geographic regions containing the residences of typically somewhere
between 600 and 1300 people. There were over 11 million such regions in the 2010 Census. We
use census blocks here in order to have the maximum level of geospatial grainularity available.
Due to the smaller aggregation size, only a small subset of summary statistics are provided
for census blocks. The total population will be used to construct the balanced geohash, with
the total number of households renting their primary residence (contrasted with owning) being
used to show the relative robustness of the balanced hash.
To help visualize the balanced geohash, the entropy balanced hash up to $3$,$4$,$5$, and
$6$-bits were calculated from the population data in the state of Ohio. In Figure~\ref{fig:ohioHash}
the geohash `buckets', all points in space with a common prefix, are illustrated over a
map of the state. Technically the buckets extend over the entire globe, but are truncated here
to increase readability of the graphic. Notice that each region in the $q$-bit bucket is bifurcated
into two regions in the coorisponding $q+1$-bit bucket. Also, as is common, the smaller set of
$3$-bit buckets all have roughly the same area. However, the $6$-bit buckets differ vastly in size
such as the small area of region 21 and large area of region 51. As expected, the buckets
tend to clump up around the major cities in Ohio, such as the $6$-bit buckets 20-22, 28, 29
around Columbus.
Continuing with the census example in Ohio, Figure~\ref{fig:ohioEntropy} plots the average
entropy for a standard geohash and several balanced geohashes for census block population
and rental household data. The rental household data uses a geohash balanced on population,
and illustrates the degree to which our method is robust to changes in the underlying data
model. In both cases, as expected, the balanced geohashes have higher average entropies the
when more bits are used for balancing. There are significantly diminishing returns of
increasing $q$, however,
with the improvement from 2 to 3 bits being larger than the jump from 5 to 20. The entropy
from the rental unit-based data is generally quite similar to the population-based data,
indicating that the balanced hash is fairly robust to moderate changes in the generating
model. Rental units are correlated with population, but do exhibit spatial dependence with
a higher rate of renting in more urban and less affluent areas as well as spikes near
large universities.
With significantly higher levels of precision, across all of the hashes, the entropies
converge and the entropy per bit begins to decay to zero. The reason for this is that
there are less than $2^{19}$ census blocks in the entire state of Ohio, and even the standard
geohash manages to put every block's centroid into its own bucket after using at least
$35$-bits. Ultimately the discreteness of the data limits our ability to further increase
the entropy even with additional splits. Additionally, the $20$-bit balanced geohash would
in theory have a near perfect entropy per bit up to $20$-bits of hash length if the data were
continuous. In fact, the $20$-bit geohash at $15$-bits of precision (note that this is
indistingusihable from a $15$-bit geohash) has only and entropy of $0.9$ per hash pbit.
Figure~\ref{fig:allStatesEntropy} plots the entropy of three balanced geohashes for
$34$ other states at $15$-bits of precision. The leftmost panel shows the outcome of
only balancing on the first $5$-bits. The worst states here are Alaska, Hawaii, South
Dakota, and North Dakota. These are all states which have a very low population density
(for Hawaii, the density is low when averaged over the area of a bounding box for the
entire island chain). The rightmost panel shows the pure effects
of the discreteness of the data, as all of the x-values would otherwise be nearly perfect
values near $1$. Not surprisingly, the most populous state of California fairs the best
followed closesly by other large states such as Texas and Florida. The smallest states
have the worst entropy here, with DC being the worst at only $0.75$ average entropy per bit.
In all cases, the hash balanced on population performs similarly in regards to the number
of rental properties.
\section{Future Extensions} \label{sec:future}
We have presented an extension on the traditional geohash which is balanced on the data
volume rather than boxes of constant latitude and longitude. The benefits of this approach
have been shown for both spatial and spatial-temporal databases. Theorem~\ref{entropyThm}
establishes the robustness of our model-based approach due to random noise and an empirical
study of US Census data demonstrates robustness to model drift. The balanced geohash is
usable for indexing large databases as-is; in most applications it will perform most queries
in less time, with fewer scans, and lower overhead compared to a standard geohash.
There are several extensions of our work which would further increase the applicability
of the entropy balanced geohash.
Our balanced geohash $b^q_m(\cdot)$ has two free parameters which give the number of bits for which
the hash is balanced ($q$) and length of the entire hash ($m$). The latter is largely
application specific, but the choice of $q$ has some important efficency aspects. If $q$ is
too large the geohash can become quite noisy and overfit to the sample of data used to
learn the underlying model. Additionally, in order to map a standard geohash to a balanced
geohash we need to know the $2^q$ break points to the linear interpolation given in
Equation~\ref{balancedHash}. So if $q$ is large the memory overhead of the balanced
geohash may become prohibitive. In order to better estimate an optimal $q$, tighter two-way
theoretical bounds are needed as compared to those given in Theorem~\ref{entropyThm}. This
will likely require replacing the distribution-free approach employeed in our proof with a
specific family of models such as Gaussian mixtures. In the meantime we can safely pick a
small $q$ without concern, knowing that the noise level is low but that long hash prefixes
may be mildly unbalanced.
The paper \cite{han2013hgrid} provides a generic approach for interleaving geospatial
and temporal components utilizing the specific implementation optimizations present in
HBase. As mentioned, the geohash used in their paper can be seamlessly replaced by the
entropy balanced geohash. The exact method of choosing how to incorporate the time and
space dimensions are not specified as this will largely be a function of the specific
underlying dataset. In the case of the balanced geohash, since the data boxes are
already balanced by the distribution of the data, it should be possible to at least
specify a methodology for choosing how to interleave these components (with perhaps
one or two tuning parameters to tweak based on the specific use-cases). For now the
method of combining these two dimensions can be done fairly well manually, particularly
if the scheme is kept simple.
Finally, while the balanced geohash is fairly robust to model drift, a method akin to
self-balancing trees whereby the balanced geohash could adapt over time would be a
great addition to fixed hash presented here. This would be particularly important when
implementing a large $q$-bit balanced geohash. Possible methods for doing this include
adaptively splitting large prefixes and joining small prefixes; this would require
re-writting data, but would hopefully not be required very often. Alternatively a
scheme could be used to only balance new data as it arrives. In either case, care would
need to be taken to avoid large increases to the computational complexity or memory
overhead of an adaptive modification to the entropy maximized geohash design.
\nocite{*}
|
{'timestamp': '2015-06-18T02:02:57', 'yymm': '1506', 'arxiv_id': '1506.05158', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05158'}
|
arxiv
|
\section*{Author Summary}
Evolution has produced a remarkable diversity of living forms that manifests in qualitative differences as well as quantitative traits.
An essential factor that underlies this variability is transcription factor binding sites, short pieces of DNA that control gene expression levels. Nevertheless, we lack a thorough theoretical understanding of the evolutionary times required for the appearance and disappearance of these sites. By combining a biophysically realistic model for how cells read out information in transcription factor binding sites with model for DNA sequence evolution, we explore these timescales and ask what factors crucially affect them. We find that the emergence of binding sites from a random sequence is generically slow under point and insertion/deletion mutational mechanisms. Strong selection, sufficient genomic sequence in which the sites can evolve, the existence of partially decayed old binding sites in the sequence, as well as certain biophysical mechanisms such as cooperativity, can accelerate the binding site gain times and make them consistent with the timescales suggested by comparative analyses of genomic data.
\section{Introduction}
Evolution produces heritable phenotypic variation within and between populations and species on relatively short timescales.
Part of this variation is due to differences in gene regulation, which determines how much of each gene product exists in every cell.
These gene expression levels are heritable quantitative traits subject to natural selection~\cite{fay_evaluating_2007, zheng_regulatory_2011, romero_comparative_2012}.
While the importance of their variability for the observed phenotypic variation is still debated~\cite{hoekstra_locus_2007}, it is believed to be crucial within closely related species or in populations whose proteins are functionally or structurally similar~\cite{wittkopp_evolution_2013}.
The genetic basis for gene expression differences is thought to be non-coding regulatory DNA, but our understanding of its evolution is still immature; this is due, in part, to the lack of precise knowledge about the mapping between the regulatory sequence and the resulting expression levels.
Transcriptional regulation is the most extensively studied mechanism of gene regulation.
Transcription factor proteins (TFs) recognize and bind specific DNA sequences called binding sites, thereby affecting the expression of target genes.
Eukaryotic regulatory sequences, i.e., enhancers and promoters, are typically between a hundred and several thousand base pairs (bp) in length~\cite{yao_coexpression_2015}, and can harbor many transcription factor binding sites (TFBSs), each typically consisting of $6-12$ bp.
The situation is different in prokaryotes: they lack enhancer regions and have one or a few TFBSs which are typically
longer, between 10 to 20 bp in length \cite{wunderlich_different_2009, stewart_why_2012}. Differences in TF binding are thought to arise primarily due to changes in the regulatory sequence at the TF binding sites rather than changes in the cellular environment or the TF proteins themselves~\cite{schmidt_five-vertebrate_2010}. Nevertheless, a theoretical understanding of the relationship between the evolution of the regulatory sequence and the evolution of gene expression levels remains elusive, mostly because of the complex interaction of evolutionary forces and biophysical processes~\cite{stefflova_cooperativity_2013}.
From the evolutionary perspective, the crucial question is whether and when these regulatory sequences can evolve rapidly enough so that new phenotypic variants can arise and fix in the population over typical speciation timescales.
Comparative genomic studies in eukaryotes provide evidence for the evolutionary dynamics of TF binding, highlighting the possibility for rapid and flexible TFBS gain and loss between closely related species on timescales of as little as a few million years~\cite{dowell_transcription_2010, villar_evolution_2014}.
Examples include quick gain and loss events that cause divergent gene expression~\cite{doniger_frequent_2007}, or the compensation of such events by turn-over at other genome locations~\cite{moses_large-scale_2006}; gain and loss events sometimes occur even in the presence of strong constraints on expression levels~\cite{ludwig_functional_1998, paris_extensive_2013}. Furthermore, such events enabled new binding sites on sex chromosomes that arose as recently as $1-2$ million years ago~\cite{ellison_dosage_2013, alekseyenko_conservation_2013}. There are examples of rapid regulatory DNA evolution across and within populations requiring shorter timescales, i.e. $10.000-100.000$ years~\cite{contente_polymorphic_2002, kasowski_variation_2010, zheng_regulatory_2011,chan_adaptive_2010}.
On the other hand, strict conservation has also been observed at orthologous regulatory locations even in distant species (e.g., \cite{vierstra_mouse_2014}).
Taken together, these facts suggest that the rates of TFBS evolution can extend over many orders of magnitude and differ greatly from the point mutation rate at a neutral site.
To study the evolutionary dynamics of regulatory sequences and understand the relevant timescales, we set up a theoretical framework with a special focus on the interplay of both population genetic and biophysical factors, briefly outlined below.
Sequence innovations originate from diverse mutational mechanisms in the genome.
While tandem repeats~\cite{gemayel_variable_2010} or transposable elements~\cite{feschotte_transposable_2008} may be important in evolution, the better studied and more widespread mutation types still need to be better understood in the context of TFBS evolution.
Specifically, we ask how the evolutionary dynamics are affected by single nucleotide (point) mutations, as well as by insertions and deletions (indels).
New mutations in the population are selected or eliminated by the combined effects of selection and random genetic drift.
Although the importance of selection~\cite{hahn_effects_2003,he_does_2011,arnold_quantitative_2014} and mutational closeness of the initial sequences~ \cite{macarthur_expected_2004, nourmohammad_formation_2011} for TF binding site evolution has already been reported, the belief in fast evolution via point mutations without selection (i.e., neutral evolution) persists in the literature (e.g.,\cite{wittkopp_evolution_2013, villar_evolution_2014}), mainly due to Stone \& Wray's (2001) misinterpretation of their own simulation results~\cite{stone_rapid_2001} (see Macarthur \& Brookfield (2004)~\cite{macarthur_expected_2004}).
This likely reflects the current lack of theoretical understanding of TFBS evolution in the literature, even under the simplest case of directional selection.
Basic population genetics shows that directional selection is expected to cause a change, e.g., yield a functional binding site, over times on the order of $1/(NsU_{b})$, where $N$ is the population size, $s$ is the selection advantage of a binding site, and $U_{b}$ is the beneficial mutation rate~\cite{berg_adaptive_2004}.
This process can be extremely slow, especially under neutrality, if several mutational steps are needed to reach a sequence with sufficient binding energy to confer a selective advantage.
As already pointed out by Berg \textit{et al.} (2004)~\cite{berg_adaptive_2004}, this places strong constraints on the length of the binding sites, if they were to evolve from random sequences.
Several biophysical factors, such as TF concentration and the energetics of TF-DNA and TF-TF interactions, might play an important role in TFBS evolution.
Quantitative models for TF sequence specificity~\cite{von_hippel_specificity_1986, berg_selection_1987, stormo_specificity_1998, stormo_identifying_1989, stormo_determining_2010, zhao_inferring_2009} and for thermodynamic (TD) equilibrium of TF occupancy on DNA~\cite{shea_or_1984, berg_selection_1987, bintu_transcriptional_2005-1, bintu_transcriptional_2005, hermsen_transcriptional_2006, hermsen_combinatorial_2010} were developed in recent decades and, in parallel with developments in sequencing, have contributed to our understanding of TF-DNA interaction biophysics.
These biophysical factors can shape the characteristics of the TFBS fitness landscape over genotype space in evolutionary models~\cite{gerland_physical_2002,gerland_selection_2002, macarthur_expected_2004, berg_adaptive_2004,stewart_why_2012,stewart_evolution_2013,payne_robustness_2014}. There are also intensive efforts to understand the mapping from promoter/enhancer sequences to gene expression~\cite{segal_predicting_2008, hermsen_transcriptional_2006, samee_quantitative_2014, he_thermodynamics-based_2010}.
Despite this recent attention, there have been relatively few attempts to understand the evolutionary dynamics of TFBS in full promoter/enhancer regions~\cite{macarthur_expected_2004, he_evolutionary_2012, hermsen_combinatorial_2010, duque_simulations_2013, duque_what_2015}, especially using biophysically realistic but still mathematically tractable models. Such models are necessary to gain a thorough theoretical understanding of binding site evolution.
Our aim in this study is to investigate the dynamics of TFBS evolution by focusing on the typical evolutionary rates for individual TFBS gain and loss events.
We consider both a single binding site at an isolated DNA region and a full enhancer/promoter region, able to harbor multiple binding sites.
In the following section, we lay out our modeling framework, which covers both population genetic and biophysical considerations, as outlined above.
Using this framework, we try to understand
{\bf i)} what typical gain and loss rates are for a single TFBS site;
{\bf ii)} how quickly populations converge to a stationary distribution for a single TFBS;
{\bf iii)} how multiple TFBS evolve in enhancers and promoters;
{\bf iv)} how early history of the evolving sequences can change the evolutionary rates of TFBS; and
{\bf v)} how cooperativity between TFs affects the evolution of gene expression.
We find that, under realistic parameter ranges, both gain and loss of a single binding site is slow, slower than the typical divergence time between species.
Importantly, fast emergence of an isolated TFBS requires strong selection and favorable initial sequences in the mutational neighborhood of a strong TFBS.
The evolutionary process approaches the equilibrium distribution very slowly, raising concerns about the use of equilibrium assumptions in theoretical work. We proceed to show that the dynamics of TFBS
evolution in larger sequences can be understood approximately from the dynamics of single binding sites; the TFBS gain times are again slow if evolution starts from random sequence in the absence of strong selection or large regulatory sequence ``real estate.''
Finally, we identify two factors that can speed up the emergence of TFBS: the existence of an initial sequence distribution biased towards the mutational neighborhood of strongly binding sequences, which suggests that ancient evolutionary history can play a major role in the emergence of ``novelties''~\cite{villar_enhancer_2015}; and the biophysical cooperativity between transcription factors, which can partially account for the lack of observed correlation between identifiable binding sequences and transcriptional activity~\cite{stefflova_cooperativity_2013}.
\section{Models \& Methods}
\subsection{Population genetics}
We consider a finite population of $N$ diploid individuals whose genetic
content consists of an evolvable $L$ base pair (bp) contiguous regulatory
sequence $\boldsymbol \sigma$ to which TFs can bind. Given that
$\sigma_{i}\in\{A,\, C,\, G,\, T\}$ where $i =1,\, 2, \, ..., \, L$ indexes the position
in regulatory sequence, there are $4^{L}$
different regulatory sequences in the genotype space. Each TF is assumed
to bind to a contiguous sequence of $n$ bp within our focal region
of $L$ bp (Fig.~\ref{Fig1}A,B). Regulatory sequences evolve under mutation, selection,
and sampling drift. The rest of the genome is assumed to be identical for all individuals and is kept constant. In the first part of
our study we consider the regulatory sequence comprised of a single
TFBS (i.e. $L=n$). Later, we consider the evolution of a longer
sequence (i.e. $L \gg n$) in which more than one TFBS can evolve.
For simulations, we use a Wright-Fisher model where $N$ diploid individuals
are sampled from the previous generation after mutation and selection.
Our analytical treatment is general and corresponds to setups where a diffusion approximation to allele frequency
evolution is valid. We neglect recombination since typical regulatory
sequences are short, $L\leq1000$. To be consistent with most of the population genetics literature we assume diploidy, but since we do not consider any dominance effects, our results
also hold for a haploid population with $2N$ individuals.
\begin{figure}
\begin{centering}
\includegraphics[height=0.75\textheight]{Figure/Fig1}
\end{centering}
\caption{
\textbf{Biophysics of transcription regulation.}
\textbf{A)}
TFs bind to regulatory DNA regions (promoters and enhancers) in a sequence-specific manner to regulate transcriptional gene expression
(mRNA production) level via different mechanisms, such as recruiting RNA polymerase (RNA-pol).
\textbf{B)}
A schematic of two types of mutational processes that we model: point mutations (left) and indel mutations (right).
\textbf{C)}
The mismatch binding model results in redundancy of genotype classes, with a binomial distribution (red) of genotypes in each mismatch class (some examples of degenerate sequences shown)
\textbf{D)}
The mapping from the TFBS regulatory sequence to gene expression level is determined by the thermodynamic occupancy (binding
probability) of the binding site.
If each of the $k$ mismatches from the consensus sequence decreases the binding energy by $\epsilon$, the occupancy of the binding site is
$\pi_{\rm TD}(k) = (1+e^{\beta(\epsilon k-\mu)})^{-1}$, where $\mu$ is the chemical potential (related to free TF concentration). A typical occupancy curve is shown in black ($\epsilon=2\,k_BT$ and $\mu=4\,k_BT$); the gray curves show the effect of perturbation to these parameters ($\epsilon=1\,k_BT$, $\epsilon=3\,k_BT$ and $\mu=6\,k_BT$); the orange curve illustrates the case of two cooperatively binding TFs ($k_c=0$ and $E_c=-3\,k_BT$, see text for details).
We pick two thresholds, shown in dashed lines, to define discrete binding classes: strong $\mathcal{S}$ ($\pi_{\rm TD}>2/3$) and weak $\mathcal{W}$ ($\pi_{\rm TD}<1/3$).
\label{Fig1}}
\end{figure}
Evolutionary dynamics simplify
in the low mutation limit where the
population consists of a single genotype during most of its evolutionary
history (the fixed state population model). Desai \& Fisher~\cite{desai_beneficial_2007}
have shown that the condition $\frac{\log 4N \Delta f}{\Delta f} \ll \frac{1}{4NU_b \Delta f}$
needs to hold for a fixed state population assumption to be accurate. The term on the left is
the establishment time of a mutant allele with a selective advantage
$\Delta f$ relative to the wild type; the term on the right-hand side is the waiting time
for such an allele to appear, where $U_b$ is the beneficial mutation
rate per individual per generation. Note that, in binding site context, $U_b$ refers to the rate of mutations which increase the fitness, for instance, by increasing binding strength. Its exact value depends on the current state of the genotype; nevertheless, typical value estimates help model the evolutionary dynamics. In multicellular eukaryotes, where most evidence for the evolution of TFBSs has been collected and which provide the motivation for this manuscript, the number of mutations per nucleotide site is
typically low, e.g. $4Nu \sim 0.01$ in \emph{Drosophila} and $4Nu \sim 0.001$
in humans~\cite{lynch_origins_2003}, where $u$ is the point mutation rate per generation per base pair. For a single binding
site of typical length $n \sim 5-15$, one therefore expects the fixed
state population model to be accurate. For longer regulatory sequences, one expects
that beneficial mutations are rare among all possible mutations, so that the fixed state population model can be assumed to hold as well.
Evolution under the fixed state assumption can be treated
as a simple Markovian jump process. The transition rate from a regulatory
sequence $\boldsymbol \sigma$ to another regulatory sequence $\boldsymbol \sigma ' $
in a diploid population is
\begin{equation}
R_{ \sigma ', \sigma }=2N\; U_{ \sigma ', \sigma }\; P_{\rm fix}(N,\, \Delta f_{\sigma', \sigma})
\end{equation}
where $\Delta f_{\sigma ', \sigma} = f(\boldsymbol \sigma' ) - f(\boldsymbol \sigma)$
is the fitness difference and $U_{\sigma', \sigma}$
is the mutation rate from $\boldsymbol \sigma$ to $\boldsymbol \sigma'$. The fixation probability $P_{\rm fix}$ of a mutation with fitness difference $\Delta f$ in a diploid population of $N$ individuals is
\begin{equation}
P_{\rm fix}(N,\, \Delta f) = \frac{1-e^{-2\Delta f}}{1-e^{-4N\Delta f}} \approx \frac{2\Delta f}{1-e^{-4N\Delta f}},
\end{equation}
which is based on the diffusion approximation~\cite{kimura_probability_1962}. Note that the fixation probability scaled with $1/N$ approximates to $2N\Delta f$ when $N\Delta f \gg 1$.
Evolutionary dynamics therefore depend essentially on how regulatory
sequences are mutationally connected in genotype space, and how fitnesses
differ between neighboring genotypes, i.e., on the fitness landscape.
\subsection{Directional selection on biophysically motivated fitness landscapes}
In this study, we focus on directional selection by assuming that fitness $f$ is proportional to gene expression level $g$ which depends on regulatory sequence, i.e.
\begin{equation}
f(\boldsymbol \sigma )=s\,g(\boldsymbol \sigma)
\label{eq:DirectionalSelection}
\end{equation}
where $s$ is the selection strength. It is important to note that this choice does not imply that directional selection is the only natural selection mechanism.
It simply aims at obtaining the theoretical upper limits for the rates of gaining and losing binding sites.
To analyze a realistic but tractable mapping from the regulatory
sequence to fitness, we primarily assume that the proxy for gene expression is the binding occupancy (binding probability) $\pi$ at a single TF binding site, or the sum of the binding occupancies within an enhancer/promoter region (based on limited experimental support~\cite{giorgetti_noncooperative_2010}). This corresponds to
\begin{equation}
f(\boldsymbol \sigma) = s \sum_i \pi^{(i)}(\boldsymbol \sigma)
\label{GeneExpressionModel1}
\end{equation}
where $\pi^{(i)}$ is the binding occupancy of a site starting at the nucleotide $i$ in sequence $\boldsymbol \sigma$, and $s$ can be interpreted as the selective advantage of a strongest binding to a weakest binding at a site. We assume all binding sites have equal strength and direction in their contribution towards total gene activation. Sites acting as repressors in our simple model would enter into Eq~(\ref{GeneExpressionModel1}) with a negative selection strength, $s$. Future studies developing mathematically tractable models should consider more realistic case of unequal contribution with combined activator and repressor sites responding differentially to various regulatory inputs~\cite{duque_what_2015}. Although one can postulate different scenarios that map TF occupancies in a long ($L\gg n$) promoter to gene expression, we chose the simplest case which allows us to make analytical calculations. Later we relax our assumption on noninteracting binding sites and consider the effects of several kinds of interactions on gene expression and thus on evolutionary dynamics.
The occupancy of the TF on its binding site is assumed to be in thermodynamic (TD) equilibrium~\cite{shea_or_1984, berg_selection_1987, bintu_transcriptional_2005-1, bintu_transcriptional_2005, hermsen_transcriptional_2006, hermsen_combinatorial_2010}.
While this might not always be realistic \cite{hammar_direct_2014, cepeda-humerez_stochastic_2015}, there is empirical support for this assumption (particularly in prokaryotes) \cite{segal_predicting_2008, brewster_tuning_2012, razo-mejia_comparison_2014},
and more importantly, it is sufficient to capture the essential nonlinearity in this genotype-phenotype-fitness mapping \cite{haldane_biophysical_2014}.
In thermodynamic equilibrium, the binding occupancy at the site starting with the $i$-th position in regulatory sequence is given by
\begin{equation}
\pi_{\rm TD}^{(i)}(E_i) = \Big(1 + e^{\beta(E_i - \mu)} \Big)^{-1}.
\label{eq:TDmodel}
\end{equation}
Here, $\mu$ is the chemical potential of the TF (related to its free concentration) \cite{gerland_physical_2002,weinert_scaling_2014}; $E_{i}$ is the sequence specific binding energy, where lower energy corresponds to tighter binding, and $\beta=(k_B T)^{-1}$.
We compute the binding energy $E_i$ by adopting an additive energy model
which is considered to be valid at least up to a few mismatches from the consensus
sequence \cite{maerkl_systems_2007, zhao_inferring_2009, stormo_determining_2010, kinney_using_2010}, i.e.
\begin{equation}
E_i(\boldsymbol \sigma ) = \sum_{j=i}^{i+n-1} \xi_{\sigma_j, j}
\end{equation}
where $\xi$ stands for the energy matrix whose $\xi_{\sigma_j, j}$
element gives the energetic contribution of the nucleotide $\sigma_j$
appearing at the $j$-th position within TFBS.
With this, Eq~(\ref{GeneExpressionModel1}) can be rewritten more formally as
\begin{equation}
f(\boldsymbol \sigma) = s \sum_i \pi_{\rm TD}^{(i)} (E_i(\boldsymbol \sigma))
\label{GeneExpressionModel}
\end{equation}
To allow analytical progress, we make the ``mismatch assumption,'' i.e., the energy matrices contain identical $\epsilon >0$ entries for every non-consensus (mismatch) base pair; the consensus entries are set to zero by convention. A
single binding sequence with $k$ mismatches therefore has the binding energy $E = k \epsilon$. We will refer to $\epsilon$ as ``specificity.''
Specificity is provided by diverse interactions between DNA and TF, including specific hydrogen bonds, van der Waals forces, steric exclusions, unpaired polar atoms, etc.~\cite{mckeown_evolution_2014}.
$\epsilon$ is expected to be in the range $1-3$ $k_{B}T$, which is consistent with theoretical arguments \cite{gerland_physical_2002} as well as direct measurements \cite{fields_quantitative_1997, kinney_using_2010, maerkl_systems_2007}. Note that we explicitly check the validity of the analytical results based on the mismatch assumption by comparing them against simulations using realistic energy matrices.
The redundancy (i.e., normalized number of distinct sequences) of a mismatch class $k$ at a
single site in a random genome can be described by a binomial distribution
$\boldsymbol \phi$ (Fig.~\ref{Fig1}C) where the probability of encountering a mismatch class $k$ is
\begin{equation}
\boldsymbol{\phi_{k}}(n,\alpha) = \binom{n}{k}\; \alpha^{k} \big( 1 - \alpha \big)^{n-k}
\label{eq:binomialdistr}
\end{equation}
where $\alpha=3/4$ in the case of equiprobable distribution over the four nucleotides.
We focus on selection in a single environment, which in this framework corresponds to a single choice for the TF concentration.
We therefore fix the chemical potential to a baseline value of $\mu=4\, k_{B}T$, which maps changes in the sequence (mismatch class $k$) to a full range of gene expression levels, as shown in Fig.~\ref{Fig1}D. We subsequently vary $\mu$ systematically and report how its value affects the results.
After these preliminaries, the equilibrium binding probability of Eq~(\ref{eq:TDmodel}) reduces to
\begin{equation}
\pi_{{\rm TD}}(k) = \Big( 1 + e^{\beta(\epsilon\; k - \mu)} \Big)^{-1}.
\end{equation}
This function has a sigmoid shape whose steepness depends on specificity
$\epsilon$ and whose midpoint depends on the ratio of chemical potential
to specificity, $\mu / \epsilon$ (Fig.~\ref{Fig1}D).
To simplify discussion, we introduce two classes of sequences:
genotypes are associated with ``strong binding'' $\mathcal S$
and ``weak binding'' $\mathcal W$ if $\pi_{\rm TD} > 2/3$ and $\pi_{\rm TD} < 1/3$,
respectively. The thresholds that we pick are arbitrary, while still placing the midpoint of the sigmoid between the two classes; our results do not change qualitatively for
other choices of thresholds. In the mismatch approximation, the genotype
classes $k= \{ 0,\,1,\,...,\, k_{\mathcal S} \} \in \mathcal S$
and $k= \{ k_{\mathcal W},\, k_{\mathcal W} + 1, \, ..., \, n \} \in \mathcal W$
correspond to strong and weak binding, respectively. $k_{\mathcal{S}}$
and $k_{\mathcal W}$ are defined as the closest integers to the thresholds defined above; these values depend on $\epsilon$ and $\mu$.
We also define a ``presite'' as the mismatch class that is $1$ bp away from the threshold for strong binding, i.e., a class with $k_{\mathcal S} + 1$ mismatches.
Note that binding length $n$ extends the tail of the fitness landscape
for a single site and shifts the center of redundancy rich mismatch
classes (Fig.~\ref{Fig1}C).
The formulation in Eq~(\ref{GeneExpressionModel}) reduces to
\begin{equation}
f(k) = s\,\pi_{\rm TD}(k)
\end{equation}
in a mismatch approximation at a single site, which we will investigate extensively for $Ns$ scaling of TFBS gain and loss rates.
We consider a wide range of $Ns$ values: $Ns<0$ for negative selection, $Ns=0$ for neutral evolution, $Ns\sim1$ for weak positive selection, $Ns \gg n \log(2)/2$ for strong positive selection (see below for this particular choice of the threshold).
In order to study the effects of interacting TFBSs in large regulatory sequences, we relax our assumption of non-interacting TFBS in Eq~(\ref{GeneExpressionModel}) and study three simple models.
In the main text, we report the cooperative physical interaction between two TF molecules binding two nearby sites where the binding probability at a site is modified as
\begin{equation}
\pi_{\rm coop}(k,\,k_c) = \frac{e^{-\beta(\epsilon k - \mu)} + e^{-\beta (\epsilon ( k + k_c ) - 2 \mu - E_c)}}{1 + e^{-\beta ( \epsilon k - \mu)} + e^{-\beta (\epsilon k_c - \mu)} + e^{-\beta (\epsilon ( k + k_c ) - 2 \mu - E_c)}},
\label{eq:TDmodelwcoop}
\end{equation}
where $k_c$ stands for the mismatch class at the co-binding
site and $E_c$ for cooperativity. In this study we consider that cooperative energy ranges from an intermediate strength ($E_{c}=-2\,k_BT$) to a high strength ($E_{c}=-4\,k_BT$)~\cite{hermsen_transcriptional_2006}.
Fig~\ref{Fig1}D shows an example of the binding probability when a strong co-binding site exists.
As a function of $k$ alone, at fixed $k_c$, this formulation of cooperativity is consistent with the zero-cooperativity ($E_c=0$) case but with a changed effective chemical potential.
We take cooperative interactions into account if the two TFs are binding within $3$ bp of each other, and we only consider the
strongest binding of the cooperative partner (i.e., the proximal location with the lowest $k_c$).
In Supporting Information, we discuss the other two models of interacting TFBS. In one model, gene expression is determined only by the binding probability of the strongest site in the regulatory sequence. In the other model, gene expression is determined by the probability of the joint occupancy of $2$ strongest binding sites, anywhere in the regulatory sequence; this model is a toy version of synergistic ``non-physical'' interaction of TFs which compete with nucleosomal binding for the occupancy of regulatory regions in eukaryotes (see Mirny (2010)~\cite{mirny_nucleosome-mediated_2010} for a detailed model).
\subsection{Point and indel mutations}
Point mutations and indels are the only mutational processes in our framework. Point mutations with a rate $u$ convert the nucleotide at
one position into one of the $3$ other nucleotide types. For a single
binding site, the probability that a point mutation changes the mismatch
class from $k$ to $k'$ is
\begin{equation}
\boldsymbol{P}_{k',k}^{\rm (point)}=\big(1-k/n\big)\,\delta_{k',k+1}+\big(k/3n\big)\,\delta_{k',k-1}+\big(2k/3n\big)\,\delta_{k',k}
\end{equation}
where $\delta_{a,b}=1$ if
$a=b$ and $0$ otherwise.
We define the indel mutation rate per base pair such that it occurs with rate $\theta\, u$ at a position where a random nucleotide sequence is either inserted, or an existing nucleotide sequence is deleted.
For mathematical simplicity, we assume that insertions and
deletions are equally likely; in fact, a slight bias towards deletions is reported in the literature with a ratio of deletion to insertion $\sim1.1-3.0$~\cite{taylor_occurrence_2004, brandstrom_genomic_2007, park_ancestral_2015}.
Parameter $\theta$ is the ratio of indel mutation rate to point mutation rate, and is reported to be in the range $0.1-0.2$~\cite{cartwright_problems_2009, chen_variation_2009, lee_rate_2012}.
We consider two cases: the baseline of $\theta=0$ for
no indel mutations, and $\theta=0.15$ for the combined effect of indel and point mutations.
Since we fix the length of the regulatory sequence, indels shift existing positions
away from or inwards to some reference position (e.g., transcription start site). For consistency,
we fix the regulatory sequence at its final position and assume
that sequences before the initial position are random.
Indel lengths vary, with reports suggesting a sharply decreasing but fat-tail frequency distribution~\cite{keightley_mcalign:_2004}. For simulations
we consider only very short indels of size $1-2$ bp, occurring proportional with their reported frequencies of $0.45$ and $0.18$, respectively. We do not need to assume any particular indel length for analytical calculations (below). While sufficient for our purposes, this setup would need to be modified when working with real sequence alignments of orthologous regions.
For a single binding site (i.e. $L=n$) one can exactly calculate the probability of an indel mutation changing
the mismatch class from $k$ to $k'$ as
\begin{equation}
\boldsymbol{P}_{k',k}^{\rm (indel)} = \sum_{i=1}^{n}(1/n)\; \sum_{x=0}^{k'} \; p(X_i = x \; | \; k)\; p(Y_i = k' - x).\label{eq:indel-mutation}
\end{equation}
Here, $i$ is the index for the position of an indel mutation within the
binding site. The distribution over possible positions is uniform (hence $1/n$). The indel mutation defines two distinct
parts in the binding site in terms of mismatches: nucleotides behind
the indel mutation preserve their mismatch information, yet the nucleotides
within and after indel mutation completely lose it. The new mismatches at these distinct parts $X_i$ and $Y_i$
are binomial random variables,
\begin{equation}
\begin{array}{lcl}
p(X_i = x\; | \; k) & = &\boldsymbol{\phi_x} (i-1, \, \alpha = k/n) \\
p(Y_i = y) & = & \boldsymbol{\phi_y} (n-i+1,\, \alpha = 3/4)
\end{array}
\end{equation}
where $\boldsymbol{\phi_k}(n,\,\alpha)$ is defined in Eq~(\ref{eq:binomialdistr}). Fig~\ref{FigS1} shows that Monte Carlo sampling of indel mutations at a single binding site
matches the analytical expression in Eq~(\ref{eq:indel-mutation}).
The two types of mutations can be combined into the mutation rate matrix as follows:
\begin{equation}
\boldsymbol{U}_{k',k} =
\begin{cases}
n\; u\; \Big( \boldsymbol P_{k', k}^{\rm (point)} + \theta \; \boldsymbol P_{k',k}^{\rm (indel)} \Big) & k' \neq k \\
-\sum_{ k' \neq k} \boldsymbol U_{k', k} & k'=k
\end{cases}.
\end{equation}
\subsection{Evolutionary dynamics of single TF binding sites}
For a sequence that consists of an isolated TFBS (i.e., $L=n$), analytical treatment is possible under the fixed state assumption.
Let $\boldsymbol \psi (t)$ be a distribution over an ensemble of populations, whose $k$-th component, $\boldsymbol \psi_k(t)$,
denotes the probability of detecting a genotype with $k$ mismatches
at time $t$. In the continuous time limit, the evolution of $\boldsymbol \psi (t)$ is described by
\begin{equation}
\frac{d}{dt} \boldsymbol \psi(t) = \boldsymbol R \cdot \boldsymbol \psi
\end{equation}
which accepts the following solution:
\begin{equation}
\boldsymbol \psi (t) = e^{\boldsymbol R \; t} \cdot \boldsymbol \psi (0).
\label{eq:timesolutionR}
\end{equation}
Here, $\boldsymbol R $ is the transition rate matrix defined as
\begin{equation}
\boldsymbol R_{k',k} =
\begin{cases}
2N \; \boldsymbol U_{k',k} \; P_{\rm fix} (N,\, \Delta f_{k',k}) & k' \neq k \\
- \sum_{k' \neq k} \boldsymbol R_{k',k} & k' = k
\end{cases}.
\label{transitionr}
\end{equation}
This dynamical system is a continous-time Markov chain and there exists a unique stationary distribution $\hat{\boldsymbol{\psi}}$ corresponding the genotype distribution over an ensemble of populations at large time points. It can be calculated by decomposing the transition rate matrix $\boldsymbol R $ into its eigenvalues and eigenvectors. The normalised left eigenvector with zero eigenvalue corresponds to the stationary distribution. This can also be expressed
analytically as
\begin{equation}
\hat{\boldsymbol \psi}_k \propto e^{F(k,N) + H(k\; | \; n, \alpha)},
\label{equilibriumsoln}
\end{equation}
where $F(k,N) = 4 N f(k)$ captures the relative importance of
selection to genetic drift, and $H(k\; | \; n,\alpha)$ is the mutational
entropy, describing how a particular mismatch class $k$ is favored
due to redundancy and connectivity of the genotype space. For point mutations alone ($\theta=0$), $H=\log\phi_{k}(n,\alpha)$, with the binomial distribution $\phi_{k}(n,\; \alpha)$ as defined in Eq~(\ref{eq:binomialdistr}). Obtaining a closed form expression for $H$ is difficult when considering indel mutations ($\theta>0$), yet the eigenvalue
method solution suggests a similar shape for $\theta$ in the range of interest.
The form of the stationary distribution was known for a long time in population genetics literature for a single locus or many loci with linkage equilibrium~\cite{wright_evolution_1931}. It has recently been generalised to arbitrary sequence space under the fixed state assumption~\cite{berg_adaptive_2004, sella_application_2005}, resulting in the form of Eq~(\ref{equilibriumsoln}) with a close analogy in the energy-entropy balance of statistical physics~\cite{barton_application_2009}, and become a subject of theoretical interest~\cite{mustonen_evolutionary_2005, mustonen_energy-dependent_2008, manhart_universal_2012, haldane_biophysical_2014}.
Under weak directional selection for high expression (and thus high binding site occupancy),
the stationary distribution shows a bimodal shape, with one peak located around the fittest class, $k \sim 0$, and another
at the core of mutational entropy, $k \sim \alpha \, n$ (recall that
$\alpha=3/4$ for a completely random genome). This
bimodal shape collapses to a unimodal one, either at no selection or at strong selection. The threshold value for $Ns$
distinguishing strong and weak selection regimes primarily depends on the
TFBS binding length, $n$. In a sigmoidal fitness landscape and approximating the binomial distribution by a normal
distribution as appropriate, the sizes of these two peaks are roughly
proportional to $\exp \left(4Ns-n\log4\right)$ and $\sqrt{2\pi\alpha(1-\alpha)n}$,
respectively. Therefore, we expect the threshold $Ns$ to scale
as $\frac{1}{4}\Big(n\,\log4-\frac{1}{2}\log2\pi\alpha(1-\alpha)n\Big)$.
For typical $n$, the linear term is dominant, suggesting that
\begin{equation}
Ns \sim n \log (2)/2
\label{eq:thresholdNS}
\end{equation}
corresponds to the threshold for strong selection in TFBS evolution (cf. Fig~\ref{FigS2}). Note that this $n$ scaling differs from the $\log(n)$ scaling which is expected in simple fitness landscapes~\cite{paixao_first_2015}.
Our argument assumes that the system is at evolutionary equilibrium, which, as we will see, is not necessarily the case even under strong selection, providing further motivation for focusing on dynamical aspects of evolution.
We define the time needed to gain (or lose) a TFBS as the time it takes for a strong binding site to emerge from a weak one (and vice versa), as schematized in Fig.~\ref{Fig1}D.
For an isolated TFBS, these times can be computed from the Markovian properties of the evolutionary dynamics, by
calculating the average first hitting times~\cite{otto_biologists_2007}.
We will use the notations $\langle t \rangle_{\mathcal S \leftarrow k}$
and $\langle t \rangle_{\mathcal W \leftarrow k}$, respectively, for
average gain and loss times when evolution starts from mismatch class
$k$. Obviously, $\langle t \rangle_{\mathcal S \leftarrow k} = 0$ if
$k$ is among the strong binding classes ($k \in \mathcal S$)
and $\langle t \rangle_{\mathcal W \leftarrow k} = 0$ if $k$ is among
the weak binding classes ($k \in \mathcal W$). The average gain
times from other mismatch classes can be found by considering the relation $\langle t \rangle_{\mathcal S \leftarrow k} = 1+ \sum_{k' \notin \mathcal S} \boldsymbol P_{k,k'} \langle t \rangle_{\mathcal S \leftarrow k'}$, where $\boldsymbol P_{k,k'}$ is the probability of transition from $k'$ to $k$ in one generation. One can compute the average gain times by writing it in terms of linear algebraic equation:
\begin{equation}
\boldsymbol T_{\mathcal S \leftarrow} = \mathbf{(R_{\notin \mathcal S})}^{\rm -T} \cdot (-\boldsymbol 1)
\label{eq:averagetimematrix}
\end{equation}
where $ \boldsymbol T_{\mathcal S \leftarrow}$ is a column
vector listing non-trivial gain times, i.e. $ \{ \langle t \rangle_{S \leftarrow k} \}$
for $k = k_{\mathcal S} + 1, \; ..., \; n$. $\mathbf{R_{\notin \mathcal S}}$
is the $\mathbf R$ matrix with all rows and columns corresponding
to $k \in \mathcal S$ deleted and $-{\rm T}$ is the matrix operator
for the transpose after an inverse operation. $\boldsymbol 1$
is a vector of ones. Similarly one can find the loss times,
\begin{equation}
\boldsymbol T_{\mathcal W \leftarrow} = \mathbf{(R_{\notin \mathcal W })}^{\rm -T} \cdot (-\boldsymbol 1)
\label{eq:averagetimematrix-1}
\end{equation}
where $\boldsymbol T_{\mathcal W \leftarrow}$ is a column
vector listing non-trivial loss times, i.e. $\left\{ \langle t\rangle_{\mathcal{W}\leftarrow k}\right\} $
for $k=1,\; 2, \;...\; k_W - 1$. $\mathbf{R_{\notin \mathcal W}}$
is the $\mathbf R$ matrix with all rows and columns corresponding
to $k \in \mathcal W$ deleted.
In the case of point mutations alone ($\theta=0$), the
$\mathbf{R}$ matrix is tri-diagonal and one can deduce simpler
formulae for gain and loss times:
\begin{equation}
\begin{array}{lcl}
\langle t \rangle_{\mathcal S \leftarrow k}^{\rm (point)} & = & \sum_{i=k_{\mathcal S} + 1}^k \frac{1}{\boldsymbol R_{i-1,\, i}} \; \frac{1 - \hat{\boldsymbol \Psi}_{i-1}}{\hat{\boldsymbol{\psi}}_{i}}\\
&&\\
\langle t \rangle_{\mathcal W \leftarrow k}^{\rm (point)} & =& \sum_{i=k+1}^{k_{\mathcal W}} \frac{1}{\boldsymbol R_{i-1,\, i}} \; \frac{\hat{\boldsymbol \Psi}_{i-1}}{\hat{\boldsymbol \psi}_i}
\label{eq:AverageTimeShortestPathGain-1}
\end{array}
\end{equation}
where we use $\hat{\boldsymbol \Psi}_i = \sum_{j=0}^i \; \hat{\boldsymbol \psi}_j$
to denote the cumulative stationary distribution. For very strong
selection, the second term in the sums approaches unity, resulting
in even simpler formulae~\cite{berg_adaptive_2004}, called the ``shortest path''
(sp) solution:
\begin{equation}
\begin{array}{lcl}
\langle t \rangle_{\mathcal S \leftarrow k}^{\rm (sp)} & = & \sum_{i = k_{\mathcal S} + 1}^k \; \frac{1}{\boldsymbol{R}_{i-1,\, i}} \\
&&\\
\langle t \rangle_{\mathcal W \leftarrow k}^{\rm (sp)} & = & \sum_{i = k+1}^{k_{\mathcal W}} \; \frac{1}{\boldsymbol{R}_{i-1,\, i}}
\end{array}.
\label{eq:AverageTimeShortestPathGain}
\end{equation}
These equations can be used to quickly estimate gain and loss rates of interest. For example, the gain rate from presites under strong selection is approximately $ 2 \,Ns\, u\frac{k_{\mathcal S}+1}{3} (f(k_{\mathcal S})-f(k_{\mathcal S}+1))$. Although the exact value depends on the binding specificity and chemical potential, one can see that it is about $Ns\,u$ for the parameter range of interest. Similarly, one can see that the rate of loss from strong sites is about $2n\,|Ns|\,u$ when there is strong negative selection.
\section{Results}
\subsection{Single TF binding site gain and loss rates under mutation-selection-drift are typically slow}
We first studied the evolutionary rates for a single TF binding site at an isolated DNA sequence of the same length under mutation, genetic drift, and directional selection for high gene expression level (i.e., tighter binding).
As detailed in the Models \& Methods section, we combined a thermodynamically motivated fitness landscape with the mismatch approximation, and assumed that the mutation rate is low enough for the fixed state population approximation to be valid. Under these assumptions, we could calculate the inverse of the average TFBS gain and loss times as a function of the starting genotype, using either an exact method or Wright-Fisher simulations. We considered point mutations alone, or point mutations combined with short indel mutations, in order to understand under which conditions the rates of gaining and losing binding sites can reach or exceed the rates $2-3$ orders of magnitude greater than point mutation rate, and thus to become comparable to rates observed in comparative genomic studies.
Fig.~\ref{Fig2}A shows the dependence of the TFBS gain rate on the selection strength (with respect to genetic drift), $Ns$. For parameters typical of eukaryotic binding sites (length $n=7$ bp, specificity $\epsilon=2\,k_BT$), the TFBS gain rates are extremely slow (practically no evolution) when there is negligible selection pressure ($Ns\sim 0$), indicating the importance of selection for TFBS emergence. Indeed, the effective selection needs to be very strong, e.g., $Ns>100$, for TFBS evolution to exceed the per-nucleotide mutation rate by orders of magnitude and become comparable to speciation rates.
\begin{figure}
\begin{centering}
\includegraphics[width=\textwidth]{Figure/Fig2}
\end{centering}
\caption{
\textbf{Single TF binding site gain rates at an isolated DNA region. A)}
The dependence of the gain rate, $1/\langle t\rangle_{\mathcal S \leftarrow k}$ shown in units of point mutation rate, from sequences in different initial mismatch classes $k$ (blue: $k=2$, red: $k=5$),
as a function of selection strength. Results with point mutations only ($\theta=0$) are shown by dashed line; with admixture of indel mutations ($\theta=0.15$) by a solid line. For strong selection, $Ns\gg n\log(2)/2$, the rates scale with $Ns$, which is captured well by the ``shortest path'' approximation (black dashed lines in the main figure) of Eq~(\ref{eq:AverageTimeShortestPathGain}). The biophysical parameters are:
site length $n=7$ bp; binding specificity $\epsilon=2$ $k_B T$; chemical
potential $\mu=4$ $k_{B}T$. Points correspond to Wright-Fisher simulations with $Nu=0.01$ where error bars cover $\pm 2$ SEM (standard error of mean).
Inset shows the behavior of the gain rates as a function of the initial mismatch class $k$ for $Ns=0$
and $Ns=100$.
\textbf{B, C)} Gain rates from redundancy rich classes ($k\sim3n/4$, typical of evolution from random ``virgin'' sequence) under strong selection, without (B) and with (C) indel mutations supplementing the point mutations. Red crosshairs denote the cases depicted in panel A. Contour lines show constant gain rates in units of $Ns\,u$ as a function of biophysical parameters $n$ and $\epsilon$. Wiggles in the contour lines are not a numerical artefact but a consequence of discrete mismatch classes.
\label{Fig2}}
\end{figure}
Even if strong selection were present, the gain rate depends crucially on the initial genotype. While gain rates from presites, i.e., genotypes one mutation away from the threshold for strong binding, are roughly $Ns\,u$ for the strong $Ns$ regime (as estimated by Berg \textit{et al.}~\cite{berg_adaptive_2004}), they decrease dramatically if more mutational steps are needed to evolve a functionally strong binding site. This is illustrated in the inset to Fig~\ref{Fig2}A, showing an exponential-like decay in the gain rates as a function of the number of mismatches, even for a TFBS of a modest length of 7 bp. As argued in the Models \& Methods section (see Eq~(\ref{eq:thresholdNS})), we confirmed that the threshold for the strong $Ns$ regime scales as $n\log(2)/2$ and not as $\log(n)$ which is the case for simple fitness landscapes~\cite{paixao_first_2015}.
The availability of a realistic fraction of indel mutations (here, $\theta=0.15$) can speed up evolution when starting from distant genotypes (cf. solid and dashed red line in Fig~\ref{Fig2}A). This is because indels connect the genotype space such that paths from many to few mismatches are possible within a single mutational step. Nevertheless, the improvement due to indel mutations does not alleviate the need for very strong selective pressure and the proximity of the initial to strongly-binding sequence, in order to evolve a functional site.
Biophysical parameters---the binding site length $n$, the chemical potential $\mu$, and the specificity $\epsilon$---influence the shape of the fitness landscape and thus the TFBS gain rates. This is especially evident when we consider \emph{de novo} evolution starting from random sequence. As shown in Figs~\ref{Fig2}B,\,C, increases in specificity or length cause a sharp drop in the gain rates from initial sequences in the most redundancy rich class, which can be only partially mitigated by the availability of indel mutations. This especially suggests that adaptation of TFBS from random sequences for TF with very large binding lengths and very strong specificities is unlikely with point and indel mutations which can constrain the evolution of TF lengths and TF specificity, which is consistent with Berg {\it et al.} (2004)~\cite{berg_adaptive_2004}'s earlier numeric observation. Importantly, the binding specificity and length show an inverse relation with the logarithm of the gain rates. This is due to the fact that a decrease in specificity allows more genotypes to generate appreciable binding and therefore fitness (see Fig.~\ref{Fig1}D), which partially compensates the increase in mutational entropy at larger binding site lengths. Variation of the chemical potential $\mu$ corresponding to an order-of-magnitude change in the free TF concentration does not qualitatively affect the results.
Typically slow TFBS evolution is a consequence of the sigmoidal shape of the thermodynamically motivated fitness landscape, where adaptive evolution in the redundant but weakly binding classes $\mathcal{W}$ must proceed very slowly due to the absence of a selection gradient. To illustrate this point, we generated alternative fitness landscapes that agree exactly with the thermodynamically motivated one from the fittest class to the threshold class for strong binding, $k_{\mathcal S}$, but after that decay as power laws, $\pi_{\rm pl}$, with a tunable exponent (see SI text). As seen in Fig~\ref{FigS3}, this exponent is a major determinant of the gain rates, suggesting that a biophysically realistic fitness landscape is crucial for the quantitative understanding of TFBS evolution.
To check that the assumption of the fixed state population is valid at $Nu=0.01$, the value used here that is also relevant for multicellular eukaryotes \cite{lynch_origins_2003}, we performed Wright-Fisher simulations as described in the Models \& Methods section. Fig~\ref{Fig2}A shows excellent agreement between the analytical results and the simulation. We further increased the mutation rate to $Nu=0.1$, a regime more relevant for prokaryotes where polymorphisms in the population are no longer negligible, to find that the analytical fixed state assumption systematically overestimates the gain rates, as shown in Fig~\ref{FigS4}. In the presence of polymorphism, therefore, evolution at best proceeds as quickly as in monomorphic populations, and generally proceeds slower, so that our results provide a theoretical bound on the speed of adaptive evolution under directional selection. This is expected since the effects of clonal interference kick in after a certain $Nu$, where two different beneficial mutants start competing with each other, and eventually decrease the fixation probability in comparison to one beneficial mutant sweeping to fixation as in the monomorphic population case.
To check that the mismatch assumption does not strongly affect the reported results, we analyzed evolutionary dynamics with more realistic models of TF-DNA interaction. Different positions within the binding site can have different specificities, and one could suspect that this can significantly lower the evolutionary times. First, some positions within the TFBS may show almost no specificity for any nucleotide, most likely due to the geometry of TF-DNA interactions (e.g, when the TF can contact the nucleic acid residues only in the major groove); we have not simulated such cases explicitly, but simply take the binding site length $n$ to be the effective sequence length where TF does make specific contacts with the DNA. Second, the positions that do exhibit specificity might do so in a manner that is more inhomogeneous than our mismatch assumption, which assigns zero energy to the consensus and a constant $\epsilon$ to any possible mismatch. We thus generated energy matrices where $\epsilon$ was drawn from a Gaussian distribution with the same mean $\langle \epsilon \rangle=2\,k_BT$ as in our baseline case of Fig~\ref{Fig2}A, but with a standard deviation $0.5\,k_BT$. Fig~\ref{FigS5} shows that both equal and unequal energy contributions produce statistically similar behaviors, indicating that inhomogeneous binding interactions cannot substantially enhance the evolutionary rates.
We further investigated the rate of TFBS loss (Fig~\ref{FigS6}). Here too strong (negative) selection is needed to lose a site on reasonable timescales, and it is highly unlikely that a site would be lost in the presence of positive selection. In contrast to the TFBS gain case, however, negative selection and mutational entropy act in the same direction for TFBS loss, reducing the importance of the initial genotype and making selection more effective at larger $n$ and $\epsilon$.
Taken together, these results suggest that the emergence of an isolated TFBS under weak or no selection is typically slow relative to the species' divergence times, and gets rapidly slower for sites that are either longer or whose TFs are more specific than the baseline case considered here. This suggests that biophysical parameters themselves may be under evolutionary constraints; in particular, if point mutations and indels were the only mutational mechanisms, the evolution of long sites, e.g. $n\gg 10-12$, would seem extremely unlikely, as has been pointed out previously \cite{berg_adaptive_2004}. Absent any mechanisms that could lead to faster evolution and which we consider below, isolated TFBS are generally only likely to emerge in the presence of strong directional selection and a favorable distribution of initial sequences that is enriched in presites.
\subsection{Convergence to the stationary distribution is slow and
depends strongly on initial conditions}
A number of previous studies (e.g., \cite{mustonen_evolutionary_2005, mustonen_energy-dependent_2008, haldane_biophysical_2014})
assumed that a stationary distribution of mismatch classes is reached
in the evolution of isolated TFBS and thus an equilibrium solution, Eq~(\ref{equilibriumsoln}), is informative for binding sequence distributions.
In contrast, our results for average gain and loss times suggest that the evolution of an isolated TFBS is typically slow.
To analyze this problem in a way that does not depend on arbitrary thresholds defining ``strong'' and ``weak'' binding classes $\mathcal{S}$ and $\mathcal{W}$, we first examined the evolution of the distribution $\boldsymbol{\psi}(k)$ over the mismatch classes as a function of time in Fig~\ref{Fig3}A. For typical parameter values it takes on the order of the inverse point mutation rate to reach the stationary distribution for populations that start off far away from it, even with strong selection.
\begin{figure}
\begin{centering}
\includegraphics[width=\textwidth]{Figure/Fig3}
\end{centering}
\caption{
\textbf{Convergence to the stationary distribution of TFBS sequences.}
\textbf{A)}
Evolutionary dynamics of the mismatch classes distribution $\boldsymbol{\psi}(k)$ for an isolated TFBS under point and indel mutations
($\theta=0.15$), directional selection for stronger binding,
and genetic drift is shown for initially well ($k=0$, blue) and badly
($k=5$, red) adapted populations. At left, no selection ($Ns=0$); at right, strong selection ($Ns=100$). Different curves show the distribution
of genotype classes at different time points ($t=0u^{-1},\; 0.05u^{-1},\; 0.1u^{-1}$ as decreasing opacity); stationary distribution is shown in green. Insets show the time evolution to convergence for initially well ($k=0$, blue) and badly ($k=5$,
red) adapted populations, measured by the Kullback-Leibler divergence $D_{KL}[\boldsymbol{\psi}(t)\,||\,\boldsymbol{\psi}(t=\infty)]$. The biophysical parameters are: $n=7$ bp, $\epsilon=2$ $k_BT$, $\mu=4$ $k_{B}T$.
\textbf{B)}
Rate of convergence to the stationary distribution for different $\epsilon$ and $n$
values under strong selection ($Ns\gg n \log (2)/2$; here specifically $Ns=100$) and for $\theta=0.15$. Crosshairs represent the parameters used in a).
\label{Fig3}}
\end{figure}
A systematic study of the convergence rates can be performed by computing the (absolute value of the) second eigenvalue, $|\lambda_2|$, of the transition rate matrix $\mathbf{R}$ from Eq~(\ref{transitionr}), and exploring how this depends on the biophysical parameters $n$ and $\epsilon$. Consistent with previous results, we observe large increases in convergence times as $n$ and $\epsilon$ increase. For example, an increase in the binding site length from $n=7$ to $n=11$ at baseline specificity of $\epsilon=2\,k_BT$ would result in a ten-fold increase in the convergence time.
The intuitive reason behind the slow convergence rates is in the bimodal nature of the distribution $\boldsymbol{\psi}(k)$ on the thermodynamically motivated fitness landscape, similar to that reported by Lynch \& Hagner~\cite{lynch_2015}. One ``attractor'' is located around the fittest class ($k\sim0$, due to directional selection), while the
other is located around the redundancy-rich mismatch classes ($k\sim3/4n$). These two attractors are separated by a typically sharp fitness landscape, and the redundancy-rich attractor lacks selection gradients needed to support fast adaptation. The temporal evolution of the distribution $\boldsymbol{\psi}(k)$ from, e.g., a maladapted state, can thus be best understood as the probability weight ``switching'' from resting approximately within one attractor to the other one, while maintaining the bimodal shape throughout, rather than a gradual shift of a unimodal distribution from a maladapted initial value of $k$ to the value favored by selection.
This is especially true when $n$ gets larger: although adaptation within the functional sites can still happen, adaptation from the most random mismatch classes becomes extremely slow, even under strong selection (see Fig~\ref{FigS10}).
These results suggest that stationary distributions of isolated TFBS sequences may not be realizable on the timescales of speciation, which should be a cause of concern when stationarity is assumed without prior critical assessment.
For example, applications assuming the stationary distribution might wrongly infer selection on regulatory DNA.
\subsection{Evolution of TF binding sites in longer sequences }
So far we have shown that the evolution of isolated TFBS is typically slow.
How do the results change if we consider TFBS evolution in a stretch of sequence $L$ bp in length, where $L\gg n$, e.g., within a promoter or enhancer?
Here we focus on \emph{de novo} evolution under strong directional selection for high gene expression, by simulating the process in the fixed state population framework.
Compared to the isolated TFBS case, we need to make one further assumption: that the expression level of the selected gene is proportional to the summed TF occupancy on all sites within the regulatory region of length $L$ (see Models \& Methods for details). While this is the simplest choice, it is neither unique nor perhaps the most biologically plausible one, although limited experimental support exists for such additivity~\cite{giorgetti_noncooperative_2010}; it does, however, represent a tractable starting point when the interactions between individual TF binding sites are not strong and the contribution of each site is equal and of the same sign.
To address the interactions, we look at the cooperative binding case in the following section.
In Supporting Information, we also discuss the competition of TFBSs for the strongest binding, and the ``nonphysical'' synergetic interaction by two strongest TFBSs.
We propose a simple analytical model for the time evolution of the number of strongly binding sites, $z(t)$, in the promoter, derived from isolated TFBS gain and loss rates, $\lambda_{\rm gain}$ and $\lambda_{\rm loss}$. Assuming constant rates, one can write
\begin{equation}
\frac{d}{dt}z(t)=\lambda_{\rm gain}\Big(z_{\rm max}-z(t)\Big)-\lambda_{\rm loss}z(t)
\label{difeqn}
\end{equation}
where $z_{\rm max}$ is the maximum number of TFBS that can fit into the regulatory
sequence of length $L$ bp. If the sites can overlap, $z_{\rm max}=L-n+1$,
otherwise $z_{\rm max}\approx L/n$. The solution for Eq~(\ref{difeqn}) is
\begin{equation}
z(t)=\Big(z_{\rm o}-\frac{B}{A}\Big)e^{-At}+\frac{B}{A}
\end{equation}
where $A=\big(\lambda_{\rm gain}+\lambda_{\rm loss}\big)$, $B=z_{\rm max}\lambda_{\rm gain}$
and $z_{\rm o}=z(t=0)$. Under strong positive selection, i.e. $Ns\gg n\log(2)/2$, the loss rate $\lambda_{\rm loss}$ can be ignored.
If the distribution of the initial mismatch classes in the promoter is $\psi_{k}$, one can approximate $z_{\rm max}-z_{\rm o}=z_{\rm max}\,\sum_{k=k_{\mathcal{S}}+1}^{n}\psi_{k}$ to obtain:
\begin{equation}
z(t)-z_{\rm o}=\big(1-e^{-\lambda_{\rm gain}t}\big)\, z_{\rm max}\,\sum_{k=k_{\mathcal{S}}+1}^{n}\psi_{k}.
\label{eq:Newnt}
\end{equation}
There are two limiting regimes in which we can examine the behavior of Eq~(\ref{eq:Newnt}). Over a short timescale, evolutionary dynamics will search over all possible positions, $z_{\rm max}=L-n+1$, to pull out the presites, since they are fastest to evolve into the strong binding class $\mathcal{S}$, i.e.:
\begin{equation}
\lambda_{\rm gain}\approx \lambda_{\rm gain}^{\rm presite}=\Big(\sum_{k\notin\mathcal{S}}\psi_{k}\Big)^{-1}\,\psi_{k_{\mathcal{S}}+1}/\langle t\rangle_{\mathcal{S}\leftarrow k_{\mathcal{S}}+1}
\label{eq:Newnt1}
\end{equation}
As the process unfolds and new sites are established, new TFBS will only be able to emerge at a smaller set of positions due to possible overlaps, so that $z_{\rm max}\approx L/n$. On the other hand, evolution from higher mismatch classes will also start to contribute towards new sites:
\begin{equation}
\lambda_{\rm gain} \approx \lambda_{\rm gain}^{\rm all}=\Big(\sum_{k\notin\mathcal{S}}\psi_{k}\Big)^{-1}\,\sum_{k\notin\mathcal{S}}\psi_{k}/\langle t\rangle_{\mathcal{S}\leftarrow k}
\label{eq:Newnt2}
\end{equation}
Fig~\ref{Fig4} shows how new TFBSs with length $n=7$ bp emerge
over time in a promoter of $L=30$ bp in length. Consistent with the predictions of our simplified model, we can distinguish the early, intermediate, and late epochs.
In the early epoch, $t < 0.01 u^{-1}$, presites are localized among all possible locations and are established as binding sites. During this period, the growth in the expected number of new TFBSs is linear with time. The importance and predictive power of presites at early epoch remain even under different models of gene expression, including interaction between TFBSs (see Fig~\ref{FigS9}).
In the intermediate epoch, new binding sites accumulate at the rate that is slightly above that expected by establishment from presites alone, as the mutational neighborhood is explored further. In the late epoch, $t>0.1 u^{-1}$, initial sites in the immediate mutational vicinity have been exhausted, and established sites have constrained the number of positions where new sites can evolve from more distant initial sequences, leading to the saturation in the number of evolved TFBS.
\begin{figure}
\begin{centering}
\includegraphics[width=0.95\textwidth]{Figure/Fig4}
\end{centering}
\caption{
\textbf{TF binding site evolution in a longer sequence of $L=30$ base pairs.}
The expected number of newly evolved TF binding sites with
length $n=7$ bp, under strong directional selection ($Ns=100$) and both point and indel mutations ($\theta=0.15$). Time is measured in inverse mutation rates; the number of newly evolved sites is scaled to the selection strength and the sequence length.
1000 replicate simulations were performed with different initial sequences. Average number of sites shown by a solid black line; the gray band shows $\pm 2$ SEM (standard error of the mean) envelope. Dashed curves are analytical predictions based on single TFBS gain rates at an isolated DNA region, given by Eqs~(\ref{eq:Newnt},\ref{eq:Newnt1},\ref{eq:Newnt2}). Biophysical parameters used: $\epsilon=2$ $k_BT$, $\mu=4$ $k_BT$.
\textbf{Insets:}
Expected number of newly evolved sites
from a random sequence of length $L$ at $t=0.001 u^{-1}$ (left) and $t=0.1 u^{-1}$ (right) for different binding length and specificity
values, computed using the analytical predictions.
Crosshairs denote the values used in the main panel.
\label{Fig4}}
\end{figure}
Using the simple analytical model, we explored in Fig~\ref{Fig4}B,C how the binding length $n$ and specificity $\epsilon$ affect the number of newly evolved TFBS. Increasing $n$ leads to a steep decrease in the number of expected sites, with a somewhat weaker dependence on $\epsilon$, especially at early times.
Simulations at other values of biophysical and evolutionary parameters confirm the qualitative agreement between the analytical model and the simulation (Fig~\ref{FigS7}); given that the model is a simple heuristic, it cannot be expected to match the simulations in detail, yet it nevertheless seems to capture the gross features of evolutionary dynamics.
Together, these results show that at early times under strong selection, the number of newly evolved sites will grow linearly with time and proportional to $L$, before evolution from higher mismatch classes can contribute and ultimately before the sites start interacting, with a consequent slowdown in their evolution. Thus, evolution in longer regulatory regions ($L=10^2-10^3$ bp) could feasibly give rise to tens of binding sites at $Ns=10^2-10^3$ within a realistic time frame $t\sim 0.001 u^{-1}$, if the sites are sufficiently short ($n\sim 7$ bp). Explaining the evolution of longer sites, e.g., $n>10-12$ bp, especially within short promoters found in prokaryotes, would likely necessitate invoking new mechanisms.
\subsection{Ancient sites and cooperativity between TFs can accelerate binding site emergence}
Finally, we briefly examine two mechanisms that can further speed up the evolution of TF binding sites in longer sequences.
The first possibility is that the sequence from which new TFBS evolve is
not truly random; as discussed previously, presites have a strong influence on the early accumulation of new binding sites.
There are a number of mechanisms that could bias the initial sequence distribution towards presites: examples include transposable elements, DNA repeats, or CG content bias.
Here we consider an alternative mechanism that we refer to as the ``ancient TFBS scenario,'' in which a strong TFBS existed in the sequence in the ancient past, after which it decayed into a weak binding site, possibly due to the relaxation of selection (i.e., $Ns\sim 0$).
As we demonstrated in the context of isolated sites, TFBS loss rates are slow and the remains of the binding site will linger in the sequence for a long time before decaying into the most redundancy rich mismatch classes. This biased initial distribution of mismatches $\boldsymbol \Psi$ in a sequence of length $L$ with a single ancient site can be captured by writing:
\begin{equation}
\boldsymbol \Psi = \frac{1}{L-n+1} \; \boldsymbol \psi (t') + \frac{L-n}{L-n+1} \; \boldsymbol \phi
\label{eq:PresiteAncient}
\end{equation}
where $\boldsymbol \phi$ is the binomial distribution, Eq~(\ref{eq:binomialdistr}), characteristic of the random background, and $\boldsymbol \psi (t')$ is the distribution of mismatches due to the presence of the ancient site. Time $t'$ refers to the interval in which the isolated ancient TFBS has been decaying under relaxed selection, and the corresponding $\boldsymbol \psi (t')$ can be solved for using Eq~(\ref{eq:timesolutionR}).
Fig~\ref{Fig5}A shows that the ancient site scenario can enhance the
number of newly evolved sites by resurrecting the ancient site, even after it has decayed for $t'=0.1u^{-1}$. Simulation results agree well with the simple analytical model using the biased initial sequence distribution of Eq~(\ref{eq:PresiteAncient}).
Importantly, such a mechanism is particularly effective for longer binding sites of high specificity, indicating that regulatory sequence reuse could be evolutionarily beneficial in this biophysical regime (see Fig~\ref{FigS8}).
\begin{figure}
\begin{centering}
\includegraphics[width=\textwidth]{Figure/Fig5}
\end{centering}
\caption{
\textbf{Ancient sites and cooperativity can accelerate the emergence of TF binding sites in longer regulatory sequences.}
{\bf A)} The expected number of newly evolved TFBS in the presence (red and brown) or absence (black) of an ancient site, for binding site length $n=10$ bp, and specificity, $\epsilon= 3\, k_BT$. In this example, the ancient site was a consensus site ($k=0$) or two mismatches away from it ($k=2$) that evolved under neutrality for $t'=0.1/u$ prior to starting this simulation. Dashed lines show the predictions of a simple analytical model, Eq~(\ref{eq:PresiteAncient}). The inset shows how the number of newly evolved TFBS at $t=0.001/u$ scales with the mismatch of the ancient site $k$ (plot markers: simulation means; error bars: two standard errors of the mean; dashed curve: prediction). \textbf{B)} The expected number of newly evolved TFBS without (black) and with cooperative interactions (for different cooperativity strengths, magenta: $E_c=-2 \, k_BT$, yellow: $E_c=-3 \, k_BT$, cyan: $E_c=-4 \, k_BT$, see Eq~(\ref{eq:TDmodelwcoop}) in the Models \& Methods and text) for binding site length $n=7$ bp, and specificity, $\epsilon= 2\, k_BT$. Both panels use $\mu=4$ $k_BT$, strong selection ($Ns=100$) and a combination of point and indel mutations ($\theta=0.15$), acting on a regulatory sequence of length $L=30$ bp. Thick solid lines show an average over 1000 simulation replicates, shading denotes $\pm 2$ SEM.
}
\label{Fig5}
\end{figure}
Fig~\ref{Fig5}A and Fig~\ref{FigS8} also show the emergence of new sites when the ancient site was not a full consensus (preferred) sequence but differed from it by a certain number of mismatches.
The results qualitatively agree with the case of perfect consensus.
Importantly, this shows that the applicability of the ancient site scenario extends to cases where the ancient site belonged to a different TF (albeit with a preferred sequence similar to the studied TF), which has recently been reported to be a frequent phenomenon by Payne \& Wagner (2014)~\cite{payne_robustness_2014}, possibly due to evolution of TFs by duplication and divergence~\cite{weirauch_determination_2014}.
The second mechanism that we consider is the physical cooperativity between TFs: when one site is occupied, it is favorable for the nearby site to be occupied as well.
We extended the thermodynamic model to incorporate cooperativity (see the Models \& Methods, Eq~(\ref{eq:TDmodelwcoop}) and Fig~\ref{Fig1}D). The genotype of a nearby site will then influence whether a given site acts as a strongly or weakly binding site.
The presence of a cooperative site acts as a local shift in the chemical potential, which changes the weak/strong threshold, so that an individually weak site can become a strongly binding site.
Simulations using cooperative binding presented in Fig~\ref{Fig5}B illustrate how cooperativity can increase the speed of evolution.
This is specifically effective for short binding sites of intermediate or low specificity, where a cooperative energy contribution can strongly influence the number of sites in the strong binding class (see Fig~\ref{FigS8}).
\section{Discussion}
In this study, we aimed at a better theoretical understanding of which biophysical and population genetic factors influence the fast evolution of TFBSs in gene regulatory DNA, making sequence specific TF binding a plausible mechanism for the evolution of gene regulation and for generating phenotypic diversity.
Following Berg et al. (2004)~\cite{berg_adaptive_2004}, we combined a biophysical model for TF binding with a simple population genetic model for the rate of sequence evolution.
The key assumptions are that binding probability is determined by a thermodynamic equilibrium; that fitness depends linearly on binding probability; and that populations are typically homogeneous in genotype, and so evolve by substitution of single point and short insertion/deletion (indel) mutations.
Remarkably, the biophysical and the evolutionary models take the same mathematical form: in the biophysical model, binding probability depends on the binding energy, relative to thermal fluctuations, $\beta E$, whilst in the evolutionary model, the chance that a mutation fixes depends on its selective advantage, relative to random sampling drift, $Ns$.
For single TFBS evolution, we calculated the average transition time between genotypes, the inverse being a measure for the speed of the evolution.
Our results indicate that TFBS evolution is typically slow unless selection is very strong. It is important to emphasize that gaining a TFBS by point mutations under neutral evolution is very unlikely, contrasting with the belief in the current literature (e.g., \cite{wittkopp_evolution_2013, villar_evolution_2014}).
This is mainly due to Stone \& Wray's argument that functional sites could readily be found by a random walk~\cite{stone_rapid_2001}; however, their argument assumed that individuals follow independent random walks, which grossly overestimates the rate of evolution (see MacArthur \& Brookfield~\cite{macarthur_expected_2004}).
Indeed, fast rates of gaining a single TFBS require not only strong selection but also initial sequences in the mutational neighborhood of the functional sites.
Especially, ``presites," i.e. sequences 1 bp away from threshold sequences, can be crucial since they can evolve to functional sites by single mutations.
Indel mutations can increase the rate of gaining a single TFBS from distant sequences, since they connect the genotype space extensively, but their effect is limited under realistic indel mutation rates~\cite{cartwright_problems_2009, chen_variation_2009}.
Future studies should consider the updates in estimates of indel mutation rates, since they are currently not as precise as point mutation rates, although we do not expect big qualitative departures from our results.
Considering the evolution of a single TFBS from random sequence, we showed that biophysical parameters, binding length and specificity, are constrained for realistic evolutionary gain rates from the most redundant mismatch classes. The rates drop exponentially with binding length, making TF whose binding length exceeds $10-12$ bp difficult to evolve from random sites, at least under the point and indel mutation mechanisms considered here. As a consequence of the biophysical fitness landscape, binding specificity and length show an inverse relation for the same magnitude of the gain rate from the most redundant mismatch class. Such an inverse relation is observed in position weight matrices of TFs collected from different databases for both eukaryotic and prokaryotic organisms, by Stewart \& Plotkin (2012)~\cite{stewart_why_2012}. In the same study, they reproduce this observation using a simple model which assumes that a trade-off between the selective advantage of binding to target sites, versus the selective disadvantage of binding to non-target sequence. Their model assumes a stationary distribution, and that sites are functional if they are mismatched at no more than one base. It would be interesting to explore a broader range of models that account for the dynamical coevolution between transcription factor binding specificity, its length, and its binding sites~\cite{lynch_2015}. One idea can be to combine the evolutionary dynamical constraints (against large binding length and high specificity, which we show here) with simple physical constraints of TF dilution in non-target DNA (against short binding length and low specificity, again in an inverse relation~\cite{gerland_physical_2002}).
For a single TF binding site, the stationary distribution for the mismatch with the consensus binding sequence depends on the binding energy, but also on the sequence entropy -- that is, the number of sequences at different distances from the consensus.
Typically, the distribution is bimodal: either the site is functional, and is maintained by selection, or it is non-functional, and evolves almost neutrally.
We show that it may take an extremely long time for the stationary distribution to be reached.
Functional sites are unlikely to be lost if selection is strong (i.e., $Ns\gg1$), whilst function is unlikely to evolve from a random sequence by neutral evolution, even if predicted under stationarity assumption.
Therefore, typical rapid convergence to stationary distribution should be considered with caution in theoretical studies.
We showed that the dynamics of TFBS evolution in longer DNA sequences can be understood from the dynamics of single TFBS.
The rate of evolution of new binding sites will be accelerated in proportion to the length of the promoter/enhancer sequence in which that can be functional; however, because this increase is linear in promoter/enhancer length, it will have a weaker influence than the exponential effect changes in specificity or length of binding site.
Especially the earlier dynamics (relevant for speciation timescales) are determined by the availability of presite biased sequences.
Any process that allowed selection to pick up more distant sequences or that increased presite ratio among non-functional sites would accelerate adaptation from ``virgin'' sequences.
A key factor for an enrichment in presite ratio may arise through variation in GC content or through simple sequence repeats (especially if the preferred sequence has some repetitive or palindromic structure).
In this study, we showed that it may also arise from ancient sites, i.e. sites that were functional in earlier evolutionary history and decayed into nonfunctional classes in evolution.
Since loss of function is slow (comparable to the neutral mutation rate once selection becomes ineffective), this is plausible for sites that are under intermittent selection, or where there is a shift to binding by a new TF with similar preferred sequence~\cite{payne_robustness_2014, weirauch_determination_2014}.
This effect of the earlier evolution can be especially important for long binding TFs as convergence to a truly randomized sequence distribution requires much longer times.
MacArthur and Brookfield~\cite{macarthur_expected_2004} showed that real promoter sequences may acquire functional sites more quickly than random sequence, but it is not clear whether that is due to a different general composition, or to the ghosts of previous selection.
New studies are required to test our enriched presite-biased sequence hypothesis, especially for orthologous regions where functional TFBS is observed in sister populations or species.
In a recent study, Villar \textit{et al.} (2015)~\cite{villar_enhancer_2015} provide evidence that enhancer DNA sequence structure is older than other DNA portions, suggesting the reuse of such regions in evolution, plausibly by gaining and losing TFBSs in repetitive manner.
Nourmohammad \& Lassig (2011)~\cite{nourmohammad_formation_2011} showed evidence suggesting that local duplication of sequences followed by point mutations played important role in binding site evolution in Drosophila species (but surprisingly, not in yeast species).
Another interesting option would be the existence of ``mobile'' presites or their fragments, e.g., as sequences embedded into transposable elements that could be inserted before the gene under selection for high expression~\cite{feschotte_transposable_2008}. Presites can be considered as concrete examples of cryptic sequences \cite{rajon_compensatory_2013}, potential source of future diversity and evolvability.
We believe that understanding the effects of presites would contribute to the predictability of genetic adaptations regarding gene regulation, especially in important medical applications such as antibiotic resistance or virus evolution.
We also showed that the evolution of a functional binding site in longer DNA can be accelerated by cooperativity between adjacent transcription factors.
When a TF occupies a co-binding site, sufficient transcriptional activity can be achieved from sequences of larger mismatch classes, an effect similar to a local increase in TF concentration. This mechanism permits faster evolution towards strongly binding sequences, and seems most effective for short TFBS where it creates a selection gradient already in the redundancy rich mismatch classes.
Cooperative physical interactions might allow the evolution of binding occupancy and thus expression without large underlying sequence changes, which might be a reason for the observed weak correlation between sequence and binding evolution at certain regulatory regions.
Importantly, TFBS clustering in eukaryotic enhancers can be a consequence of the fast evolution with cooperativity, as also supported by a recent empirical study~\cite{stefflova_cooperativity_2013}.
Our theoretical framework is relevant more broadly for understanding the evolution of gene regulatory architecture. Since the speed of TFBS evolution from random sequences is proportional to $NsL$, our results suggest that population size $N$ and the length of regulatory sequences $L$ can compensate for each other in terms of the rate of adaptation.
This is exactly what is observed: eukaryotes typically have longer regulatory DNA regions but small population sizes, while prokaryotes evolve TFBS within shorter regulatory sequence fragments but have large population sizes. Similarly, prokaryotes might have achieved longer TF binding lengths $n$, as large population size allowed them to overcome the exponential decrease in the gain rates with increasing $n$. If relevant, these observations would suggest that an important innovation in eukaryotic gene regulation must have been the ability of the transcriptional machinery to integrate the simultaneous occupancy of many low-specificity transcription factors bound over hundreds of basepairs of regulatory sequence, a process for which we currently have no good biophysical model.
\section{Acknowledgments}
We thank Magdalena Steinr\"uck, Georg Rieckh, Ferran Palero and Ziya Kalay for helpful comments. NB acknowledges support from ERC Advanced Grant 250152 ``Selection and Information.''
\section{References}
|
{'timestamp': '2015-11-09T02:13:45', 'yymm': '1506', 'arxiv_id': '1506.05162', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05162'}
|
arxiv
|
\section{Introduction} \label{Introduction}
\PARstart{I}{n} spite of common belief, recently conducted channel measurements have shown that millimeter wave (mmWave) frequencies may be suitable for cellular communications, provided that the cell radius is of the order of 100-200 meters \cite{Rappaport__mmWaveAccess}. Based on these measurements, the authors of \cite{Rappaport__mmWaveJSAC} have recently studied system-level performance of mmWave cellular networks and have compared them against conventional micro wave ($\mu$Wave) cellular networks. The results have highlighted that mmWave cellular communications may outperform $\mu$Wave cellular communications, by assuming similar cellular network densities, provided that a sufficient beamforming gain is guaranteed between Base Stations (BSs) and Mobile Terminals (MTs). These preliminary but encouraging results have motivated several researchers to investigate potential and challenges of mmWave cellular communications for wireless access, in light of the large and unused bandwidth that is available at these frequencies.
System-level performance evaluation of cellular networks is widely recognized to be a mathematically intractable problem \cite{AndrewsNov2011}, due to the lack of tractable approaches for modeling the other-cell interference. Only recently, a new mathematical methodology has gained prominence due to its analytical tractability and reasonable accuracy compared to currently deployed cellular networks. This emerging approach exploits results from stochastic geometry and relies upon modeling the locations of the BSs as points of a point process \cite{AndrewsNov2011}. Usually, the Poisson Point Process (PPP) is used due to its mathematical tractability \cite{Haenggi_Survey2013}. Recent results for cellular networks modeling based on stochastic geometry are available in \cite{MDR_TCOMrate}-\cite{MDRwei_TCOM2015}, to which the reader is referred for further information.
Motivated by the mathematical flexibility of the PPP-based abstraction modeling, researchers have recently tried to study the performance of mmWave cellular communications with the aid of stochastic geometry, by developing new frameworks specifically tailored to account for the peculiarities of mmWave propagation \cite{Heath__mmWave}, \cite{Singh__mmWave}. In fact, the mathematical frameworks currently available for modeling $\mu$Wave cellular networks are not directly applicable to mmWave cellular networks. The main reasons are related to the need of incorporating realistic path-loss and blockage models, which are significantly different from $\mu$Wave communications. For example, \cite{Rappaport__mmWaveAccess} and \cite{Rappaport__mmWaveJSAC} have pointed out that Line-Of-Sight (LOS) and Non-Line-Of-Sight (NLOS) links need to be appropriately modeled and may have different distributions, due to the more prominent impact of spatial blockages at mmWave frequencies compared to $\mu$Wave frequencies. Furthermore, in mmWave communications a new outage state may be present in addition to LOS and NLOS states, which better reflects blockage effects at high frequencies and accounts for the fact the a link may be too weak to be established.
Recently reported results on stochastic geometry modeling of mmWave cellular communications \cite{Heath__mmWave}, \cite{Singh__mmWave} take these aspects into account only in part. The approach proposed in \cite{Heath__mmWave} is mathematically tractable for dense network deployments and relies upon an equivalent LOS ball approximation. The approach proposed in \cite{Singh__mmWave} uses a similar LOS ball approximation, but is applicable to medium/sparse network deployments. The outage state observed in \cite{Rappaport__mmWaveJSAC} is not explicitly taken into account either in \cite{Heath__mmWave} or in \cite{Singh__mmWave}. Against this background, in the present paper a new methodology to the stochastic geometry modeling of mmWave cellular communications is proposed, which explicitly incorporates the empirical path-loss and blockage models recently reported in \cite{Rappaport__mmWaveJSAC}.
The paper is organized as follows. In Section \ref{SystemModel}, system model and main modeling assumptions are introduced. In Section \ref{CoverageRate}, the mathematical frameworks for computing coverage probability and average rate are described. In Section \ref{Results}, the frameworks are validated via numerical simulations and the performance of mmWave and $\mu$Wave cellular networks are compared. Finally, Section \ref{Conclusion} concludes this paper.
\section{System Model} \label{SystemModel}
\subsection{PPP-Based Abstraction Modeling} \label{PPP_CellularModeling}
A bi-dimensional downlink cellular network deployment is considered, where a probe MT is located, without loss of generality thanks to the Slivnyak theorem \cite[vol. 1, Th. 1.4.5]{BaccelliBook2009}, at the origin and the BSs are modeled as points of a homogeneous PPP, denoted by $\Psi $, of density $\lambda$. The MT is assumed to be served by the BS providing the smallest path-loss to it. The path-loss model is introduced in Section \ref{PathLossModeling}. The serving BS is denoted by ${\rm{BS}}^{\left( 0 \right)}$. Similar to \cite[Sec. VI]{AndrewsNov2011}, full-frequency reuse is considered. For notational simplicity, the set of interfering BSs is denoted by $\Psi ^{\left( \backslash 0 \right)} = \Psi \backslash {\rm{BS}}^{\left( 0 \right)}$. The distance from the generic BS to the MT is denoted by $r$.
\subsection{Directional Beamforming Modeling} \label{BeamformingModeling}
Thanks to the small wavelength, mmWave cellular networks are capable of exploiting directional beamforming for compensating for the increased path-loss at mmWave frequencies and for overcoming the additional noise due to the large transmission bandwidth. As a desirable bonus, directional beamforming provides interference isolation, which reduces the impact of the other-cell interference. Thus, antenna arrays are assumed at both the BSs and the MT for performing directional beamforming. For mathematical tractability and similar to \cite{Heath__mmWave} and \cite{Singh__mmWave}, the actual antenna array patterns are approximated by considering a sectored antenna model. In particular, the antenna gain of the generic BS, $G_{{\rm{BS}}} \left( \cdot \right)$, and of the MT, $G_{{\rm{MT}}} \left( \cdot \right)$, can be formulated as follows:
\setcounter{equation}{0}
\begin{equation}
\label{Eq_1}
G_{\rm{q}} \left( \theta \right) = \begin{cases}
G_{\rm{q}}^{\left( {\max } \right)} & {\rm{if}}\quad \left| \theta \right| \le \omega _{\rm{q}} \\
G_{\rm{q}}^{\left( {\min } \right)} & {\rm{if}}\quad \left| \theta \right| > \omega _{\rm{q}} \\
\end{cases}
\end{equation}
\noindent where $q \in \left\{ {{\rm{BS}},{\rm{MT}}} \right\}$, $\theta \in \left[ {0,2\pi } \right)$ denotes the angle off the boresight direction, $\omega _q $ denotes the beamwidth of the main lobe, $G_q^{\left( {\max } \right)}$ is the array gain of the main lobe and $G_q^{\left( {\min } \right)}$ is the antenna gain of the side lobe.
Both the MT and its serving BS, ${\rm{BS}}^{\left( 0 \right)}$, are assumed to estimate the angles of arrival and to adjust their antenna steering orientations accordingly. On the intended links, therefore, the maximum directivity gain can be exploited. Thus, the directivity gain of the intended link is $G^{\left( 0 \right)} = G_{{\rm{BS}}}^{\left( {\max } \right)} G_{{\rm{MT}}}^{\left( {\max } \right)}$. The beams of all non-intended links are assumed to be randomly oriented with respect to each other and to be uniformly distributed in $\left[ {0,2\pi } \right)$. Accordingly, the directivity gains of the interfering links, $G^{\left( i \right)}$ for $i \in \Psi ^{\left(\backslash 0 \right)}$, are randomly distributed. Based on \eqref{Eq_1}, their Probability Density Function (PDF) can be formulated as $f_{G^{\left( i \right)} } \left( g \right) = \left( {f_{G_{{\rm{BS}}}^{\left( i \right)} } \otimes f_{G_{{\rm{MT}}}^{\left( i \right)} } } \right)\left( g \right)$, where:
\setcounter{equation}{1}
\begin{equation}
\label{Eq_2}
f_{G^{\left( i \right)}_q } \left( g \right) = \frac{{\omega _{\rm{q}} }}{{2\pi }}\delta \left( {g - G_q^{\left( {\max } \right)} } \right) + \left( {1 - \frac{{\omega _{\rm{q}} }}{{2\pi }}} \right)\delta \left( {g - G_q^{\left( {\min } \right)} } \right)
\end{equation}
\noindent for $q \in \left\{ {{\rm{BS}},{\rm{MT}}} \right\}$, $\delta \left( \cdot \right)$ is the Kronecker's delta function and $\otimes$ denotes the convolution operator.
\subsection{Link State Modeling} \label{LinkStateModeling}
Let an arbitrary link of length $r$, \textit{i.e.}, the distance from the generic BS to the MT is equal to $r$. Motivated by recent experimental findings on mmWave channel modeling \cite[Sec. III-D]{Rappaport__mmWaveJSAC}, a three-state statistical model for each link is assumed, according to which each link can be in a LOS, NLOS or in an outage (OUT) state. A LOS state occurs if there is no blockage between BS and MT. A NLOS state, on the other hand, occurs if the BS-to-MT link is blocked. An outage state occurs if the path-loss between BS and MT is so high that no link between them can be established. In this case, the path-loss of the link is assumed to be infinite. In practice, outages occur implicitly when the path-loss in either a LOS or a NLOS state are sufficiently large. In \cite[Fig. 7]{Rappaport__mmWaveJSAC}, with the aid of experimental results, it is proved that adding an outage state, which usually is not observed for transmission at $\mu$Wave frequencies, provides a more accurate statistical description of the inherent coverage possibilities at mmWave frequencies.
In particular, the probabilities of occurrence $p_{{\rm{LOS}}} \left( \cdot \right)$, $p_{{\rm{NLOS}}} \left( \cdot \right)$, $p_{{\rm{OUT}}} \left( \cdot \right)$ of LOS, NLOS and outage states, respectively, as a function of the distance $r$ can be formulated, based on experimental results, as follows \cite[Eq. 8]{Rappaport__mmWaveJSAC}:
\setcounter{equation}{2}
\begin{equation}
\label{Eq_3}
\begin{array}{l}
p_{{\rm{OUT}}} \left( r \right) = \max \left\{ {0,1 - \gamma _{{\rm{OUT}}} e^{ - \delta _{{\rm{OUT}}} r} } \right\} \\
p_{{\rm{LOS}}} \left( r \right) = \left( {1 - p_{{\rm{OUT}}} \left( r \right)} \right)\gamma _{{\rm{LOS}}} e^{ - \delta _{{\rm{LOS}}} r} \\
p_{{\rm{NLOS}}} \left( r \right) = \left( {1 - p_{{\rm{OUT}}} \left( r \right)} \right)\left( {1 - \gamma _{{\rm{LOS}}} e^{ - \delta _{{\rm{LOS}}} r} } \right)
\end{array}
\end{equation}
\noindent where $\left( {\delta _{{\rm{LOS}}} ,\gamma _{{\rm{LOS}}} } \right)$ and $\left( {\delta _{{\rm{OUT}}} ,\gamma _{{\rm{OUT}}} } \right)$ are parameters that depend on the propagation scenario and on the carrier frequency being considered. Examples are available in \cite[Table I]{Rappaport__mmWaveJSAC}.
Under the assumptions that the BSs are modeled as points of a homogeneous PPP and that the probabilities of the BS-to-MT links being in a LOS, NLOS or outage state are independent, $\Psi$ can be partitioned into three (one for each link state) independent and non-homogeneous PPPs, \textit{i.e.}, $\Psi _{{\rm{LOS}}}$, $\Psi _{{\rm{NLOS}}}$ and $\Psi _{{\rm{OUT}}}$, such that $\Psi = \Psi _{{\rm{LOS}}} \cup \Psi _{{\rm{NLOS}}} \cup \Psi _{{\rm{OUT}}}$. This originates from the thinning property of the PPPs \cite{BaccelliBook2009}. From \eqref{Eq_3}, the densities of the PPPs $\Psi _{{\rm{LOS}}}$, $\Psi _{{\rm{NLOS}}}$ and $\Psi _{{\rm{OUT}}}$ are equal to $\lambda _{{\rm{LOS}}} \left( r \right) = \lambda p_{{\rm{LOS}}} \left( r \right)$, $\lambda _{{\rm{NLOS}}} \left( r \right) = \lambda p_{{\rm{NLOS}}} \left( r \right)$ and $\lambda _{{\rm{OUT}}} \left( r \right) = \lambda p_{{\rm{OUT}}} \left( r \right)$, respectively.
\subsection{Path-Loss Modeling} \label{PathLossModeling}
Based on the channel measurements reported in \cite{Rappaport__mmWaveJSAC}, the path-loss model for LOS and NLOS links is assumed to be:
\setcounter{equation}{3}
\begin{equation}
\label{Eq_4}
l_{{\rm{LOS}}} \left( r \right) = \left( {\kappa _{{\rm{LOS}}} r} \right)^{\beta _{{\rm{LOS}}} }, \; l_{{\rm{NLOS}}} \left( r \right) = \left( {\kappa _{{\rm{NLOS}}} r} \right)^{\beta _{{\rm{NLOS}}} }
\end{equation}
\noindent where $r$ denotes the generic BS-to-MT distance, $\kappa _{{\rm{LOS}}}$ and $\kappa _{{\rm{NLOS}}}$ can be interpreted as the path-loss of LOS and NLOS links at a distance of 1 meter, respectively, $\beta _{{\rm{LOS}}}$ and $\beta _{{\rm{NLOS}}}$ denote the power path-loss exponents of LOS and NLOS links, respectively.
The path-loss model in \eqref{Eq_4} is general enough for modeling several practical propagation conditions. For example, it can be linked to the widespread used $\left( {\alpha ,\beta } \right)$ model \cite{Rappaport__mmWaveAccess}, \cite{Rappaport__mmWaveJSAC}, by setting $\kappa _{{\rm{LOS}}} = 10^{{{\alpha _{{\rm{LOS}}} } \mathord{\left/ {\vphantom {{\alpha _{{\rm{LOS}}} } {\left( {10\beta _{{\rm{LOS}}} } \right)}}} \right. \kern-\nulldelimiterspace} {\left( {10\beta _{{\rm{LOS}}} } \right)}}}$ and $\kappa _{{\rm{NLOS}}} = 10^{{{\alpha _{{\rm{NLOS}}} } \mathord{\left/ {\vphantom {{\alpha _{{\rm{NLOS}}} } {\left( {10\beta _{{\rm{NLOS}}} } \right)}}} \right. \kern-\nulldelimiterspace} {\left( {10\beta _{{\rm{NLOS}}} } \right)}}}$, where $\alpha _{{\rm{LOS}}}$ and $\alpha _{{\rm{NLOS}}}$ are defined in \cite[Table I]{Rappaport__mmWaveJSAC}. As mentioned in Section \ref{LinkStateModeling}, the path-loss of the links that are in an outage state is assumed to be infinite, \textit{i.e.}, $l_{{\rm{OUT}}} \left( r \right) = \infty$.
\begin{figure*}[!t]
\setcounter{equation}{9}
\begin{equation}
\label{Eq_10}
\begin{split}
\Upsilon _0 \left( x;s \right) & = {\mathcal{K}}_1 \left( {1 - e^{ - Q_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } - Q_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} e^{ - Q_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } } \right){\mathcal{\bar H}}\left( {x - Z_s } \right)
+ {\mathcal{K}}_1 \left( {1 - e^{ - R } - R e^{ - R } } \right){\mathcal{H}}\left( {x - Z_s } \right) \\
& + {\mathcal{K}}_2 \left( {e^{ - W } + W e^{ - W } - e^{ - V_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } - V_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} e^{ - V_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } } \right){\mathcal{H}}\left( {x - Z_s } \right) \\
\Upsilon _1 \left( {x;s} \right) & = \pi \lambda \kappa _s^{ - 2} x^{{2 \mathord{\left/
{\vphantom {2 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} {\mathcal{\bar H}}\left( {x - Z_s } \right) + \pi \lambda \left( {\delta _{{\rm{OUT}}}^{ - 1} \ln \left( {\gamma _{{\rm{OUT}}} } \right)} \right)^2 {\mathcal{H}}\left( {x - Z_s } \right) \\
& + 2\pi \lambda \delta _{{\rm{OUT}}}^{ - 2} \gamma _{{\rm{OUT}}} \left( {\gamma _{{\rm{OUT}}}^{ - 1} + \gamma _{{\rm{OUT}}}^{ - 1} \ln \left( {\gamma _{{\rm{OUT}}} } \right) - e^{ - T_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } - T_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} e^{ - T_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } } \right){\mathcal{H}}\left( {x - Z_s } \right) \\
\end{split}
\end{equation}
\normalsize \hrulefill \vspace*{-5pt}
\end{figure*}
\subsection{Fading Modeling} \label{FadingModeling}
In addition to the distance-dependent path-loss model of Section \ref{PathLossModeling}, each link is assumed to be subject to a complex randomly distributed channel gain, which, for a generic BS-to-MT link, is denoted by $h$. According to \cite{Rappaport__mmWaveJSAC}, the power gain $\left| h \right|^2$ is assumed to follow a Log-Normal distribution with mean (in dB) equal to $\mu^{({\rm{dB}})}$ and standard deviation (in dB) equal to $\sigma^{({\rm{dB}})}$. Thus, $\left| h \right|^2$ takes into account large-scale shadowing. In general, $\mu^{({\rm{dB}})}$ and $\sigma^{({\rm{dB}})}$ for LOS and NLOS links are different \cite{Rappaport__mmWaveJSAC}. In what follows, they are denoted by $\mu _s^{\left( {{\rm{dB}}} \right)}$ and $\sigma _s^{\left( {{\rm{dB}}} \right)}$, where $s = \left\{ {{\rm{LOS}},{\rm{NLOS}}} \right\}$ denotes the link state.
As mentioned in Section \ref{LinkStateModeling}, for mathematical tractability, the shadowing correlations between links are ignored. Thus, the fading power gains of LOS and NLOS links are assumed to be independent and identically distributed. As recently remarked and verified with the aid of simulations in \cite{Heath__mmWave}, this assumption usually causes a minor loss of accuracy in the evaluation of the statistics of the Signal-to-Interference-plus-Noise-Ratio (SINR). Due to space limitations and for ease of description, fast-fading is neglected in the present paper, but it may be readily incorporated.
\subsection{Cell Association Criterion} \label{CellAssociation}
The MT is assumed to be served by the BS providing the smallest path-loss to it. Let $L_{{\rm{LOS}}}^{\left( 0 \right)}$, $L_{{\rm{NLOS}}}^{\left( 0 \right)}$ and $L_{{\rm{OUT}}}^{\left( 0 \right)}$ be the smallest path-loss of LOS, NLOS and OUT links, respectively. They can be formulated as:
\setcounter{equation}{4}
\begin{equation}
\label{Eq_5}
\begin{split}
& L_s^{\left( 0 \right)} = \begin{cases}
\mathop {\min }\limits_{n \in \Psi _s } \left\{ {l_s \left( {r^{\left( n \right)} } \right)} \right\}\quad & {\rm{if}}\quad \Psi _s \ne \emptyset \\
+ \infty \quad & {\rm{if}}\quad \Psi _s = \emptyset \\
\end{cases} \\
& L_{{\rm{OUT}}}^{\left( 0 \right)} = \mathop {\min }\limits_{n \in \Psi _{{\rm{OUT}}} } \left\{ {l_{{\rm{OUT}}} \left( {r^{\left( n \right)} } \right)} \right\} = + \infty
\end{split}
\end{equation}
\noindent where $s = \left\{ {{\mathop{\rm LOS}\nolimits} ,{\rm{NLOS}}} \right\}$, $r^{(n)}$ denotes the distance of a generic BS to the MT, and $\emptyset$ denotes an empty set. Hence, the path-loss of the serving BS, ${\rm{BS}}^{\left( 0 \right)}$, can be formulated as $L^{\left( 0 \right)} = \min \left\{ {L_{{\rm{LOS}}}^{\left( 0 \right)} ,L_{{\rm{NLOS}}}^{\left( 0 \right)} ,L_{{\rm{OUT}}}^{\left( 0 \right)} } \right\}$.
\begin{figure*}[!t]
\setcounter{equation}{13}
\begin{equation}
\label{Eq_12}
\begin{split}
\Upsilon _0^{\left( 1 \right)} \left( {x;s} \right) & = {\mathcal{K}}_2 \left( {e^{ - W} + We^{ - W} - e^{ - V_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } - V_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} e^{ - V_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } } \right)\delta \left( {x - Z_s } \right) \\
& - {\mathcal{K}}_1 \left( {1 - e^{ - Q_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } - Q_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} e^{ - Q_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } } \right)\delta \left( {x - Z_s } \right)+ {\mathcal{K}}_1 \left( {1 - e^{ - R} - Re^{ - R} } \right)\delta \left( {x - Z_s } \right) \\
& + {\mathcal{K}}_2 \left( {{{V_s^2 } \mathord{\left/
{\vphantom {{V_s^2 } {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} \right)x^{{2 \mathord{\left/
{\vphantom {2 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }} - 1} e^{ - V_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } {\mathcal{H}}\left( {x - Z_s } \right) + {\mathcal{K}}_1 \left( {{{Q_s^2 } \mathord{\left/
{\vphantom {{Q_s^2 } {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} \right)x^{{2 \mathord{\left/
{\vphantom {2 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }} - 1} e^{ - Q_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } {\mathcal{\bar H}}\left( {x - Z_s } \right) \\
\Upsilon _1^{\left( 1 \right)} \left( {x;s} \right) & = - \pi \lambda \kappa _s^{ - 2} x^{{2 \mathord{\left/
{\vphantom {2 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} \delta \left( {x - Z_s } \right) + \pi \lambda \left( {\delta _{{\rm{OUT}}}^{ - 1} \ln \left( {\gamma _{{\rm{OUT}}} } \right)} \right)^2 \delta \left( {x - Z_s } \right) \\
& + 2\pi \lambda \delta _{{\rm{OUT}}}^{ - 2} \gamma _{{\rm{OUT}}} \left( {\gamma _{{\rm{OUT}}}^{ - 1} + \gamma _{{\rm{OUT}}}^{ - 1} \ln \left( {\gamma _{{\rm{OUT}}} } \right) - e^{ - T_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } - T_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} e^{ - T_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } } \right)\delta \left( {x - Z_s } \right) \\
& + 2\pi \lambda \kappa _s^{ - 2} \beta _s^{ - 1} x^{{2 \mathord{\left/
{\vphantom {2 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }} - 1} {\mathcal{\bar H}}\left( {x - Z_s } \right) + 2\pi \lambda \delta _{{\rm{OUT}}}^{ - 2} \gamma _{{\rm{OUT}}} T_s^2 \beta _s^{ - 1} x^{{2 \mathord{\left/
{\vphantom {2 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }} - 1} e^{ - T_s x^{{1 \mathord{\left/
{\vphantom {1 {\beta _s }}} \right.
\kern-\nulldelimiterspace} {\beta _s }}} } {\mathcal{H}}\left( {x - Z_s } \right) \\
\end{split}
\end{equation}
\normalsize \hrulefill \vspace*{-5pt}
\end{figure*}
\section{Mathematical Modeling of Coverage Probability and Average Rate} \label{CoverageRate}
Based on the system model of Section \ref{SystemModel}, the SINR of the cellular network under analysis can be formulated as follows:
\setcounter{equation}{5}
\begin{equation}
\label{Eq_6}
\begin{split}
{\rm{SINR}} & = \frac{{{{PG^{\left( 0 \right)} \left| {h^{\left( 0 \right)} } \right|^2 } \mathord{\left/
{\vphantom {{PG^{\left( 0 \right)} \left| {h^{\left( 0 \right)} } \right|^2 } {L^{\left( 0 \right)} }}} \right.
\kern-\nulldelimiterspace} {L^{\left( 0 \right)} }}}}{{\sigma _N^2 + I_{{\rm{agg}}} }} \\ & \mathop = \limits^{\left( a \right)} \frac{{{{PG^{\left( 0 \right)} \left| {h_{{\rm{LOS}}}^{\left( {\rm{0}} \right)} } \right|^2 } \mathord{\left/
{\vphantom {{PG^{\left( 0 \right)} \left| {h_{{\rm{LOS}}}^{\left( {\rm{0}} \right)} } \right|^2 } {L^{\left( 0 \right)} }}} \right.
\kern-\nulldelimiterspace} {L^{\left( 0 \right)} }}}}{{\sigma _N^2 + I_{{\rm{agg}}} }}\delta \left\{ {L^{\left( 0 \right)} - L_{{\rm{LOS}}}^{\left( 0 \right)} } \right\} \\
& + \frac{{{{PG^{\left( 0 \right)} \left| {h_{{\rm{NLOS}}}^{\left( {\rm{0}} \right)} } \right|^2 } \mathord{\left/
{\vphantom {{PG^{\left( 0 \right)} \left| {h_{{\rm{NLOS}}}^{\left( {\rm{0}} \right)} } \right|^2 } {L^{\left( 0 \right)} }}} \right.
\kern-\nulldelimiterspace} {L^{\left( 0 \right)} }}}}{{\sigma _N^2 + I_{{\rm{agg}}} }}\delta \left\{ {L^{\left( 0 \right)} - L_{{\rm{NLOS}}}^{\left( 0 \right)} } \right\}
\end{split}
\end{equation}
\noindent where $P$ is the transmit power, $\left| {h^{\left( 0 \right)} } \right|^2$ is the power gain of the serving BS, ${\rm{BS}}^{\left( 0 \right)}$, $\sigma _N^2$ is the noise power and $I_{{\rm{agg}}}$ is the aggregate other-cell interference, \textit{i.e.}, the total interference generated by the BSs in $\Psi ^{\left(\backslash 0 \right)}$. In particular, $\sigma _N^2$ is defined as $\sigma _N^2 = 10^{{{\sigma _N^2 \left( {{\rm{dBm}}} \right)} \mathord{\left/ {\vphantom {{\sigma _N^2 \left( {{\rm{dBm}}} \right)} {10}}} \right. \kern-\nulldelimiterspace} {10}}}$, where $\sigma _N^2 \left( {{\rm{dBm}}} \right) = - 174 + 10\log _{10} \left( {{\rm{BW}}} \right) + \mathcal{F}_{{\rm{dB}}}$, ${{\rm{BW}}}$ is the transmission bandwidth and $\mathcal{F}_{{\rm{dB}}}$ is the noise figure in dB. By using a notation similar to the desired link, the aggregate other-cell interference is defined as $I_{{\rm{agg}}} = \sum\nolimits_{i \in \Psi ^{\left( {\backslash 0} \right)} } {\left( {{{P G^{\left( i \right)} \left| {h^{\left( i \right)} } \right|^2 } \mathord{\left/ {\vphantom {{P G^{\left( i \right)} \left| {h^{\left( i \right)} } \right|^2 } {L^{\left( i \right)} }}} \right. \kern-\nulldelimiterspace} {L^{\left( i \right)} }}} \right)}$. The equality in (a) takes into account that the distribution of LOS and NLOS links is assumed to be different in the present paper.
From \eqref{Eq_6}, coverage probability (${\rm{P}}_{{\mathop{\rm cov}} }$) and average rate ($\rm{R}$) can be formulated as follows \cite{MDR_COMMLPeng}:
\setcounter{equation}{6}
\begin{equation}
\label{Eq_7}
{\rm{P}}^{({\mathop{\rm cov}} )} \left( {\rm{T}} \right) = \Pr \left\{ {{\rm{SINR}} \ge {\rm{T}}} \right\}
\end{equation}
\setcounter{equation}{7}
\begin{equation}
\label{Eq_8}
\begin{split}
{\rm{R}} &= {\mathbb{E}}_{{\rm{SINR}}} \left\{ {{\rm{BW}}\log _2 \left( {1 + {\rm{SINR}}} \right)} \right\} \\ & = \frac{{{\rm{BW}}}}{{\ln \left( 2 \right)}}\int\nolimits_0^{ + \infty } {\frac{{{\rm{P}}_{{\mathop{\rm cov}} } \left( t \right)}}{{t + 1}}dt}
\end{split}
\end{equation}
\noindent where ${\rm{T}}$ is a reliability threshold and ${\mathbb{E}}\left\{ \cdot \right\}$ denotes the expectation operator.
In what follows, a new mathematical expression for the coverage probability, ${\rm{P}}^{({\mathop{\rm cov}})}(\cdot)$, is provided. The average rate, $\rm{R}$, can be obtained directly from \eqref{Eq_8}. The analytical formulation is based on the noise-limited approximation of mmWave cellular communications, \textit{i.e.}, ${\rm{SINR}} \approx {\rm{SNR}} = P G^{\left( 0 \right)} \left| {h^{\left( 0 \right)} } \right|^2 \left( {\sigma _N^2 L^{\left( 0 \right)} } \right)^{-1}$, which has been observed in recent studies, both with the aid of numerical simulations and field measurements \cite{Rappaport__mmWaveJSAC}, \cite{Singh__mmWave}. In Section \ref{Results}, the validity and the accuracy of the noise-limited approximation are substantiated with the aid of Monte Carlo simulations, which account for the other-cell interference as well.
Before presenting the main result summarized in \textit{Proposition \ref{Pcov_Prop}}, we introduce two lemmas that are useful for its proof.
\begin{lemma} \label{Intensity_Lemma}
Let $L = \left\{ {L _{{\rm{LOS}}} ,L _{{\rm{NLOS}}} ,L _{{\rm{OUT}}} } \right\}$, where $L_{\bar s} = \left\{ {l_{\bar s} \left( {r^{\left( n \right)} } \right),n \in \Psi _{\bar s} } \right\}$ for $\bar s \in \left\{ {{\rm{LOS}},{\rm{NLOS}},{\rm{OUT}}} \right\}$ are transformations of the path-loss of LOS, NLOS and OUT BSs, respectively. Let the link state and the path-loss models in \eqref{Eq_3} and \eqref{Eq_4}, respectively. $L$ is a PPP with intensity as follows:
\setcounter{equation}{8}
\begin{equation}
\label{Eq_9}
\Lambda \left( {\left[ {0,x} \right)} \right) = \Lambda _{{\rm{LOS}}} \left( {\left[ {0,x} \right)} \right) + \Lambda _{{\rm{NLOS}}} \left( {\left[ {0,x} \right)} \right)
\end{equation}
\noindent where $\Lambda _{{\rm{LOS}}} \left( {\left[ {0,x} \right)} \right) = \Upsilon _0 \left( {x;s = {\rm{LOS}}} \right)$, $\Lambda _{{\rm{NLOS}}} \left( {\left[ {0,x} \right)} \right) = \Upsilon _1 \left( {x;s = {\rm{NLOS}}} \right) - \Upsilon _0 \left( {x;s = {\rm{NLOS}}} \right)$, $\Upsilon _0 \left( \cdot;\cdot \right)$ and $\Upsilon _1 \left( \cdot;\cdot \right)$ are defined in \eqref{Eq_10}, ${\mathcal{H}}\left( \cdot \right)$ is the Heaviside function, ${\mathcal{\bar H}}\left( x \right) = 1 - {\mathcal{H}}\left( x \right)$, ${\mathcal{K}}_1 = 2\pi \lambda \gamma _{{\rm{LOS}}} \delta _{{\rm{LOS}}}^{ - 2}$, ${\mathcal{K}}_2 = 2\pi \lambda \gamma _{{\rm{LOS}}} \gamma _{{\rm{OUT}}} \left( {\delta _{{\rm{LOS}}} + \delta _{{\rm{OUT}}} } \right)^{ - 2}$, $R = \delta _{{\rm{LOS}}} \delta _{{\rm{OUT}}}^{ - 1} \ln \left( {\gamma _{{\rm{OUT}}} } \right)$, $W = \left( {\delta _{{\rm{LOS}}} + \delta _{{\rm{OUT}}} } \right)\delta _{{\rm{OUT}}}^{ - 1} \ln \left( {\gamma _{{\rm{OUT}}} } \right)$, $Q_s = \delta _{{\rm{LOS}}} \kappa _s^{ - 1}$, $T_s = \delta _{{\rm{OUT}}} \kappa _s^{ - 1}$, $V_s = \left( {\delta _{{\rm{LOS}}} + \delta _{{\rm{OUT}}} } \right)\kappa _s^{ - 1}$, $Z_s = \left( {\kappa _s \delta _{{\rm{OUT}}}^{ - 1} \ln \left( {\gamma _{{\rm{OUT}}} } \right)} \right)^{\beta _s }$ for $s = \left\{ {{\rm{LOS}},{\rm{NLOS}}} \right\}$.
\emph{Proof}: See the Appendix. \hfill $\Box$
\end{lemma}
\begin{corollary} \label{CDF_Corollary}
Let $\delta _{{\rm{OUT}}} = 0$, $\gamma _{{\rm{OUT}}} = 1$, \textit{i.e.}, $p_{{\rm{OUT}}} \left( r \right) = 0$ in \eqref{Eq_3}. $\Lambda \left( \cdot \right)$ in \eqref{Eq_9} holds with $\Upsilon _0 \left( x;s \right) = {\mathcal{K}}_1 \left( {1 - e^{ - Q_s x^{{1 \mathord{\left/ {\vphantom {1 {\beta _s }}} \right. \kern-\nulldelimiterspace} {\beta _s }}} } - Q_s x^{{1 \mathord{\left/ {\vphantom {1 {\beta _s }}} \right. \kern-\nulldelimiterspace} {\beta _s }}} e^{ - Q_s x^{{1 \mathord{\left/ {\vphantom {1 {\beta _s }}} \right. \kern-\nulldelimiterspace} {\beta _s }}} } } \right)$, $\Upsilon _1 \left( {x;s} \right) = \pi \lambda \kappa _s^{ - 2} x^{{2 \mathord{\left/ {\vphantom {2 {\beta _s }}} \right. \kern-\nulldelimiterspace} {\beta _s }}}$, $s = \left\{ {{\rm{LOS}},{\rm{NLOS}}} \right\}$.
\emph{Proof}: It follows directly from \eqref{Eq_10}, since $Z_s \to +\infty$ for $s = \left\{ {{\rm{LOS}},{\rm{NLOS}}} \right\}$. \hfill $\Box$
\end{corollary}
\begin{lemma} \label{CDF_Lemma}
Let $L ^{\left( 0 \right)} = \min \left\{ {L_{{\rm{LOS}}}^{\left( 0 \right)} ,L_{{\rm{NLOS}}}^{\left( 0 \right)} ,L_{{\rm{OUT}}}^{\left( 0 \right)} } \right\} = \min \left\{ L \right\}$ be the smallest element of the PPP $L$ introduced in \textit{Lemma \ref{Intensity_Lemma}}. Its Cumulative Distribution Function (CDF), \textit{i.e.}, $F_{L^{\left( 0 \right)} } \left( x \right) = \Pr \left\{ {L^{\left( 0 \right)} \le x} \right\}$, can be formulated as follows:
\setcounter{equation}{10}
\begin{equation}
\label{Eq_11}
F_{L^{\left( 0 \right)} } \left( x \right) = 1 - \exp \left( { - \Lambda \left( {\left[ {0,x} \right)} \right)} \right)
\end{equation}
\noindent where $\Lambda \left( \cdot \right)$ is defined in \eqref{Eq_9}.
\emph{Proof}: It follows by applying the void probability theorem of PPPs \cite[Corollary 6]{Blaszczyszyn_Infocom2013}. \hfill $\Box$
\end{lemma}
\subsection{Coverage Probability}
\begin{proposition} \label{Pcov_Prop}
Let the SINR in \eqref{Eq_6} and the coverage probability in \eqref{Eq_7}. If $\sigma _N^2 \gg I_{{\rm{agg}}}$, \textit{i.e.}, ${\rm{SINR}} \approx {\rm{SNR}} = P G^{\left( 0 \right)} \left| {h^{\left( 0 \right)} } \right|^2 \left( {\sigma _N^2 L^{\left( 0 \right)} } \right)^{-1}$, then the following holds:
\setcounter{equation}{11}
\begin{equation}
\label{Eq_13}
{\rm{P}}^{\left( {{\mathop{\rm cov}} } \right)} \left( {\rm{T}} \right) = {\rm{P}}_{{\rm{LOS}}}^{\left( {{\mathop{\rm cov}} } \right)} \left( {\rm{T}} \right) + {\rm{P}}_{{\rm{NLOS}}}^{\left( {{\mathop{\rm cov}} } \right)} \left( {\rm{T}} \right)
\end{equation}
\setcounter{equation}{12}
\begin{equation}
\label{Eq_14}
\hspace{-0.15cm} {\rm{P}}_s^{\left( {{\mathop{\rm cov}} } \right)} \left( {\rm{T}} \right) = \frac{1}{2} \int\nolimits_0^{ + \infty } {{\rm{erfc}}\left( {\frac{{{\rm{ln}}\left( {{{{\rm{T}}x} \mathord{\left/
{\vphantom {{{\rm{T}}x} {\gamma ^{\left( 0 \right)} }}} \right.
\kern-\nulldelimiterspace} {\gamma ^{\left( 0 \right)} }}} \right) - \mu _s }}{{\sqrt 2 \sigma _s }}} \right) \bar \Lambda_s \left( {\left[ {0,x} \right)} \right) dx}
\end{equation}
\noindent where $s = \left\{ {{\rm{LOS}},{\rm{NLOS}}} \right\}$, ${\rm{erfc}}\left( \cdot \right)$ is the complementary error function, $\bar \Lambda_s \left( {\left[ {0,x} \right)} \right) = \Lambda _{s }^{\left( 1 \right)} \left( {\left[ {0,x} \right)} \right)\exp \left( { - \Lambda \left( {\left[ {0,x} \right)} \right)} \right)$, $\Lambda \left( \cdot \right)$ is defined in \eqref{Eq_9}, $\Lambda _{{{\rm{LOS}}} }^{\left( 1 \right)} \left( {\left[ {0,x} \right)} \right) = \Upsilon _0^{\left( 1 \right)} \left( {x;{\rm{LOS}}} \right)$, where $\Upsilon _0^{\left( 1 \right)} \left( { \cdot ; \cdot } \right)$ is the first derivative of $\Upsilon _0 \left( { \cdot ; \cdot } \right)$ in \eqref{Eq_10}, $\Lambda _{{{\rm{NLOS}}} }^{\left( 1 \right)} \left( {\left[ {0,x} \right)} \right) = \Upsilon _1^{\left( 1 \right)} \left( {x;{\rm{NLOS}}} \right) - \Upsilon _0^{\left( 1 \right)} \left( {x;{\rm{NLOS}}} \right)$, where $\Upsilon _1^{\left( 1 \right)} \left( { \cdot ; \cdot } \right)$ is the first derivative of $\Upsilon _1 \left( { \cdot ; \cdot } \right)$ in \eqref{Eq_10}, $\gamma ^{\left( 0 \right)} = {{{{P}}G^{\left( 0 \right)} } \mathord{\left/ {\vphantom {{{\mathsf{P}}G^{\left( 0 \right)} } {\sigma _N^2 }}} \right. \kern-\nulldelimiterspace} {\sigma _N^2 }}$, $\mu _s = \mu _s^{\left( {{\rm{dB}}} \right)} {{\ln \left( {10} \right)} \mathord{\left/ {\vphantom {{\ln \left( {10} \right)} {10}}} \right. \kern-\nulldelimiterspace} {10}}$ and $\sigma _s = \sigma _s^{\left( {{\rm{dB}}} \right)} {{\ln \left( {10} \right)} \mathord{\left/ {\vphantom {{\ln \left( {10} \right)} {10}}} \right. \kern-\nulldelimiterspace} {10}}$. $\Upsilon _0^{\left( 1 \right)} \left( { \cdot ; \cdot } \right)$ and $\Upsilon _1^{\left( 1 \right)} \left( { \cdot ; \cdot } \right)$ are available in \eqref{Eq_12}.
\emph{Proof}: See the Appendix. \hfill $\Box$
\end{proposition}
\section{Numerical and Simulation Results} \label{Results}
In this section, we illustrate some numerical examples for validating the accuracy of the proposed mathematical frameworks and for comparing mmWave and $\mu$Wave cellular networks. The results are compared against Monte Carlo simulations, where some modeling assumptions considered for developing the mathematical frameworks are not enforced in the system simulator. Notably, coverage probability and average rate in Section \ref{CoverageRate} are computed under the assumption of noise-limited cellular networks. This assumption is \textit{not} retained in the system simulator, in order to show to which extent the noise-limited assumption holds for mmWave cellular communications. Monte Carlo simulation results are obtained by using the system simulator described in \cite{MDR_TCOMrate}-\cite{MDR_COMMLPeng}, to which the reader is referred for further information.
Unless otherwise stated, the following setup is considered for obtaining the numerical examples, which agrees with previous studies in this field \cite{Rappaport__mmWaveJSAC}, \cite{Heath__mmWave}, \cite{Singh__mmWave}. In particular, the channel and blockage models are taken from \cite{Rappaport__mmWaveJSAC}. In addition:
\begin{itemize}
\item Two mmWave cellular networks are studied, which operate at a carrier frequency, $F_c$, equal to $F_c=28$ GHz and $F_c=73$ GHz. The transmission bandwidth is ${\rm{BW}} = 2$ GHz. The noise figure is ${\mathcal{N}}_{\rm{dB}} = 10$. The transmit power is $P=30$ dBm.
\item The path-loss model is as follows \cite[Table I]{Rappaport__mmWaveJSAC}: $\alpha _{{\rm{LOS}}} = 61.4$ dB, $\beta _{{\rm{LOS}}} = 2$ and $\alpha _{{\rm{NLOS}}} = 72$ dB, $\beta _{{\rm{NLOS}}} = 2.92$ if $F_c=28$ GHz and $\alpha _{{\rm{LOS}}} = 69.8$ dB, $\beta _{{\rm{LOS}}} = 2$ and $\alpha _{{\rm{NLOS}}} = 82.7$ dB, $\beta _{{\rm{NLOS}}} = 2.69$ if $F_c=73$ GHz.
\item The shadowing model is as follows \cite[Table I]{Rappaport__mmWaveJSAC}: $\sigma _{{\rm{LOS}}}^{(\rm{dB})} = 5.8$, $\sigma _{{\rm{NLOS}}}^{(\rm{dB})} = 8.7$ if $F_c=28$ GHz and $\sigma _{{\rm{LOS}}}^{(\rm{dB})} = 5.8$, $\sigma _{{\rm{NLOS}}}^{(\rm{dB})} = 8.7$ if $F_c=73$ GHz. On the other hand, $\mu^{(\rm{dB})}$ is assumed to be equal to zero for both LOS and NLOS scenarios.
\item The blockage model is as follows \cite[Table I]{Rappaport__mmWaveJSAC}: $\delta _{{\rm{LOS}}} = {1 \mathord{\left/ {\vphantom {1 {67.1}}} \right. \kern-\nulldelimiterspace} {67.1}}$, $\gamma _{{\rm{LOS}}} = 1$ and $\delta _{{\rm{OUT}}} = 5.2$, $\gamma _{{\rm{OUT}}} = \exp \left( {{1 \mathord{\left/ {\vphantom {1 {30}}} \right. \kern-\nulldelimiterspace} {30}}} \right)$, for both $F_c=28$ GHz and $F_c=73$ GHz scenarios.
\item The directional beamforming model is as follows \cite{Heath__mmWave}: $G_{{\rm{BS}}}^{\left( {\max } \right)} = G_{{\rm{MT}}}^{\left( {\max } \right)} = 20$ dB, $G_{{\rm{BS}}}^{\left( {\min } \right)} = G_{{\rm{MT}}}^{\left( {\min } \right)} = -10$ dB and $\omega _{{\rm{BS}}} = \omega _{{\rm{MT}}} = 30$ degrees.
\item Similar to \cite{Heath__mmWave}, the density of BSs, $\lambda$, is represented as a function of the average cell radius, \textit{i.e.}, $R_c = \sqrt {{1 \mathord{\left/{\vphantom {1 {\left( {\pi \lambda } \right)}}} \right. \kern-\nulldelimiterspace} {\left( {\pi \lambda } \right)}}}$.
\item As for the $\mu$Wave cellular network, a setup similar to \cite{Rappaport__mmWaveJSAC} is considered. In particular, we set $F_c = 2.5$ GHz, ${\rm{BW}} = 40$ MHz, $G_{{\rm{MT}}}^{\left( {\max } \right)} = G_{{\rm{MT}}}^{\left( {\min } \right)} = 0$ dB and $\omega _{{\rm{MT}}} = 360$ degrees. The channel model is chosen as in \cite[Eq. (11)]{Rappaport__mmWaveJSAC}, \textit{i.e.}, $l\left( r \right)^{\left( {{\rm{dB}}} \right)} = 22.7 + 36.7\log _{10} \left( r \right) + 26\log _{10} \left( {2.5} \right)$. All the channels are assumed to be in a NLOS state, with a shadowing standard deviation equal to $\sigma _{{\rm{NLOS}}} = 4$. No outage state is assumed, \textit{i.e.}, $p_{{\rm{OUT}}} \left( r \right) = 0$. The rest of the paraments is the same as for the mmWave cellular network setup.
\end{itemize}
\begin{figure}[!t]
\centering
\includegraphics [width=\columnwidth] {Fig_1.eps}
\vspace{-0.75cm} \caption{Coverage probability of a mmWave cellular network operating at $F_c=28$ GHz. (a) $p_{{\rm{OUT}}}(\cdot)$ in \eqref{Eq_3} is used. (b) $p_{{\rm{OUT}}}(r) = 0$. Solid lines show the mathematical framework and markers show Monte Carlo simulations.}
\label{Fig_1}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics [width=\columnwidth] {Fig_2.eps}
\vspace{-0.75cm} \caption{Coverage probability of a mmWave cellular network operating at $F_c=73$ GHz. (a) $p_{{\rm{OUT}}}(\cdot)$ in \eqref{Eq_3} is used. (b) $p_{{\rm{OUT}}}(r) = 0$. Solid lines show the mathematical framework and markers show Monte Carlo simulations.} \label{Fig_2}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics [width=\columnwidth] {Fig_3.eps}
\vspace{-0.75cm} \caption{Coverage probability of mmWave and $\mu$Wave cellular networks operating at $F_c=28$ GHz (mmWave), $F_c=73$ GHz (mmWave) and $F_c=2.5$ GHz ($\mu$Wave). For mmWave networks, $p_{{\rm{OUT}}}(\cdot)$ in \eqref{Eq_3} is used. For the $\mu$Wave cellular network, $p_{{\rm{OUT}}}(r) = 0$. (a) $R_c = 50$ m. (b) $R_c = 100$ m. (c) $R_c = 150$ m. (d) $R_c = 200$ m.} \label{Fig_3}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics [width=\columnwidth] {Fig_4.eps}
\vspace{-0.75cm} \caption{Average rate of a mmWave cellular network operating at $F_c=28$ GHz and $F_c=73$ GHz. (a) The normalized rate ${\rm{R}}/{\rm{BW}}$ is shown. Solid lines show the mathematical framework and markers show Monte Carlo simulations. (b) Ratio of the average rates of two mmWave networks operating at $F_c=28$ GHz and $F_c=73$ GHz and of a $\mu$Wave network operating at $F_c=2.5$ GHz.} \label{Fig_4}
\end{figure}
Some selected numerical results are illustrated in Figs. \ref{Fig_1}-\ref{Fig_4}. From Figs. \ref{Fig_1} and \ref{Fig_2}, we observe that the proposed noise-limited approximation is quite accurate for practical densities of BSs. If $R_c \ge 100$ meters for the considered setup, in particular, we observe that mmWave cellular networks can be assumed to be noise-limited. If the density of BSs increases, on the other hand, this approximation may no longer hold. The performance gap compared to Monte Carlo simulations is, however, tolerable and this shows that, in any case, mmWave cellular networks are likely not to be interference-limited. This finding is in agreement with recent published papers that considered a simplified blockage model \cite{Singh__mmWave}. The figures also show that, in general, the presence of an outage state reduces the coverage probability. This is noticeable, however, only for small values of the reliability threshold $\rm{T}$.
In Fig. \ref{Fig_3}, mmWave and $\mu$Wave cellular networks are compared. This figure shows that mmWave communications have the potential of outperforming $\mu$Wave communications, provided that the network density is sufficiently high. Otherwise, $\mu$Wave communications are still to be preferred, especially for small values of the reliability threshold $\rm{T}$. As expected, mmWave transmission at $F_c=28$ GHz slightly outperforms its counterpart at $F_c=73$ GHz due to a smaller path-loss.
Finally, Fig. \ref{Fig_4} shows the average rate of mmWave and $\mu$Wave cellular networks. It confirms that the proposed framework is accurate enough for practical network densities. Also, it highlights that mmWave communications are capable of significantly enhancing the average rate. This is mainly due to the larger transmission bandwidth, which is 50 times larger, in the considered setup, for mmWave communications. The figure shows, however, that the gain can be larger than the ratio of the bandwidths, especially for medium/dense cellular network deployments.
\begin{figure*}[!t]
\setcounter{equation}{15}
\begin{equation}
\label{Eq_App2}
\begin{split}
{\rm{P}}^{\left( {{\mathop{\rm cov}} } \right)} \left( {\rm{T}} \right) & = {\mathbb{E}}_{L_{{\rm{LOS}}}^{\left( 0 \right)} } \left\{ {\Pr \left\{ {\left. {\frac{{{{P}}G^{\left( 0 \right)} \left| {h_{{\rm{LOS}}}^{\left( 0 \right)} } \right|^2 }}{{\sigma _N^2 L_{{\rm{LOS}}}^{\left( 0 \right)} }} > {\rm{T}}} \right|L_{{\rm{LOS}}}^{\left( 0 \right)} } \right\}\Pr \left\{ {\left. {L_{{\rm{NLOS}}}^{\left( 0 \right)} > L_{{\rm{LOS}}}^{\left( 0 \right)} } \right|L_{{\rm{LOS}}}^{\left( 0 \right)} } \right\}} \right\} \\
& + {\mathbb{E}}_{L_{{\rm{NLOS}}}^{\left( 0 \right)} } \left\{ {\Pr \left\{ {\left. {\frac{{{{P}}G^{\left( 0 \right)} \left| {h_{{\rm{NLOS}}}^{\left( 0 \right)} } \right|^2 }}{{\sigma _N^2 L_{{\rm{NLOS}}}^{\left( 0 \right)} }} > {\rm{T}}} \right|L_{{\rm{NLOS}}}^{\left( 0 \right)} } \right\}\Pr \left\{ {\left. {L_{{\rm{LOS}}}^{\left( 0 \right)} > L_{{\rm{NLOS}}}^{\left( 0 \right)} } \right|L_{{\rm{NLOS}}}^{\left( 0 \right)} } \right\}} \right\} \\
\end{split}
\end{equation}
\normalsize \hrulefill \vspace*{-5pt}
\end{figure*}
\section{Conclusion} \label{Conclusion}
In the present paper, a new analytical framework for computing coverage probability and average rate of mmWave cellular networks has been proposed. Its novelty lies in taking into account realistic channel and blockage models for mmWave propagation, which are based on empirical data recently reported in the literature. The proposed methodology relies upon the noise-limited assumption for mmWave communications, which is shown to be sufficiently accurate for typical densities of BSs. The numerical examples have shown that sufficiently dense mmWave cellular networks have the inherent capability of outperforming $\mu$Wave cellular networks.
Current research activities are concerned with the extension of the proposed mathematical framework to ultra-dense mmWave cellular networks, where interference can no longer be neglected, as well as to compare different blockage models and cell association criteria. An extended version of the present paper is available in \cite{MDR_TWCmmWave}.
\section*{Appendix -- Proofs} \label{Appendix}
\subsection{Proof of Lemma \ref{Intensity_Lemma}}
The proof follows by using a methodology similar to \cite[Sec. II-A]{Blaszczyszyn_Infocom2013}. In particular, by invoking the displacement theorem of PPPs \cite[Th. 1.10]{BaccelliBook2009}, the process of the propagation losses $L = \left\{ {l\left( {r^{(n)} } \right)}, n \in \Psi \right\}$ can be interpreted as a transformation of $\Psi$, which is still a PPP on $\mathbb{R}^+$. From Section \ref{LinkStateModeling}, we know that $\Psi = \Psi _{{\rm{LOS}}} \cup \Psi _{{\rm{NLOS}}} \cup \Psi _{{\rm{OUT}}}$. Since $\Psi _{{\rm{LOS}}}$, $\Psi _{{\rm{NLOS}}}$ and $\Psi _{{\rm{OUT}}}$ are independent, the density (or intensity), ${\Lambda \left( \cdot \right)}$, of $L$ is equal to the summation of the intensities of $\Psi _{{\rm{LOS}}}$, $\Psi _{{\rm{NLOS}}}$ and $\Psi _{{\rm{OUT}}}$, \textit{i.e.}, $\Lambda \left( {\left[ {0,x} \right)} \right) = \Lambda _{{\rm{LOS}}} \left( {\left[ {0,x} \right)} \right) + \Lambda _{{\rm{NLOS}}} \left( {\left[ {0,x} \right)} \right) + \Lambda _{{\rm{OUT}}} \left( {\left[ {0,x} \right)} \right)$. Since the path-loss of the links in outage is infinite, by definition $\Lambda _{{\rm{OUT}}} \left( {\left[ {0,x} \right)} \right) = 0$. On the other hand, $\Lambda _s \left( \cdot \right)$ for $s = \left\{ {{\rm{LOS}},{\rm{NLOS}}} \right\}$ can be computed by using mathematical steps similar to the proof of \cite[Lemma 1]{Blaszczyszyn_Infocom2013}. More specifically, we have:
\setcounter{equation}{14}
\begin{equation}
\label{Eq_App1}
\Lambda _s \left( {\left[ {0,x} \right)} \right) = 2\pi \lambda \int\nolimits_0^{ + \infty } {{\mathcal{H}}\left( {x - \left( {\kappa _s r} \right)^{\beta _s } } \right)p_s \left( r \right)rdr}
\end{equation}
Equation \eqref{Eq_9} follows by inserting $p_s \left( \cdot \right)$ of \eqref{Eq_3} in \eqref{Eq_App1} and by computing the integrals with the aid of the notable result $\int\nolimits_a^b {e^{ - cr} rdr} = \left( {{1 \mathord{\left/ {\vphantom {1 {c^2 }}} \right.\kern-\nulldelimiterspace} {c^2 }}} \right)\left( {e^{ - ca} + ae^{ - ca} - e^{ - cb} - be^{ - cb} } \right)$.
\subsection{Proof of Proposition \ref{Pcov_Prop}}
From \eqref{Eq_6} and \eqref{Eq_7}, the coverage probability can be formulated, by definition, as shown in \eqref{Eq_App2}. Let us denote the first and second addends in \eqref{Eq_App2} by ${\rm{P}}_s^{\left( {{\mathop{\rm cov}} } \right)} \left( \cdot \right)$, where $s = {\rm{LOS}}$ and $s = {\rm{NLOS}}$, respectively. Each addend can be computed by using the following results:
\setcounter{equation}{16}
\begin{equation}
\label{Eq_App3}
\hspace{-0.1cm}\begin{split}
& \Pr \left\{ {\left. {\left| {h_{{s}}^{\left( 0 \right)} } \right|^2 > {{L_{{s}}^{\left( 0 \right)} {\rm{T}}} \mathord{\left/
{\vphantom {{L_{{s}}^{\left( 0 \right)} {\rm{T}}} {\gamma ^{\left( 0 \right)} }}} \right.
\kern-\nulldelimiterspace} {\gamma ^{\left( 0 \right)} }}} \right|L_{{s}}^{\left( 0 \right)} } \right\} \\ &\mathop = \limits^{\left( a \right)} {1 \mathord{\left/
{\vphantom {1 2}} \right.
\kern-\nulldelimiterspace} 2} - ({1 \mathord{\left/
{\vphantom {1 2}} \right.
\kern-\nulldelimiterspace} 2}){\rm{erf}}\left( {{{\left( {\ln \left( {{{L_{{s}}^{\left( 0 \right)} {\rm{T}}} \mathord{\left/
{\vphantom {{L_{\rm{s}}^{\left( 0 \right)} {\rm{T}}} {\gamma ^{\left( 0 \right)} }}} \right.
\kern-\nulldelimiterspace} {\gamma ^{\left( 0 \right)} }}} \right) - \mu _s } \right)} \mathord{\left/
{\vphantom {{\left( {\ln \left( {{{L_{\rm{s}}^{\left( 0 \right)} {\rm{T}}} \mathord{\left/
{\vphantom {{L_{\rm{s}}^{\left( 0 \right)} {\rm{T}}} {\gamma ^{\left( 0 \right)} }}} \right.
\kern-\nulldelimiterspace} {\gamma ^{\left( 0 \right)} }}} \right) - \mu _s } \right)} {\left( {\sqrt 2 \sigma _s } \right)}}} \right.
\kern-\nulldelimiterspace} {\left( {\sqrt 2 \sigma _s } \right)}}} \right) \\
& \Pr \left\{ {\left. {L_{{\rm{NLOS}}}^{\left( 0 \right)} > L_{{\rm{LOS}}}^{\left( 0 \right)} } \right|L_{{\rm{LOS}}}^{\left( 0 \right)} } \right\}\mathop = \limits^{\left( b \right)} \exp \left( { - \Lambda _{{\rm{NLOS}}} \left( {\left[ {0,L_{{\rm{LOS}}}^{\left( 0 \right)} } \right)} \right)} \right) \\
& \Pr \left\{ {\left. {L_{{\rm{LOS}}}^{\left( 0 \right)} > L_{{\rm{NLOS}}}^{\left( 0 \right)} } \right|L_{{\rm{NLOS}}}^{\left( 0 \right)} } \right\}\mathop = \limits^{\left( c \right)} \exp \left( { - \Lambda _{{\rm{LOS}}} \left( {\left[ {0,L_{{\rm{NLOS}}}^{\left( 0 \right)} } \right)} \right)} \right) \\
\end{split}
\end{equation}
\noindent where ${\rm{erf}}\left( \cdot \right)$ is the error function, (a) follows from the CDF of a Log-Normal random variable, and (b) and (c) follow from \textit{Lemma \ref{Intensity_Lemma}} and \textit{Lemma \ref{CDF_Lemma}} by using arguments similar to the computation of the intensity of $L$ and of the CDF of $L^{\left( 0 \right)}$.
The proof follows by explicitly writing the expectation with respect to $L_{{\rm{LOS}}}^{\left( 0 \right)}$ and $L_{{\rm{NLOS}}}^{\left( 0 \right)}$ in terms of their PDFs, which can be formulated, similar to (b) and (c), as $f_{L_s^{\left( 0 \right)} } \left( \xi \right) = {{d\Pr \left\{ {L_s^{\left( 0 \right)} < \xi } \right\}} \mathord{\left/ {\vphantom {{d\Pr \left\{ {L_s^{\left( 0 \right)} < \xi } \right\}} {d\xi }}} \right. \kern-\nulldelimiterspace} {d\xi }} = \Lambda _s^{\left( 1 \right)} \left( {\left[ {0,\xi } \right)} \right)\exp \left( { - \Lambda _s \left( {\left[ {0,\xi } \right)} \right)} \right)$, since $\Pr \left\{ {L_s^{\left( 0 \right)} < \xi } \right\} = \exp \left( { - \Lambda _s \left( {\left[ {0,\xi } \right)} \right)} \right)$.
\section*{Acknowledgment}
This work is supported by the European Commission under the FP7-PEOPLE MITN-CROSSFIRE project (grant 317126).
|
{'timestamp': '2015-06-18T02:09:52', 'yymm': '1506', 'arxiv_id': '1506.05222', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05222'}
|
arxiv
|
\section{Introduction}
In Distributed Storage Systems (DSSs), data file is encoded into certain packets and those packets are distributed among $n$ nodes. A data collector has to collect packets from any $k$ (called reconstruction degree) nodes among the $n$ nodes to reconstruct the whole file. In the case of node failure, system is allowed to reconstruct a new node to replace the failed node. The repair is of two types viz. exact and functional. In the repair process, the new node is constructed by downloading $\beta$ packets from each node (helper node) of a set of $d$ (repair degree) nodes. Thus total bandwidth for a repairing a node is $d\beta$. For an $(n, k, d)$DSS, such regenerating codes are specified by the parameters $\{[n, k, d], [\alpha,\beta, B] \}$, where B is the size of the file and $\alpha$ is the number of packets on each node.
One has to optimize both $\alpha$ and $\beta$, hence we get two kind of regenerating codes viz. Minimum Storage Regenerating (MSR) codes useful for archival purpose and Minimum Bandwidth Regenerating (MBR) codes useful for Internet applications \cite{rr10,survey}. Some of the MBR codes studied by the researchers fails to optimize other parameters of the system such as disk I/O, computation and scalability etc. Towards this goal, a class of MBR codes called Dress codes were introduced and studied by researchers \cite{rr10,6062413,RSKR10,7066224} to optimize disk I/O. These codes have a repair mechanism known as encoded repair or table based repair. Dress codes consisting of an inner code called fractional repetition (FR) code and outer MDS code. Construction of FR codes has been an important research problem and many constructions of FR codes are known based on graphs \cite{DBLP:journals/corr/abs-1102-3493,rr10,Wangwang12,DBLP:journals/corr/SilbersteinE14,DBLP:journals/corr/SilbersteinE15,7118709}, combinatorial designs \cite{6912604,DBLP:journals/corr/OlmezR14,DBLP:journals/corr/abs-1210-2110,DBLP:journals/corr/abs-1210-2110,6763122,7004501,DBLP:journals/corr/SilbersteinE14,DBLP:journals/corr/abs-1210-2110} and other combinatorial configuration \cite{6810361,6033980,6570830,DBLP:journals/corr/abs-1208-2787}. Existence of FR code is discussed in \cite{DBLP:journals/corr/abs-1201-3547}. FR codes have been studied in different directions such as Weak FR codes \cite{DBLP:journals/corr/abs-1302-3681,DBLP:journals/corr/abs-1303-6801}, Irregular FR codes \cite{6804948}, Variable FR codes \cite{6811237}. A new family of Fractional Repetition Batch Code is studied in \cite{DBLP:journals/corr/Silberstein14,DBLP:journals/corr/SilbersteinE15}. For a given FR code, algorithms to calculate repair degree $d$ and upper-bound of reconstruction degree $k$, is given in \cite{DBLP:journals/corr/abs-1305-4580}.
In this paper, a more general definition of FR code (Definition \ref{defWFR}) is considered for a realistic practical scenario. Further, a sequence based construction for FR code, is given. In particular, construction of Flower code is studied in detail.
The structure of the paper is as follows. In Section $2$, we define a general FR codes and collects relevant background material. In Section $3$, construction of flower code with single and multiple ring
is given. We also study its relations with sequences. In particular, we show how to construct them using arbitrary binary sequences. Final section concludes the paper with general remarks.
\begin{figure}
\centering
\includegraphics[scale=0.3]{flowerfigures/dressstrong}
\caption{DRESS Code consisting of an inner fractional repetition code $\mathscr{C}$ having $n=4$ nodes, number of packets $\theta=6$, replication factor $\rho=2$ and repair degree $d=3$ and an outer MDS code.}
\label{dressstrong}
\end{figure}
\section{Background}
Distributed Replication-based Simple Storage (Dress) Codes consists of an inner Fractional Repetition (FR) code and an outer MDS code (see Figure \ref{dressstrong}). In this, $5$ packets are encoded into $6$ packets using a MDS code and then each packet is replicated twice and distributed among $4$ nodes. In case of one node failure data can be recovered easily in such a system.
We formally define FR code as follows
\begin{definition} (Fractional Repetition Code):
Given a DSS with $n$ nodes $U_i (i \in\Omega_n = \{1,2,\ldots,n\})$ and $\theta$ packets $P_j ( j \in \Omega_{\theta} = \{1,\ 2,\ldots,\theta \})$, one can define FR code $\mathscr{C}(n, \theta, \alpha, \rho)$ as a collection $\mathscr{C}$ of $n$ subsets $U_i$ ($i\in\Omega_n$) of a set $\{P_j:j\in\Omega_{\theta}\}$, which satisfies the following conditions.
\begin{itemize}
\item For each $j\in\Omega_{\theta}$, packet $P_j$ appears exactly $\rho_j$ ($\rho_j\in{\NN}$) times in the collection $\mathscr{C}$.
\item For every $i = 1, 2, \ldots, n$, $|U_i|=\alpha_i$ ($\alpha_i \in{\NN}$),
\end{itemize}
where $\alpha_i$ denotes the number of packets on the node $U_i$, $\rho = \max\{\rho_j\}_{j=1}^{\theta}$ is the maximum replication among all packets. The maximum number of packets on any node is given by $\alpha=\max\{\alpha_i\}_{i=1}^n$. Clearly $\sum_{j=1}^{\theta}\rho_j = \sum_{i=1}^n\alpha_i$.
\begin{remark}
When a node fails it can be repaired by a set of different nodes. Number of nodes contacted for repairing the fail node is known as repair degree.
Hence each node $U_i$ has a set of different repair degrees. Let $(d_i)^j$ denotes the typical repair degree of the node $U_i$ then the set of repair degrees is $\{(d_i)^j : j \in {\NN} \}$. If
$d_i=\max_{j} \{(d_i)^j\}$ is the maximum repair degree of the node $U_i$ then $d=\max\{d_i\}_{i=1}^n$ denotes the maximum repair degree of any node.
\end{remark}
\label{defWFR}
\end{definition}
An example of FR code $\mathscr{C}: (7, 5, 3, 4)$ is shown in Table \ref{nodep4}. In this example, packet $1$ is replicated $4$ times and all other packets are replicated $3$ times. The set of
repair degrees for each node are shown in the last column. Note that node $U_7$ has two different repair degrees.
\begin{table}[ht]
\caption{Node-Packet Distribution for FR code $\mathscr{C}:\ (7, 5, 3, 4)$.}
\centering
\begin{tabular}{|c||c|c|}
\hline
\textbf{Nodes} &\textbf{Packets distribution} & \textbf{Set of repair degrees} \\[0.5ex]
\textbf{$U_i$} & &\textbf{ for each node}\\
\hline\hline
$U_1$& $P_1,\ P_5$ &\{2\}\\
\hline
$U_2$& $P_1,\ P_2$ &\{2\}\\
\hline
$U_3$& $P_2,\ P_3$ &\{2\}\\
\hline
$U_4$& $P_1,\ P_3,\ P_4$ &\{3\}\\
\hline
$U_5$& $P_2,\ P_4,\ P_5$ &\{3\}\\
\hline
$U_6$& $P_3,\ P_5$ &\{2\}\\
\hline
$U_7$& $P_1,\ P_4$ &\{1,2\}\\
\hline
\end{tabular}
\label{nodep4}
\end{table}
\begin{remark}
Each FR code $\mathscr{C}: (n, \theta, \alpha, \rho)$ considered in this paper from now on has same replication factor $\rho$ for each packet $i.e.$ $\rho_j=\rho$ for every $j=1,2,\ldots, \theta$.
\end{remark}
For every FR code one can generate a node-packet distribution incidence matrix denoted by $M_{n\times\theta}$. The distribution matrix is unique representation of FR code. The formal definition of node-packet distribution incidence matrix is as follows.
\begin{definition} (Node-Packet Distribution Incidence Matrix): For an FR code $ \mathscr{C}: (n, \theta, \alpha , \rho)$, a node-packet distribution incidence matrix is a matrix $M_{n \times \theta}$ = $[a_{ij}]_{n \times \theta}\ s.t.$
\[
a_{ij} = \left\{
\begin{array}{ll}
a_{ij} & :\mbox{ if packet $P_j$ appears $a_{ij}$ times on node $U_i$;} \\
0 & :\mbox{ if packet $P_j$ is not on node $U_i$.}\\
\end{array}
\right.
\]
\label{incidence matrix}
\end{definition}
Clearly, if the packet $P_j$ appears exactly ones on node $U_i$ then the matrix is binary.
For example, the node packet distribution incidence matrix $M_{7\times 5}$ for the FR code $\mathscr{C}:\ (7, 5, 3, 4)$ as given in Table \ref{nodep4}, will be
\[
M_{7 \times 5} =
\begin{bmatrix}
1 & 0 & 0 & 0 & 1 \\
1 & 1 & 0 & 0 & 0 \\
0 & 1 & 0 & 1 & 0 \\
1 & 0 & 1 & 1 & 0 \\
0 & 1 & 0 & 1 & 1 \\
0 & 0 & 1 & 0 & 1 \\
1 & 0 & 0 & 1 & 0 \\
\end{bmatrix}.
\]
In order to construct an FR code $\mathscr{C}: (n, \theta, \alpha , \rho)$, one has to drop $\theta$ packets on $n$ nodes such that an arbitrary packet $P_j$ is replicated $\rho$ times in the code. The size of node $U_i$ is $\alpha_i$.
This motivates us to define $cycle\ m$ and $jump$.
\begin{definition} (Cycle): For every $1 \leq m \leq \rho$, a cycle is defined as one complete dropping of packets on $n$ nodes such that all $\theta$ packets are exhausted from $\Omega_{\theta} = \{1,\ldots,\theta \}$ without any replication. Note that $\rho$ is the replication factor of each packets in FR code $\mathscr{C}: (n, \theta, \alpha , \rho)$.
\label{cycle}
\end{definition}
An example of such cycle is shown in Table \ref{jump and cycle}.
\begin{definition} (Jump): A jump is defined as the number of null packets between two consecutive packets from $\Omega_{\theta} = \{1,\ldots,\theta \}$ while dropping them on $n$ nodes $U_1,U_2, \ldots ,U_n$.
\end{definition}
An example of such jump is shown in Table \ref{jump and cycle}. In the table, dash between two packets (such as packets indexed by $3$ and $4$) represents jump for the certain cycle.
\begin{table}[ht]
\caption{Jump and cycles for the $4$ packets on $3$ nodes.}
\begin{center}
{\renewcommand\arraystretch{1.5}
\begin{tabular}{|c||c|c|c|c|c|c|c|c|c|c|c|c|}\hline
\textbf & \multicolumn{5}{c|}{\textbf{Cycle 1}} & \multicolumn{7}{c|}{\textbf{Cycle 2}} \\ \cline{2-13}
\hline\hline
Packet Index & 1 & 2 & 3 & - & 4 & - & - & 1 & 2 & - & 3 & 4 \\
\hline
Node Index & 1 & 2 & 3 & 1 & 2 & 3 & 1 & 2 & 3 & 1 & 2 & 3 \\
\hline
\end{tabular}}
\end{center}
\label{jump and cycle}
\end{table}
One can associate a binary characteristic sequence (dropping sequence), node sequence (ordering the node sequence where the packet is dropped) and node-packet incidence matrix with any fractional repetition code. We now formally collect these definitions.
\begin{definition} (Dropping Sequence): An FR code $\mathscr{C}: (n, \theta, \alpha , \rho)$ can be characterized by a binary characteristic sequence (weight of the sequence is $\rho\theta$) which is one whenever a packet is dropped on a node and zero whenever no packet is dropped.
\label{dropping sequence}
\end{definition}
\begin{example}
For a given $n=4$ and $\theta=6$ a possible dropping sequence for the FR code $\mathscr{C}: (4, 6, 3, 2)$ as shown in Figure \ref{dressstrong}, is $\left\langle 1,1,1,1,1,1,0,0,0,1,1,1,0,0,1,1,1 \right\rangle$. Using the sequence one can generate the FR code by dropping packet $P_1$ on node $U_1$, since $d(1)=1$ and so on.
\end{example}
Dropping sequence $\left\langle d(m)\right\rangle_{m=1}^l$ of an FR code $\mathscr{C}: (n, \theta, \alpha , \rho)$ has the following properties.
\begin{enumerate}
\item
\begin{equation*}
d(m) = \left\{
\begin{array}{ll}
1 & :\mbox{ if packet is dropped on node $U_t$;} \\
0 & :\mbox{ if packet is not dropped on node $U_t$,}
\end{array}
\right. \\
\end{equation*}
where
\[
t = \left\{
\begin{array}{ll}
m \ (mod \ n) & :\mbox{ if } n\nmid m; \\
n & :\mbox{ if } n\mid m.
\end{array}
\right.
\]
\item WLOG one can set $d(l)=1$ for dropping sequence $\left\langle d(m)\right\rangle_{m=1}^l$, where $l\in {\NN}\ s.t.\ weight$ of $\left\langle d(m)\right\rangle_{m=1}^l$ = $w(\left\langle d(m)\right\rangle_{m=1}^l)=\rho\theta \mbox{ and } d(m)\in \{0, 1\}.$
\item It is clear that $l\in\{\rho\theta, \rho\theta +1, ..., \rho\theta + (n-1)^{\rho\theta -1},...\}$ but one can reduce the value of $l$ such that $\rho\theta\leq l\leq\rho\theta + (n-1)^{\rho\theta -1}$ by puncturing $n$ consecutive 0's in $\left\langle d(m)\right\rangle_{m=1}^l$. It can be observed easily that if $l>\rho\theta + (n-1)^{\rho\theta -1}$ then $\exists\ q(\geq n)$ consecutive 0's in $\left\langle d(m)\right\rangle_{m=1}^l$.
\item If $d(r)=1(1\leq r\leq l)$ then packet P$_\lambda$ is distributed on node $U_t$, where
\begin{equation*}
\lambda = \left\{ \,
\begin{array}{ll}
\eta (r) & :\mbox{ if $\eta (r)\neq 0$;} \\
\theta & :\mbox{ if $\eta (r) =0$,}
\end{array}
\right.
\end{equation*}
where $\eta (r)=w\left(\left\langle d(m)\right\rangle_{m=1}^r\right) \ (mod \ \theta)$.
\end{enumerate}
\begin{definition} (Node Sequence): An FR code $\mathscr{C}: (n, \theta, \alpha , \rho)$ can be characterized by a finite sequence $\left\langle s_i \right\rangle _{i=1}^{\rho\theta}$ defined from $\left\{1, 2,..., \rho\theta \right\}\left(\subset{\NN}\right)$ to $\Omega_n = \left\{1, 2,..., n \right\}\left(\subset{\NN}\right)$ such as packet $P_t\left(t \in \Omega_{\theta} \right)$ is dropped on node $s_i \left( \in \Omega_n \right)$, where
\begin{equation}
t = \left\{ \,
\begin{array}{ll}
i \ (mod \ \theta) & :\mbox{ if } \left(i\ (mod \ \theta) \right) \neq 0; \\
\theta & :\mbox{ if } \left(i\ (mod \ \theta) \right) = 0.
\end{array}
\right.
\label{eq:example_left_right1}
\end{equation}
\label{node sequence}
\end{definition}
\begin{example}
For given $n$ nodes and $\theta$ packets, a possible node sequence is $\left\langle 1,2,3,4,1,2,2,3,4,3,4,1\right\rangle$ for FR code $\mathscr{C}: (4, 6, 3, 2)$ as shown in Figure \ref{dressstrong}.
\end{example}
\begin{remark}
For an FR code $\mathscr{C}:(n, \theta, \alpha, \rho)$, there may exist more then one dropping sequences $\left\langle d(m)\right\rangle_{m=1}^l$ as well as node sequences $\left\langle s_i \right\rangle _{i=1}^{\rho\theta}$.
\end{remark}
Next section describes the construction of the flower codes
by arranging $n$ nodes in a single ring or multiple ring configuration and then dropping $\theta$ packets following a configuration.
\section{Constructions of Flower Codes}
A generalized ring construction of FR codes was described in \cite{DBLP:journals/corr/abs-1302-3681} which give rise to Weak FR codes with $\rho=2$ depending upon weather $\theta$ is a multiple of $n$ or not. In this section, we generalize $\rho=2$ construction to $\rho > 2$. In order to construct the FR code of replication factor $\rho$, we first place $n$ nodes on a circle. Now we can place $\theta$ packets on each of them one by one till a cycle is complete. One has to place the packets till we complete all $\rho$ cycles. This will give rise to an FR code since all $\theta$ packets are replicated $\rho$ times in the system. Now we can vary the packet dropping mechanism by introducing jumps within a cycle or after every cycle. To do so first we define different kind of jumps. This process yields several classes of interesting FR codes.
\begin{definition} (Internal $\&$ External Jumps): An internal jump is a jump applied within a cycle $m, 1 \leq m \leq \rho$. Similarly a jump is called external jump if it is applied between two consecutive cycles $m\; \& \;m+1, 1 \leq m \leq \rho$.
In particular, internal (external) jump function is denoted by $f_{in} (f_{ex})$ with domain $\left\{1,2,...,\rho\theta\right\}\backslash\{\theta, 2\theta,\ldots,\rho\theta\}\left(\left\{1, 2,...,\rho\right\}\right)$. Both jump functions have common co-domain ${\NN}\cup \{0\}$.
\label{Jumps}
\end{definition}
\begin{example} For given nodes $n=3$, packets $\theta=4$, internal jump function $f_{in}=1$ and external jump function $f_{ex}$, one can construct node sequence $\left\langle 1,3,2,1,2,1,3,2\right\rangle$ for some FR code $\mathscr{F}_{\mathscr{C}}: (3, 4, 3, 2)$.
\end{example}
\begin{remark}
A special kind of jump, (for example, see Definition \ref{subsetjump}), can be described by a characteristic function $\xi(i)=1 \;\mbox{(drop)}\;\mbox{or} \;0\;\mbox{(do not drop)}$ which tells us when to drop a packet at a position $i, 1 \leq i \leq n$.
\end{remark}
\begin{definition} (Subset Type Jumps): \label{subsetjump}
Let $\Omega_n =\{1, 2, \ldots, n \}$ be an index set of $n$ nodes and let $A \subseteq \Omega_n$. A jump is called subset type jump if it's characteristic function $\xi(i)$ is given by
\[
\xi(i) =\left\{
\begin{array}{ll}
1 & :\mbox{if}\; i \in A; \\
0 & :\mbox{if}\; i \notin A.
\end{array}\right.
\]
\end{definition}
Now we are ready to define a Flower code with single ring having a subset type jump within it's $\rho$ cycles.
\begin{definition}(Flower code with single ring): A Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ with single ring and having a subset type jumps can be defined by first placing $n$ nodes along a single ring and then dropping packets as per a subset jump $A_m (1 \leq m \leq \rho)$ (see Definition \ref{subsetjump}) within every cycle $m (1 \leq m \leq \rho)$ till we drop all $\rho \theta$ packets on the ring. An example for such jump, is illustrate in Table \ref{flower jump table}.
\label{Flower with 1 ring}
\end{definition}
\begin{table}[ht]
\caption{A possible distribution for a Flower code $\mathscr{F}_{\mathscr{C}}: (8, 7, 4, 3)$ with subset type jumps $A_1=\{ 1, 2, 4\}$, $A_2= \{5, 6, 7, 8\}$ and $A_3= \{2, 3, 5, 6, 7\}.$}
\begin{center}
{\renewcommand\arraystretch{1.5}
\begin{tabular}{|c||c|c|c|c|c|c|c|c|}\hline
\textbf{Node} & \multicolumn{7}{c|}{\textbf{Packet distribution}} & \textbf{Node Capacity} \\ \cline{2-8}
$U_i$ & \multicolumn{3}{c|}{\textbf{For $A_1$}}&\multicolumn{2}{c|}{\textbf{For $A_2$}}&\multicolumn{2}{c|}{\textbf{For $A_3$}}& $\alpha_i$ \\
\hline\hline
$U_1$& $P_1$ & $P_4$ & $P_7$ & - & - & - & - &3\\
\hline
$U_2$& $P_2$ & $P_5$ & - & - & - & $P_1$ & $P_6$& 3\\
\hline
$U_3$& - & - & - & - & - & $P_2$ & $P_7$ &2\\
\hline
$U_4$& $P_3$ & $P_6$ & - & - & - & - & - &2\\
\hline
$U_5$& - & - & - & $P_1$ & $P_5$ & $P_3$ & - &3\\
\hline
$U_6$& - & - & - & $P_2$ & $P_6$ & $P_4$ & - &3\\
\hline
$U_7$& - & - & - & $P_3$ & $P_7$ & $P_5$ & - &3\\
\hline
$U_8$& - & - & - & $P_4$ & - & - & - &1\\
\hline
\end{tabular}}
\end{center}
\label{flower jump table}
\end{table}
\begin{lemma}
Consider a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ with single ring and having subset type jumps on node subsets $A_1, A_2,\ldots A_{\rho}$. If total number of packets distributed on node $U_{i_t} (i_t\in A_m; 1\leq m\leq\rho\mbox{ and }t=1,2,\ldots,|A_m|)$ for subset type jump with single ring on node subset $A_m$ is $P(U_{i_t},A_m)$ then
\begin{equation*}
P(U_{i_t},A_m)=\left\{
\begin{array}{ll}
\left\lceil\frac{\theta}{|A_m|}\right\rceil & :\mbox{ if } t\leq\theta\ (mod\ |A_m|); \\
&\\
\left\lfloor \frac{\theta}{|A_m|}\right\rfloor & :\mbox{ otherwise.}
\end{array}
\right.
\end{equation*}
\label{11}
\end{lemma}
\begin{proof} Suppose $A_1,A_2,\ldots,A_{\rho}$ are the subsets of $\Omega_n$. For the given $n$ nodes, $\theta$ packets and $A_m$ $(m=1,2,\ldots \rho)$ one can construct flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ with single ring and subset type jump on $A_m$, $\forall$ $m$. Since subset type jump on particular subset $A_m$ is assigning $\theta$ distinct packets on nodes $U_{i_t}\in A_m$ ($1\leq t\leq |A_m|$) in some specific order. If $|A_m|$ divides $\theta$ then number of packets dropped on a particular node $U_{i_t}$ is $\frac{\theta}{|A_m|}$. If $|A_m|$ does not divide $\theta$ then after dropping $\left\lfloor\frac{\theta}{|A_m|}\right\rfloor$ packets on each node of $A_m$, there will remain $\theta\ (mod\ |A_m|)$ packets to assign nodes. Hence, there are $\theta\ (mod\ |A_m|)$ number of nodes $U_{i_t}\in A_m$ with $\left\lfloor\frac{\theta}{|A_m|}\right\rfloor+1$ packets each. Remaining nodes in the set $A_m$ have $\left\lfloor\frac{\theta}{|A_m|}\right\rfloor$ packets each. Hence, the lemma is proved.
\end{proof}
\begin{lemma}
For a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ with single ring and having subset type jumps on node subsets $A_1, A_2,\ldots A_{\rho}$, the total number of packets stored on a particular node $U_i$ is
\begin{equation*}
\alpha_i=\sum_{m=1}^{\rho}P(U_i,A_m),
\end{equation*}
where, $P(U_i,A_m)=0$ for $U_i\notin A_m$.
\end{lemma}
\begin{proof} For a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ with single ring and having subset type jumps, all packets stored on a particular node are equal to the sum of total number of packets dropped on the node for each subset type jump of $A_m$ ($1\leq m\leq\rho$). Hence proved.
\end{proof}
\begin{remark}
For a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ with a subset type jump $A_m (1 \leq m \leq \rho)$ has the following properties
\begin{itemize}
\item If $\left|A_{\max}\right|=\max \left\{\left|A_1\right|,\left|A_2\right|,...,\left|A_{\rho}\right|\right\}$ then
\begin{equation*}
\left\lfloor\frac{\theta}{\left|A_{\max}\right|}\right\rfloor\leq\alpha_i\leq\alpha\leq\sum\limits_{m=1}^{\rho}\left\lceil \frac{\theta}{|A_m|}\right\rceil.
\end{equation*}
\item If $\exists\ U_i\ s.t.\ U_i\in\bigcap_{m=1}^{\rho}A_m$ then the node $U_i$ has maximum number of distributed distinct packets $i.e.\ \left|U_i\right|=\alpha$ but converse is not true.
\item If $\exists\ U_p\left(p\in A_m\right)\ s.t.$
\begin{equation*}
U_p\notin\bigcup_{\stackrel{i=1}{i\neq m}}^{\rho}A_i,\ then \ \alpha _{\max}\geq\left\lceil \frac{\theta}{\left|A_m\right|}\right\rceil
\end{equation*}
\end{itemize}
and viz., where $1\leq i, j, p\leq n$.
\end{remark}
To construct FR code $\mathscr{C}: (n, \theta, \alpha, \rho)$, one can concatenate $\rho$ distinct cycles with some internal and external jumps, where each cycle defined on $n$ nodes.
\begin{definition}(Flower code with multiple rings): A system with $\rho$ cycles of $\theta$ packets in which packets are distributed among $n$ nodes arranged on a circle with internal jump function $f_{in}:\left\{1,2,...,\rho\theta\right\}\backslash\{\theta, 2\theta,\ldots,\rho\theta\}\rightarrow{\NN}\cup \{0\}$ and external jump function $f_{ex}: \left\{1, 2,...,\rho\right\}\rightarrow{\NN}\cup\{0\}$ is called Flower code $\mathscr{F}_{\mathscr{C}}$ with parameters $n, \theta, \alpha$ and $\rho$, where $\alpha$ is the maximum collective frequency of appearance of a node in all cycles.
\label{Flower with multi ring}
\end{definition}
\begin{example} A Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ with internal jump function $f_{in}(x)=1$ and external jump function $f_{ex}(x)=0$, is illustrated in Table \ref{Flower table 3}.
\begin{table}[ht]
\caption{A Flower code $\mathscr{F}_{\mathscr{C}}: (5, 6, 3, 2)$.}
\begin{center}
{\renewcommand\arraystretch{1.5}
\begin{tabular}{|c||c|c|c|c|c|c|}\hline
\textbf{Node} & \multicolumn{5}{c|}{\textbf{Packet distribution}} & \textbf{Node Capacity} \\
\hline\hline
$U_1$& $P_1$ & - & $P_6$ & $P_3$ & - &3\\
\hline
$U_2$& - & $P_4$ & $P_1$ & - & $P_6$ &3\\
\hline
$U_3$& $P_2$ & - & - & $P_4$ & - &2\\
\hline
$U_4$& - & $P_5$ & $P_2$ & - & - &2\\
\hline
$U_5$& $P_3$ & - & - & $P_5$ & - &2\\
\hline
\end{tabular}}
\end{center}
\label{Flower table 3}
\end{table}
\end{example}
Note that the Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ has internal and external jump functions ($f_{in}$ and $f_{ex}$ respectively) and each Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ is an FR code $\mathscr{C}: (n, \theta, \alpha, \rho)$ so terms of node sequence $s_m$ in $\left\langle s_m\right\rangle_{m=1}^{\rho\theta}$ can be represented in terms of $f_{in}$ and $f_{ex}$ as described in Theorem \ref{theorem} .
\begin{theorem} Consider a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ having an internal jump function $f_{in}:\left\{1,2,...,\rho\theta\right\}\backslash$ $\{\theta, 2\theta,\ldots,\rho\theta\}$ $\rightarrow{\NN}\cup \{0\}$ and an external jump function $f_{ex}:\left\{1, 2,...,\rho\right\}\rightarrow{\NN}\cup \{0\}$.
If node sequence of the Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ is $\left\langle s_m\right\rangle _{m=1}^{\rho\theta}$ then
\begin{equation}
s_m = \left\{
\begin{array}{ll}
1 & :\mbox{ if }m=1; \\
\vartheta (m) & :\mbox{ if } \vartheta (m) \neq 0, 1<m\leq \rho\theta; \\
n & :\mbox{ if } \vartheta (m)= 0, 1<m\leq \rho\theta;\\
0 & :\mbox{ if } m>\rho\theta,
\end{array}
\right.
\label{Node sequence and jump}
\end{equation}
where
\begin{equation*}
\vartheta (m)=\left[m+\sum\limits_{
\begin{array}[b]{c}
i=0 \\
\theta\nmid i
\end{array}
}^{m-1}f_{in}(i)+\sum\limits_{
\begin{array}[b]{c}
i=0 \\
\theta\mid i
\end{array}
}^{m-1}f_{ex}\left(\frac{i}{\theta}\right)\right](mod\ n).
\end{equation*}
\label{theorem}
\end{theorem}
\begin{proof}
Suppose the node sequence of the Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ is $\left\langle s_m\right\rangle _{m=1}^{\rho\theta}$, with an internal jump function
$f_{in}(m): \left\{1,2,...,\rho\theta\right\}\backslash\{\theta, 2\theta,\ldots,\rho\theta\}\rightarrow{\NN}\cup \{0\}$
and an external jump function
$f_{ex}(m): \left\{1, 2,...,\rho\right\}\rightarrow{\NN}\cup \{0\}$.
By the Definition \ref{eq:example_left_right1} of node sequence $\left\langle s_m\right\rangle _{m=1}^{\rho\theta}$ of Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$, we have $s_m\left(\in\Omega_n\right)$ is the node on which packet is dropped and WLOG for $m=1$ one can take $s_1=1$. If $p$ is the index of term $s_p$ in $\left\langle s_m\right\rangle_{m=1}^{\rho\theta}$ then for $p \neq 1$ and $p\leq\rho\theta$, following cases are raised.
\begin{enumerate}
\item If $\theta\mid p$ then $\theta^{th}$ packet is placed on $s_p$ for a cycle and first packet for the next cycle is placed on $s_{p+1}$. Hence there is external jump between packets dropped on node $s_p$ and node $s_{p+1}$.
Clearly $\frac{p}{\theta}$ gives the index number of jump completed at node $s_p$.
\item If $\theta\nmid p$ then both packets dropped on nodes indexed $s_p$ and $s_{p+1}$, are from same cycle so there is internal jump between the both nodes.
\end{enumerate}
Note that both cases can not fall on same node $s_m$ in node sequence $\left\langle s_m\right\rangle _{m=1}^{\rho\theta}$. Following case $1$ for $p=m-1$,
\begin{equation}
s_{m} = s_{m-1} + f_{ex}\left(\frac{m-1}{\theta}\right)+1,
\label{recursion on external}
\end{equation}
where $\theta\mid(m-1)$ and $m\in\{1,2,\ldots\rho\theta\}$.
Again for case $2$,
\begin{equation}
s_{m}=s_{m-1}+f_{in}\left(m-1\right)+1,
\label{recursion on internal}
\end{equation}
where $\theta\nmid(m-1)$ and $m\in\{1,2,\ldots\rho\theta\}$.
Hence one can have the following recursive equation by the above equations (\ref{recursion on external}) and (\ref{recursion on internal}) with boundary conditions $s_1=1$ and $s_i=0\ \forall i(\in{\NN})>\rho\theta$ on node sequence $\left\langle s_m\right\rangle_{m=1}^{\rho\theta}$.
\begin{equation}
s_{m} = \left\{ \,
\begin{array}{ll}
1 & :\mbox{ if } m=1; \\
s_{t} + f_{ex}(t_{ex})+1 & :\mbox{ if } \theta\mid t, 1<m\leq \rho\theta; \\
s_{t}+f_{in}(t)+1 & :\mbox{ if } \theta\nmid t, 1<m\leq \rho\theta; \\
0 & :\mbox{ if } m>\rho\theta,
\end{array}
\right.\label{recursive equastion}
\end{equation}
where $t_{ex} = \frac{m-1}{\theta}\mbox{ and }t = (m-1)$. Solving the recursive equation (\ref{recursive equastion}), one can get relation (\ref{Node sequence and jump}).
\end{proof}
\par Since each FR code can be represented by node sequence, dropping sequence and incidence matrix so each Flower code can also be represented by node sequence, dropping sequence and incidence matrix. The following lemmas establish the relation among those collectively. The lemmas are as follows.
\begin{lemma} Consider a dropping sequence $\left\langle d(m)\right\rangle_{m=1}^l$ for a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$. If $d(t)=1$ for any $t$ $(1\leq t\leq l)$ then binary node-packet distribution incidence matrix $M_{n \times \theta}$ = $[a_{ij}]_{n \times \theta}$ is given by $a_{ij}=1$, where
\begin{equation}
\begin{split}
& j = \left\{ \,
\begin{array}{ll}
\left[wt\left\langle d(m)\right\rangle_{m=1}^t\right](mod\ \theta) & :\mbox{ if } \theta\nmid\left[wt\left\langle d(m)\right\rangle_{m=1}^t\right]; \\
\theta & :\mbox{ if } \theta\mid\left[wt\left\langle d(m)\right\rangle_{m=1}^t\right].
\end{array}
\right. \\
& and \\
& i = \left\{ \,
\begin{array}{ll}
t\ (mod\ n) & :\mbox{ if } n\nmid t; \\
n & :\mbox{ if } n\mid t;
\end{array}
\right.
\end{split}
\end{equation}
\label{dropping sequence and matrix relation}
\end{lemma}
\begin{proof} Let $\left\langle d(m)\right\rangle_{m=1}^l$ be a dropping sequence for an FR code $\mathscr{C}: (n, \theta, \alpha, \rho)$ with $n$ nodes and $\theta$ packets.
For $d(m)=1$ ($d(t)\in\left\langle d(m)\right\rangle_{m=1}^l$), index of the packet associated with the $d(t)$ is mapped to weight of subsequence $\left\langle d(m)\right\rangle_{m=1}^l$. Hence the lemma.
\end{proof}
\begin{remark} If Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ has a non-binary incidence matrix then one can calculate the incidence matrix by the Algorithm \ref{algo for incidence matrix} using dropping sequence.
\line(-1,0){20}\line(1,0){240}
\begin{algorithm}
Algorithm to compute node-packet distribution incidence matrix $M_{n \times \theta}$ for Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$.
\label{algo for incidence matrix}
\end{algorithm}
\line(-1,0){20}\line(1,0){240}
\newline\textbf{REQUIRE} Dropping sequence $\left\langle d(m)\right\rangle_{m=1}^l$ of Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$.
\newline\textbf{ENSURE} Node-packet distribution incidence matrix $M_{n \times \theta}$.
{\footnotesize\begin{enumerate}
\item Initially $\forall i,j$ set $a_{ij}=0$ and $t=1\ where\ a_{ij}$ is the element of $M_{n\times\theta},1\leq i\leq n,\ 1\leq j\leq\theta\ and\ 1\leq t\leq l.$
\item If $d(t)=0$ then jump to step $3$ and if $d(t)=1$ then calculate $i,j$ and set $a_{ij}=a_{ij}+1$ and go to step $3$, $where$
\begin{equation*}
\begin{split}
& i = \left\{ \,
\begin{array}{ll}
t\ (mod\ n) & :\mbox{ if } n\nmid t; \\
n & :\mbox{ if } n\mid t;
\end{array}
\right. and \\
& j = \left\{ \,
\begin{array}{ll}
\left[wt\left\langle d(m)\right\rangle_{m=1}^t\right](mod\ \theta) & :\mbox{ if } \theta\nmid\left[wt\left\langle d(m)\right\rangle_{m=1}^t\right]; \\
\theta & :\mbox{ if } \theta\mid\left[wt\left\langle d(m)\right\rangle_{m=1}^t\right].
\end{array}
\right.
\end{split}
\end{equation*}
\item If $t<l$ then set $t=t+1$ and go to step $2$ otherwise stop.
\end{enumerate}}
\line(-1,0){20}\line(1,0){240}
\par It is clear that Algorithm \ref{algo for incidence matrix} is the generalization of Lemma \ref{dropping sequence and matrix relation}.
\end{remark}
\begin{lemma} Consider a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ with node sequence $\left\langle s_i\right\rangle_{i=1}^{\rho\theta}$. Its dropping sequence is given by $\left\langle d(m)\right\rangle_{m=1}^l\ s.t.\ \forall\ i,1\leq i\leq\rho\theta$
\begin{equation*}
d(m) = \left\{ \,
\begin{array}{ll}
1 & :\mbox{ if } m=\sum\limits_{j=1}^i\left(s_j-s_{j-1}\right)(mod\ n); \\
0 & :\mbox{ if } m\neq\sum\limits_{j=1}^i\left(s_j-s_{j-1}\right)(mod\ n),
\end{array}
\right.
\end{equation*}
where $s_o\ =\ 0$.
\end{lemma}
\begin{proof} For a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$, consider a dropping sequence $\left\langle d(m)\right\rangle_{m=1}^l$. By Definition \ref{node sequence}, two packets with consecutive indexes are associated with $s_i$ and $s_{i+1}$ for some $i$. Using Definition \ref{dropping sequence}, one can find that $[s_{i+1}-s_i](mod\ n)$ number of zeros exist between two consecutive $1$'$s$. In particular, the $1$'$s$ are associative with the two packets. It proves the lemma.
\end{proof}
\begin{lemma} Consider a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ with dropping sequence $\left\langle d(m)\right\rangle_{m=1}^l$. Its node sequence is given by $\left\langle s_i\right\rangle_{i=1}^{\rho\theta}\ s.t. \forall\ t\ (1\leq t\leq l)\ with\ d(t)=1$,
\begin{equation*}
i = wt\left\langle d(m)\right\rangle_{m=1}^t
\end{equation*}
and
\begin{equation*}
s_i = \left\{ \,
\begin{array}{ll}
t\ (mod\ n) & :\mbox{ if } n\nmid t; \\
n & :\mbox{ if } n\mid t.
\end{array}
\right. \\
\end{equation*}
\end{lemma}
\begin{proof}
Using Definition \ref{node sequence} and Definition \ref{dropping sequence}, one can easily prove the lemma by observing that the weight of subsequence $\left\langle d(m)\right\rangle_{m=1}^t$ is associated with the packet for $d(t)=1$.
\end{proof}
These sequence construction approaches suggest that one can construct an FR code from any arbitrary finite binary sequence by treating it as a characteristic sequence of dropping packets on the nodes. This can be done in different ways by choosing appropriate sequences of symbols. Hence, an arbitrary finite binary sequence $\left\langle \chi(m)\right\rangle_{m=1}^{\ell}\ (\chi(m)\in{\ZZ}_2)$ with length $\ell(\in{\NN})$ can be defined as a characteristic sequence for an FR code. In the sequence, value $\chi(m)=1$ represents to drop (value $\chi(m)=0$ not to drop) a packet on certain node.
Hence a more general Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ can be defined as follows.
\begin{definition} (Flower code): For $n$ nodes, $\theta$ packets and an arbitrary binary sequence $\left\langle \chi(m)\right\rangle_{m=1}^{\ell}\ (\chi(m)\in{\ZZ}_2)$ of length $\ell(\in{\NN})$ (treated as characteristic sequence indexed by $m$), Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ can be defined as a system in which packet indexed by $m(mod\ \theta)$ is dropped on node indexed by $m(mod\ n)$ iff $\chi(m)=1$, where $P_0$ and $U_0$ are mapped to packet $P_{\theta}$ and node $U_n$ respectively. Clearly $\alpha_i=\sum_{m=0}^{\left\lfloor \frac{\ell-i}{n}\right\rfloor}\chi(i+nm)$ and $\rho_j=\sum_{m=0}^{\left\lfloor \frac{\ell-j}{\theta}\right\rfloor}\chi(j+\theta m)$.
\label{Flower}
\end{definition}
\begin{example}
For given $n=4$, $\theta=5$ and a binary characteristic sequence $\left\langle \chi(m)\right\rangle_{m=1}^{16}$ = $\left\langle 1,1,0,1,0,0,1,1,1,1,1,1,\right.$ $\left. 0,1,0,1\right\rangle$, one can find Node packet distribution of Flower code $\mathscr{F}_{\mathscr{C}}:\ (4, 5, 3, 2)$ as shown in Table \ref{3}
\begin{table}[ht]
\caption{Node-Packet Distribution for Flower code $\mathscr{F}_{\mathscr{C}}:\ (4, 5, 4, 3)$.}
\centering
\begin{tabular}{|c||c|c|}
\hline
\textbf{Nodes $U_i$} &\textbf{Packets distribution} & \textbf{Repair degree $d_i$} \\[0.5ex]
\hline\hline
$U_1$& $P_1,\ P_4$ & 2\\ \hline
$U_2$& $P_2,\ P_4\ P_5$ & 3\\ \hline
$U_3$& $P_1,\ P_2,\ P_5$ & 3\\ \hline
$U_4$& $P_1,\ P_2,\ P_3,\ P_4$& 4\\ \hline
\end{tabular}
\label{3}
\end{table}
\end{example}
\begin{remark}
Flower codes $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ (Definition \ref{Flower}) with different packet replication factor $\rho_j$ $(j\in\Omega_{\theta})$ can also be constructed using any binary sequence $\left\langle \chi(m)\right\rangle_{m=1}^{\ell}$.
\end{remark}
\section{Conclusion}
This paper introduces a novel class of FR codes based on sequences. It will be an interesting future task to find a condition when Flower codes are optimal (in sense of the capacity). Our work opens a nice connection of FR codes with well known area of sequences. It would be an interesting future task to study FR codes by using well known class of sequences.
\bibliographystyle{IEEEtran}
\section{Introduction}
In Distributed Storage Systems (DSSs), data file is encoded into certain packets and those packets are distributed among $n$ nodes. A data collector has to collect packets from any $k$ (called reconstruction degree) nodes among the $n$ nodes to reconstruct the whole file. In the case of node failure, system is allowed to reconstruct a new node to replace the failed node. The repair is of two types viz. exact and functional. In the repair process, the new node is constructed by downloading $\beta$ packets from each node (helper node) of a set of $d$ (repair degree) nodes. Thus total bandwidth for a repairing a node is $d\beta$. For an $(n, k, d)$DSS, such regenerating codes are specified by the parameters $\{[n, k, d], [\alpha,\beta, B] \}$, where B is the size of the file and $\alpha$ is the number of packets on each node.
One has to optimize both $\alpha$ and $\beta$, hence we get two kind of regenerating codes viz. Minimum Storage Regenerating (MSR) codes useful for archival purpose and Minimum Bandwidth Regenerating (MBR) codes useful for Internet applications \cite{rr10,survey}. Some of the MBR codes studied by the researchers fails to optimize other parameters of the system such as disk I/O, computation and scalability etc. Towards this goal, a class of MBR codes called Dress codes were introduced and studied by researchers \cite{rr10,6062413,RSKR10,7066224} to optimize disk I/O. These codes have a repair mechanism known as encoded repair or table based repair. Dress codes consisting of an inner code called fractional repetition (FR) code and outer MDS code. Construction of FR codes has been an important research problem and many constructions of FR codes are known based on graphs \cite{DBLP:journals/corr/abs-1102-3493,rr10,Wangwang12,DBLP:journals/corr/SilbersteinE14,DBLP:journals/corr/SilbersteinE15,7118709}, combinatorial designs \cite{6912604,DBLP:journals/corr/OlmezR14,DBLP:journals/corr/abs-1210-2110,DBLP:journals/corr/abs-1210-2110,6763122,7004501,DBLP:journals/corr/SilbersteinE14,DBLP:journals/corr/abs-1210-2110} and other combinatorial configuration \cite{6810361,6033980,6570830,DBLP:journals/corr/abs-1208-2787}. Existence of FR code is discussed in \cite{DBLP:journals/corr/abs-1201-3547}. FR codes have been studied in different directions such as Weak FR codes \cite{DBLP:journals/corr/abs-1302-3681,DBLP:journals/corr/abs-1303-6801}, Irregular FR codes \cite{6804948}, Variable FR codes \cite{6811237}. A new family of Fractional Repetition Batch Code is studied in \cite{DBLP:journals/corr/Silberstein14,DBLP:journals/corr/SilbersteinE15}. For a given FR code, algorithms to calculate repair degree $d$ and upper-bound of reconstruction degree $k$, is given in \cite{DBLP:journals/corr/abs-1305-4580}.
In this paper, a more general definition of FR code (Definition \ref{defWFR}) is considered for a realistic practical scenario. Further, a sequence based construction for FR code, is given. In particular, construction of Flower code is studied in detail.
The structure of the paper is as follows. In Section $2$, we define a general FR codes and collects relevant background material. In Section $3$, construction of flower code with single and multiple ring
is given. We also study its relations with sequences. In particular, we show how to construct them using arbitrary binary sequences. Final section concludes the paper with general remarks.
\begin{figure}
\centering
\includegraphics[scale=0.3]{flowerfigures/dressstrong}
\caption{DRESS Code consisting of an inner fractional repetition code $\mathscr{C}$ having $n=4$ nodes, number of packets $\theta=6$, replication factor $\rho=2$ and repair degree $d=3$ and an outer MDS code.}
\label{dressstrong}
\end{figure}
\section{Background}
Distributed Replication-based Simple Storage (Dress) Codes consists of an inner Fractional Repetition (FR) code and an outer MDS code (see Figure \ref{dressstrong}). In this, $5$ packets are encoded into $6$ packets using a MDS code and then each packet is replicated twice and distributed among $4$ nodes. In case of one node failure data can be recovered easily in such a system.
We formally define FR code as follows
\begin{definition} (Fractional Repetition Code):
Given a DSS with $n$ nodes $U_i (i \in\Omega_n = \{1,2,\ldots,n\})$ and $\theta$ packets $P_j ( j \in \Omega_{\theta} = \{1,\ 2,\ldots,\theta \})$, one can define FR code $\mathscr{C}(n, \theta, \alpha, \rho)$ as a collection $\mathscr{C}$ of $n$ subsets $U_i$ ($i\in\Omega_n$) of a set $\{P_j:j\in\Omega_{\theta}\}$, which satisfies the following conditions.
\begin{itemize}
\item For each $j\in\Omega_{\theta}$, packet $P_j$ appears exactly $\rho_j$ ($\rho_j\in{\NN}$) times in the collection $\mathscr{C}$.
\item For every $i = 1, 2, \ldots, n$, $|U_i|=\alpha_i$ ($\alpha_i \in{\NN}$),
\end{itemize}
where $\alpha_i$ denotes the number of packets on the node $U_i$, $\rho = \max\{\rho_j\}_{j=1}^{\theta}$ is the maximum replication among all packets. The maximum number of packets on any node is given by $\alpha=\max\{\alpha_i\}_{i=1}^n$. Clearly $\sum_{j=1}^{\theta}\rho_j = \sum_{i=1}^n\alpha_i$.
\begin{remark}
When a node fails it can be repaired by a set of different nodes. Number of nodes contacted for repairing the fail node is known as repair degree.
Hence each node $U_i$ has a set of different repair degrees. Let $(d_i)^j$ denotes the typical repair degree of the node $U_i$ then the set of repair degrees is $\{(d_i)^j : j \in {\NN} \}$. If
$d_i=\max_{j} \{(d_i)^j\}$ is the maximum repair degree of the node $U_i$ then $d=\max\{d_i\}_{i=1}^n$ denotes the maximum repair degree of any node.
\end{remark}
\label{defWFR}
\end{definition}
An example of FR code $\mathscr{C}: (7, 5, 3, 4)$ is shown in Table \ref{nodep4}. In this example, packet $1$ is replicated $4$ times and all other packets are replicated $3$ times. The set of
repair degrees for each node are shown in the last column. Note that node $U_7$ has two different repair degrees.
\begin{table}[ht]
\caption{Node-Packet Distribution for FR code $\mathscr{C}:\ (7, 5, 3, 4)$.}
\centering
\begin{tabular}{|c||c|c|}
\hline
\textbf{Nodes} &\textbf{Packets distribution} & \textbf{Set of repair degrees} \\[0.5ex]
\textbf{$U_i$} & &\textbf{ for each node}\\
\hline\hline
$U_1$& $P_1,\ P_5$ &\{2\}\\
\hline
$U_2$& $P_1,\ P_2$ &\{2\}\\
\hline
$U_3$& $P_2,\ P_3$ &\{2\}\\
\hline
$U_4$& $P_1,\ P_3,\ P_4$ &\{3\}\\
\hline
$U_5$& $P_2,\ P_4,\ P_5$ &\{3\}\\
\hline
$U_6$& $P_3,\ P_5$ &\{2\}\\
\hline
$U_7$& $P_1,\ P_4$ &\{1,2\}\\
\hline
\end{tabular}
\label{nodep4}
\end{table}
\begin{remark}
Each FR code $\mathscr{C}: (n, \theta, \alpha, \rho)$ considered in this paper from now on has same replication factor $\rho$ for each packet $i.e.$ $\rho_j=\rho$ for every $j=1,2,\ldots, \theta$.
\end{remark}
For every FR code one can generate a node-packet distribution incidence matrix denoted by $M_{n\times\theta}$. The distribution matrix is unique representation of FR code. The formal definition of node-packet distribution incidence matrix is as follows.
\begin{definition} (Node-Packet Distribution Incidence Matrix): For an FR code $ \mathscr{C}: (n, \theta, \alpha , \rho)$, a node-packet distribution incidence matrix is a matrix $M_{n \times \theta}$ = $[a_{ij}]_{n \times \theta}\ s.t.$
\[
a_{ij} = \left\{
\begin{array}{ll}
a_{ij} & :\mbox{ if packet $P_j$ appears $a_{ij}$ times on node $U_i$;} \\
0 & :\mbox{ if packet $P_j$ is not on node $U_i$.}\\
\end{array}
\right.
\]
\label{incidence matrix}
\end{definition}
Clearly, if the packet $P_j$ appears exactly ones on node $U_i$ then the matrix is binary.
For example, the node packet distribution incidence matrix $M_{7\times 5}$ for the FR code $\mathscr{C}:\ (7, 5, 3, 4)$ as given in Table \ref{nodep4}, will be
\[
M_{7 \times 5} =
\begin{bmatrix}
1 & 0 & 0 & 0 & 1 \\
1 & 1 & 0 & 0 & 0 \\
0 & 1 & 0 & 1 & 0 \\
1 & 0 & 1 & 1 & 0 \\
0 & 1 & 0 & 1 & 1 \\
0 & 0 & 1 & 0 & 1 \\
1 & 0 & 0 & 1 & 0 \\
\end{bmatrix}.
\]
In order to construct an FR code $\mathscr{C}: (n, \theta, \alpha , \rho)$, one has to drop $\theta$ packets on $n$ nodes such that an arbitrary packet $P_j$ is replicated $\rho$ times in the code. The size of node $U_i$ is $\alpha_i$.
This motivates us to define $cycle\ m$ and $jump$.
\begin{definition} (Cycle): For every $1 \leq m \leq \rho$, a cycle is defined as one complete dropping of packets on $n$ nodes such that all $\theta$ packets are exhausted from $\Omega_{\theta} = \{1,\ldots,\theta \}$ without any replication. Note that $\rho$ is the replication factor of each packets in FR code $\mathscr{C}: (n, \theta, \alpha , \rho)$.
\label{cycle}
\end{definition}
An example of such cycle is shown in Table \ref{jump and cycle}.
\begin{definition} (Jump): A jump is defined as the number of null packets between two consecutive packets from $\Omega_{\theta} = \{1,\ldots,\theta \}$ while dropping them on $n$ nodes $U_1,U_2, \ldots ,U_n$.
\end{definition}
An example of such jump is shown in Table \ref{jump and cycle}. In the table, dash between two packets (such as packets indexed by $3$ and $4$) represents jump for the certain cycle.
\begin{table}[ht]
\caption{Jump and cycles for the $4$ packets on $3$ nodes.}
\begin{center}
{\renewcommand\arraystretch{1.5}
\begin{tabular}{|c||c|c|c|c|c|c|c|c|c|c|c|c|}\hline
\textbf & \multicolumn{5}{c|}{\textbf{Cycle 1}} & \multicolumn{7}{c|}{\textbf{Cycle 2}} \\ \cline{2-13}
\hline\hline
Packet Index & 1 & 2 & 3 & - & 4 & - & - & 1 & 2 & - & 3 & 4 \\
\hline
Node Index & 1 & 2 & 3 & 1 & 2 & 3 & 1 & 2 & 3 & 1 & 2 & 3 \\
\hline
\end{tabular}}
\end{center}
\label{jump and cycle}
\end{table}
One can associate a binary characteristic sequence (dropping sequence), node sequence (ordering the node sequence where the packet is dropped) and node-packet incidence matrix with any fractional repetition code. We now formally collect these definitions.
\begin{definition} (Dropping Sequence): An FR code $\mathscr{C}: (n, \theta, \alpha , \rho)$ can be characterized by a binary characteristic sequence (weight of the sequence is $\rho\theta$) which is one whenever a packet is dropped on a node and zero whenever no packet is dropped.
\label{dropping sequence}
\end{definition}
\begin{example}
For a given $n=4$ and $\theta=6$ a possible dropping sequence for the FR code $\mathscr{C}: (4, 6, 3, 2)$ as shown in Figure \ref{dressstrong}, is $\left\langle 1,1,1,1,1,1,0,0,0,1,1,1,0,0,1,1,1 \right\rangle$. Using the sequence one can generate the FR code by dropping packet $P_1$ on node $U_1$, since $d(1)=1$ and so on.
\end{example}
Dropping sequence $\left\langle d(m)\right\rangle_{m=1}^l$ of an FR code $\mathscr{C}: (n, \theta, \alpha , \rho)$ has the following properties.
\begin{enumerate}
\item
\begin{equation*}
d(m) = \left\{
\begin{array}{ll}
1 & :\mbox{ if packet is dropped on node $U_t$;} \\
0 & :\mbox{ if packet is not dropped on node $U_t$,}
\end{array}
\right. \\
\end{equation*}
where
\[
t = \left\{
\begin{array}{ll}
m \ (mod \ n) & :\mbox{ if } n\nmid m; \\
n & :\mbox{ if } n\mid m.
\end{array}
\right.
\]
\item WLOG one can set $d(l)=1$ for dropping sequence $\left\langle d(m)\right\rangle_{m=1}^l$, where $l\in {\NN}\ s.t.\ weight$ of $\left\langle d(m)\right\rangle_{m=1}^l$ = $w(\left\langle d(m)\right\rangle_{m=1}^l)=\rho\theta \mbox{ and } d(m)\in \{0, 1\}.$
\item It is clear that $l\in\{\rho\theta, \rho\theta +1, ..., \rho\theta + (n-1)^{\rho\theta -1},...\}$ but one can reduce the value of $l$ such that $\rho\theta\leq l\leq\rho\theta + (n-1)^{\rho\theta -1}$ by puncturing $n$ consecutive 0's in $\left\langle d(m)\right\rangle_{m=1}^l$. It can be observed easily that if $l>\rho\theta + (n-1)^{\rho\theta -1}$ then $\exists\ q(\geq n)$ consecutive 0's in $\left\langle d(m)\right\rangle_{m=1}^l$.
\item If $d(r)=1(1\leq r\leq l)$ then packet P$_\lambda$ is distributed on node $U_t$, where
\begin{equation*}
\lambda = \left\{ \,
\begin{array}{ll}
\eta (r) & :\mbox{ if $\eta (r)\neq 0$;} \\
\theta & :\mbox{ if $\eta (r) =0$,}
\end{array}
\right.
\end{equation*}
where $\eta (r)=w\left(\left\langle d(m)\right\rangle_{m=1}^r\right) \ (mod \ \theta)$.
\end{enumerate}
\begin{definition} (Node Sequence): An FR code $\mathscr{C}: (n, \theta, \alpha , \rho)$ can be characterized by a finite sequence $\left\langle s_i \right\rangle _{i=1}^{\rho\theta}$ defined from $\left\{1, 2,..., \rho\theta \right\}\left(\subset{\NN}\right)$ to $\Omega_n = \left\{1, 2,..., n \right\}\left(\subset{\NN}\right)$ such as packet $P_t\left(t \in \Omega_{\theta} \right)$ is dropped on node $s_i \left( \in \Omega_n \right)$, where
\begin{equation}
t = \left\{ \,
\begin{array}{ll}
i \ (mod \ \theta) & :\mbox{ if } \left(i\ (mod \ \theta) \right) \neq 0; \\
\theta & :\mbox{ if } \left(i\ (mod \ \theta) \right) = 0.
\end{array}
\right.
\label{eq:example_left_right1}
\end{equation}
\label{node sequence}
\end{definition}
\begin{example}
For given $n$ nodes and $\theta$ packets, a possible node sequence is $\left\langle 1,2,3,4,1,2,2,3,4,3,4,1\right\rangle$ for FR code $\mathscr{C}: (4, 6, 3, 2)$ as shown in Figure \ref{dressstrong}.
\end{example}
\begin{remark}
For an FR code $\mathscr{C}:(n, \theta, \alpha, \rho)$, there may exist more then one dropping sequences $\left\langle d(m)\right\rangle_{m=1}^l$ as well as node sequences $\left\langle s_i \right\rangle _{i=1}^{\rho\theta}$.
\end{remark}
Next section describes the construction of the flower codes
by arranging $n$ nodes in a single ring or multiple ring configuration and then dropping $\theta$ packets following a configuration.
\section{Constructions of Flower Codes}
A generalized ring construction of FR codes was described in \cite{DBLP:journals/corr/abs-1302-3681} which give rise to Weak FR codes with $\rho=2$ depending upon weather $\theta$ is a multiple of $n$ or not. In this section, we generalize $\rho=2$ construction to $\rho > 2$. In order to construct the FR code of replication factor $\rho$, we first place $n$ nodes on a circle. Now we can place $\theta$ packets on each of them one by one till a cycle is complete. One has to place the packets till we complete all $\rho$ cycles. This will give rise to an FR code since all $\theta$ packets are replicated $\rho$ times in the system. Now we can vary the packet dropping mechanism by introducing jumps within a cycle or after every cycle. To do so first we define different kind of jumps. This process yields several classes of interesting FR codes.
\begin{definition} (Internal $\&$ External Jumps): An internal jump is a jump applied within a cycle $m, 1 \leq m \leq \rho$. Similarly a jump is called external jump if it is applied between two consecutive cycles $m\; \& \;m+1, 1 \leq m \leq \rho$.
In particular, internal (external) jump function is denoted by $f_{in} (f_{ex})$ with domain $\left\{1,2,...,\rho\theta\right\}\backslash\{\theta, 2\theta,\ldots,\rho\theta\}\left(\left\{1, 2,...,\rho\right\}\right)$. Both jump functions have common co-domain ${\NN}\cup \{0\}$.
\label{Jumps}
\end{definition}
\begin{example} For given nodes $n=3$, packets $\theta=4$, internal jump function $f_{in}=1$ and external jump function $f_{ex}$, one can construct node sequence $\left\langle 1,3,2,1,2,1,3,2\right\rangle$ for some FR code $\mathscr{F}_{\mathscr{C}}: (3, 4, 3, 2)$.
\end{example}
\begin{remark}
A special kind of jump, (for example, see Definition \ref{subsetjump}), can be described by a characteristic function $\xi(i)=1 \;\mbox{(drop)}\;\mbox{or} \;0\;\mbox{(do not drop)}$ which tells us when to drop a packet at a position $i, 1 \leq i \leq n$.
\end{remark}
\begin{definition} (Subset Type Jumps): \label{subsetjump}
Let $\Omega_n =\{1, 2, \ldots, n \}$ be an index set of $n$ nodes and let $A \subseteq \Omega_n$. A jump is called subset type jump if it's characteristic function $\xi(i)$ is given by
\[
\xi(i) =\left\{
\begin{array}{ll}
1 & :\mbox{if}\; i \in A; \\
0 & :\mbox{if}\; i \notin A.
\end{array}\right.
\]
\end{definition}
Now we are ready to define a Flower code with single ring having a subset type jump within it's $\rho$ cycles.
\begin{definition}(Flower code with single ring): A Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ with single ring and having a subset type jumps can be defined by first placing $n$ nodes along a single ring and then dropping packets as per a subset jump $A_m (1 \leq m \leq \rho)$ (see Definition \ref{subsetjump}) within every cycle $m (1 \leq m \leq \rho)$ till we drop all $\rho \theta$ packets on the ring. An example for such jump, is illustrate in Table \ref{flower jump table}.
\label{Flower with 1 ring}
\end{definition}
\begin{table}[ht]
\caption{A possible distribution for a Flower code $\mathscr{F}_{\mathscr{C}}: (8, 7, 4, 3)$ with subset type jumps $A_1=\{ 1, 2, 4\}$, $A_2= \{5, 6, 7, 8\}$ and $A_3= \{2, 3, 5, 6, 7\}.$}
\begin{center}
{\renewcommand\arraystretch{1.5}
\begin{tabular}{|c||c|c|c|c|c|c|c|c|}\hline
\textbf{Node} & \multicolumn{7}{c|}{\textbf{Packet distribution}} & \textbf{Node Capacity} \\ \cline{2-8}
$U_i$ & \multicolumn{3}{c|}{\textbf{For $A_1$}}&\multicolumn{2}{c|}{\textbf{For $A_2$}}&\multicolumn{2}{c|}{\textbf{For $A_3$}}& $\alpha_i$ \\
\hline\hline
$U_1$& $P_1$ & $P_4$ & $P_7$ & - & - & - & - &3\\
\hline
$U_2$& $P_2$ & $P_5$ & - & - & - & $P_1$ & $P_6$& 3\\
\hline
$U_3$& - & - & - & - & - & $P_2$ & $P_7$ &2\\
\hline
$U_4$& $P_3$ & $P_6$ & - & - & - & - & - &2\\
\hline
$U_5$& - & - & - & $P_1$ & $P_5$ & $P_3$ & - &3\\
\hline
$U_6$& - & - & - & $P_2$ & $P_6$ & $P_4$ & - &3\\
\hline
$U_7$& - & - & - & $P_3$ & $P_7$ & $P_5$ & - &3\\
\hline
$U_8$& - & - & - & $P_4$ & - & - & - &1\\
\hline
\end{tabular}}
\end{center}
\label{flower jump table}
\end{table}
\begin{lemma}
Consider a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ with single ring and having subset type jumps on node subsets $A_1, A_2,\ldots A_{\rho}$. If total number of packets distributed on node $U_{i_t} (i_t\in A_m; 1\leq m\leq\rho\mbox{ and }t=1,2,\ldots,|A_m|)$ for subset type jump with single ring on node subset $A_m$ is $P(U_{i_t},A_m)$ then
\begin{equation*}
P(U_{i_t},A_m)=\left\{
\begin{array}{ll}
\left\lceil\frac{\theta}{|A_m|}\right\rceil & :\mbox{ if } t\leq\theta\ (mod\ |A_m|); \\
&\\
\left\lfloor \frac{\theta}{|A_m|}\right\rfloor & :\mbox{ otherwise.}
\end{array}
\right.
\end{equation*}
\label{11}
\end{lemma}
\begin{proof} Suppose $A_1,A_2,\ldots,A_{\rho}$ are the subsets of $\Omega_n$. For the given $n$ nodes, $\theta$ packets and $A_m$ $(m=1,2,\ldots \rho)$ one can construct flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ with single ring and subset type jump on $A_m$, $\forall$ $m$. Since subset type jump on particular subset $A_m$ is assigning $\theta$ distinct packets on nodes $U_{i_t}\in A_m$ ($1\leq t\leq |A_m|$) in some specific order. If $|A_m|$ divides $\theta$ then number of packets dropped on a particular node $U_{i_t}$ is $\frac{\theta}{|A_m|}$. If $|A_m|$ does not divide $\theta$ then after dropping $\left\lfloor\frac{\theta}{|A_m|}\right\rfloor$ packets on each node of $A_m$, there will remain $\theta\ (mod\ |A_m|)$ packets to assign nodes. Hence, there are $\theta\ (mod\ |A_m|)$ number of nodes $U_{i_t}\in A_m$ with $\left\lfloor\frac{\theta}{|A_m|}\right\rfloor+1$ packets each. Remaining nodes in the set $A_m$ have $\left\lfloor\frac{\theta}{|A_m|}\right\rfloor$ packets each. Hence, the lemma is proved.
\end{proof}
\begin{lemma}
For a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ with single ring and having subset type jumps on node subsets $A_1, A_2,\ldots A_{\rho}$, the total number of packets stored on a particular node $U_i$ is
\begin{equation*}
\alpha_i=\sum_{m=1}^{\rho}P(U_i,A_m),
\end{equation*}
where, $P(U_i,A_m)=0$ for $U_i\notin A_m$.
\end{lemma}
\begin{proof} For a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ with single ring and having subset type jumps, all packets stored on a particular node are equal to the sum of total number of packets dropped on the node for each subset type jump of $A_m$ ($1\leq m\leq\rho$). Hence proved.
\end{proof}
\begin{remark}
For a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ with a subset type jump $A_m (1 \leq m \leq \rho)$ has the following properties
\begin{itemize}
\item If $\left|A_{\max}\right|=\max \left\{\left|A_1\right|,\left|A_2\right|,...,\left|A_{\rho}\right|\right\}$ then
\begin{equation*}
\left\lfloor\frac{\theta}{\left|A_{\max}\right|}\right\rfloor\leq\alpha_i\leq\alpha\leq\sum\limits_{m=1}^{\rho}\left\lceil \frac{\theta}{|A_m|}\right\rceil.
\end{equation*}
\item If $\exists\ U_i\ s.t.\ U_i\in\bigcap_{m=1}^{\rho}A_m$ then the node $U_i$ has maximum number of distributed distinct packets $i.e.\ \left|U_i\right|=\alpha$ but converse is not true.
\item If $\exists\ U_p\left(p\in A_m\right)\ s.t.$
\begin{equation*}
U_p\notin\bigcup_{\stackrel{i=1}{i\neq m}}^{\rho}A_i,\ then \ \alpha _{\max}\geq\left\lceil \frac{\theta}{\left|A_m\right|}\right\rceil
\end{equation*}
\end{itemize}
and viz., where $1\leq i, j, p\leq n$.
\end{remark}
To construct FR code $\mathscr{C}: (n, \theta, \alpha, \rho)$, one can concatenate $\rho$ distinct cycles with some internal and external jumps, where each cycle defined on $n$ nodes.
\begin{definition}(Flower code with multiple rings): A system with $\rho$ cycles of $\theta$ packets in which packets are distributed among $n$ nodes arranged on a circle with internal jump function $f_{in}:\left\{1,2,...,\rho\theta\right\}\backslash\{\theta, 2\theta,\ldots,\rho\theta\}\rightarrow{\NN}\cup \{0\}$ and external jump function $f_{ex}: \left\{1, 2,...,\rho\right\}\rightarrow{\NN}\cup\{0\}$ is called Flower code $\mathscr{F}_{\mathscr{C}}$ with parameters $n, \theta, \alpha$ and $\rho$, where $\alpha$ is the maximum collective frequency of appearance of a node in all cycles.
\label{Flower with multi ring}
\end{definition}
\begin{example} A Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ with internal jump function $f_{in}(x)=1$ and external jump function $f_{ex}(x)=0$, is illustrated in Table \ref{Flower table 3}.
\begin{table}[ht]
\caption{A Flower code $\mathscr{F}_{\mathscr{C}}: (5, 6, 3, 2)$.}
\begin{center}
{\renewcommand\arraystretch{1.5}
\begin{tabular}{|c||c|c|c|c|c|c|}\hline
\textbf{Node} & \multicolumn{5}{c|}{\textbf{Packet distribution}} & \textbf{Node Capacity} \\
\hline\hline
$U_1$& $P_1$ & - & $P_6$ & $P_3$ & - &3\\
\hline
$U_2$& - & $P_4$ & $P_1$ & - & $P_6$ &3\\
\hline
$U_3$& $P_2$ & - & - & $P_4$ & - &2\\
\hline
$U_4$& - & $P_5$ & $P_2$ & - & - &2\\
\hline
$U_5$& $P_3$ & - & - & $P_5$ & - &2\\
\hline
\end{tabular}}
\end{center}
\label{Flower table 3}
\end{table}
\end{example}
Note that the Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ has internal and external jump functions ($f_{in}$ and $f_{ex}$ respectively) and each Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ is an FR code $\mathscr{C}: (n, \theta, \alpha, \rho)$ so terms of node sequence $s_m$ in $\left\langle s_m\right\rangle_{m=1}^{\rho\theta}$ can be represented in terms of $f_{in}$ and $f_{ex}$ as described in Theorem \ref{theorem} .
\begin{theorem} Consider a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ having an internal jump function $f_{in}:\left\{1,2,...,\rho\theta\right\}\backslash$ $\{\theta, 2\theta,\ldots,\rho\theta\}$ $\rightarrow{\NN}\cup \{0\}$ and an external jump function $f_{ex}:\left\{1, 2,...,\rho\right\}\rightarrow{\NN}\cup \{0\}$.
If node sequence of the Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ is $\left\langle s_m\right\rangle _{m=1}^{\rho\theta}$ then
\begin{equation}
s_m = \left\{
\begin{array}{ll}
1 & :\mbox{ if }m=1; \\
\vartheta (m) & :\mbox{ if } \vartheta (m) \neq 0, 1<m\leq \rho\theta; \\
n & :\mbox{ if } \vartheta (m)= 0, 1<m\leq \rho\theta;\\
0 & :\mbox{ if } m>\rho\theta,
\end{array}
\right.
\label{Node sequence and jump}
\end{equation}
where
\begin{equation*}
\vartheta (m)=\left[m+\sum\limits_{
\begin{array}[b]{c}
i=0 \\
\theta\nmid i
\end{array}
}^{m-1}f_{in}(i)+\sum\limits_{
\begin{array}[b]{c}
i=0 \\
\theta\mid i
\end{array}
}^{m-1}f_{ex}\left(\frac{i}{\theta}\right)\right](mod\ n).
\end{equation*}
\label{theorem}
\end{theorem}
\begin{proof}
Suppose the node sequence of the Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ is $\left\langle s_m\right\rangle _{m=1}^{\rho\theta}$, with an internal jump function
$f_{in}(m): \left\{1,2,...,\rho\theta\right\}\backslash\{\theta, 2\theta,\ldots,\rho\theta\}\rightarrow{\NN}\cup \{0\}$
and an external jump function
$f_{ex}(m): \left\{1, 2,...,\rho\right\}\rightarrow{\NN}\cup \{0\}$.
By the Definition \ref{eq:example_left_right1} of node sequence $\left\langle s_m\right\rangle _{m=1}^{\rho\theta}$ of Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$, we have $s_m\left(\in\Omega_n\right)$ is the node on which packet is dropped and WLOG for $m=1$ one can take $s_1=1$. If $p$ is the index of term $s_p$ in $\left\langle s_m\right\rangle_{m=1}^{\rho\theta}$ then for $p \neq 1$ and $p\leq\rho\theta$, following cases are raised.
\begin{enumerate}
\item If $\theta\mid p$ then $\theta^{th}$ packet is placed on $s_p$ for a cycle and first packet for the next cycle is placed on $s_{p+1}$. Hence there is external jump between packets dropped on node $s_p$ and node $s_{p+1}$.
Clearly $\frac{p}{\theta}$ gives the index number of jump completed at node $s_p$.
\item If $\theta\nmid p$ then both packets dropped on nodes indexed $s_p$ and $s_{p+1}$, are from same cycle so there is internal jump between the both nodes.
\end{enumerate}
Note that both cases can not fall on same node $s_m$ in node sequence $\left\langle s_m\right\rangle _{m=1}^{\rho\theta}$. Following case $1$ for $p=m-1$,
\begin{equation}
s_{m} = s_{m-1} + f_{ex}\left(\frac{m-1}{\theta}\right)+1,
\label{recursion on external}
\end{equation}
where $\theta\mid(m-1)$ and $m\in\{1,2,\ldots\rho\theta\}$.
Again for case $2$,
\begin{equation}
s_{m}=s_{m-1}+f_{in}\left(m-1\right)+1,
\label{recursion on internal}
\end{equation}
where $\theta\nmid(m-1)$ and $m\in\{1,2,\ldots\rho\theta\}$.
Hence one can have the following recursive equation by the above equations (\ref{recursion on external}) and (\ref{recursion on internal}) with boundary conditions $s_1=1$ and $s_i=0\ \forall i(\in{\NN})>\rho\theta$ on node sequence $\left\langle s_m\right\rangle_{m=1}^{\rho\theta}$.
\begin{equation}
s_{m} = \left\{ \,
\begin{array}{ll}
1 & :\mbox{ if } m=1; \\
s_{t} + f_{ex}(t_{ex})+1 & :\mbox{ if } \theta\mid t, 1<m\leq \rho\theta; \\
s_{t}+f_{in}(t)+1 & :\mbox{ if } \theta\nmid t, 1<m\leq \rho\theta; \\
0 & :\mbox{ if } m>\rho\theta,
\end{array}
\right.\label{recursive equastion}
\end{equation}
where $t_{ex} = \frac{m-1}{\theta}\mbox{ and }t = (m-1)$. Solving the recursive equation (\ref{recursive equastion}), one can get relation (\ref{Node sequence and jump}).
\end{proof}
\par Since each FR code can be represented by node sequence, dropping sequence and incidence matrix so each Flower code can also be represented by node sequence, dropping sequence and incidence matrix. The following lemmas establish the relation among those collectively. The lemmas are as follows.
\begin{lemma} Consider a dropping sequence $\left\langle d(m)\right\rangle_{m=1}^l$ for a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$. If $d(t)=1$ for any $t$ $(1\leq t\leq l)$ then binary node-packet distribution incidence matrix $M_{n \times \theta}$ = $[a_{ij}]_{n \times \theta}$ is given by $a_{ij}=1$, where
\begin{equation}
\begin{split}
& j = \left\{ \,
\begin{array}{ll}
\left[wt\left\langle d(m)\right\rangle_{m=1}^t\right](mod\ \theta) & :\mbox{ if } \theta\nmid\left[wt\left\langle d(m)\right\rangle_{m=1}^t\right]; \\
\theta & :\mbox{ if } \theta\mid\left[wt\left\langle d(m)\right\rangle_{m=1}^t\right].
\end{array}
\right. \\
& and \\
& i = \left\{ \,
\begin{array}{ll}
t\ (mod\ n) & :\mbox{ if } n\nmid t; \\
n & :\mbox{ if } n\mid t;
\end{array}
\right.
\end{split}
\end{equation}
\label{dropping sequence and matrix relation}
\end{lemma}
\begin{proof} Let $\left\langle d(m)\right\rangle_{m=1}^l$ be a dropping sequence for an FR code $\mathscr{C}: (n, \theta, \alpha, \rho)$ with $n$ nodes and $\theta$ packets.
For $d(m)=1$ ($d(t)\in\left\langle d(m)\right\rangle_{m=1}^l$), index of the packet associated with the $d(t)$ is mapped to weight of subsequence $\left\langle d(m)\right\rangle_{m=1}^l$. Hence the lemma.
\end{proof}
\begin{remark} If Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ has a non-binary incidence matrix then one can calculate the incidence matrix by the Algorithm \ref{algo for incidence matrix} using dropping sequence.
\line(-1,0){20}\line(1,0){240}
\begin{algorithm}
Algorithm to compute node-packet distribution incidence matrix $M_{n \times \theta}$ for Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$.
\label{algo for incidence matrix}
\end{algorithm}
\line(-1,0){20}\line(1,0){240}
\newline\textbf{REQUIRE} Dropping sequence $\left\langle d(m)\right\rangle_{m=1}^l$ of Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$.
\newline\textbf{ENSURE} Node-packet distribution incidence matrix $M_{n \times \theta}$.
{\footnotesize\begin{enumerate}
\item Initially $\forall i,j$ set $a_{ij}=0$ and $t=1\ where\ a_{ij}$ is the element of $M_{n\times\theta},1\leq i\leq n,\ 1\leq j\leq\theta\ and\ 1\leq t\leq l.$
\item If $d(t)=0$ then jump to step $3$ and if $d(t)=1$ then calculate $i,j$ and set $a_{ij}=a_{ij}+1$ and go to step $3$, $where$
\begin{equation*}
\begin{split}
& i = \left\{ \,
\begin{array}{ll}
t\ (mod\ n) & :\mbox{ if } n\nmid t; \\
n & :\mbox{ if } n\mid t;
\end{array}
\right. and \\
& j = \left\{ \,
\begin{array}{ll}
\left[wt\left\langle d(m)\right\rangle_{m=1}^t\right](mod\ \theta) & :\mbox{ if } \theta\nmid\left[wt\left\langle d(m)\right\rangle_{m=1}^t\right]; \\
\theta & :\mbox{ if } \theta\mid\left[wt\left\langle d(m)\right\rangle_{m=1}^t\right].
\end{array}
\right.
\end{split}
\end{equation*}
\item If $t<l$ then set $t=t+1$ and go to step $2$ otherwise stop.
\end{enumerate}}
\line(-1,0){20}\line(1,0){240}
\par It is clear that Algorithm \ref{algo for incidence matrix} is the generalization of Lemma \ref{dropping sequence and matrix relation}.
\end{remark}
\begin{lemma} Consider a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ with node sequence $\left\langle s_i\right\rangle_{i=1}^{\rho\theta}$. Its dropping sequence is given by $\left\langle d(m)\right\rangle_{m=1}^l\ s.t.\ \forall\ i,1\leq i\leq\rho\theta$
\begin{equation*}
d(m) = \left\{ \,
\begin{array}{ll}
1 & :\mbox{ if } m=\sum\limits_{j=1}^i\left(s_j-s_{j-1}\right)(mod\ n); \\
0 & :\mbox{ if } m\neq\sum\limits_{j=1}^i\left(s_j-s_{j-1}\right)(mod\ n),
\end{array}
\right.
\end{equation*}
where $s_o\ =\ 0$.
\end{lemma}
\begin{proof} For a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$, consider a dropping sequence $\left\langle d(m)\right\rangle_{m=1}^l$. By Definition \ref{node sequence}, two packets with consecutive indexes are associated with $s_i$ and $s_{i+1}$ for some $i$. Using Definition \ref{dropping sequence}, one can find that $[s_{i+1}-s_i](mod\ n)$ number of zeros exist between two consecutive $1$'$s$. In particular, the $1$'$s$ are associative with the two packets. It proves the lemma.
\end{proof}
\begin{lemma} Consider a Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha, \rho)$ with dropping sequence $\left\langle d(m)\right\rangle_{m=1}^l$. Its node sequence is given by $\left\langle s_i\right\rangle_{i=1}^{\rho\theta}\ s.t. \forall\ t\ (1\leq t\leq l)\ with\ d(t)=1$,
\begin{equation*}
i = wt\left\langle d(m)\right\rangle_{m=1}^t
\end{equation*}
and
\begin{equation*}
s_i = \left\{ \,
\begin{array}{ll}
t\ (mod\ n) & :\mbox{ if } n\nmid t; \\
n & :\mbox{ if } n\mid t.
\end{array}
\right. \\
\end{equation*}
\end{lemma}
\begin{proof}
Using Definition \ref{node sequence} and Definition \ref{dropping sequence}, one can easily prove the lemma by observing that the weight of subsequence $\left\langle d(m)\right\rangle_{m=1}^t$ is associated with the packet for $d(t)=1$.
\end{proof}
These sequence construction approaches suggest that one can construct an FR code from any arbitrary finite binary sequence by treating it as a characteristic sequence of dropping packets on the nodes. This can be done in different ways by choosing appropriate sequences of symbols. Hence, an arbitrary finite binary sequence $\left\langle \chi(m)\right\rangle_{m=1}^{\ell}\ (\chi(m)\in{\ZZ}_2)$ with length $\ell(\in{\NN})$ can be defined as a characteristic sequence for an FR code. In the sequence, value $\chi(m)=1$ represents to drop (value $\chi(m)=0$ not to drop) a packet on certain node.
Hence a more general Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ can be defined as follows.
\begin{definition} (Flower code): For $n$ nodes, $\theta$ packets and an arbitrary binary sequence $\left\langle \chi(m)\right\rangle_{m=1}^{\ell}\ (\chi(m)\in{\ZZ}_2)$ of length $\ell(\in{\NN})$ (treated as characteristic sequence indexed by $m$), Flower code $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ can be defined as a system in which packet indexed by $m(mod\ \theta)$ is dropped on node indexed by $m(mod\ n)$ iff $\chi(m)=1$, where $P_0$ and $U_0$ are mapped to packet $P_{\theta}$ and node $U_n$ respectively. Clearly $\alpha_i=\sum_{m=0}^{\left\lfloor \frac{\ell-i}{n}\right\rfloor}\chi(i+nm)$ and $\rho_j=\sum_{m=0}^{\left\lfloor \frac{\ell-j}{\theta}\right\rfloor}\chi(j+\theta m)$.
\label{Flower}
\end{definition}
\begin{example}
For given $n=4$, $\theta=5$ and a binary characteristic sequence $\left\langle \chi(m)\right\rangle_{m=1}^{16}$ = $\left\langle 1,1,0,1,0,0,1,1,1,1,1,1,\right.$ $\left. 0,1,0,1\right\rangle$, one can find Node packet distribution of Flower code $\mathscr{F}_{\mathscr{C}}:\ (4, 5, 3, 2)$ as shown in Table \ref{3}
\begin{table}[ht]
\caption{Node-Packet Distribution for Flower code $\mathscr{F}_{\mathscr{C}}:\ (4, 5, 4, 3)$.}
\centering
\begin{tabular}{|c||c|c|}
\hline
\textbf{Nodes $U_i$} &\textbf{Packets distribution} & \textbf{Repair degree $d_i$} \\[0.5ex]
\hline\hline
$U_1$& $P_1,\ P_4$ & 2\\ \hline
$U_2$& $P_2,\ P_4\ P_5$ & 3\\ \hline
$U_3$& $P_1,\ P_2,\ P_5$ & 3\\ \hline
$U_4$& $P_1,\ P_2,\ P_3,\ P_4$& 4\\ \hline
\end{tabular}
\label{3}
\end{table}
\end{example}
\begin{remark}
Flower codes $\mathscr{F}_{\mathscr{C}}: (n, \theta, \alpha , \rho)$ (Definition \ref{Flower}) with different packet replication factor $\rho_j$ $(j\in\Omega_{\theta})$ can also be constructed using any binary sequence $\left\langle \chi(m)\right\rangle_{m=1}^{\ell}$.
\end{remark}
\section{Conclusion}
This paper introduces a novel class of FR codes based on sequences. It will be an interesting future task to find a condition when Flower codes are optimal (in sense of the capacity). Our work opens a nice connection of FR codes with well known area of sequences. It would be an interesting future task to study FR codes by using well known class of sequences.
\bibliographystyle{IEEEtran}
|
{'timestamp': '2015-06-23T02:13:54', 'yymm': '1506', 'arxiv_id': '1506.05313', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05313'}
|
arxiv
|
\section{Introduction}
Traditional analysis of fMRI data focused primarily on studying the patterns of individual brain regions.
Recently, there has been a growing interest in understanding relationships between distinct regions; referred to as
brain connectivity.
The subsequent study of brain connectivity has provided fundamental insights into the
human brain \citep{bullmore}.
A cornerstone in the understanding of brain connectivity is the notion that
connectivity can be represented as a graph or network composed of a set of nodes interconnected by
a set of edges.
Nodes can represent anything from individual
voxels to entire regions of interest (ROIs). Here each node
is associated with its own time course of imaging data. This
can subsequently be used to estimate the connections between
nodes, defined as the edge structure of the network.
In this work we consider estimating edge structure according to
statistical dependencies between nodes.
The resulting networks are referred to as
functional connectivity networks.
Until recently, functional connectivity networks had been assumed to be stationary. This implied that only a
global measure of dependency was considered for each pair of nodes. However, there is growing evidence
to suggest that functional connectivity networks are highly non-stationary \citep{allen2012tracking}.
This has lead to mounting interest in quantifying dynamic changes in brain connectivity and has
resulted in the proposal of several novel methodologies \citep{allen2012tracking, leonardi2013principal, monti2014estimating}.
Such methodologies have provided unprecedented details relating to the restructuring and
temporal evolution of functional connectivity networks.
However, understanding and interpreting the high-dimensional output
provided by such methods has posed novel statistical challenges.
Many of these challenges arise from the fact that while graphs offer a
rich representation of the data at hand, measuring similarities across
multiple graphs remains non-trivial.
One potential method with which to address this issue is
to employ graph embedding techniques.
Briefly, such methods look
to map estimated graphs or networks down to a
low-dimensional vector space. Such methods have been shown to be well-suited
to the task of classifying functional networks;
often referred to as brain decoding
\citep{richiardi2011decoding}.
The objectives of this work are two fold. First, we present an extensive study of the working memory
HCP data \citep{elam2014human} using the recently proposed
Smooth Incremental Graphical Lasso Estimation (SINGLE) algorithm \citep{monti2014estimating}.
Second, the estimated functional connectivity networks are then studied
using two distinct graph embedding algorithms.
The first is based on Principal Component Analysis (PCA) and is strongly related to the eigen-connectivity method
developed in \cite{leonardi2013principal}. This embedding can be interpreted a mapping from
networks to a low-dimensional vector space that captures the maximal variability.
The second approach corresponds to a novel supervised embedding algorithm which is based on Linear
Discriminant Analysis (LDA).
This algorithm can be interpreted as a mapping to a low-dimensional vector space that maximizes
discriminatory power across the various tasks or states.
The strengths of these embeddings is that they are both based on
linear projections. As a result, the transformation described by the
embeddings can be directly interpreted as a functional connectivity network.
The remainder of this paper is organised as follows: in Section \ref{methods_sec} we describe two distinct
graph embedding algorithms. These are applied to HCP data in Section \ref{ResultSection}.
\section{Methods}
\label{methods_sec}
Throughout this section it is assumed we have access to fMRI time series over a fixed set of $p$ nodes for $S$ subjects.
We write $X^{(s)} \in \mathbb{R}^{n \times p}, s \in \{1, \ldots, S\}$ to denote the
observed time series for the $s$th subject.
We write $X_i^{(s)} \in \mathbb{R}^{1 \times p}$ to
denote the BOLD measurements at the $i$th observation for $i=1, \ldots, n$.
For each subject, we first look to estimate time-varying functional connectivity
networks at each point in time. This is achieved using the
recently proposed Smooth Incremental Graphical Lasso Estimation (SINGLE) algorithm \citep{monti2014estimating}.
The resulting estimates over all subjects are then studied using two distinct graph embedding
methods.
The first method is strongly related to the eigen-connectivities method of \cite{leonardi2013principal}
and is designed to provide a low-dimensional embedding which maximizes explained variance.
The second method is a novel supervised embedding method based on Linear Discriminant Analysis (LDA).
Here the objective is to obtain a low-dimensional embedding which provides the maximum discriminatory
power between various classes (in the case of HCP data these will be the various tasks undertaken by the subject).
The remainder of this section is organized as follows: in Section \ref{SINGLE} we describe the method used to
obtain time-varying estimates of functional connectivity networks for each subject independently.
In Sections \ref{PCAembed} and \ref{LDAembed} the two graph embedding methodologies are described.
\subsection{Estimating non-stationary functional connectivity networks}
\label{SINGLE}
In this section, we infer dynamic functional connectivity networks by estimating the corresponding
precision (inverse covariance) matrix at each observation. Thus, for the $s$th subject we estimate
a sequence of precision matrices $\{\Theta^{(s)}_i\} = \{ \Theta^{(s)}_1, \ldots, \Theta_n^{(s)} \}$.
Here $\Theta^{(s)}_i \in \mathbb{R}^{p \times p}$ encodes the partial correlation structure at the $i$th observation
for subject $s$. It follows that we can encode $\Theta^{(s)}_i$ as a graph $G^{(s)}_i$ where
the presence of an edge implies a non-zero entry in the corresponding entry of the precision matrix.
The SINGLE algorithm was employed to estimate time-varying precision matrices, $\{\Theta^{(s)}\}$,
for each of the $S$ subjects independently.
The SINGLE algorithm is able to accurately estimate functional connectivity networks
by enforcing sparsity and temporal homogeneity constraints.
Sparsity
is introduced in order to
ensure the estimation problem was well-posed as well as to remove spurious edges introduced by noise.
Meanwhile, the introduction of temporal homogeneity is motivated by a desire to ensure
changes in functional connectivity are only reported when strongly corroborated by evidence in the data.
The SINGLE algorithm therefore seeks to find a balance between adequately describing the observed
data while satisfying the aforementioned constraints by minimizing the following
convex objective:
\begin{equation}
\label{SINGLE_cost}
\{\hat \Theta_i^{(s)}\} = \underset{\Theta_i^{(s)}}{\mbox{argmin}} \left \{f(\{\Theta_i^{(s)}\}) + g_{\lambda_1, \lambda_2}(\{\Theta_i^{(s)}\}) \right \}.
\end{equation}
Here $f(\{\Theta_i^{(s)}\}) = \sum_{i=1}^T -\mbox{log det } \Theta_i^{(s)} + \mbox{trace } ( \hat \Sigma_i^{(s)} \Theta_i^{(s)})$
is proportional to the
sum of negative log-likelihoods where $\hat \Sigma_i^{(s)}$ is the estimated covariance at time $i$.
The penalty terms are enforced by the second term:
$$g_{\lambda_1, \lambda_2}(\{\Theta_i^{(s)} \}) = \lambda_1 \sum_{i=1}^T || \Theta_i^{(s)}||_1 + \lambda_2 \sum_{i=2}^T || \Theta_i^{(s)} - \Theta_{i-1}^{(s)}||_1. $$
Regularization
parameters $\lambda_1$ and $\lambda_2$ each determine the extent of sparsity and temporal homogeneity respectively
and can be tuned in a data-driven manner.
\subsection{Graph embedding}
Having obtained functional connectivity estimates, $\{ \Theta^{(s)}_i\}$ for all $S$ subjects
we turn to the problem of graph embedding.
Graph embeddings methods allow us to represent graphs or networks in (potentially low-dimensional) vector spaces.
Such methods are beneficial as there is no ``standard'' method to measure distances
between graphs \citep{richiardi2010vector} while vectors are easily interpretable and
can be studied in a variety of ways. Moreover, as we will discuss below, the embeddings
studied here consist of linear projections and therefore yield a unique
interpretation in terms of
functional connectivity networks.
We begin
by first calculating the Laplacian of each estimated functional connectivity network:
\begin{equation}
L_i^{(s)} = (D^{(s)}_i)^{-\frac{1}{2}} (D^{(s)}_i - \Theta^{(s)}_i ) (D^{(s)}_i)^{-\frac{1}{2}},
\end{equation}
where $D^{(s)}_i$ is a diagonal matrix containing the variance of each node respectively.
It therefore follows that each $L^{(s)}_i$ is fully characterized the its $\binom{p}{2}$ upper-triangular entries.
In the following sections we will use $\{L^{(s)}_i\}$ directly to perform graph embedding.
We define
\begin{equation}
\mbox{vec}(L^{(s)}) = \mathbb{R}^{n \times \binom{p}{2}}
\end{equation}
as a matrix where the $i$th row corresponds to the vectorized upper-triangular entries of
the Laplacian
at the $i$th observation.
The matrix, $L$, consisting of all vectorized Laplacians across all subjects can subsequently
be defined as:
\begin{equation}
L = \left [ \mbox{vec}(L^{(1)})^T, \ldots \mbox{vec}(L^{(S)})^T \right ]^T \in \mathbb{R}^{ S \cdot n \times \binom{p}{2}}.
\end{equation}
This process is described in Figure [\ref{TheFig}a].
It
follows that each column of $L$ corresponds directly to one of the $\binom{p}{2}$ possible edges.
As both embeddings studied here consist of linear projections of $L$ onto lower-dimensional subspaces,
they can each be understood as a
a linear combination of edges and interpreted as
functional connectivity networks.
\subsubsection{Unsupervised PCA-driven embedding}
\label{PCAembed}
Here we look to obtain a low-dimensional embedding that maximizes the amount of explained variance.
Following from the method described in \cite{leonardi2013principal}, we
look to achieve this by applying Principal Component Analysis (PCA) to $L$.
This will yield the linear combination of edges that best summarize the variability in
functional connectivity networks over time.
Formally, PCA is an unsupervised dimensionality reduction technique which produces a
new set of uncorrelated variables. This is
achieved by considering the $k$ leading eigenvectors of the covariance matrix $ L^T L$,
defined as the principal components $P_k \in \mathbb{R}^{k \times \binom{p}{2}}$.
The principal components, $P_k$, can be studied in two ways.
By considering the entries of each principal component we
are able to quantify the contribution of the corresponding edges.
Edges which vary highly with a dataset
can therefore be expected to provide a large contribution to the leading principal
components.
Moreover, the embedding produced by $P_k$ is obtained as:
\begin{equation}
P_k \cdot \mbox{vec}(L^{(s)}) \in \mathbb{R}^{k \times n}.
\end{equation}
This yields a $k$-dimensional graph embedding for each subject at each of the $n$ observations.
\subsubsection{Supervised LDA-driven embedding}
\label{LDAembed}
While the PCA-driven embedding was
motivated by understanding the components of
functional connectivity which
demonstrated the greatest variability,
we may also be interested in understanding which functional networks are
most discriminative across multiple tasks. As a result, a supervised learning approach is taken here.
We propose the use of LDA to learn the functional connectivity networks which are
most discriminative between tasks.
LDA is a simple and robust classification algorithm,
but more importantly,
LDA can also be interpreted as a linear projection.
As a result, LDA reports the linear combination of edges which are most discriminative
between tasks. These can subsequently be interpreted as
a discriminative embedding which reports changes in functional
connectivity induced by a given task.
In such a high-dimensional supervised learning problems it is of paramount importance to avoid overfitting.
Two popular methods to guard against overfitting involve the introduction of
regularization,
thereby penalizing overly complex models which are more
susceptible to overfitting,
and cross-validation.
Here a combination of both approaches was employed.
First a variable screening procedure was applied, reducing the
number of candidate variables (i.e., edges) to $p' << \binom{p}{2}$.
This serves to greatly reduce the risk of overfitting as well as
yield a sparse embedding which is easily interpretable.
The remaining $p'$ selected edges are subsequently used to train
an LDA classifier.
Such a classifier will learn the linear projection of selected edges
which is most discriminative across tasks. This projection will serve
as our LDA-driven embedding.
The screening method employed in this work selected the most reproducible
edges across all $S$ subjects. This was achieved by fitting an independent
LDA classifier for the data of each subject. Due to the limited observations per subject, regularization was introduced in the form of an $l_1$ penalty.
As a result, an $l_1$ penalized LDA model was estimated for each subject.
Such models can be estimated efficiently as described in \citep{clemmensen2011sparse}
and provide the additional benefit of performing variable selection.
It follows that the regularization parameter will play a fundamental role in
the variable selection procedure and must therefore be carefully
tuned.
This issue was addressed via the use of a cross-validation scheme.
The variables which were consistently
selected across all subjects where retained and all others discarded.
Such a screening approach can be interpreted as performing stability selection, as
described in \citep{meinshausen2010stability}, where the sub-sampling
is performed by studying each subject independently.
This serves to discard a large number of
noisy and non-informative variables, yielding a
Laplacian matrix, $L' \in \mathbb{R}^{S \cdot n \times p'}$,
consisting of only selected variables which have
demonstrated reproducible discriminative power
across all subjects.
\section{Materials and Results}
\label{ResultSection}
Working Memory (WM) task data from the Human Connectome Project \cite{elam2014human} was studied with
$S=206$ of the 500 available subjects selected at random.
During the tasks subjects were presented with blocks of trails
consisting of either 0-back or 2-back WM tasks.
For each subject both a LR and a RL acquisition dataset was studied, however, they were treated as
separate scans and studied separately throughout. Thus
a total of $2 \times 206=412$ datasets were studied.
Preprocessing involved regression of Friston’s 24 motion parameters from the fMRI data.
Sixty-eight cortical and 16 subcortical ROIs were derived from
the Desikan-Killiany atlas and the ASEG atlas,
respectively. Mean BOLD timeseries for each of these 84 ROIs were extracted and further
cleaned by regressing out timeseries sampled from white matter and cerebrospinal fluid.
Finally, the extracted timecourses were high-pass filtering using a cut-off frequency of $\frac{1}{130}$ Hz.
\subsection{PCA-driven embedding results}
The objective of PCA-driven embedding is to provide a low-dimensional embedding
which captures a large portion of the variability present in the data.
This was achieved in an unsupervised manner by considering
the leading $k=2$ principal components of Laplacian matrix $L$.
The leading $k=2$ components were considered
here as the emphasis lay on visualization, however further components
could also be studied.
In this section, both the LR and RL acquisitions for each subject were
considered simultaneously as the goal was to understand variability across
the entire population.
Figure [\ref{TheFig}b] shows the average
embeddings across all $S$ subjects\footnote{Note: only LR acquisition datasets
plotted here, as the task design varied from LR to RL acquisitions.}.
The background is colored to denote the task taking place at each point in time;
green is used to denote 2-back WM task
while purple denotes a 0-back WM task and a white background is indicative of rest.
We note that in the case of both embeddings
there is a clear oscillatory pattern which is
strongly correlated with the task. Moreover, the two embeddings are lagged,
with the second principal component embedding peaking immediately after
the first.
The functional connectivity networks associated with these embeddings are
shown in Figures [\ref{TheFig}c].
These networks have
been thresholded to retain only 2\% of edges with the largest absolute value.
It can be seen that they reflect independent networks dynamics.
The first component appears to reflect stronger inter-hemispheric coupling, particularly between
motor regions.
The second
component appears to reflect
increased intra-hemispheric long-range connections between frontal and parietal regions.
\subsection{LDA-driven embedding results}
The motivation behind the use of LDA-driven embedding is to provide an
interpretable embedding which is highly discriminative across
various tasks. In this section, we studied the contrast between
the 0-back and 2-back WM tasks.
As noted previously, two datasets where available for each subject. In such a
supervised learning task it is important to differentiate between
the LR and RL acquisition datasets as they each employed a distinct task-design.
The approach taken here was to build an LDA-driven embedding using only the LR
acquisition datasets across all subjects and then validate this model using
the unseen RL acquisition datasets.
All $\binom{p}{2}$ potential edges were screened as described previously and
only those selected over 60\% of the time were studied. This reduced
the number of candidate edges to $p'=126 << \binom{p}{2}$.
Figure [\ref{TheFig}b] shows the results of applying
the LDA-driven embedding to the unseen RL acquisition datasets, averaged
across all $S$ subjects. We note
the resulting embedding is strongly correlated with the onset of the
0-back WM task (denoted by the purple background).
This serves as evidence that the estimated LDA-driven embedding is
able to discriminate between the two WM tasks in a validation dataset.
The corresponding functional connectivity network
associated estimate LDA-driven embedding is shown in Figure [\ref{TheFig}c].
We note that the higher loading task condition (2-back WM task; characterized by red edges in Figure [\ref{TheFig}ciii])
is associated with stronger long-range inter-hemispheric connections.
\section{Conclusion}
We present results from applying two graph embedding methods to HCP working memory task data for
206 subjects. Both of the embedding methods studied here are based on
linear projections and therefore yield embeddings that
are easily interpretable in terms of functional connectivity networks.
The first method studied here is closely related to the eigen-connectivities method
introduced in \citep{leonardi2013principal}. Here PCA is employed to
capture variability throughout a task across a population of subjects.
The second graph embedding method studied corresponds to a novel supervised embedding
algorithm. First, a screening step drastically reduces the total number of potential
in order to yield interpretable embeddings and avoid overfitting.
LDA is subsequently used to obtain an embedding that is discriminative across tasks.
In future, such approaches could be applied to the full range of
task data provided by the HCP.
In addition, we note that the
SINGLE algorithm requires
the input of two regularization parameters which will ultimately affect
the results of the approaches discussed.
Future work would involve studying the sensitivity of each method to the choice of such parameters.
\section*{acknowledgement}
The data was provided by the Human Connectome Project.
\begin{figure}[h]
\centering
\fbox{\includegraphics[width=.4\paperwidth, height=.65\paperheight]{FinalFigCamera.png}}
\caption{\textbf{a)} The various steps involved in the proposed embedding method are visualized: 1) the SINGLE algorithm is used
to obtain estimates of time-varying precision matrices. 2) The precision matrices are transformed to Laplacian matrices.
3) The Laplacian matrices are vectorized by taking their upper-triangular components.
4) The vectorized Laplacians of all subjects are stacked vertically.
5) Finally the PCA/LDA-driven embeddings are estimated.
\textbf{b)} The results for the PCA-driven embeddings are plotted for the LR acquisition datasets. We note there is a
clear periodicity which is strongly correlated with task onset.
The results for LDA-driven embeddings are also shown for unseen RL acquisition datasets.
We note these are strongly correlated with 0-back
task onset.
\textbf{c)} Functional connectivity networks associated with various embeddings
(negative edges shown in red, positive in blue)
\textbf{i)} first principal component embedding,
\textbf{ii)} second principal component embedding and \textbf{iii)} LDA-driven embedding.
In the case of the PCA-embeddings the networks where thresholded to leave only 2\% of edges with largest absolute value.
}
\label{TheFig}
\end{figure}
{\footnotesize
\bibliographystyle{unsrtnat}
|
{'timestamp': '2015-06-18T02:09:48', 'yymm': '1506', 'arxiv_id': '1506.05219', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05219'}
|
arxiv
|
\section{Introduction}
We consider the problem of learning to predict a non-negative measure over a finite set. This problem includes many common machine learning scenarios. In multiclass classification, for example, one often predicts a vector of scores or probabilities for the classes. And in semantic segmentation \cite{long-shelhamer-fcn}, one can model the segmentation as being the support of a measure defined over the pixel locations. Many problems in which the output of the learning machine is both non-negative and multi-dimensional might be cast as predicting a measure.
We specifically focus on problems in which the output space has a natural metric or similarity structure, which is known (or estimated) {\it a priori}. In practice, many learning problems have such structure. In the ImageNet Large Scale Visual Recognition Challenge [ILSVRC] \cite{ILSVRC15}, for example, the output dimensions correspond to 1000 object categories that have inherent semantic relationships, some of which are captured in the WordNet hierarchy that accompanies the categories. Similarly, in the keyword spotting task from the IARPA Babel speech recognition project, the outputs correspond to keywords that likewise have semantic relationships. In what follows, we will call the similarity structure on the label space the \emph{ground metric} or \emph{semantic similarity}.
Using the ground metric, we can measure prediction performance in a way that is sensitive to relationships between the different output dimensions. For example, confusing dogs with cats might be more severe an error than confusing breeds of dogs. A loss function that incorporates this metric might encourage the learning algorithm to favor predictions that are, if not completely accurate, at least semantically similar to the ground truth.
\begin{floatingfigure}[r]{0.33\textwidth}
\centering\vskip-.8em
\includegraphics[width=0.15\textwidth]{Siberian-husky
\hspace{3pt}
\includegraphics[width=0.15\textwidth]{Eskimo-dog-husky
\scriptsize \hspace{1em} Siberian husky \hspace{3em} Eskimo dog
\caption{Semantically near-equivalent classes in ILSVRC}
\label{fig:dogs}
\end{floatingfigure}
In this paper, we develop a loss function for multi-label learning that measures the \emph{Wasserstein distance} between a prediction and the target label, with respect to a chosen metric on the output space. The Wasserstein distance is defined as the cost of the optimal transport plan for moving the mass in the predicted measure to match that in the target, and has been applied to a wide range of problems, including barycenter estimation \cite{Cuturi:2014vh}, label propagation \cite{Solomon:2014ts}, and clustering \cite{Coen:2010ut}. To our knowledge, this paper represents the first use of the Wasserstein distance as a loss for supervised learning.
We briefly describe a case in which the Wasserstein loss improves learning performance. The setting is a multiclass classification problem in which label noise arises from confusion of semantically near-equivalent categories. Figure \ref{fig:dogs} shows such a case from the ILSVRC, in which the categories \emph{Siberian husky} and \emph{Eskimo dog} are nearly indistinguishable. We synthesize a toy version of this problem by identifying categories with points in the Euclidean plane and randomly switching the training labels to nearby classes. The Wasserstein loss yields predictions that are closer to the ground truth, robustly across all noise levels, as shown in Figure~\ref{fig:lattice}. The standard multiclass logistic loss is the baseline for comparison. Section~\ref{sec:lattice-details} in the Appendix describes the experiment in more detail.
\begin{figure}
\centering
\begin{subfigure}[b]{0.49\textwidth}
\resizebox{\linewidth}{!}{
\input{grid-mean.pgf
}\vskip-.4em
\end{subfigure}\hfill
\begin{subfigure}[b]{0.49\textwidth}
\resizebox{\linewidth}{!}{
\input{noise-mean.pgf
}\vskip-.4em
\end{subfigure}
\caption{The Wasserstein loss encourages predictions that are similar to ground truth, robustly to incorrect labeling of similar classes (see Appendix \ref{sec:lattice-details}). Shown is Euclidean distance between prediction and ground truth vs. (left) number of classes, averaged over different noise levels and (right) noise level, averaged over number of classes. Baseline is the multiclass logistic loss.}
\vskip-0.5cm
\label{fig:lattice}
\end{figure}
The main contributions of this paper are as follows. We formulate the problem of learning with prior knowledge of the ground metric, and propose the Wasserstein loss as an alternative to traditional information divergence-based loss functions. Specifically, we focus on empirical risk minimization (ERM) with the Wasserstein loss, and describe an efficient learning algorithm based on entropic regularization of the optimal transport problem. We also describe a novel extension to unnormalized measures that is similarly efficient to compute. We then justify ERM with the Wasserstein loss by showing a statistical learning bound. Finally, we evaluate the proposed loss on both synthetic examples and a real-world image annotation problem, demonstrating benefits for incorporating an output metric into the loss.
\section{Related work}
Decomposable loss functions like KL Divergence and $\ell_p$ distances are very popular for probabilistic \cite{long-shelhamer-fcn} or vector-valued \cite{MAL-036} predictions, as each component can be evaluated independently, often leading to simple and efficient algorithms.
The idea of exploiting smoothness in the label space
according to a prior metric has been explored in many different forms, including regularization \cite
{rudin1992nonlinear} and post-processing with graphical models \cite{chen14semantic}. Optimal transport provides a natural distance for probability distributions over metric spaces. In \cite
{Cuturi:2014vh, Cuturi:2015ue}, the optimal transport is used to formulate the Wasserstein barycenter as a probability distribution with minimum total Wasserstein distance to a set of given points on the probability simplex. \cite{Solomon:2014ts} propagates histogram values on a graph by minimizing a Dirichlet energy induced by optimal transport. The
Wasserstein distance is also used to formulate a metric for comparing clusters in \cite{Coen:2010ut}, and is applied to image retrieval \cite{rubner2000earth}, contour matching \cite{grauman2004fast}, and many other problems \cite{Shirdhonkar2008-sc, persistent}. However, to our knowledge, this is the first time it is used as a loss function in a discriminative learning framework. The closest work to this paper is a theoretical study \cite{Bassetti2006-nu} of an estimator that minimizes the optimal transport cost between the empirical distribution and the estimated distribution in the setting of statistical parameter estimation.
\section{Learning with a Wasserstein loss}
\subsection{Problem setup and notation}
We consider the problem of learning a map from $\mathcal{X}\subset\mathbb{R}^{D}$ into the space $\mathcal{Y} = \mathbb{R}_+^K$ of measures over a finite set $\mathcal{K}$ of size $|\mathcal{K}|=K$. Assume $\mathcal{K}$ possesses a metric
$d_\mathcal{K}(\cdot,\cdot)$, which is called the \emph{ground metric}. $d_\mathcal{K}$ measures semantic similarity between dimensions of the output, which correspond to the elements of $\mathcal{K}$.
We perform learning over a hypothesis space $\mathcal{H}$ of predictors
$h_\theta:\mathcal{X}\rightarrow \mathcal{Y}$,
parameterized by $\theta\in\Theta$. These might be linear logistic regression models, for example.
In the standard statistical learning setting, we get an i.i.d. sequence of training examples
$S=((x_1,y_1),\ldots,(x_N,y_N))$, sampled from an unknown joint distribution
$\mathcal{P}_{\mathcal{X}\times\mathcal{Y}}$. Given a
measure of performance (a.k.a. \emph{risk}) $\mathcal{E}(\cdot,\cdot)$, the goal is to find the predictor
$h_\theta\in\mathcal{H}$ that minimizes the expected risk
$\mathbb{E}[\mathcal{E}(h_\theta(x), y)]$. Typically $\mathcal{E}(\cdot,\cdot)$ is
difficult to optimize directly and the joint distribution $\mathcal{P}_{\mathcal{X}\times\mathcal{Y}}$ is
unknown, so learning is performed via \emph{empirical risk minimization}. Specifically, we \textbf{}solve
\begin{equation}
\min_{h_\theta\in\mathcal{H}} \left\{ \hat{\mathbb{E}}_S[\ell(h_\theta(x),y)
= \frac{1}{N}\sum_{i=1}^N \ell(h_\theta(x_i),y_i) \right\}
\label{eq:erm-obj}
\end{equation}
with a loss function $\ell(\cdot,\cdot)$ acting as a surrogate of $\mathcal{E}(\cdot,\cdot)$.
\subsection{Optimal transport and the exact Wasserstein loss}
Information divergence-based loss functions are widely used in learning with probability-valued outputs. Along
with other popular measures like Hellinger distance and $\chi^2$ distance, these divergences treat the output dimensions independently, ignoring any metric structure on $\mathcal{K}$.
Given a cost function $c:\mathcal{K}\times\mathcal
{K}\rightarrow\mathbb{R}$, the \emph {optimal transport} distance \cite{villani2008optimal} measures the cheapest way to transport the mass in probability measure $\mu_1$ to match that in $\mu_2$:
\begin{equation}
\label{eq:optimal-transport}
W_c(\mu_1,\mu_2) = \inf_{\gamma \in\Pi(\mu_1,\mu_2)}\int_{\mathcal{K}\times\mathcal{K}} c
(\kappa_1,\kappa_2) \gamma(d\kappa_1,d\kappa_2)
\end{equation}
where $\Pi(\mu_1,\mu_2)$ is the set of joint probability measures on $\mathcal{K}\times\mathcal{K}$
having $\mu_1$ and $\mu_2$ as marginals. An important case is
that in which the cost is given by a metric $d_\mathcal{K}(\cdot,\cdot)$ or its $p$-th power $d^p_\mathcal{K}
(\cdot,\cdot)$ with $p\geq 1$. In this case, \eqref{eq:optimal-transport} is called a \emph{Wasserstein distance} \cite
{Bogachev2012-gm}, also known as the \emph {earth mover's distance} \cite{rubner2000earth}. In this
paper, we only work with discrete measures. In the case of probability measures, these are histograms in the simplex $\Delta^\mathcal{K}$. When the ground truth $y$ and the output of $h$ both lie in the simplex $\Delta^{\mathcal{K}}$, we can define a Wasserstein loss.
\begin{definition}[Exact Wasserstein Loss]
For any $h_\theta\in\mathcal{H}$, $h_{\theta} : \mathcal{X} \rightarrow \Delta^{\mathcal{K}}$, let $h_\theta(\kappa|x)=h_
{\theta} (x)_\kappa$ be the predicted value at element $\kappa\in\mathcal{K}$, given input $x\in\mathcal{X}$. Let $y(\kappa)$ be the ground truth value for $\kappa$ given by the corresponding label $y$.
Then we define the \emph{exact Wasserstein loss} as
\begin{equation}
W_p^p(h(\cdot|x), y(\cdot)) = \inf_{T\in\Pi(h(x),y)} \langle T,
M\rangle
\label{eq:wasserstein-loss}
\end{equation}
where $M\in\mathbb{R}^{K\times K}_+$ is the distance matrix $M_{\kappa,\kappa'}=d_\mathcal {K}^p
(\kappa,\kappa')$, and the set of valid transport plans is
\begin{equation}
\Pi(h(x),y) = \{T\in\mathbb{R}^{K\times K}_+: T\mathbf{1}=h(x),\;
T^\top\mathbf{1} = y\}
\label{eq:transport-polytope}
\end{equation}
where $\mathbf{1}$ is the all-one vector.
\end{definition}
$W_p^p$ is the cost of the optimal plan for transporting the predicted mass distribution $h(x)$ to match the target distribution $y$. The penalty increases as more mass is transported over longer distances, according
to the ground metric $M$.
\section{Efficient optimization via entropic regularization}
\label{sec:Wass-computation}
\begin{algorithm}
\caption{Gradient of the Wasserstein loss}
\begin{algorithmic}
\State Given $h(x)$, $y$, $\lambda$, $\mathbf{K}$. ($\gamma_a$, $\gamma_b$ if $h(x)$, $y$ unnormalized.)
\State $u \gets \mathbf{1}$
\While{$u$ has not converged}
\State $u \gets \bigbrace{h(x) \oslash \lr{\mathbf{K} \lr{y \oslash \mathbf{K}^\top u}} & \text{if $h(x)$, $y$ normalized} \\
h(x)^{\frac{\gamma_a \lambda}{\gamma_a \lambda + 1}} \oslash \lr{\mathbf{K} \lr{y \oslash \mathbf{K}^\top u}^{\frac{\gamma_b \lambda}{\gamma_b \lambda + 1}}}^{\frac{\gamma_a \lambda}{\gamma_a \lambda + 1}} & \text{if $h(x)$, $y$ unnormalized}}$
\EndWhile
\State If $h(x)$, $y$ unnormalized: $v \gets y^{\frac{\gamma_b \lambda}{\gamma_b \lambda + 1}} \oslash \lr{\mathbf{K}^\top u}^{\frac{\gamma_b \lambda}{\gamma_b \lambda + 1}}$
\State $\partial W_p^p/\partial h(x) \gets \bigbrace{\frac{\log u}{\lambda} - \frac{\log u^\top \mathbf{1}}{\lambda K} \mathbf{1} & \text{if $h(x)$, $y$ normalized} \\
\gamma_a \lr{\mathbf{1} - (\diag u \mathbf{K} v) \oslash h(x)} & \text{if $h(x)$, $y$ unnormalized}}$
\end{algorithmic}
\label{algo:subgradient}
\end{algorithm}
To do learning, we optimize the empirical risk minimization functional \eqref{eq:erm-obj} by gradient descent. Doing so requires evaluating a descent direction for the loss, with respect to the predictions $h(x)$. Unfortunately, computing a subgradient of the exact Wasserstein loss \eqref{eq:wasserstein-loss}, is quite costly, as follows.
The exact Wasserstein loss \eqref{eq:wasserstein-loss} is a linear program and a subgradient of its solution can be computed using Lagrange duality.
The dual LP of \eqref{eq:wasserstein-loss} is
\begin{equation}
^dW_p^p(h(x), y) = \sup_{\alpha,\beta\in C_M} \alpha^\top h(x) + \beta^\top y, \quad
C_M = \{(\alpha,\beta)\in\mathbb{R}^{K \times K}: \alpha_{\kappa}+\beta_{\kappa'} \leq M_{\kappa, \kappa'}\}.
\end{equation}
As \eqref{eq:wasserstein-loss} is a linear program, at an optimum the values of the dual and the primal are equal (see, e.g. \cite{introLP}), hence the dual optimal $\alpha$ is a subgradient of the loss with respect to its first argument.
Computing $\alpha$ is costly, as it entails solving a linear program with $O(K^2)$ contraints, with $K$ being the dimension of the output space. This cost can be prohibitive when optimizing by gradient descent.
\subsection{Entropic regularization of optimal transport}
Cuturi \cite{Cuturi:2013wo} proposes a smoothed transport objective that enables efficient approximation of both the transport matrix in \eqref{eq:wasserstein-loss} and the subgradient of the loss. \cite{Cuturi:2013wo} introduces an entropic regularization term that results in a strictly convex problem:
\begin{equation}
\label{eq:regularized-primal}
^\lambda W_p^p(h(\cdot|x),y(\cdot)) = \inf_{T\in\Pi(h(x),y)}\langle T, M\rangle - \frac{1}{\lambda} H(T), \quad
H(T) = -\sum_{\kappa,\kappa'}T_{\kappa,\kappa'}\log T_{\kappa,\kappa'}.
\end{equation}
Importantly, the transport matrix that solves \eqref{eq:regularized-primal} is a \emph{diagonal scaling} of a matrix $\mathbf{K}=e^{-\lambda M - 1}$:
\begin{equation}
\label{eq:diagonal-scaling}
T^* = \diag{u} \mathbf{K} \diag{v}
\end{equation}
for $u = e^{\lambda \alpha}$ and $v = e^{\lambda \beta}$,
where $\alpha$ and $\beta$ are the Lagrange dual variables for \eqref{eq:regularized-primal}.
Identifying such a matrix subject to equality constraints on the row and column sums is exactly a \emph{matrix balancing} problem, which is well-studied in numerical linear algebra and for which efficient iterative algorithms exist \cite{Knight:2012eh}. \cite{Cuturi:2013wo} and \cite{Cuturi:2014vh} use the well-known Sinkhorn-Knopp algorithm.
\subsection{Extending smoothed transport to the learning setting}
When the output vectors $h(x)$ and $y$ lie in the simplex, \eqref{eq:regularized-primal} can be used directly in place of \eqref{eq:wasserstein-loss}, as \eqref{eq:regularized-primal} can approximate the exact Wasserstein distance closely for large enough $\lambda$ \cite{Cuturi:2013wo}. In this case, the gradient $\alpha$ of the objective can be obtained from the optimal scaling vector $u$ as $\alpha = \frac{\log u}{\lambda} - \frac{\log{u}^\top \mathbf{1}}{\lambda K} \mathbf{1}$. \footnote{Note that $\alpha$ is only defined up to a constant shift: any upscaling of the vector $u$ can be paired with a corresponding downscaling of the vector $v$ (and vice versa) without altering the matrix $T^*$. The choice $\alpha = \frac{\log u}{\lambda} - \frac{\log{u}^\top \mathbf{1}}{\lambda K} \mathbf{1}$ ensures that $\alpha$ is tangent to the simplex.} A Sinkhorn iteration for the gradient is given in Algorithm \ref{algo:subgradient}.
For many learning problems, however, a normalized output assumption is unnatural. In image segmentation, for example, the target shape is not naturally represented as a histogram. And even when the prediction and the ground truth are constrained to the simplex, the observed label can be subject to noise that violates the constraint.
There is more than one way to generalize optimal transport to unnormalized measures, and this is a subject of active study \cite{Chizat:2015ud}. We will develop here a novel objective that deals effectively with the difference in total mass between $h(x)$ and $y$ while still being efficient to optimize.
\begin{figure}
\centering
\begin{subfigure}[b]{0.32\textwidth}
\resizebox{\linewidth}{!}{
\includegraphics[width=\linewidth,]{softkl-to-sinkhorn
}\vskip-.4em
\caption{Convergence to smoothed transport.}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.32\textwidth}
\resizebox{\linewidth}{!}{
\includegraphics[width=\linewidth]{softkl-to-emd-256-abc
}\vskip-.4em
\caption{Approximation of exact Wasserstein.}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.32\textwidth}
\resizebox{\linewidth}{!}{
\includegraphics[width=\linewidth]{softkl-niter
}\vskip-.4em
\caption{Convergence of alternating projections ($\lambda = 50$).}
\end{subfigure}
\caption{The relaxed transport problem \eqref{eq:soft-kl} for unnormalized measures.}\vskip-1em
\label{fig:relaxed-transport}
\end{figure}
\subsection{Relaxed transport}
We propose a novel relaxation that extends smoothed transport to unnormalized measures. By replacing the equality constraints on the transport marginals in \eqref{eq:regularized-primal} with soft penalties with respect to KL divergence, we get an unconstrained approximate transport problem. The resulting objective is:
\begin{equation}
\label{eq:soft-kl}
^{\lambda,\gamma_a,\gamma_b} W_{KL}(h(\cdot|x),y(\cdot)) = \min_{T \in \mathbb{R}_+^{K \times K}} \langle T, M\rangle - \frac{1}{\lambda} H(T) + \gamma_a \gKL{T \mathbf{1}}{h(x)} + \gamma_b \gKL{T^\top \mathbf{1}}{y}
\end{equation}
where $\gKL{w}{z} = w^\top \log(w\oslash z) - \mathbf{1}^\top w + \mathbf{1}^\top z$ is the \emph{generalized KL divergence} between $w, z \in \mathbb{R}_+^K$. Here $\oslash$ represents element-wise division.
As with the previous formulation, the optimal transport matrix with respect to \eqref{eq:soft-kl} is a diagonal scaling of the matrix $\mathbf{K}$.
\begin{proposition}
\label{prop:relaxed-transport}
The transport matrix $T^*$ optimizing \eqref{eq:soft-kl} satisfies
$T^* = \diag{u} \mathbf{K} \diag{v}$,
where $u = \lr{h(x) \oslash T^* \mathbf{1}}^{\gamma_a \lambda}$, $v = \lr{y \oslash (T^*)^\top \mathbf{1}}^{\gamma_b \lambda}$, and $\mathbf{K} = e^{-\lambda M - 1}$.
\end{proposition}
And the optimal transport matrix is a fixed point for a Sinkhorn-like iteration. \footnote{Note that, although the iteration suggested by Proposition \ref{prop:soft-kl-iteration} is observed empirically to converge (see Figure \ref{fig:relaxed-transport}c, for example), we have not proven a guarantee that it will do so.}
\begin{proposition}
\label{prop:soft-kl-iteration}
$T^* = \diag{u} \mathbf{K} \diag{v}$ optimizing \eqref{eq:soft-kl} satisfies:
i) $u = h(x)^{\frac{\gamma_a \lambda}{\gamma_a \lambda + 1}} \odot \lr{\mathbf{K} v}^{-\frac{\gamma_a \lambda}{\gamma_a \lambda + 1}}$, and
ii) $v = y^{\frac{\gamma_b \lambda}{\gamma_b \lambda + 1}} \odot \lr{\mathbf{K}^\top u}^{-\frac{\gamma_b \lambda}{\gamma_b \lambda + 1}}$,
where $\odot$ represents element-wise multiplication.
\end{proposition}
Unlike the previous formulation, \eqref{eq:soft-kl} is unconstrained with respect to $h(x)$. The gradient is given by $\nabla_{h(x)} W_{KL}(h(\cdot|x),y(\cdot)) = \gamma_a \lr{\mathbf{1} - T^* \mathbf{1} \oslash h(x)}$. The iteration is given in Algorithm \ref{algo:subgradient}.
When restricted to normalized measures, the relaxed problem \eqref{eq:soft-kl} approximates smoothed transport \eqref{eq:regularized-primal}. Figure \ref{fig:relaxed-transport}a shows, for normalized $h(x)$ and $y$, the relative distance between the values of \eqref{eq:soft-kl} and \eqref{eq:regularized-primal} \footnote{In figures \ref{fig:relaxed-transport}a-c, $h(x)$, $y$ and $M$ are generated as described in \cite{Cuturi:2013wo} section 5. In \ref{fig:relaxed-transport}a-b, $h(x)$ and $y$ have dimension $256$. In 3c, convergence is defined as in \cite{Cuturi:2013wo}. Shaded regions are $95\%$ intervals.}. For $\lambda$ large enough, \eqref{eq:soft-kl} converges to \eqref{eq:regularized-primal} as $\gamma_a$ and $\gamma_b$ increase.
\eqref{eq:soft-kl} also retains two properties of smoothed transport \eqref{eq:regularized-primal}. Figure \ref{fig:relaxed-transport}b shows that, for normalized outputs, the relaxed loss converges to the unregularized Wasserstein distance as $\lambda$, $\gamma_a$ and $\gamma_b$ increase \footnote{The unregularized Wasserstein distance was computed using {\tt FastEMD} \cite{Pele:2009hk}.}. And Figure \ref{fig:relaxed-transport}c shows that convergence of the iterations in \eqref{prop:soft-kl-iteration} is nearly independent of the dimension $K$ of the output space.
\section{Statistical Properties of the Wasserstein loss}
\label{sec:generalization-error}
Let $S=\left((x_1,y_1),\ldots,(x_N,y_N)\right)$ be i.i.d. samples and $h_{\hat{\theta}}$ be the empirical risk minimizer
\[
h_{\hat{\theta}} = \argmin_{h_\theta\in\mathcal{H}} \left\{
\hat{\mathbb{E}}_S\left[W_p^p(h_\theta (\cdot|x),y)\right]
= \frac{1}{N}\sum_{i=1}^N W_p^p(h_x\theta(\cdot|x_i),y_i)
\right\}.
\]
Further assume $\mathcal{H}=\mathfrak{s}\circ\mathcal{H}^o$ is the composition of a
softmax $\mathfrak{s}$ and a base hypothesis space $\mathcal{H}^o$ of functions mapping into
$\mathbb{R}^K$. The softmax layer outputs a prediction that lies in the simplex $\Delta^{\mathcal{K}}$.
\begin{theorem}
For $p=1$, and any $\delta>0$, with probability at least $1-\delta$, it holds that
\begin{equation}
\mathbb{E}\left[W_1^1(h_{\hat{\theta}}(\cdot|x), y)\right]
\leq \inf_{h_\theta\in\mathcal{H}} \mathbb{E}\left[W_1^1(h_{\theta}(\cdot|x),y)\right] + 32KC_M
\mathfrak{R}_N(\mathcal{H}^o) + 2C_M\sqrt {\frac{\log(1/\delta)}{2N}}
\end{equation}
with the constant $C_M=\max_{\kappa,\kappa'}M_{\kappa,\kappa'}$. $\mathfrak{R}_N(\mathcal{H}^o)$
is the \emph{Rademacher complexity} \cite{Bartlett2003-kp} measuring the complexity of the
hypothesis space $\mathcal{H}^o$.
\label{thm:main-theorem}
\end{theorem}
The Rademacher complexity $\mathfrak{R}_N(\mathcal{H}^o)$ for commonly used models like neural
networks and kernel machines \cite{Bartlett2003-kp} decays with the
training set size. This theorem guarantees that the expected
Wasserstein loss of the empirical risk minimizer approaches the best achievable loss for $\mathcal
{H}$.
As an important special case, minimizing the empirical risk with Wasserstein loss
is also good for multiclass classification. Let $y=\mathbbm{e}_\kappa$ be the
``one-hot'' encoded label vector for the groundtruth class.
\begin{proposition}
In the multiclass classification setting, for $p=1$ and any $\delta>0$, with probability at least
$1-\delta$, it holds that
\begin{equation}
\mathbb{E}_{x,\kappa}\left[d_\mathcal{K}(\kappa_{\hat{\theta}}(x), \kappa)\right]
\leq \inf_{h_\theta\in\mathcal{H}}K\mathbb{E}[W_1^1(h_\theta(x),y)] + 32K^2C_M\mathfrak{R}_N
(\mathcal{H}^o) + 2C_MK\sqrt{\frac{\log(1/\delta)}{2N}}
\end{equation}
where the predictor is $
\kappa_{\hat{\theta}}(x)=\argmax_\kappa h_{\hat{\theta}}(\kappa|x)$, with $h_{\hat{\theta}}$ being
the empirical risk minimizer.
\label{prop:multiclass-bound}
\end{proposition}
Note that instead of the classification error $\mathbb{E}_{x,\kappa}[\mathbbm{1}\{\kappa_{\hat{\theta}}
(x)\neq \kappa\}]$, we actually get a bound on the expected semantic distance between the prediction
and the groundtruth.
\section{Empirical study}
\subsection{Impact of the ground metric}
\label{sec:mnist}
In this section, we show that the Wasserstein loss encourages smoothness with respect to an artificial metric on the MNIST handwritten digit dataset.
This is a multi-class classification problem with output dimensions corresponding to the 10 digits, and we apply a ground metric $d_p(\kappa,\kappa') = |\kappa-\kappa'|^p$, where $\kappa,\kappa'\in
\{0,\ldots,9\}$ and $p\in [0,\infty)$. This metric
encourages the recognized digit to be \emph{numerically} close to the true one. We train a model independently for each value of $p$ and plot the average predicted probabilities of the different digits on the test set in Figure~\ref{fig:mnist}.
\begin{figure}
\centering
\begin{subfigure}[b]{0.49\textwidth}
\resizebox{\linewidth}{!}{
\input{0.pgf
}\vskip-.4em
\caption{Posterior predictions for images of digit 0.}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.49\textwidth}
\resizebox{\linewidth}{!}{
\input{4.pgf
}\vskip-.4em
\caption{Posterior predictions for images of digit 4.}
\end{subfigure}
\caption{MNIST example. Each curve shows the predicted probability for one digit, for models trained with different $p$ values for the ground metric.}
\label{fig:mnist}
\end{figure}
Note that as $p\rightarrow 0$, the metric approaches the $0-1$ metric $d_0 (\kappa,\kappa')=\mathbbm {1}_
{\kappa\neq \kappa'}$, which treats all incorrect digits as being equally unfavorable. In this case, as
can be seen in the figure, the predicted probability of the true digit goes to 1 while the probability for all other digits goes to 0. As $p$ increases, the predictions become more evenly distributed over the neighboring digits, converging to a uniform distribution as $p\rightarrow\infty$ \footnote{To avoid numerical issues, we scale down the ground metric such that all of the distance values are in the interval $[0, 1)$.}.
\subsection{Flickr tag prediction}
We apply the Wasserstein loss to a real world multi-label learning problem, using the recently released Yahoo/Flickr Creative Commons 100M dataset \cite{thomee2015yfcc100m}. \footnote{The dataset used here is available at \url{http://cbcl.mit.edu/wasserstein}.} Our goal is \emph{tag prediction}: we select 1000 descriptive tags along with two random sets of 10,000 images each, associated with these tags, for training and testing. We derive a distance metric between tags by using \texttt
{word2vec}
\cite{mikolov2013distributed}
to embed the tags as unit vectors, then taking their Euclidean
distances. To extract image features we use \texttt{MatConvNet} \cite{arXiv:1412.4564}.
Note that the set of tags is highly redundant and often many semantically equivalent or similar tags can apply to an image. The images are also partially tagged, as different users may prefer different tags. We therefore measure the prediction performance by the
\emph {top-K cost}, defined as
$C_K = 1/K\sum_{k=1}^K \min_j d_\mathcal{K}(\hat{\kappa}_k,\kappa_j)$,
where $\{\kappa_j\}$ is the set of groundtruth tags, and $\{\hat{\kappa}_k\}$ are the tags with highest predicted probability. The standard AUC measure is also reported.
We find that a linear combination of the Wasserstein loss $W_p^p$ and the standard multiclass logistic loss $\mathsf{KL}$ yields the best prediction results. Specifically, we train a linear model by minimizing $W_p^p + \alpha\mathsf{KL}$ on the training set, where $\alpha$ controls the relative weight of $\mathsf{KL}$. Note that $\mathsf{KL}$ taken alone is our baseline in these experiments. Figure~\ref{fig:flickr-cost}a shows the top-K cost on the test set for the combined loss and the baseline $\mathsf{KL}$ loss. We additionally create a second dataset by removing redundant labels from the original dataset: this simulates the potentially more difficult case in which a single user tags each image, by selecting one tag to apply from amongst each cluster of applicable, semantically similar tags. Figure 3b shows that performance for both algorithms decreases on the harder dataset, while the combined Wasserstein loss continues to outperform the baseline.
\begin{figure}
\centering
\begin{subfigure}[b]{0.49\textwidth}
\resizebox{\linewidth}{!}{
\input{semantic-cost-basic.pgf
}
\caption{Original Flickr tags dataset.}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.49\textwidth}
\resizebox{\linewidth}{!}{
\input{semantic-cost-harder.pgf
}
\caption{Reduced-redundancy Flickr tags dataset.}
\end{subfigure}
\caption{Top-K cost comparison of the proposed loss (Wasserstein) and the baseline (Divergence).}
\vskip-0.5cm
\label{fig:flickr-cost}
\end{figure}
In Figure~\ref{fig:flickr-tradeoff}, we show the effect on performance of varying the weight $\alpha$ on the KL loss. We observe that the optimum of the top-$K$ cost is achieved when the Wasserstein loss is weighted more heavily than at the optimum of the AUC. This is consistent with a semantic smoothing effect of Wasserstein, which during training will favor mispredictions that are semantically similar to the ground truth, sometimes at the cost of lower AUC \footnote{The Wasserstein loss can achieve a similar trade-off by choosing the metric parameter $p$, as discussed in Section~\ref{sec:mnist}.
However, the relationship between $p$ and the smoothing behavior is complex and it can be simpler to implement the trade-off by combining with the $\mathsf {KL}$ loss.}. We finally show two selected images from the test set in Figure~\ref{fig:flickr-eg}. These illustrate cases in which both algorithms make predictions that are semantically relevant, despite overlapping very little with the ground truth. The image on the left shows errors made by both algorithms. More examples can be found in the appendix.
\begin{figure}
\centering
\begin{subfigure}[b]{0.49\textwidth}
\resizebox{\linewidth}{!}{
\input{trade-off-cost-basic.pgf
}\vskip-2.0em
\resizebox{\linewidth}{!}{
\input{trade-off-auc-basic.pgf
}\vskip-.8em
\caption{Original Flickr tags dataset.}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.49\textwidth}
\resizebox{\linewidth}{!}{
\input{trade-off-cost-harder.pgf
}\vskip-2.0em
\resizebox{\linewidth}{!}{
\input{trade-off-auc-harder.pgf
}\vskip-.8em
\caption{Reduced-redundancy Flickr tags dataset.}
\end{subfigure}
\caption{Trade-off between semantic smoothness and maximum likelihood.}
\label{fig:flickr-tradeoff}
\end{figure}
\begin{figure}
\centering
\begin{subfigure}[b]{.45\textwidth}
\includegraphics[width=\linewidth]{2258242999
\caption{\textbf{Flickr user tags}: street, parade, dragon; \textbf{our proposals}: people, protest, parade;
\textbf{baseline proposals}: music, car, band.}
\end{subfigure}\hfill
\begin{subfigure}[b]{.45\textwidth}
\includegraphics[width=\linewidth]{2215089260
\caption{\textbf{Flickr user tags}: water, boat, reflection, sunshine; \textbf{our proposals}: water, river,
lake, summer; \textbf{baseline proposals}: river, water, club, nature.}
\end{subfigure}
\caption{Examples of images in the Flickr dataset. We show the groundtruth tags and as well as tags
proposed by our algorithm and the baseline.}
\label{fig:flickr-eg}
\end{figure}
\section{Conclusions and future work}
In this paper we have described a loss function for learning to predict a non-negative measure over a finite set, based on the Wasserstein distance. Although optimizing with respect to the exact Wasserstein loss is computationally costly, an approximation based on entropic regularization is efficiently computed. We described a learning algorithm based on this regularization and we proposed a novel extension of the regularized loss to unnormalized measures that preserves its efficiency. We also described a statistical learning bound for the loss. The Wasserstein loss can encourage smoothness of the predictions with respect to a chosen metric on the output space, and we demonstrated this property on a real-data tag prediction problem, showing improved performance over a baseline that doesn't incorporate the metric.
An interesting direction for future work may be to explore the connection between the Wasserstein loss and Markov random fields, as the latter are often used to encourage smoothness of predictions, via inference at prediction time.
\newpage
\bibliographystyle{unsrt}
{\small
|
{'timestamp': '2015-12-31T02:07:22', 'yymm': '1506', 'arxiv_id': '1506.05439', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05439'}
|
arxiv
|
\section{Our main tools}
\label{sec:main_tool}
\subsection{Single-set Spectral Sparsification}\vskip -0.2cm
We describe the Single-Set Spectral Sparsification algorithm (\textbf{BSS}\footnote{The name BSS comes from the authors Batson, Spielman and Srivastava.} for short) of \citet{BSS09} as Algorithm ~\ref{alg:alg_ssp}. Algorithm ~\ref{alg:alg_ssp} is a greedy technique that selects columns one at a time. Consider the input matrix as a set of $d$ column vectors $\mat{U}^T = \left[ {\mathbf u}_1, {\mathbf u}_2,....,{\mathbf u}_d \right]$, with ${\mathbf u}_i \in \mathbb{R}^\ell \left(i = 1,..,d\right).$ Given $\ell$ and $r>\ell$, we iterate over $\tau = 0,1,2,.. r-1$. Define the parameters $L_{\tau} = \tau - \sqrt{r\ell}, \delta_L = 1, U_{\tau} = \delta_U\left(\tau + \sqrt{\ell r}\right)$ and $\delta_U = \left(1+\sqrt{\ell/r}\right)/\left(1 - \sqrt{\ell/r}\right)$. For $U, L \in \mathbb{R}$ and $\mat{A} \in \mathbb{R}^{\ell\times \ell}$ a symmetric positive definite matrix with eigenvalues $\lambda_1, \lambda_2,...,\lambda_\ell$, define
$$ \Phi\left(L,\mat{A}\right) = \sum_{i=1}^\ell \frac{1}{\lambda_i-L}; \; \; \hat{\Phi}\left(U,\mat{A}\right) = \sum_{i=1}^\ell \frac{1}{U-\lambda_i} $$
as the lower and upper potentials respectively. These potential functions measure how far the eigenvalues of $\mat{A}$ are from the upper and lower barriers $U$ and $L$ respectively. We define $\mathcal{L}\left({\mathbf u}, \delta_L, \mat{A}, L\right)$ and $\mathcal{U}\left({\mathbf u}, \delta_U, \mat{A}, U\right)$ as follows:
$$ \mathcal{L}\left({\mathbf u}, \delta_L, \mat{A}, L\right)= \frac{{\mathbf u}^T \left(\mat{A} - \left(L+\delta_L\right)\mat{I}_\ell\right)^{-2}{\mathbf u}}{\Phi\left(L+\delta_L,\mat{A}\right) - \Phi\left(L,\mat{A}\right)} - {\mathbf u}^T\left(\mat{A} - \left(L+\delta_L\right)\mat{I}_\ell\right)^{-1}{\mathbf u}$$
$$ \mathcal{U}\left({\mathbf u}, \delta_U, \mat{A}, U\right)= \frac{{\mathbf u}^T \left(\left(U+\delta_U\right)\mat{I}_\ell - \mat{A}\right)^{-2}{\mathbf u}}{ \hat{\Phi}\left(U,\mat{A}\right)-\hat{\Phi}\left(U+\delta_U,\mat{A}\right)} + {\mathbf u}^T\left(\left(U+\delta_U\right)\mat{I}_\ell - \mat{A}\right)^{-1}{\mathbf u}.$$
At every iteration, there exists an index $i_{\tau}$ and a weight $t_{\tau}>0$ such that, ${t_{\tau}}^{-1}\leq\mathcal{L}\left({\mathbf u}_{i_\tau}, \delta_L, \mat{A}, L\right)$ and
${t_{\tau}}^{-1}\geq \mathcal{U}\left({\mathbf u}_{i_\tau}, \delta_U, \mat{A}, U\right).$ Thus, there will be at most $r$ columns selected after $\tau$ iterations. The running time of the algorithm is dominated by the search for an index $i_\tau$ satisfying $$ \mathcal{U}\left({\mathbf u}_{i_\tau},\delta_U,\mat{A}_{\tau},U_{\tau} \right) \leq \mathcal{L}\left({\mathbf u}_{i_\tau},\delta_L, \mat{A}_{\tau},L_{\tau} \right)$$ and computing the weight $t_{\tau}.$ One needs to compute the upper and lower potentials $\hat{\Phi}\left(U,\mat{A}\right)$ and $\Phi\left(L,\mat{A}\right)$ and hence the eigenvalues of $\mat{A}$. Cost per iteration is $O\left(\ell^3\right)$ and the total cost is $O\left(r\ell^3\right).$ For $i=1,..,d$, we need to compute $\mathcal{L}$ and $\mathcal{U}$ for every ${\mathbf u}_i$ which can be done in $O\left(d\ell^2 \right)$ for every iteration, for a total
of $O\left(rd\ell^2 \right).$ Thus total running time of the algorithm is $O\left(rd\ell^2 \right).$
We present the following lemma for the single-set spectral sparsification algorithm.
\input{sssp}
\begin{lemma}\label{lem:bss}
\textbf{BSS} \citep{BSS09}: Given $\mat{U} \in \mathbb{R}^{d \times \ell}$ satisfying $\mat{U}^T\mat{U} = \mat{I}_\ell$ and $r>\ell$, we can deterministically construct sampling and rescaling matrices $\mat{S}\in\mathbb{R}^{r\times d}$ and $\mat{D}\in\mathbb{R}^{r \times r}$ with $\mat{R}=\mat{D}\mat{S}$, such that, for all ${\mathbf y} \in \mathbb{R}^\ell :$
$$ \left(1-\sqrt{\ell/r}\right)^2 \TNormS{\mat{U}{\mathbf y}} \le \TNormS{\mat{R}\mat{U}{\mathbf y}} \le \left( 1+ \sqrt{\ell/r} \right)^2 \TNormS{\mat{U}{\mathbf y}}.$$
\end{lemma}
We now present a slightly modified version of Lemma~\ref{lem:bss} for our theorems.
\begin{lemma} \label{lem:ssp}
Given $\mat{U} \in \mathbb{R}^{d \times \ell}$ satisfying $\mat{U}^T\mat{U} = \mat{I}_\ell$ and $r>\ell$, we can deterministically construct sampling and rescaling matrices $\mat{S} \in \mathbb{R}^{r\times d}$ and $\mat{D} \in \mathbb{R}^{r \times r}$ such that for $\mat{R}= \mat{D}\mat{S}$, $$\TNorm{ \mat{U}^T\mat{U} - \mat{U}^T\mat{R}^T\mat{R}\mat{U}} \leq 3\sqrt{\ell/r}.$$
\end{lemma}
\begin{proof}
From Lemma~\ref{lem:bss}, it follows,
\begin{equation}
\sigma_\ell\left(\mat{U}^T\mat{R}^T \mat{R}\mat{U}\right)\ge\left(1-\sqrt{\ell/r}\right)^2 \text{ and }
\sigma_1 \left(\mat{U}^T\mat{R}^T\mat{R}\mat{U}\right)\le\left(1+\sqrt{\ell/r}\right)^2. \nonumber
\end{equation}
Thus,
\begin{equation}
\lambda_{max}\left(\mat{U}^T\mat{U}-\mat{U}^T\mat{R}^T \mat{R}\mat{U}\right)\le \left(1-\left(1-\sqrt{\ell/r}\right)^2\right)\le 2\sqrt{\ell/r}.\nonumber
\end{equation}
Similarly,
\begin{equation}
\lambda_{min} \left(\mat{U}^T\mat{U} - \mat{U}^T\mat{R}^T \mat{R}\mat{U}\right) \ge \left( 1 - \left(1 +\sqrt{\ell/r}\right)^2 \right) \ge 3\sqrt{\ell/r}.\nonumber
\end{equation}
Combining these, we have
$\TNorm{\mat{U}^T\mat{U} - \mat{U}^T\mat{R}^T\mat{R}\mat{U}} \leq 3\sqrt{\ell/r}.$
\noindent Note: Let $\epsilon=3\sqrt{\ell/r}.$ It is possible to set an upper bound on $\epsilon$ by setting the value of $r$. We will assume $\epsilon\in(0,1/2]$.
\end{proof}
\subsection{Leverage Score Sampling}
Our randomized feature selection method is based on importance sampling or the so-called leverage-score sampling of \citet{Rudelson}. Let $\mat{U}$ be the top-$\rho$ left singular vectors of the training set $\mat{X}$. A carefully chosen probability distribution of the form
\begin{equation}
p_i = \frac{\TNormS{\mat{U}_{i}}}{n}, \text{ for } i=1,2,...,d,
\label{eqn:eqnlvg}
\end{equation}
i.e. proportional to the squared Euclidean norms of the rows of the left-singular vectors and select $r$ rows of $\mat{U}$ in i.i.d trials and re-scale the rows with $1/\sqrt{p_i}$. The time complexity is dominated by the time to compute the SVD of $\mat{X}$.
\begin{lemma} \label{lem:lvgscr}
\citep{Rudelson} Let $\epsilon \in(0,1/2]$ be an accuracy parameter and $\delta \in(0,1)$ be the failure probability. Given $\mat{U} \in \mathbb{R}^{d \times \ell}$ satisfying $\mat{U}^T\mat{U} = \mat{I}_\ell.$ Let $\tilde{p} = min\{1, rp_i\}$, let $p_i$ be as Eqn.~\ref{eqn:eqnlvg} and let $r = O\left(\frac{n}{\epsilon^2} \log\left(\frac{n}{\epsilon^2 \sqrt{\delta}}\right) \right)$. Construct the sampling and rescaling matrix $\mat{R}$. Then with probability at least $(1-\delta)$,
$ \TNorm{\mat{U}^T\mat{U} - \mat{U}^T\mat{R}^T\mat{R}\mat{U}} \leq \epsilon.$
\end{lemma}
\section{Experiments}
All experiments were performed in MATLAB R2013b on an Intel i-7 processor with 16GB RAM.
\subsection{BSS Implementation Issues}
The authors of ~\cite{BSS09} do not provide any implementation details of the \textbf{BSS} algorithm. Here we discuss several issues arising during the implementation. \\
\noindent\textbf{Choice of column selection:}
At every iteration, there are multiple columns which satisfy the condition $\mathcal{U}\left({\mathbf u}_i,\delta_U,\mat{A}_{\tau},U_{\tau} \right) \leq \mathcal{L}\left({\mathbf u}_i,\delta_L, \mat{A}_{\tau},L_{\tau} \right).$ The authors of ~\cite{BSS09} suggest picking any column which satisfies this constraint. Instead of breaking ties arbitrarily, we choose the column ${\mathbf u}_i$ which has not been selected in previous iterations and whose Euclidean-norm is highest among the candidate set. Columns with zero Euclidean norm never get selected by the algorithm.
In the inner loop of Algorithm~\ref{alg:alg_ssp}, $\mathcal{U}$ and $\mathcal{L}$ has to be computed for all the $d$ columns in order to pick a good column. This step can be done efficiently using a single line of Matlab code, by making use of matrix and vector operations.
\subsection{Other Feature Selection Methods}
In this section, we describe other feature-selection methods with which we compare BSS.
\subsubsection{Rank-Revealing QR Factorization (RRQR)}
Within the numerical linear algebra community, subset selection algorithms use the so-called Rank Revealing QR (RRQR) factorization. Here we slightly abuse notation and state $\mat{A}$ as a short and fat matrix as opposed to the tall and thin matrix.
Let $\mat{A}$ be a $n\times d$ matrix with $\left(n<d\right)$ and an integer $k \left(k<d\right)$ and assume partial QR factorizations of the form $$\mat{A}\mat{P} = \mat{Q} \begin{pmatrix} \mat{R}_{11} & \mat{R}_{12} \\ \mathbf{0} & \mat{R}_{22} \end{pmatrix},$$
where $\mat{Q} \in \mathbb{R}^{n\times n}$ is an orthogonal matrix, $\mat{P} \in \mathbb{R}^{d\times d}$ is a permutation matrix, $\mat{R}_{11} \in \mathbb{R}^{k\times k}, \mat{R}_{12} \in \mathbb{R}^{k\times (d-k)}, \mat{R}_{22} \in \mathbb{R}^{(d-k)\times (d-k)}$ The above factorization is called a RRQR factorization if $\sigma_{min}\left( \mat{R}_{11}\right) \geq \sigma_k\left(\mat{A}\right)/p(k,d)$, $\sigma_{max}\left( \mat{R}_{22}\right) \leq \sigma_{min}(\mat{A}) p(k,d),$ where $p(k,d)$ is a function bounded by a low-degree polynomial in $k$ and $d$. The important columns are given by $\mat{A}_1= \mat{Q} \begin{pmatrix} \mat{R}_{11} \\ \mathbf{0} \end{pmatrix}$ and $\sigma_i \left(\mat{A}_1\right) = \sigma_i\left(\mat{R}_{11}\right)$ with $1\leq i \leq k.$ We perform feature selection using RRQR by picking the important columns which preserve the rank of the matrix.
\subsubsection{Random Feature Selection}
We select features uniformly at random without replacement which serves as a baseline method. To get around the randomness, we repeat the sampling process five times.
\subsubsection{Leverage-Score Sampling}
For leverage-score sampling, we repeat the experiments five times to get around the randomness. We pick the top-$\rho$ left singular vectors of $\mat{X},$ where $\rho$ is the rank of the matrix $\mat{X}.$
\subsubsection{Information Gain (IG)} The Information Gain feature selection method \citep{yang97} measures the amount of information obtained for binary class prediction by knowing the presence or absence of a feature in a dataset. The method is a supervised strategy, whereas the other methods used here are unsupervised.
\begin{table}[!htbp]
\caption{\small Most frequently selected features using the synthetic dataset.}
\label{tab:synth}
\begin{center}
\begin{small}
\begin{tabular}{|c||c|c|}
\hline
$r=80$ & $k=90$ & $k=100$ \\
\hline
BSS &89, 88, 87, 86, 85 &100, 99, 98, 97, 95 \\
\hline
RRQR &90, 80, 79, 78, 77 & 100, 80, 79, 78, 77 \\
\hline
Lvg-Score &73, 85, 84, 81, 87 &93, 87, 95, 97, 96 \\
\hline
IG &80, 79, 78, 77, 76 &80, 79, 78, 77, 76 \\
\hline\hline
$r=90$ & $k=90$ & $k=100$ \\
\hline
BSS & 90, 88, 87, 86, 85 &100, 99, 98, 97, 96 \\
\hline
RRQR & 90, 89, 88, 87, 86 &100, 90, 89, 88, 87 \\
\hline
Lvg-Score &67, 88, 83, 87, 85 &100, 97, 92, 48, 58 \\
\hline
IG &90, 89, 88, 87, 86 &90, 89, 88, 87, 86 \\
\hline
\end{tabular}
\end{small}
\end{center}
\end{table}
\begin{table}[!htb]
\caption{\small Running time of various feature selection methods in seconds. For synthetic data, the running time corresponds to the experiment when $r=80$ and $k=90$ and is averaged over ten ten-fold cross-validation experiments. For TechTC-300, the running time corresponds to the experiment when $r=400$ and is averaged over ten ten-fold cross-validation experiments and over 48 TehTC-300 datasets.}
\label{tab:rlsc_trun}
\begin{center}
\begin{small}
\begin{tabular}{|c||c|c|c|c|}
\hline
&BSS &IG &LVG &RRQR \\ \hline
Synthetic Data &0.1025 &0.0003 &0.0031 &0.0016 \\ \hline
TechTC-300 &75.7624 &0.0242 &0.4054 &0.2631 \\ \hline
\end{tabular}
\end{small}
\end{center}
\end{table}
\subsection{Experiments on RLSC}
The goal of this section is to compare BSS with existing feature selection methods for RLSC and show that BSS is better than the other methods.
\subsubsection{Synthetic Data}\label{subsubsec:synth}
We run our experiments on synthetic data where we control the number of relevant features in the dataset and demonstrate the working of Algorithm~\ref{alg:alg_ssp} on RLSC.
We generate synthetic data in the same manner as given in \cite{Bhat04}. The dataset has $n$ data-points and $d$ features. The class label $y_i$ of each data-point was randomly chosen to be 1 or -1 with equal probability. The first $k$ features of each data-point ${\mathbf x}_i$ are drawn from $y_i \mathcal{N}\left(-j,1\right)$ distribution, where $\mathcal{N}\left(\mu,\sigma^2\right)$ is a random normal distribution with mean $\mu$ and variance $\sigma^2$ and $j$ varies from 1 to k. The remaining $d-k$ features are chosen from a $\mathcal{N}(0,1)$ distribution. Thus the dataset has $k$ relevant features and $(d-k)$ noisy features. By construction, among the first $k$ features, the $kth$ feature has the most discriminatory power, followed by $(k-1)th$ feature and so on. We set $n$ to 30 and $d$ to 1000. We set $k$ to 90 and 100 and ran two sets of experiments.\\
\begin{table}[!htbp]
\caption{\small Out-of-sample error of TechTC-300 datasets averaged over ten ten-fold cross-validation and over 48 datasets for three values of $r$. The first and second entry of each cell represents the mean and standard deviation. Items in bold indicate the best results.}
\label{tab:techtc_alleout}
\begin{center}
\begin{small}
\begin{tabular}{|c|c|c|c|c|}
\hline
$r=300$ & $\lambda=0.1$ & $\lambda=0.3$ & $\lambda=0.5$ & $\lambda=0.7$ \\
\hline
\textbf{BSS} &\textbf{31.76} $\pm$ \textbf{0.68} & \textbf{31.46} $\pm$ \textbf{0.67} & \textbf{31.24} $\pm$ \textbf{0.65} &\textbf{31.03} $\pm$ \textbf{0.66} \\
\hline
\textbf{Lvg-Score} &38.22 $\pm$ 1.26 &37.63 $\pm$ 1.25 &37.23 $\pm$ 1.24 &36.94 $\pm$ 1.24 \\
\hline
\textbf{RRQR} &37.84 $\pm$ 1.20 &37.07 $\pm$ 1.19 &36.57 $\pm$ 1.18 &36.10 $\pm$ 1.18 \\
\hline
\textbf{Randomfs} &50.01 $\pm$ 1.2 &49.43 $\pm$ 1.2 &49.18 $\pm$ 1.19 &49.04 $\pm$ 1.19 \\
\hline
\textbf{IG} &38.35 $\pm$ 1.21 &36.64 $\pm$ 1.18 &35.81 $\pm$ 1.18 &35.15 $\pm$ 1.17 \\
\hline \hline
$r=400$ & $\lambda=0.1$ & $\lambda=0.3$ & $\lambda=0.5$ & $\lambda=0.7$ \\
\hline
\textbf{BSS} &\textbf{30.59} $\pm$ \textbf{0.66} &\textbf{30.33} $\pm$ \textbf{0.65} &\textbf{30.11} $\pm$ \textbf{0.65} &\textbf{29.96} $\pm$ \textbf{0.65} \\
\hline
\textbf{Lvg-Score} &35.06 $\pm$ 1.21 &34.63 $\pm$ 1.20 &34.32 $\pm$ 1.2 &34.11 $\pm$ 1.19 \\
\hline
\textbf{RRQR} &36.61 $\pm$ 1.19 &36.04 $\pm$ 1.19 &35.46 $\pm$ 1.18 &35.05 $\pm$ 1.17 \\
\hline
\textbf{Randomfs} &47.82 $\pm$ 1.2 &47.02 $\pm$ 1.21 &46.59 $\pm$ 1.21 &46.27 $\pm$ 1.2 \\
\hline
\textbf{IG} &37.37 $\pm$ 1.21 &35.73 $\pm$ 1.19 &34.88 $\pm$ 1.18 &34.19 $\pm$ 1.18 \\
\hline\hline
$r=500$ & $\lambda=0.1$ & $\lambda=0.3$ & $\lambda=0.5$ & $\lambda=0.7$ \\
\hline
\textbf{BSS} &\textbf{29.80} $\pm$ \textbf{0.77} &\textbf{29.53} $\pm$ \textbf{0.77} &\textbf{29.34} $\pm$ \textbf{0.76} &\textbf{29.18} $\pm$ \textbf{0.75} \\
\hline
\textbf{Lvg-Score} &33.33 $\pm$ 1.19 &32.98 $\pm$ 1.18 &32.73 $\pm$ 1.18 &32.52 $\pm$ 1.17 \\
\hline
\textbf{RRQR} &35.77 $\pm$ 1.18 &35.18 $\pm$ 1.16 &34.67 $\pm$ 1.16 &34.25 $\pm$ 1.14 \\
\hline
\textbf{Randomfs} &46.26 $\pm$ 1.21 &45.39 $\pm$ 1.19 &44.96 $\pm$ 1.19 &44.65 $\pm$ 1.18 \\
\hline
\textbf{IG} &36.24 $\pm$ 1.20 &34.80 $\pm$ 1.19 &33.94 $\pm$ 1.18 &33.39 $\pm$ 1.17 \\
\hline
\end{tabular}
\end{small}
\end{center}
\end{table}
\noindent
We set the value of $r$, i.e. the number of features selected by BSS to 80 and 90 for all experiments. We performed ten-fold cross-validation and repeated it ten times. The value of $\lambda$ was set to 0, 0.1, 0.3, 0.5, 0.7, and 0.9. We compared BSS with RRQR, IG and leverage-score sampling. The mean out-of-sample error was 0 for all methods for both $k=90$ and $k=100$. Table~\ref{tab:synth} shows the set of five most frequently selected features by the different methods for one such synthetic dataset across 100 training sets. The top features picked up by the different methods are the relevant features by construction and also have good discriminatory power. This shows that BSS
is as good as any other method in terms of feature selection and often picks more discriminatory features than the other methods. We repeated our experiments on ten different synthetic datasets and each time, the five most frequently selected features were from the set of relevant features.
\begin{figure}[!htb]
\centering
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure1.eps}
\includegraphics[height = 45mm,width=0.49\columnwidth]{NECO-10-15-2473-Figure2.eps}
\includegraphics[height = 45mm,width=0.49\columnwidth]{NECO-10-15-2473-Figure3.eps}
\includegraphics[height = 45mm,width=0.49\columnwidth]{NECO-10-15-2473-Figure4.eps}
\caption{Out-of-sample error of 48 TechTC-300 documents averaged over ten ten-fold cross validation experiments for different values of regularization parameter $\lambda$ and number of features $r=300$. Vertical bars represent standard deviation.}
\label{fig:techtc_eout}
\end{figure}
Thus, by selecting only 8\%-9\% of all features, we show that we are able to obtain the most discriminatory features along with good out-of-sample error using BSS.
Though running time is not the main subject of this study, we would like to point out that we computed the running time of the different feature selection methods averaged over ten ten-fold cross validation experiments. The time to perform feature selection for each of the methods averaged over ten ten-fold cross-validation experiments was less than a second (See Table~\ref{tab:rlsc_trun}), which shows that the methods can be implemented in practice.
\begin{figure}[!htbp]
\centering
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure5.eps}
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure6.eps}
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure7.eps}
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure8.eps}
$r=400$
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure9.eps}
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure10.eps}
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure11.eps}
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure12.eps}
$r=500$
\caption{Out-of-sample error of 48 TechTC-300 documents averaged over ten ten-fold cross validation experiments for different values of regularization parameter $\lambda$ and number of features $r=400$ and $r=500$. Vertical bars represent standard deviation.}
\label{fig:techtc_eout2}
\end{figure}
\subsubsection{TechTC-300}\label{subsubsec:techttc300}
We use the TechTC-300 data \cite{David04}, consisting of a family of 295 document-term data matrices. The TechTC-300 dataset comes from the Open Directory Project (ODP), which is a large, comprehensive directory of the web, maintained by volunteer editors. Each matrix in the TechTC-300 dataset contains a pair of categories from the ODP. Each category corresponds to a label, and thus the resulting classification task is binary. The documents that are collected from the union of all the subcategories within each category are represented in the bag-of-words model, with the words constituting the features of the data \cite{David04}. Each data matrix consists of 150-280 documents, and each document is described with respect to 10,000-50,000 words. Thus, TechTC-300 provides a diverse collection of data sets for a systematic study of the performance of the RLSC using BSS. We removed all words of length at most four from the datasets. Next we grouped the datasets based on the categories and selected those datasets whose categories appeared at least thrice. There were 147 datasets, and we performed ten-fold cross validation and repeated it ten times on 48 such datasets. We set the values of the regularization parameter of RLSC to $0.1, 0.3, 0.5$ and $0.7$.
\begin{table}
\caption{\small A subset of the TechTC matrices of our study.}
\label{tab:filenames}
\begin{center}
\begin{small}
\begin{tabular}{|c|c|c|}
\hline
\textbf{id1\_id2} &\textbf{id1} &\textbf{id2}\\ \hline
1092\_789236 &Arts:Music:Styles:Opera &US Navy:Decommisioned Submarines \\ \hline
17899\_278949 &US:Michigan:Travel \& Tourism &Recreation:Sailing Clubs:UK \\ \hline
17899\_48446 &US:Michigan:Travel \& Tourism &Chemistry:Analytical:Products \\ \hline
14630\_814096 &US:Colorado:Localities:Boulder &Europe:Ireland:Dublin:Localities \\ \hline
10539\_300332 &US:Indiana:Localities:S &Canada:Ontario:Localities:E \\ \hline
10567\_11346 &US:Indiana:Evansville &US:Florida:Metro Areas:Miami \\ \hline
10539\_194915 &US:Indiana:Localities:S &US:Texas:Localities:D \\ \hline
\end{tabular}
\end{small}
\end{center}
\end{table}
\begin{table}
\caption{\small Frequently occurring terms of the TechTC-300 datasets of Table~\ref{tab:filenames} selected by BSS}
\label{tab:techtc_words}
\begin{center}
\begin{small}
\begin{tabular}{|c|c|}
\hline
\textbf{id1\_id2} &\textbf{words}\\ \hline
1092\_789236 & naval,shipyard,submarine,triton,music,opera,libretto,theatre\\ \hline
17899\_278949 & sailing,cruising,boat,yacht,racing,michigan,leelanau,casino\\ \hline
17899\_48446 & vacation,lodging,michigan,asbestos,chemical,analytical,laboratory\\ \hline
14630\_814096 & ireland,dublin,boulder,colorado,lucan,swords,school,dalkey \\ \hline
10539\_300332 &ontario,fishing,county,elliot,schererville,shelbyville,indiana,bullet \\ \hline
10567\_11346 &florida,miami,beach,indiana,evansville,music,business,south \\ \hline
10539\_194915 &texas,dallas,plano,denton,indiana,schererville,gallery,north \\
\hline
\end{tabular}
\end{small}
\end{center}
\end{table}
\begin{table}
\caption{\small Frequently occurring terms of the TechTC-300 datasets of Table~\ref{tab:filenames} selected by Leverage-Score Sampling} \label{tab:techtc_words_lvg}
\begin{center}
\begin{small}
\begin{tabular}{|c|c|}
\hline
\textbf{id1\_id2} &\textbf{words}\\ \hline
1092\_789236 & sturgeon, seawolf, skate, triton, frame, opera, finback \\ \hline
17899\_278949 & sailing, yacht, laser, michigan,breakfast, county, clear\\ \hline
17899\_48446 & analysis, michigan, water, breakfast, asbestos, environmental, analytical\\ \hline
14630\_814096 & ireland, dublin, estate, lucan, dalkey, colorado, boulder \\ \hline
10539\_300332 & library, fishing, service, lodge, ontario, elliot, indiana, shelbyville\\ \hline
10567\_11346 & evansville, services, health, church, south, bullet, florida\\ \hline
10539\_194915 & dallas, texas, schererville, indiana, shelbyville, plano\\
\hline
\end{tabular}
\end{small}
\end{center}
\end{table}
\noindent We set $r$ to 300, 400 and 500. We report the out-of-sample error for all 48 datasets. BSS consistently outperforms Leverage-Score sampling, IG, RRQR and random feature selection on all 48 datasets for all values of the regularization parameter. Table~\ref{tab:techtc_alleout} and Fig~\ref{fig:techtc_eout} shows the results. The out-of-sample error decreases with increase in number of features for all methods. In terms of out-of-sample error, BSS is the best, followed by Leverage-score sampling, IG, RRQR and random feature selection. BSS is at least 3\%-7\% better than the other methods when averaged over 48 document matrices. From Fig~\ref{fig:techtc_eout} and \ref{fig:techtc_eout2}, it is evident that BSS is comparable to the other methods and often better on all 48 datasets. Leverage-score sampling requires greater number of samples to achieve the same out-of-sample error as BSS (See Table~\ref{tab:techtc_alleout}, $r=500$ for Lvg-Score and $r=300$ for BSS). Therefore, for the same number of samples, BSS outperforms leverage-score sampling in terms of out-of-sample error. The out-of-sample error of supervised IG is worse than that of unsupervised BSS, which could be due to the worse generalization of the supervised IG metric. We also observe that the out-of-sample error decreases with increase in $\lambda$ for the different feature selection methods.\\
\noindent
We list the most frequently occurring words selected by BSS and leverage-score sampling for the $r=300$ case for seven TechTC-300 datasets over 100 training sets used in the cross-validation experiments. Table~\ref{tab:filenames} shows the names of the seven TechTC-300 document-term matrices. The words shown in Tables ~\ref{tab:techtc_words} and ~\ref{tab:techtc_words_lvg} were selected in all cross-validation experiments for these seven datasets. The words are closely related to the categories to which the documents belong, which shows that BSS and leverage-score sampling select important features from the training set. For example, for the document-pair $(1092\_789236)$, where $1092$ belongs to the category of ``Arts:Music:Styles:Opera" and $789236$ belongs to the category of ``US:Navy: Decommisioned Submarines", the BSS algorithm selects submarine, shipyard, triton, opera, libretto, theatre which are closely related to the two classes. The top words selected by leverage-score sampling for the same document-pair are seawolf, sturgeon, opera, triton finback, which are closely related to the class. Another example is the document-pair $10539\_300332$, where $10539$ belongs to ``US:Indiana:Localities:S" and $300332$ belongs to the category of ``Canada: Ontario: Localities:E". The top words selected for this document-pair are ontario, elliot, shelbyville, indiana, schererville which are closely related to the class values. Thus, we see that using only 2\%-4\% of all features we are able to select relevant features and obtain good out-of-sample error. The top words selected by leverage-score sampling are library, fishing, elliot, indiana, shelbyville, ontario which are closely related to the class.\\
Though feature selection is an offline task, we give a discussion of the running times of the different methods to highlight that BSS can be implemented in practice. We computed the running time of the different feature selection methods averaged over ten ten-fold cross validation experiments and over 48 datasets (See Table~\ref{tab:rlsc_trun}). The average time for feature selection by BSS is approximately over a minute, while the rest of the methods take less than a second.
This shows that BSS can be implemented in practice and can scale up to reasonably large datasets with 20,000-50,000 features. For BSS and leverage-score sampling, the running time includes the compute to compute SVD of the matrix. BSS takes approximately a minute to select features, but is at least 3\%-7\% better in terms of out-of-sample error than the other methods. IG takes less than a second to select features, but is 4\%-7\% worse than BSS in terms of out-of-sample error.
\subsection{Experiments on Ridge Regression in the fixed design setting}
In this section, we describe experiments on feature selection on ridge regression in the fixed design setting using synthetic and real data.
\begin{figure}[!htb]
\centering
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure13.eps}
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure14.eps}
$k=90$\\
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure15.eps}
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure16.eps}
$k=100$
\caption{MSE/Risk for synthetic data for $k=90$ and $k=100$ using different feature selection methods as a function of $\lambda$. The risk after feature selection is comparable to the risk of full-data.}
\label{fig:risk_bss}
\end{figure}
\subsubsection{Synthetic Data}
We generate the features of the synthetic data $\mat{X}$ in the same manner as described in Section~\ref{subsubsec:synth}. We generate ${\bm \beta} \sim \mathcal{N}(0,1)$ and ${\mathbf y} =\mat{X}^T {\bm \beta} + {\bm \omega}$, where ${\bm \omega} \in \mathbb{R}^n$ and ${\bm \beta} \in \mathbb{R}^d.$
We set $n$ to 30 and $d$ to 1000. We set the number of relevant features, $k$ to 90 and 100 and ran two sets of experiments. We set the value of $r$, i.e. the number of features selected by BSS and leverage-score sampling to $t*n$, where $t=6, 7, 8, 9$ for both experiments. The value of $\lambda$ was set to 0.1, 0.3, 0.5 and 0.7. We compared the risk of ridge regression using BSS and leverage-score sampling with the risk of full-feature selection and report the MSE/Risk in the fixed design setting as a measure of accuracy. Fig~\ref{fig:risk_bss} shows the risk of synthetic data for both BSS and leverage-score sampling as a function of $\lambda$. The risk of the sampled data is comparable to the risk of the full-data in most cases, which follows from our theory. We observe that for higher values of $\lambda$, the risk of sampled space becomes worse than that of full-data for both BSS and leverage-score sampling. The risk in the sampled space is almost the same for both BSS and Leverage-score sampling. The time to compute feature selection is less than a second for both methods (See Table~\ref{tab:rr_trun}).
\begin{figure}[!htb]
\centering
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure17.eps}
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure18.eps}
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure19.eps}
\includegraphics[height = 45mm,width= 0.49\columnwidth]{NECO-10-15-2473-Figure20.eps}
\caption{MSE/Risk for TechTC-300 data using different feature selection methods as a function of $\lambda$. The risk after feature selection is comparable to the risk of full-data.}
\label{fig:risk_techtc}
\end{figure}
\begin{table}[!htb]
\caption{\small Running time of various feature selection methods in seconds. For synthetic data, the running time corresponds to the experiment when $r=8n.$ For TechTC-300, the running time corresponds to the experiment when $r=400.$}
\label{tab:rr_trun}
\begin{center}
\begin{small}
\begin{tabular}{|c||c|c|c|c|}
\hline
&Synthetic Data &TechTC (10341-14525) &TechTC (10341-61792) \\ \hline
BSS &0.3368 &68.8474 &67.013 \\ \hline
LVG &0.0045 &0.3994 &0.3909 \\ \hline
\end{tabular}
\end{small}
\end{center}
\end{table}
\subsubsection{TechTC-300}
We use two TechTC-300 datasets, namely ``10341-14525" and ``10341-61792" to illustrate our theory.
We add gaussian noise to the labels. We set the value of $r,$ the number of features to be selected to 300, 400 and 500. The value of $\lambda$ was set to 0.1, 0.3 and 0.5. We compared the risk of ridge regression using BSS and leverage-score sampling with the risk of full-feature selection and report the MSE/Risk in the fixed design setting as a measure of accuracy. Fig~\ref{fig:risk_techtc} shows the risk of real data for both BSS and leverage-score sampling as a function of $\lambda$. The risk of the sampled data is comparable to the risk of the full-data in most cases, which follows from our theory. The risk of the sampled data decreases with increase in $r.$ The time to perform feature selection is approximately a minute for BSS and less than a second for leverage-score sampling (See Table~\ref{tab:rr_trun}).
\section{Conclusion}
We present a provably accurate feature selection method for RLSC which works well empirically and also gives better generalization peformance than prior existing methods. The number of features required by BSS is of the order $O\left(n/\epsilon^2\right)$, which makes the result tighter than that obtained by leverage-score sampling. BSS has been recently used as a feature selection technique for k-means clustering \citep{Bouts13}, linear SVMs \citep{Paul14} and our work on RLSC helps to expand research in this direction. The risk of ridge regression in the sampled space is comparable to the risk of ridge regression in the full feature space in the fixed design setting and we observe this in both theory and experiments. An interesting future work in this direction would be to include feature selection for non-linear kernels with provable guarantees.
\noindent \textbf{Acknowledgements.}
Most of the work was done when SP was a graduate student at RPI.
This work is supported by NSF CCF 1016501 and NSF IIS 1319280.
\section{Introduction}
Ridge regression is a popular technique in machine learning and statistics. It is a commonly used penalized regression method.
Regularized Least Squares Classifier (RLSC) is a simple classifier based on least squares and has a long history in machine learning \citep{PZhang04,Poggio03,RifkinRLSC,fung01,Suykens99,TZhang01,Agarwal02}. RLSC is also the classification analogue to ridge regression. RLSC has been known to perform comparably to the popular Support Vector Machines (SVM) \citep{RifkinRLSC,fung01,Suykens99,TZhang01}. RLSC can be solved by simple vector space operations and do not require quadratic optimization techniques like SVM. \\
We propose a deterministic feature selection technique for RLSC with provable guarantees. There exist numerous feature selection techniques, which work well empirically. There also exist randomized feature selection methods like leverage-score sampling, \citep{Dasgup07} with provable guarantees which work well empirically. But the randomized methods have a failure probability and have to be re-run multiple times to get accurate results. Also, a randomized algorithm may not select the same features in different runs. A deterministic algorithm will select the same features irrespective of how many times it is run. This becomes important in many applications. Unsupervised feature selection involves selecting features oblivious to the class or labels. \\
In this work, we present a new provably accurate unsupervised feature selection technique for RLSC. We study a deterministic sampling based feature selection strategy for RLSC with provable non-trivial worst-case performance bounds. \\
We also use single-set spectral sparsification and leverage-score sampling as unsupervised feature selection algorithms for ridge regression in the fixed design setting. Since the methods are unsupervised, it will ensure that the methods work well in the fixed design setting, where the target variables have an additive homoskedastic noise. The algorithms sample a subset of the features from the original data matrix and then perform regression task on the reduced dimension matrix. We provide risk bounds for the feature selection algorithms on ridge regression in the fixed design setting.\\
The number of features selected by both algorithms is proportional to the rank of the training set. The deterministic sampling-based feature selection algorithm performs better in practice when compared to existing methods of feature selection.
\section{Our Contributions}\vskip -0.1cm
We introduce single-set spectral sparsification as a provably accurate deterministic feature selection technique for RLSC in an unsupervised setting. The number of features selected by the algorithm is independent of the number of features, but depends on the number of data-points. The algorithm selects a small number of features and solves the classification problem using those features. \citet{Dasgup07} used a leverage-score based randomized feature selection technique for RLSC and provided worst case guarantees of the approximate classifier function to that using all features. We use a deterministic algorithm to provide worst-case generalization error guarantees. The deterministic algorithm does not come with a failure probability and the number of features required by the deterministic algorithm is lesser than that required by the randomized algorithm. The leverage-score based algorithm has a sampling complexity of
$O\left(\frac{n}{\epsilon^2} \log\left(\frac{n}{\epsilon^2 \sqrt{\delta}}\right) \right)$, whereas single-set spectral sparsification requires $O\left( n/ \epsilon^2 \right)$ to be picked, where $n$ is the number of training points, $\delta \in (0,1)$ is a failure probability and $\epsilon \in (0,1/2]$ is an accuracy parameter. Like in \citet{Dasgup07}, we also provide additive-error approximation guarantees for any test-point and relative-error approximation guarantees for test-points that satisfy some conditions with respect to the training set. \\
We introduce single-set spectral sparsification and leverage-score sampling as unsupervised feature selection algorithms for ridge regression and provide risk bounds for the subsampled problems in the fixed design setting. The risk in the sampled space is comparable to the risk in the full-feature space. We give relative-error guarantees of the risk for both feature selection methods in the fixed design setting.\\
From an \textbf{empirical perspective}, we evaluate single-set spectral sparsification on synthetic data and 48 document-term matrices, which are a subset of the TechTC-300 \citep{David04} dataset. We compare the single-set spectral sparsification algorithm with leverage-score sampling, information gain, rank-revealing QR factorization (RRQR) and random feature selection. We do not report running times because feature selection is an offline task. The experimental results indicate that single-set spectral sparsification out-performs all the methods in terms of out-of-sample error for all 48 TechTC-300 datasets. We observe that a much smaller number of features is required by the deterministic algorithm to achieve good performance when compared to leverage-score sampling.
\section{Background and Related Work}
\subsection{Notation}
$\mat{A}, \mat{B}, \ldots$ denote matrices and ${\bm \alpha}, {\mathbf b}, \ldots$ denote column vectors; ${\mathbf e}_i$ (for all $i=1\ldots n$) is the standard basis, whose dimensionality will be clear from context; and $\mat{I}_n$ is the $n \times n$ identity matrix. The Singular Value Decomposition (SVD) of a matrix $\mat{A} \in \mathbb{R}^{n \times d}$ is equal to %
$ \mat{A} = \mat{U} \mat{\Sigma} \mat{V}^T,$
where $\mat{U} \in \mathbb{R}^{n \times d}$ is an orthogonal matrix containing the left singular vectors, $\mat{\Sigma} \in \mathbb{R}^{d \times d}$ is a diagonal matrix containing the singular values $\sigma_1 \geq \sigma_2 \geq \ldots \sigma_{d} > 0$, and $\mat{V} \in \mathbb{R}^{d \times d}$ is a matrix containing the right singular vectors.
The spectral norm of $\mat{A}$ is $\TNorm{\mat{A}} = \sigma_1$. $\sigma_{max}$ and $\sigma_{min}$ are the largest and smallest singular values of $\mat{A}$.
$\kappa_{\mat{A}} = \sigma_{max}/\sigma_{min}$ is the condition number of $\mat{A}$. $\mat{U}^{\perp}$ denotes any $n \times \left(n-d\right)$ orthogonal matrix whose columns span the subspace orthogonal to $\mat{U}$. A vector ${\mathbf q} \in \mathbb{R}^n$ can be expressed as: ${\mathbf q} = \mat{A}\bm{\alpha} + \mat{U}^{\perp}\bm{\beta},$ for some vectors $\bm{\alpha} \in \mathbb{R}^d$ and $\bm{\beta} \in \mathbb{R}^{n-d}$, i.e. ${\mathbf q}$ has one component along $\mat{A}$ and another component orthogonal to $\mat{A}$.
\subsection{Matrix Sampling Formalism}
We now present the tools of feature selection. Let $\mat{A} \in \mathbb{R}^{d \times n}$ be the data matrix consisting of $n$ points and $d$ dimensions, $\mat{S} \in \mathbb{R}^{r\times d}$ be a matrix such that $\mat{S}\mat{A} \in \mathbb{R}^{r\times n}$ contains $r$ rows of $\mat{A}.$ Matrix $\mat{S}$ is a binary $(0/1)$ indicator matrix, which has exactly one non-zero element in each row. The non-zero element of $\mat{S}$ indicates which row of $\mat{A}$ will be selected. Let $\mat{D} \in \mathbb{R}^{r\times r}$ be the diagonal matrix such that $\mat{D}\mat{S}\mat{A} \in \mathbb{R}^{r\times n}$ rescales the rows of $\mat{A}$ that are in $\mat{S}\mat{A}.$ The matrices $\mat{S}$ and $\mat{D}$ are called the sampling and re-scaling matrices respectively. We will replace the sampling and re-scaling matrices by a single matrix $\mat{R} \in \mathbb{R}^{r\times d}$, where $\mat{R} = \mat{D}\mat{S}$ denotes the matrix specifying which of the $r$ rows of $\mat{A}$ are to be sampled and how they are to be rescaled.
\subsection{RLSC Basics}
Consider a training data of $n$ points in $d$ dimensions with respective labels $y_i \in \{-1,+1\}$ for $i=1,..,n.$ The solution of binary classification problems via Tikhonov regularization in a Reproducing Kernel Hilbert Space (RKHS) using the squared loss function results in Regularized Least Squares Classification (RLSC) problem~\citep{RifkinRLSC}, which can be stated as:
\begin{equation}
\min_{{\mathbf x} \in \mathbb{R}^n} \TNormS{\mat{K}{\mathbf x} -{\mathbf y}} + \lambda{\mathbf x}^T\mat{K}{\mathbf x}
\label{eqn:rlsc1}
\end{equation}
\noindent where $\mat{K}$ is the $n\times n$ kernel matrix defined over the training dataset, $\lambda$ is a regularization parameter and ${\mathbf y}$ is the $n$ dimensional $\{\pm1 \}$ class label vector. In matrix notation, the training data-set $\mat{X}$ is a $d\times n$ matrix, consisting of $n$ data-points and $d$ features $(d\gg n)$. Throughout this study, we assume that $\mat{X}$ is a full-rank matrix. We shall consider the linear kernel, which can be written as $\mat{K} = \mat{X}^T\mat{X}.$ Using the SVD of $\mat{X}$, the optimal solution of Eqn.~\ref{eqn:rlsc1} in the full-dimensional space is
\begin{equation}
{\mathbf x}_{opt} = \mat{V}\left(\mat{\Sigma}^2 + \lambda\mat{I}\right)^{-1} \mat{V}^T{\mathbf y}.
\label{eqn:xopt}
\end{equation}
\noindent The vector ${\mathbf x}_{opt}$ can be used as a classification function that generalizes to test data. If ${\mathbf q} \in \mathbb{R}^d$ is the new test point, then the binary classification function is:
\begin{equation}
f({\mathbf q}) ={\mathbf x}_{opt}^T\mat{X}^T{\mathbf q}.
\label{eqn:clsf}
\end{equation}
\noindent Then, $sign(f({\mathbf q}))$ gives the predicted label ($-1$ or $+1$) to be assigned to the new test point ${\mathbf q}$.
Our goal is to study how RLSC performs when the deterministic sampling based feature selection algorithm is used to select features in an unsupervised setting. Let $\mat{R} \in \mathbb{R}^{r \times d}$ be the matrix that samples and re-scales $r$ rows of $\mat{X}$ thus reducing the dimensionality of the training set from \math{d} to $r \ll d$ and $r$ is proportional to the rank of the input matrix. The transformed dataset into \math{r} dimensions is given by \math{\tilde\mat{X}=\mat{R}\mat{X}} and the RLSC problem becomes
\begin{equation}
\min_{{\mathbf x} \in \mathbb{R}^n} \TNormS{\tilde{\mat{K}}{\mathbf x} -{\mathbf y}} + \lambda{\mathbf x}^T\tilde{\mat{K}}{\mathbf x},
\label{eqn:rlsc2}
\end{equation}
thus giving an optimal vector $\tilde{{\mathbf x}}_{opt}$. The new test point ${\mathbf q}$ is first dimensionally reduced to $\tilde{{\mathbf q}}=\mat{R}{\mathbf q}$, where $\tilde{{\mathbf q}} \in \mathbb{R}^r$ and then classified by the function,
\begin{equation}
\tilde{f}= f(\tilde{{\mathbf q}}) =\tilde{{\mathbf x}}_{opt}^T\tilde{\mat{X}}^T\tilde{{\mathbf q}}.
\label{eqn:clsf2}
\end{equation}
In subsequent sections, we will assume that the test-point ${\mathbf q}$ is of the form ${\mathbf q} = \mat{X}\bm{\alpha} + \mat{U}^{\perp}\bm{\beta}.$ The first part of the expression shows the portion of the test-point that is similar to the training-set and the second part shows how much the test-point is novel compared to the training set, i.e. $\TNorm{\bm\beta}$ measures how much of ${\mathbf q}$ lies outside the subspace spanned by the training set.
\subsection{Ridge Regression Basics}
Consider a data-set $\mat{X}$ of $n$ points in $d$ dimensions with $d\gg n$. Here $\mat{X}$ contains $n$ i.i.d samples from the $d$ dimensional independent variable. ${\mathbf y} \in \mathbb{R}^{n}$ is the real-valued response vector. Ridge Regression(RR) or Tikhonov regularization penalizes the $\ell_2$ norm of a parameter vector ${\bm \beta}$ and shrinks the estimated coefficients towards zero. In the fixed design setting, we have ${\mathbf y} =\mat{X}^T{\bm \beta}+{\bm \omega}$ where ${\bm \omega} \in \mathbb{R}^n$ is the homoskedastic noise vector with mean 0 and variance $\sigma^2$. Let ${\bm \beta}_\lambda$ be the solution to the ridge regression problem. The RR problem is stated as:
\begin{equation}
\hat{{\bm \beta}}_\lambda = \arg \min_{{\bm \beta} \in \mathbb{R}^d} \frac{1}{n}\TNormS{{\mathbf y} -\mat{X}^T{\bm \beta}} + \lambda\TNormS{{\bm \beta}}.
\label{eqn:rr1}
\end{equation}
\noindent The solution to Eqn.\ref{eqn:rr1} is $\hat{{\bm \beta}}_\lambda = \left( \mat{X} \mat{X}^T+n\lambda\mat{I}_d\right)^{-1}\mat{X}{\mathbf y}$. One can also solve the same problem in the dual space. Using change of variables, ${\bm \beta} = \mat{X} {\bm \alpha}$, where ${\bm \alpha} \in \mathbb{R}^{n}$ and let $\mat{K} = \mat{X}^T\mat{X}$ be the $n\times n$ linear kernel defined over the training dataset. The optimization problem becomes:
\begin{equation}
\hat{\bm \alpha}_\lambda = \arg \min_{{\bm \alpha} \in \mathbb{R}^n} \frac{1}{n}\TNormS{{\mathbf y} -\mat{K}{\bm \alpha}} + \lambda{\bm \alpha}^T\mat{K}{\bm \alpha}.
\label{eqn:rr2}
\end{equation}
Throughout this study, we assume that $\mat{X}$ is a full-rank matrix. Using the SVD of $\mat{X}$, the optimal solution in the dual space (Eqn.~\ref{eqn:rr2}) for the full-dimensional data is given by $\hat{\bm \alpha}_\lambda = \left(\mat{K} + n\lambda\mat{I}_n\right)^{-1}{\mathbf y}.$ The primal solution is $\hat{\bm \beta}_\lambda =\mat{X}\hat{\bm \alpha}_\lambda.$
In the sampled space, we have $\tilde{\mat{K}}=\tilde{\mat{X}}^T\tilde{\mat{X}}.$ The dual problem in the sampled space can be posed as:
\begin{equation}
\tilde{\bm \alpha}_\lambda = \arg \min_{{\bm \alpha} \in \mathbb{R}^n} \frac{1}{n}\TNormS{{\mathbf y} -\tilde{\mat{K}}{\bm \alpha}} + \lambda{\bm \alpha}^T\tilde{\mat{K}}{\bm \alpha}.
\label{eqn:rr3}
\end{equation}
The optimal dual solution in the sampled space is $\tilde{\bm \alpha}_\lambda = \left(\tilde{\mat{K}} + n\lambda\mat{I}_n\right)^{-1}{\mathbf y}.$
The primal solution is $\tilde{\bm \beta}_\lambda =\tilde{\mat{X}}\tilde{\bm \alpha}_\lambda.$
\subsection{Related Work}
The work most closely related to ours is that of \citet{Dasgup07} who used a leverage-score based randomized feature selection technique for RLSC and provided worst case bounds of the approximate classifier with that of the classifier for all features. The proof of their main quality-of-approximation results provided an intuition of the circumstances when their feature selection method will work well. The running time of leverage-score based sampling is dominated by the time to compute SVD of the training set i.e. $O\left( n^2 d\right)$, whereas, for single-set spectral sparsification, it is $O\left(rdn^2\right)$. Single-set spectral sparsification is a slower and more accurate method than leverage-score sampling. Another work on dimensionality reduction of RLSC is that of \citet{Avron13} who used efficient randomized-algorithms for solving RLSC, in settings where the design matrix has a Vandermonde structure. However, this technique is different from ours, since their work is focused on dimensionality reduction using linear combinations of features, but not on actual feature selection. \\
\citet{Dhillon13} used Randomized Walsh-Hadamard transform to lower the dimension of data matrix and subsequently solve the ridge regression problem in the lower dimensional space. They provided risk-bounds of their algorithm in the fixed design setting. However, this is different from our work, since they use linear combinations of features, while we select actual features from the data.
\subsection{Our Main Theorems on Ridge Regression}
We compare the risk of subsampled ridge regression with the risk of true dual ridge regreesion in the fixed design setting.
Recall that the response vector ${\mathbf y} =\mat{X}^T {\bm \beta}+{\bm \omega}$ where ${\bm \omega} \in \mathbb{R}^n$ is the homoskedastic noise vector with mean 0 and variance $\sigma^2$.
Also, we assume that the data matrix is of full rank.
\begin{lemma}
\label{lem:lembss}
Let $\rho$ be the rank of $\mat{X}$. Form $\tilde{\mat{K}}$ using BSS. Then,
\begin{equation}
\left(1-\Delta \right)\mat{K} \preceq \tilde{\mat{K}} \preceq \left(1+\Delta \right) \mat{K},\nonumber
\end{equation}
where $\Delta = C\sqrt{\rho/r}.$ For p.s.d matrices $\mat{A} \succeq \mat{B}$ means $\mat{B} -\mat{A}$ is p.s.d.
\end{lemma}
\begin{proof}
Using the SVD of $\mat{X}$, $\tilde{\mat{K}} = \mat{V}\mat{\Sigma}\left(\mat{U}^T\mat{R}^T\mat{R}\mat{U}\right)\mat{\Sigma}\mat{V}^T$. Lemma~\ref{lem:ssp} implies $$\mat{I}_\rho \left(1-\Delta\right) \preceq \left(\mat{U}^T \mat{R}^T \mat{R}\mat{U} \right) \preceq \mat{I}_\rho \left(1+\Delta \right).$$
Multiplying left and right hand side of the inequality by $\mat{V}\mat{\Sigma}$ and $\mat{\Sigma} \mat{V}^T$ respectively, to the above inequality completes the proof.
\end{proof}
\begin{lemma}
\label{lem:lemlvg}
Let $\rho$ be the rank of $\mat{X}$. Form $\tilde{\mat{K}}$ using leverage-score sampling. Then, with probability at least $(1-\delta)$, where $\delta \in (0,1)$,
\begin{equation}
\left(1-\Delta \right)\mat{K} \preceq \tilde{\mat{K}} \preceq \left(1+\Delta \right) \mat{K},\nonumber
\end{equation}
where $\Delta = C\frac{\rho}{\epsilon^2} \log\left(\frac{\rho}{\epsilon^2 \sqrt{\delta}}\right).$
\end{lemma}
\subsubsection{Risk Function for Ridge Regression}
Let ${\mathbf z} = \bf{E}_\omega [{\mathbf y}] = \mat{X}^T {\bm \beta}$. The risk for a prediction function $\hat{\mathbf y} \in \mathbb{R}^n$ is $\frac{1}{n}\bf{E}_\omega {\TNormS{\hat{\mathbf y} -{\mathbf z}}}.$ For any $n\times n$ positive symmetric matrix $\mat{K}$, we define the following risk function:
\begin{equation}
R\left(\mat{K}\right) = \frac{\sigma^2}{n} \Trace{\mat{K}^2 \left(\mat{K}+ n\lambda\mat{I}_n \right)^{-2}}
+ n\lambda^2 {\mathbf z}^T\left(\mat{K}+n\lambda\mat{I}_n \right)^{-2}{\mathbf z}.\nonumber
\end{equation}
\begin{theorem}
\label{thm:thm1}
Under the fixed design setting, the risk for the ridge regression solution in the full-feature space is $R(\mat{K})$ and the risk for the ridge regression in the reduced dimensional space is $R(\tilde\mat{K}).$
\end{theorem}
\begin{proof}
The risk of the ridge regression estimator in the reduced dimensional space is
\begin{equation}
\frac{1}{n}\textbf{E}_\omega\TNormS{\tilde{\matK}\tilde{\bm \alpha}_\lambda-{\mathbf z}} = \frac{1}{n}\textbf{E}_\omega\TNormS{\tilde{\matK}\left(\tilde{\matK}+n\lambda\mat{I}_n\right)^{-1}{\mathbf y} -{\mathbf z} }.
\label{eqn:riskrr}
\end{equation}
Taking $\tilde{\matK}\left(\tilde{\matK}+n\lambda\mat{I}_n\right)^{-1}$ as $\mat{Q}$ we can write Eqn.(\ref{eqn:riskrr}) as,
\begin{eqnarray*}
&&\frac{1}{n} \textbf{E}_\omega \TNormS{\mat{Q}{\mathbf y} - \textbf{E}_\omega\left[ \mat{Q} {\mathbf y} \right]} + \frac{1}{n} \TNormS{\textbf{E}_\omega\left[\mat{Q}{\mathbf y} \right]-{\mathbf z}} \nonumber \\
&=&\frac{1}{n}\textbf{E}_\omega \left[\TNormS{\tilde{\matK}\left(\tilde{\matK}+n\lambda\mat{I}_n\right)^{-1} {\bm \omega}}\right]
+\frac{1}{n} \TNormS{\tilde{\matK}\left(\tilde{\matK}+ n \lambda\mat{I}_n\right)^{-1}{\mathbf z}-{\mathbf z}} \nonumber \\
&=& \frac{1}{n}\Trace{\tilde{\matK}^2 \left(\tilde{\matK}+n \lambda\mat{I}_n\right)^{-2}{\bm \omega}\omegavec^T}+ \frac{1}{n}{\mathbf z}^T\left(\mat{I}_n-\tilde{\matK}\left(\tilde{\matK}+n\lambda\mat{I}_n\right)^{-1}\right)^2 {\mathbf z} \nonumber \\
&=& \frac{\sigma^2}{n}\Trace{\tilde{\matK}^2 \left(\tilde{\matK}+n\lambda\mat{I}_n\right)^{-2}}+ n\lambda^2 {\mathbf z}^T \left(\tilde{\matK}+n\lambda\mat{I}_n\right)^{-2}{\mathbf z}. \nonumber
\end{eqnarray*}
The expectation is only over the random noise ${\bm \omega}$ and is conditional on the feature selection method used.
\end{proof}
Our next theorem bounds the risk inflation of ridge regression in the reduced dimensional space compared with the ridge regression solution in the full-feature space.
\begin{theorem}
\label{thm:thm2}
Let $\rho$ be the rank of the matrix $\mat{X}$. When using leverage-score sampling as a feature selection technique, with probability
at least $1-\delta$, where $\delta\in(0,1)$,
$$R(\tilde{\matK}) \leq (1-\Delta)^{-2}R(\mat{K}),$$ where $\Delta=C\frac{\rho}{\epsilon^2} \log\left(\frac{\rho}{\epsilon^2 \sqrt{\delta}}\right).$
\end{theorem}
\begin{proof}
For any positive semi-definite matrix, $\mat{K} \in \mathbb{R}^{n\times n}$, we define the bias $B(\mat{K})$ and variance $V(\mat{K})$ of the risk function as follows:
$$ B(\mat{K}) = n\lambda^2 {\mathbf z}^T\left(\mat{K}+ n\lambda\mat{I}_n \right)^{-2}{\mathbf z},$$
$$ V(\mat{K}) = \frac{\sigma^2}{n}\Trace{\tilde{\matK}^2 \left(\tilde{\matK}+n\lambda\mat{I}_n\right)^{-2}}.$$
Therefore, $R(\mat{K}) = B(\mat{K}) + V(\mat{K}).$ Now due to \cite{Bach13} we know $B(\mat{K})$ is non-increasing in $\mat{K}$ and $V(\mat{K})$ is non-decreasing in $\mat{K}$. When Lemma ~\ref{lem:lemlvg} holds,
\begin{eqnarray}
R(\tilde{\matK}) &=& V(\tilde{\matK}) + B(\tilde{\matK}) \nonumber \\
&\leq& V\left(\left(1+\Delta\right)\mat{K}\right) + B\left(\left(1-\Delta\right)\mat{K}\right) \nonumber \\
&\leq& \left(1+\Delta\right)^2 V(\mat{K}) + \left(1-\Delta\right)^{-2} B(\mat{K}) \nonumber \\
&\leq& \left(1-\Delta\right)^{-2}\left(V(\mat{K})+B(\mat{K})\right) \nonumber \\
&=& \left(1-\Delta\right)^{-2} R(\mat{K}). \nonumber
\end{eqnarray}
\end{proof}
We can prove a similar theorem for BSS.
\begin{theorem}
\label{thm:thm2}
Let $\rho$ be the rank of the matrix $\mat{X}$. When using BSS as a feature selection technique, with $\Delta=C\rho/\epsilon^2,$
$$R(\tilde{\matK}) \leq (1-\Delta)^{-2}R(\mat{K}).$$
\end{theorem}
\section{Theory}
In this section we describe the theoretical guarantees of RLSC using BSS and also the risk bounds of ridge regression using BSS and Leverage-score sampling. Before we begin, we state the following lemmas from numerical linear algebra which will be required for our proofs.
\begin{lemma}\citep{stewart}
For any matrix $\mat{E}$, such that $\mat{I}+\mat{E}$ is invertible,
$\left(\mat{I}+\mat{E}\right)^{-1}=\mat{I}+\sum\limits_{i=1}^\infty(-\mat{E})^i.$
\label{lem:leminv}
\end{lemma}
\begin{lemma}\citep{stewart}
Let $\mat{A}$ and $\tilde{\mat{A}}= \mat{A}+\mat{E}$ be invertible matrices. Then $$\tilde{\mat{A}}^{-1} - {\mat{A}}^{-1} = -{\mat{A}}^{-1}\mat{E}\tilde{\mat{A}}^{-1}.$$
\label{lem:leminv2}
\end{lemma}
\begin{lemma}\citep{demmel}
Let $\mat{D}$ and $\mat{X}$ be matrices such that the product $\mat{D}\mat{X}\mat{D}$ is a symmetric positive definite matrix with matrix $\mat{X}_{ii}=1$. Let the product $\mat{D}\mat{E}\mat{D}$ be a perturbation such that, $\TNorm{E} = \eta < \lambda_{min}(\mat{X}).$ Here $\lambda_{min}$ corresponds to the smallest eigenvalue of $\mat{X}$. Let $\lambda_i$ be the i-th eigenvalue of $\mat{D}\mat{X}\mat{D}$ and let $\tilde{\lambda}_i$ be the i-th eigenvalue of $\mat{D}\left(\mat{X}+\mat{E}\right)\mat{D}.$ Then,
$\abs{\frac{\lambda_i - \tilde{\lambda}_i}{\lambda_i}} \leq \frac{\eta}{\lambda_{min}\left(\mat{X}\right)}.$
\label{lem:lem5}
\end{lemma}
\begin{lemma}
Let $\epsilon\in(0,1/2]$. Then $\TNorm{{\mathbf q}^T\mat{U}^{\perp}\mat{U}^{\perp T}\mat{R}^T \mat{R}\mat{U}} \leq \epsilon\TNorm{\mat{U}^{\perp}\mat{U}^{\perp T}{\mathbf q}}.$
\label{lem:per3}
\end{lemma}
The proof of this lemma is similar to Lemma 4.3 of \cite{Drineas06}.
\subsection{Our Main Theroems on RLSC}
The following theorem shows the additive error guarantees of the generalization bounds of the approximate classifer with that of the classifier with no feature selection. The classification error bound of BSS on RLSC depends on the condition number of the training set and on how much of the test-set lies in the subspace of the training set.
\begin{theorem}
\label{thm:Thm1}
Let $\epsilon\in(0,1/2]$ be an accuracy parameter, $r=O\left(n/\epsilon^2\right)$ be the number of features selected by BSS.
Let \math{\mat{R}\in\mathbb{R}^{r\times d}} be the matrix, as defined in Lemma~\ref{lem:ssp}. Let $\mat{X} \in \mathbb{R}^{d\times n}$ with $d>> n$, be the training set, $\tilde{\mat{X}} =\mat{R}\mat{X}$ is the reduced dimensional matrix and ${\mathbf q} \in \mathbb{R}^d$ be the test point of the form ${\mathbf q} = \mat{X}\bm{\alpha} + \mat{U}^{\perp}\bm{\beta}$. Then, the following hold:
\begin{itemize}
\item If $\lambda=0$, then $\abs{\tilde{{\mathbf q}}^T\tilde{\mat{X}}\tilde{x}_{opt} - {\mathbf q}^T\mat{X}{\mathbf x}_{opt}} \leq \frac{\epsilon \kappa_{\mat{X}}}{\sigma_{max}} \TNorm{\bm\beta}\TNorm{{\mathbf y}}.$
\item If $\lambda>0$, then $\abs{\tilde{{\mathbf q}}^T\tilde{\mat{X}}\tilde{x}_{opt} - {\mathbf q}^T\mat{X}{\mathbf x}_{opt}} \leq 2\epsilon\kappa_{\mat{X}}\TNorm{\bm{\alpha}}\TNorm{{\mathbf y}} + \frac{2\epsilon \kappa_{\mat{X}}}{\sigma_{max}} \TNorm{\bm\beta}\TNorm{{\mathbf y}}.$
\end{itemize}
\end{theorem}
\begin{proof}
We assume that $\mat{X}$ is a full-rank matrix.
Let $\mat{E} = \mat{U}^T\mat{U} - \mat{U}^T \mat{R}^T\mat{R}\mat{U}$ and $\TNorm{\mat{E}}=\TNorm{\mat{I} - \mat{U}^T \mat{R}^T\mat{R}\mat{U}} = \epsilon\leq 1/2$.
Using the SVD of $\mat{X}$, we define
\begin{equation}
\mat{\Delta} = \mat{\Sigma}\mat{U}^T\mat{R}^T\mat{R}\mat{U}\mat{\Sigma} = \mat{\Sigma}\left(\mat{I}+\mat{E}\right)\mat{\Sigma}.
\label{eqn:delta}
\end{equation}
The optimal solution in the sampled space is given by,
\begin{equation}
\tilde{{\mathbf x}}_{opt} = \mat{V}\left(\mat{\Delta}+\lambda\mat{I}\right)^{-1}\mat{V}^T{\mathbf y}.
\label{eqn:xopt3}
\end{equation}
\noindent
It can be proven easily that $\mat{\Delta}$ and $\mat{\Delta}+\lambda\mat{I}$ are invertible matrices.
We focus on the term ${\mathbf q}^T\mat{X}{\mathbf x}_{opt}.$ Using the SVD of $\mat{X}$, we get
\begin{eqnarray}
{\mathbf q}^T\mat{X}{\mathbf x}_{opt} &=& \bm\alpha^T\mat{X}^T\mat{X}{\mathbf x}_{opt} + \bm\beta\mat{U}^{\perp T}\left(\mat{U}\mat{\Sigma}\mat{V}^T\right){\mathbf x}_{opt} \nonumber \\
&=& \bm\alpha^T\mat{V} \mat{\Sigma}^2\left(\mat{\Sigma}^2+\lambda\mat{I}\right)^{-1} \mat{V}^T{\mathbf y} \label{eqn:eqn8} \\
&=& \bm\alpha^T\mat{V} \left(\mat{I} + \lambda\mat{\Sigma}^{-2}\right)^{-1}\mat{V}^T{\mathbf y}. \label{eqn:eqn9}
\end{eqnarray}
Eqn(\ref{eqn:eqn8}) follows because of the fact $\mat{U}^{\perp T}\mat{U}= \bm0$ and by substituting ${\mathbf x}_{opt}$ from Eqn.(\ref{eqn:xopt}). Eqn.(\ref{eqn:eqn9}) follows from the fact that the matrices $\mat{\Sigma}^2$ and $\mat{\Sigma}^2+\lambda\mat{I}$ are invertible. Now,
\begin{eqnarray}
\abs{{\mathbf q}^T\mat{X}{\mathbf x}_{opt} - \tilde{{\mathbf q}}^T\tilde{\mat{X}}\tilde{{\mathbf x}}_{opt}} &=& \abs{ {\mathbf q}^T\mat{X}{\mathbf x}_{opt} - {\mathbf q}^T\mat{R}^T\mat{R}\mat{X}\tilde{{\mathbf x}}_{opt}} \nonumber \\
&\leq& \abs{ {\mathbf q}^T\mat{X}{\mathbf x}_{opt} - \bm\alpha^T \mat{X}^T\mat{R}^T \mat{R}\mat{X}\tilde{{\mathbf x}}_{opt}} \label{eqn:term1} \\
&& + \abs{\bm\beta^T \mat{U}^{{\perp}T}\mat{R}^T\mat{R}\mat{X}\tilde{{\mathbf x}}_{opt} }. \label{eqn:term2}
\end{eqnarray}
\noindent
We bound (\ref{eqn:term1}) and (\ref{eqn:term2}) separately. Substituting the values of $\tilde{{\mathbf x}}_{opt}$ and $\mat{\Delta}$,
\begin{eqnarray}
\bm\alpha^T \mat{X}^T\mat{R}^T \mat{R}\mat{X}\tilde{{\mathbf x}}_{opt} &=& \bm\alpha^T\mat{V}\mat{\Delta}\mat{V}^T\tilde{{\mathbf x}}_{opt} \nonumber \\
&=& \bm\alpha^T \mat{V}\mat{\Delta}\left(\mat{\Delta} + \lambda\mat{I} \right)^{-1}\mat{V}^T{\mathbf y} \nonumber \\
&=& \bm\alpha^T \mat{V}\left(\mat{I}+\lambda\mat{\Delta}^{-1}\right)^{-1} \mat{V}^T{\mathbf y} \nonumber \\
&=& \bm\alpha^T \mat{V} \left(\mat{I}+ \lambda\mat{\Sigma}^{-1} \left(\mat{I}+\mat{E}\right)^{-1} \mat{\Sigma}^{-1} \right)^{-1} \mat{V}^T {\mathbf y} \nonumber \\
&=& \bm\alpha^T \mat{V} \left(\mat{I}+ \lambda\mat{\Sigma}^{-2} + \lambda\mat{\Sigma}^{-1}\mat{\Phi}\mat{\Sigma}^{-1} \right)^{-1} \mat{V}^T {\mathbf y}. \label{eqn:eqnA}
\end{eqnarray}
\noindent
The last line follows from Lemma \ref{lem:leminv} in Appendix, which states that $\left(\mat{I}+\mat{E}\right)^{-1} = \mat{I}+\mat{\Phi}$, where $\mat{\Phi} = \sum\limits_{i=1}^\infty (-\mat{E})^i$. The spectral norm of $\mat{\Phi}$ is bounded by,
\begin{equation}
\TNorm{\mat{\Phi}} = \TNorm{\sum\limits_{i=1}^\infty (-\mat{E})^i} \leq \sum\limits_{i=1}^\infty \TNorm{\mat{E}}^i \leq \sum\limits_{i=1}^\infty \epsilon^i = \epsilon/(1-\epsilon).
\label{eqn:phi}
\end{equation}
We now bound (\ref{eqn:term1}). Substituting (\ref{eqn:eqn9}) and (\ref{eqn:eqnA}) in (\ref{eqn:term1}),
\begin{eqnarray}
&& \abs{{\mathbf q}^T\mat{X}{\mathbf x}_{opt} - \bm\alpha^T \mat{X}^T\mat{R}^T \mat{R}\mat{X}\tilde{{\mathbf x}}_{opt}} \nonumber \\
&=& \abs{\bm\alpha^T\mat{V}\{\left(\mat{I}+\lambda\mat{\Sigma}^{-2}+\lambda\mat{\Sigma}^{-1}\mat{\Phi}\mat{\Sigma}^{-1} \right)^{-1}-\left(\mat{I}+\lambda\mat{\Sigma}^{-2}\right)^{-1}\}\mat{V}^T{\mathbf y}} \nonumber \\
&\leq& \TNorm{\bm\alpha^T\mat{V}\left(\mat{I}+\lambda\mat{\Sigma}^{-2}\right)} \TNorm{\mat{V}^T{\mathbf y}}\TNorm{\mat{\Psi}}. \nonumber
\end{eqnarray}
\noindent
The last line follows because of Lemma \ref{lem:leminv2} and the fact that all matrices involved are invertible. Here,
\begin{eqnarray}
\mat{\Psi} &=& \lambda\mat{\Sigma}^{-1}\mat{\Phi}\mat{\Sigma}^{-1}\left(\mat{I}+ \lambda\mat{\Sigma}^{-2}+\lambda\mat{\Sigma}^{-1}\mat{\Phi}\mat{\Sigma}^{-1}\right)^{-1} \nonumber \\
&=& \lambda\mat{\Sigma}^{-1}\mat{\Phi} \mat{\Sigma}^{-1}\left(\mat{\Sigma}^{-1}\left(\mat{\Sigma}^2+\lambda\mat{I}+\lambda\mat{\Phi}\right)\mat{\Sigma}^{-1}\right)^{-1} \nonumber \\
&=& \lambda\mat{\Sigma}^{-1}\mat{\Phi}\left(\mat{\Sigma}^2+\lambda\mat{I}+\lambda\mat{\Phi}\right)^{-1}\mat{\Sigma}. \nonumber
\end{eqnarray}
Since the spectral norms of $\mat{\Sigma}, \mat{\Sigma}^{-1}$ and $\mat{\Phi}$ are bounded, we only need to bound the spectral norm of $\left(\mat{\Sigma}^2+\lambda\mat{I}+\lambda\mat{\Phi}\right)^{-1}$ to bound the spectral norm of $\mat{\Psi}$. The spectral norm of the matrix $\left(\mat{\Sigma}^2+\lambda\mat{I}+\lambda\mat{\Phi}\right)^{-1}$ is the inverse of the smallest singular value of $\left(\mat{\Sigma}^2+\lambda\mat{I}+\lambda\mat{\Phi}\right).$ From perturbation theory of matrices \cite{stewart} and (\ref{eqn:phi}), we get
$$\abs{\sigma_i \left(\mat{\Sigma}^2 +\lambda\mat{I}+\lambda\mat{\Phi}\right) - \sigma_i \left(\mat{\Sigma}^2+\lambda\mat{I}\right)}\leq \TNorm{\lambda\mat{\Phi}}\leq \epsilon\lambda.$$ Here, $\sigma_i(\mat{Q})$ represents the $i^{th}$ singular value of the matrix $\mat{Q}$. \\
Also, ${\sigma_i}^2 \left(\mat{\Sigma}^2+\lambda\mat{I}\right) = {\sigma_i}^2+\lambda,$ where $\sigma_i$ are the singular values of $\mat{X}$.
$${\sigma_i}^2+(1-\epsilon)\lambda \leq \sigma_i \left(\mat{\Sigma}^2+\lambda\mat{I}+\lambda\mat{\Phi}\right) \leq {\sigma_i}^2+(1+\epsilon)\lambda.$$
Thus, $$\TNorm{\left(\mat{\Sigma}^2+\lambda\mat{I}+\lambda\mat{\Phi}\right)^{-1}} = 1/\sigma_{min}\left(\mat{\Sigma}^2+\lambda\mat{I}+\lambda\mat{\Phi}\right) \leq 1/\left( {\sigma^2}_{min} + (1-\epsilon)\lambda)\right).$$
Here, $\sigma_{max}$ and $\sigma_{min}$ denote the largest and smallest singular value of $\mat{X}$. Since $\TNorm{\mat{\Sigma}}\TNorm{\mat{\Sigma}^{-1}} = \sigma_{max}/\sigma_{min} \leq \kappa_{\mat{X}}$, (condition number of $\mat{X}$) we bound (\ref{eqn:term1}):\\
\begin{equation}
\abs{{\mathbf q}^T\mat{X} {\mathbf x}_{opt}-\bm\alpha^T \mat{X}^T \mat{R}^T \mat{R}\mat{X} \tilde{{\mathbf x}}_{opt}} \leq \frac{\epsilon\lambda\kappa_{\mat{X}}}{{\sigma^2}_{min}+(1-\epsilon)\lambda} \TNorm{\bm\alpha^T \mat{V}\left(\mat{I}+\lambda\mat{\Sigma}^{-2}\right)^{-1}} \TNorm{\mat{V}^T {\mathbf y}}.
\label{eqn:term1_bound}
\end{equation}
For $\lambda>0$, the term ${\sigma^2}_{min}+(1-\epsilon)\lambda$ in Eqn.(\ref{eqn:term1_bound}) is always larger than $\left(1-\epsilon\right)\lambda$, so it can be upper bounded by $2\epsilon\kappa_{\mat{X}}$ (assuming $\epsilon\leq 1/2$). Also,
$$\TNorm{\bm\alpha^T \mat{V}\left(\mat{I}+\lambda\mat{\Sigma}^{-2}\right)^{-1}} \leq \TNorm{\bm\alpha^T \mat{V}}\TNorm{\left(\mat{I}+\lambda\mat{\Sigma}^{-2}\right)^{-1}} \leq \TNorm{\bm\alpha}.$$
This follows from the fact, that
$\TNorm{\bm\alpha^T\mat{V}}=\TNorm{\bm\alpha}$ and $\TNorm{\mat{V}{\mathbf y}}=\TNorm{{\mathbf y}}$ as $\mat{V}$ is a full-rank orthonormal matrix and the singular values of
$\mat{I}+\lambda\mat{\Sigma}^{-2}$ are equal to $1+\lambda/{\sigma_i}^2$; making the spectral norm of its inverse at most one. Thus we get,
\begin{equation}
\abs{{\mathbf q}^T\mat{X} {\mathbf x}_{opt}-\bm\alpha^T \mat{X}^T \mat{R}^T \mat{R}\mat{X} \tilde{{\mathbf x}}_{opt}} \leq 2\epsilon\kappa_{\mat{X}}\TNorm{\bm\alpha}\TNorm{{\mathbf y}}.
\label{eqn:bound1}
\end{equation}
We now bound (\ref{eqn:term2}). Expanding (\ref{eqn:term2}) using SVD and $\tilde{{\mathbf x}}_{opt}$,
\begin{eqnarray}
\abs{\bm\beta^T \mat{U}^{{\perp}T}\mat{R}^T\mat{R}\mat{X} \tilde{{\mathbf x}}_{opt}} &=&
\abs{\bm\beta^T \mat{U}^{{\perp}T}\mat{R}^T\mat{R}\mat{U}\mat{\Sigma}\left(\mat{\Delta}+\lambda\mat{I}\right)\mat{V}^T {\mathbf y}} \nonumber \\
&\leq& \TNorm{{\mathbf q}^T\mat{U}^{\perp}\mat{U}^{\perp T}\mat{R}^T\mat{R}\mat{U}}\TNorm{\mat{\Sigma}\left(\mat{\Delta}+\lambda\mat{I}\right)^{-1}} \TNorm{\mat{V}^T {\mathbf y}} \nonumber \\
&\leq& \epsilon \TNorm{\mat{U}^{\perp}\mat{U}^{\perp T}{\mathbf q}} \TNorm{\mat{V}^T {\mathbf y}} \TNorm{\mat{\Sigma}\left(\mat{\Delta}+\lambda\mat{I}\right)^{-1}} \nonumber \\
&\leq& \epsilon \TNorm{\bm\beta}\TNorm{{\mathbf y}} \TNorm{\mat{\Sigma}\left(\mat{\Delta}+\lambda\mat{I}\right)^{-1}}. \nonumber
\end{eqnarray}
The first inequality follows from $\bm\beta = \mat{U}^{\perp T}{\mathbf q}$; and the second inequality follows from Lemma \ref{lem:per3}.
To conclude the proof, we bound the spectral norm of $\mat{\Sigma}\left(\mat{\Delta}+\lambda\mat{I}\right)^{-1}$. Note that from Eqn.(\ref{eqn:delta}), $\mat{\Sigma}^{-1}\mat{\Delta}\mat{\Sigma}^{-1} = \mat{I} +\mat{E}$ and $\mat{\Sigma}\matSig^{-1}=\mat{I}$,
$$\mat{\Sigma}\left(\mat{\Delta}+\lambda\mat{I}\right)^{-1}=\left(\mat{\Sigma}^{-1}\mat{\Delta}\mat{\Sigma}^{-1}+\lambda\mat{\Sigma}^{-2}\right)^{-1} \mat{\Sigma}^{-1}= \left(\mat{I}+\lambda\mat{\Sigma}^{-2}+\mat{E}\right)^{-1} \mat{\Sigma}^{-1}.$$
\noindent
One can get a lower bound for the smallest singular value of $\left(\mat{I}+\lambda\mat{\Sigma}^{-2}+\mat{E}\right)^{-1}$ using matrix perturbation theory and by comparing the singular values of this matrix to the singular values of $\mat{I} +\lambda\mat{\Sigma}^{-2}.$
We get,
$$\left(1-\epsilon\right)+\frac{\lambda}{{\sigma_i}^2} \leq {\sigma_i}\left(\mat{I}+\mat{E}+\lambda\mat{\Sigma}^{-2}\right) \leq \left(1+\epsilon\right)+\frac{\lambda}{{\sigma_i}^2}.$$
\begin{eqnarray}
\TNorm{\left(\mat{I}+\lambda\mat{\Sigma}^{-2}+\mat{E}\right)^{-1} \mat{\Sigma}^{-1}} &\leq& \frac{{\sigma^2}_{max}}{\left(\left(1-\epsilon\right){\sigma^2}_{max}+\lambda \right){\sigma_{min}}} \nonumber \\
&=& \frac{\kappa_{\mat{X}}\sigma_{max}}{\left(1-\epsilon\right){\sigma^2}_{max}+\lambda} \nonumber \\
&\leq& \frac{2\kappa_{\mat{X}}}{\sigma_{max}}.
\end{eqnarray}
We assumed that $\epsilon\leq 1/2$, which implies $\left(1-\epsilon\right)+\lambda/{\sigma^2}_{max}\geq 1/2.$ Combining these, we get,
\begin{equation}
\abs{\bm\beta^T \mat{U}^{{\perp}T}\mat{R}^T\mat{R}\mat{X}\tilde{{\mathbf x}}_{opt}} \leq \frac{2\epsilon\kappa_{\mat{X}}}{\sigma_{max}}\TNorm{\bm{\beta}}\TNorm{{\mathbf y}}.
\label{eqn:bound2}
\end{equation}
Combining Eqns (\ref{eqn:bound1}) and (\ref{eqn:bound2}) we complete the proof for the case $\lambda>0$. For $\lambda=0$, Eqn.(\ref{eqn:term1_bound}) becomes zero and the result follows.
\end{proof}
\noindent
Our next theorem provides relative-error guarantees to the bound on the classification error when the test-point has no-new components, i.e. $\bm\beta=\bm0.$
\begin{theorem}
Let $\epsilon\in(0,1/2]$ be an accuracy parameter, $r=O\left(n/\epsilon^2\right)$ be the number of features selected by BSS and $\lambda>0$. Let ${\mathbf q} \in \mathbb{R}^d$ be the test point of the form ${\mathbf q} = \mat{X}\bm{\alpha}$, i.e. it lies entirely in the subspace spanned by the training set, and the two vectors $\mat{V}^T{\mathbf y}$ and $\left(\mat{I}+\lambda\mat{\Sigma}^{-2}\right)^{-1}\mat{V}^T\bm\alpha$ satisfy the property,
\begin{eqnarray}
\TNorm{\left(\mat{I}+\lambda\mat{\Sigma}^{-2}\right)^{-1}\mat{V}^T\bm\alpha}\TNorm{\mat{V}^T{\mathbf y}} &\leq& \omega \TNorm{\left( \left(\mat{I}+\lambda\mat{\Sigma}^{-2}\right)^{-1}\mat{V}^T\bm\alpha\right)^T \mat{V}^T{\mathbf y}} \nonumber \\
&=& \omega\abs{{\mathbf q}^T\mat{X} {\mathbf x}_{opt}} \nonumber
\end{eqnarray}
for some constant $\omega$. If we run RLSC after BSS, then $$\abs{\tilde{{\mathbf q}}^T\tilde{\mat{X}}\tilde{x}_{opt}-{\mathbf q}^T\mat{X}{\mathbf x}_{opt}} \leq 2\epsilon\omega\kappa_{\mat{X}} \abs{{\mathbf q}^T\mat{X}{\mathbf x}_{opt}}.$$
\label{thm:thm2}
\end{theorem}
\noindent
The proof follows directly from the proof of Theorem 1 if we consider $\bm\beta=\bm0$.
|
{'timestamp': '2015-12-08T02:07:20', 'yymm': '1506', 'arxiv_id': '1506.05173', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05173'}
|
arxiv
|
\subsection{Model parameter estimation} \label{sec:estimation}
\vspace{-2mm}
Given a collection of messages $\Hcal(T) = \{ (u_i, m_i, t_i) \}$ recorded during a time period $[ 0, T)$ in a social
network $\Gcal = (\Vcal, \Ecal)$, we can find the optimal parameters $\alphab$, $\mub$, $\Ab$ and $\Bb$ by solving
a maximum likelihood estimation (MLE) problem\footnote{\scriptsize Here, if one decides to model the message
intensities with a Poisson process, $\Bb = 0$.}.
To do so, it is easy to show that the log-likelihood of the messages is given by
\vspace{-2mm}
\begin{equation}\label{eq:log-likelihood}
\mathcal{L}(\alphab, \mub,\Ab, \Bb) = \underbrace{\sum_{e_i \in \Hcal(T)}
\log p(m_i | x^*_{u_i}(t_i))}_{\text{message sentiments}} +
\underbrace{\sum_{e_i \in \Hcal(T)} \log \lambda_{u_i}^*(t_i) - \sum_{u \in
\Vcal} \int_{0}^T \lambda_{u}^*(\tau)\, d\tau}_{\text{message times}}.
\end{equation}
\vspace{-2mm}
Then, we can find the optimal parameters $(\alphab, \mub,\Ab, \Bb)$ using MLE as
\vspace{-1mm}
\begin{equation}
\label{eq:opt-problem}
\begin{aligned}
& \underset{ \alphab, \mub \geq 0, \Ab, \Bb \geq 0}{\text{maximize}}
& & \mathcal{L}(\alphab,\mub, \Ab, \Bb) .
\end{aligned}
\end{equation}
Note that, as long as the sentiment distributions are log-concave, the MLE problem above is concave and thus can be solved efficiently.
Moreover, the problem decomposes in $2 |\Vcal|$ independent subproblems, two per user $u$, since the first term in Eq.~\ref{eq:log-likelihood} only
depends on $(\alphab,\Ab)$ whereas the last two terms only depend on $(\mub,\Bb)$, and thus can be readily parallelized.
Then, we find $(\mub^{*}, \Bb^{*})$ using spectral projected gradient descent~\cite{birgin2000}, which works well in practice and achieves $\varepsilon$
accuracy in $O(\log(1/\varepsilon))$ iterations,
and find $(\alphab^{*},\Ab^{*})$ analytically, since, for Gaussian sentiment distributions, the problem reduces to
a least-square problem.
Fortunately, in each subproblem, we can use the Markov property from Proposition~\ref{prop:opinion-dynamics} to precompute the sums and integrals in \eqref{eq:opt-problem}
in linear time, \ie, $O(|\Hcal_u(T)| + |\cup_{v \in \Ncal(u)} \Hcal_v(T)|)$.
Appendix~\ref{app:estimation-algorithm} summarizes the overall estimation algorithm.
\vspace{-2mm}
\subsection{Model simulation} \label{sec:simulation}
\vspace{-2mm}
We leverage the efficient sampling algorithm for multivariate Hawkes introduced by Farajtabar et al.~\cite{coevolve15nips} to design a scalable
algorithm to sample opinions from our model. The two key ideas that allow us to adapt the procedure by Farajtabar et al. to our model of opinion dynamics, while keeping
its efficiency, are as follows:
(i) the opinion dynamics, defined by Eqs.~\ref{eq:opinion-jsde} and~\ref{eq:intensity-jsde}, are Markovian and thus we can update individual intensities and opinions in $O(1)$ -- let $t_{i}$ and
$t_{i+1}$ be two consecutive events, then, we can compute $\lambda^*(t_{i+1})$ as $(\lambda^*(t_{i}) - \mu) \exp(-\nu (t_{i+1}-t_{i})) + \mu$ and $x^*(t_{i+1})$
as $(x^*(t_{i}) - \alpha) \exp(-\omega (t_{i+1}-t_{i})) + \alpha$, respectively; and,
(ii) social networks are typically sparse and thus both $\Ab$ and $\Bb$ are also sparse, then, whenever a node expresses its opinion, only a small
number of opinions and intensity functions in its local neighborhood will change. As a consequence, we can reuse the majority of samples from the intensity
functions and sentiment distributions for the next new sample.
Appendix~\ref{app:simulation} summarizes the overall simulation algorithm.
\subsection{Analytical forecasting} \label{sec:analytical-forecasting}
\vspace{-2mm}
In this section, we derive a set of formulas to compute the conditional expectation for both Poisson and Hawkes messages intensities. However, since the derivation of such formulas for general multivariate
Hawkes is difficult, we focus here on the case when $b_{vu} = 0$ for all $v, u \in \Gcal, v \neq u$, and rely on the efficient sampling based method for the general case.
\xhdr{I. Poisson intensity} Consider each user'{}s messages follow a Poisson process with rate $\mu_u$. Then,
the conditional average opinion is given by (proven in Appendix~\ref{app:poisson-average}):
\begin{theorem}\label{thm:poisson-average}
Given a collection of messages $\Hcal_{t_0}$ recorded during a time period $[0, t_0)$ and $\lambda^{*}_u(t) = \mu_u$ for all $u \in \Gcal$, then,
\begin{align}\label{eq:poisson-transient}
\EE_{\Hcal_t\backslash\htz}[\xb^{*}(t)|\Hcal_{t_0}]
&= e^{(\Ab\Lambdab_1-\omega I)(t-t_0)}\xb(t_0)+ \omega (\Ab\Lambdab_1-\omega I)^{-1} \left( e^{(\Ab\Lambdab_1-\omega \Ib)(t-t_0)} - \Ib \right) \bm{\alpha},
\end{align}
where $\Lambdab_1 := \diag[\mub]$ and $(\xb(t_0))_{u\in \Vcal}=\alpha_u+\sum_{v\in \Ncal(u)}a_{uv} \sum_{t_i\in\Hcal_v(t_0)} e^{-\omega(t_0-t_i)}m_v(t_i)$.
\end{theorem}
Remarkably, we can efficiently compute both terms in Eq.~\ref{eq:poisson-transient} by using the iterative algorithm by Al-Mohy et al.~\cite{AlmHig11} for the matrix exponentials and
the well-known GMRES method~\cite{SaaSch86} for the matrix inversion.
Given this predictive formula, we can easily study the stability condition and, for stable systems, find the steady state conditional average opinion (proven
in Appendix~\ref{app:poisson-steady}):
\begin{theorem}\label{thm:poisson-steady}
Given the conditions of Theorem~\ref{thm:poisson-average}, if $Re[\xi(\Ab \Lambdab_1)]<\omega$, then,
\begin{equation} \label{eq:poisson-steady}
\lim_{t \to \infty} \EE_{\Hcal_t \backslash \Hcal_{t_0} }[\xb^{*}(t) | \Hcal_{t_0}] = \left(I-\frac{\Ab\Lambdab_1}{w}\right)^{-1}\bm{\alpha}.
\end{equation}
\end{theorem}
The above results indicate that the conditional average opinions are nonlinearly related to the pa\-ra\-me\-ter matrix $\Ab$, which depends on the network structure,
and the message rates $\mub$, which in this case are assumed to be constant and independent on the network structure. Figure~\ref{fig:thdem} provides empirical
evidence of these results.
\xhdr{II. Multivariate Hawkes Process} Consider each user'{}s messages follow a multivariate Hawkes process, given by Eq.~\ref{eq:intensity-multidimensional-hawkes},
and $b_{vu} = 0$ for all $v, u \in \Gcal, v \neq u$.
Then, the conditional average opinion is given by (proven in Appendix~\ref{app:hawkes-opinion-transient}):
\begin{theorem}\label{thm:hawkes-opinion-transient}
Given a collection of messages $\Hcal_{t_0}$ recorded during a time period $[0, t_0)$ and $\lambda^{*}_u(t) = \mu_u + b_{uu} \sum_{e_i \in \Hcal_{u}(t)}e^{-\nu(t-t_i)}$ for all $u \in \Gcal$, then,
the conditional average satisfies the following differential equation:
\begin{align}
\frac{d\EE_{\Hcal_t \backslash \Hcal_{t_0} }[\xb^{*}(t) | \Hcal_{t_0}]}{dt}=[-\omega I +\Ab \Lambdab(t)]\EE_{\Hcal_t \backslash \Hcal_{t_0} }[\xb^{*}(t) | \Hcal_{t_0}]+\omega\alphab, \label{eq:diff-eq} \end{align}
where
\begin{align}
\Lambdab(t) &= \diag\left(\EE_{\Hcal_t \backslash \Hcal_{t_0} }[\lambdab^*(t) | \Hcal_{t_0}]\right), \nonumber \\ \nonumber
\EE_{\Hcal_t\backslash\htz}[\lambdab^{*}(t)|\Hcal_{t_0}]& =e^{(\Bb-\nu I)(t-t_0)}\bm{\eta}(t_0)+\nu (\Bb-\nu I)^{-1} \left( e^{(\Bb-\nu \Ib)(t-t_0)} - \Ib \right) \mub \quad \forall t\geq t_0,\\ \nonumber
(\bm{\eta}(t_0))_{u\in \Vcal}&=\mu_u+\sum_{v\in \Ncal(u)}b_{uv}\sum_{t_i\in\Hcal_v(t_0)}e^{-\nu(t_0-t_i)}, \\ \nonumber
\Bb &= \diag \left( [b_{11}, \ldots, b_{|\Vcal||\Vcal|}]^{\top}\right). \nonumber
\end{align}
\end{theorem}
Here, we can compute the conditional average by solving numerically the differential equation above, which is not stochastic, where we
can efficiently compute the vector $\EE_{\Hcal_t}[\lambdab^*(t)]$ by using again the algorithm by Al-Mohy et al.~\cite{AlmHig11} and the
GMRES method~\cite{SaaSch86}.
In this case, the stability condition and the steady state conditional average opinion are given by (proven in Appendix~\ref{app:hawkes-opinion-steady}):
\begin{theorem}\label{thm:hawkes-opinion-steady}
Given the conditions of Theorem~\ref{thm:hawkes-opinion-transient}, if the transition matrix $\Phi(t)$ associated to the time-varying linear system described by Eq.~\ref{eq:diff-eq}
satisfies that $||\Phi(t)||\leq \gamma e^{-ct}$ $\forall t >0$, where $\gamma,c>0$, then,
\begin{equation} \label{eq:hawkes-opinion-steady}
\lim_{t \to \infty} \EE_{\Hcal_t \backslash \Hcal_{t_0} }[\xb^{*}(t) | \Hcal_{t_0}] = \left(I-\frac{\Ab\Lambdab_2}{w}\right)^{-1}\bm{\alpha},
\end{equation}
where $\Lambdab_2:=\diag\left[\left(I-\frac{\Bb}{\nu}\right)^{-1}\mub\right]$
\end{theorem}
The above results indicate that the conditional average opinions are nonlinearly related to the parameter matrices $\Ab$ and $\Bb$. This suggests that the effect of
the temporal influence on the opinion evolution, by means of the parameter matrix $\Bb$ of the mul\-ti\-va\-riate Hawkes process, is non trivial. We illustrate this result
empirically in Figure~\ref{fig:thdem}.
\begin{figure*}[t]
\captionsetup[subfigure]{labelformat=empty}
\centering
\subfloat[\scriptsize Network $G_1$]{ \includegraphics[width=0.14\textwidth, trim = 0cm -2cm 0cm 0cm]{3_1} \label{fig:3_1}} \hspace{2mm}
\subfloat[\scriptsize P: $\frac{\sum_{u \in \Vcal^{\pm}}\EE[x_u(t)]}{|V^\pm|}$]{ \includegraphics[width=0.17\textwidth]{g1_new} \label{fig:OpTraj3p}} \hspace{2mm}
\subfloat[\scriptsize H: $\frac{\sum_{u \in \Vcal^{\pm}}\EE[x_u(t)]}{|V^\pm|}$]{ \includegraphics[width=0.17\textwidth]{H3_new} \label{fig:OpTraj3h}} \hspace{2mm}
\subfloat[\scriptsize P: Temporal evolution]{ \includegraphics[width=0.17\textwidth]{pCon_new} \label{fig:3_1p}} \hspace{2mm}
\subfloat[\scriptsize H: Temporal evolution]{ \includegraphics[width=0.17\textwidth]{pHawkes_new} \label{fig:3_1h}} \\ \vspace{-2mm}
\subfloat[\scriptsize Network $G_2$]{ \includegraphics[width=0.14\textwidth, trim = 0cm -2cm 0cm 0cm]{4_1} \label{fig:4_1}} \hspace{2mm}
\subfloat[\scriptsize P: $\frac{\sum_{u \in \Vcal} \EE[x_u(t)]}{|V|}$]{ \includegraphics[width=0.17\textwidth]{g2_new} \label{fig:OpTraj4p}} \hspace{2mm}
\subfloat[\scriptsize H: $\frac{\sum_{u \in \Vcal} \EE[x_u(t)]}{|V|}$]{ \includegraphics[width=0.17\textwidth]{H4_new} \label{fig:OpTraj4h}} \hspace{2mm}
\subfloat[\scriptsize P: Temporal evolution]{ \includegraphics[width=0.17\textwidth]{nCon_new} \label{fig:4_1p}} \hspace{2mm}
\subfloat[\scriptsize H: Temporal evolution]{ \includegraphics[width=0.17\textwidth]{nHawkes_new} \label{fig:4_1h}} \\ \vspace{-2mm}
\caption{Opinion dynamics on two 50-node networks $G_1$ (top) and $G_2$ (bottom) for Poisson (P) and Hawkes (H) message intensities.
The first column visualizes the two networks and opinion of each node at $t = 0$ (positive/negative opinions in red/blue).
The second column shows the temporal evolution of the theoretical and empirical average opinion for Poisson intensities.
The third column shows the temporal evolution of the empirical average opinion for Hawkes intensities, where we compute the average
separately for positive ($+$) and negative ($-$) opinions in the steady state.
The fourth and fifth columns shows the polarity of average opinion per user over time.
}
\label{fig:thdem}
\vspace{-5mm}
\end{figure*}
\vspace{-2mm}
\subsection{Simulation based forecasting}
\vspace{-2mm}
Given the efficient simulation procedure described in Section~\ref{sec:simulation}, we can readily derive a general simulation based formula for opinion forecasting:
\vspace{-1mm}
\begin{equation}\label{eq:simulatedE}
\EE_{\Hcal_t \backslash \Hcal_{t_0} }[\xb^{*}(t) | \Hcal_{t_0}] \approx \hat{\xb}^*(t)=\frac{1}{n} \sum_{l=1}^{n} \xb_{l}^{*}(t),
\end{equation}
where $n$ is the number of times that we simulate the opinion dynamics and $\xb_{l}^{*}(t)$ gathers the users'{} opinion at time $t$ for the $l$-th simulation.
Moreover, we have the following theoretical guarantee (proven in Appendix~\ref{app:simulation-guarantee}):
\vspace{-1mm}
\begin{theorem} \label{thm:simulation-guarantee}
Simulate the opinion dynamics up to time $t > t_0$ the following number of times:
\begin{equation}\label{eq:n-bound-gen}
n \geq \frac{1}{3\epsilon^2}(6\sigma^{2}_{\text{max}}+4x_{\text{max}}\epsilon)\log(2/\delta),
\end{equation}
where $\sigma^{2}_{\text{max}} = \max_{u\in\Gcal} \sigma_{\Hcal_t\backslash\htz}^2(x_u^*(t)|\Hcal_{t_0})$ is the maximum variance of the users'{} opinions, which we analyze in
Appendix~\ref{app:simulation-guarantee}, and $x_{\text{max}} \geq |x_u(t)|, \forall u \in \Gcal$ is an upper bound on the users'{} (absolute) opinions.
Then, for each user $u \in \Gcal$, the error between her true and estimated average opinion satisfies that $|\hat{x}_u^*(t) -\EE_{\Hcal_t\backslash\htz}[x_u^*(t)|\Hcal_{t_0}]| \leq \epsilon$ with probability
at least $1 - \delta$.
\end{theorem}
\subsection{Experiments on synthetic data}
\vspace{-1mm}
We first provide empirical evidence that our model is able to produce different types of opinion dynamics, which may or may not converge to a steady state of consensus
or polarization. Then, we show that our model estimation and simulation algorithms as well as our predictive formulas scale to networks with millions of users and events.
Appendix~\ref{app:synthetic} contains an evaluation of the accuracy of our model parameter estimation method.
\xhdr{Different types of opinion dynamics}
We first simulate our model on two different small networks using Poisson intensities, \ie, $\lambda^{*}_u(t) = \mu_u$, $\mu_u \sim U(0,1)$ $ \forall u$, and
then simulate our model on the same networks while using Hackers intensities with $b_{vu} \sim U(0,1)$ on 5\% of the nodes, chosen at random,
and the original Poisson intensities on the remaining nodes.
Figure~\ref{fig:thdem} summarizes the results, which show that (i) our model is able to produce opinion dynamics that converge to consensus
(second column) and polarization (third column); (ii) the opinion forecasting formulas described in Section~\ref{sec:forecasting} closely match an simulation based
estimation (second column); and, (iii) the evolution of the average opinion and whether opinions converge to a steady state of consensus or polarization depend
on the functional form of message intensity\footnote{\scriptsize For these particular networks, Poisson intensities lead to consensus while Hake's intensities lead to
polarization, however, we did find other examples in which Poisson intensities lead to polarization and Hawkes intensities lead to consensus.}.
\xhdr{Scalability}
Figure~\ref{fig:scalability-estimation} shows that our model estimation and simulation algorithms, described in Sections~\ref{sec:estimation} and~\ref{sec:simulation},
and our analytical predictive formulas, described in Section~\ref{sec:analytical-forecasting}, scale to networks with millions of users and events.
For example, our algorithm takes $20$ minutes to estimate the model parameters from 10 million events generated by one million nodes using a single machine
with 24 cores and 64 GB RAM.
\begin{figure}[t]
\centering
\subfloat[Estimation vs \# nodes]{\makebox[0.24\textwidth][c]{\includegraphics[width=0.18\textwidth]{Scalenode_new}}}
\subfloat[Simulation vs \# nodes]{\makebox[0.24\textwidth][c]{\includegraphics[width=0.18\textwidth]{ScaleSimulationnode_new}}}
\subfloat[Forecast vs \# nodes]{\makebox[0.24\textwidth][c]{\includegraphics[width=0.18\textwidth]{VNode_new}}}
\subfloat[Forecast vs $T$]{\makebox[0.27\textwidth][c]{\includegraphics[width=0.17\textwidth]{VTime_new}}}
\vspace{-1mm}
\caption{Panels (a) and (b) show running time of our estimation and simulation procedures against number of nodes, where the average number of events
per node is $10$.
Panels (c) and (d) show the running time needed to compute our analytical formulas against number of nodes and time horizon $T = t - t_0$, where
the number of nodes is $10^3$. In Panel (c), $T = 6$ hours.
For all panels, the average degree per node is $30$.
The experiments are carried out in a single machine with 24 cores and 64 GB of main memory.}
\label{fig:scalability-estimation}
\vspace{-5mm}
\end{figure}
\vspace{-2mm}
\subsection{Experiments on real data}
\vspace{-2mm}
We use real data gathered from Twitter to show that our model can forecast users'{} opinions more accurately than six state
of the art methods~\cite{das2014modeling,de2014learning,degroot1974reaching,hegselmann2002opinion,kim2013sentiment,yildiz2010voting}.
\xhdr{Experimental Setup}
We experimented with five Twitter datasets about current real-world events (Politics, Movie, Fight, Bollywood and US),
in which, for each recorded message $i$, we compute its sentiment value $m_i$ using a popular sentiment analysis toolbox, specially
designed for Twitter~\cite{hannak2012tweetin}. Here, the sentiment takes values $m\in(-1, 1)$ and we consider the sentiment polarity
to be simply $\sgn(m)$.
Appendix~\ref{app:dataset-description} contains further details and statistics about these datasets.
\xhdr{Opinion forecasting}
We first evaluate the performance of our model at predicting sentiment (expressed opinion) at a message level.
To do so, for each dataset, we first estimate the parameters of our model, {\textsc{SLANT}}\xspace, using messages from a training set containing the
(chronologically) first 90\% of the messages. Here, we set the decay parameters of the exponential triggering kernels $\kappa(t)$ and
$g(t)$ by cross-validation.
Then, we evaluate the predictive performance of our opinion forecasting formulas using the last 10\% of the messages\footnote{\scriptsize Here, we do not distinguish
between analytical and sampling based forecasting since, in practice, they closely match each other.}. More specifically, we predict the sentiment
value $m$ for each message posted by user $u$ in the test set given the history up to $T$ hours before the time of the message
as $\hat{m} = E_{\Hcal_t \backslash \Hcal_{t-T}}[x^*_u(t) | \Hcal_{t-T}]$.
We compare the performance of our model with the asynchronous linear model (AsLM)~\cite{de2014learning}, DeGroot'{}s model~\cite{degroot1974reaching},
the voter model~\cite{yildiz2010voting}, the biased voter model~\cite{das2014modeling}, the flocking model~\cite{hegselmann2002opinion}, and
the sentiment prediction method based on colla\-bo\-ra\-tive filtering by Kim et al.~\cite{kim2013sentiment}, in terms of: (i) the mean squared error between the true
($m$) and the estimated ($\hat{m}$) sentiment value for all messages in the held-out set, \ie, $\EE[(m-\hat{m})^2]$, and (ii) the failure rate, defined as the probability
that the true and the estimated polarity do not coincide, \ie, $\PP(\sgn(m) \neq \sgn(\hat{m}))$.
For the baselines algorithms, which work in discrete time, we simulate $N_T$ rounds in $(t-T, t)$, where $N_T$ is the number of posts in time $T$.
Figure~\ref{fig:forcast} summarizes the results, which show that:
(i) our opinion forecasting formulas consistently outperform others both in terms of MSE (often by an order of magnitude) and failure rate;\footnote{\scriptsize The failure rate is very close to zero for those datasets in which
most users post messages with the same polarity.}
(ii) its forecasting performance degrades gracefully with respect to $T$, in contrast, competing methods often fail catastrophically;
and, (iii) it achieves an additional mileage by using Hawkes processes instead of Poisson processes.
To some extent, we believe {\textsc{SLANT}}\xspace'{}s superior performance is due to its ability to leverage historical data to learn its model
parameters and then simulate realistic temporal patterns.
Finally, we look at the forecasting results at a network level and show that our forecasting formulas can also predict the evolution of opinions macroscopically
(in terms of the average opinion across users).
Figure~\ref{fig:trackPerform} summarizes the results for two real world datasets, which show that the forecasted opinions become less accurate as the time $T$
becomes larger, since the average is computed on longer time periods.
As expected, our model is more accurate when the message intensities are
modeled using multivariate Hawkes.
We found qualitatively similar results for the remaining datasets.
\begin{figure*}[!!!t]
\centering
{ \includegraphics[width=0.956\textwidth]{Legend_new}}\\ \vspace*{-3mm}
\hspace*{-0.6cm}\subfloat{ \includegraphics[width=0.215\textwidth]{forecastLog_Twitter_new}}
\hspace*{0.2cm}\subfloat{\includegraphics[width=0.18\textwidth]{forecastLog_VTwitter_new}}
\hspace*{0.2cm}\subfloat{\includegraphics[width=0.18\textwidth]{forecastLog_MlargeTwitter_new}}
\hspace*{0.2cm}\subfloat{ \includegraphics[width=0.18\textwidth]{forecastLog_STwitter_new}}
\hspace*{0.2cm}\subfloat{ \includegraphics[width=0.18\textwidth]{forecastLog_trump_data_new}} \\
\vspace*{-4mm}
\hspace*{-0.6cm}\subfloat[Politics]{\setcounter{subfigure}{1} \includegraphics[height=0.148\textwidth, width=0.215\textwidth]{forecastLog_DTwitter_new}}
\hspace*{0.2cm}\subfloat[Movie]{\includegraphics[width=0.18\textwidth]{forecastLog_DVTwitter_new}}
\hspace*{0.2cm}\subfloat[Fight]{\includegraphics[width=0.18\textwidth]{forecastLog_DMlargeTwitter_new}}
\hspace*{0.2cm}\subfloat[Bollywood]{ \includegraphics[width=0.18\textwidth]{forecastLog_DSTwitter_new}}
\hspace*{0.2cm}\subfloat[US]{ \includegraphics[width=0.18\textwidth]{forecastLog_Dtrump_data_new}}
\vspace{-1mm}
\caption{Sentiment prediction performance using a $10$\% held-out set for each real-world dataset.
Performance is measured in terms of mean squared error (MSE) on the sentiment value, $\EE[(m-\hat{m})^2]$, and failure rate on the sentiment
polarity, $\PP(\sgn(m) \neq \sgn(\hat{m}))$.
For each message in the held-out set, we predict the sentiment value $m$ given the history up to $T$ hours before the time of
the message, for different values of $T$. Nowcasting corresponds to $T=0$ and forecasting to $T > 0$.
The sentiment value $m \in (-1, 1)$ and the sentiment polarity $\sgn{(m)} \in \{-1, 1\}$.}
\label{fig:forcast}
\vspace{-2mm}
\end{figure*}
\section{Proof of Proposition~\ref{prop:opinion-dynamics}} \label{app:opinion-dynamics}
Given $\xb^*(t):=[\xb_1(t),...,\xb_{|\Vcal|}(t)]^T$ and $\lambdab^*(t):=[\lambdab_1(t),...,\lambdab_{|\Vcal|}(t)]^T$, we can compactly rewrite Eqs.~\ref{eq:intensity-multidimensional-hawkes}
and~\ref{eq:opinion} for all users as:
\begin{align}
\xb^* (t)=\alphab+\Ab\int_0 ^t g(t-\theta)\mb(t)\odot d\Nb(t) \label{eq:op-int}
\end{align}
and
\begin{align}
\lambdab^* (t)=\mub+\Bb\int_0 ^t \kappa(t-\theta)\odot d\Nb(t).
\end{align}
Then, it easily follows that
\begin{align}
&d\xb^* (t)=\Ab\int_0 ^t g'(t-\theta)\mb(t)\odot d\Nb(t)+g(0)\Ab \mb(t)\odot d\Nb(t),
\end{align}
where $g(t)=e^{-\omega t}$ and $g'(t-\theta)=-\omega g(t-\theta)$.
And, we can rewrite the above expression as
\begin{align}
&d\xb^* (t
=\omega ( \alphab - \mathbf{x}^{*}(t) ) dt + \mathbf{A} ( \mathbf{m}(t) \odot d\Nb(t) ).
\end{align}
Similarly, we can show that
\begin{align*}
d\lambdab^{*}(t) &= \nu ( \mub - \lambdab^{*}(t) ) dt + \mathbf{B} \, d\Nb(t). \label{eq:intensity-jsde}
\end{align*}
\section{Auxiliary theoretical results} \label{app:diff-eq}
The proofs of Theorems~\ref{thm:poisson-average} and~\ref{thm:hawkes-opinion-steady} rely on the following auxiliary Lemma.
\begin{lemma} \label{lem:diff-eq}
The expected opinion $\EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}]$ in the model of opinion dynamics defined by Eqs.~\ref{eq:opinion} and~\ref{eq:intensity-multidimensional-hawkes} with exponential triggering
kernels with parameters $\omega$ and $\nu$ satisfies the following differential equation:
\begin{equation} \label{eq:diff-general1}
\frac{d\EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}]}{dt}= \Ab \EE_{\Hcal_t\backslash\htz}[\xb^*(t) \odot \lambdab^{*}(t)|\Hcal_{t_0}] - \omega \EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}] + \omega \alphab,
\end{equation}
where $\Ab = (a_{vu})_{v, u \in \Gcal}$ and the sign $\odot$ denotes pointwise product.
\end{lemma}
Using that $\EE[m_v(\theta) | x^*_v(\theta)] = x^*_v(\theta)$, we can compute the average opinion of user $u$ across all possible histories from Eq.~\ref{eq:opinion} as
\begin{align*}
&\EE_{\Hcal_t\backslash\htz}[x^{*}_u(t)|\Hcal_{t_0}]=\alpha_u+\sum_{v\in \Ncal(u)}a_{uv} \int_0 ^t g(t-\theta)\EE_{\Hcal_t\backslash\htz}[m_v(\theta)dN_v(\theta)|\Hcal_{t_0}] \nonumber \\
&= \alpha_u+\sum_{v\in \Ncal(u)}a_{uv} \sum_{t_i\in\Hcal_v(t_0)} g(t-t_i)m_v(t_i)+\sum_{v\in \Ncal(u)}a_{uv} \int_{t_0} ^t g(t-\theta)\EE_{\Hcal(\theta)\backslash\Hcal_{t_0}}\big[x^{*}_v(\theta) \lambda^{*}_v(\theta)|\Hcal_{t_0}\big]d\theta,
\end{align*}
and we can write the expectation of the opinion for all users in vectorial form as
\begin{equation} \label{eq:mean-general}
\EE_{\Hcal_t\backslash\htz}[\xb^{*}(t)]=\vb(t)+\Ab \int_0 ^t g(t-\theta)\EE_{\Hcal(\theta)\backslash\htz}[\xb^{*}(\theta) \odot \lambdab^{*}(\theta)] d\theta,
\end{equation}
where the $\odot$ denotes pointwise product and
\[(\vb(t))_u=\alpha_u+\sum_{v\in \Ncal(u)}a_{uv} \sum_{t_i\in\Hcal_v(t_0)} g(t-t_i)m_v(t_i).\]
Since $g(t)=e^{-\omega t}$, one may observe that $\omega\vb(t)+\dot{\vb}(t)=\omega\alpha$. Then, by differentiating Eq.~\ref{eq:mean-general}, we obtain
\begin{equation} \label{eq:diff-general}
\frac{d\EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}]}{dt}= \Ab \EE_{\Hcal_t\backslash\htz}[\xb^*(t) \odot \lambdab^{*}(t)|\Hcal_{t_0}] - \omega \EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}] + \omega \alphab,
\end{equation}
\section{Proof of Theorem~\ref{thm:poisson-average}} \label{app:poisson-average}
Using Lemma~\ref{lem:diff-eq} and $\lambda^{*}_u(t) = \mu_u$, we obtain
\begin{equation}
\frac{d\EE_{\Hcal_t}[\xb^*(t)]}{dt}=[-\omega I +\Ab \Lambdab_1]\EE_{\Hcal_t}[\xb^*(t)]+\omega\alphab,
\end{equation}
where $\Lambdab_1=\diag[\mub]$.
Then, we apply the Laplace transform to the expression above and obtain
\begin{equation*}
\hat{\xb}(s)=[sI+\omega I-A\Lambdab_1]^{-1}\xb(t_0)+\frac{\omega}{s}[sI+\omega I-A\Lambdab_1]^{-1}\bm{\alpha},
\end{equation*}
where we leverage the fact that, conditioning the prior history, the opinion is non-random, \ie, $\EE_{\Hcal_{t_0}\backslash\Hcal_{t^-_0}}{[\xb(t_0)|\Hcal_{t^- _0}]}=\xb(t_0)$.
Finally, applying the inverse Laplace transform, we obtain the average opinion $\EE_{\Hcal_t\backslash\htz}[\xb^{*}(t)|\Hcal_{t_0}]$ in time domain as
\begin{align*}
\EE_{\Hcal_t\backslash\htz}[\xb^{*}(t)|\Hcal_{t_0}]
&=e^{(\Ab\Lambdab_1-\omega I)(t-t_0)}\xb(t_0)+\omega (\Ab\Lambdab_1-\omega I)^{-1} \left( e^{(\Ab\Lambdab_1-\omega \Ib)(t-t_0)} - \Ib \right)\Big] \bm{\alpha}.
\end{align*}
\vspace{-1mm}
\section{Proof of Theorem~\ref{thm:poisson-steady}} \label{app:poisson-steady}
\vspace{-1mm}
Theorem~\ref{thm:poisson-average} states that the average users' opinion $\EE_{\Hcal_t}[\xb^{*}(t)]$ in time domain is given by
\begin{align*}
\EE_{\Hcal_t\backslash\htz}[\xb^{*}(t)|\Hcal_{t_0}]
&=e^{(\Ab\Lambdab_1-\omega I)(t-t_0)}\xb(t_0)+\omega (\Ab\Lambdab_1-\omega I)^{-1} \left( e^{(\Ab\Lambdab_1-\omega \Ib)(t-t_0)} - \Ib \right)\Big] \bm{\alpha}.
\end{align*}
If $Re[\xi(\Ab\Lambdab_1)]<\omega$, where $\xi(\Xb)$ denote the eigenvalues of matrix $\Xb$, it easily follows that
\begin{equation}
\lim_{t \to \infty} \EE_{\Hcal_t}[\xb^{*}(t)] = \left(I-\frac{\Ab\Lambdab_1}{w}\right)^{-1}\bm{\alpha}.
\end{equation}
\section{Proof of Theorem~\ref{thm:hawkes-opinion-transient}} \label{app:hawkes-opinion-transient}
Assume $b_{vu} = 0$ for all $v, u \in \Gcal, v \neq u$. Then, $\lambda^{*}_v(t)$ only depends on user $v$'{}s history and, since $x^{*}_v(t)$ only depends on the history of the user $v$'s neighbors $\Ncal(v)$,
we can write
\begin{equation*}
\EE_{\Hcal_t\backslash\htz}[\xb^{*}(t) \odot \lambdab^{*}(t)|\Hcal_{t_0}] = \EE_{\Hcal_t\backslash\htz}\big[\xb^{*}(t)|\Hcal_{t_0}\big] \odot \EE_{\Hcal_t\backslash\htz}\big[\lambdab^{*}(t)\big],
\end{equation*}
and rewrite Eq.~\ref{eq:diff-general} as
\begin{align} \label{eq:diff-general-2}
&\frac{d\EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}]}{dt} =\\ & \Ab ( \EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}] \odot \EE_{\Hcal_t\backslash\htz}[\lambdab^{*}(t)|\Hcal_{t_0}] ) \nonumber- \omega \EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}] + \omega \alphab.
\end{align}
We can now compute $\EE_{\Hcal(\theta)\backslash\htz}[\lambdab^{*}(\theta)|\Hcal_{t_0}]$ analytically as follows. From Eq.~\ref{eq:intensity-multidimensional-hawkes},
we obtain
\begin{equation} \label{eq:lambda-lem}
\EE_{\Hcal_t\backslash\htz}\big[\lambdab^*(t)|\Hcal_{t_0}\big]=\bm{\eta}(t)+\int_{t_0} ^t \Bb \kappa(t-\theta) \EE_{\Hcal_\theta\backslash\Hcal_{t_0}}\big[\lambdab^*(\theta)\big] d\theta,
\end{equation}
where $\kappa(t)=e^{-\nu t}$, $[\bm{\eta}(t)]_{u\in \Vcal}=\mu_u+\sum_{v\in \Ncal(u)}b_{uv}\sum_{t_i\in\Hcal_v(t_0)}\kappa(t-t_i)$ and $\Bb = (b_{vu})_{v, u \in \Vcal}$, where $b_{vu}=0$ for all $v \neq u$, by assumption.
Differentiating with respect to $t$, we get,
\begin{align*}
\frac{d}{dt}{\EE_{\Hcal_t\backslash\htz}\big[\lambdab^*(t)|\Hcal_{t_0}\big]}&=-\nu\EE_{\Hcal_t\backslash\htz}\big[\lambdab^*(t)|\Hcal_{t_0}\big]+ \Bb \EE_{\Hcal_t\backslash\htz}\big[\lambdab^*(t)|\Hcal_{t_0}\big]+\nu\mub,
\end{align*}
with initial condition $\EE_{\Hcal(t^+ _0)\backslash\Hcal(t_0)}\lambdab^*(t_0)=\bm{\eta}(t_0)$.
By taking the Laplace transform and then applying inverse Laplace transform,
\begin{equation} \label{eq:lambdab}
\EE_{\Hcal_t\backslash\htz}[\lambdab^{*}(t)|\Hcal_{t_0}] =e^{(\Bb-\nu I)(t-t_0)}\bm{\eta}(t_0)+\nu (\Bb-\nu I)^{-1} \left( e^{(\Bb-\nu \Ib)(t-t_0)} - \Ib \right) \mub\text{ }\forall t\geq t_0,
\end{equation}
where $\bm{\eta}(t_0) = \EE_{\Hcal(t^+ _0)\backslash\Hcal(t_0)} [\lambdab^*(t_0)]$.
Using Eqs.~\ref{eq:diff-general-2} and \ref{eq:lambdab}, as well as $\EE_{\Hcal_t\backslash\htz}[\xb^*(t)] \odot \EE_{\Hcal_t\backslash\htz}[\lambdab^{*}(t)] = \Lambdab(t) \EE_{\Hcal_t\backslash\htz}[\xb^*(t)]$, where
$\Lambdab(t) := \diag[\EE_{\Hcal_t\backslash\htz}[\lambdab^{*}(t)]]$, we obtain
\begin{align*}
&\frac{d\EE_{\Hcal_t\backslash\htz}[\xb^*(t)]}{dt}=[-\omega I +\Ab \Lambdab(t)]\EE_{\Hcal_t\backslash\htz}[\xb^*(t)]+\omega\alphab,
\end{align*}
with initial conditions $(\EE_{\Hcal(t_0 ^+)\backslash \Hcal(t_0)}[\xb^*(t_0)])_{u\in\Vcal}=\alpha_u+\sum_{v\in \Ncal(u)}a_{uv} \sum_{t_i\in\Hcal_v(t_0)} g(t_0-t_i)m_v(t_i)$.
\section{Proof of Theorem~\ref{thm:hawkes-opinion-steady}} \label{app:hawkes-opinion-steady}
\vspace{-1mm}
Theorem~\ref{thm:hawkes-opinion-transient} states that the average users' opinion $\EE_{\Hcal_t}[\xb^{*}(t)]$ in time domain is
given by
\begin{equation}
\frac{d\EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}]}{dt}=[-\omega I +\Ab \Lambdab(t)]\EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}]+\omega\alphab.
\end{equation}
In such systems, solutions can be written as~\cite{Hinrichsen1989}
\begin{equation} \label{eq:system}
\EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}]=\Phi(t) \alpha + \omega\int_0 ^t \Phi(s)\alphab ds,
\end{equation}
where the transition matrix $\Phi(t)$ defines as a solution of the matrix differential equation
\begin{equation*}
\dot{\Phi}(t)=[-\omega I+\Ab \Lambdab(t)]\Phi(t)\text{ with }\Phi(0)=I.
\end{equation*}
If $\Phi(t)$ satisfies $||\Phi(t)||\leq \gamma e^{-ct}$ $\forall t >0$ for $\gamma,c >0$ then the steady state solution
to Eq.~\ref{eq:system} is given by~\cite{Hinrichsen1989}
\begin{align*}
& \lim_{t\to \infty}\EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}]=\left(I-\frac{\Ab\Lambdab_2}{\omega}\right)^{-1}\alphab.
\end{align*}
where $\Lambdab_2 = \lim_{t\to \infty} \Lambdab(t) =\diag\Big[I-\frac{\Bb}{\nu}\Big]^{-1}\mub$.
\newcommand{\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}}{\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}}
\section{Proof of Theorem~\ref{thm:simulation-guarantee}}\label{app:simulation-guarantee}
Let $\{{\xb}_{l}^{*}(t)\}_{l=1} ^n$ be the simulated opinions for all users and define $\bm{s}(t) = \frac{1}{n} \sum_{l=1}^{n} \bm{s}_l(t)$, where
$\bm{s}_l(t) = (\hat{\xb}_l^{*} (t)-\EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}])$.
Clearly, for a given $t$, all elements in $\bm{s}_{l}(t)$ are i.i.d. random variables with zero mean and variance, and we can bound
$|s_u(t)|< 2 x_\text{max}$.
Then, by Bernstein'{}s inequality, the following holds true,
\[\mathbb{P}(|s_u(t)|>\epsilon)=\mathbb{P}(s_u(t)>\epsilon)+\mathbb{P}(s_u(t)<-\epsilon)>2.\text{exp}{\Big(-\frac{3n\epsilon^2}{6\sigma_{\Hcal_t\backslash\htz}^2(x_u^*(t)|\Hcal_{t_0})+4x_\text{max}\epsilon}\Big)}\]
Let $\sigma_{\text{max}} ^2(t)=\max_{u\in\Gcal}\sigma_{\Hcal_t\backslash\htz}^2(x_u^*(t)|\Hcal_{t_0})$. If we choose,
\begin{align}\label{eq:deltaBound}
\delta<2.\text{exp}{\Big(-\frac{3n\epsilon^2}{6\sigma_{\text{max}} ^2 (t)+4x_\text{max}\epsilon}\Big)}
\end{align}
we obtain the required bound for $n$. Moreover, given this choice of $\delta$, we have $\mathbb{P}(|s _u(t)|<\epsilon)>1-\delta$ immediately.
However, a finite bound on $n$ requires the variance $\sigma_{\text{max}} ^2 (t)$ to be bounded for all $t$. Hence, we analyze the variance and its
stability below.
\subsection{Dynamics of variance}\label{app:stabPlusVar}
In this section we compute the time-domain evolution of the variance and characterize its stability for Poisson driven opinion dynamics. A general analysis
of the variance for multidimensional Hawkes is left for future work.
\begin{lemma}\label{stabLem}
Given a collection of messages $\Hcal_{t_0}$ recorded during a time period $[0, t_0)$ and $\lambda^{*}_u(t) = \mu_u$ for all $u \in \Gcal$, the covariance matrix $\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t)$
at any time $t$ conditioned on the history $\Hcal_{t_0}$ can be described as,
\begin{align*}
& \text{vec}(\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t))= \int_0 ^t \Phib{(t-\theta)} \text{vec}[\sigma^2 \Ab\Lambdab \Ab^T+\Ab \diag(\EE_{\Hcal_{t-}}[\xb^*(\theta)])^2\Lambdab \Ab^T]d\theta.
\end{align*}
where
\[\Phib(t)=e^{\big((-\omega I+\Ab\Lambdab)\otimes I+ I \otimes (-\omega I+\Ab\Lambdab)+(\Ab \otimes \Ab )\widehat{\Lambdab}\big)t},\]
$\hat{\Lambdab} _{i^2,i^2}=\lambdab^*(i)$, and $\Lambdab:=\diag[\lambdab]$.
Moreover, the stability of the system is characterized by
\[ \xi\big[(-\omega I+\Ab\Lambdab)\otimes I+ I \otimes (-\omega I+\Ab\Lambdab)+(\Ab \otimes \Ab )\widehat{\Lambdab}\big]<0.\]
\end{lemma}
\xhdr{Proof}
By definition, the covariance matrix is given by
\begin{equation}
\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t):=\EE_{\Hcal_t\backslash\htz}[\big(\xb^*(t)-\EE_{\Hcal_t\backslash\htz}(\xb^*(t))\big)\big(\xb^*(t)-\EE_{\Hcal_t\backslash\htz}(\xb^*(t))\big)^T|\Hcal_{t_0}].
\end{equation}
Hence, if we define $\Delta \xb=(\xb^*(t)-\EE_{\Hcal_t\backslash\htz}(\xb^*(t)))$, we can compute the differential of the covariance matrix as
\begin{equation}\label{eq:dgamma}
d \bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t)= \EE_{\Hcal_t\backslash\htz}[d(\Delta \xb \Delta \xb^T)|\Hcal_{t_0}]=\EE_{\Hcal_t\backslash\htz}[\Delta \xb d(\Delta \xb^T)+ d(\Delta \xb) \Delta \xb^T+d(\Delta \xb)d(\Delta \xb^T)|\Hcal_{t_0}],
\end{equation}
where
\begin{equation}\label{eq:ddeltax0}
d(\Delta \xb) = d(\xb^*(t)-\EE_{\Hcal_t\backslash\htz}(\xb^*(t))) = d(\xb^*(t))- d(\EE_{\Hcal_t\backslash\htz}(\xb^*(t))).
\end{equation}
Next, note that
\begin{align}\label{eq:jump}
&\EE(d\Nb(t) d\Nb^T(t))=\EE[dN_i(t)dN_j(t)]_{i,j\in \Vcal}=\EE[\diag(d\Nb(t))]=\Lambdab,
\end{align}
where the off-diagonal entries vanish, since two jumps cannot happen at the same time point~\cite{hanson2007}.
Now, recall the Markov representation of our model, \ie,
\begin{align}
d{\xb^*}(t)& =-\omega\xb^*(t)dt+\Ab\Mb^*(t)d\Nb(t)+\alphab dt, \label{eq:dx}
\end{align}
where $\Mb^*(t):=\diag[\mb(t)]$ is the diagonal formed by the sentiment vector and
note that,
\begin{align}\label{mNeq}
\mb(t)\odot d\Nb(t)=\Mb^*(t) d\Nb(t)=\diag[d\Nb(t)] \mb(t),
\end{align}
and, using Eq.~\ref{eq:diff-general},
\begin{equation}\label{eq:dEx}
d{\EE_{\Hcal_t\backslash\htz}[ \xb^*(t)|\Hcal_{t_0}]}=-\omega \EE_{\Hcal_t\backslash\htz} [\xb^*(t)|\Hcal_{t_0}] dt +\Ab\Lambda \EE_{\Hcal_t\backslash\htz} [ \xb^*(t)|\Hcal_{t_0}] dt + \omega \alpha dt.
\end{equation}
Then, if we substitute Eqs.~\ref{eq:dx} and~\ref{eq:dEx} in Eq.~\ref{eq:ddeltax0}, we obtain
\begin{equation}\label{eq:ddeltax}
d(\Delta \xb) =-\omega[\xb^*(t)-\EE_{\Hcal_t\backslash\htz}(\xb^*(t)|\Hcal_{t_0})]dt+\Ab[\Mb^*(t)d\Nb(t)-\Lambdab\EE_{\Hcal_t\backslash\htz}(\xb^*(t)|\Hcal_{t_0})dt].
\end{equation}
As a result, we can write
\begin{align}\label{eq:dgamma2}
d \bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t) &= \EE_{\Hcal_t\backslash\htz}\big[-2\omega \Delta \xb \Delta \xb^T dt+\underbrace{\Delta x\big((\Mb^*(t)d\Nb(t)-\Lambdab \EE_{\Hcal_t\backslash\htz}(\xb^*(t))dt\big)^T \Ab^T}_{\text{Term 1}} \nonumber \\
& +\Ab\big(\Mb^*(t)d\Nb(t)-\Lambdab \EE_{\Hcal_t\backslash\htz}(\xb^*(t))dt \big)\Delta x^T \nonumber \\
&+\underbrace{\Ab(\Mb^*(t)d\Nb(t)-\Lambdab \EE_{\Hcal_t\backslash\htz}(\xb^*(t))dt)(\Mb^*(t)d\Nb(t)-\Lambdab \EE_{\Hcal_t\backslash\htz}(\xb^*(t))dt)^T\Ab^T}_{\text{Term 2}} |\Hcal_{t_0} \big],
\end{align}
where Term 1 gives
\begin{align*}
&\EE_{\Hcal_t\backslash\htz}\big[\Delta x\big(\Mb^*(t)d\Nb(t)-\Lambdab \EE_{\Hcal_t\backslash\htz}(\xb^*(t))dt\big)^T\Ab^T\big|\Hcal_{t_0}]\\
&=\EE_{\Hcal_t\backslash\htz}\big[\Delta x(m^*(t)-\EE_{\Hcal_t\backslash\htz}(\xb^*(t))dt)^T\Ab^T|\Hcal_{t_0}\big]\Lambdab dt \text{\hspace*{0.5cm}(Using Eq.~\ref{mNeq} and the fact that $\EE[\diag(d\Nb(t))]=\Lambdab$) }\\
&=\EE_{\Hcal_t\backslash\htz}\Big[\Delta x. \EE\big[(m^*(t)-\EE_{\Hcal_t\backslash\htz}(\xb^*(t)))^T\Ab^T|x(t),\Hcal_{t_0}\big]\Big]\Lambdab dt\\
&=\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t)\Lambdab dt,
\end{align*}
and Term 2 gives
\begin{align*}
\EE_{\Hcal_t\backslash\htz} &\Ab[(\Mb^*(t)d\Nb(t)-\Lambdab\EE_{\Hcal_t\backslash\htz}(\xb^*(t))dt)(\Mb^*(t)d\Nb(t)-\Lambdab\EE_{\Hcal_t\backslash\htz}(\xb^*(t))dt)^T|\Hcal_{t_0}]\Ab^T\\
&=\Ab\EE_{\Hcal_t\backslash\htz}[\Mb^*(t)\EE(d\Nb(t)d\Nb^T(t))\Mb^*(t)|\Hcal_{t_0}]\Ab^T+O(dt^2) \\
&=\Ab\EE_{\Hcal_t\backslash\htz}[\Mb^2(t)|\Hcal_{t_0}]\Lambdab dt\Ab^T \text{\hspace*{0.5cm} (From Eq.~\ref{eq:jump})}\\
&=\Ab(\sigma^2 I+\diag(\EE_{\Hcal_t\backslash\htz}(x(t) ^2)|\Hcal_{t_0}))\Lambdab \Ab^T dt\\
&=\Ab\big[\sigma^2 I+ \bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}_{ii}(t_0,t)+\diag[\EE_{\Hcal_t\backslash\htz}(\xb^*(t)|\Hcal_{t_0})]^2)\big]\Lambdab \Ab^Tdt.
\end{align*}
Hence, substituting the expectations above into Eq.~\ref{eq:dgamma2}, we obtain
\begin{flalign} \label{eq:covariance-dynamics}
&\frac{d\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t)}{dt}=-2\omega\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t)+\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t)\Lambdab \Ab^T+ \Ab \Lambdab \bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t)\\ \nonumber
&+\Ab \bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}_{ii}(t)\Lambdab \Ab^T+
\sigma^2 \Ab \Lambdab \Ab^T+\Ab \diag(\EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}])^2\Lambdab \Ab^T,
\end{flalign}
Eq.~\ref{eq:covariance-dynamics} can be readily written in vectorial form by exploiting the properties of the Kronecker product as
\begin{align}\label{cov-master}
& \frac{d[\text{vec}(\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t)])}{dt}=\Vb(t) \text{vec}(\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t)) + \text{vec}\big(\sigma^2 \Ab \Lambdab \Ab^T+\Ab \diag(\EE_{\Hcal_t\backslash\htz}[\xb^*(t)|\Hcal_{t_0}])^2\Lambdab \Ab^T\big) \nonumber
\end{align}
where
\[\Vb(t)=(-\omega I+\Ab\Lambdab )\otimes I+ I \otimes (-\omega I+\Ab\Lambdab )+\sum_{i=1}^n (\Ab \Lambdab P_i\otimes \Ab P_i ),\]
$P_i = [\delta_{ii}]$ and $\otimes$ stands for the Kronecker product.
Hence, the closed form solution of the above equation can be written as,
\begin{align}\label{eq:poisson-cov}
& \text{vec}(\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t))=\int_0 ^t e^{\Vb(t-\theta)} \text{vec}[\sigma^2 \Ab\Lambdab \Ab^T+\Ab \diag(\EE_{\Hcal(\theta)\backslash\htz}[\xb^*(\theta)|\Hcal_{t_0}])^2\Lambdab \Ab^T]d\theta.
\end{align}
Moreover, the covariance matrix $\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t)$ is bounded iff
\begin{align*}
\text{Re}\big[\lambda[(-\omega I+\Ab\Lambdab)\otimes I+ I \otimes (-\omega I+\Ab\Lambdab)+(\Ab \otimes \Ab )\widehat{\Lambdab}]]<0,
\end{align*}
where $\widehat{\Lambdab}:=\sum_{i=1} ^{|\Vcal|}\Lambdab P_i\otimes P_i$.
In this case, the steady state solution $\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi} = \lim_{t \rightarrow \infty} \bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t)$ is given by
\begin{align}
-2\omega\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}+\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}\Lambdab \Ab^T+\Ab \Lambdab \bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}+\Ab \diag(\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi})\Lambdab \Ab^T+\sigma^2 \Ab\Lambdab \Ab+\Ab \diag(\EE_{\Hcal_{t-}}[\xb^*])^2\Lambdab \Ab^T=0.
\end{align}
that means $\lim_{t\to\infty}\text{vec}[\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t)]$ is same as,
\begin{align}
\text{vec}(\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi})= & {[(-\omega I+\Ab\Lambdab)\otimes I+ I \otimes (-\omega I+\Ab\Lambdab)^T+ (\Ab\otimes \Ab){\hat{\Lambdab}}]}^{-1}\nonumber\\ & \times \text{vec}[\sigma^2 \Ab\Lambdab
\Ab^T+\Ab \diag(\xb_\infty^*)^2\Lambdab \Ab^T]
\end{align}
where $\xb^*=\lim_{t\to\infty}\EE_{\Hcal_t\backslash\htz}(\xb^*(t)|\Hcal_{t_0})$. Finally, the variance of node $u$'{}s opinion at any time $t$ is given by
\[ \sigma_{\Hcal_t\backslash\htz}^2(x_u^*(t)|\Hcal_{t_0}) = [\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t)]_{u,u}=\text{vec}(P_u)^T\text{vec}(\bm{\Gamma}}\newcommand{\Phib}{\bm{\Phi}(t_0,t)), \]
where $P_u$ is the sparse matrix with its only $(u,u)$ entry to
be equal to unity.
\clearpage
\newpage
\section{Parameter estimation algorithm} \label{app:estimation-algorithm}
\newcommand{\vec{\mathbf{1}}}{\vec{\mathbf{1}}}
\subsection{Estimation of $\alphab$ and $\Ab$}
Algorithm~\ref{alg:EstInfInfluence} summarizes the estimation of the opinion dynamics, \ie, $\alphab$ and $\Ab$, which reduces to a least-square problem.
\begin{algorithm}[!h]
\small
\begin{algorithmic}[1]
\STATE\textbf{Input: }{$\mathcal{H}_T$, $G(V,E)$ , regularizer $\lambda$, error bound $\epsilon$ } \\
\STATE\textbf{Output: }{$\hat{\alphab}$, $\hat{\mathbf{A}}$}\\
\STATE\textbf{Initialize: }\\
\STATE IndexForV$[1:|V|]=\vec{0}$
\FOR{$i=1 \text{ to } |\Hcal(T)|$}
\STATE $\Tcal[u_i](\text{IndexForV}[u_i])=(t_i,u_i,m_i)$
\STATE IndexForV$[u_i]$++
\ENDFOR
\FOR{$u\in\Vcal$}
\STATE $i=0$
\STATE $S=\Tcal[u]$
\FOR{$v\in \Ncal(u)$}
\STATE $S=$MergeTimes($S,\Tcal[v]$)
\STATE{\tt // Merges two sets w.r.t $t_i$, takes $O(|\Hcal_u(T)|+|\cup_{v\in\Ncal(u)}\Hcal_v(T)|)$ steps}
\STATE{$\xb_{\text{last}}={0}$}
\STATE{$t_{\text{last}}=0$}
\STATE{$j=0$}
\FOR{$i=1$ to $|S|$ }
\STATE {\tt // This loop takes $O(|S|)=O(|\Hcal_u(T)|+|\cup_{v\in\Ncal(u)}\Hcal_v(T)|)$ steps}
\STATE $(t_v,v,m_v)=S[i]$
\STATE $t_\text{now}=t_v$
\IF{$u=v$}
\STATE $\xb_{\text{now}}=\xb_{\text{last}}e^{-\omega(t_{\text{now}}-t_{\text{last}})}$
\STATE $j$++
\STATE $g[u](j,v)=\xb_{\text{now}}$
\STATE $Y[u](j)=m_u$
\ELSE
\STATE
$\xb_{\text{now}}=\xb_{\text{last}}e^{-\omega(t_{\text{now}}-t_{\text{last}})}+m_v$
\ENDIF
\STATE $t_{\text{last}}=t_{\text{now}}$
\STATE $\xb_{\text{last}}=\xb_{\text{now}}$
\ENDFOR
\ENDFOR
\ENDFOR
\STATE{ \tt // Estimation of $(\alpha,\Ab)$}
\FOR{$u\in \Vcal$}
\STATE $a=$InferOpinionParams($Y[u],\lambda,g[u]$)
\STATE $\hat{\alpha}_u = a[1]$
\STATE $\hat{A}[*][u] = a[1:\text{end}]$
\ENDFOR
\caption{Estimation of $\alphab$ and $\Ab$}
\end{algorithmic}
\end{algorithm}\label{alg:EstInfInfluence}
\newpage
\begin{algorithm}[!!!t]
\small
\caption{InferOpinionParams($Y_u,\lambda, g_u $)}
\label{alg:sampleEvent}
\begin{algorithmic}[1]
\STATE $s=\text{numRows($g_u$)}$
\STATE $X=[\vec{\mathbf{1}} _s \text{ } g_u]$
\STATE $Y=Y_u$
\STATE $L=X'X$
\STATE $x=(\lambda I+L)^{-1}X'Y$
\STATE return $x$
\end{algorithmic}
\end{algorithm}
\subsection{Estimation of $(\mub,\Bb)$}
The first step of the parameter estimation procedure for temporal dynamics also involves the computation of the triggering kernels,
which we do in same way as for the opinion dynamics in Algorithm~\ref{alg:EstInfInfluence}.
In order to estimate the parameters, we adopted the spectral projected gradient descent (SPG) method proposed in~\cite{birgin2000}.
\begin{algorithm}[h]
\small
\begin{algorithmic}[1]
\STATE\textbf{Input: }{$\mathcal{H}_T$, $G(V,E)$ and ${\mu}^0 _u, {\mathbf{B}}^0 _{u^*}$, step-length bound $\alpha_{max}>0$ and initial-step length $\alpha_{bb}\in(0,\alpha_{max}]$, error bound $\epsilon$ and size of memory $h$} \\
\STATE\textbf{Output: }{$\hat{\mu}_u$, $\hat{\mathbf{B}}_{u^*}$}\\
\STATE\textbf{Notation: }\\
$x=[ {\mu} _u$, $ {\mathbf{B}}_{u^*}]$ \\
$f(x)=\sum_{e_i \in \Hcal(T)} \log \lambda_{u_i}^*(t_i) - \sum_{u \in \Vcal} \int_{0}^T \lambda_{u}^*(\tau)\, d\tau$ \\
\STATE\textbf{Initialize: }\\
$k=0$\\
$x_0=[{\mu}^0 _u, {\mathbf{B}}^0 _{u^*}]$
\WHILE{$||d_k||<\epsilon$}
\STATE$\bar{\alpha}_k\leftarrow \min \{ \alpha_{\max},\alpha_{bb}\}$
\STATE$d_k\leftarrow P_c\big[x_k-\bar{\alpha}_k\nabla f^u(x_k)]-x_k$
\STATE$f^u_b\leftarrow\max\{f^u(x_k),f^u(x_{k-1}),...,f^u (x_{k-h})\}$
\STATE$\alpha\leftarrow 1$
\WHILE{$q_k(x_k+\alpha d_k)>f^u_b+\nu\alpha\nabla f^u(x_k)^Td_k$}
\STATE Select $\alpha$ by backtracking line-search;
\ENDWHILE
\STATE $x_{k+1}\leftarrow x_k+\alpha d_k$
\STATE $s_k\leftarrow \alpha d_k$
\STATE $y_k\leftarrow \alpha B_k d_k$
\STATE $\alpha_{bb}\leftarrow y_k^Ty_k/s_k^T y_k$
\STATE $k=k+1$
\ENDWHILE
\caption{Spectral projected gradient descent for $\mu_u$ and $\mathbf{B}_{u^{*}}$}
\end{algorithmic}
\label{alg:SPGHawkes}
\end{algorithm}
\section{Model simulation algorithm} \label{app:simulation}
We leverage the simulation algorithm in~\cite{coevolve15nips} to design an efficient algorithm for simulating opinion-dynamics.
The two basic premises of the simulation algorithm are the sparsity of the network and the Markovian property of the model. Due to sparsity, any sampled event would effect only
a few number of intensity functions, only those of the local neighbors of the node. Therefore, to generate the new sample and to identify the intensity functions that require changes,
we need $O(\log|\Vcal|)$ operations to maintain the heap for the priority queue. On the other hand, the Markovian property allows us to update the rate and opinion in $O(1)$ operations.
The worst-case time-complexity of this algorithm can be found to be $O(d_{\text{max}}|\Hcal(T)||\Vcal|)$, where $d_{\text{max}}$ is the maximum degree.
\begin{algorithm}[h]
\small
\caption{OpinionModelSimulation($T, \mub, \Bb, \alphab, \Ab$)}
\label{alg:simulation}
\begin{algorithmic}[1]
\STATE Initialize the priority queue $Q$
\STATE LastOpinionUpdateTime$[1:|V|]=$ LastIntensityUpdateTime$[1:|V|]=\vec{0}$
\STATE LastOpinionUpdateValue$[1:|V|]=\alphab$
\STATE LastIntensityUpdateValue$[1:|V|]=\mub$
\STATE $\Hcal(0)\leftarrow \emptyset$
\FOR{$u \in \Vcal$}
\STATE $t=$\text{SampleEvent}$(\mub[u],0,u)$
\STATE $Q$.{insert}($[t,u]$)
\ENDFOR
\WHILE{$t<T$}
\STATE {\tt \%\%Approve the minimum time of all posts}
\STATE $[t',u]=Q.\text{ExtractMin}()$
\STATE $t_u=\text{LastOpinionUpdateTime}[u]$
\STATE $x_{t_u}=\text{LastOpinionUpdateValue}[u]$
\STATE $x_{t'_u}\leftarrow \alphab[u]+(x_{t_u}-\alphab[u])e^{-\omega(t-t_u)}$
\STATE $\text{LastOpinionUpdateTime}[u]=t'$
\STATE $\text{LastOpinionUpdateValue}[u]=x_{t'_u}$
\STATE $m_u\sim p(\mb|x_u(t)) $
\STATE $\Hcal(t')\leftarrow \Hcal(t)\cup (t,m_u,u)$
\STATE{\tt \%\% Update neighbors'{}}
\FOR{$\forall v$ \text{such that} $u \rightsquigarrow v$ }
\STATE $t_v=\text{LastIntensityUpdateTime}[v]$
\STATE $\lambda_{t_v}=\text{LastIntensityUpdateValue}[v]$
\STATE $\lambda_{t'_v}\leftarrow \mub[v]+(\lambda_{t_v}-\mub[v])e^{-\omega(t-t_v)}+\Bb_{uv}$
\STATE $\text{LastIntensityUpdateTime}[v]=t'$
\STATE $\text{LastIntensityUpdateValue}[v]=\lambda_{t'_v}$
\STATE $t_v=\text{LastOpinionUpdateTime}[v]$
\STATE $x_{t_v}=\text{LastOpinionUpdateValue}[v]$
\STATE $x_{t'_v}\leftarrow \alphab[v]+(x_{t_v}-\alphab[v])e^{-\omega(t-t_v)}+\Ab_{uv}m_u$
\STATE $\text{LastOpinionUpdateTime}[v]=t'$
\STATE $\text{LastOpinionUpdateValue}[v]=x_{t'_v}$
\STATE{\tt \%\%Sample by only effected nodes}
\STATE $t_+=$SampleEvent($\lambda_v(t'),t',v$)
\STATE $Q.$UpdateKey($v,t_+ $)
\ENDFOR
\STATE $t\leftarrow t'$
\ENDWHILE
\STATE return $\Hcal(T)$
\end{algorithmic}
\label{alg:opDynamicsSim}
\end{algorithm}
\begin{algorithm}[!!!h]
\small
\caption{SampleEvent($\lambda,t,v$)}
\label{alg:sampleEvent}
\begin{algorithmic}[1]
\STATE$\bar{\lambda}=\lambda$, $s\leftarrow t$
\WHILE {$s<T$}
\STATE $\Ucal\sim\text{Uniform}[0,1]$
\STATE $s=s-\frac{\ln \Ucal}{\bar{\lambda}}$
\STATE $\lambda(s)\leftarrow \mub[v]+(\lambda_v(t)-\mub[v])e^{-\omega(s-t)} $
\STATE $d\sim\text{Uniform}[0,1]$
\IF {$d\bar{\lambda}<\lambda$}
\STATE break
\ELSE
\STATE $\bar{\lambda}=\lambda(s)$
\ENDIF
\ENDWHILE
\STATE return $s$
\end{algorithmic}
\end{algorithm}
\clearpage
\newpage
\section{Experiments on Synthetic Data} \label{app:synthetic}
\xhdr{Parameter estimation accuracy}
We evaluate the accuracy of our model estimation procedure on three types of Kronecker networks~\cite{LeskovecCKFG10}:
i) Assortative networks (parameter matrix $[0.96,0.3; 0.3,0.96]$), in which nodes tend to link to nodes with similar degree;
ii) dissortative networks ($[0.3, 0.96;0.96,0.3]$), in which nodes tend to link to nodes with different degree;
and iii) core-periphery networks ($[0.9, 0.5;0.5,0.3]$).
For each network, the message intensities are multivariate Hawkes, $\mub$ and $\Bb$ are drawn from a uniform distribution $U(0,1)$, and
$\alphab$ and $\Ab$ are drawn from a Gaussian distribution $\mathcal{N}(\mu=0,\sigma=1)$.
We use exponential kernels with parameters $\omega=100$ and $\nu=1$, respectively, for opinions $\mathbf{x}^{*}_u(t)$ and intensities $\lambdab^{*}(t)$.
We evaluate the accuracy of our estimation procedure in terms of mean squared error (MSE), between the estimated and true parameters,
\ie, $\EE[(x-\hat{x})^2]$.
Figure~\ref{fig:kronecker-estimation} shows the MSE of the parameters $(\alphab, \Ab)$, which control the Hawkes intensities, and the parameters $(\mub, \Bb)$,
which control the opinion updates. As we feed more messages into the estimation procedure, it becomes more accurate.
\begin{figure}[h]
\centering
\subfloat[Temporal parameters, $(\alphab, \Ab)$]{\makebox[0.3\textwidth][c]{\includegraphics[width=0.25\textwidth]{KronParamErrorCont_new}}} \hspace{2mm}
\subfloat[Opinion parameters, $(\mub, \Bb)$]{\makebox[0.3\textwidth][c]{\includegraphics[width=0.25\textwidth]{KronParamErrorEvents_new}}}
\vspace{-1mm}
\caption{Performance of model estimation for several $512$-node kronecker networks in terms of mean squared error between estimated and true parameters. As we feed more
messages into the estimation procedure, the estimation becomes more accurate.}
\label{fig:kronecker-estimation}
\vspace{-3mm}
\end{figure}
\clearpage
\newpage
\section{Twitter dataset description} \label{app:dataset-description}
We used the Twitter search API\footnote{\scriptsize \url{https://dev.twitter.com/rest/public/search}} to collect all the tweets (corresponding to a 2-3 weeks period around the event date) that contain hashtags
related to the following events/topics:
\begin{itemize}[noitemsep,nolistsep]
\item \textbf{Politics:} Delhi Assembly election, from 9th to 15th of December 2013.
\item \textbf{Movie:} Release of ``\emph{Avengers: Age of Ultron}'' movie, from April 28th to May 5th, 2015.
\item \textbf{Fight:} Professional boxing match between the eight-division world champion Manny Pacquiao and the undefeated five-division world champion Floyd Mayweather Jr., on May 2, 2015.
\item \textbf{Bollywood:} Verdict that declared guilty to Salman Khan (a popular Bollywood movie star) for causing death of a person by rash and negligible driving, from May 5th to 16th, 2015.
\item \textbf{US:} Presidential election in the United-States, from April 7th to 13th, 2016.
\end{itemize}
We then built the follower-followee network for the users that posted the collected tweets using the Twitter rest API\footnote{\scriptsize \url{https://dev.twitter.com/rest/public}}.
Finally, we filtered out users that posted less than 200 tweets during the account lifetime, follow less than 100 users, or have less than 50 followers.
\begin{table}[!h]
\small
{\centering\begin{tabular}{|p{2.4cm}|c|c|c|c|c|}
\hline%
\textbf{Dataset} &\textbf{ $\mathbf{|\Vcal|}$} & \textbf{$\mathbf{|\Ecal|}$} & \textbf{$|\Hcal(T)|$} & $\mathbf{\EE[m]}$ & \textbf{$\text{std}[m]$} \\ \hline \hline
{Tw: Politics} & 548 &5271 &20026 & 0.0169&0.1780\\ \hline
{Tw: Movie} & 567 & 4886 & 14016 & 0.5969&0.1358 \\ \hline
{Tw: Fight} & 848 &10118 & 21526 & -0.0123&0.2577\\ \hline
{Tw: Bollywood} & 1031 &34952 & 46845 & 0.5101&0.2310\\ \hline%
{Tw: US}& 533 &20067 &18704& -0.0186& 0.7135\\ \hline%
\end{tabular}
\caption{Real datasets statistics}
\label{tab:datasets}}
\end{table}
\section{Introduction}
\label{sec:intro}
\vspace{-2mm}
\input{010intro}
\vspace{-2mm}
\section{Proposed model}
\label{sec:model}
\vspace{-2mm}
\input{020model}
\vspace{-2mm}
\section{Opinion forecasting}
\label{sec:forecasting}
\vspace{-2mm}
\input{030forecasting}
\vspace{-2mm}
\section{Experiments}
\label{sec:experiments}
\vspace{-2mm}
\input{040experiments}
\vspace{-4mm}
\section{Conclusions}
\label{sec:conclusions}
\vspace{-3mm}
\input{050conclusions}
\vspace{-2mm}
{
\bibliographystyle{abbrv}
|
{'timestamp': '2016-05-25T02:11:59', 'yymm': '1506', 'arxiv_id': '1506.05474', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05474'}
|
arxiv
|
\section{Introduction}
Bayesian statistics has provided a principled and robust framework to create many important and powerful data analysis methods over the past several decades. Given a probabilistic model for the underlying mechanism of observed data, Bayesian methods properly quantify uncertainty and reveal the landscape or global structure of the parameter space. However, these methods tend to be computationally intensive since Bayesian inference usually requires the use of Markov Chain Monte Carlo (MCMC) algorithms to simulate samples from intractable distributions. Although the simple Metropolis algorithm \cite{metropolis53} is often effective at exploring low-dimensional distributions, it can be very inefficient for complex, high-dimensional distributions: successive states may exhibit high autocorrelation, due to the random walk nature of the movement. As a result, the effective sample size tends to be quite low and the convergence to the true distribution is usually very slow. The celebrated Hamiltonian Monte Carlo (HMC) \cite{duane87, neal11} reduces the random walk behavior of Metropolis by Hamiltonian dynamics, which uses gradient information to propose states that are distant from the current state, but nevertheless have a high probability of acceptance.
Although HMC explores the parameter space more efficiently than random walk Metropolis does, it does not fully exploit the structure (i.e., geometric properties) of parameter space \cite{girolami11} since dynamics are defined over Euclidean space. To address this issue, Girolami and Calderhead \cite{girolami11} proposed a new method, called Riemannian Manifold HMC (RMHMC), that uses the Riemannian geometry of the parameter space \cite{amari00} to improve standard HMC's efficiency by automatically adapting to local structures.
To make such geometrically motivated methods practical for big data analysis, one needs to combine them with efficient and scalable computational techniques. A common bottleneck for using such sampling algorithms for big data analysis is repetitive evaluations of functions, their derivatives, geometric and statistical quantities that involves the whole observed data and maybe a complicated model. A natural question is how to construct effective approximation of these quantities that provides a good balance between accuracy and computation cost. One common approach is subsampling (see, for example, \cite{wellingTeh11, hoffman10, shahbabaSplitHMC, chen14}), which restricts the computation to a subset of the observed data. This is based on the idea that big datasets contain a large amount of redundancy so the overall information can be retrieved from a small subset. However, in general applications, we cannot simply use random subsets for this purpose: the amount of information we lose as a result of random sampling leads to non-ignorable loss of accuracy, which in turn has a substantially negative impact on computational efficiency \cite{Betancourt15}. Therefore, in practice, it is a challenge to find good criteria and strategies for an appropriate and effective subsampling.
Another approach is to exploit smoothness or regularity in parameter space, which is true for most statistical models. This way, one could find computationally cheaper surrogate functions to substitute the expensive target (or potential energy) functions \cite{liu01, rasmussen03, zhang15, meeds14, lan15, strathmann15}. However, the usefulness of these methods is often limited to moderate dimensional problems because of the computational cost needed to achieve desired approximation accuracy.
In this work, our objective is to develop a faster alternative to the method of \cite{rasmussen03}. To this end, we propose to use random nonlinear bases along with efficient learning algorithms to construct a surrogate functions that provides effective approximation of the probabilistic model based on the collective behavior of the large data. The randomized nonlinear basis functions combined with the computationally efficient learning process can incorporate correct criteria for an efficient implicit subsampling resulting in both flexible and scalable approximation \cite{huang06,huang06chen,rahimi07,rahimi08}. Because our method can be presented as a special case of shallow random networks implemented in HMC, we refer to it as \emph{random network surrogate function}; however, we will show that our proposed method is related to (and can be extended to) other surrogate functions such as generalized additive models and Gaussian process models by constructing the surrogate functions using different bases and optimization process.
Our proposed method provides a natural framework to incorporate surrogate functions in the sampling algorithms such as HMC, and it can be easily extended to geometrically motivated methods such as Riemannian Manifold HMC. Further, for problems with a limited time budget, we propose an adaptive version of our method that substantially reduces the required number of training points. This way, the random bases surrogate function could be utilized earlier and its approximation accuracy could be improved adaptively as more training points become available. We show that theoretically the learning procedure for our surrogate function is asymptotically equivalent to {\em potential matching}, which is itself a novel distribution matching strategy similar to the {\em score matching} method discussed in \cite{hyvarinen05, strathmann15}.
Finally, we should emphasize that out method is used to generate high quality proposals at low computational cost. However, when calculating the acceptance probability of these proposals, we use the original Hamiltonian (used in standard HMC) to ensure that the stationary distribution of the Markov chain will remain the correct target distribution.
Our paper is organized as follows. An overview of HMC and RMHMC is given in Section \ref{sec:preliminaries}. Our random network surrogate HMC is explained in detail in Section \ref{sec:RNSHMC}. The adaptive model is developed in Section \ref{sec:OLRNSHMC}. Experimental results based on simulated and real data are presented in Section \ref{sec:results}. Code for these examples is available at \textcolor{blue}{\url{github.com/chengzhang-uci/RNSHMC}.} Finally, Section \ref{sec:discussion} is devoted to discussion and future work. As an interesting supplement, an overall description of the {\em potential matching} procedure is presented in Section \ref{sec:potentialmatching} in the appendix.
\section{Preliminaries}
\label{sec:preliminaries}
\subsection{Hamiltonian Monte Carlo}
In Bayesian Statistics, we are interested in sampling from the posterior distribution of the model parameters $q$ given the observed data, $Y=(y_1,y_2,\ldots,y_N)^T$,
\begin{equation}
P(q|Y) \propto \exp(-U(q)),
\end{equation}
where the potential energy function $U$ is defined as
\begin{equation} \label{eq:U}
U(q) = -\sum_{i=1}^N\log P(y_i|q) -\log P(q).
\end{equation}
The posterior distribution is almost always analytically intractable. Therefore, MCMC algorithms are typically used for sampling from the posterior distribution to perform statistical inference. As the number of parameters increases, however, simple methods such as random walk Metropolis \cite{metropolis53} and Gibbs sampling \cite{geman84} may require a long time to converge to the target distribution. Moreover, their explorations of parameter space become slow due to inefficient random walk proposal-generating mechanisms, especially when there exist strong dependencies between parameters in the target distribution. By inclusion of geometric information from the target distribution, HMC \cite{duane87,neal11} introduces a Hamiltonian dynamics system with auxiliary momentum variables $p$ to propose samples of $q$ in a Metropolis framework that explores the parameter space more efficiently compared to standard random walk proposals. More specifically, HMC generates proposals jointly for $q$ and $p$ using the following system of differential equations:
\begin{align}
\frac{dq_i}{dt} &= \frac{\partial H}{\partial p_i}\label{eq:Hq}\\
\frac{dp_i}{dt} &= -\frac{\partial H}{\partial q_i}\label{eq:Hp}
\end{align}
where the Hamiltonian function is defined as $H(q,p) = U(q) + \frac12p^TM^{-1}p$. The quadratic kinetic energy function $K(p) = \frac12p^TM^{-1}p$ corresponds to the negative log-density of a zero-mean multivariate Gaussian distribution with the covariance $M$. Here, $M$ is known as the mass matrix, which is often set to the identity matrix, $I$. Starting from the current state $(q,p)$, the Hamiltonian dynamics system \eqref{eq:Hq},\eqref{eq:Hp} is simulated for $L$ steps using the leapfrog method, with a stepsize of $\epsilon$. The proposed state, $(q^{\ast},p^{\ast})$, which is at the end of the trajectory, is accepted with probability $\min(1,\exp[-H(q^{\ast},p^{\ast}) + H(q,p)])$. By simulating the Hamiltonian dynamics system together with the correction step, HMC generates samples from a joint distribution
\[
P(q,p) \propto \exp\left(-U(q)-\frac12p^TM^{-1}p\right)
\]
Notice that $q$ and $p$ are separated, the marginal distribution of $q$ then follows the target distribution.
These steps are presented in Algorithm \ref{alg:HMC}.
\begin{algorithm}[t]
{\small
\KwIn{Starting position $q^{(1)}$ and step size $\epsilon$}
\For{$t =1,2,\cdots$ }{
\textit{Resample momentum $p$}\\
$p^{(t)} \sim \mathcal{N}(0,M),\;(q_0,p_0)$ = $(q^{(t)},p^{(t)})$\\
\textit{Simulate discretization of Hamiltonian dynamics:}\\
\For{$l = 1$ to $L$} {
$p_{l-1} \leftarrow p_{l-1} - \frac{\epsilon}{2} \frac{\partial U}{\partial q}(q_{l-1})$\\
$q_l \leftarrow q_{l-1} + \epsilon M^{-1}p_{l-1}$\\
$p_l \leftarrow p_l - \frac{\epsilon}{2} \frac{\partial U}{\partial q}(q_{l})$
}
$(q^{\ast},p^{\ast}) = (q_L,p_L)$\\
\textit{Metropolis-Hasting correction:} \\
$u \sim \text{Uniform}[0,1]$\\
$\rho = \exp[{ H(q^{(t)},p^{(t)})-H(q^{\ast},p^{\ast}) }]$\\
\lIf{$u < \min(1,\rho)$,} {$q^{(t+1)} = q^{\ast}$}
}
\caption{Hamiltonian Monte Carlo}
}
\label{alg:HMC}
\end{algorithm}
Following the dynamics of the assumed Hamiltonian system, HMC can generate distant proposals with high acceptance probability which allows an efficient exploration of parameter space.
\subsection{Riemannian Manifold HMC}
Although HMC explores the target distribution more efficiently than random walk Metropolis, it does not fully exploit the geometric structures of the underlying probabilistic model since a flat metric (i.e., ${M} = {I}$) is used. Using more geometrically motivated methods could substantially improves sampling algorithms' efficiency. Recently, Girolami and Calderhead \cite{girolami11} proposed a new method, called Riemannian Manifold HMC (RMHMC), that exploits the Riemannian geometry of the target distribution to improve standard HMC's efficiency by automatically adapting to local structures. To this end, instead of the identity mass matrix commonly used in standard HMC, they use a position-specific mass matrix ${M} = { G}({q})$. More specifically, they set ${G}({q})$ to the Fisher information matrix, and define Hamiltonian as follows:
\begin{equation}\label{rmhamiltonp}
H({q}, { p}) = U({q}) +\frac12 \log\det { G}({q}) +
\frac12 { p}^{T}{ G}({q})^{-1}{ p} = \phi(q) + \frac12 { p}^{T}{ G}({q})^{-1}{ p}
\end{equation}
where $\phi(q):= U(q) +\frac12 \log\det G(q)$. Note that standard HMC is a special case of RMHMC with $G(q) = I$. Based on this dynamic, they propose the following HMC on Riemmanian manifold:
\begin{eqnarray}\begin{array}{lcrcr }
\displaystyle
\dot q & = & \nabla_p H(q, p) & = & G(q)^{-1}p \\ [12pt]
\displaystyle
\dot p & = & -\nabla_q H(q, p)& = & -\nabla_q \phi(q) +
\frac12 \nu(q,p)
\end{array}\label{eq:rmhmc}\end{eqnarray}
where the $i$th element of the vector $\nu(q,p)$ is
\begin{eqnarray*}
(\nu(q,p))_i = -p^{T} \partial_i ( G(q)^{-1})p = ({G(q)^{-1}p})^{T} \partial_i G(q) {G(q)^{-1}p}
\end{eqnarray*}
with the shorthand notation $\partial_i = {\partial}/{\partial q_i}$ for partial derivative.
The above dynamic is non-separable (it contains products of $q$ and $p$), and the resulting proposal generating mechanism based on the standard leapfrog method is neither time-reversible nor symplectic. Therefore, the standard leapfrog algorithm cannot be used for the above dynamic \cite{girolami11}. Instead, we can use the St\"omer-Verlet \cite{verlet67} method, known as generalized leapfrog \cite{leimkuhler04},
\begin{eqnarray}\label{gleapfrog}
p^{(t+1/2)}
& = & p^{(t)} - \frac{\epsilon}{2} \left[\nabla_q\phi(q^{(t)})-\frac12
\nu(q^{(t)},p^{(t+1/2)})\right] \label{gleapfrog:imp1}\\
q^{(t+1)}
& = & q^{(t)} + \frac{\epsilon}{2} \left[G^{-1}(q^{(t)}) + G^{-1}(q^{(t+1)})\right]p^{(t+1/2)}\label{gleapfrog:imp2}\\
p^{(t+1)}
& = & p^{(t+1/2)} - \frac{\epsilon}{2}\left[\nabla_q\phi(q^{(t+1)})-\frac12
\nu(q^{(t+1)},p^{(t+1/2)})\right]
\end{eqnarray}
The resulting map is 1) deterministic, 2) reversible, and 3) volume-preserving. However, it requires solving two computationally intensive implicit equations (Equations \eqref{gleapfrog:imp1} and \eqref{gleapfrog:imp2}) at each leapfrog step.
\section{Random Network Surrogate HMC (RNS-HMC)}
\label{sec:RNSHMC}
For HMC, the Hamiltonian dynamics contains the information from the target distribution through the potential energy $U$ and its gradient. For RMHMC, more geometric structure (i.e., the Fisher information) is included through the mass matrix for kinetic energy. It is the inclusion of such information in the Hamiltonian dynamics that allows HMC and RMHMC to improve upon random walk Metropolis. However, one common computational bottleneck for HMC and other Bayesian models for big data is repetitive evaluations of functions, their derivatives, geometric and statistical quantities. Typically, each evaluation involves the whole observed data. For example, one has to compute the potential $U$ and its gradient from the equation (\ref{eq:U}) for HMC and mass matrix $M$, its inverse and the involved partial derivatives for RMHMC \emph{at every time step or M-H correction step}. When $N$ is large, this can be extremely expensive to compute. In some problems, each evaluation may involve solving a computationally expensive problem. (See the inverse problem and Remark in Section \ref{sec:PDE}.)
To alleviate this issue, in recent years several methods have been proposed to construct \emph{surrogate} Hamiltonians. For relatively low dimensional spaces, (sparse) grid based piecewise interpolative approximation using precomputing strategy was developed in \cite{zhang15}. Such grid based methods, however, are difficult to extend to high dimensional spaces due to the use of structured grids. Alternatively, we can use Gaussian process model, which are commonly used as surrogate models for emulating expensive-to-evaluate functions, to learn the target functions from early evaluations (training data) \cite{rasmussen03, lan15, meeds14}. However, naive (but commonly used) implementations of Gaussian process models have high computation cost associated with inverting the covariance matrix, which grows cubically as the size of the training set increases. This is especially crucial in high dimensional spaces, where we need large training sets in order to achieve a reasonable level of accuracy. Recently, scalable Gaussian processes using induing point methods \cite{snelson06,joaquin05} have been introduced to scale up GPs to larger datasets. While these methods have been quite succsessful in reducing computation cost, the tuning of inducing points could still be problematic in high dimensional spaces. (See a more detailed discussion in Section \ref{sec:SPGP}.)
The key in developing surrogate functions is to develop a method that can effectively capture the collective properties of large datasets with scalability, flexibility and efficiency. In this work, we propose to construct surrogate functions using proper random nonlinear bases and efficient optimization process on training data. More specifically, we present our method as a special case of shallow neural networks; although, we show that it is related to (and can be extended to) other surrogate functions such as generalized additive models and Gaussian process models. Random networks of nonlinear functions prove capable of approximating a rich class of functions arbitrarily well \cite{huang06chen,rahimi08}. Using random nonlinear networks and algebraic learning algorithms can also be viewed as an effective implicit subsampling with desired criteria. The choice of hidden units (basis functions) and the fast learning process can be easily adapted to be problem specific and scalable. Unlike typical (naive) Gaussian process models, our random network scales linearly with the number of training points. In fact, a random nonlinear network can be considered as a standard regression model with randomly mapped features. For such shallow random networks, the computational cost for inference is cubic in the number of hidden nodes. Those differences in scaling allow us to explicitly trade off computational efficiency and approximation accuracy and construct more efficient surrogate in certain applications. As our empirical results suggest, with appropriate training data good approximation of smooth functions in high dimensional space can be achieved using a moderate and scalable number of hidden units. Therefore, our proposed method has the potential to scale up to large data sizes and provide effective and scalable surrogate Hamiltonians that balance accuracy and efficiency well.
\subsection{Shallow Random Network Approximation}
A typical shallow network architecture (i.e., a single-hidden layer feedforward scalar-output neural network) with $s$ hidden units, a nonlinear activation function $a$, and a scalar (for simplicity) output $z$ for a given {\it d}-dimensional input $q$ is defined as
\begin{equation}\label{eq:nn}
z(q) = \sum_{i=1}^sv_ia(q;\gamma_i)+b
\end{equation}
where $\gamma_i$ is the {\it i}th hidden node parameter, $v_i$ is the output weight for the {\it i}th hidden node, and $b$ is the output bias. Given a training data set
\[\mathcal{T} = \{(q^{(j)},t^{(j)})|q^{(j)}\in\mathbb{R}^d,\;t^{(j)}\in\mathbb{R},\; j = 1,\ldots,N\}\] the neural network can be trained by finding the optimal model parameters $\vect{W}=\{\gamma_i,v_i,\;i=1,\ldots,s,b\}$ to minimize the mean square error cost function,
\begin{equation}\label{eq:cost}
C(\vect{W}|\mathcal{T}) = \frac1N\sum_{j=1}^N\|z(q^{(j)})-t^{(j)}\|^2
\end{equation}
The most popular algorithm in machine learning to optimize \eqref{eq:cost} is back-propagation \cite{rumelhart86}. However, as a gradient descent-based iterative algorithm, back-propagation is usually quite slow and can be trapped at some local minimum since the cost function is nonlinear, and for most cases, non-convex. Motivated by the fact that randomization is computationally cheaper than optimization, alternative methods based on random nonlinear bases have been proposed \cite{huang06,rahimi07}. These methods drastically decrease the computation cost while maintaining a reasonable level of approximation accuracy. The key feature of random networks is that they reduce the full optimization problem into standard linear regression by mapping the input data to a randomized feature space and then apply existing fast algebraic training methods (e.g., by minimizing squared error) to find the output weight. Given the design objective, algebraic training can achieve exact or approximate matching of the data at the training points. Compared to the gradient descent-based techniques, algebraic training methods can reduce computational complexity and provide better generalization properties. A typical algebraic approach for single-hidden layer feedforward random networks is extreme learning machine (ELM) \cite{huang06}, which is summarized in Algorithm \ref{alg:ELM}.
\begin{algorithm}[t]
{\small
\caption{Extreme Learning Machine}\label{alg:ELM}
Given a training set $\mathcal{T} = \{(I_j,t_j)|I_j\in\mathbb{R}^d,\;t_j\in\mathbb{R}^m,\; j = 1,\ldots,N\}$, activation function $a(x;\gamma)$ and hidden node number $s$\\[3pt]
Step 1: Randomly assign hidden node parameters $\gamma_i$, $i = 1,\ldots,s$ \\[3pt]
Step 2: Calculate the hidden layer output matrix $H$
\[
H_{ji} = a(I_j;\gamma_i),\quad i=1,\ldots,s,\;j = 1,\ldots,N
\]
Step 3: Calculate the output weight $v$
\[
v = H^{\dagger}T,\quad T =[t_1,t_2,\ldots,t_N]^T
\]
\hspace{30pt}where $H^{\dagger}$ is the \textit{Moore-Penrose generalized inverse} of matrix $H$
}
\end{algorithm}
Using randomized nonlinear features, ELM estimates the output weight by finding the least-squares solution to the resulting linear equations system $Hv = T$. Note that presented this way, our method can also be regarded as a random version of Generalized Additive Model (GAM). In practice, people could add regularization to improve stability and generalizability.
\subsection{Choice of Nonlinearity}
There are many choices for nonlinear activation functions in random networks. Different types of activation functions can be used for different learning tasks. In this paper, we focus on random networks with two typical types of nonlinear nodes:
\begin{itemize}
\item \emph{Additive nodes}:
\[
a(q;\gamma) = a(\vect{w}\cdot q + d),\quad \vect{w}\in\mathbb{R}^d,\;d \in\mathbb{R}, \quad \gamma = \{\vect{w},d\}
\]
where $\vect{w}$ and $d$ are the weight vector and the bias of the hidden node.
\item \emph{Radial basis functions (RBF) nodes}:
\[
a(q;\gamma) = a\left(-\frac{\|q-c\|^2}{2\ell^2}\right),\quad c\in\mathbb{R}^d,\;\ell \in\mathbb{R}^{+}, \quad \gamma = \{c,\ell\}
\]
where $c$ and $\ell$ are the center and width of the hidden node.
\end{itemize}
Both random networks can approximate a rich class of functions arbitrarily well \cite{huang06chen,rahimi08}. With randomly assigned input weights and biases composed linearly inside the nonlinear activation function, additive nodes form a set of basis functions, whose level sets are hyperplanes orientated by $\vect{w_i}$ and shifted by $d_i$ respectively. Random networks with additive nodes tend to reflect the global structure of the target function. On the other hand, RBF nodes are almost compactly supported (can be adjusted by the width $\ell$) rendering good local approximation for the corresponding random networks.
\subsection{Connection to GPs and Sparse GPs}\label{sec:SPGP}
It is worth noting the connection between networks with RBF nodes and Gaussian processes models \cite{rasmussen96,neal99}. Given a training data set
\[\mathcal{T} = \{(q^{(j)},t^{(j)})|q^{(j)}\in\mathbb{R}^d,\;t^{(j)}\in\mathbb{R},\; j = 1,\ldots,N\}\]
and using squared exponential covariance function
\[
K(q^{(j)},q^{(j')}) = \sigma_f^2\exp\left(-\frac{\|q^{(j)}-q^{(j')}\|^2}{2\ell^2}\right),\quad \theta = \{\sigma_f,\ell\}
\]
the standard GP regression with a Gaussian noise model has the following marginal likelihood
\[
p(\vect{t}|\vect{Q},\theta) = \mathcal{N}(\vect{t}|\vect{0},\vect{K}_N+\sigma^2\vect{I})
\]
where $\vect{Q}=\{q^{(j)}\}_{j=1}^N, \; \vect{t} = \{t^{(j)}\}_{j=1}^N,\; [\vect{K}_N]_{jj'} = K(q^{(j)},q^{(j')})$ is the covariance matrix and $\sigma$ is the noise parameter. Prediction on a new observation $q^{\ast}$ is made according to the conditional distribution
\[
p(t^{\ast}|q^{\ast},\mathcal{T},\theta) = \mathcal{N}(t^{\ast}|\vect{k}_\ast^T(\vect{K}_N+\sigma^2\vect{I})^{-1}\vect{t},\;K_{\ast\ast}-\vect{k}_\ast^T(\vect{K}_N+\sigma^2\vect{I})^{-1}\vect{k}_\ast + \sigma^2)
\]
where $[k_\ast]_j=K(q^{(j)},q^{\ast})$ and $K_{\ast\ast} = K(q^{\ast},q^{\ast})$.
On the other hand, if we use $K(q^{(j)},\cdot)$ as the $j$th hidden node, $j=1,2,\ldots,N$, the output matrix becomes $H=\vect{K}_N$, and the output weight learned by algebraic approach to a regularized least square problem is
\[
\hat{v} = \arg\min_{v} \|\vect{H}v-\vect{t}\|^2 + \sigma^2v^T\vect{K}_Nv = (\vect{K}_N+\sigma^2\vect{I})^{-1}\vect{t}
\]
Therefore, such a network provides the same prediction point estimate as the above full GP models. This way, a Gaussian process model can be interpreted as a self-organizing RBF network where new hidden nodes are added adaptively with new observations. This is also an alternative point of view to \cite{neal96} where GP models were shown to be equivalent to single hidden-layer neural networks with infinite many hidden nodes.
Notice that the above GP model scales cubically with the number of data points $N$ which limits the application of GPs to relatively small datasets. To derive a GP model that is computationally tractable for large datasets, sparse GPs based on inducing point methods \cite{snelson06,joaquin05} have been previously proposed. These sparse models introduce a set of inducing points $\bar{\vect{Q}}= \{\bar{q}^{(i)}\}_{i=1}^M$ and approximate the exact kernel $K(q,q')$ by an approximation $\tilde{K}(q,q')$ for fast computation. For example, the fully independent training conditional (FITC) \cite{snelson06} method uses the approximate kernel
\[
\tilde{K}_{\small{\mathrm{FITC}}}(q,q')= \vect{k}_q^T\vect{K}_M^{-1}\vect{k}_{q'} + \delta_{qq'}(K(q,q')-\vect{k}_q^T\vect{K}_M^{-1}\vect{k}_{q'})
\]
where $\vect{K}_M$ is the exact covariance matrix for the $M$ inducing points and $\vect{k}_q,\vect{k}_{q'}$ are the exact covariance matrices between $q,q'$ and the inducing points. Given the same training data set $\mathcal{T}$, the marginal likelihood is
\[
p(\vect{t}|\vect{Q},\theta) = \mathcal{N}(\vect{t}|\vect{0},\vect{K}_{NM}\vect{K}_M^{-1}\vect{K}_{MN}+\vect{\Lambda}+\sigma^2\vect{I})
\]
Here, $\vect{\Lambda}$ is a diagonal matrix with $\vect{\Lambda}_{jj} = K_{jj}- \vect{k}_j^T\vect{K}_{M}^{-1}\vect{k}_j$ that adjusts the diagonal elements to the ones from the exact covariance matrix $\vect{K}_N$. Simiarly, predictions can be made according to the conditional distribution
\[
p(t^{\ast}|q^{\ast},\mathcal{T},\theta) = \mathcal{N}(t^{\ast}|\vect{k}_\ast^T\vect{\Sigma}_M^{-1}\vect{K}_{MN}(\vect{\Lambda}+\sigma^2\vect{I})^{-1}\vect{t},K_{\ast\ast}-\vect{k}_\ast^T(\vect{K}_M^{-1}-\vect{\Sigma}_M^{-1})\vect{k}_\ast + \sigma^2)
\]
where $\vect{\Sigma}_M = \vect{K}_M + \vect{K}_{MN}(\vect{\Lambda}+\sigma^2\vect{I})^{-1}\vect{K}_{NM}$. The computation cost is reduced to $\mathcal{O}(M^2N)$ for learning and after that the predictive mean costs $\mathcal{O}(M)$ per new observation. The hyperparameters $\theta,\sigma$ and inducing points $\bar{\vect{Q}}$ can be tuned to maximize the marginal likelihood. However, in high dimension the tuning of $\bar{\vect{Q}}$ becomes infeasible.
\begin{figure}[!t]
\begin{center}
\includegraphics[width=0.33\textwidth,height=0.3\textheight]{figs/SurrogateComp_N10v2.eps} \hspace{-8pt}
\includegraphics[width=0.33\textwidth,height=0.3\textheight]{figs/SurrogateComp_N20v2.eps} \hspace{-8pt}
\includegraphics[width=0.33\textwidth,height=0.3\textheight]{figs/SurrogateComp_N40v2.eps} \hspace{-8pt}\\
\caption{Comparing different surrogate approximations with an increasing number of observations $N=10,20,40$ on target function $y=x^2/2$. The observation points are nested samples from the standard normal distribution. For FITC and random networks, we choose 5 inducing points and 5 hidden neurons respectively. FITC and random networks are all run 100 times and averaged to reduce the random effects on the results.}\label{fig:surrcomp}
\vspace{-10pt}
\end{center}
\end{figure}
On the other hand, if we use the inducing points $\bar{\vect{Q}}$ as the centers of a RBF network, the output matrix $\vect{H}=\vect{K}_{NM}$. Given the diagonal matrix $\vect{D} = \vect{\Lambda} + \sigma^2\vect{I}$, the output weight estimated by the algebraic approach to a weighted least square problem plus a regularization term is
\[
\hat{v} = \arg\min_v \|\vect{D}^{-\frac12}(\vect{H}v-\vect{t})\|^2 + v^T\vect{K}_Mv = \vect{\Sigma}_M^{-1}\vect{K}_{MN}(\vect{\Lambda}+\sigma^2\vect{I})^{-1}\vect{t}
\]
Therefore, the same predictive mean can be reproduced if we use the inducing points as centers and use the same hyperparameter configuration in our random network with RBF nodes and optimize with respect to the above cost function. Moreover, those hyperparameters in each basis (or hidden nodes) can also be trained (typically by gradient decent) if we abandon the use of random bases and simple linear regression.
Figure \ref{fig:surrcomp} compares random networks with different node types and related GP methods on fitting a simple function $y=x^2/2$ which corresponds to the negative log-density of the standard normal distributions. We used \emph{softplus} function $\sigma(x) = \log\big(1+\exp(x)\big)$ in additive nodes and exponential square kernels in RBF nodes and GP methods. As we can see from the graph, random networks generally perform better than GP methods when the number of observations is small. The randomness in the configuration of hidden nodes force networks to learn more globally. In contrast, GP models are more local and need more data to generalize well. By introducing sparsity, FITC tends to generalize better than full GP, especially on small datasizes. Since our goal is to fit negative log-posterior density function in (\ref{eq:U}) and $U(q)\rightarrow \infty$ as $q$ moves away from the high density domain, using \emph{softplus} basis functions in random networks are more capable to capture this far field feature by striking a better balance between flexibility and generalization while being less demanding on the datasize. Also, the number of hidden neurons (bases) can be used to regularize the approximation to mitigate overfitting issue.
\subsection{Surrogate Induced Hamiltonian Flow}
\begin{figure}[!t]
\begin{center}
\includegraphics[width=0.33\textwidth,height=0.3\textheight]{figs/force_inverted.eps} \hspace{-8pt}
\includegraphics[width=0.33\textwidth,height=0.3\textheight]{figs/traj_HMC_revised2_inverted.eps} \hspace{-8pt}
\includegraphics[width=0.33\textwidth,height=0.3\textheight]{figs/traj_NNSHMC_revised2_inverted.eps} \hspace{-8pt}
\caption{Comparing HMC and NNS-HMC based on a 2-dimensional banana-shaped distribution. The left panel shows the gradient fields (force map) for the original Hamiltonian flow (red) and the surrogate induced Hamiltonian flow (blue). The middle and right panel show the trajectories for HMC and NNS-HMC samplers. Both samplers start from the same point (red square) with same initial momentums. Blue points at the end of the trajectories are the proposals. The overall acceptance probability drops from 0.97 using HMC to 0.88 using NNS-HMC.}\label{fig:ar}
\vspace{-10pt}
\end{center}
\end{figure}
As mentioned in the previous sections, repetitive computation of Hamiltonian, its gradient and other quantities that involve all data set undermine the overall exploration efficiency of HMC. To alleviate this issue, we exploit the smoothness or regularity in parameter space, which is true for most statistical models. As discussed in \cite{neal96, liu01, rasmussen03}, one can improve computational efficiency of HMC by approximating the energy function and using the resulting approximation to device a surrogate transition mechanism while still converging to the correct target distribution. To this end, \cite{rasmussen03} proposed to use pre-convergence samples (which are discarded during the burn-in period) to approximate the energy function using a Gaussian process model. Here, we define an alternative surrogate-induced Hamiltonian as follows:
\[
\tilde{H}(q,p) = \tilde{U}(q) + \frac12p^TM^{-1}p
\]
where $\tilde{U}(q)$ is the neural network surrogate function. $\tilde{H}(q,p)$ now defines a surrogate-induced Hamiltonian flow, parametrized by a trajectory length $t$, which is a map $\tilde{\phi}_t:\; (q,p) \rightarrow (q^{\ast},p^{\ast})$. Here, $(q^{\ast},p^{\ast})$ being the end-point of the trajectory governed by the following equations
\[
\frac{dq}{dt} = \frac{\partial \tilde{H}}{\partial p} = M^{-1}p,\quad \frac{dp}{dt} = - \frac{\partial \tilde{H}}{\partial q} = -\frac{\partial \tilde{U}}{\partial q}
\]
When the original potential $U(q)$ is computationally costly, simulating the surrogate induced Hamiltonian system provides a more efficient proposing mechanism for our HMC sampler. The introduced bias along with discretization error from the leap-frog integrator are all naturally corrected in the MH step where we use the original Hamiltonian in the computation of acceptance probability. As a result, \emph{the stationary distribution of the Markov chain will remain the correct target distribution} (see Appendix \ref{sec:target} for a detailed proof). Note that by controlling the approximation quality of the surrogate function, we can maintain a relatively high acceptance probability. This is illustrated in Figure \ref{fig:ar} for a two-dimensional banana-shaped distribution \cite{girolami11}.
To construct such a surrogate, the early evaluations of the target function during the early iterations of MCMC will be used as the training set based on which we can train a shallow random network using fast algebraic approaches, such as ELM (Algorithm \ref{alg:ELM}). The gradient of the scalar output $z$ (see \ref{eq:nn}) for a network with additive hidden nodes, for example, then can be computed as
\begin{equation}\label{eq:grad}
\frac{\partial z}{\partial q} = \sum_{i=1}^sv_ia'(\vect{w}_i\cdot q+d_i)\vect{w}_i
\end{equation}
which costs only $\mathcal{O}(s)$ computations. To balance the efficiency in computation and flexibility in approximation, and to reduce the possibility of overfitting, the number of hidden nodes $s$ need to be small as long as a reasonable level of accuracy can be achieved. In practice, this can be done by monitoring the resulting acceptance rate using an initial chain.
\begin{figure}[!t]
\begin{center}
\includegraphics[width=0.45\textwidth]{figs/Gaussian32dComp_Acprat.eps} \hspace{-8pt}
\includegraphics[width=0.45\textwidth]{figs/Gaussian32dComp_MeanESSperSec.eps} \hspace{-8pt}
\caption{Comparing the efficiency of our random network surrogates and Gaussian process surrogates on a challenging $32$ dimensional Gaussian target whose covariance matrix has an eigenvector $(1,1,\ldots,1)^T$ with a corresponding eigenvalue of $1.0$, and all other eigenvalues are $0.01$. We set the step size to keep the acceptance probability around $70\%$ for HMC and use the same step size in all surrogate methods. For FITC and random networks, the number of inducing points and hidden neurons are all set to be $1000$ to allow reasonably accurate approximation. We ran each algorithm ten times and plot the medians and $80\%$ error bars.}\label{fig:gpvsnn}
\vspace{-10pt}
\end{center}
\end{figure}
\begin{algorithm}[t]
{\small
\KwIn{Starting position $q^{(1)}$, step size $\epsilon$ and number of hidden units $s$}
Initialize the training data set: $D=\emptyset$ or several random samples from the prior\\
\For{$t =1,2,\cdots, B$ }{
\textit{Resample momentum $p$}\\
$p^{(t)} \sim \mathcal{N}(0,M),\;(q_0,p_0)$ = $(q^{(t)},p^{(t)})$\\
\textit{Simulate discretization of Hamiltonian dynamics and propose $(q^{\ast},p^{\ast})$}\\
\textit{Metropolis-Hasting correction:} \\
$u \sim \text{Uniform}[0,1]$, $\rho = \exp[{ H(q^{(t)},p^{(t)})-H(q^{\ast},p^{\ast}) }]$\\
\lIf{$u < \min(1,\rho)$,} {$q^{(t+1)} = q^{\ast},\; D = D\cup\{(q^{\ast},U(q^{\ast}))\}$}
}
Train a neural network with $s$ hidden units via ELM on $D$ to form the surrogate function $z$\\
\For{$t =B+1,B+2,\cdots $ }{
\textit{Resample momentum $p$}\\
$p^{(t)} \sim \mathcal{N}(0,M),\;(q_0,p_0)$ = $(q^{(t)},p^{(t)})$\\
\textit{Simulate discretization of a new Hamiltonian dynamics using $z$:}\\
\For{$l = 1$ to $L$} {
$p_{l-1} \leftarrow p_{l-1} - \frac{\epsilon}{2} \frac{\partial z}{\partial q}(q_{l-1})$\\
$q_l \leftarrow q_{l-1} + \epsilon M^{-1}p_{l-1}$\\
$p_l \leftarrow p_l - \frac{\epsilon}{2} \frac{\partial z}{\partial q}(q_{l})$
}
$(q^{\ast},p^{\ast}) = (q_L,p_L)$\\
\textit{Metropolis-Hasting correction:} \\
$u \sim \text{Uniform}[0,1]$, $\rho = \exp[{ H(q^{(t)},p^{(t)})-H(q^{\ast},p^{\ast}) }]$\\
\lIf{$u < \min(1,\rho)$,} {$q^{(t+1)} = q^{\ast}$}
}
\caption{Random Network Surrogate HMC}
}
\label{alg:RNSHMC}
\end{algorithm}
Following \cite{rasmussen03}, we propose to run our method, henceforth called random network surrogate Hamiltonian Monte Carlo (RNS-HMC, see Algorithm \ref{alg:RNSHMC}), in two phases: exploration phase and exploitation phase. During the exploration phase, we initialize the training data set $D$ with an empty set or some samples from the prior distribution of parameters. We then run the standard HMC algorithm for some iterations and collect information from the new states (i.e., accepted proposals). When we have sufficiently explored the high density domain in parameter space and collected enough training data (during the burn-in period), a shallow random network is trained based on the collected training set $D$ to form a surrogate for the potential energy function. The surrogate function will be used to approximate the gradient information needed for HMC simulations later in the exploitation phase.
As an illustrative example, we compare the performance of different surrogate HMC methods on a challenging Gaussian target density in $32$ dimensions (A lower dimensional case was used in \cite{rasmussen03}). The target density has 31 confined directions and a main direction that is $10$ times wider, and all variables are correlated. Both the full GPs and FITC methods are implemented using GPML package \cite{rasmussen10}. The results are presented in Figure \ref{fig:gpvsnn}. Compared to the full GPs, FITC and random networks (with additive and RBF nodes) all scales linearly with the number of observations. Both random network surrogates can start with fewer training data. We also compare the efficiency of the surrogate induced Hamiltonian flows in terms of time normalized mean effective sample sizes (ESS). The efficiency of FITC and random networks all increases as the number of observations increase until no more approximation gain can be obtained (see the acceptance probability in the middle panel). However, the efficiency of full GP begin to drop before the model reaches its full capacity. That is because its predictive complexity also grows with the number of observations, which in turn diminishes the overall efficiency. Overall, the random network with additive nodes outperform other methods based on these example.
Our proposed method provides a natural framework to incorporate surrogate functions in HMC. Moreover, it can be easily extended to RMHMC. To this end, the Hessian matrix of the surrogate function can be used to construct a metric in parameter space and the third order derivatives can be used to simulate the corresponding modified Hamiltonian flow. We refer to this extended version of our method as RNS-RMHMC.
\begin{figure}[!t]
\begin{center}
\includegraphics[width=0.34\textwidth,height=0.25\textheight]{figs/ac_dimvsneuron.png} \hspace{-12pt}
\includegraphics[width=0.34\textwidth,height=0.25\textheight]{figs/ar_d32_revised.png} \hspace{-12pt}
\includegraphics[width=0.34\textwidth,height=0.25\textheight]{figs/ar_s2000_revised.png}
\caption{Acceptance probability of surrogate induced Hamiltonian flow on simulated logistic regression models for different number of parameters, $d$, and hidden neurons, $s$. The step size is chosen to keep the acceptance probability around $70\%$ for HMC. {\bf Left:} Acceptance probability as a function of $s$ (x-axis) and $d$ (y-axis). {\bf Middle:} Acceptance probability as a function of $s$ for a fixed dimension $d=32$. {\bf Right:} Acceptance probability as a function of $d$ for a fixed $s=2000$.}\label{fig:dimvsneuron}
\vspace{-10pt}
\end{center}
\end{figure}
Note that the approximation quality of the neural network surrogate function depends on several factors including the dimension of parameter space, $d$, the number of hidden neurons, $s$ and the training size, $N$. Here, we assume that $N$ is sufficiently large enough, and investigate the efficiency of RNS-HMC in terms of its acceptance probability for different values of $d$ and $s$ based on a standard logistic regression model with simulated data. Similar to the results presented in \cite{strathmann15}, Figure \ref{fig:dimvsneuron} shows the acceptance rate (over $10$ MCMC runs) as a function of $d$ and $s$. For dimensions up to $d\approx 50$, RNS-HMC maintains a relatively high acceptance probability with a shallow random network trained in a few seconds on a laptop computer. Appendix \ref{sec:potentialmatching} provides a theoretical justification for our method.
\section{Adaptive RNS-HMC}\label{sec:OLRNSHMC}
So far, we have assumed that the neural network model in our method is trained using a sufficiently large enough number of training points after waiting for an adequate number of iterations to allow the sampler explore the parameter space. This, however, could be very time consuming in practice: waiting for a long time to collect a large number of training points could undermine the benefits of using the surrogate Hamiltonian function.
Figure \ref{fig:ntrainvsneuron} shows the average acceptance probabilities (over $10$ MCMC chains) as a function of the number of training points, $N$, and the number hidden neurons, $s$, on a simulated logistic regression model for a fixed number of parameters, $d=32$. While it takes around $2000$ training data points to fulfill the network's capability and reach a high acceptance comparable to HMC, only $500$ training points are enough to provide an acceptable surrogate Hamiltonian flow (around $0.1$ acceptance probability). Therefore, we can start training the neural network surrogate earlier and adapting it as more training points become available. Although adapting a Markov chain based on its history may undermine its ergodicity and consequently its convergence to the target distribution \cite{andrieu08}, we can enforce a vanishing adaption rate $a_t$ such that $a_t\rightarrow 0$ and $\sum_{t=1}^\infty a_t = \infty$ and update the surrogate function with probability $a_t$ at iteration $t$. By Theorem 5 of \cite{roberts07}, the resulting algorithm is ergodic and converges to the right target distribution.
\begin{figure}[!t]
\begin{center}
\includegraphics[width=0.34\textwidth,height=0.25\textheight]{figs/ac_ntrainvsneuron.png} \hspace{-12pt}
\includegraphics[width=0.34\textwidth,height=0.25\textheight]{figs/ar_d32_s1000_revised_blue.png} \hspace{-12pt}
\includegraphics[width=0.34\textwidth,height=0.25\textheight]{figs/ar_d32_N1600_revised_blue.png}
\caption{Acceptance probability of the surrogate induced Hamiltonian flow based on a simulated logistic regression models with dimension $d=32$. {\bf Left:} Acceptance probability as a function of the number of hidden neurons $s$ (x-axis) and the number of training points $N$ (y-axis). {\bf Middle:} Acceptance probability as a function of $N$ for a fixed $s=1000$ . {\bf Right:} Acceptance probability as a function of $s$ for a fixed $N=1600$ .}\label{fig:ntrainvsneuron}
\vspace{-10pt}
\end{center}
\end{figure}
It is straightforward to adapt the neural network surrogate from the history of Markov chain. However, the
estimator in Algorithm \ref{alg:ELM} costs $\mathcal{O}(Nds+Ns^2+s^3)$ computation and $\mathcal{O}(Ns)$ storage, where $N$ is the number of training data (e.g., the number of rows in the output matrix $H$). As $N$ increases, finding the right weight and bias for the output neuron becomes increasingly difficult. In \cite{greville60}, Grevillle shows that $H^{\dagger}$ can be learned incrementally in real time as new data points become available. Based on Greville's method, online and adaptive pseudoinverse solutions for updating ELM weights has been proposed in \cite{vanschaik15} which can be readily employed here to develop an adaptive version of RNS-HMC. To be more efficient, only the estimator is updated.
\begin{proposition}\label{prop:online}
Suppose the current output matrix is $H_k$ and the target vector is $T_k$. At time $k+1$, a new sample $q_{k+1}$ and the target (potential) $t_{k+1}$ are collected. Denote the output vector from the hidden layer at $q_{k+1}$ as $h_{k+1}$. The adaptive updating formula for the empirical potential matching estimator is given by
\[
v_{k+1} = v_{k} + (t_{k+1}-h_{k+1}^Tv_{k})b_{k+1}
\]
where $b_{k+1}$ and auxiliary matrices $\Phi_{k+1},\;\Theta_{k+1}$ are updated according to $c_{k+1} = \Phi_{k}h_{k+1}$.
\begin{itemize}
\item[(i)] $c_{k+1} = 0$
\[
b_{k+1} =\frac{\Theta_{k}h_{k+1}}{1+ h_{k+1}^T\Theta_{k}h_{k+1}}, \quad \Phi_{k+1} = \Phi_k, \quad \Theta_{k+1} = \Theta_k - \Theta_{k}h_{k+1}b_{k+1}^T
\]
\item[(ii)] $c_{k+1}\neq0$
\[
b_{k+1} =\frac{ c_{k+1}}{\|c_{k+1}\|^2}, \quad \Phi_{k+1} = \Phi_k - \Phi_kh_{k+1}b_{k+1}^T
\]
\[
\Theta_{k+1} = \Theta_k -\Theta_kh_{k+1}b_{k+1}^T + (1+h_{k+1}^T\Theta_kh_{k+1})b_{k+1}b_{k+1}^T - b_{k+1}h_{k+1}^T\Theta_k^T
\]
\end{itemize}
\end{proposition}
At time $k$, the estimator takes a one-off $\mathcal{O}(kds+ks^2+s^3)$ computation and $\mathcal{O}(s^2)$ storage (only need to store $\Phi_k$ and $\Theta_k$, not $H_k^{\dagger}$). Starting at a previously computed solution $v_{K} = H_{K}^{\dagger}T_{K}$, and two auxiliary matrices $\Phi_K=I-H_K^T(H_K^{\dagger})^T,\Theta_K=H_K^{\dagger}(H_K^{\dagger})^T$, this adaptive updating costs $\mathcal{O}(ds + s^2)$ computation and $\mathcal{O}(s^2)$ storage, independent of the training data size $k$. Further details are provided in Appendix \ref{sec:OLproof}. We refer to this extended version of our method as Adaptive RNS-HMC (ARNS-HMC).
\begin{algorithm}[t]
{\small
\KwIn{Initial estimator $v_0$ and auxiliary matrices $\Phi_0,\Theta_0$, adaption schedule $a_t$, }
\myinput{step size $\epsilon$, number of hidden units $s$}
Initialize the surrogate $z_0 = z(q,v_0)$
\For{$t =0,1,\cdots $ }{
\textit{Resample momentum $p$}
$p^{(t)} \sim \mathcal{N}(0,M),\;(q_0,p_0)$ = $(q^{(t)},p^{(t)})$
\textit{Propose $(q^{\ast},p^{\ast})$ by simulating discretization of Hamiltonian dynamics with $\frac{\partial U}{\partial q} = \frac{\partial z_t}{\partial q}$}
\textit{Metropolis-Hasting correction:}
$u \sim \text{Uniform}[0,1]$, $\rho = \exp[{ H(q^{(t)},p^{(t)})-H(q^{\ast},p^{\ast}) }]$
\lIf{$u < \min(1,\rho)$,} {$q^{(t+1)} = q^{\ast}$;} \lElse{$q^{(t+1)} = q^{(t)}$}
update the estimator and auxiliary matrices to $v_{t+1},\Phi_{t+1},\Theta_{t+1}$ using ($q^{(t+1)},U(q^{(t+1)})$)
$u \sim \text{Uniform}[0,1]$,
\lIf{$u < a_t$,} {$z_{t+1} = z(q,v_{t+1})$;} \lElse{$z_{t+1} = z_t$}
}
\caption{ARNS-HMC}
}
\label{alg:OLNNSHMC}
\end{algorithm}
\section{Experiments}
\label{sec:results}
In this section, we use several experiments based on logistic regression models and inverse problem for elliptic partial differential equation (PDE) to compare our proposed methods to standard HMC and RMHMC in terms of sampling efficiency defined as time-normalized effective sample size (ESS). Given $B$ MCMC samples for each parameter, ESS =
$B[1 + 2\Sigma_{k=1}^{K}\gamma(k)]^{-1}$, where $\Sigma_{k=1}^{K}\gamma(k)$ is
the sum of $K$ monotone sample autocorrelations \cite{geyer92}. We use the
minimum ESS over all parameters normalized by the CPU time, $s$ (in seconds), as the overall measure
of efficiency: $\min(\textrm{ESS})/\textrm{s}$. The corresponding step sizes $\epsilon$ and number of leapfrog steps $L$ for HMC and RMHMC are chosen to make them stable and efficient (e.g., reasonably high acceptance probability and fast mixing). The same settings are used for our methods. Note that while the acceptance rates are similar in the first two examples, they drop a little bit for the last two examples, which is mainly due to the constraints we imposed on our surrogate functions. To prevent non-ergodicity and ensure high ESS for both HMC and RNS-HMC, we follow the suggestion by \cite{neal11} to uniformly sample $L$ from $\{1, \ldots,L\}$ in each iteration. The number of hidden nodes $s$ in random network surrogates are not tuned too much and better results could be obtained by more careful tunings.
In what follows, we first compare different methods in terms of their time-normalized ESS after the burin-period. To this end, we collect $5000$ samples after a reasonable large number of iterations ($5000$) of burn-in to make sure the chains have reached their stationary states. For our methods, the accepted proposals during the burn-in period after a short warming-up session (the first 1000 iterations) are used as a training set for a shallow random network. Later, we show the advantages of our adaptive algorithm.
\subsection{Logistic regression model}
As our first example, we compare HMC, RMHMC, RNS-HMC, and RNS-RMHMC using a simulation study based on a logistic regression model with $50$ parameters and $N=10^5$ observations. The design matrix is $X=(\frac1{10}\vect{1},X_1)$ and true parameters $\beta$ are uniformly sampled from $[0,1]^{50}$, where $X_1\sim\mathcal{N}_{49}(\vect{0},\frac1{100}I_{49})$. The binary responses $Y=(y_1,y_2,\ldots,y_N)^T$ are sampled independently from Bernoulli distributions with probabilities $p_i = 1/(1+\exp(-x_i^T\beta))$. We assume $\beta\sim\mathcal{N}_{50}(\vect{0},100I_{50})$, and sample from the corresponding posterior distribution.
Notice that the potential energy function $U$ is now a convex function, the Hessian matrix is positive semi-definite everywhere. Therefore, we use the Hessian matrix of the surrogate as a local metric in RNS-RMHMC. For HMC and RNS-HMC, we set the step size and leapfrog steps $\epsilon = 0.045,\;L=6$. For RMHMC and RNS-RMHMC, we set the step size and leapfrog steps $\epsilon = 0.54,\;L=2$.
To illustrate that our method indeed converges to the right target distribution, Figure \ref{fig:logit} provides the one- and two-dimensional posterior marginals of some selected parameters obtained by HMC and RNS-HMC. Table \ref{tab:experiments} compares the performance of the four algorithms. As we can see, RNS-HMC has substantially improved the sampling efficiency in terms of time-normalized min(ESS).
\begin{figure}[!t]
\begin{tabular}{cc}
\includegraphics[width=0.45\textwidth]{figs/logistic_HMC.pdf}&
\includegraphics[width=0.45\textwidth]{figs/logistic_NNSHMC.pdf} \\
HMC & RNS-HMC
\end{tabular}
\caption{HMC vs RNS-HMC: Comparing one- and two-dimensional posterior marginals of $\beta_1,\beta_{11},\beta_{21},\beta_{31},\beta_{41}$ based on the logistic regression model with simulated data.}\label{fig:logit}
\end{figure}
\begin{table}\begin{center}
{\small
\begin{tabular}{|c|c|c|c|c|c|c|}\hline
Experiment & Method & AP & ESS& s/Iter & $\min(\textrm{ESS})/\textrm{s}$ & spdup \\\hline
\multirow{2}{*}{LR (Simulation)} & HMC
& 0.76 & (4351,5000,5000) & 0.061 & 14.17 & 1 \\
& RMHMC & 0.80 & (1182,1496,1655) & 3.794 & 0.06 & 0.004 \\
\multirow{2}{*}{$s$ = 2000}& RNS-HMC & 0.76 & (4449,4999,5000) & 0.007 & 123.56 & \bf{8.72} \\
& RNS-RMHMC & 0.82 & (1116,1471,1662) & 0.103 & 2.17 & 0.15 \\\hline
\multirow{2}{*}{LR (Bank Marketing)} & HMC
& 0.70 & (2005,2454,3368) & 0.061 & 6.52 & 1 \\
& RMHMC & 0.92 & (1769,2128,2428) & 0.631 & 0.56 & 0.09 \\
\multirow{2}{*}{$s$ = 1000}& RNS-HMC & 0.70 & (1761,2358,3378) & 0.007 & 52.22 & \bf{8.01} \\
& RNS-RMHMC & 0.90 & (1974,2254,2457) & 0.027 & 14.41 & 2.21 \\\hline
\multirow{2}{*}{LR ($\mathtt{a9a}$ 60 dimension)} & HMC
& 0.72 & (1996,2959,3564) & 0.033 & 11.96 & 1 \\
& RMHMC & 0.82 & (5000,5000,5000) & 3.492 & 0.29 & 0.02 \\
\multirow{2}{*}{$s$ = 2500}& RNS-HMC & 0.68 & (1835,2650,3203) & 0.005 & 81.80 & \bf{6.84} \\
& RNS-RMHMC & 0.79 & (4957,5000,5000) & 0.370 & 2.68 & 0.22 \\\hline
\multirow{2}{*}{Elliptic PDE} & HMC
& 0.91 & (4533,5000,5000) & 0.775 & 1.17 & 1 \\
& RMHMC & 0.80 & (5000,5000,5000) & 4.388 & 0.23 & 0.20 \\
\multirow{2}{*}{$s$ = 1000
&RNS-HMC & 0.75 & (2306,3034,3516) & 0.066 & 7.10 & \bf{6.07} \\
& RNS-RMHMC & 0.66 & (2126,4052,5000) & 0.097 & 4.38 & 3.74 \\\hline
\end{tabular}
\caption{\small Comparing the algorithms using logistic regression models and an elliptic PDE inverse problem. For each method, we provide the acceptance probability (AP), the CPU time (s) for each iteration and the time-normalized ESS.}\label{tab:experiments}
\vspace{-10pt}
}
\end{center}
\end{table}
Next, we apply our method to two real datasets: Bank Marketing and the $\mathtt{a9a}$ dataset \cite{lin08}. The Bank Marketing dataset (40197 observations and 24 features) is collected based on direct marketing campaigns of a Portuguese banking institution aiming at predicting if a client will subscribe to a term deposit \cite{moro14}. We set the step size and number of leapfrog steps $\epsilon=0.012,\;L=45$ for HMC and RNS-HMC; $\epsilon=0.4,\;L=6$ for RMHMC and RNS-RMHMC. The $\mathtt{a9a}$ dataset (32561 features and 123 features) is complied from the UCI $\mathtt{adult}$ dataset \cite{bache13} which has been used to determine whether a person makes over 50K a year. We reduce the number of features to $60$ by random projection (increasing the dimension to 100 results in a substantial drop in the acceptance probability). We set the step size and number of leapfrog steps $\epsilon=0.012,\;L=10$ for HMC and RNS-HMC; $\epsilon=0.5,\;L=4$ for RMHMC and RNS-RMHMC. All datasets are normalized to have zero mean and unit standard deviation. The priors are the same as before. The results for the two data sets are summarized in Table 1. As before, both RNS-HMC and RNS-RMHMC significantly outperform their counterpart algorithms.
\subsection{Elliptic PDE inverse problem}
\label{sec:PDE}
Another computationally intensive model is the elliptic PDE inverse problem discussed in \cite{dashti11,conard14}. This classical inverse problem involves inference of the diffusion coefficient in an elliptic PDE which is usually used to model isothermal steady flow in porous media. Let $c$ be the unknown diffusion coefficient and $u$ be the pressure field, the forward model is governed by the elliptic PDE
\begin{equation}\label{eq:ePDE}
\nabla_{\vect{x}}\cdot(c(\vect{x},\theta)\nabla_{\vect{x}}u(\vect{x},\theta)) = 0,
\end{equation}
where $\vect{x} =(x_1,x_2)\in[0,1]^2$ is the spatial coordinate. The boundary conditions are
\[
u(\vect{x},\theta)|_{x_2=0} = x_1,\quad u(\vect{x},\theta)|_{x_2=1} = 1-x_1,
\quad
\frac{\partial u(\vect{x},\theta)}{\partial x_1}\Big|_{x_1=0} = 0,\quad \frac{\partial u(\vect{x},\theta)}{\partial x_1}\Big|_{x_1=1} = 0
\]
In our numerical simulation, \eqref{eq:ePDE} is solved using standard continuous GFEM with bilinear basis functions on a uniform $30\times30$ quadrilateral mesh.
A log-Gaussian process prior is used for $c(\vect{x})$ with mean zero and an isotropic squared-exponential covariance kernel:
\[
C(\vect{x}_1,\vect{x}_2) = \sigma^2\exp\left(-\frac{\|\vect{x}_1-\vect{x}_2\|^2_2}{2l^2}\right)
\]
for which we set the variance $\sigma^2 =1$ and the length scale $l=0.2$. Now, the diffusivity field can be easily parameterized with a Karhunen-Loeve (K-L) expansion:
\[
c(\vect{x},\theta) \approx \exp\left(\sum_{i=1}^d\theta_i\sqrt{\lambda_i}v_i(\vect{x})\right)
\]
where $\lambda_i$ and $v_i(\vect{x})$ are the eigenvalues and eigenfunctions of the integral operator defined by the kernel $C$, and the parameter $\theta_i$ are endowed with independent standard normal priors, $\theta_i\sim\mathcal{N}(0,0.5^2)$, which are the targets of inference. In particular, we truncate the K-L expansion at $d=20$ modes and condition the corresponding mode weights on data. Data are generated by adding independent Gaussian noise to observations of the solution field on a uniform $11\times 11$ grid covering the unit square.
\[
y_j = u(\vect{x}_j,\theta) + \epsilon_j,\quad \epsilon_j\sim\mathcal{N}(0,0.1^2), \quad j = 1,2,\ldots,N
\]
The number of leap frog steps and step sizes are set to be $L=10,\; \epsilon = 0.16$ for both HMC and NNS-HMC. Note that the potential energy function is no longer convex; therefore, we can not construct a local metric from the Hessian matrix directly. However, the diagonal elements
\[
\frac{\partial^2 U}{\partial \theta_i^2} = \frac{1}{\sigma_\theta^2} + \sum_{j=1}^{N}\frac{1}{\sigma_y^2}\left(\frac{\partial u_j}{\partial \theta_i}\right)^2 - \sum_{j=1}^{N}\frac{\epsilon_j}{\sigma_y^2}\frac{\partial^2 u_j}{\partial \theta_i^2}, \quad \sigma_\theta = 0.5,\;\sigma_y = 0.1,\quad i=1,2,\ldots,d
\]
are highly likely to be positive in that the deterministic part (first two terms) is always positive and the noise part (last term) tends to cancel out. The diagonals of the Hessian matrix of surrogate therefore induce an effective local metric which can be used in RNS-RMHMC. A comparison of the results of all algorithms are presented in Table \ref{tab:experiments}. As before, RNS-HMC provides a substantial improvement in the sampling efficiency. For the RMHMC methods, we set $L=3,\;\epsilon=0.8$. As seen in the table, RMHMC is less efficient than HMC mainly due to the slow computation speed. However, RNS-RMHMC improves RMHMC substantially and outperforms HMC. Although the metric induced by the diagonals of the Hessian matrix of surrogate may not be as effective as Fisher information, it is much cheaper to compute and provide a good approximation.
{\bf Remark.} In addition to the usual computational bottleneck as in previous examples, e.g., large amount of data, there is another challenge on top of that for this example due to the complicated forward model. Instead of a simple explicit probabilistic model that prescribes the likelihood of data given the parameter of interest, a PDE \eqref{eq:ePDE} is involved in the probabilistic model. The evaluation of geometrical and statistical quantities, therefore, involves solving a PDE similar to \eqref{eq:ePDE} in each iteration of HMC and RHMHC. This is a preventive factor in practice. Using our methods based on neural network surrogates provide a huge advantage. Numerical experiments show a gain of efficiency by more than 20 times. More improvement is expected as the amount of data increases.
\begin{figure}[!t]
\begin{center}
\begin{tabular}{cc}
\includegraphics[width=0.45\textwidth,height=0.25\textheight]{figs/ar_ol_lrd50_ntrain500_revised} &
\includegraphics[width=0.45\textwidth,height=0.25\textheight]{figs/ar_ol_lrd25_ntrain600_revised} \\
(a) Simulated Data & (b) Bank Market\\ \\
\includegraphics[width=0.45\textwidth,height=0.25\textheight]{figs/ar_ol_lrd28_ntrain800_revised} &
\includegraphics[width=0.45\textwidth,height=0.25\textheight]{figs/ar_ol_ePDEd20_ntrain1600_revised} \\
(c) Adult Data & (d) Elliptic PDE
\end{tabular}
\caption{Median acceptance rate of ANNS-HMC along with the corresponding 90\% interval (shaded area). The red line shows the average acceptance rate of standard HMC.} \label{fig:acprat}
\end{center}
\end{figure}
\begin{figure}[!t]
\begin{center}
\begin{tabular}{cc}
\includegraphics[width=0.45\textwidth,height=0.25\textheight]{figs/REM_lrd50_s2000_ntrain1400_revised} &
\includegraphics[width=0.45\textwidth,height=0.25\textheight]{figs/REM_lrd25_s1000_ntrain600_revised} \\
(a) Simulated Data & (b) Bank Market\\ \\
\includegraphics[width=0.45\textwidth,height=0.25\textheight]{figs/REM_lrd28_s1000_ntrain800_revised} &
\includegraphics[width=0.45\textwidth,height=0.25\textheight]{figs/REM_ePDEd20_s1000_ntrain1600_revised} \\
(c) Adult Data & (d) Elliptic PDE
\end{tabular}
\caption{Relative error of mean as a function of running time.}\label{fig:rem}
\vspace{-10pt}
\end{center}
\end{figure}
\subsection{Adaptive learning}
Next, using the above four examples we show that ARNS-HMC can start with far fewer training points and quickly reach the same level of performance as that of RNS-HMC. Figure \ref{fig:acprat} shows that as the number of training points (from initial MCMC iterations) increases, ARNS-HMC fully achieves the network's capability and reaches a comparable acceptance rate to that of HMC.
We also compare ARNS-HMC to HMC and RNS-HMC in terms of the relative error of mean (REM) which is defined as $\|\bar{q(t)}-E(q)\|_2/\|E(q)\|_2$, where $\bar{q(t)}$ means sample mean up to time $t$. Figure \ref{fig:rem} shows the results using the four examples discussed above. Note that before training the neural network models, both RNS-HMC and ARNS-HMC are simply standard HMC so the three algorithms have similar performance. As we can see, ARNS-HMC has the best overall performance: it tends to provide lower REM at early iterations. This could be useful if we have limited time budget to fit a model.
\section{Discussion and Future Work}
\label{sec:discussion}
In this paper, we have proposed an efficient and scalable computational method for Bayesian inference by exploring and exploiting regularity of probability models in parameter space. Our method is based on training surrogate function of the potential energy after exploring the parameter space sufficiently well. For situations where it is not practical to wait for a thorough exploration of parameter space, we have proposed an adaptive version of our method that can start with fewer training points and can quickly reach its full potential.
As an example, we used random networks and efficient learning algorithms to construct effective surrogate functions. These random bases surrogate functions provide good approximations of collective information of the full data set while striking a good balance between accuracy and computation cost for efficient computation. Random networks combined with the optimized learning process can provide flexibility, accuracy, and scalability. Note that in general the overall performance could be sensitive to the architecture of the random network. Our proposed random network surrogate method scales differently than GP emulators because of the specific constraints we imposed on its architecture. As our experimental results show, this approach could improve the performance of HMC in some applications.
In its current form, our method is more effective in problems with costly likelihood and a moderate number of parameters. In spite of improvements we have made to standard HMC, dealing with high dimensional and complex distributions still remains quite challenging. For multimodal distributions, for example, our method's effectiveness largely depends on the quality of training samples. If these samples are collected from one mode only, the surrogate function will miss the remaining modes and the sampler might not be able to explore them (especially if they are isolated modes). A surrogate function based on Gaussian processes might have a better chance at finding these modes in the tails of the approximate distribution since it tends to go to zero gradually. To address this issue, we can utilize mode searching and mode exploring ideas such as those proposed by \cite{ahn13, lan14}. For constrained target distributions, we can employ the method of \cite{lanICML14} based on Spherical HMC.
For HMC, gradient of the potential function is an important driving force in the Hamiltonian dynamics. Although accurate approximation of a well sampled smooth function automatically leads to accurate approximation of its gradient, this is not the case when the sampling is not well distributed. For example, when dense and well sampled training data sets are difficult to obtain in very high dimensions, one can incorporate the gradient information in the training process. In future, we will study more effective way to utilize this information in the training process. As a common practice in adaptive MCMC methods, one may also learn the mass matrix $M$ adaptively together with the surrogate in ARNS-HMC.
\subsubsection*{Acknowledgments}
This work is supported by NIH grant R01AI107034 and NSF grants DMS-1418422 and DMS-1622490
\bibliographystyle{unsrt}
\small{
|
{'timestamp': '2017-04-19T02:01:32', 'yymm': '1506', 'arxiv_id': '1506.05555', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05555'}
|
arxiv
|
\section{Introduction}
In order to utilize the radio spectrum more effectively, the secondary users (SUs) may be allowed to share the spectrum with the primary users (PUs). However, the SUs need to control the transmit power in order not to cause harmful interference to the PUs \cite{Goldsmith2009}. While research literature on this topic is rich, we recall in the following works that are most relevant for this study. Results in \cite{Gastpar2007} have shown that, under a received-power constraint, the channel capacity of the SU can be significantly different from the one in a conventional AWGN channel. In \cite{Kang2009}, authors studied the ergodic capacity and the outage capacity of the SU assuming fading channels, where the interference from the PU to the SU was ignored. In \cite{Suraweera2010}, authors studied a single-antenna spectrum-sharing system by taking into consideration the interference from the PU at the secondary receiver (SR).
The multiple antenna techniques provide an efficient tool to improve the link level capacity. Among others, the transmit antenna selection (TAS) scheme is attractive, since it can reduce the hardware costs and complexity \cite{Sanayei2004}. In \cite{Blagojevic2012}, authors studied the ergodic capacity of the SU using TAS and maximum ratio combining (MRC) at the receiver. However, the PU interference was ignored, and no closed-form expression was given for the SU ergodic capacity in the presence of the peak transmit power and interference power constraints. Authors in \cite{Tourki2014} derived the exact expressions for the ergodic capacity of MIMO cognitive system in terms of Fox's H-function. This result, although of theoretical interests, involves complicated contour integral and is thus difficult to use in practice.
In what follows, we consider a spectrum-sharing system with multiple antennas at the secondary transmitter. By assuming the interference from the PU to the SU and the transmit power constraints at the ST, we derive the asymptotic mean capacity and outage capacity for the link between ST and SR by applying the extreme value theory (EVT) \cite{Galambos1978}. The derived results are simple but accurate, and they become exact when the number of antennas approaches to infinity. Using these results, we obtain the rate scaling laws for the spectrum-sharing systems under the interference power and the transmit power limitations.
The remainder of this paper is organized as follows. In Section \ref{sec:model}, we provide the system model and introduce the probability density function (PDF) and cumulative distribution function (CDF) of the SINR at the secondary receiver. In Section \ref{sec:EVT}, we briefly review the EVT, and show that the SU SINR of the proposed system lies on the domain of the attraction of the Gumbel distribution. Then we investigate the SU mean capacity, the SU outage capacity, and the scaling issues in Section \ref{sec:perf}. Section \ref{sec:Sim} presents the simulation results. The last Section concludes this paper.
\section{System and Channel Models}\label{sec:model}
We consider a spectrum-sharing cognitive radio system depicted in Fig. \ref{fig_SysMod}. This model is similar to the one in \cite{Suraweera2010}, where the ST was equipped with single antenna. In our model, the secondary receiver (SR) is equipped with one antenna, and the secondary transmitter (ST) is equipped with $N$ antennas assuming TAS technique adopted at the ST. The primary transmitter (PT) and receiver (PR) are assumed to be equipped with one antenna. Let $g_i$, $h_i$ ($i = 1, \cdots, N$), and $q$ denote the channel power gains between the $i$-th antenna of the ST and the SR, the $i$-th antenna of the ST and the PR, and the PT and the SR, respectively.
\begin{figure}[!t]
\centering
\includegraphics[width=.4\columnwidth]{SysMod.eps}
\caption{Spectrum-sharing system with antenna selection at the secondary transmitter. Single antenna is equipped at the secondary receiver, the primary transmitter and receiver.}
\label{fig_SysMod}
\end{figure}
When the $i$-th antenna is used, the signal received at the SR, can be written as
\begin{equation}
y_i = \sqrt{P_s\, g_i}\, s + \sqrt{P_p\, q}\, z + \nu, \label{eq:signal_model}
\end{equation}
where $P_s$ and $P_p$ are the transmit power of the SU and PU, respectively, $s$ and $z$ denotes the transmit signals of the SU and PU with unit average power, and $\nu$ represents the additive white Gaussian noise with power $\sigma^2$. We assume that the channels experience independent block Rayleigh fading. Namely, the channels keep constant during each block, and are uncorrelated between blocks \cite{Ozarow1994}. Furthermore, the channels between the ST and the SR are identical and independent distributed (i.i.d.), and the channel between the ST and the PR is independent from the secondary channels. For a Rayleigh fading channel, the channel power gain $x$, $x\in \left\{g_i, h_i, q\right\}$, follows exponential distribution with mean value $\bar{x}$. The probability density function (PDF) of $x$ is given by
\begin{equation}
f(x) = \frac{1}{\overline{x}}e^{-x/\overline{x}} , \quad x \geq 0
\label{x_pdf}
\end{equation}
and the cumulative distribution function (CDF) is
\begin{equation}
F(x) = 1 - e^{-x/\overline{x}} , \quad x \geq 0.
\label{x_cdf}
\end{equation}
The selected antenna element of the ST provides the maximum output SINR at the SR. The SR then sends back the index to the ST through an error-free feedback channel. In order to limit the interference caused by the SU, an interference power constraint, denoted by $Q$, is adopted, which limits the instantaneous interference generated by the SU to the PU. In addition, $P_{\max}$ denotes the maximum transmit power of the ST due to, for instance, hardware limitations or regulations. On limited power, now, the transmit power of the ST using the $i$-th antenna can be represented as \cite{Li2012d,Suraweera2010}
\begin{equation}
P_s^{(i)} = \min\left\{\frac{Q}{h_i}, P_{\max}\right\}.
\label{tran_power}
\end{equation}
Accordingly, when the $i$-th antenna of the ST is used, the received SINR at the SR is represented as
\begin{equation}
\gamma_i = \min\left\{\frac{Q g_i}{h_i\left(P_p q+\sigma^2\right)}. \frac{P_{\max}g_i}{P_p q +\sigma^2}\right\}
\label{eq:gamma_i}
\end{equation}
The CDF of $\gamma_i$ has been deduced in \cite[eq. (15)]{Suraweera2010} as
\begin{equation}\begin{split}
F_{\gamma_i}(x) &= 1 - \frac{Q\overline{g}_i}{x P_p\overline{q} \overline{h}_i} e^{\frac{\sigma^2}{P_p\overline{q}} + \frac{Q\overline{g}_i}{x P_p\overline{q} \overline{h}_i}} \\
& \quad \times \Gamma\left[0, \left(\frac{x}{\overline{g}_i P_{\max}}+ \frac{1}{P_p\overline{q}}\right)\left(\frac{Q\overline{g}_i}{x \overline{h}_i} + \sigma^2\right)\right] \\
& \quad - \left[1-e^{-\frac{Q}{\overline{h}_i P_{\max}}}\right] \frac{\overline{g}_i P_{\max}}{x P_p \overline{q} + \overline{g}_i P_{\max}} e^{- \frac{x\sigma^2}{\overline{g}_i P_{\max}}},
\end{split}
\label{cdf_gamma_i}
\end{equation}
where $\Gamma(a,b) = \int_b^{\infty} e^{-t} t^{a-1} \mathrm{d} t$ denotes the incomplete Gamma function \cite[eq. 8.350-2]{Gradshteyn2007}. If the TAS technique is used, then the antenna of the ST providing the maximum SINR at the SR is selected such that
\begin{equation}
\gamma_{\max} = \max_i \gamma_i, \,\, i=1,\cdots,N , \label{eq:gamma_max}
\end{equation}
where $\gamma_i$ is given by (\ref{eq:gamma_i}). The CDF of the received SINR at the SR can be written, using order theory \cite{David2003}, as
\begin{equation}
F_{\gamma_{\max}}(x) = \left[F_{\gamma_i}(x)\right]^{N} .
\label{cdf_sinr}
\end{equation}
To the best of our knowledge, there is no explicit expressions for mean and outage capacities when using the CDF (\ref{cdf_sinr}) due to its algebraic complexity. In order to obtain tractable analysis and gain insight for the considered cognitive radio system, we deduce asymptotic expressions for the mean capacity and outage capacity using extreme value theory.
\section{Implications of the Extreme Value Theory} \label{sec:EVT}
Let $X_1, \cdots, X_N$ denote the i.i.d. random variables, and let $F_X(x)$ be the underlying cumulative distribution function. We denote by $M_X$ the maximum of $\left\{X_i\right\}_{1\leq i \leq N}$. If there exist real constants $a_N$ and $b_N>0$, and a non-degenerate limit distribution $G(x)$ such that
\begin{equation}
\lim_{N\rightarrow \infty}\frac{M_X - a_N}{b_N} \xrightarrow[]{d} G(x),
\label{evt_conv}
\end{equation}
then $G(x)$ is one of the extreme value distributions: Gumbel, Fr\'{e}chet, or reverse-Weibull \cite{Haan2006}. We say that $F_X(x)$ belongs to the maximum domain of attraction (MDA) of $G(x)$.
Before using the extreme value distributions to approximate $F_{\gamma_{\max}}(x)$ in (\ref{cdf_sinr}), we recall a lemma proved in \cite{Song2006, Galambos1978} which gives a sufficient condition for a distribution belonging to the MDA of the Gumbel distribution.
\begin{lemma}\label{lemma_mda} \cite[Theorem 2.7.2]{Galambos1978} and \cite[Lemma 1]{Song2006}. Let $\omega(F_X)=\sup\left\{x: F_X<1\right\}$. Assume that there is a real number $x_1$, such that for $x_1\leq x <\omega(F_X)$, $f_X(x) = F_X'(x) \neq 0$ and $F_X''(x)$ exists. If
\begin{equation}
\lim_{x\rightarrow \omega(F_X)}\frac{d}{dx}\left[\frac{1-F_X(x)}{f_X(x)}\right] = 0,
\label{lemma_evt}
\end{equation}
then $F_X(x)$ lies on the MDA of the Gumbel distribution (\ref{evt_conv}) with the CDF expressed as
\begin{equation}
G(x) = e^{-e^{-\frac{x-a_N}{b_N}}},
\label{eq:CDF_Gumbel}
\end{equation}
where the normalizing constants $a_N$ and $b_N$ are determined by
\begin{equation}
\begin{split}
a_N &= F_X^{-1}\left(1-\frac{1}{N}\right), \\
b_N &= F_X^{-1}\left(1-\frac{1}{Ne}\right) - a_N.
\end{split}
\label{eq:SINR_coeffs}
\end{equation}
Here $e$ is the base of the natural logarithm, and $F_X^{-1}(\cdot)$ denotes the inverse of the CDF.
\end{lemma}
Using Lemma \ref{lemma_mda}, we prove that the CDF of SINR $F_{\gamma_i}(\cdot)$ lies on the MDA of the Gumbel distribution.
\begin{proposition} \label{proposition_SINR}
Assume that the transmit power of the secondary transmitter is given by (\ref{tran_power}). Then the SINR distribution $F_{\gamma_i}(\cdot)$ of the SR with transmit antenna selection belongs to the MDA of the Gumbel distribution.
\end{proposition}
\begin{IEEEproof}
see Appendix \ref{append_proof}.
\end{IEEEproof}
Using Proposition \ref{proposition_SINR}, we obtain approximations for the mean capacity and outage capacity of the SU.
\section{Asymptotic Performance Analysis} \label{sec:perf}
\subsection{SU Mean Capacity}\label{sec:ec}
The instantaneous rate for the SU can be represented as
\begin{equation}
R_{\max} = \max_{1\leq i\leq N}\,\, R_i, \label{eq:R_max}
\end{equation}
where $R_i=\log\left(1+\gamma_i\right), \forall i=1,\cdots, N$ is the instantaneous rate using the $i$-th antenna. According to the limiting throughput distribution (LTD) theorem proved in \cite{Song2006}, the distribution of $R_i$ belongs to the MDA of the Gumbel distribution. Consequently, we have $\lim_{N\rightarrow \infty}\frac{R_{\max} - a_N}{b_N} \xrightarrow[]{d} G(x)$ and $G(x)$ is expressed in (\ref{eq:CDF_Gumbel}) with the following normalizing constants
\begin{equation}
\begin{split}
a_N &= \log\left[1+ F^{-1}_{\gamma_i}\left(1-\frac{1}{N}\right)\right], \\
b_N &= \log\left[\frac{1+ F^{-1}_{\gamma_i}\left(1-\frac{1}{N e}\right)}{1+ F^{-1}_{\gamma_i}\left(1-\frac{1}{N}\right)}\right],
\end{split}
\label{eq:coeff_cap}
\end{equation}
where $F^{-1}_{\gamma_i}(\cdot)$ denotes the inverse function of $F_{\gamma_i}(\cdot)$ in (\ref{cdf_gamma_i}).
Based on the Lemma 2 in \cite{Song2006}, we find that the expectation of $\frac{R_{\max} - a_N}{b_N}$ converges, and the mean capacity of the SU $C_s = \mathbb{E}\left[R_{\max}\right]$ can be thus approximated by integrating $R_{\max}$ over (\ref{eq:CDF_Gumbel}) as
\begin{equation}
C_s \approx a_N + b_N\text{E}_0, \label{eq:Cs_appr}
\end{equation}
where $\text{E}_0 = 0.5772\ldots$ denotes the Euler constant. According to Proposition \ref{proposition_SINR} the approximation is tight in the asymptotic regime $N\rightarrow \infty$.
Based on (\ref{eq:Cs_appr}), we study the behavior of the SU mean capacity in two limiting regimes. First, we consider that the maximum transmit power constraint approaches infinity ($P_{\max}\rightarrow \infty$). And the second case is that the interference power constraint is much larger than $P_{\max}$, i.e., $Q \gg P_{\max}$. We name these two scenarios as interference power limited regime (IPLR) and transmit power limited regime (TPLR), respectively.
\subsubsection{Interference power limited regime}
When $P_{\max}\rightarrow \infty$ and the $i$-th antenna is selected, we rewrite the asymptotic CDF (\ref{cdf_gamma_i}) of the SINR at the SR as
\begin{equation}
F_{\gamma_i, \text{IPLR}}(x) = 1-c_p \frac{Q \overline{g}}{x\overline{h}},
\end{equation}
where $c_p = e^{\sigma^2/\left(P_p \overline{q}\right)} \Gamma\left(0,\frac{\sigma^2}{P_p \overline{q}}\right)/P_p\, \overline{q}$ represents the effects of the additive noise and the PU interference. The inverse CDF of the SINR is given by
\begin{equation}
F_{\gamma_i,\text{IPLR}}^{-1}[y] = c_p \frac{Q \overline{g}}{(1-y)\overline{h}}. \label{eq:F_IPLR}
\end{equation}
Using (\ref{eq:coeff_cap}) and (\ref{eq:F_IPLR}), the normalizing constants of the Gumbel distribution $G(x)$ are obtained as
\begin{equation}
a^{\text{IPLR}}_N = \log\left(1+c_p \frac{Q \overline{g}}{\overline{h}} N\right),
\label{eq:aN_IPLR}
\end{equation}
and
\begin{equation}
b^{\text{IPLR}}_N = \log\left(\frac{1+c_p \frac{Q \overline{g}}{\overline{h}} N e}{1+c_p \frac{Q \overline{g}}{\overline{h}} N}\right),
\label{eq:bN_IPLR}
\end{equation}
where $b^{\text{IPLR}}_N\rightarrow 1$ as $N\rightarrow \infty$. Thus, the asymptotic mean capacity (\ref{eq:Cs_appr}) becomes
\begin{equation}
C^{\text{IPLR}} = \log\left(1+c_p \frac{Q \overline{g}}{\overline{h}} N\right) + \text{E}_0, \label{eq:C_IPLR}
\end{equation}
which indicates that the SU mean capacity scales as $\log(N)$ in the interference power limited regime.
\subsubsection{Transmit power limited regime}
When $Q \gg P_{\max}$ and the $i$-th antenna is selected, we rewrite the asymptotic CDF (\ref{cdf_gamma_i}) of the SINR at the SR as
\begin{equation}
F_{\gamma_i, \text{TPLR}}(x) = 1-\frac{c_q\, P_{\max} \overline{g}}{x P_p \overline{q} + P_{\max}\overline{g}} e^{-\frac{x \sigma^2}{P_{\max}\overline{g}}}, \label{eq:F_TPLR}
\end{equation}
where $c_q = 1-e^{-\rho/\overline{h}}$ and $\rho = Q/P_{\max}$. The inverse CDF of the SINR can be obtained as
\begin{equation}
F_{\gamma_i, \text{TPLR}}^{-1}[y] \approx \frac{P_{\max}\overline{g}}{\sigma^2} \mathcal{W}\left(\frac{c_q\, e^{\frac{\sigma^2}{P_p \overline{q}}}}{(1-y) P_p \overline{q}/\sigma^2}\right) - \frac{P_{\max}\overline{g}}{P_p \overline{q}}, \label{eq:Finvs_TPLR}
\end{equation}
where $\mathcal{W}(x)$ denotes the Lambert W-Function satisfying $\mathcal{W}(x) e^{\mathcal{W}(x)} = x$. Thus, using (\ref{eq:coeff_cap}) and (\ref{eq:Finvs_TPLR}), the normalizing constants of the Gumbel distribution $G(x)$ are obtained as
\small
\begin{IEEEeqnarray}{ll}
a_N^{\text{TPLR}} &= \log\left(1+\frac{P_{\max}\overline{g}}{\sigma^2} \mathcal{W}\left(\frac{N\,c_q\, e^{\frac{\sigma^2}{P_p \overline{q}}}}{ P_p \overline{q}/\sigma^2}\right) - \frac{P_{\max}\overline{g}}{P_p \overline{q}}\right), \label{eq:aN_TPLR} \\
b_N^{\text{TPLR}} &= \log\left(1+\frac{P_{\max}\overline{g}}{\sigma^2} \mathcal{W}\left(\frac{e N\,c_q\, e^{\frac{\sigma^2}{P_p \overline{q}}}}{ P_p \overline{q}/\sigma^2}\right) - \frac{P_{\max}\overline{g}}{P_p \overline{q}}\right)-a_N^{\text{TPLR}}, \nonumber\\
& \label{eq:bN_TPLR}
\end{IEEEeqnarray}
\normalsize
where $b_N^{\text{TPLR}} = O\left(1/N\right)$ as $N\rightarrow \infty$, and $O\left(z\right)^m$ represents a term of order $\left(z\right)^m$. Therefore, the SU asymptotic mean capacity (\ref{eq:Cs_appr}) becomes
\begin{equation}
C^{\text{TPLR}} = a_N^{\text{TPLR}} + b_N^{\text{TPLR}} \text{E}_0, \label{eq:C_TPLR}
\end{equation}
which admits an explicit expression and avoids the operation of inverting the SINR CDF function (\ref{cdf_gamma_i}).
When the interference from the PU can be ignored, i.e. $P_p \overline{q}\rightarrow 0$, (\ref{eq:F_TPLR}) becomes
\begin{equation}
F_{\gamma_i, \text{TPLR}}(x) \approx 1- c_q e^{-\frac{x \sigma^2}{P_{\max}\overline{g}}},
\end{equation}
which is the approximation of the CDF of the SINR at low interference regime. Then we obtain the inverse CDF as
\begin{equation}
F_{\gamma_i, \text{TPLR}}^{-1}[y] \approx \frac{P_{\max}\overline{g}}{\sigma^2}\log\left(\frac{c_q}{1-y}\right).
\label{eq:TPLR}
\end{equation}
Substituting (\ref{eq:TPLR}) into (\ref{eq:coeff_cap}), we have the normalizing constants
\begin{equation}
a_{N, \text{low}}^{\text{TPLR}} = \log\left(1+\frac{P_{\max}\overline{g}}{\sigma^2}\log(c_q N)\right), \label{eq:aN_TPLR_low}
\end{equation}
\begin{equation}
b_{N, \text{low}}^{\text{TPLR}} = \log\left(1+\frac{P_{\max}\overline{g}/\sigma^2}{1+\frac{P_{\max}\overline{g}}{\sigma^2}\log(c_q N)}\right). \label{eq:bN_TPLR_low}
\end{equation}
Substituting (\ref{eq:aN_TPLR_low}) and (\ref{eq:bN_TPLR_low}) into (\ref{eq:Cs_appr}), the asymptotic mean capacity is obtained as
\begin{equation}
C^{\text{TPLR}}_{\text{low}} \approx a_{N, \text{low}}^{\text{TPLR}} + b_{N, \text{low}}^{\text{TPLR}} \text{E}_0, \label{eq:C_TPLR_noPp}
\end{equation}
where $b_{N, \text{low}}^{\text{TPLR}} = O\left(1/N\right)$ as $N\rightarrow \infty$. This shows that the SU mean capacity scales as $\log\log(N)$ in the transmit power limited regime with low PU interference. Note that in the TPLR with low PU interference, the considered model (\ref{eq:signal_model}) reduces to the conventional point-to-point communication. In this case, the derived result (\ref{eq:C_TPLR_noPp}) is in line with \cite[eq. (38)]{Bai2009}.
\subsubsection*{Remarks}
The results suggest that the TAS provides different power gains in these two scenarios. In the TPLR, (\ref{eq:C_TPLR_noPp}) shows that increasing the number of transmit antennas may not be an efficient way to achieve higher mean capacity, while it is effective in the IPLR as shown in (\ref{eq:C_IPLR}).
\subsection{SU Outage Capacity}\label{sec:outc}
Given the rate $r$ (nats/s/Hz), the SU outage probability after transmit antenna selection can be defined as
\begin{equation}
F_{\text{out}}(r) = \Pr\left\{R_{\max}<r\right\},
\end{equation}
where $R_{\max}$ is given by (\ref{eq:R_max}). The outage capacity can be interpreted as the maximum rate such that $F_{\text{out}}\leq \epsilon$, where $\epsilon$ is the defined outage threshold. For monotonically increasing function $F_{\text{out}}(r)$, we have
\begin{equation}
C_{\text{out}} = F_{\text{out}}^{-1}(\epsilon). \label{eq:cout_def}
\end{equation}
According to the LTD theorem \cite{Song2006}, the asymptotic distribution of $R_{\max}$ can be approximated as (\ref{eq:CDF_Gumbel}). Thereafter, we have the following proposition for the SU outage capacity.
\begin{proposition} \label{proposition_C_out}
With TAS, the asymptotic outage capacity of the SU is given by
\begin{equation}
C_{\text{out}} \approx a_N - b_N \log\log\left(\frac{1}{\epsilon}\right), \label{eq:C_out}
\end{equation}
where the normalizing constants $a_N$ and $b_N$ are the normalizing coefficients given in (\ref{eq:coeff_cap}).
\end{proposition}
\begin{IEEEproof}
The proof of this proposition is straightforward by substituting (\ref{eq:CDF_Gumbel}) into (\ref{eq:cout_def}).
\end{IEEEproof}
Based on Proposition \ref{proposition_C_out}, we investigate the SU outage capacity scaling properties in case of IPLR and TPLR, respectively.
\subsubsection{Interference power limited regime} When $P_{\max}\rightarrow \infty$, the normalizing constants $a_N^{\text{IPLR}}$ and $b_N^{\text{IPLR}}$ are computed in (\ref{eq:aN_IPLR}) and (\ref{eq:bN_IPLR}), respectively. Following (\ref{eq:C_out}), the asymptotic SU outage capacity in IPLR yields
\small
\begin{equation}
C^{\text{IPLR}}_{\text{out}} = \log\left(1+c_p \frac{Q \overline{g}}{\overline{h}} N\right) - \log\left(\frac{1+c_p \frac{Q \overline{g}}{\overline{h}} N e}{1+c_p \frac{Q \overline{g}}{\overline{h}} N}\right)\log\log\left(\frac{1}{\epsilon}\right). \label{C_out_IPLR}
\end{equation}
\normalsize
Recall that $b_N^{\text{IPLR}} \rightarrow 1$ when $N\rightarrow \infty$, we have
\begin{IEEEeqnarray}{ll}
C^{\text{IPLR}}_{\text{out}} &\approx \log\left(1+c_p \frac{Q \overline{g}}{\overline{h}} N\right) - \log\log\left(\frac{1}{\epsilon}\right) \\
& = C^{\text{IPLR}} - \text{E}_0 - \log\log\left(\frac{1}{\epsilon}\right), \label{eq:C_IPLR_out}
\end{IEEEeqnarray}
where $C^{\text{IPLR}}$ is given in (\ref{eq:C_IPLR}). We can see that the SU outage capacity scales in the same manner as the SU mean capacity. When given the outage threshold $\epsilon$, there exists a constant gap $\text{E}_0 + \log\log\left(\frac{1}{\epsilon}\right)$ between $C^{\text{IPLR}}_{\text{out}}$ and $C^{\text{IPLR}}$.
\subsubsection{Transmit power limited regime}
When $Q\gg P_{\max}$, following (\ref{eq:C_out}) the asymptotic SU outage capacity in TPLR yields
\begin{equation}
C^{\text{TPLR}}_{\text{out}} = a_N^{\text{TPLR}} - b_N^{\text{TPLR}}\log\log\left(\frac{1}{\epsilon}\right), \label{eq:c_out_TPLR}
\end{equation}
where the normalizing constants $a_N^{\text{TPLR}}$ and $b_N^{\text{TPLR}}$ are computed in (\ref{eq:aN_TPLR}) and (\ref{eq:bN_TPLR}), respectively.
We can see that the SU outage capacity scales the same way as the SU mean capacity, i.e. $C^{\text{TPLR}}_{\text{out}}\sim \log\log\left(N\right)$ as $N\rightarrow \infty$. It is also shown that the asymptotic SU outage capacity does not depend on the outage threshold $\epsilon$. However, the convergence speed is pretty slow due to $C^{\text{TPLR}}_{\text{out}}\sim \log\log\left(N\right)$.
When the interference from the PU can be ignored in TPLR, i.e. $P_p \overline{q}\rightarrow 0$, the asymptotic SU outage capacity (\ref{eq:c_out_TPLR}) yields
\begin{equation}
C^{\text{TPLR}}_{\text{out, low}} \approx a_{N, \text{low}}^{\text{TPLR}} - b_{N, \text{low}}^{\text{TPLR}} \log\log\left(\frac{1}{\epsilon}\right). \label{eq:C_out_TPLR_low}
\end{equation}
where $a_{N, \text{low}}^{\text{TPLR}}$ and $b_{N, \text{low}}^{\text{TPLR}}$ are given by (\ref{eq:aN_TPLR_low}) and (\ref{eq:bN_TPLR_low}), respectively.
\subsubsection*{Remarks} The number of antennas has different influence on the asymptotic outage capacity of the SU. In the TPLR case, i.e. $P_{\max}\ll Q$, the SU outage capacity increases logarithmically with $N$ and the gap between the SU mean capacity and outage capacity vanishes. However, this is not for the IPLR scenario, i.e. $P_{\max}\rightarrow \infty$, that the outage capacity has a much slower scaling rate, $\log\log(N)$. In addition, there is always a gap between the outage capacity $C^{\text{IPLR}}_{\text{out}}$ and mean capacity $C^{\text{IPLR}}$.
\section{Simulation Results}\label{sec:Sim}
We present the asymptotic results with respect to $N$ for the SU mean capacity and the outage capacity, assuming that the ST employs transmit antenna selection and the transmit power is restricted by the peak interference power constraint and the maximum transmit power constraint. The rate scaling behaviors of the mean capacity and outage capacity are also discussed. The mean channel power gains are set to 1. The noise power per Hz at the SR is set to $-10$ dB, i.e., $\sigma^2 = 0.1$, where we assume that the maximum average received signal to noise ratio at the SR is greater or equal to 1, i.e., $\mathbb{E}\left[P_{\max}\overline{g_i}\right]/\sigma^2\geq 1$. Let $\mathsf{INR}=P_p/\sigma^2$ denote the interference to the noise ratio, $\mathsf{SIR_Q}=Q/P_p$ and $\mathsf{SIR_P}=P_{\max}/P_p$ be the transmit signal to the interference power ratio, and $\mathsf{SNR_Q}=Q/\sigma^2$ and $\mathsf{SNR_P}=P_{\max}/\sigma^2$ be the transmit signal to the noise power ratio. In addition, $\mathsf{PQR}=P_{\max}/Q$ is the maximum power to the interference constraint ratio.
Fig. \ref{fig:ergC_Q} shows the SU mean capacity versus the interference power constraint $Q$ when the number of the ST antennas is $N=4$, 10, and 20. The PU transmit power is set to $P_p=0$ dB, and the maximum transmit power $P_{\max}$ of the SU is $0$ dB. We also plotted the asymptotic mean capacity of the SU according to (\ref{eq:Cs_appr}), and compared it to the simulation results generated by $10^{6}$ channel realizations. As the interference power constraint $Q$ increases, the SU mean capacity is improved until the maximum transmit power constraint $P_{\max}$ becomes dominating. We can see that the asymptotic results using EVT are reasonably accurate, which validates our approach to characterize the SU mean capacity using simple and explicit expressions.
\begin{figure}[!t]
\centering
\includegraphics[width=0.7\columnwidth]{ergC_Q.eps}
\caption{SU mean capacity versus the peak interference power constraint $Q$ with $P_{\max} = 0$ dB and $P_p = 0$ dB.}
\label{fig:ergC_Q}
\end{figure}
Fig. \ref{fig:c_Scal} shows the the SU mean capacity as a function of the number of ST antennas in the interference power and the transmit power limited regimes, respectively. In Fig. \ref{fig:c_Scal_IPLR}, the maximum transmit power constraint is set to $P_{\max}=30$ dB$\gg Q$. In this case, we calculate the SU mean capacity using IPLR approximation, namely (\ref{eq:Cs_appr}) with the normalizing constant $a^{\text{IPLR}}_N$ and $b^{\text{IPLR}}_N$ given by (\ref{eq:aN_IPLR}) and (\ref{eq:bN_IPLR}), respectively. In addition, we show the SU rate scaling (\ref{eq:C_IPLR}) in IPLR. Numerical results show that the approximation and scaling yield good agreement with simulations, especially when $\mathsf{PQR}=35$ dB and $\mathsf{SNR_Q} = 5$ dB. Furthermore, the scaling behavior of the SU capacity is shown to be $\log(N)$ as predicted by (\ref{eq:C_IPLR}). In Fig. \ref{fig:c_Scal_TPLR}, we assume that $\mathsf{PQR} = \left\{-10, -20\right\}$ dB. The SU mean capacity is computed using TPLR approximation (\ref{eq:C_TPLR}), and the SU rate scaling is obtained via (\ref{eq:C_TPLR_noPp}). In TPLR with low PU interference, e.g. $\mathsf{INR} = -10$ dB, the SU capacity scales as $\log(\log(N))$. Results show that in TPLR, it is more effective to improve the SU capacity by increasing the transmit power than by using more transmit antennas. However, in IPLR if the SU is subject to a lower interference limit, the mean capacity can be maintained by using more transmit antennas.
\begin{figure}[!t]
\centering
\subfloat[IPLR]{\label{fig:c_Scal_IPLR} \includegraphics[width=0.7\columnwidth]{erg_IPLR.eps}} \\
\subfloat[TPLR]{\label{fig:c_Scal_TPLR} \includegraphics[width=0.7\columnwidth]{erg_TPLR.eps}}
\caption{SU mean capacity versus the number of ST antennas $N$. Lines with circles denote $\mathsf{INR} = -10$ dB; lines with diamonds denote $\mathsf{INR} = 10$ dB. (a) IPLR: $\mathsf{PQR} = \left\{35, 40\right\}$ dB. (b) TPLR: $\mathsf{PQR} = \left\{-10, -20\right\}$ dB.}
\label{fig:c_Scal}
\end{figure}
The SU outage capacity is plotted as a function of the interference constraint $Q$ in Fig. \ref{fig:c_out_Q}, where the outage probability is set to $10\%$. Although the EVT approximation is not very accurate for $N=4$ ST antennas, it gives an estimate trend of the SU outage capacity. As the number of antennas increases, the accuracy of the EVT approximation improves. In addition, for $N=20$ the approximation for a large range interference constraint, $Q\geq -10$dB, is acceptably accurate for understanding such systems.
\begin{figure}[!t]
\centering
\includegraphics[width=0.7\columnwidth]{c_out_Q.eps}
\caption{SU outage capacity. $P_{\max}=0 dB$, $P_p=0dB$, and $\epsilon = 10\%$.}
\label{fig:c_out_Q}
\end{figure}
In order to gain some insight into the asymptotic behavior of the SU outage capacity, we depict in Fig. \ref{fig:c_outN_scal} the SU outage capacity in the transmit power limited and interference power limited regimes, respectively. The asymptotic SU mean capacity is also plotted for a comparison. As the number of ST antennas increases, the asymptotic outage capacities for various cases are accurate compared to the numerical simulations. The scaling properties of the SU outage capacity are validated. In Fig. \ref{fig:out_IPLR}, the SU outage capacity in IPLR behaves as $\log(N)$ when the number of ST antennas $N$ approaches to infinity. In this case, there is a constant gap $\text{E}_0 +\log\log\left(1/\epsilon\right)$ between the outage and the mean capacities as predicted by (\ref{eq:C_IPLR_out}). Yet, the SU outage capacity in TPLR behaves as $\log\log(N)$ as shown in Fig. \ref{fig:out_TPLR}, which can be proved using (\ref{eq:C_out_TPLR_low}).
\begin{figure}[!t]
\centering
\subfloat[IPLR]{\label{fig:out_IPLR}\includegraphics[width=0.7\columnwidth]{out_IPLR.eps}}\\
\subfloat[TPLR]{\label{fig:out_TPLR}\includegraphics[width=0.7\columnwidth]{out_TPLR.eps}}
\caption{SU outage capacity versus the number of ST antennas $N$. Lines with circles denote $\mathsf{INR}=-10$ dB; lines with diamonds denote $\mathsf{INR}=10$ dB. The peak interference power constraint $Q = 5$ dB. Outage threshold $\epsilon = 10\%$. (a) IPLR: $\mathsf{PQR}=25$ dB. (b) TPLR: $\mathsf{PQR} = \left\{-5, -15\right\}$ dB.}
\label{fig:c_outN_scal}
\end{figure}
\section{Conclusion}\label{sec:Con}
In this paper, we applied the extreme value theory while studying the performance of a spectrum sharing system in terms of the SU mean capacity, the SU outage capacity, and the rate scaling characteristics. The SU mean capacity and outage capacity have two scaling behaviors with the number of available transmit antennas: in the interference power limited regime (IPLR), capacities scale as $\log(N)$, while they scale as $\log(\log(N))$ in transmit power limited regime (TPLR). These results indicate that the transmit antenna selection technique provides different power gain in considered two scenarios. The obtained accurate approximations provide us a better understanding on the performance of the spectrum-sharing systems with multiple transmit antennas.
|
{'timestamp': '2015-06-18T02:09:59', 'yymm': '1506', 'arxiv_id': '1506.05226', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05226'}
|
arxiv
|
\subsection{Simulation Study 2: Details \& Typical Fits}\label{app:ex-families}
\subsubsection{Data Generating Process for Simulation Study 2}
We use different signal-to-noise ratios (SNR) to control the difficulty of the simulation settings. For Beta-distributed responses with $g(\cdot)=\operatorname{logit}^{-1}(\cdot)$, distribution parameters $\alpha, \beta$ are determined by approximate SNR via $\phi = \text{SNR} \tfrac{m_\mu}{v_\mu}- 1$, with $m_\mu = N^{-1} \sum_{i,t} \mu_{it}(1-\mu_{it})$, where $v_\mu$ is the sample variance of the simulated $\mu_{it}$ and $\bm{\mu} = \text{logit}^{-1}(\bm{\eta})$. Beta parameters for generating $\bm{y}$ are then given by $\bm{\alpha} = \phi\bm{\mu}$ and $\bm{\beta} = \phi - \bm{\alpha}$. $\bm{\eta}$ is first scaled linearly to the interval $\left[-1.5, 1.5\right]$.
\subsubsection{Computational details}
We use the following spline bases to construct $\bm{\Phi}_{\bm x}$ for the different effects:
\begin{itemize}
\item \texttt{smoo}: 8 cubic thin plate splines over the range of $x$
\item \texttt{te}: 45 bivariate cubic thin plate splines over the joint space of $x_1$ and $x_2$
\item \texttt{ff}: 5 cubic P-splines with first order difference penalty over $\mathcal{S}$
\end{itemize}
The functional intercept (\texttt{int}) uses 40 cubic cyclic P-splines with first order difference penalty over $\mathcal T$. For all other terms, we use 5 cubic P-splines with first order difference penalty for $\bm{\Phi}_{\bm t}$.
\subsubsection{Typical Fits for Simulation Study 2}
Figures \ref{fig:families-ex-beta} to \ref{fig:families-ex-t3} show some typical fits for these data generating processes. Figure \ref{fig:families-ex-beta} shows estimated effects for a Beta-response model with a nonlinear effect of a scalar covariate (\code{smoo}, $n=300, \text{SNR}=1$), Figure \ref{fig:families-ex-nb} shows estimated effects for
a Negative Binomial-response model with a linear function-on-function effect (\code{ff}, $n=100$) and Figure \ref{fig:families-ex-t3} shows estimated effects for
a $t(3)$-response model with a nonlinear interaction effect of two scalar covariates (\code{te}, $n=100, \text{SNR}=5$)
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/families-ex-beta-1}
}
\caption[Typical model fit for a Beta-distributed model with a nonlinear effect of scalar covariate (\code{smoo}, ]{Typical model fit for a Beta-distributed model with a nonlinear effect of scalar covariate (\code{smoo}, $n=300, \text{SNR}=1$) with rRIMSE$(\hat\eta(t))\approx 0.047$ and coverage $\approx 0.98$ for $\hat\eta(t)$. Red line in the left panel shows true intercept function, light grey ribbon gives approximate pointwise 95\% interval. On the right, top panel shows estimated nonlinear effect of scalar covariate $\hat f(x,t)$ and bottom panel the true $f(x,t)$.}\label{fig:families-ex-beta}
\end{figure}
\end{knitrout}
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/families-ex-nb-1}
}
\caption[Typical model fit for a NB-distributed model with a linear effect of a functional covariate (\code{ff}, ]{Typical model fit for a NB-distributed model with a linear effect of a functional covariate (\code{ff}, $n=100$) with rRIMSE$(\hat\eta(t))\approx 0.083$ and coverage $\approx 0.97$ for $\hat\eta(t)$. Red dotted line in the left panel shows true intercept function, light grey ribbon gives approximate pointwise 95\% interval. On the right, top panel shows estimated $\hat \beta(s, t)$ and bottom panel the true $\beta(s, t)$ for the function-on-function effect.}\label{fig:families-ex-nb}
\end{figure}
\end{knitrout}
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/families-ex-t3-1}
}
\caption[Typical model fit for a t3-distributed model with a nonlinear interaction effect of two scalar covariates (\code{te}, ]{Typical model fit for a t3-distributed model with a nonlinear interaction effect of two scalar covariates (\code{te}, $n=300, \text{SNR}=5$) with rRIMSE$(\hat\eta(t))\approx 0.043$ and coverage $\approx 0.94$ for $\hat\eta(t)$. Red dotted line in the left panel shows true intercept function, light grey ribbon gives approximate pointwise 95\% interval. On the right, top panel shows estimated smooth interaction $\hat f(x_1, x_2)$ and bottom panel the true $f(x_1, x_2)$.}\label{fig:families-ex-t3}
\end{figure}
\end{knitrout}
\subsubsection{Tabular Results for Simulation Study 2}
Tables \ref{tab:families-tables-eta} and \ref{tab:families-tables-coef} show median
rRIMSES and coverages for simulation study \ref{sec:sim-families} for the entire additive predictor and the estimated covariate effects, respectively.
\begin{table}[ht]
\begin{footnotesize}
\begin{tabular}{llll|rrr|rrr}
\hline
Family & Set & SNR & n & Median rRIMSE$(\hat\eta(t))$ & $q_{25}$ & $q_{75}$ & Median coverage & $q_{25}$ & $q_{75}$ \\
\hline
Beta & int & 1 & 100 & 0.06 & 0.05 & 0.06 & 0.97 & 0.95 & 0.98 \\
& & & 300 & 0.04 & 0.04 & 0.04 & 0.97 & 0.93 & 0.98 \\
& & 5 & 100 & 0.03 & 0.03 & 0.04 & 0.96 & 0.93 & 0.98 \\
& & & 300 & 0.02 & 0.02 & 0.02 & 0.94 & 0.92 & 0.97 \\
& smoo & 1 & 100 & 0.08 & 0.07 & 0.08 & 0.98 & 0.96 & 0.99 \\
& & & 300 & 0.05 & 0.05 & 0.06 & 0.97 & 0.95 & 0.98 \\
& & 5 & 100 & 0.04 & 0.04 & 0.05 & 0.97 & 0.96 & 0.98 \\
& & & 300 & 0.03 & 0.03 & 0.03 & 0.96 & 0.95 & 0.97 \\
& te & 1 & 100 & 0.10 & 0.09 & 0.11 & 0.97 & 0.96 & 0.98 \\
& & & 300 & 0.07 & 0.06 & 0.07 & 0.96 & 0.95 & 0.97 \\
& & 5 & 100 & 0.05 & 0.05 & 0.06 & 0.95 & 0.94 & 0.96 \\
& & & 300 & 0.04 & 0.04 & 0.04 & 0.93 & 0.91 & 0.94 \\
& ff & 1 & 100 & 0.07 & 0.07 & 0.08 & 0.96 & 0.94 & 0.98 \\
& & & 300 & 0.05 & 0.05 & 0.05 & 0.96 & 0.94 & 0.97 \\
& & 5 & 100 & 0.04 & 0.04 & 0.04 & 0.96 & 0.94 & 0.97 \\
& & & 300 & 0.03 & 0.02 & 0.03 & 0.95 & 0.93 & 0.96 \\
NB & int & NA & 100 & 0.05 & 0.05 & 0.06 & 0.97 & 0.95 & 0.98 \\
& & & 300 & 0.04 & 0.03 & 0.04 & 0.95 & 0.93 & 0.97 \\
& smoo & & 100 & 0.08 & 0.07 & 0.09 & 0.97 & 0.96 & 0.98 \\
& & & 300 & 0.05 & 0.05 & 0.06 & 0.97 & 0.96 & 0.98 \\
& te & & 100 & 0.14 & 0.13 & 0.15 & 0.97 & 0.96 & 0.98 \\
& & & 300 & 0.10 & 0.09 & 0.11 & 0.97 & 0.95 & 0.98 \\
& ff & & 100 & 0.08 & 0.08 & 0.09 & 0.96 & 0.94 & 0.97 \\
& & & 300 & 0.05 & 0.05 & 0.06 & 0.95 & 0.94 & 0.97 \\
t(3) & int & 1 & 100 & 0.07 & 0.06 & 0.08 & 0.97 & 0.95 & 0.98 \\
& & & 300 & 0.05 & 0.04 & 0.05 & 0.97 & 0.95 & 0.98 \\
& & 5 & 100 & 0.04 & 0.03 & 0.04 & 0.95 & 0.93 & 0.97 \\
& & & 300 & 0.02 & 0.02 & 0.03 & 0.95 & 0.92 & 0.97 \\
& smoo & 1 & 100 & 0.09 & 0.08 & 0.10 & 0.98 & 0.96 & 0.99 \\
& & & 300 & 0.06 & 0.05 & 0.06 & 0.97 & 0.96 & 0.98 \\
& & 5 & 100 & 0.05 & 0.05 & 0.05 & 0.97 & 0.96 & 0.98 \\
& & & 300 & 0.03 & 0.03 & 0.03 & 0.97 & 0.95 & 0.97 \\
& te & 1 & 100 & 0.12 & 0.11 & 0.12 & 0.97 & 0.96 & 0.98 \\
& & & 300 & 0.08 & 0.07 & 0.08 & 0.96 & 0.95 & 0.97 \\
& & 5 & 100 & 0.06 & 0.06 & 0.07 & 0.95 & 0.94 & 0.97 \\
& & & 300 & 0.04 & 0.04 & 0.04 & 0.94 & 0.93 & 0.95 \\
& ff & 1 & 100 & 0.09 & 0.08 & 0.09 & 0.96 & 0.94 & 0.98 \\
& & & 300 & 0.06 & 0.05 & 0.06 & 0.96 & 0.94 & 0.97 \\
& & 5 & 100 & 0.05 & 0.04 & 0.05 & 0.96 & 0.94 & 0.97 \\
& & & 300 & 0.03 & 0.03 & 0.03 & 0.95 & 0.93 & 0.96 \\
\hline
\end{tabular}
\caption{Tabular display of results in Figure \ref{fig:families-eta}. Median and 25\% and 75\% quantiles for relative RIMSE and pointwise coverages for the additive predictor $\hat\eta(t)$.}
\label{tab:families-tables-eta}
\end{footnotesize}
\end{table}
\begin{table}[ht]
\begin{footnotesize}
\begin{tabular}{llll|rrr|rrr}
\hline
Family & Set & SNR & n & Median rRIMSE$(\hat f(\mathcal{X}_{r}, t))$ & $q_{25}$ & $q_{75}$ & Median coverage & $q_{25}$ & $q_{75}$ \\
\hline
Beta & smoo & 1 & 100 & 0.29 & 0.25 & 0.33 & 0.99 & 0.97 & 1.00 \\
& & & 300 & 0.20 & 0.18 & 0.22 & 0.99 & 0.97 & 1.00 \\
& & 5 & 100 & 0.17 & 0.16 & 0.19 & 0.99 & 0.97 & 1.00 \\
& & & 300 & 0.12 & 0.11 & 0.13 & 0.98 & 0.96 & 0.99 \\
& te & 1 & 100 & 0.18 & 0.16 & 0.20 & 0.94 & 0.92 & 0.96 \\
& & & 300 & 0.11 & 0.10 & 0.12 & 0.94 & 0.92 & 0.96 \\
& & 5 & 100 & 0.13 & 0.11 & 0.15 & 0.90 & 0.88 & 0.92 \\
& & & 300 & 0.07 & 0.07 & 0.08 & 0.89 & 0.87 & 0.91 \\
& ff & 1 & 100 & 0.32 & 0.28 & 0.36 & 0.93 & 0.87 & 0.97 \\
& & & 300 & 0.20 & 0.18 & 0.23 & 0.94 & 0.90 & 0.99 \\
& & 5 & 100 & 0.17 & 0.15 & 0.19 & 0.95 & 0.90 & 0.99 \\
& & & 300 & 0.11 & 0.10 & 0.12 & 0.94 & 0.91 & 0.98 \\
NB & smoo & NA & 100 & 0.31 & 0.27 & 0.35 & 0.99 & 0.97 & 1.00 \\
& & & 300 & 0.21 & 0.18 & 0.22 & 0.99 & 0.97 & 1.00 \\
& te & & 100 & 0.23 & 0.22 & 0.26 & 0.96 & 0.93 & 0.97 \\
& & & 300 & 0.16 & 0.14 & 0.17 & 0.96 & 0.94 & 0.97 \\
& ff & & 100 & 0.35 & 0.31 & 0.40 & 0.93 & 0.85 & 0.97 \\
& & & 300 & 0.22 & 0.19 & 0.24 & 0.94 & 0.89 & 0.97 \\
t(3) & smoo & 1 & 100 & 0.32 & 0.29 & 0.36 & 1.00 & 0.98 & 1.00 \\
& & & 300 & 0.22 & 0.20 & 0.25 & 0.99 & 0.97 & 1.00 \\
& & 5 & 100 & 0.19 & 0.18 & 0.21 & 0.99 & 0.97 & 0.99 \\
& & & 300 & 0.13 & 0.12 & 0.14 & 0.98 & 0.96 & 0.99 \\
& te & 1 & 100 & 0.20 & 0.18 & 0.22 & 0.95 & 0.93 & 0.97 \\
& & & 300 & 0.12 & 0.11 & 0.13 & 0.95 & 0.94 & 0.97 \\
& & 5 & 100 & 0.14 & 0.12 & 0.15 & 0.91 & 0.89 & 0.93 \\
& & & 300 & 0.08 & 0.07 & 0.09 & 0.90 & 0.88 & 0.92 \\
& ff & 1 & 100 & 0.36 & 0.32 & 0.41 & 0.93 & 0.87 & 0.98 \\
& & & 300 & 0.24 & 0.20 & 0.26 & 0.94 & 0.89 & 0.98 \\
& & 5 & 100 & 0.19 & 0.17 & 0.22 & 0.94 & 0.90 & 0.99 \\
& & & 300 & 0.13 & 0.11 & 0.14 & 0.94 & 0.90 & 0.97 \\
\hline
\end{tabular}
\caption{Tabular display of results in Figure \ref{fig:families-coef}. Median and 25\% and 75\% quantiles for relative RIMSE and pointwise coverages for the estimated effects $\hat f(\mathcal{X}_{r}, t)$.}
\label{tab:families-tables-coef}
\end{footnotesize}
\end{table}
\subsection{Replication of Simulation Study in \citet{Goldsmith2015}}\label{app:goldsmith}
This section describes our results of a replication of the simulation study described in Web Appendix 2 of \citet{Goldsmith2015}. We ran 20 replicates per setting. The data comes from a logit model for binary data with a functional intercept, a functional linear effect of a scalar covariate and observation-specific smooth functional random effects. The observation-specific smooth functional random effects $b_i(t)$ are drawn using 2 trigonometric functional principal component functions, the functional intercept $\beta_0(t)$ is a trigonometric function as well and the functional coefficient function $\beta_1(t)$ associated with a $N(0, 25)$-distributed scalar covariate $x$ is a scaled normal density function, see \citet[][Web Appendix, Section 2]{Goldsmith2015} for details. Note that \code{genfpca}, the \pkg{rstan} \citep{rstan} implementation provided by Goldsmith et al., uses the same number of FPCs (i.e, two) for the fit as used for generating the data, while our \code{pffr}-implementation uses 10 cubic B-spline basis functions to represent each $b_i(t)$.
The model and data generating process are thus $P(y_i(t_l)=1) = \text{logit}^{-1}\left(\eta_i(t)\right)$ with $\eta_i(t) = \beta_0(t_l) + \beta_1(t_l)x_i + b_i(t_l)$; $i=1, \dots,n; l=1, \dots, T.$
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/goldsmith_rmse-1}
}
\caption{Replication of \citet{Goldsmith2015}: RIMSE for the estimated effects and the additive predictor. Top: functional intercept; 2nd row: functional coefficient; 3rd row: functional random effects; bottom: sum of the three. Each graph shows results for $n=50, 100$ (rows) and $T=50, 100$ (columns). Upper boxplots for \code{pffr}, lower for \code{genfpca}.}\label{fig:goldsmith_rmse}
\end{figure}
\end{knitrout}
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/goldsmith_cicover-1}
}
\caption{Replication of \citet{Goldsmith2015}: Observed CI coverage for $\eta_i(t) = \operatorname{logit}\left(\beta_0(t)+ \beta_1(t)x_i + b_i(t)\right)$ for $n=50, 100$ (rows) and $T=50, 100$. Upper boxplots for \code{pffr}, lower for \code{genfpca}. Vertical fat gray line denotes nominal 95\% coverage.}\label{fig:goldsmith_cicover}
\end{figure}
\end{knitrout}
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/goldsmith_comptimes-1}
}
\caption{Replication of \citet{Goldsmith2015}: Computation times for $n=50, 100$ (rows) and $T=50, 100$ (columns). Upper boxplots for \code{pffr}, lower for \code{genfpca}. Horizontal axis on $\log_{10}$-scale.}\label{fig:goldsmith_comptimes}
\end{figure}
\end{knitrout}
Figure \ref{fig:goldsmith_rmse} shows RIMSE for (top to bottom) the estimated functional intercept, the estimated functional coefficient, the functional random effect and the combined additive predictor. It seems that \code{pffr} yields somewhat more precise estimates for $\beta_0(t)$ in this setting, while the estimation performance of the two approaches for the functional coefficient and the random effects is broadly similar although the results for \code{pffr} for $\beta_1(t)$ show more variability.
\code{pffr} yields slightly better estimates of the total additive predictor $\eta_i(t)$ in this setting. Note that \citet{Goldsmith2015} report mean integrated square error (MISE, in their notation) while we report the RIMSE. Taking this into account, the \code{genfpca} results reported here correspond very closely to theirs.
Figure \ref{fig:goldsmith_cicover} shows observed confidence [credibility] interval (CI) coverage for nominal 95\% CIs for the two approaches evaluated over $\hat\eta_i(t)$. Both approaches mostly achieve close to nominal coverage in this setting, but while coverages for \code{pffr} are mostly greater than the nominal $95$\% for $T=50$ with some rare problematic fits with coverages below 75\%, \code{genfpca} shows small but systematic under-coverage for $T=100$. Figure \ref{fig:goldsmith_comptimes} shows computation times for the two approaches. The median computation time for \code{genfpca} is about 4 times that of \code{pffr} for $n=50$, and $0.80$ to $0.94$ that of \code{pffr} for $n=100$.
In summary, our replication shows that \code{pffr} achieves mostly similar estimation accuracies and coverages in much shorter time or roughly the same time for a data generating process tailored specifically to \code{genfpca}'s strengths.
\subsection{Replication of Simulation Study in \citet{WangShi2014}}\label{app:wang}
This section describes our results of a replication of the simulation study described in Section 4.1 of \citet{WangShi2014}. We ran 20 replicates per setting.
The data comes from a logit model for binary data with just a functional intercept and observation-specific smooth functional random effects. The observation-specific smooth functional random effects $b_i(t)$ are realizations of a Gaussian process with ``squared exponential'' covariance structure,
the functional intercept $\beta_0(t)$ is a cubed sine-function, see \citet[their Section 4.1.]{WangShi2014} for details.
The model and data generating process are thus $P(y_i(t_l)=1) = \text{logit}^{-1}\left(\eta_i(t)\right)$ with $\eta_i(t) = \beta_0(t_l) + b_i(t_l)$; $i=1, \dots,n; l=1, \dots, T.$
Note that Wang \& Shi's MATLAB \citep{MATLAB} implementation of their proposal (denoted by \code{ggpfr}) uses the same ``squared exponential'' covariance structure for fitting as that used for generating the data, while our \code{pffr}-implementation uses a B-spline basis (8 basis functions per subject) to represent the $b_i(t)$. We used the same basis dimension for $\beta_0(t)$ for \code{ggpfr} as Wang \& Shi.
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/wang_rmse-1}
}
\caption{Replication of \citet{WangShi2014}: RIMSE for the estimated effects and the additive predictor. Top: functional intercept; middle: functional random effects; bottom: sum of the two. Each graph shows results for $n=30, 60$ (rows) and $T=21, 41, 61$ (columns). Upper boxplots for \code{pffr}, lower for \code{ggpfr}.}\label{fig:wang_rmse}
\end{figure}
\end{knitrout}
Boxplots in Figure \ref{fig:wang_rmse} show RIMSEs for the estimated effects and the additive predictor for each of the 20 replicates per combination of settings. While \code{ggpfr} tends to yield more precise estimates for $b_i(t)$,
it often does not do as well as \code{pffr} in estimating the functional intercept.
As a consequence, the two approaches yield very similar errors for $\eta_i(t)$, even though the data generating process is tailored towards \code{ggpfr} and more adversarial for \code{pffr}.
Note that we were not able to reproduce the mean RIMSE values for logit$(\eta(t))$ reported by \citet{WangShi2014} despite the authors' generous support. Our mean RIMSE results for \code{ggpfr} were $0.37, 0.33, 0.30$ while \citet{WangShi2014} reported $0.32, 0.26, 0.24$ for $n=60; T=21, 41, 61$, respectively.
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/wang_cicover-1}
}
\caption{Replication of \citet{WangShi2014}: Observed CI coverage for $\eta(t) = \operatorname{logit}\left(\beta_0(t)+ b_i(t)\right)$ for $n=30, 60$ (rows) and $T=21, 41, 61$. Upper boxplots for \code{pffr}, lower for \code{ggpfr}. Vertical fat gray line denotes nominal 90\% coverage.}\label{fig:wang_cicover}
\end{figure}
\end{knitrout}
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/wang_comptimes-1}
}
\caption{Replication of \citet{WangShi2014}: Computation times for $n=30, 60$ (rows) and $T=21, 41, 61$ (columns). Upper boxplots for \code{pffr}, lower for \code{ggpfr}. Horizontal axis on $\log_{10}$-scale.}\label{fig:wang_comptimes}
\end{figure}
\end{knitrout}
Figure \ref{fig:wang_cicover} shows observed CI coverage for nominal 90\% CIs for the two approaches evaluated over $\hat\eta_i(t)$. Both approaches mostly do not achieve nominal coverage for these very small data sets, but coverages for \code{pffr} converge towards the nominal level much faster as $n$ and $T$ increase than those for \code{ggpfr} and show fewer and smaller incidences of severe under-coverage.
Figure \ref{fig:wang_comptimes} shows computation times for the two approaches.
The median computation time for \code{ggpfr} is about three times that of \code{pffr} for $T=21$, which increases to a factor of 13-19 for $n=60; T=41, 61$ and a factor of 40-48 for $n=30; T=41, 61$\footnote{Note that these computation times seem to be extremely sensitive towards different MATLAB versions -- in personal communication, Bo Wang reported average computation times of 3 minutes for $T=21, N=60$ (our result for \code{ggpfr}: $\approx 19$), 4 minutes for $T=41, N=30$ (our result: $\approx 200$) and 10 minutes for $T=61, N=60$ (our result: $\approx 540$) for a single run using MATLAB 7.4 on an Intel Core Duo CPU (2.53GHz, 3GB RAM) instead of MATLAB 7.12 which we used.}. Note that computation times for \code{ggpfr} are given for a single run using a pre-specified number of basis functions for estimating $\beta_0(t)$ here. But since the BIC-based selection of the basis dimension proposed by \citet{WangShi2014} requires $k$ runs for selecting between $k$ candidate numbers of basis functions, actual computation times for \code{ggpfr} in practical applications will increase roughly $k$-fold.
Our replication shows that \code{pffr} achieves mostly similar estimation accuracies with better CI coverage for a data generating process tailored specifically to \code{ggpfr}'s strengths. Depending on the MATLAB version that is used, \code{pffr} does so in similar or much, much shorter time.
\section{PIGWISE Model: Alternatives and Criticism\label{app:alternative-models}}
\begin{figure}
\begin{center}
\includegraphics[width=.8\textwidth]{figure/piggyplot.png}
\end{center}
\caption[Observed feeding episodes for pig 57]{Observed feeding episodes for pig 57. Horizontal axis gives time of day, vertical axis represents days. Black dots show observed feeding episodes as measured by proximity to the trough (yes-no).}\label{fig:piggyplot1}
\end{figure}
This section shows the raw data used for the PIGWISE application (Figure~\ref{fig:piggyplot1}) and compares the result of a different model specification to that of the main article.
Beyond the smoothly varying functional day effects used in the analysis in Section
\ref{sec:app-model}, we considered two alternative random effect spe\-ci\-fi\-cations:
auto-correlated functional random day effects with a marginal $AR(1)$-structure with
auto-correlation 0.8 over the days as well as $\iid$ random day effects $b_i(t)$. We also considered models with no day effects at all.
Beyond the 3h-cumulative auto-regressive effect of previous feeding used in the analysis in Section \ref{sec:app-model}, we also fit models with a 6h-cumulative auto-regressive effect
($\int^{t-10\text{min}}_{t-6\text{h}} y_i(s) \beta(t,s)ds$) as well as non-linear time-constant auto-regressive effects ($f(y_i(t-10\text{min}))$) and time-varying ($f(y_i(t-10\text{min}), t)$). We also considered models with no auto-regressive effects at all.
To model possible effects of humidity and temperature, we considered additive non-linear time-varying ($f(\text{hum}(t), t) + f(\text{temp}(t), t)$) and
time-constant ($f(\text{hum}(t)) + f(\text{temp}(t))$) concurrent effects, as well as
corresponding concurrent interaction effects $f(\text{hum}(t), \text{temp}(t))$ and $f(\text{hum}(t), \text{temp}(t), t)$, respectively. We also considered models with no
effects of humidity and/or temperature at all.
We estimated models for all 100 combinations (4 day effects, 5 auto-regressive effects, 5 humidity/temperature effects) of the different effect specifications given above. As in the main analysis, we excluded every third day from the training sample to serve as a validation set. Analysis of mean Brier scores achieved on the training data showed that all 100 models fit the training data similarly well, with slightly better fits for models with $\iid$ or $AR(1)$ functional random effects compared to models with no day effects or a smooth day effect.
Analysis of mean Brier scores on the validation data, however, showed that only very small differences in predictive accuracy between models with a smooth day effect and no day effects at all exist and also revealed a strong decrease in predictive performance for models with humidity-temperature effects, especially in combination with cumulative auto-regressive effects.
All in all, the majority of models performed worse in terms of predictive Brier score than a simple functional intercept model $y_i(t) \sim B(60, \text{logit}^{-1}(\beta_0(t)))$, which had a mean predictive Brier score of 0.026, compared to a mean predictive Brier score of 0.029 for the $\iid$ functional random intercept model discussed below and a mean predictive Brier score of 0.024 of a model like the one discussed in Section \ref{sec:app-res} with a smoothly varying day effect better suited for generating interpolating predictions for missing days instead of functional random day effects, which are constant 0 for days in the test set. We conclude that overfitting of complex effects could be a serious concern for the model class we propose, as shown by the large differences in Brier scores between training and validation data for many of the models with complicated effect structures. Note, however, that even though the $\iid$ random effect model yields inferior predictions, it may be better suited for estimating explanatory and interpretable models than the one discussed in Section \ref{sec:app-model}, as the larger flexibility of the $\iid$ functional random day effects is presumably more effective at modeling the peaky and irregular temporal dependencies in the observations than a smoothly varying aging effect.
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/plot_m62_fit-1}
}
\caption{Fitted (top) and predicted (bottom) values for pig 57 for selected days for an alternative model specification with $\iid$ functional random day effects instead of a smooth aging effect. Black lines for fitted (top) and predicted (bottom) values $\hat\mu_i(t)$, red for observed feeding rate $y_i(t)/60$. Numbers above each panel give the day. Vertical axis on $\sqrt{\;}$-scale.}\label{fig:plot_m62_fit}
\end{figure}
\end{knitrout}
We present detailed results for an alternative model specification with $\iid$ functional random day effects $b_i(t)$ instead of a smooth aging effect $f(i, t)$ below. Figure \ref{fig:plot_m62_fit} shows fitted and observed values for 12 selected days from the training data (top) as well as predicted and observed values for 12 selected days from the validation data (bottom). It is easy to see that the model is able to reproduce many of the feeding episodes in the training data, in the sense that peaks in the estimated probability curves mostly line up well with observed spikes of $y_i(t)$. This model explains about 41\% of the deviance and achieves a Brier score of about 0.019 taking the mean over all days and time-points. Prediction (lower panel) with this model is more challenging (Brier score: 0.029), and succeeds only partially. For example, while the predictions for day 73 are mostly very good, predictions for the evening hours of day 11 or around noon on day 82 are far off the mark. Note, however, that $\hat b_i(t) \equiv 0$ for the validation data, as $E(b_i(t)) \equiv 0 \,\forall\, t, i.$ Models that include a smooth day effect $f(i, t)$ instead, which can be interpolated for the days in the calibration data, are more successful at prediction, see Section \ref{sec:app-res}.
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/plot_m62_coef-1}
}
\caption[Estimated effects for an alternative model specification with ]{Estimated effects for an alternative model specification with $\iid$ functional random day effects instead of a smooth aging effect. Top row: Estimated functional intercept and functional random day effects. Bottom row: Estimated coefficient surface for cumulative auto-regressive effect. Intervals are $\pm$ 2 standard errors. Vertical axis for functional random day effects is truncated at $-10$ to show structure of typical results.}\label{fig:plot_m62_coef}
\end{figure}
\end{knitrout}
Figure \ref{fig:plot_m62_coef} shows the estimated components of the additive predictor for this alternative model specification.
The functional intercept in the top left panel of Figure \ref{fig:plot_m62_coef}
is fairly similar in shape to Figure \ref{fig:plot_m64_coef}, but overall the base rate is estimated to be much higher and the peak before 6h is much less pronounced.
Estimated random day effects are shown in the top right panel of Figure \ref{fig:plot_m62_coef}. In terms of absolute size, these are much larger than the values of the smooth aging effect depicted in Figure \ref{fig:plot_m64_coef}. Effect sizes for $b_i(t)$ are often unrealistically large, with some estimates going as low as -20 (-20 on the logit scale corresponds to a reduction of the probability by a factor of about $2 \cdot 10^{-9}$), presumably an artifact of the very low feeding activity between midnight and early morning leading to (quasi-)complete separability of the data. The vertical axis in Figure \ref{fig:plot_m62_coef} is cut off at $-10$ in order to showcase the typical ``peaky'' structure of the $\hat b_i(t)$ which would otherwise be hidden by the larger vertical axis required to show the $12$ random intercept functions reaching minimal values below $-10$ in their entirety.
The cumulative auto-regressive effect of feeding during the previous 3 hours displayed in the bottom row of Figure \ref{fig:plot_m62_coef} is quite similar to the estimate for the original model shown in Figure \ref{fig:plot_m64_coef} but with a weaker positive association between feeding in the immediate past and current feeding and a stronger negative association for feeding episodes in the early morning hours.
\section{Additional Simulation Details}
Section \ref{app:ex-families} provides some more details on the data generating process used in Section \ref{sec:sim-families} and shows some typical effect estimates in these settings.
\input{gfamm_ex_binomial.tex}
\input{appendix_ex_families.tex}
\subsection{Computational Details}
Code to reproduce results for Section 4 is included in a code supplement.\\
Results described here were computed on various Linux PCs and servers under \textsf{R-3.2.3} to \textsf{3.2.5} with \textsf{mgcv 1.8-5} to \textsf{1.8-7}, \textsf{refundDevel 0.1-11} to \textsf{0.1-15}.
\setcounter{figure}{0}
\input{gfamm_app_data.tex}
\section{Application to Pigs' Feeding Behavior}\label{sec:app}
\subsection{Data}\label{sec:app-data}
We use data on pigs' feeding behavior collected in the ICT-AGRI era-net project
``PIGWISE'', funded by the European Union. In this project, high frequency radio frequency identification (HF RFID) antennas were
installed above the troughs of pig barns to register the feeding times of pigs
equipped with passive RFID tags \citep{Maselyne2014}.
We are interested in modelling the binary functional data that arises from measuring
the proximity of the pig to the trough (yes-no) every 10 secs over 102 days available
for each pig. The raw data for one such pig, called `pig 57' whose behavior we analyse in depth is shown in Figure~\ref{fig:piggyplot1} in Appendix \ref{app:alternative-models}.
Such models of (a proxy of) individual feeding behavior can be useful for ethology research as well as monitoring individual pigs' health status and/or quality of the available feed stock, c.f. \citet{Gertheiss2014}. Available covariates include the time of day, the age of the pig (i.e, the day of observation), as well as the barn's temperature and humidity.
\subsection{Model}\label{sec:app-model}
Due to pronounced differences in feeding behavior between individual pigs \citep[c.f. ][Figure 4]{Gertheiss2014}, we focus on pig-wise models and model the observed feeding rate for a single pig for each day $i=1,\dots,102$ as a smooth function over the daytime $t$.
For our model, we aggregate the originally observed binary feeding indicators
$\tilde y_i(t)$, which are measured every 10 seconds, over 10 min intervals into
$y_i(t)$. This temporal resolution is sufficient for the purposes of our modeling
effort. We then model
\begin{align*}
y_i(t) |\mathcal{X}_i &\sim \text{Bin}(60, \pi=\mu_i(t));\\
\mu_i(t) &= \text{logit}^{-1}\left(\sum_{r=1}^R f_r(\mathcal{X}_{ri},t)\right).
\end{align*}
As is typical for applied problems such as this, many different distributional
assumptions for $y_i(t) |\mathcal{X}_i$ and specifications of $\sum_{r=1}^R f_r(\mathcal{X}_{ri},t)$
are conceivable. In this case, both Beta and Negative Binomial distributions
yielded less plausible and more unstable fits than the Binomial distribution. With
respect to the additive predictor, the effect of temperature or humidity (i.e.,
$\mathcal{X}_{ri} = \texttt{hum}_i(t)$), for example, could be modeled as a linear functional
effect $\int^{u(t)}_{l(t)} \texttt{hum}(s) \beta(s,t) ds$, which represents the cumulative
effect of humidity exposure over the time window $l(t) \leq t \leq u(t)$, or the concurrent
effect of humidity, either linearly via $\texttt{hum}(t)\beta_h(t)$ or non-linearly via
$f(\texttt{hum}(t), t)$. Auto-regressive and lagged effects of previous feeding behavior
(i.e., $\mathcal{X}_{ri} = y_i(t)$) could be modeled similarly either as the cumulative effect
of previous feeding over a certain time window ($\int^{t-10\text{min}}_{t-\delta} y(s) \beta(s,t) ds$)
or nonlinear ($f(y_i(t-\delta), t)$) or linear ($y_i(t-\delta)\beta(t)$)
effects of the lagged responses with a pre-specified time lag $\delta$. Finally,
our implementation also offers diverse possibilities for accounting for aging effects
and day-to-day variations in behavior (i.e., $\mathcal{X}_{ri} = i$). Aging effects that result
in a gradual change of daily feeding rates over time could be represented as
$i \beta(t)$ for a gradual linear change or as $f(i, t)$ for a nonlinear smooth change over days $i$. Less systematic day-to-day variations can be modeled as daily
functional random intercepts $b_i(t)$, potentially auto-correlated over $i$ to
encourage similar shapes for neighboring days. In this application, the performances of most of these models on the validation set were fairly similar and the subsequent section presents results for a methodologically interesting model that was among the most accurate models on the validation set.
\subsection{Results}\label{sec:app-res}
In what follows, we present detailed results for an auto-regressive binomial logit
model with smoothly varying day effects for pig 57 (see Figure~\ref{fig:piggyplot1}, Appendix \ref{app:alternative-models}):
$$\text{logit}\left(\mu_i(t)\right) = \beta_0(t) + f(i, t) + \int^{t-10\text{min}}_{t-3\text{h}} y_i(s) \beta(t,s)ds.$$
This model assumes that feeding behavior during the previous 3 hours affects the
current feeding rate. We use periodic P-spline bases over $t$ to enforce similar $f_r(\mathcal{X}_{ri}, t)$
for $t=$00:00h and $t=$23:59h for all $r.$ The term $f(i,t)$ can be interpreted
as a non-linear aging effect on the feeding rates or as a functional random day effect
whose shapes vary smoothly across days $i$. This model contains $\operatorname{dim}(\bm{\lambda}) = 5$
smoothing parameters (1 for the functional intercept, 2 each for the daily and auto-regressive effects),
$\operatorname{dim}(\bm{\theta}) = 106$ spline coefficients (24 for the intercept,
25 for the autoregressive effect, 56 for the day effect) and $N = nT = 9648$ observations
in the training data. We leave out every third day to serve as external validation data for evaluating the generalizability of the model. The fit takes about 1 minute on a modern desktop PC. Appendix~\ref{app:alternative-models} contains detailed results for an alternative model specification, Section~\ref{sec:sim-binomial} describes results for synthetic data with similar structure and size.
Beside giving insight into pigs' feeding patterns and how these patterns change as the pigs age, the model reported here enables short-term predictions of feeding probabilities for a given pig based on its previous feeding behavior. This could be very helpful when using the RFID system for surveillance and early identification of pigs showing unusual feeding behavior. Unusual feeding behavior is then indicated by model predictions that are consistently wrong; i.e, the pig is not behaving as expected.
Such discrepancies can then indicate problems such as disease or low-quality feed stock. For the auto-regressive model discussed here, only very short-term predictions 10 minutes into the future can be generated easily as $y_i(t-10\text{min})$ is required as a covariate value. Other model formulations without such auto-regressive terms or larger lead times of auto-regressive terms will allow more long-term forecasting. More long-term forecasts for auto-regressive models could also be achieved by using predictions $\hat y_i(t)$ instead of observed values of $y_i(t)$ as inputs for the forecast. These can be generated sequentially for timepoints farther and farther in the future, but errors and uncertainties will accumulate correspondingly. A detailed analysis of this issue is beyond the scope of this paper, \citet{Tashman2000} gives an overview. In addition to the lagged response value, also the aging effect $f(i,t)$ is needed. Here, we could either use the value from the preceding day $i-1$, if it can be assumed that the pig's (expected) behavior does not change substantially from one day to the next; or do some extrapolation.
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/plot_m64_fit-1}
}
\caption{Training (top) and validation data (bottom) results for pig 57 for selected days with a smoothly varying day effect. Black lines for fitted (top) and predicted (bottom) values $\hat\mu_i(t)$, red for observed feeding rate $y_i(t)/60$. Numbers above each panel denote the day. Vertical axis on $\sqrt{\;}$-scale.}\label{fig:plot_m64_fit}
\end{figure}
\end{knitrout}
Figure~\ref{fig:plot_m64_fit} shows fitted and observed values for 12 selected days
from the training data (top) as well as estimated and observed values for 12 selected
days from the validation data (bottom). The model is able to reproduce many of the
feeding episodes, in the sense that peaks in the estimated probability curves mostly
line up well with observed spikes of $y_i(t)$. This model explains about 24\% of the
deviance and, taking the mean over all days and time-points, achieves a Brier score of
about 0.024 on both the training data and the validation data,
i.e., we see no evidence for overfitting with this model specification.
This model performs somewhat better on the validation data than an alternative model
specification with $\iid$ random functional day effects $b_i(t)$, c.f.~Appendix~\ref{app:alternative-models}, Figure~\ref{fig:plot_m62_fit}.
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/plot_m64_coef-1}
}
\caption[Top row]{Top row: Estimated functional intercept and smoothly varying day effects for the model with smoothly varying day effect.\\ Bottom: Estimated coefficient surface for cumulative auto-regressive effect. Point-wise intervals are $\pm$ 2 standard errors.}\label{fig:plot_m64_coef}
\end{figure}
\end{knitrout}
Figure~\ref{fig:plot_m64_coef} shows the estimated components of the additive predictor for the model with smoothly varying day effects.
The functional intercept in the left top panel of Figure~\ref{fig:plot_m64_coef} shows two clear peaks of the feeding rate around 10h and 18h, and very low feeding activity from 19h to 23h and from 2h to 6h. A two-peak profile has been identified previously as the typical feeding behavior of pigs \citep{Montgomery1978, Guillemet2006}.
Our analysis exploiting the rich information provided by the new RFID antennas used \citep{Maselyne2014}, however, gives pig-specific results, whereas previous studies typically reported on group characteristics; see, e.g., \citet{Hyun1997} and \citet{Guillemet2006}. Furthermore, existing results usually aggregated over time periods.
The estimated smoothly varying day effect (top right panel) shows increased feeding
rates in the early morning in the first few days and a corresponding strong reduction in feeding rates in the early morning towards the end of the fattening period, as well as a tendency for increased feeding activity to concentrate more strongly in two periods around 9h and 21h towards the end of the observation period, a pattern also visible in the raw data shown in Figure~\ref{fig:piggyplot1} (Appendix \ref{app:alternative-models}). The cumulative auto-regressive
effect of feeding during the previous 3 hours is displayed in the bottom row of Figure~\ref{fig:plot_m64_coef}.
Unsurprisingly, feeding behavior in the immediate past is associated positively
with current feeding (c.f.~the blue region for $s-t \approx 0$), especially during off-peak times in the early morning where a higher propensity for feeding is not already modeled by the global functional intercept.
The model also finds a negative association between prior feeding during the night and
feeding in the very early hours of the morning that takes place 1 to 3 hours later (c.f.~the red region around $t=0$). Confidence intervals for all three effects show that they can be estimated fairly precisely.
\section{Discussion}\label{sec:discuss}
This work introduces a comprehensive framework for generalized additive mixed models (GAMM) for non-Gaussian functional responses. Our implementation extends all the flexibility of GAMMs for dependent scalar responses to dependent functional responses and functional covariates, even for response distributions outside the exponential family such as robust models based on the $t$-distribution. Dependency structures can be spatial, temporal or hierarchical. Simulation and application results show that our approach provides reliable and precise inference about the underlying latent processes.
The work presented here opens up promising new avenues of inquiry -- one challenge that we have already begun to work on is to improve the speed and memory efficiency of the underlying computational engine to be able to fit the huge data sets increasingly common in functional data analysis. Along these lines, more efficient computation of simultaneous instead of pointwise confidence intervals for functional effects as well as a more detailed investigation of the performance of the available approximate pointwise confidence intervals for noisy and small non-Gaussian data is another important field of inquiry.
An extension of the approach presented here to models with multiple additive predictors controlling different aspects of the responses' distribution -- like the generalized additive models for location, scale and shape introduced for scalar response by \citet{Rigby2005} or zero-inflation and hurdle models -- is yet another promising generalization of the ideas we have presented here.
\subsection{Simulation 1: Computation times, Details and Examples}\label{app:ex_binomial}
\subsubsection{Computation times}
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/binomial-time-1}
}
\caption[Computation times for the different models]{Computation times for the different models. Time axis on $\log_2$-scale.}\label{fig:binomial-time}
\end{figure}
\end{knitrout}
Figure \ref{fig:binomial-time} shows computation times for the various settings.
Note that the times are plotted on binary log-scale. One fit for a random intercept model (\code{ri}) did not converge within 200 iterations and ran for more than 16 hours.
\subsubsection{Computational details}
We use the following (spline) bases to construct $\bm{\Phi}_{\bm x}$ for the different effects:
\begin{itemize}
\item \texttt{lag.c, lag}: 20 cubic thin plate splines over $\tilde y(t)$
\item \texttt{humtemp, humtemp.c}: 50 bivariate cubic thin plate splines over the joint space of \texttt{hum} and \texttt{temp}.
\item \texttt{day}: 8 cubic thin plate splines over $i=1, \dots ,100$.
\item \texttt{ri}: dummy variables for each curve $i=1, \dots ,100$.
\end{itemize}
The coefficient surfaces for \texttt{ff.3, ff.6} are estimated with 30 bivariate cubic thin plate splines over $\mathcal T \times \mathcal T$. The functional intercept (\texttt{int}) uses 40 cubic cyclic P-splines with first order difference penalty over $\mathcal T$, while the functional random intercepts (\texttt{ri}) use 9 of those per curve. For all other terms, we use 8 cubic P-splines with first order difference penalty for $\bm{\Phi}_{\bm t}$.
\subsubsection{Typical model fits}
Figures \ref{fig:binomial-daylag-ex} to \ref{fig:binomial-dayht-ex} show graphical summaries of typical model fits for three difficult settings of the simulated binomial data discussed in Section \ref{sec:sim-binomial}.
It is clear to see that estimating unstructured daily functional random intercepts is a harder task than estimating a smoothly varying aging effect (compare the accuracy of $\hat f(t,i)$ in Figures \ref{fig:binomial-daylag-ex} and \ref{fig:binomial-dayht-ex} to that of $\hat b_{i}(t)$ in Figure \ref{fig:binomial-riff6-ex}), and that concurrent functional nonlinear interaction effects can not be recovered very reliably in this setting. Also note that we can model very rough latent response processes $\mu_i(t)$ for these data by including, e.g., a (nonlinear) auto-regressive term as in the top left panel of Figure \ref{fig:binomial-daylag-ex}.
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/binomial-daylag-ex-1}
}
\caption{Typical model fit for setting \code{day+lag.c}: smoothly varying day effect with a nonlinear auto-regressive term. Left column shows true (dashed, red) and estimated (solid, black) conditional expectation for 12 randomly selected days in the top row and estimated and true smoothly varying day-daytime effect in the middle and bottom panels. Right column shows true and estimated global intercept (top) and true and estimated nonlinear auto-regressive effect (middle) and its true and estimated contributions to the additive predictor. For this model, rRIMSE$(\hat\eta_i(t)) = 0.05 $, about the same as the median rRIMSE for this setting.}\label{fig:binomial-daylag-ex}
\end{figure}
\end{knitrout}
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/binomial-riff6-ex-1}
}
\caption{Typical model fit for setting \code{ri+ff.6}: random functional intercepts for each day with a cumulative auto-regressive term. Left column shows true (dashed, red) and estimated (solid, black) conditional expectation (top row) and estimated and true random intercepts (middle). Right column shows true and estimated global intercept (top) and estimated (middle, top panel) and true (middle, bottom panel) coefficient surface for the cumulative auto-regressive effect and true and estimated contributions of the cumulative auto-regressive effect to the additive predictor (bottom) for 12 randomly selected days. For this model, rRIMSE$(\hat\eta(t)) = 0.2$, while the median rRIMSE for this setting is 0.19.}\label{fig:binomial-riff6-ex}
\end{figure}
\end{knitrout}
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/binomial-dayht-ex-1}
}
\caption{Typical model fit for setting \code{day+humtemp.c}: smoothly varying day effect with a time-constant concurrent nonlinear interaction effect of humidity and temperature. Left column shows true (dotted) and estimated (solid) conditional expectation (top) for 12 randomly selected days in the top row, estimated (top panel) and true (bottom panel) smoothly varying day-daytime effect (middle), and true and estimated contributions of the time-constant humidity-temperature interaction effect to the additive predictor (bottom). Right column shows true and estimated global intercept (top) and estimated (middle, top panel) and true (middle, bottom panel) effect surface for the humidity-temperature interaction. For this model, rRIMSE$(\hat\eta(t)) = 0.05$, while the median rRIMSE for this setting is 0.05.}\label{fig:binomial-dayht-ex}
\end{figure}
\end{knitrout}
\section{Introduction}
Data sets in which measurements consist of curves or images instead of scalars -- i.e., functional data -- are becoming ever more common in many areas of application. This is due to the increasing affordability and deployment of sensors like accelerometers or spectroscopes, high-throughput imaging technologies and automated logging equipment that continuously records conditions over time. Recent methodological development in this area has been rapid and intense, see \citet{Morris2015} for a review of the state of the art for regression models for functional data.
In this work, we extend the general framework for functional additive mixed models for potentially correlated functional Gaussian responses described in \citet{famm2014} to non-Gaussian functional responses. The development is motivated by and evaluated on an animal husbandry dataset in which the feeding behavior of growing-finishing pigs was monitored continuously over 3 months \citep{Maselyne2014, Gertheiss2014}.
These are non-Gaussian functional data in the sense that the underlying probability
of feeding is assumed to be a continuous function over time, while the available data are sequences of binary indicators ("feeding: yes/no") evaluated at the temporal resolution of the sensors. Aggregating these binary indicators over given time intervals, we get time series of counts or proportions for which (truncated) Poisson, Negative Binomial, Binomial or Beta distributional assumptions could be appropriate. Another example of non-Gaussian functional data with large practical relevance would be continuously valued functional responses with heavy-tailed measurement errors for which a scaled $t$-distribution could be appropriate.
We briefly summarize the most relevant prior work on regression models for non-Gaussian functional responses. The fundamental work of \citet{Hall2008} relates observed functional binary or count data to a latent Gaussian process (GP) through a link function. This is the underlying idea of almost all the works that follow. They differ primarily in 1) how the latent functional processes are represented (i.e., either spline, wavelet or functional principal component (FPC) representations or full GP models), 2) to what extent additional covariate information can be included, 3) whether they allow the modelling of dependencies between and along the functional responses, 4) which distributions are available for the responses, 5) whether the functional data has to be available on a joint regular grid, and 6) in the availability of documented and performant software implementations.
In \citet{Hall2008}, the latent GP is represented in terms of its FPCs and neither correlated responses nor covariates are accommodated. No implementation is publicly available. A Bayesian variant of \citet{Hall2008} is provided by \citet{vanDerLinde2009}. \citet{ZhuEtal2011} describe a robustified wavelet-based functional mixed model with scalar covariates for error-contaminated continuous functional responses on regular grids. No implementation was publicly available at the time of writing. \citet{SerbanStaicuCarroll2013} extend the approach of \citet{Hall2008} to multilevel binary data without covariates and provide a rudimentary problem-specific implementation. \citet{WangShi2014} describe an empirical Bayesian approach for latent Gaussian process regression models for data from exponential families with scalar and concurrent functional covariates. The available implementation does not accommodate covariate effects and is limited to binary data with curve-specific $\iid$ functional random effects, see Section \ref{app:wang} for a systematic comparison with our proposal based on a replication of their simulation study.
\citet{Lietal2014} present a model for concurrent binary and continuous functional observations. Association between the two is modeled via cross-correlated (latent) FPC scores and cannot take into account any other covariate effects or dependency structures.
A similar approach is described in \citet[][ch. 3]{Tidemann2014}. \citet{Goldsmith2015}
develop a fully Bayesian approach which uses latent FPCs in a spline basis representation to represent multilevel functional random effects and linear functional effects of scalar covariates. They provide an implementation for binary outcomes with a logit link function, see Section \ref{app:goldsmith} for a systematic comparison with our proposal based on a replication of their simulation study.
\citet{Gertheiss2014} describe a marginal GEE-type approach for correlated binary functional responses with concurrent functional covariates. \citet{Brockhaus2015} develop a framework for estimating flexible functional regression models via boosting with similar flexibility as ours, implemented in R \citep{R} package \pkg{FDboost} \citep{fdboost}. The package additionally implements functional quantile regression models, which are not included in the framework we present here. Since their implementation is based on a component-wise gradient boosting algorithm, they cannot provide hypothesis tests or resampling-free construction of confidence intervals, however, and also have to rely on computationally intensive resampling methods for hyperparameter tuning.
Compared to previous work, the novel contribution of this work is the development, implementation and evaluation of a comprehensive maximum likelihood-based inferential framework for generalized functional additive mixed models (GFAMMs) for potentially correlated functional responses. Our proposal accommodates diverse latent-scale correlation structures as well as flexible modeling of the conditional mean structure with multiple linear and non-linear effects of both scalar and functional covariates and their interactions. Our proposal is implemented in the full generality described here for both regular grid data and sparse or irregularly observed functional responses in the \code{pffr} function in R package \pkg{refund} \citep{refund}. Available response distributions include all exponential family distributions as well as Beta, scaled and shifted t-, Negative Binomial, Tweedie and zero-inflated Poisson distributions, each with various link functions, as well as cumulative threshold models for ordered categorical responses. With the exception of \citet{Brockhaus2015}, none of the previous proposals in this area achieve anything close to this level of generality, not to mention offer publicly available, widely applicable open-source implementations.
Since our framework is a natural extension of previous work done on generalized additive mixed models for scalar data and builds on the high performing, flexible implementations available for them, we can directly make use of many results from this literature, such as improved confidence intervals and tests for smooth effects \citep{MarraWood2012, Wood2013}.
The remainder of this work is structured as follows: Section \ref{sec:model} introduces notation and the theoretical and inferential framework for our model class. Section \ref{sec:app} presents results for our application. Section \ref{sec:sim} summarizes results of our extensive validation on synthetic data and of our partial replication of the simulation studies of \citet{WangShi2014} and \citet{Goldsmith2015}. Section \ref{sec:discuss} concludes.
\section*{Acknowledgements}
Sonja Greven and Fabian Scheipl were funded by Emmy Noether grant GR 3793/1-1 from the German Research Foundation. We appreciate Engel Hessel's permission to use the PIGWISE data collected in the framework of the ICT-AGRI era-net project PIGWISE ``Optimizing performance and welfare of fattening pigs using High Frequent Radio Frequency Identification (HF RFID) and synergistic control on individual level'' (Call for transnational research projects 2010). We are grateful for Bo Wang's patient and generous support for our attempt to reproduce the \code{ggpfr} results. We are indebted to the associate editor and three anonymous reviewers whose constructive remarks helped to improve the manuscript.
\section{Model} \label{sec:model}
\subsection{Model Structure}
In what follows, we discuss structured additive regression models of the general form
\begin{align}
\begin{split}
y_i(t) &\sim \mathcal{F}(\mu_i(t), \bm{\nu})\\
g(\mu_i(t)) &= \eta_{i}(t) = \sum^R_{r=1} f_r(\mathcal{X}_{ri}, t),
\end{split}
\label{eq:fdmodel}
\end{align}
where, for each $t$, \mbox{$y_i(t), i=1,\dots,n,$} is a random variable
from some distribution $\mathcal{F}$ with conditional expectation
\mbox{$E(y_i(t)|\mathcal{X}_{i}, t, \bm{\nu}) = \mu_i(t)$} observed over a domain
$\mathcal{T}$ and an optional vector of nuisance parameters $\bm{\nu}$. We use
$g(\cdot)$ to denote the known link function. Our implementation allows analysts
to choose $\mathcal{F}$ from the exponential family distributions as well as
Tweedie, Negative Binomial, Beta, ordered categorical, zero-inflated Poisson and
scaled and shifted $t$-distributions.
Note that, in the special case of ordered categorical responses, $\mu_i(t)$ is not the conditional mean of the response itself, but that of a latent variable whose value determines the response category.
Each term in the additive predictor is a function of a) the index $t$ of the
response and b) a subset $\mathcal{X}_r$ of the complete covariate set
$\mathcal{X}$ potentially including scalar and functional covariates and
(partially) nested or crossed grouping factors. Note that the
definition also includes functional random effects $b_{g}(t)$ for a grouping
variable $g$ with $M$ levels. These are modeled as realizations of a mean-zero
Gaussian random process on $\{1,\dots,M\} \times \mathcal{T}$ with a general
covariance function \mbox{$K^{b}(m,m',t,t') = \operatorname{Cov}(b_{g,m}(t), b_{g,m'}(t'))$}
that is smooth in $t$, where $m, m'$ denote different levels of $g$. Table
\ref{tab.effects} shows how a selection of the most frequently used effect types
fit into this framework.
We approximate each term $f_r(\mathcal{X}_r, t)$ by a linear combination of basis
functions given by the tensor product of marginal bases for $\mathcal{X}_r$ and
$t$. Since the basis has to be rich enough to ensure sufficient flexibility,
Section \ref{sec:inference} describes a penalized likelihood approach that
stabilizes estimates by suppressing variability of the effects that is not strongly supported by the data and finds a data-driven compromise between goodness of fit and simplicity of the fitted effects.
\begin{table}[!ht]\centering
\caption{A selection of possible model terms $f_r(\mathcal{X}_r, t)$ for model \eqref{eq:fdmodel}. All effects can be constant in $t$ as well.
\label{tab.effects}}
\begin{small}
\begin{tabular}{p{.33\textwidth} p{.3\textwidth} p{.2\textwidth}}
\toprule[0.09 em]
$\mathcal{X}_r$ & type of effect & $f_r(\mathcal{X}_r, t)$ \\
\hline
$\emptyset$ (none) & smooth intercept & $\beta_0(t)$ \\%[0.5em]
scalar covariate $z$ & linear or smooth effect & $z \beta(t)$, $f(z, t)$ \\%[0.5em]
two scalars $z_1$, $z_2$ & linear or smooth interaction & $z_1 z_2 \beta(t)$, $z_1 f(z_2,t)$, $f(z_1, z_2, t)$\\
\hline
functional covariate $x(s)$ & linear or smooth (historical) functional effect & $\int x(s) \beta(s,t)ds$, $\int_{l(t)}^{u(t)} x(s) \beta(s,t)ds,$ $\int F(x(s), s, t) ds$ \\
functional covariate $v(t)$ & concurrent effects & $v(t)\beta(t)$, $f(v(t), t)$ \\
functional covariates $v(t), w(t)$ & concurrent interactions & $v(t)w(t)\beta(t)$, $f(v(t), w(t), t)$ \\
\hlin
grouping variable $g$ & functional random intercept & $b_g(t)$ \\[0.5em]
grouping variable $g$, scalar $z$ & functional random slope & $z b_{g}(t)$ \\%[0.5em]
\hline
curve indicator $i$ & smooth functional residual & $e_i(t)$ \\
\bottomrule[0.09 em]
\end{tabular}
\end{small}
\end{table}
\subsection{Data and Notation}
In practice, functional responses $y_i(t)$ are observed on a grid of $T_{i}$
points \linebreak \mbox{$\bm{t}_{\bm{i}}=(t_{i1}, \dots,t_{iT_{i}})^\top$} which can be irregular
and/or sparse. Let $y_{il}=y_i(t_l)$ and \mbox{$\bm{y}_{i} = (y_{i1},\dots,y_{i{T_i}}).$}
To fit the model, we form \mbox{$\bm{y} = (\bm{y}_{1}^\top, \dots, \bm{y}_{n}^\top)^\top$} and
\linebreak\mbox{$\bm{t} = (\bm{t}_{1}^\top, \dots, \bm{t}_{n}^\top)^\top$,} two $N=\sum^n_{i=1} T_i$-vectors that
contain the concatenated observed responses and their argument values, respectively.
Let $\bm{\mathcal{X}}_{\bm{r}i}$ contain the observed values of
$\mathcal{X}_r$ associated with a given $\bm{y}_i$. Model \eqref{eq:fdmodel} can
then be expressed as
\begin{equation}
\label{eq:ammodel}
\begin{split}
y_{il} &\sim \mathcal{F}(\mu_{il}, \bm{\nu})\\
g(\mu_{il}) &= \sum^R_{r=1} f_r(\bm{\mathcal{X}}_{\bm{r}i}, t_{il})
\end{split}
\end{equation}
for $i= 1, \dots, n$ and $l=1, \dots, T_i$. Let $f(\bm{t})$ denote the vector of
function evaluations of $f$ for each entry in the vector $\bm{t}$ and let $f(\bm{x},
\bm{t})$ denote the vector of evaluations of $f$ for each combination of rows in
the vectors or matrices $\bm{x}, \bm{t}$.
In the following, we let $T_i \equiv T$ to simplify notation, but our approach
is equally suited to data on irregular grids. For regular grids, each
observed value in any $\mathcal{X}_r$ that is constant over $t$ is simply repeated $T$ times
to match up with the corresponding entry in the $N=nT$-vector $\bm{y}$.
\subsection{Tensor product representation of effects}\label{sec:tensorrep}
We approximate each term $f_r(\mathcal{X}_r, t)$ by a linear combination of basis functions defined on the product space of the two spaces: one for the covariates in $\mathcal{X}_r$ and one over $\mathcal T$, where each marginal basis is
associated with a corresponding marginal penalty. A very versatile method to
construct basis function evaluations on such a joint space is given by the row
tensor product of marginal bases evaluated on $\bm{\mathcal{X}_r}$ and $\bm{t}$
\citep[e.g.][ch.~4.1.8]{Wood2006}. Let $\bm{1}_d=(1,\dots,1)^\top$ denote a
$d$-vector of ones. The row tensor product of an $m \times a$ matrix $\bm{A}$ and
an $m \times b$ matrix $\bm{B}$ is defined as the $m\times ab$ matrix $\bm{A} \odot
\bm{B} = (\bm{A} \otimes \bm{1}_b^\top) \cdot (\bm{1}_a^\top \otimes \bm{B} )$, where $\otimes$ denotes the Kronecker product and $\cdot$ denotes element-wise multiplication. Specifically, for each of the terms,
\begin{align}
\dimm{f_r(\boldsymbol{\mathcal{X}_r}, \bm{t})}{N \times 1} &\approx
\dimm{(\bm{\Phi}_{\bm{x}r}}{N
\times K_{xr}} \odot \dimm{\bm{\Phi}_{\bm{t}r})}{N \times K_{tr}}
\dimm{\bm{\theta}_r}{K_{xr} K_{tr} \times 1} = \bm{\Phi}_r \bm{\theta}_r,
\label{eq:tensorrep}
\end{align}
where $\bm{\Phi}_{\bm{x}r}$ contains the evaluations of a suitable marginal basis for the
covariate(s) in $\boldsymbol{\mathcal{X}_r}$ and $\bm{\Phi}_{\bm{t}r}$ contains the
evaluations of a marginal basis in $\bm{t}$ with $K_{xr}$ and $K_{tr}$ basis functions,
respectively. The shape of the function is determined by the vector of
coefficients $\bm{\theta}_r$. A corresponding penalty term can be defined using the
Kronecker sum of the marginal penalty matrices $\bm{P}_{\bm{x}r}$ and
$\bm{P}_{\bm{t}r}$ associated with each basis \citep[ch.~4.1]{Wood2006}, i.e.
\begin{align}\label{eq:tensorpen}
\begin{split}
\operatorname{pen}(\bm{\theta}_r| \lambda_{tr}, \lambda_{xr}) &=
\bm{\theta}_r^T \bm{P}_{r}(\lambda_{tr},\lambda_{xr}) \bm{\theta}_r, \\
\text{where } \bm{P}_{r}(\lambda_{tr},\lambda_{xr}) &= \lambda_{xr} \bm{P}_{\bm{x}r} \otimes
\bm{I}_{K_{tr}}+ \lambda_{tr} \bm{I}_{K_{xr}} \otimes \bm{P}_{\bm{t}r}.
\end{split}
\end{align}
$\bm{P}_{\bm{x}r}$ and $\bm{P}_{\bm{t}r}$ are known and fixed positive semi-definite penalty matrices
and $\lambda_{tr}$ and $\lambda_{xr}$ are positive smoothing parameters
controlling the trade-off between goodness of fit and the smoothness of
$f_r(\boldsymbol{\mathcal{X}_r}, \bm{t})$ in $\boldsymbol{\mathcal{X}_r}$ and
$\bm{t}$, respectively.
This approach is extremely versatile and powerful as it allows analysts to pick and
choose bases and penalties best suited to the problem at hand. Any basis and penalty
over $\mathcal T$ (for example, incorporating monotonicity or periodicity constraints)
can be combined with any basis and penalty over $\mathcal{X}_r$.
We provide some concrete examples for frequently encountered effects:
For a functional intercept $\beta_0(t)$, $\bm{\Phi}_{\bm{x}r} = \bm{1}_N$ and $\bm{P}_{\bm{x}r}=0$.
For a linear functional effect of a scalar covariate $z \beta(t)$, $\bm{\Phi}_{\bm{x}r} = \bm{z} \otimes \bm 1_T$ and $\bm{P}_{\bm{x}r}=0$, where $\bm{z} = (z_1, \dots, z_n)^T$ contains the observed values of a scalar covariate $z$.
For a smooth functional effect of a scalar covariate $f(z, t)$,
$\bm{\Phi}_{\bm{x}r}=[\phi_h(z_i)]{\smsubalign{1 &\leq i \leq n \\ 1 &\leq h \leq K_{xr}}} \otimes \bm 1_T$ and $\bm{P}_{\bm{x}r}$ is the penalty associated with the basis functions $\phi_h(z)$.
For a linear effect of a functional covariate $\int_{l(t)}^{u(t)} x(s) \beta(s,t)ds$, $$\bm{\Phi}_{\bm{x}r}= (\dimm{\bm W_s}{N \times S} \cdot \dimm{\bm X_{\phantom{.}}}{N \times S}) \dimm{\bm{\Phi}_s}{S \times K_{xr}},$$ where $\bm W_s$ contains suitable quadrature weights for the numerical integration and zeroes for combinations of $s$ and $t$ not inside the integration range $[l(t), u(t)]$. $\bm X = [x_i(s_k)]{\smsubalign{ 1&\leq i \leq n\\ 1 &\leq k \leq S}} \otimes \bm 1_T$ contains the repeated evaluations of $x(s)$ on the observed grid $(s_1, \dots, s_S)$ and $\bm{\Phi}_s = [\phi_h(s_k)]{\smsubalign{1 &\leq k \leq S \\ 1 &\leq h \leq K_{xr}}}$ the evaluations of basis functions $\phi_h(s)$ for the basis expansion of $\beta(s,t)$ over $s$.
$\bm{P}_{\bm{x}r}$ is again simply the penalty matrix associated with the basis functions $\phi_h(s)$.\\
For a functional random slope $z b_g(t)$ for a grouping factor $g$ with $K_{xr} = M$ levels,
$\bm{\Phi}_{\bm{x}r}= (\operatorname{diag}(\bm z) \bm{G}) \otimes \bm{1}_T$, where
$\bm{G} = [\delta(g_i = m)]{\smsubalign{1 &\leq i \leq n \\ 1 &\leq m \leq M}}$ is an incidence matrix mapping each observation to its group level. $\bm{P}_{\bm{x}r}$ is typically $\bm I_M$ for $\iid$ random effects,
but can also be any inverse correlation or covariance matrix defining the expected similarity of levels of $g$ with each other, defined for example via spatial or temporal correlation functions or other similarity measures defined between the levels of $g$.\\
In general, $\bm{\Phi}_{\bm{t}r}$ and $\bm{P}_{\bm{t}r}$ can be any matrix of basis function evaluations $\bm{\Phi}_{\bm{t}r} = \bm{1}_{n} \otimes [\phi_k(t_l)]{\smsubalign{1 &\leq l \leq T \\ 1 &\leq k \leq K_{tr}}}$ over $t$ with a corresponding penalty matrix. For effects that are constant over $t$, we simply use $\bm{\Phi}_{\bm{t}r} = \bm 1_N$ and $\bm{P}_{\bm{t}r} = 0$.\\
Note that for data on irregular $t$-grids, the stacking via ``$\otimes \bm{1}_T$'' in the expressions above simply has to be replaced by using a different suitable repetition pattern. \citet{famm2014} discuss tensor product representations of many additional effects available in our implementation.
As for other penalized spline models, fits are usually robust against increases in $K_{tr}$ and $K_{xr}$ once a sufficiently large number of basis functions has been chosen since it is the penalty parameters $\lambda_{tr}, \lambda_{xr}$ that control the
effective degrees of freedom of the fit, c.f.~\citet{Ruppert2002}, \citet[Ch. 4.1.7]{Wood2006}. \citet{Pya2016} describe and implement a test procedure to determine sufficiently large basis dimensions that is also applicable to our model class.
\subsection{Inference and Implementation}\label{sec:inference}
Let $\bm{\Phi} = [\bm{\Phi}_1 | \dots | \bm{\Phi}_R]$ contain the concatenated design matrices
$\bm{\Phi}_r$ associated with the different model terms and $\bm{\theta}=(\bm{\theta}_1^\top, \dots
,\bm{\theta}_R^\top)^\top$ the respective stacked coefficient vectors $\bm{\theta}_r$. Let
$\bm{\lambda} = (\lambda_{t1},\lambda_{x1}, \dots, \lambda_{tR},\lambda_{xR})$.
The penalized log-likelihood to be maximized is given by
\begin{align}
\ell_p(\bm{\theta}, \bm{\lambda}, \bm{\nu} | \bm{y}) &= \ell(\bm{\mu}, \bm{\nu}|\bm{y}) - \tfrac{1}{2}
\sum^R_{r=1} \operatorname{pen}(\bm{\theta}_r| \lambda_{tr}, \lambda_{xr})
\label{eq:jointlik}
\end{align}
where $\bm\mu = g^{-1}(\bm{\Phi} \bm{\theta})$ and $\ell(\bm{\mu}, \bm{\nu}|\bm{y}) = \sum^n_{i=1}\sum^{T_i}_{l=1} \ell(\mu_{il}, \bm{\nu} | y_{il})$ is the log-likelihood function implied by the respective response distribution
$\mathcal{F}(\mu_{il},\bm\nu)$ given in \eqref{eq:ammodel}.
Recent results indicate that REML-based inference for this class of penalized regression models can be preferable to GCV-based optimization \citep[][Section 4]{ReissOgden2009, Wood2011}. \citet{Wood2014} describes a numerically stable implementation for directly optimizing a Laplace-approximate marginal likelihood of the smoothing parameters $\bm{\lambda}$ which we summarize below. Note that this is equivalent to REML optimization in the Gaussian response case. The idea is to iteratively perform optimization over $\bm{\lambda}$ and then estimate basis coefficients $\bm{\theta}$ given $\bm{\lambda}$ via standard penalized likelihood methods.\\
We first define a Laplace approximation $\ell_{LA}(\bm{\lambda},\bm{\nu} | \bm{y}) \approx \int \ell_p(\bm{\theta},\bm{\lambda},\bm{\nu}| \bm{y}) d\bm{\theta}$ to the marginal (restricted) ML score suitable for optimization. \newline Let \mbox{$\bm{H} = - \partial^2 \ell_p(\bm{\theta}, \bm{\lambda}, \bm{\nu} | \bm{y}) / (\partial \bm{\theta} \partial \bm{\theta}^T)$} denote the negative Hessian of the penalized log-likelihood \eqref{eq:jointlik}, and let $\tilde\bm{\theta} = \arg\max_\theta \ell_p(\bm{\theta},\bm{\lambda},\bm{\nu} | \bm{y})$ for fixed $\bm{\lambda}, \bm{\nu}$ with $\tilde{\bm{\mu}} = g^{-1}(\bm{\Phi} \tilde\bm{\theta})$. The approximate marginal (restricted) ML criterion can then be defined as
\begin{align}
\begin{split}
\ell_{LA}(\bm{\lambda},\bm{\nu} | \bm{y}) = \ell(\tilde{\bm{\mu}}, \bm{\nu} | \bm{y}) - \tfrac{1}{2}
\sum^R_{r=1} \left(\operatorname{pen}(\tilde\bm{\theta}_r| \lambda_{tr},
\lambda_{xr}) - \log|\bm{P}_r(\lambda_{tr}, \lambda_{xr})|^+\right) -\\
\quad\tfrac{1}{2}\log\left|\bm{H}\right| + \tfrac{1}{2} d_\emptyset \log(2\pi),
\end{split}
\label{eq:laplacereml}
\end{align}
where $|\bm{A}|^+$ denotes the generalized determinant, i.e., the product of the positive eigenvalues of $\bm{A}$, and $d_\emptyset$ is the sum of the rank deficiencies of the $\bm{P}_r(\lambda_{tr}, \lambda_{xr}), r=1, \dots, R$.
The R package \code{mgcv} \citep{Wood2006} provides an efficient and numerically stable implementation for the iterative optimization of \eqref{eq:laplacereml} that 1) finds $\tilde\bm{\theta}$ for each candidate $\bm{\lambda}$ via penalized iteratively re-weighted least squares, 2) computes the gradient and Hessian of $\ell_{LA}(\bm{\lambda},\bm{\nu} | \bm{y})$ w.r.t.~$\log(\bm{\lambda})$ via implicit differentiation, 3) updates $\log(\bm{\lambda})$ via Newton's method and 4) estimates $\bm{\nu}$ either as part of the maximization for $\bm{\lambda}$ or based on the Pearson statistic of the fitted model. See \citet{Wood2011, Wood2014, WoodPyaSaefken2015} for technical details and numerical considerations.
Confidence intervals \citep{MarraWood2012} and tests \citep{Wood2013} for the estimated effects are based on the asymptotic normality of ML estimates. Confidence intervals use the variance of the distance between the estimators and true effects. Similar to the idea behind the MSE, this accounts for both the variance and the penalization induced bias (shrinkage effect) of the spline estimators.
We provide an implementation of the full generality of the proposed models in the \code{pffr()} function in the R package \code{refund} \citep{refund} and use the \code{mgcv} \citep{Wood2011} implementation of (scalar) generalized additive mixed models as computational backend. The \code{pffr()} function provides a formula-based wrapper for the definition of a broad variety of functional effects as in Section \ref{sec:tensorrep} as well as convenience functions for summarizing and visualizing model fits and generating predictions.
\subsection{Synthetic Data: Binomial Additive Mixed Model}\label{sec:sim-binomial}
We describe an extensive simulation study to evaluate the quality of estimation for
various potential model specifications for the PIGWISE data presented in Section \ref{sec:app-data}. We simulate Binomial data $y_i(t) \sim B\left(\text{trials}, \pi=\operatorname{logit}^{-1}\left(\eta_i(t)\right)\right)$ with $\text{trials}=10, 60, 200$ for $n=100$ observations on $T=150$ equidistant grid-points over $[0, 1]$ for a variety of true additive predictors $\eta_i(t) = \sum_{r=1}^R f_r(\mathcal{X}_{ri},t)$. The subsequent paragraph describes the various $f_r(\mathcal{X}_{ri},t)$ we investigate.
The additive predictor always includes a functional intercept $\beta_0(t)$.
For modelling day-to-day differences in feeding rates, the additive predictor includes an $\iid$ functional random intercept $b_i(t)$ (setting: \code{ri}) or a smoothly varying day effect $f(i, t)$ (setting: \code{day}).
Note that the ``true'' functional random intercepts were generated with Laplace-distributed spline coefficients in order to mimic the spiky nature of the application data. For modeling the auto-regressive effect of past feeding behavior, the additive predictor can include one of
\begin{compactitem}
\item a time-varying nonlinear term $f(\tilde y_i(t-.005), t)$ (\code{lag}),
\item a time-constant nonlinear term $f(\tilde y_i(t-.005))$ (\code{lag.c}),
\item a cumulative linear term over the previous 0.3 time units
$\int_W \tilde y_i(s) \beta(t, s) ds$; $W= \{s: t-0.3 \leq s < t\}$ (\code{ff.3}),
\item a cumulative linear term over the previous 0.6 time units
$\int_W \tilde y_i(s) \beta(t, s) ds$; $W= \{s: t-0.6 \leq s < t\}$ (\code{ff.6}),
\end{compactitem}
where $\tilde y_i(s) = (y_i(s) - \bar y(s))$ denotes the centered responses and $\bar y(s)$
the mean response function.
The simulated data also contains humidity and temperature profiles generated
by drawing random FPC score vectors from the respective empirical FPC score distributions estimated from the (centered) humidity and temperature data provided in the PIGWISE data. For modeling the effect of these functional covariates, the additive predictor includes either a nonlinear concurrent interaction effect
$f(\text{hum}_i(t), \text{temp}_i(t), t)$ (\code{ht}) or a nonlinear time-constant concurrent interaction effect $f(\text{hum}_i(t), \text{temp}_i(t))$ (\code{ht.c}).
We simulate data based on additive predictors containing each of the terms described above on its own, as well as additive predictors containing either
functional random intercepts (\code{ri}) or a smoothly varying day effect (\code{day}) and one of the remaining terms, for a total of 21 different combinations.
For all of these settings, we vary the amplitude of the global functional intercept (small: $\operatorname{logit}^{-1}(\beta_0(t)) \in [0.06, 0.13]\;\forall\, t$; intermediate: $\in [0.04, 0.19]$; large: $\in [0.02, 0.34]$). For the settings with just a single additional term we also varied the absolute effect size of these terms.
For small effect sizes the respective
$\exp(f_r(\mathcal{X}_{ri},t)) \in [0.5, 2]\;\forall\, t$, is $\in [0.2, 5]$ for intermediate effect sizes and $\in [0.1, 10]$ for large effect sizes. We ran 30 replicates for each of the resulting 333 combinations of simulation parameters, for a total of 9990 fitted models. Since the settings' effects are large and systematic and we use a fully crossed experimental design, 30 replicates are more than enough to draw reliable qualitative conclusions from the results here.
We focus on the results for $\text{trials}=60$ with intermediate
amplitude of the global intercept as these settings are most similar to the application. Results for the other settings are qualitatively similar, with the expected trends: performance improves for more informative data (i.e, more ``trials'') and larger effect sizes and worsens for less informative data with fewer ``trials'' and smaller effect sizes.
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/binomial-eta-rmse-cover-1}
}
\caption[rRIMSE]{rRIMSE$(\hat\eta(t))$ and coverages for the different models for synthetic binomial data (60 trials, $\operatorname{logit}^{-1}(\beta_0(t)) \in [0.04, 0.19]$).}\label{fig:binomial-eta-rmse-cover}
\end{figure}
\end{knitrout}
Figure \ref{fig:binomial-eta-rmse-cover} shows rRIMSE$(\hat\eta(t))$ (left panel) and average point-wise coverages (right panel) for the various settings -- it is easy to see that the concurrent functional effects (\code{humtemp, humtemp.c})
and especially the daily random intercepts (\code{ri}) are the hardest to estimate.
Further study shows that concurrent interaction effects are very sensitive to the rank of the functional covariates involved: both humidity and temperature are practically constant in this data and show little variability, so effects are hard to estimate reliably in this special case due to a lack of variability in the covariate. The daily random intercepts are generated from a Laplace distribution of the coefficients to yield ``peaky'' functions as seen in the application, not the Gaussian distribution our model assumes. Figure \ref{fig:binomial-riff6-ex} in Appendix \ref{app:ex_binomial} displays a typical fit for the setting with functional random intercepts and a cumulative autoregressive effect (\code{ri+ff.6}) and shows that rRIMSEs around .2 correspond to useful and sensible fits in this setting. Also note that performance improves dramatically if the Gaussianity assumption for the random intercept functions is met, c.f.~the results in Sections \ref{app:wang} and \ref{app:goldsmith} for Gaussian random effects in some much simpler settings.
Note that we are trying to estimate a latent smooth function for each day based only on the feeding episodes for that day for \code{ri} and, through smoothing, based on each day and its neighboring days in the case of \code{day}. The results show that this strategy can work rather well, albeit with a high computational cost in the case of \code{ri}: On our hardware, models with such functional random intercepts usually take between 5 minutes and 2 hours to fit, while models with a smooth day effect usually take between 15 seconds and 15 minutes, depending on which covariate effects are present in the model. See Figure \ref{fig:binomial-time} in Appendix \ref{app:ex_binomial} for details on computation times.
As seen in the replication studies in Sections \ref{app:wang} and \ref{app:goldsmith}, estimating random intercepts with our approach also works as well or better than competing approaches in more conventional settings with multiple replicates per group level rather than the one considered here with a single curve per group level. The results here still represent quite successful fits -- Figure \ref{fig:binomial-dayff6-ex} shows results for a typical \code{day+ff.6}-model that yields about the median RIMSE for that setting. Most estimates are very close to the ``truth''.
In terms of CI coverage, we find that CIs for $\hat\eta_i(t)$ (Figure \ref{fig:binomial-eta-rmse-cover}, right panel) are usually close to their nominal $95$\% level.
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/binomial-dayff6-ex-1}
}
\caption{Typical model fit for setting \code{day+ff.6}: smoothly varying day effect with a cumulative auto-regressive term. Left column shows true (red, dashed) and estimated (black, solid) conditional expectation (top) for 12 randomly selected days in the top row, estimated (top panel) and true (bottom panel) smoothly varying day-daytime effect (middle and bottom rows). Right column shows true and estimated global intercept (top), estimated (middle, top panel) and true (middle, bottom panel) coefficient surface for the cumulative auto-regressive effect and true and estimated contributions of the cumulative auto-regressive effect to the additive predictor (bottom). For this model, rRIMSE$(\hat\eta(t)) = 0.054 $, while the median rRIMSE for this setting is 0.069}\label{fig:binomial-dayff6-ex}
\end{figure}
\end{knitrout}
Appendix \ref{app:ex_binomial} shows typical fits for some of the remaining settings. In summary, the proposed approach yields useful point estimates for most terms under consideration and confidence intervals with coverages consistently close to the nominal level on data with a similar structure as the application.
\subsection{Synthetic Data: Beta-, Negative Binomial-, $t(3)$-Distribution}\label{sec:sim-families}
\subsubsection{Data Generating Process}
We generate data with responses with scaled $t(3)$-distributed errors,
Beta($\alpha, \beta$)-distributed responses and Negative Binomial NB($\mu, \theta$)-distributed responses. We generate data with $n=100, 300$ observations, each with signal-to-noise ratios SNR $= 1, 5$. SNR is not easily adjustable for Negative Binomial data since variance and mean cannot be specified separately. In our simulation, we use $g(\cdot)=\log(\cdot)$, with $\theta= 0.5$, so that $\operatorname{Var}(y(t)) = \operatorname{E}(y(t)) + 2 \operatorname{E}(y(t))^2$. See Appendix \ref{app:ex-families} for details.
Functional responses are evaluated on $T=60$ equidistant grid-points over $[0, 1]$. We investigate performance for 4 different additive predictors:
\begin{compactitem}
\item \code{int}: $\operatorname{E}(y(t)) = g^{-1}(\beta_0(t))$
\item \code{smoo}: index-varying non-linear effect: $\operatorname{E}(y(t)) = g^{-1}(\beta_0(t) + f(x, t))$
\item \code{te}: non-linear interaction: $\operatorname{E}(y(t)) = g^{-1}(\beta_0(t) + f(x_1, x_2))$ via tensor product spline
\item \code{ff}: functional covariate: $\operatorname{E}(y(t)) = g^{-1}(\beta_0(t) + \int x(s)\beta(t, s) ds)$
\end{compactitem}
50 replicates were run for each of the 32 settings for Beta and $t(3)$ and each of the 16 settings for NB.
\subsubsection{Results}
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/families-eta-1}
}
\caption[Relative RIMSE (left) and achieved coverage (right, nominal 95\%) for estimated additive predictor]{Relative RIMSE (left) and achieved coverage (right, nominal 95\%) for estimated additive predictor. Rows for the three distributions and columns for the 4 model settings. Blue for high noise settings with SNR $= 1$, red for SNR $= 5$, white for NB without available SNR. Horizontal axis represents the varying number of observations. Fat grey horizonal line denotes nominal 95\% coverage.}\label{fig:families-eta}
\end{figure}
\end{knitrout}
\begin{knitrout}\scriptsize
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}
{\centering \includegraphics[width=\textwidth]{figure/families-coef-1}
}
\caption[Relative RIMSE (left) and achieved coverage (right, nominal 95\%) for estimated effects]{Relative RIMSE (left) and achieved coverage (right, nominal 95\%) for estimated effects. Columns for the three distributions and rows for settings with index-varying nonlinear effect, nonlinear interaction effect and linear function-on-function effect, respectively. Blue for high noise settings with SNR $= 1$, red for SNR $= 5$, white for NB without available SNR. Horizontal axis represents the varying number of observations.}\label{fig:families-coef}
\end{figure}
\end{knitrout}
Figure \ref{fig:families-eta} shows relative RIMSEs (left figure) and achieved point-wise coverages averaged across $t$ and $i$ (right figure, nominal 95\%) for the estimated additive predictor $\hat\eta_i(t)$ for each setting and replicate. Both point estimation and uncertainty quantification work well in these settings. For the point estimates, we observe the expected patterns of increasing precision with bigger data sets and decreasing noise levels.
The systematic under-coverage for $n=300$, SNR$=5$ we observe for the Beta-settings for the model with a time-constant nonlinear interaction effect (third column, first row) seems of little practical relevance -- in this setting, the point estimates are so close to the true effects and estimation uncertainty becomes so small that the CIs almost vanish, and in any case observed coverages mostly remain above 90\% for nominal 95\%.
Figure \ref{fig:families-coef} shows relative RIMSEs (left) and coverages (right) for the estimated effects in the three settings that include more than an intercept. Again, we observe the expected patterns of increasing precision with bigger data sets and decreasing noise levels. Estimates are generally fairly precise and most coverages are close to or greater than the nominal 95\%-level. Systematic under-coverage occurs for the scalar interaction effect (middle column) for the Beta and $t(3)$-distributions, but note again that given the high precision of the point estimates the fact that CIs tend to be too narrow is of little practical relevance. This could also indicate a basis specification that is too small to fit the true effect without approximation bias. We also observe a single replicate of setting \texttt{smoo} with $t(3)$-distributed errors with much larger rRIMSE and coverage around 20\% (bottom row, leftmost panels, rightmost boxplots), indicating that the robustification by specifying a $t$-distribution may not always be successful.
Median computation times for these fairly easy settings were between 3 and 49 seconds. Estimating the bivariate non-linear effect for setting \code{smoo} took the longest, with some fits taking up to
8 minutes.
We observed no relevant or systematic differences in computation times between the three response distributions we used.
Appendix \ref{app:ex-families} shows some typical results for these settings and gives additional details on the data generating process as well as tabular representations of the performance measures in Figures \ref{fig:families-eta} and
\ref{fig:families-coef}.
\section{Simulation Study}\label{sec:sim}
This section describes results on binomial
(Section \ref{sec:sim-binomial}) and Beta-, $t$- and negative binomial-distributed data (\ref{sec:sim-families}). Sections \ref{app:wang} and \ref{app:goldsmith} present replications of (parts of) the simulation studies on functional random intercept models in \citet{WangShi2014} and \citet{Goldsmith2015}, respectively. Note that neither of these competing approaches are able to fit nonlinear effects of scalar covariates, effects of functional covariates, functional random slopes or correlated functional random effects in their current implementation, while \code{pffr} does. Both approaches are implemented only for binary data, not the broad class of distributions available for \code{pffr}-models.
All results presented in this section can be reproduced with the code supplement available for this work at \verb+http://stat.uni-muenchen.de/~scheipl/downloads/gfamm-code.zip+.
To evaluate results on artificial data, we use the relative root integrated mean square error rRIMSE of the estimates evaluated on equidistant grid points over $\mathcal T$:
$$
\text{rRIMSE}(\hat f_r(\mathcal{X}_r, t)) = \sqrt{\tfrac{|\mathcal T|}{nT}\sum_{i,l}\frac{(\hat f_r(\bm{\mathcal{X}}_{\bm{r}i}, t_l) - f(\bm{\mathcal{X}}_{\bm{r}i}, t_l))^2}{\text{sd}(f(\bm{\mathcal{X}}_{\bm{r}i}, \bm t))^2}},
$$
where $\text{sd}(f(\bm{\mathcal{X}}_{\bm{r}i}, \bm t))$ is the empirical standard deviation of $[f(\bm{\mathcal{X}}_{\bm{r}i}, t_l)]_{l=1, \dots, T}$, i.e., the variability of the estimand values over $\bm{t}$. We use the relative RIMSE rather than RIMSE$(\hat f_r(\mathcal{X}_r, t)) = \sqrt{\tfrac{|\mathcal T|}{nT}\sum_{i,l} (\hat f_r(\bm{\mathcal{X}}_{\bm{r}i}, t_l) - f_r(\bm{\mathcal{X}}_{\bm{r}i}, t_l))^2}$ in order to make results more comparable between estimands with different numerical ranges and to give a more intuitively accessible measure of the estimation error, i.e., the relative size of the estimation error compared to the variability of the estimand across $\mathcal T$.
\input{gfamm_sim_binomial.tex}
\input{gfamm_sim_families.tex}
\input{appendix_wang.tex}
\input{appendix_goldsmith.tex}
\subsection{Summary of Simulation results}
We achieve useful and mostly reliable estimates for many complex settings in data structured like the PIGWISE data in acceptable time. Simulation results for less challenging settings and other response distributions than Binomial are good to excellent as well.
Our partial replications of the simulation studies in \citet{WangShi2014} and \citet{Goldsmith2015} in Sections \ref{app:wang} and \ref{app:goldsmith}, respectively, show that
our implementation achieves highly competitive results in similar or much shorter computation times even though the settings are tailored towards the competing earlier approaches which are also less flexible than ours by quite a large margin.
|
{'timestamp': '2016-05-09T02:08:17', 'yymm': '1506', 'arxiv_id': '1506.05384', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05384'}
|
arxiv
|
\section{Experiments}
\label{experimentssect}
In order to measure the performance of spectral networks on real-world data and to explore the effect of the graph estimation procedure, we conducted experiments on three datasets from text categorization, computational biology and computer vision. All experiments were done using the Torch machine learning environment with a custom CUDA backend.
We based the spectral network architecture on that of a classical convolutional network, namely by interleaving graph convolution, ReLU and graph pooling layers, and ending with one or more fully connected layers. As noted above, training a spectral network requires an $O(N^2)$ matrix multiplication for each input and output feature map to perform the Graph Fourier Transform, compared to the efficient $O(N \text{log} N)$ Fast Fourier Transform used in classical ConvNets. We found that training the spectral networks with large numbers of feature maps to be very time-consuming and therefore chose to experiment mostly with architectures with fewer feature maps and smaller pool sizes. We found that performing pooling at the beginning of the network was especially important to reduce the dimensionality in the graph domain and mitigate the cost of the expensive Graph Fourier Transform operation.
In this section we adopt the following notation to descibe network architectures: GC$k$ denotes a graph convolution layer with $k$ feature maps, P$k$ denotes a graph pooling layer with stride $k$ and pool size $2k$, and FC$k$ denotes a fully connected layer with $k$ hidden units. In our results we also denote the number of free parameters in the network by $P_\text{net}$ and the number of free parameters when estimating the graph by $P_\text{graph}$.
\subsection{Reuters}
We used the Reuters dataset described in ~\cite{JMLR:v15:srivastava14a}, which consists of training and test sets each containing 201,369 documents from 50 mutually exclusive classes. Each document is represented as a log-normalized bag of words for 2000 common non-stop words. As a baseline we used the fully-connected network of ~\cite{JMLR:v15:srivastava14a} with two hidden layers consisting of 2000 and 1000 hidden units regularized with dropout.
We chose hyperparameters by performing initial experiments on a validation set consisting of one-tenth of the training data. Specifically, we set the number of subsampled weights to $k=60$, learning rate to 0.01 and used max pooling rather than average pooling. We also found that using AdaGrad ~\cite{adagrad} made training faster. All architectures were then trained using the same hyperparameters.
Since the experiments were computationally expensive, we did not train all models until full convergence. This enabled us to explore more model architectures and obtain a clearer understanding of the effects of graph construction.
\begin{table}[H]
\caption{Results for Reuters dataset. Accuracy is shown at epochs 200 and 1500.}
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Graph & Architecture & $P_\text{net}$ & $P_\text{graph}$ & Acc. (200) & Acc. (1500)\\
\hline
- &FC2000-FC1000 & $6 \cdot 10^6$ & 0 &70.18 \footnotemark & 70.18 \\
Supervised & GC4-P4-FC1000 & $2\cdot 10^6$ & $2 \cdot 10^6$ & 69.41 & 70.03 \\
Supervised & GC8-P8-FC1000 & $2 \cdot 10^6$ & $2 \cdot 10^6$ & 69.15 & - \\
Supervised low rank & GC4-P4-FC1000 & $2\cdot 10^6$ & $5 \cdot 10^5$ & 69.25 & - \\
Supervised low rank & GC8-P8-FC1000 & $2 \cdot 10^6$ & $5 \cdot 10^5$ & 68.35 & - \\
Supervised & GC16-P4-GC16-P4-FC1000& $2 \cdot 10^6$ & $2 \cdot 10^6$ & 69.04 & - \\
Supervised &GC64-P8-GC64-P8-FC1000 & $2 \cdot 10^6$ & $2 \cdot 10^6$ & 69.09 & - \\
RBF kernel & GC4-P4-FC1000 & $2\cdot 10^6$ & $2 \cdot 10^6$ & 67.85 & - \\
RBF kernel & GC8-P8-FC1000 & $2 \cdot 10^6$ & $2 \cdot 10^6$ & 66.95 & - \\
RBF kernel & GC16-P4-GC16-P4-FC1000 & $2 \cdot 10^6$ & $2 \cdot 10^6$ & 67.16 & - \\
RBF kernel & GC64-P8-GC64-P8-FC1000 & $2 \cdot 10^6$ & $2 \cdot 10^6$ & 67.42 & - \\
RBF kernel (local)& GC4-P4-FC1000 & $2\cdot 10^6$ & $2 \cdot 10^6$ & 68.56 & - \\
RBF kernel (local) & GC8-P8-FC1000 & $2 \cdot 10^6$ & $2 \cdot 10^6$ & 67.66 & - \\
\hline
\end{tabular}
\end{center}
\label{reuterstable}
\end{table}
\footnotetext{this is the maximum value before the fully connected starts overfitting}
Note that our architectures are designed so that they factor the first hidden layer of the fully connected network across feature maps and a subsampled graph, trading off resolution in the graph domain for resolution across feature maps. The number of inputs into the last fully connected layer is always the same as for the fully-connected network. The idea is to reduce the number of parameters in the first layer of the network while avoiding too much compression in the second layer.
We note that as we increase the tradeoff between resolution in the graph domain and across features, there reaches a point where performance begins to suffer. This is especially pronounced for the unsupervised graph estimation strategies. When using the supervised method, the network is much more robust to the factorization of the first layer. Table \ref{reuterstable} compares the test accuracy of the fully connected network and the GC4-P4-FC1000 network. Figure \ref{merckfigure}-left shows that the factorization of the lower layer has a beneficial regularizing effect.
\begin{figure}
\centering
\includegraphics[width=0.25\textwidth]{{reuters_alpha_0.01_global}.pdf}
\includegraphics[width=0.25\textwidth]{{reuters_alpha_0.01_local}.pdf} \\
\includegraphics[width=0.25\textwidth]{{merck3_alpha_0.01_global}.pdf}
\includegraphics[width=0.25\textwidth]{{merck3_alpha_0.01_local}.pdf}
\caption{Similarity graphs for the Reuters (top) and Merck DPP4 (bottom) datasets. Left plots correspond to global $\sigma$, right plots to local $\sigma$.}\label{fig:animals}
\end{figure}
\subsection{Merck Molecular Activity Challenge}
The Merck Molecular Activity Challenge is a computational biology benchmark where the task is to predict activity levels for various molecules based on the distances in bonds between different atoms. For our experiments we used the DPP4 dataset which has 8193 samples and 2796 features. We chose this dataset because it was one of the more challenging and was of relatively low dimensionality which made the spectral networks tractable. As a baseline architecture, we used the network of ~\cite{Ma:JournalChem2015} which has 4 hidden layers and is regularized using dropout and weight decay. We used the same hyperparameter settings and data normalization recommended in the paper.
As before, we used one-tenth of the training set to tune hyperparameters of the network. For this task we found that $k=40$ subsampled weights worked best, and that average pooling performed better than max pooling. Since the task is to predict a continuous variable, all networks were trained by minimizing the Root Mean-Squared Error loss. Following ~\cite{Ma:JournalChem2015}, we measured performance by computing the squared correlation between predictions and targets.
\begin{figure}[h]
\begin{center}
\includegraphics[width=0.4\textwidth]{reuterscrop.pdf}~
\includegraphics[width=0.4\textwidth]{merckcrop.pdf}
\caption{Evolution of Test accuracy. Left: Reuters dataset, Right: Merck dataset.}
\end{center}
\end{figure}
\label{merckfigure}
\begin{table}[H]
\caption{Results for Merck DPP4 dataset.}
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
Graph & Architecture & $P_\text{net}$ & $P_\text{graph}$ & $R^2$\\
\hline
- &FC4000-FC2000-FC1000-FC1000 & $22.1 \cdot 10^6$ & 0 & 0.2729 \\
Supervised & GC16-P4-GC16-P4-FC1000-FC1000 & $3.8\cdot 10^6$ & $3.9 \cdot 10^6$ & 0.2773 \\
Supervised & GC64-P8-GC64-P8-FC1000-FC1000 & $3.8\cdot 10^6$ & $3.9 \cdot 10^6$ &0.2580 \\
RBF Kernel & GC64-P8-GC64-P8-FC1000-FC1000 & $3.8\cdot 10^6$ & $3.9 \cdot 10^6$ &0.2037 \\
RBF Kernel (local) & GC64-P8-GC64-P8-FC1000-FC1000 & $3.8\cdot 10^6$ & $3.9 \cdot 10^6$ &0.1479 \\
\hline
\end{tabular}
\end{center}
\end{table}
We again designed our architectures to factor the first two hidden layers of the fully-connected network across feature maps and a subsampled graph, and left the second two layers unchanged. As before, we see that the unsupervised graph estimation strategies yield a significant drop in performance whereas the supervised strategy enables our network to perform similarly to the fully-connected network with much fewer parameters. This indicates that it is able to factor the lower-level representations in such a way as to retain useful information for the classification task.
Figure \ref{merckfigure}-right shows the test performance as the models are being trained. We note that the Merck datasets have test set samples assayed at a different time than the samples in the training set, and thus the distribution of features is typically different between the training and test sets. Therefore the test performance can be a significantly noisy function of the train performance. However, the effect of the different graph estimation procedures is still clear.
\subsection{ImageNet}
In the experiments above our graph construction relied on estimation from the data.
To measure the influence of the graph construction compared to the filter learning in the graph frequency domain, we performed the same experiments on the ImageNet dataset for which the graph is already known, namely it is the 2-D grid. The spectral network was thus a convolutional network whose weights were defined in the frequency domain using frequency smoothing rather than imposing compactly supported filters.
Training was performed exactly as in Figure 1, except that the linear transformation was a Fast Fourier Transform.
Our network consisted of 4 convolution/ReLU/max pooling layers with 48, 128, 256 and 256 feature maps, followed by 3 fully-connected layers each with 4096 hidden units regularized with dropout. We trained two versions of the network: one classical convolutional network and one as a spectral network where the weights were defined in the frequency domain only and were interpolated using a spline kernel. Both networks were trained for 40 epochs over the ImageNet dataset where input images were scaled down to $128 \times 128$ to accelerate training.
\begin{table}[H]
\caption{ImageNet results}
\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline
Graph & Architecture & Test Accuracy (Top 5) & Test Accuracy (Top 1)\\
\hline
2-D Grid & Convolutional Network & 71.854 & 46.24\\
2-D Grid & Spectral Network & 71.998 & 46.71\\
\hline
\end{tabular}
\end{center}
\end{table}
\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{{imagenetcrop}.pdf}
\caption{ConvNet vs. SpectralNet on ImageNet.}
\end{figure}
We see that both models yield nearly identical performance. Interstingly, the spectral network learns faster than the ConvNet during the first part of training, although both networks converge around the same time. This requires further investigation.
\section{Introduction}
In recent times, Deep Learning models have proven extremely successful on a wide variety of tasks, from computer vision and acoustic modeling to natural language processing \cite{natureyann}. At the core of their success lies an important assumption on the statistical properties of the data, namely the \emph{stationarity} and the \emph{compositionality} through \emph{local} statistics, which are present in natural images, video, and speech.
These properties are exploited efficiently by ConvNets ~\cite{krizhevsky2012,hinton12}, which are designed to extract local features that are shared across the signal domain. Thanks to this, they are able to greatly reduce the number of parameters in the network with respect to generic deep architectures, without sacrificing the capacity to extract informative statistics from the data. Similarly, Recurrent Neural Nets (RNNs) trained on temporal data implicitly assume a stationary distribution.
One can think of such data examples as being signals defined on a low-dimensional grid. In this case stationarity is well defined via the natural translation
operator on the grid, locality is defined via the metric of the grid, and compositionality is obtained from downsampling, or equivalently thanks to the multi-resolution property of the grid.
However, there exist many examples of data that lack the underlying low-dimensional grid structure.
For example, text documents represented as bags of words can be thought of as signals defined on a graph whose nodes are vocabulary terms and whose weights represent some similarity measure between terms, such as co-occurence statistics. In medicine, a patient's gene expression data can be viewed as a signal defined on the graph imposed by the regulatory network. In fact, computer vision and audio, which are the main focus of research efforts in deep learning, only represent a special case of data defined on an extremely simple low-dimensional graph. Complex graphs arising in other domains might be of higher dimension, and the statistical properties of data defined on such graphs might not satisfy the stationarity, locality and compositionality assumptions previously described.
For such type of data of dimension $N$, deep learning strategies are reduced to learning with fully-connected layers, which have $O(N^2)$ parameters, and regularization is carried out via weight decay and dropout \cite{srivastava2014dropout}.
When the graph structure of the input is known, \cite{spectralnet2013} introduced a model to generalize ConvNets using low learning complexity similar to that of a ConvNet, and which was demonstrated on simple low-dimensional graphs. In this work, we are interested in generalizing ConvNets to high-dimensional, general datasets, and, most importantly, to the setting where the graph structure is not known a priori. In this context, learning the graph structure amounts to estimating the similarity matrix, which has complexity $O(N^2)$. One may therefore wonder whether the graph estimation followed by graph convolutions offers advantages with respect to learning directly from the data with fully connected layers. We attempt to answer this question experimentally and to establish baselines for future work.
We explore these approaches in two areas of application for which it has not been possible to apply convolutional networks before: text categorization and bioinformatics. Our results show that our method is capable of matching or outperforming large, fully-connected networks trained with dropout using fewer parameters.
Our main contributions can be summarized as follows:
\begin{itemize}
\item We extend the ideas from \cite{spectralnet2013} to large-scale classification problems, specifically Imagenet Object Recognition, text categorization and bioinformatics.
\item We consider the most general setting where no prior information on the graph structure is available, and propose unsupervised and new supervised graph estimation strategies in combination with the supervised graph convolutions.
\end{itemize}
The rest of the paper is structured as follows. Section \ref{relatedworksect} reviews similar works in the literature. Section \ref{spectralsect} discusses generalizations of convolutions on graphs, and Section \ref{graphestimsect} addresses the question of graph estimation. Finally, Section \ref{experimentssect} shows numerical experiments on large scale object recogniton, text categorization and bioinformatics.
\section{Related Work}
\label{relatedworksect}
There have been several works which have explored architectures using the so-called local receptive fields \cite{karol, coates2011selecting, ngiam2010tiled}, mostly with applications to image recognition. In particular, \cite{coates2011selecting} proposes a scheme to learn how to group together features based upon a measure of similarity that is obtained in an unsupervised fashion. However, it does not attempt to exploit any weight-sharing strategy.
Recently, \cite{spectralnet2013} proposed a generalization of convolutions to graphs via the Graph Laplacian. By identifying a linear, translation-invariant operator in the grid (the Laplacian operator), with its counterpart in a general graph (the Graph Laplacian), one can view convolutions as the family of linear transforms commuting with the Laplacian. By combining this commutation property with a rule to find localized filters, the model requires only $O(1)$ parameters per ``feature map". However, this construction requires prior knowledge of the graph structure, and was shown only on simple, low-dimensional graphs. More recently, \cite{DBLP:journals/corr/MasciBBV15} introduced Shapenet, another generalization of convolutions on non-Euclidean domains based on geodesic polar coordinates, which was successfully applied to shape analysis, and allows comparison across different manifolds. However, it also requires prior knowledge of the manifolds.
The graph or similarity estimation aspects have also been extensively studied in the past. For instance, \cite{ravikumar2010high} studies the estimation of the graph from a statistical point of view, through the identification of a certain graphical model using $\ell_1$-penalized logistic regression. Also, \cite{chen2014unsupervised} considers the problem of learning a deep architecture through a series of Haar contractions, which are learnt using an unsupervised pairing criteria over the features.
\section{Generalizing Convolutions to Graphs }
\label{spectralsect}
\subsection{Spectral Networks}
Our work builds upon ~\cite{spectralnet2013} which introduced spectral networks. We recall the definition here and its main properties.
A spectral network generalizes a convolutional network through the Graph Fourier Transform, which is in turn defined via a generalization of the Laplacian operator on the grid to the graph Laplacian. An input vector $x \in \mathbb{R}^N$ is seen as a a signal defined on a graph $G$ with $N$ nodes.
\begin{graphconv}
Let $W$ be a $N \times N$ similarity matrix representing an undirected graph $G$, and let $L = I - D^{-1/2}WD^{-1/2}$ be its graph Laplacian with $D=W\cdot {\bf 1}$ eigenvectors $U=(u_1,\dots,u_N)$. Then a \textit{graph convolution} of input signals $x$ with filters $g$ on $G$ is defined by $x \ast_G g = U^T \left( Ux \odot Ug \right)$, where $\odot$ represents a point-wise product.
\end{graphconv}
Here, the unitary matrix $U$ plays the role of the Fourier Transform in $\mathbb{R}^d$.
There are several ways of computing the graph Laplacian $L$ \cite{belkin2001laplacian}. In this paper, we choose the normalized version $L = I - D^{-1/2}WD^{-1/2}$, where $D$ is a diagonal matrix with entries $D_{ii} = \sum_j W_{ij}$. Note that in the case where $W$ represents the lattice, from the definition of $L$ we recover the discrete Laplacian operator $\Delta$. Also note that the Laplacian commutes with the translation operator, which is diagonalized in the Fourier basis.
It follows that the eigenvectors of $\Delta$ are given by the Discrete Fourier Transform (DFT) matrix.
We then recover a classical convolution operator by noting that convolutions are by definition linear operators that diagonalize in the Fourier domain (also known as the Convolution Theorem \cite{mallat1999wavelet}).
Learning filters on a graph thus amounts to learning spectral multipliers $w_g = (w_1, \dots,w_N)$
$$x \ast_G g := U^T ( \mbox{diag}(w_g) U x)~.$$
Extending the convolution to inputs $x$ with multiple input channels is straightforward. If $x$ is a signal with $M$ input channels and $N$ locations, we apply the transformation $U$ on each channel, and then use multipliers $w_g = (w_{i,j}\, ;\, i \leq N~, j \leq M)$.
However, for each feature map $g$ we need convolutional kernels are typically restricted to have small spatial support, independent of the number of input pixels $N$, which enables the model to learn a number of parameters independent of $N$. In order to recover a similar learning complexity in the spectral domain, it is thus necessary to restrict the class of spectral multipliers to those corresponding to localized filters.
For that purpose, we seek to express spatial localization of filters in terms of their spectral multipliers. In the grid, smoothness in the frequency domain corresponds to the spatial decay, since
$$\left| \frac{\partial^k \hat{x}(\xi)}{\partial \xi^k} \right| \leq C \int |u|^k |x(u)| du~,$$
where $\hat{x}(\xi)$ is the Fourier transform of $x$.
In \cite{spectralnet2013} it was suggested to use the same principle in a general graph, by considering a smoothing kernel $\mathcal{K} \in \mathbb{R}^{N \times N_0}$, such as splines, and searching for spectral multipliers of the form
$$w_g = \mathcal{K} \tilde{w}_g~.$$
The algorithm which implements the graph convolution is described in Algorithm \ref{pseudoPSO}.
\begin{algorithm}
\caption{Train Graph Convolution Layer}
\label{pseudoPSO}
\begin{algorithmic}[1]
\State Given GFT matrix $U$, interpolation kernel $\mathcal{K}$, weights $w$.
\State \textbf{Forward Pass:}
\State Fetch input batch $x$ and gradients w.r.t outputs $\nabla y$.
\State Compute interpolated weights: $w_{f'f} = \mathcal{K} \tilde{w_{f'f}}$.
\State Compute output: $y_{sf'} = U^T\left(\sum_{f} Ux_{sf} \odot w_{f'f} \right)$.
\State \textbf{Backward Pass:}
\State Compute gradient w.r.t input: $\nabla x_{sf} = U^T\left(\sum_{f'} \nabla y_{sf'} \odot w_{f'f} \right)$
\State Compute gradient w.r.t interpolated weights: $\nabla w_{f'f} = U^T\left(\sum_s \nabla y_{sf'} \odot x_{sf} \right)$
\State Compute gradient w.r.t weights $\nabla \tilde{w_{f'f}} = \mathcal{K}^T \nabla w_{f'f}$.
\end{algorithmic}
\end{algorithm}
\subsection{Pooling with Hierarchical Graph Clustering}
In image and speech applications, and in order to reduce the complexity of the model, it is often useful to trade off spatial resolution for feature resolution as the representation becomes deeper. For that purpose, pooling layers compute statistics in local neighborhoods, such as the average amplitude, energy or maximum activation.
The same layers can be defined in a graph by providing the equivalent notion of neighborhood. In this work, we construct such neighborhoods at different scales using multi-resolution spectral clustering \cite{von2007tutorial}, and consider both average and max-pooling as in standard convolutional network architectures.
\section{ Graph Construction }
\label{graphestimsect}
Whereas some recognition tasks in non-Euclidean domains, such as those considered in \cite{spectralnet2013} or \cite{DBLP:journals/corr/MasciBBV15}, might have a prior knowledge of the graph structure of the input data, many other real-world applications do not have such knowledge. It is thus necessary to estimate a similarity matrix $W$ from the data before constructing the spectral network. In this paper we consider two possible graph constructions, one unsupervised by measuring joint feature statistics, and another one supervised using an initial network as a proxy for the estimation.
\subsection{ Unsupervised Graph Estimation }
Given data $X \in \mathbb{R}^{L \times N}$, where $L$ is the number of samples and $N$ the number of features,
the simplest approach to estimating a graph structure from the data is to consider a distance between features $i$ and $j$ given by
$$d(i,j) = \| X_i - X_j \|^2~,$$
where $X_i$ is the $i$-th column of $X$.
While correlations are typically sufficient to reveal the intrinsic geometrical structure of images \cite{roux2008learning},
the effects of higher-order statistics might be non-negligible in other contexts, especially in presence of sparsity.
Indeed, in many situations the pairwise Euclidean distances might suffer from unnormalized measurements. Several strategies and variants
exist to gain some robustness, for instance replacing the Euclidean distance by the $Z$-score (thus renormalizing each feature by its standard
deviation), the ``square-correlation" (computing the correlation of squares of previously whitened features), or the mutual information.
This distance is then used to build a Gaussian diffusion Kernel \cite{belkin2001laplacian}
\begin{equation}
\label{unsupervisedkernel}
\omega(i,j) = \exp^{-\frac{d(i,j)}{\sigma^2}}~.
\end{equation}
In our experiments, we also consider the variant of self-tuning diffusion kernel \cite{zelnik2004self}
$$\omega(i,j) = \exp^{-\frac{d(i,j)}{\sigma_i \sigma_j}}~,$$
where $\sigma_i$ is computed as the distance $d(i,i_{k})$ corresponding to the $k$-th nearest neighbor $i_{k}$ of feature $i$.
This defines a kernel whose variance is locally adapted around each feature point, as opposed to (\ref{unsupervisedkernel}) where
the variance is shared.
The main advantage of (\ref{unsupervisedkernel}) is that it does not require labeled data. Therefore, it is possible to estimate
the similarity using several datasets that share the same features, for example in text classification.
\subsection{ Supervised Graph Estimation }
As discussed in the previous section, the notion of feature similarity is not well defined, as it depends on our choice of
kernel and criteria. Therefore, in the context of supervised learning, the relevant statistics from the input signals might not correspond to
our imposed similarity criteria. It may thus be interesting to ask for the feature similarity that best suits a particular classification task.
A particularly simple approach is to use a fully-connected network to determine the feature similarity. Given a training set with normalized \footnote{In our experiments we simply normalized each feature by its standard deviation, but one could also whiten completely the data.} features $X \in \mathbb{R}^{L \times N}$
and labels $y \in \{1,\dots,C\}^L$, we initially train a fully connected network $\phi$ with $K$ layers of weights $W_1, \dots, W_K$, using standard ReLU activations and dropout. We then extract the first layer features $W_1 \in \mathbb{R}^{N \times M_1}$, where $M_1$ is the number of first-layer hidden features, and consider the distance
\begin{equation}
\label{supervisedkernel}
d_{sup}(i, j) = \| W_{1,i} - W_{1,j} \|^2~,
\end{equation}
that is then fed into the Gaussian kernel as in (\ref{unsupervisedkernel}). The interpretation is that the supervised criterion will extract through $W_1$ a collection of linear measurements that best serve the classification task. Thus two features are similar if the network decides to use them similarly within these linear measurements.
This constructions can be seen as ``distilling" the information learnt by a first network into a kernel. In the general case where no assumptions are made on the dimension of the graph, it amounts to extracting $N^2/2$ parameters from the first learning stage (which typically involves a much larger number of parameters). If, moreover, we assume a low-dimensional graph structure of dimension $m$, then $m N$ parameters are extracted by projecting the resulting kernel into its leading $m$ directions.
Finally, observe that one could simply replace the eigen-basis $U$ obtained by diagonalizing the graph Laplacian by an arbitrary unitary matrix, which is then optimized by back-propagation together with the rest of the parameters of the model. We do not report results on this strategy, although we point out that it has the same learning complexity as the Fully Connected network (requiring $O(K N^2)$ parameters, where $K$ is the number of layers and $N$ is the input dimension).
\input{nips2015_exp}
\section{Discussion}
ConvNet architectures base their appeal and success on their
ability to produce highly informative local statistics using low learning complexity
and avoiding expensive matrix multiplications. This motivated us to
consider generalizations on high-dimensional, unstructured data.
When the statistical properties of the input satisfy both stationarity
and composotionality, spectral networks have a learning complexity
of the same order as Convnets. In the general setting where no
prior knowledge of the input graph structure is known, our model
requires estimating the similarities, a $O(N^2)$ operation, but making
the model deeper does not increase learning complexity as much as
the general Fully Connected architectures. Moreover, in contexts
where feature similarities can be estimated using unlabeled data (such as
word representations), our model has less parameters to learn from labeled data.
However, as our results demonstrate,
their extension poses significant challenges:
\begin{itemize}
\item Although the learning complexity requires $O(1)$ parameters per feature map,
the evaluation, both forward and backward, requires a multiplication by the Graph Fourier Transform,
which costs $O(N^2)$ operations. This is a major difference with respect to traditional ConvNets, which
require only $O(N)$. Fourier implementations of Convnets \cite{mathieu2013fast, DBLP:journals/corr/VasilacheJMCPL14} bring the complexity to $O(N \log N)$
thanks again to the specific symmetries of the grid. An open question is whether one can find approximate eigenbasis
of general Graph Laplacians using Givens' decompositions similar to those of the FFT.
\item Our experiments show that when the input graph structure is not known a priori, graph estimation is
the statistical bottleneck of the model, requiring $O(N^2)$ for general graphs and $O(M N)$ for $M$-dimensional graphs.
Supervised graph estimation performs significantly better than unsupervised graph estimation based on low-order moments. Furthermore, we have verified that
the architecture is quite sensitive to graph estimation errors. In the supervised setting, this step can be viewed in terms of
a Bootstrapping mechanism, where an initially unconstrained network is self-adjusted to become more localized and with weight-sharing.
\item Finally, the statistical assumptions of stationarity and compositionality are not always verified. In those situations, the constraints
imposed by the model risk to reduce its capacity for no reason. One possibility for addressing this issue is to insert Fully connected
layers between the input and the spectral layers, such that data can be transformed into the appropriate statistical model. Another strategy, that is
left for future work, is to relax the notion of weight sharing by introducing instead a commutation error $\| W_i L - L W_i \|$ with the graph Laplacian,
which puts a soft penalty on transformations that do not commute with the Laplacian, instead of imposing exact commutation as is the case in the spectral net.
\end{itemize}
|
{'timestamp': '2015-06-18T02:04:00', 'yymm': '1506', 'arxiv_id': '1506.05163', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05163'}
|
arxiv
|
\section{Preliminaries}
\label{sec:background-1}
In this section, we give a concise exposition of the knockoff filter \cite{knockoff}. Consider
\begin{equation}\nonumbe
\y = \X \bm\beta + \z,
\end{equation}
where the design $\X$ is $n$ by $p$ and noise term $\z$ consists of $n$ i.i.d.~ $\mathcal{N}(0, \sigma^2)$ entries. The knockoffs framework assumes the number of variables $p$ is no more than the number of measurements $n$ and the design matrix $\X$ has full rank. This is used to ensure model identifiability since otherwise there exists a non-trivial linear combination of the $p$ features $\X_j$ that sums to zero. Moreover, we normalize each column: $\|\X_j\|_2 = 1$ for all $1 \le j \le
p$.
This method starts with constructing the knockoff features $\widetilde \X \in \mathbb{R}^{n \times p}$ that satisfies
\begin{equation}\label{eq:ko_symm}
\widetilde{\X}^{\top}\widetilde{\X} = \X^\top \X, \quad \X^\top \widetilde{\X} = \X^\top \X - \operatorname{diag}(\bm s),
\end{equation}
where $\bm s \in \mathbb{R}^p$ has nonnegative entries. To understand the
constraints, observe that the first equality forces $\widetilde \X$ to mimic the correlation structure of $\X$. The second equality further requires any original-knockoff pair $\X_j, \widetilde\X_j$ have the same correlation with all the other $2p-2$ features. In a nutshell, the purpose of knockoff design is to manually construct a control group as compared to the original design $\X$.
The next step is to generate statistics for every original-knockoff pair. Denote by $\ko = [\X, \widetilde \X] \in \mathbb{R}^{n \times 2p}$, the
augmented design matrix. The reference paper suggests choosing the Lasso on the augmented design as a pilot estimator:
\begin{equation}\nonumber
\widehat{\bm\beta}(\lambda) = \underset{\bm b \in \mathbb{R}^{2p}}{\operatorname{argmin}} ~ \frac12 \|\y - \ko \bm b\|_2^2 + \lambda\|\bm b\|_1.
\end{equation}
Then, let $Z_j = \sup\{\lambda: \widehat\beta_j(\lambda) \ne 0\}$. Similarly, define $\widetilde Z_j$ for the knockoff variable $\widetilde\X_j$. Then, a recommended choice of the knockoff statistics are (different notation is used for the ease of exposition)
\[
W_j = \max\{Z_j, \widetilde Z_j \}, \quad \chi_j = \sgn(Z_j - \widetilde{Z}_j),
\]
where $\operatorname{sgn}(x) = -1, 0, 1$ depending on whether $x < 0, x= 0, x > 0$ respectively. As a matter of fact, many alternative knockoff statistics can be used instead, as emphasized in the reference paper. For instance, $W_j$ can take the form of any symmetric function of $Z_j$ and $\widetilde Z_j$. Furthermore, the use of the pilot estimator is not necessarily confined to the Lasso; alternatives include least-squares, least angle regression \cite{lars}, and any likelihood estimation procedures with a symmetric penalty (see e.g. \cite{SCAD,elasticnet,slope}).
The following lemma, due to \cite{knockoff}, is essential for the proof of FDR control of our knockoff aggregation. As clear from \eqref{eq:fdr}, we call $j$ a true null when $\beta_j = 0$ and a false null otherwise.
\begin{lemma}\label{lm:knockoff_key}
Conditional on all false null $\chi_j$ and all $W_j$, all true null $\chi_j$ are jointly independent and uniformly distributed on $\{-1,1\}$.
\end{lemma}
This simple lemma follows from the delicate symmetry between $\X_j$ and its knockoff $\widetilde\X_j$, which is guaranteed by the construction \eqref{eq:ko_symm}. The result implies that each $\chi_j$ can be
interpreted as a one-bit $p$-value, in the sense that it takes $1$ or $-1$ with equal probability if $\beta_j = 0$. In the case of large $|\beta_j|$, we shall expect that $\chi_j$ is more likely to take $1$ since the original feature $\X_j$ has more odds to enter the Lasso path earlier than $\widetilde\X_j$. This lemma also suggests ordering the hypotheses based on the magnitude of $W_j$ so that hypotheses that are more likely to be rejected would be tested earlier. Good ordering of hypotheses is a key element for improving power in sequential hypothesis testing (see e.g. \cite{foster2008alpha,javanmard2015}).
\section{Discussion}
\label{sec:discussion-1}
We introduce a communication-efficient method for aggregating the knockoff filter running on many decentralized linear models. This knockoff aggregation enjoys exact FDR control and some desired properties inherited from the knockoffs framework. Simulation results provide evidence that this proposed method exhibits nice properties in a range of examples.
Many challenging problems remain and we address a few of them. An outstanding open problem is to generalize the knockoffs framework to the high-dimensional setting $p > n$. This would as well help the knockoff aggregation cover a broader range of applications. In addition, the flexibility of the use of the link functions $\Omega$ and $\Gamma$ leaves room for further investigation: For example, does there exist an optimal $\Omega$ or $\Gamma$? Can these functions be chosen in a data-driven fashion? Last, it would be interesting to incorporate differential privacy (see e.g. \cite{cdwork2013}) in the stage of aggregation, which could lead to much stronger protection of confidentiality.
\section{Introduction}
Modern scientific discoveries are commonly supported by statistical significance summarized from exploring datasets. In our present world of Big Data, there are a number of difficulties with this scenario: an increasing number of hypotheses tested simultaneously, extensive use of sophisticated techniques, and enormous tuning parameters. In this pipeline, spurious discoveries arise naturally by \textit{mere} random chance alone across nearly all disciplines including health care \cite{ioannidis2005,begley2012,freedman2015}, machine learning \cite{dwork2014, demvsar2006statistical}, and neuroscience \cite{kriegeskorte2009circular}.
To address this challenge, the statistical community in the past two decades has developed a variety of approaches. A landmark work \cite{BH1995} proposed the false discovery rate (FDR) as a new measure of type-I error for claiming discoveries, along with the elegant Benjamini-Hochberg procedure (BHq) for controlling the FDR in the case of independent test statistics. Roughly speaking, FDR is the expected fraction of erroneously made discoveries among all the claimed discoveries. Today, this concept has been widely accepted as a criterion for providing evidence about the reproducibility of discoveries claimed in one experiment.
Our motivation for this work is further enhanced by the observation that scientific experiments are inherently decentralized in nature, where a given set of hypotheses are probed by several groups working in parallel. For an individual group, its access to datasets collected by the others is very limited. Then, challenges arise on how to statistically and efficiently perform meta-analysis of results from all groups for controlling the FDR while maintaining a higher power (the fraction of correctly identified true discoveries) compared to an individual group. As a running example, imagine that an initiative is intended to study the genetic causes of autism across many research institutes. Due to the privacy and confidentiality of the datasets held by different institutes, it would be difficult to share full datasets. In contrast, aggregating small-volume summary statistics from each institute is a practical solution. Another issue is observed in different high-tech companies that hold background and behavioral information on thousands of millions of individuals, but are reluctant to share data for common research topics in part due to huge communication costs.
\subsection{Problem Setup and Contributions}
\label{sec:problem-setup}
To formalize the problem considered throughout the paper, suppose we observe a sequence of linear models
\begin{equation}\nonumber
\y^i = \X^i \bm\beta^i + \z^i,
\end{equation}
where the design $\X^i \in \mathbb{R}^{n_i \times p}$ and the response $\y^i \in \mathbb{R}^{n_i}$ are collected by the $i$th group, the error term $\z^i$ has i.i.d.~ $\mathcal{N}( 0, \sigma_i^2)$ entries, and the signal $\bm\beta^i \in \mathbb{R}^p$ may vary across different groups. Keeping in mind that a (sufficiently) strong signal in one of the groups is adequate to declare significance in the meta-analysis finding, we are interested in any feature $j$ that obeys $\beta_j^i \ne 0$ for at least one $i$; for any model selection procedure returning a set of discoveries $\widehat{S} \subset \{1, \ldots, p\}$, the false discovery proportion (FDP) is defined as
\begin{equation}\label{eq:fdr}
\mbox{FDP} = \frac{ \# \left\{1 \le j \le p: j \in \widehat{S} ~\mbox{and}~ \beta^i_j =0 ~\mbox{for all}~ i \right\} } {\max \{ |\widehat S |, 1 \} },
\end{equation}
and FDR is the expectation of FDP. We assume that each group has only access to its own data, that is, $(\y^i, \X^i)$, and reports summary statistics encoded in about $O(p)$ bits to a coordinating center. In this protocol, we aim to achieve the exact FDR control by only making use of the information received at the center. Our approach, referred to as \textit{knockoff aggregation}, is built on top of the knockoffs framework introduced by Barber and Cand\`es \cite{knockoff}. The knockoff filter remarkably achieves exact FDR control in the finite sample setting for a single linear model whenever the number of variables is no more than the number of observations. The validity of the method does not depend on the amplitude or sparsity of the unknown signal, or any knowledge of the noise variance. In sharp contrast, the BHq is only known to control the FDR for sequence models under very restricted correlation structures \cite{benjamini2001} apart from the independent case \cite{BH1995}.
Some appealing features of the knockoff aggregation are listed as follows. Inherited from the knockoffs, our method also controls the FDR exactly for general design matrices in a non-asymptotic manner and does not require any knowledge of the noise variances of linear models. Apart from these inheritances, knockoff aggregation provides more refined information on the significance of each hypothesis by aggregating many independent copies of the summary statistics, resembling the multiple knockoffs as briefly mentioned in \cite{knockoff}. This property not only improves power by amplifying the signal, but also allows control of a generalized FDR which incorporates randomized decision rules. Due to the one-shot nature, this method only costs $O(p \cdot \#\mbox{linear models})$ bits in communication up to a logarithmic factor used in quantizing scalar summary statistics. We also propose a simple example where this rate of communication complexity is nearly optimal from an information-theoretic point of view.
\section{Aggregating the Knockoffs}
\label{sec:distr-knock}
We recap the problem: Observe a sequence of decentralized linear regression models with the same set of hypotheses of interest,
\begin{equation}\label{eq:decentralizedmodel}
\y^i = \X^i \bm\beta^i + \z^i
\end{equation}
for $1 \le i \le m$. The design matrix $\X^i$ is $n_i$ by $p$ and $\z^i$ consists of i.i.d.~ centered normals. The error terms $\z^i$ are jointly independent and are allowed to have \textit{different} variance levels. The number of observed models $m$ is not necessarily deterministic, but must be independent of the randomness of all $\z^i$. We are interested in simultaneously testing
\[
H_{0,j}: \beta^1_j = \beta^2_j = \cdots = \beta^m_j = 0
\]
(that is, there is no effect of feature $j$ in all studies) versus
\[
H_{a,j}: \mbox{at least one } \beta^i_j \ne 0
\]
for $1 \le j \le p$. To fully utilize the knockoffs framework, we assume $n_i \ge p$ for all $i \ge 1$.
Our aggregation starts by running the knockoff filter with an arbitrary pilot estimator for each linear model \eqref{eq:decentralizedmodel}, which provides us with the ordering statistics $W^i_1, \ldots W^i_p$ and the one-bit $p$-values $\chi^i_1, \ldots, \chi^i_p$. Then, for each $1 \le j \le p$, we aggregate $W^1_j, \ldots, W^m_j$ to produce $W_j$ that measures the rank of the $j$th hypothesis: the larger $W_j$ is, the earlier the hypothesis $H_{0, j}$ is tested. Let this summary statistic take the form $W_j = \Gamma(W_j^1, \ldots, W^m_j)$ for some nonnegative measurable function $\Gamma$ defined on $\mathbb{R}_+^m$. Recognizing that a large $W_j^i$ provides evidence of significant rank of the corresponding hypothesis, we are particularly interested in summary functions $\Gamma$ that are non-decreasing in each coordinate. No further conditions of $\Gamma$ are required. Examples include $\Gamma(x_1, \ldots, x_m) = \max\{x_1, \ldots, x_m\}, \, \Gamma(x_1, \ldots, x_m) = \mbox{the sum (or product) of the } r \mbox{ largest of } x_1, \ldots x_m$ for some $1 < r \le m$, and $\Gamma(x_1, \ldots, x_m) = \sum_{i=1}^m n_i x_i$. The first two examples are symmetric in the $W$-statistics and the last one incorporates sizes of the $m$ models.
With the ordering statistics $W_j$ in place, we move to define the aggregated $\chi$-statistics by making use of the one-bit $\chi_j^i$:
\begin{equation}\nonumbe
\chi_j = \frac{m}{2} + \frac12 \sum_{i=1}^m \chi^i_j,
\end{equation}
which is simply the number of $+1$ of $\chi_j^1, \ldots, \chi^m_j$. The motivation behind this construction is simple. That is, the more winnings of the original feature $\bm X_j^i$ over its knockoffs $\widetilde{\bm X}_j^i$, the stronger evidence that $\beta_j^i$ is nonzero. As will be shown in Lemma~\ref{lm:key_lemma}, under the null $\beta_j^1 = \cdots = \beta_j^m = 0$, this aggregated $\chi_j$ follows a simple binomial distribution so that it can be easily translated into a refined $p$-value.
In passing, the content of this section by far is summarized in Algorithm~\ref{algo:dist}.
\begin{algorithm}[H]
\caption{Running the knockoff filter in parallel}
\label{algo:dist}
\begin{algorithmic}[1]
\REQUIRE $\X^1, \ldots, \X^m, \y^1, \ldots, \y^m$ and a summary function $\Gamma$.
\STATE Run the knockoff filter for each model and get $\chi^1_j, \ldots, \chi^m_j$ and $W_j^1, \ldots, W_j^m$.
\STATE (One-shot communication) Let $\chi_j \leftarrow \frac{m}{2} + \frac12 \sum_{i=1}^m \chi^i_j$ and $W_j \leftarrow \Gamma(W^1_j, \ldots, W^m_j)$.
\end{algorithmic}
\end{algorithm}
\subsection{Controlling the Weighted FDR}
\label{sec:contr-fdr-other}
Having defined the aggregated knockoff statistics, we now turn to control a generalized FDR. We call it the weighted false discovery rate ($\wfdr$) which includes the original FDR as a special example. In lieu of the accept-or-reject decision rule, we introduce a randomized decision rule that assigns each hypothesis $H_{0, j}$ a number $\omega_j$ between 0 and 1. The closer $\omega_j$ is to 1, the more confidence we have in rejecting the hypothesis $H_{0, j}$. The definition the weighted FDR is given as follows.
\begin{definition}
Given a randomized decision rule $\bm\omega \in [0, 1]^p$, define the weighted false discovery proportion as
\[
\wfdp = \frac{\sum_{j=1}^p \omega_j \bm{1}_{\textnormal{null } j}}{ \sum_{j=1}^p \omega_j}
\]
if $\sum_{j=1}^p \omega_j > 0$ and otherwise $\wfdp = 0$, where $\bm{1}_{\textnormal{null } j} = 1$ if the hypothesis $H_{0, j}$ is a true null and otherwise 0. The $\wfdr$ is the expectation of $\wfdp$.
\end{definition}
If the weights $\omega_j$ take only $0, 1$, then the $\wfdr$ reduces to the vanilla FDR. In general, $\omega_j$ can be interpreted as the probability, or \textit{confidence}, of randomly rejecting $H_{0, j}$. As a special case, rejecting a hypothesis with confidence 0 is equivalent to accepting it. The motivation for this generalized FDR is simple: The accept-or-reject rule behaves like a hard rule that may make completely different decisions for very close $p$-values, whereas randomization smoothes out this undesirable artifact. From a practical point of view, this generalized FDR has the potential to find applications in large-scale Internet experiments where randomized decisions occurred frequently. Randomization of testing also comes naturally from an empirical Bayesian framework (see e.g. \cite{efron}).
As mentioned earlier, the particular form of the refined $\chi$-statistics is highly motivated by the fact that $\chi_j$ under the null hypotheses (i.e. $\beta_j^1= \cdots = \beta^m_j = 0$) are simply i.i.d.~ binomial random variables, no matter how complicated the joint distribution of $W_j$ is. The following lemma formalizes this point, whose proof is just a stone away from Lemma~\ref{lm:knockoff_key}.
\begin{lemma}\label{lm:key_lemma}
Conditional on all false null $\chi_j$ and all $W_j$, all true null $\chi_j$ are jointly independent and have binomial distribution $B(m, 1/2)$.
\end{lemma}
Therefore, the refined $p$-value for testing $H_{0,j}$ is naturally given by
\[
P_j = \frac1{2^m}\sum_{i=\chi_j}^m {m \choose i},
\]
which, by definition, is stochastically smaller than the uniform distribution on $[0, 1]$.
Now we turn to introduce Algorithm~\ref{algo:weight} which is a generalization of the original knockoff+ filter via incorporating a confidence function $\Omega$. We call $\Omega : [0, 1] \rightarrow [0, 1]$ a confidence function if $\Omega$ is non-increasing and obeys
\[
\lim_{x \rightarrow 0+} \Omega(x) = \Omega(0) = 1, \quad \lim_{x \rightarrow 1-} \Omega(x) = \Omega(1) = 0.
\]
This function is used to provide weights $\bm\omega$ in rejecting the hypotheses. In the special case of $\Omega(x) = \bm{1}_{x \le c}$ for some $0 < c < 1$, this algorithm reduces to the \textit{Selective SeqStep+} in \cite{knockoff}. Interested readers are referred to \cite{barber2015} for generalizations in a different direction.
Below, let $U$ be uniformly distributed on $[0, 1]$.
We present the main result as follows, which generalizes Theorem 3 of \cite{knockoff}. The control of $\wfdr$ in the finite sample setting holds for any summary function $\Gamma$ and confidence function $\Omega$.
\begin{theorem}\label{thm:fdr_control}
Combining Algorithm~\ref{algo:dist} and Algorithm~\ref{algo:weight} gives
\[
\wfdr \le q.
\]
\end{theorem}
\begin{algorithm}[H]
\caption{Knockoff filter with aggregated statistics from Algorithm~\ref{algo:dist}}
\label{algo:weight}
\begin{algorithmic}[1]
\REQUIRE $\chi_1, \ldots, \chi_p, W_1, \ldots, W_p$ from Algorithm~\ref{algo:dist}, nominal level $q \in (0, 1)$, and confidence function $\Omega$.
\STATE Compute $P_j = \frac1{2^m}\sum_{i=\chi_j}^m {m \choose i}$.
\STATE Order hypotheses according to the magnitude of the $W$-statistics: $W_{\rho(1)} \ge W_{\rho(2)} \ge \cdots \ge W_{\rho(p)}$, where $\rho(\cdot)$ is a permutation of $1, \ldots, p$.
\STATE Let $\widehat k$ be
\[
\max \left\{k: \frac{1 + \sum_{j=1}^k( 1 - \Omega(P_{\rho(j)}) )}{\sum_{j=1}^k \Omega(P_{\rho(j)})} \le \frac{q}{\E \, \Omega(U)} - q \right\},
\]
with the convention that $\max \emptyset = -\infty$.
\STATE Reject all hypotheses $H_{0, \rho(j)}$ for $j \le \widehat{k}$ with weight (confidence) $\omega_j = \Omega(P_{\rho(j)})$.
\end{algorithmic}
\end{algorithm}
The proof of the theorem relies on two lemmas stated below, which are parallel to Lemma 4 of \cite{knockoff}. We defer the proofs of these two lemmas to the Appendix.
\begin{lemma}\label{lm:martinglae}
Let
\[
V^+(k) = \sum_{j=1}^k \Omega(P_j) \bm{1}_{\textnormal{null } j}, \quad V^-(k) = \sum_{j=1}^k (1 - \Omega(P_j)) \bm{1}_{\textnormal{null } j}.
\]
Then,
\[
M(k) = \frac{V^+(k)}{1 + V^-(k)}
\]
is a super-martingale running backward in $k$ with respect to the filtration $\mathcal{F}_k$, which only knows all the false null $P_j$, and $V^+(k), V^+(k+1), \ldots, V^+(p)$.
\end{lemma}
\begin{lemma}\label{lm:mgle_start}
For any integer $N \ge 1$, let $U, U_1, \ldots, U_N$ be i.i.d.~ uniform random variables on $[0, 1]$. Then,
\begin{equation}\label{eq:mgle_start_val}
\E\left[ \frac{\sum_{j=1}^N \Omega(U_j) }{ 1 + \sum_{j=1}^N (1 - \Omega(U_j))} \right] \le \frac{\E \, \Omega(U)}{1 - \E \, \Omega(U)}.
\end{equation}
\end{lemma}
Now, we turn to give the proof of Theorem~\ref{thm:fdr_control}. The idea of the proof is similar to that of Theorem 2 in \cite{knockoff}.
\begin{proof}[Proof of Theorem~\ref{thm:fdr_control}]
Recall that the weights $\omega_j$ are given as $\omega_j = \Omega(P_j)$ if $H_{0, j}$ is ranked among the first $\widehat k$ hypotheses processed by Algorithm~\ref{algo:weight} and otherwise $\omega_j = 0$. Due to the independence between $m$ and all $\z^i$, by a conditional argument the theorem is reduced to proving for a deterministic $m$. By Lemma~\ref{lm:key_lemma}, without loss of generality, we may assume $W_1 \ge \cdots \ge W_p$. Then we get
\begin{align*}
\wfdp \cdot \bm{1}_{\widehat k \ge 1} &= \frac{\sum_{j=1}^{\widehat k} \Omega(P_j) \bm{1}_{\textnormal{null } j}}{ \sum_{j=1}^{\widehat k} \Omega(P_j)}\\
&= \frac{1 + \sum_{j=1}^{\widehat k} (1 - \Omega(P_j))\bm{1}_{\textnormal{null } j}}{\sum_{j=1}^{\widehat k} \Omega(P_j)} \cdot \frac{\sum_{j=1}^{\widehat k} \Omega(P_j) \bm{1}_{\textnormal{null } j}}{ 1 + \sum_{j=1}^{\widehat k} (1 - \Omega(P_j))\bm{1}_{\textnormal{null } j}}\\
&\le \frac{1 + \sum_{j=1}^{\widehat k} (1 - \Omega(P_j))}{\sum_{j=1}^{\widehat k} \Omega(P_j)} \cdot \frac{\sum_{j=1}^{\widehat k} \Omega(P_j) \bm{1}_{\textnormal{null } j}}{ 1 + \sum_{j=1}^{\widehat k} (1 - \Omega(P_j))\bm{1}_{\textnormal{null } j}}\\
& \le \frac{q(1 - \E \, \Omega(U))}{\E \, \Omega(U)} \cdot M(\widehat k).
\end{align*}
Recognizing that $\widehat k$ is a stopping time with respect to $\mathcal{F}$, we apply the Doob's optional stopping theorem to the super-martingale $M(k)$ in Lemma~\ref{lm:martinglae},
\begin{align*}
\wfdr &\le \frac{q(1 - \E \, \Omega(U))}{\E \, \Omega(U)} \cdot \E \, M(\widehat k) \\
&\le \frac{q(1 - \E \, \Omega(U))}{\E \, \Omega(U)} \cdot \E \, M(p) \\
&\le \frac{q(1 - \E \, \Omega(U))}{\E \, \Omega(U)} \cdot \frac{\E \, \Omega(U)}{1 - \E \, \Omega(U)} = q,
\end{align*}
where the last inequality follows from Lemma~\ref{lm:mgle_start} and the observation that $\Omega(P_j)$ is stochastically dominated by $\Omega(U_j)$.
\end{proof}
\subsection{Controlling Other Error Rates}
\label{sec:contr-other-error}
While it is out of the scope of the present paper, we would like to briefly point out that the knockoff aggregation can be applied to control other type-I error rates, including the $k$-familywise error rate ($k$-FWER) \cite{hh1988}, $\gamma$-FDP \cite{genovese2004stochastic}, and per-family error rate (PFER) \cite{gordon2007}. These error rates have different interpretations from the FDR and are more favorable in certain applications. Interested readers are referred to a recent work \cite{knockoffFWER} where some attractive features of the knockoffs framework are translated into a novel procedure for provably controlling the $k$-FWER and PFER. With more refined information, the knockoff aggregation has the potential to improve power while still controlling these error rates.
\section{Communication Complexity}
\label{sec:optimality-algo}
The knockoff aggregation is communication efficient due to its one-shot nature. For each decentralized linear model, the message sent to the coordinating center is merely the sign information $\chi_j^i$ and the ordering information $W_j^i$. This piece of information can be encoded in $O(p \, \mathtt{poly}(\log p))$ bits, where the polylogarithmic factor is used in quantizing each $W_j^i$ depending on the accuracy required. Hence, the total bits of communication is $\widetilde O(mp)$. We can further get rid of this logarithmic factor by forcing $W_j^i$ to take only $0$ or $1$, respectively, depending on whether the original $W_j^i$ is below the median of the original $W_1^i, \ldots, W_p^i$ or not.
It would be interesting to get a lower bound on the total communication cost required to control the FDR while maintaining a decent power. A trivial bound as such is $\Omega(p)$ since it needs $p$ bits to fully characterize the support set of $\bm\beta^i$ (in this section $\Omega(\cdot)$ is the Big Omega notation in complexity theory, instead of the confidence function). In general, this bound is unachievable since the summary statistics from each decentralized model are obtained by using only local information. To shed light on this, we provide a simple but illuminating example of \eqref{eq:decentralizedmodel} where $\Theta(mp)$ is the optimal communication cost in achieving asymptotically vanishing FDP and full power up to a polylogarithmic factor. To start with, fix the noise level $\sigma_i^2 = 1$. All $\bm\beta^i$ are equal to a common $\bm\beta$. Let the design matrix $\bm X^i$ of each decentralized model be a $(2p) \times p$ matrix with orthonormal columns, and each $\beta_j$ independently take $\mu := \sqrt{\frac{\log p}{m}}$ with probability half and 0 otherwise. We further assume that $\bm\beta$ is independent of $\bm z^i$, and both $p, m \rightarrow \infty$ but do not differ extremely from each other in the sense that $p = O(\e{m^{0.99}})$ and $m = O(\mathtt{poly}(p))$. This condition allows $m \asymp \log^2 p$ or $m \asymp p^{\alpha}$ for arbitrary $\alpha > 0$. Here, the summary statistics are defined as follows: We regress $\bm y^i $ on the augmented design $[\bm X^i,
\widetilde{ \bm X }^i ]$ ($\widetilde{ \bm X }^i$ is an orthogonal complement of $\bm X^i$), obtain the least-squares estimates $\widehat\beta_j^i, \widetilde\beta_j^i$ for each $1 \le j \le p$, and then take $\chi_j^i = \sgn(\widehat\beta_j^i - \widetilde\beta_j^i)$ and $W_j^i = 1$ or 0, respectively, depending on whether $|\widehat\beta_j^i - \widetilde\beta_j^i|$ is above the median of $|\widehat\beta_1^i - \widetilde\beta_1^i|, \ldots, |\widehat\beta_p^i - \widetilde\beta_p^i|$ or not.
Under the preceding assumptions, the knockoff aggregation almost perfectly recovers the support set of the signal $\bm\beta$, with a total communication cost of $O(mp)$. Let $\bm V \in \{0, 1\}^p$ be constructed as $V_j = 1$ if $\beta_j \ne 0$ and otherwise $V_j = 0$ (so $\bm V$ is uniformly distributed in the cube $\{0, 1\}^p$). Similarly, the output of the knockoff aggregation, denoted as $\widehat{\bm V}_{\textnormal{\tiny KO}}$, takes the form of $\widehat V_{\textnormal{\tiny KO}, j} = 1$ if $H_{0, j}$ is rejected and $\widehat V_{\textnormal{\tiny KO}, j} = 0$ if $H_{0, j}$ is accepted. Last, denote by $\operatorname{Hamm}(\cdot, \cdot)$ the Hamming distance.
\begin{proposition}\label{prop:knockoff_opt}
Let $\epsilon$ be any positive constant. With probability tending to one, this knockoff aggregation with slowly vanishing nominal levels $q$ obeys
\[
\operatorname{Hamm}(\widehat {\bm V}_{\textnormal{\tiny KO}}, \bm V) \le \epsilon p.
\]
\end{proposition}
Hence, the knockoff aggregation is capable of distinguishing almost all the signal features from the noise features, resulting $\fdp \rightarrow 0$ and $\tpp \rightarrow 1$. The nominal level $q$ is spelled out in the proof.
Next, we move to give the information-theoretic lower bound. Denote by $\bm M^i$ the message sent by the $i$th model, which only depends on the local information $\bm y^i, \X^i$. Then the coordinating center makes decisions $\widehat{\bm V} \in \{0, 1\}^p$ to reject or accept each of the $p$ hypotheses solely based on the $m$ pieces of messages $\bm M^1, \ldots, \bm M^m$. In other words, the protocol is non-interactive. Let $L^i$ be the minimal length of $\bm M^i$ in bit, with a preassigned budget constraint $\E (L^1 + \cdots + L^m) \le B$. The proof of the result below uses tools from \cite{duchi2014}.
\begin{proposition}\label{prop:comm_lower}
Let $\epsilon$ and $C$ be arbitrary positive constants. If the total communication budget
\[
B = \frac{Cmp}{ \log^{2.1} p},
\]
then for any non-interactive protocol,
\[
\operatorname{Hamm}(\widehat {\bm V}, \bm V) \ge \frac{1 - \epsilon}{2} \, p
\]
holds with probability tending to one.
\end{proposition}
Incidentally, the exponent $2.1$ can be replaced by any constant greater than 2. To appreciate this result, note that randomly flipping a coin for each hypothesis would have a Hamming distance about $p/2$ from the true support set $\bm V$. Hence, it is hopeless to draw any statistically valid conclusion based on $O(mp/\log^{2+o(1)} p)$ bits of information in the distributed setting. In a nutshell, for our example a communication budget of $O(mp)$ up to a logarithmic factor, is both sufficient and necessary for recovering the true signal.
\subsection*{Acknowledgments}
W.~S.~was supported in part by a General Wang Yaowu Stanford Graduate Fellowship. W.~S.~would like to thank Emmanuel Cand\`es for encouragement. We would like to thank John Duchi for helpful comments, and Becky Richardson for discussions about an early version of the manuscript.
\bibliographystyle{abbrv}
\section{Technical Proofs}
\label{sec:technical-proof}
\begin{proof}[Proof of Lemma~\ref{lm:key_lemma}]
Denote by $S$ the set of indices of all false null hypotheses, that is, $S = \{1 \le j \le p: \mbox{at least one } \beta^i_j \ne 0\}$. Similarly, $S^c$ corresponds to the true null hypotheses. For each $i$, conditional on $\bm W^i := (W^1_1, \ldots, W^i_p)$ and $\bm\chi^i_{S}$, from Lemma~\ref{lm:knockoff_key} it follows that $\bm\chi^i_{S^c}$ has i.i.d.~ components uniformly distributed on $\{-1, 1\}$. Since the $m$ linear models are independently generated, we thus see that the concatenation of $\bm\chi^i_{S^c}, 1 \le i \le m$ are uniformly distributed on $\{-1, 1\}^{m|S^c|}$ conditional on all $\bm W^i$ and all $\bm\chi^i_{S}$. Then the proof immediately follows by recognizing that $W_j$ and $\chi_j$ only depend on $W_j^i, 1 \le i \le m$ and $\chi_j^i, 1 \le i \le m$, respectively. The binomial distribution follows from the fact that $\chi_j$ is simply the number of $1$ in $\chi^i_j, 1 \le i \le m$.
\end{proof}
\begin{proof}[Proof of Lemma~\ref{lm:martinglae}]
We use some ideas from the proof of Lemma 4 in \cite{knockoff}. Given the filtration $\mathcal{F}_k$, we know all $V^-(k), \ldots, V^-(p)$ since it always holds that $V^-(k') + V^+(k') = \#\{j ~ \textnormal{null }: j \le k'\}$ for all $k' \ge k$. Without loss of generality, we assume all the hypotheses are true due to the observation that $M(j)$ agrees with $M(j-1)$ if the $j$th hypothesis is true. Write $V^+(k) = \sum_{j=1}^k \Omega(P_j) = A$. By the exchangeability of $\Omega(P_1), \ldots, \Omega(P_k)$, we get
\begin{equation}\label{eq:v_mean}
\E(V^+(k-1) | \mathcal{F}_k) = \E(V^+(k-1) | V^+(k) = A) = \frac{k-1}{k}A.
\end{equation}
Hence, we have
\begin{align*}
\E(M(k-1) | \mathcal{F}_k) &= \E(M(k-1) | V^+(k) = A)\\
&= \E\left( \frac{\sum_{j=1}^{k-1} \Omega(P_j)/k}{ 1 - \sum_{j=1}^{k-1} \Omega(P_j)/k} \Big{|} V^+(k) = A) \right).\\
\end{align*}
To proceed, note that $x/(1- x)$ is convex for $x < 1$. Since $\sum_{j=1}^{k-1} \Omega(P_j) \in [A-1, A]$ almost surely, by the inverse Jensen inequality we get
\[
\E\left( \frac{\sum_{j=1}^{k-1} \Omega(P_j)/k}{ 1 - \sum_{j=1}^{k-1} \Omega(P_j)/k} \Big{|} V^+(k) = A) \right) \le \frac{(A-1)/k}{1 - (A-1)/k} \eta + \frac{A/k}{1 - A/k}(1 - \eta),
\]
where $\eta = A/k$ is provided by \eqref{eq:v_mean}. Simple calculation reveals that
\[
\frac{(A-1)/k}{1 - (A-1)/k} \eta + \frac{A/k}{1 - A/k}(1 - \eta) = \frac{A}{1 + k - A} = M(k),
\]
as desired.
\end{proof}
\begin{proof}[Proof of Lemma~\ref{lm:mgle_start}]
Write $\alpha = \E \, \Omega(U) \in (0, 1)$. Note that each summand $\Omega(U_j)$ obeys $0 \le \Omega(U_j) \le 1$ and $\E \, \Omega(U_j) = \alpha$. We assert that the right-hand side (RHS) of \eqref{eq:mgle_start_val} attains the maximum if each $\Omega(U_j)$ is replaced by i.i.d.~ Bernoulli random variable $B(\alpha)$. (Note that $B(\alpha)$ assumes only $0, 1$ and obeys $\E \, B(\alpha) = \alpha$.) To see this, we examine which $\Omega(U_1)$ gives the maximum conditional expectation while $\sum_{j=2}^p \Omega(U_j)$ is fixed. Write
\begin{equation}\label{eq:u1_condi}
\frac{\sum_{j=1}^N \Omega(U_j) }{ 1 + \sum_{j=1}^N (1 - \Omega(U_j))} = \frac{\Omega(U_1) + \sum_{j=2}^N \Omega(U_j) }{ N+1 - \sum_{j=2}^N \Omega(U_j) - \Omega(U_1)}
\end{equation}
For any constants $c_1 > 0, c_2 > 1$, the function $(x + c_1)/(c_2 - x)$ is convex on $[0, 1]$. Hence, the inverse Jensen's inequality gives
\[
\E \left( \frac{\Omega(U_1) + c_1}{c_2 - \Omega(U_1)} \right) \le \E \left( \frac{B(\alpha) + c_1}{c_2 - B(\alpha)} \right).
\]
Applying the last display to \eqref{eq:u1_condi}, we see that the RHS of \eqref{eq:mgle_start_val} shall never decrease if each $\Omega(U_j)$ is replaced by i.i.d.~ $B(\alpha)$. As a consequence, it only remains to show
\[
\E\left( \frac{B(N, \alpha) }{ 1 + N - B(N, \alpha)} \right) \le \frac{\alpha}{1 - \alpha},
\]
which has been established in the proof of Lemma 4 in \cite{knockoff}. This finishes the proof.
\end{proof}
\begin{proof}[Proof of Lemma~\ref{prop:knockoff_opt}]
We start with the observation that
\[
\P(\chi^i_j = 1 | \beta_j = \mu) = \frac12 + (1+o(1))\sqrt{\log p/m}.
\]
Hence, $\chi_j = m/2 + (1 + o_{\P}(1)) \sqrt{m\log p}$ if $\beta_j = \mu$ for a fixed $j$. By the central limit theorem, $\chi_j = m/2 + O_{\P}(\sqrt{m})$ if $\beta_j = 0$. Set the confidence function $\Omega(x) = \bm{1}_{x \le c_p}$ for some slowly vanishing sequence $c_p$. Then, as $\log p \rightarrow \infty$ when taking the limit $p \rightarrow \infty$, we have
\begin{align*}
&\frac{\#\{j: \beta_j =\mu, \Omega(P_j) = 1 \}}{p} \rightarrow \frac12\\
&\frac{\#\{j: \beta_j = 0, \Omega(P_j) = 0 \}}{p} \rightarrow \frac12
\end{align*}
with probability tending to one, which implies that
\[
\frac{1 + \sum_{j=1}^p( 1 - \Omega(P_{\rho(j)}) )}{\sum_{j=1}^p \Omega(P_{\rho(j)})} \rightarrow 1
\]
for any permutation $\rho(\cdot)$. Then the rejection rule $\widehat k$ given by Algorithm~\ref{algo:weight} takes $p$ with probability approaching one since the targeted upper bound $q/\E\Omega(U) - q = q/c_p - q > 1$ asymptotically (set $c_p \ll q = q_p$). Recognizing that for almost all $j$ the weights $\Omega(P_j) = 1$ if and only if $\beta_j \ne 0$. This is equivalent to saying that $\widehat{\bm V}$ has only a vanishing fraction of indices that do not agree with $\bm V$.
\end{proof}
\begin{proof}[Proof of Proposition~\ref{prop:comm_lower}]
For the sake of generality, replace $2.1$ by $2 + \epsilon_1$ and $\epsilon$ by $\epsilon_2$. The proof makes extensive use of Lemmas 2, 4, and 6 of \cite{duchi2014}. Take $\delta = 1/2, \sigma = 1/\mu$ in Lemma 6 of \cite{duchi2014}, and
\[
a = \sqrt{m} \log^{\frac{\epsilon_1}{4}} p.
\]
First, we show that
\begin{equation}\label{eq:small_mutual}
I(\bm V; \bm{M}) = o(p).
\end{equation}
Recognizing $n_i \equiv 1$ (this is the notation used in \cite{duchi2014}, not in our problem setup), we see that the pair $(a, \delta)$ satisfies Eqn.~(18) of \cite{duchi2014} for sufficiently large $m$. Then, combined with Lemma 4, Eqn~(19b) gives
\begin{equation}\nonumber
\begin{aligned}
&I(\bm V; \bm{M}) \le \sum_{i=1}^m I(\bm V; \bm M^i) \\
&\le 128 \frac{\delta^2 a^2}{\sigma^4} \sum_{i=1}^m H(\bm M^i) + pm h_2(p^\star) + pmp^\star\\
&\le \frac{32 \log^{2 + \frac{\epsilon_1}{2}} p}{m} \sum_{i=1}^m H(\bm M^i) + pm h_2(p^\star) + pmp^\star\\
&\le \underbrace{\frac{32 B \log^{2 + \frac{\epsilon_1}{2}} p}{m}}_{I_1} + \underbrace{pm h_2(q^\star)}_{I_2} + \underbrace{pm q^\star}_{I_3},
\end{aligned}
\end{equation}
where the last inequality follows from Shannon’s source coding theorem \cite{cover2012}. This inequality asserts that \eqref{eq:small_mutual} is a simple consequence of
\begin{equation}\label{eq:I_three}
I_l = o(p)
\end{equation}
for all $l = 1, 2, 3$. Now we move to prove \eqref{eq:I_three}. For $l = 1$, we have
\[
I_1 = \frac{32 B \log^{2 + \frac{\epsilon_1}{2}} p}{m} = O\left( \frac{mp}{\log^{2 + \epsilon_1} p} \cdot \frac{\log^{2 + \frac{\epsilon_1}{2}} p}{m}\right) \\
= O\left( \frac{p}{\log^{\frac{\epsilon_1}{2}} p} \right) = o(p).
\]
For $l = 2, 3$, note that
\[
q^\star = \min\left\{ 2\e{-\frac{(a - 0.5)^2}{2\sigma^2}}, \frac12 \right\}.
\]
Since $a \gg 1$, it follows that the exponent
\[
\frac{(a - 0.5)^2}{2\sigma^2} \asymp \log^{1 + \frac{\epsilon_1}{2}} p.
\]
As a consequence,
\[
q^\star = \exp\left( -\Theta(\log^{1 + \frac{\epsilon_1}{2}} p) \right) = o(1).
\]
Thus, $I_3 = o(I_2)$, and $I_2$ further obeys
\begin{align*}
I_2 &\asymp -pm q^\star \log q^\star\\
& \asymp \frac{pm \log^{1 + \frac{\epsilon_1}{2}} p}{\exp\left( \Theta(\log^{1 + \frac{\epsilon_1}{2}} p) \right)} = o(p),
\end{align*}
which makes use of $m = O(\mathtt{poly}(p))$. This proves \eqref{eq:small_mutual}.
Next, we proceed to finish the proof by resorting to Lemma 2 of \cite{duchi2014}. To this end, set $t = (0.5 - \epsilon_2) p$ (if $\epsilon_2 \ge 0.5$ then there is nothing to prove). Then, Lemma 2 yields
\begin{equation}\label{eq:continu_fano}
\P\left( \operatorname{Hamm}(\widehat {\bm V}, \bm V) > (0.5 - \epsilon_2) p \right) \\
\ge 1 - \frac{I(\bm V; \bm M) + \log 2}{ \log \frac{2^p}{N_t}},
\end{equation}
where, in our setting, $N_t = \{\bm v \in \{0, M\}^p: \|\bm v\|_0 \le (0.5 - \epsilon_2) p\}$. By the large deviation theory, we get
\begin{equation}\label{eq:ldt}
\log\frac{2^p}{N_t} \sim ( \log 2 + (0.5 - \epsilon_2)\log(0.5 - \epsilon_2)
+ (0.5+\epsilon_2)\log(0.5+\epsilon_2) ) p \asymp p.
\end{equation}
Substituting \eqref{eq:small_mutual} and \eqref{eq:ldt} into \eqref{eq:continu_fano}, we obtain
\[
\P\left( \operatorname{Hamm}(\widehat {\bm V}, \bm V) > (0.5 - \epsilon_2) p \right) \ge 1 - o(1),
\]
which completes the proof.
\end{proof}
\section{Numerical Experiments}
\label{simulate}
In this section, we test the performance of the knockoff aggregation under a range of designs with different sparsity levels and signal strengths.
Recall that we have $m$ decentralized linear models
\[
\y^i = \X^i \bm\beta^i + \z^i
\]
for $i = 1, \ldots, m$, where $\X^i \in \mathbb{R}^{n_i \times p}$. Our setup is similar to \cite{knockoff}. First, the rows of $\X^i$ are drawn independently from $\mathcal{N} (\bm 0, \bm\Sigma)$, and are also independent of other sub-models. The columns of each $\X^i$ are then normalized to have unit length. Second, given a sparsity level $k$, we randomly sample $k$ signal locations and set $\beta^i_j = A$ for each selected index $j$ and all $i$, where $A$ is a fixed magnitude. Last, we fix the design and repeat the experiment by drawing $\y \overset{\text{iid}}{\sim} \mathcal{N} (\X \bm\beta, \bm I)$. Nominal FDR level is set to be $q = 0.20$.
\subsection{Power Gains with FDR Control}
Our first experiment tests the performance across different $m$ as the sparsity level or signal strength varies. To save space, here we only show the results for the models with independent features, i.e. $\bm\Sigma$ is diagonal. Similar patterns still hold under correlated designs. We take $p = 1000$, and $n_i = 3000$ for each $i$. Fix $\bm\Sigma = \bm I$ and $m = 5$. In this scenario, we take $A = 1.2 \sqrt{(2 {\log p})/{5}} \approx 1.99$, where $\sqrt{(2 {\log p})/{5}}$ is the universal threshold for detection if we had access to the entire datasets of the $m=5$ decentralized models, and 1.2 is a compensation factor for information loss in our communication-efficient aggregation. Each experiment is repeated 30 times.
In the knockoff aggregation, we are allowed to choose the summary function $\Gamma$ (in Algorithm~\ref{algo:dist}) and confidence function $\Omega$ (in Algorithm~\ref{algo:weight}). The choice can be made adaptively to different $m, n, p$ and the design structure. In the following simulation, we take $\Gamma (W_j^1, \ldots, W_j^m) = \sum_{i=1}^m n_i W_j^i$, and $\Omega(P_j) = \bm{1}_{P_j \leq 0.5}$.
Figure~\ref{diff_m_sparsity_iid} shows the FDR and power achieved by knockoff aggregation with fixed signal strength $A = 1.99$ and varying sparsity levels $k = 10, 30, 50, 100$, as well as with fixed sparsity $k = 30$ and varying strengths $A = c \sqrt{(2\log p)/5}$, where $c = 1.0, 1.2, 1.5, 2.0$. Recall that the power is the fraction of identified true discoveries among all the $k$ potential true discoveries. We see that our procedure can effectively control the FDR for different $m$ in both cases. Meanwhile, as $m$ increases power gains are significant even we only need $\widetilde O(mp)$ bits of communication.
\begin{figure}[!h]
\centering
\includegraphics[width=\textwidth, height = 0.3\textwidth]{diff_m_sparsity_iid.eps}
\vspace{-0.1in}
\includegraphics[width=\textwidth, height = 0.3\textwidth]{diff_m_amp_iid.eps}
\caption{Top row: mean FDP and power versus sparsity level $k$ with fixed strength $A = 1.99$. Bottom row: mean FDP and power versus amplitude level $A$ with fixed sparsity $k = 30$. We use i.i.d. design with $p = 1000, n_i = 3000$ and nominal level $q = 0.20$.}
\label{diff_m_sparsity_iid}
\end{figure}
\subsection{Comparison with Other Methods}
We compare the knockoff aggregation with other methods, such as the least-squares (OLS) and the Lasso. For the OLS, we consider the following procedure. For each $i$, we have the OLS estimator $\widehat{\bm \beta}^i$ based on $(\X^i, \y^i)$. This estimator obeys $\widehat{\bm \beta}^i \sim \mathcal{N} (\bm \beta, \bm\Theta^i)$, where $\bm\Theta^i = ((\X^i)^\top \X^i)^{-1}$. Then, $\widehat{\bm \beta}^i$ and the corresponding marginal variances $(\bm\Theta^i_{jj})_{1 \leq j \leq p}$ are aggregated from the $m$ nodes as follows. Let $\widehat{\beta}_j = \sum_{i=1}^m \widehat{\beta}^i_j /m$ be an averaged estimator of $\beta_j$ and $\Theta_j = (1/m^2) \sum_{i=1}^m \Theta^i_{jj}$ be its variance. Set the $z$-score $Z_j = {\widehat{\beta}_j}/\sqrt{\Theta_j}$ for testing $H_{0,j}$. Note that $Z_j \sim \mathcal{N}(0, 1)$ marginally when $\beta_j^1 = \cdots \beta^m_j = 0$. Ignoring the correlations, we apply the BHq procedure directly to the $p$-values derived from the $z$-scores. We simply call this OLS for convenience hereafter.
For the Lasso, we take the following approach. Given data $(\X^i, \y^i)$, we compute the Lasso estimates in parallel
\[
\widehat{\bm \beta}_{\text{Lasso}}^i = \argmin_{\bm b \in \mathbb{R}^p} ~ \frac{1}{2} \|\y^i - \X^i \bm b\|_2^2 + \lambda_i \|\bm b\|_1,
\]
where $\lambda_i \geq 0$ is a regularization parameter and is often selected by cross-validation. In particular, we choose the largest value of $\lambda_i$ such that the cross-validation error is within one standard error of the minimum. For each $i$, the support set of $\widehat{\bm \beta}_{\text{Lasso}}^i$ is sent to the center and a majority vote is applied to determine whether to accept $H_{0,j}$ or not.
To compare these methods, we consider a correlated design as an illustration. Let $p = 500, n_i = 1500$, and $m = 5$. To generate the rows $\X^i_j$, we set $\Sigma_{ij} = 1$ if $i = j$ and $\Sigma_{ij} = -0.3/(0.3 \cdot (p-2) + 1)$ otherwise. Fix the sparsity level $k = 100$ and signal strength $A = 5 \sqrt{2 \log p}$. In this setting, while the powers of these procedures are essentially 1, their behavior in FDP shown in Table \ref{fdp_table} is very distinct.
\begin{center}
\begin{tabular}{lcc}
\toprule
& Mean of FDP & SD of FDP \\
\midrule
Knockoff Aggregation & 0.1774 & 0.0493 \\
OLS & 0.1433 & 0.1260 \\
Lasso & 0.3458 & 0.0405 \\
\bottomrule
\end{tabular}
\captionof{table}{FDP of knockoff aggregation, OLS and Lasso.}
\label{fdp_table}
\end{center}
The Lasso with a cross-validated penalty lacks a guarantee of FDR control (see e.g. \cite{lassoFDR}). In the case of correlated designs, its empirical FDR $0.3458$ is way higher than the nominal level $q = 0.20$. Despite the fact that we choose a sparser model in cross-validation, Lasso still tends to select more variables than necessary. In terms of controlling false discoveries, the Lasso does not give a satisfactory solution. In contrast, the mean FDP of the knockoff aggregation and that of the OLS are both under the nominal level, though the former is slightly higher than the latter.
However, more importantly, as shown in Figure~\ref{hist_fdp}, the FDPs of the knockoff aggregation are tightly concentrated around the nominal level, while those of the OLS are widely spread---sometimes the proportions of false discoveries can be as high as 70\% for the OLS. For information, the estimated standard deviation of the knockoff FDP is 0.0493, while, in stark contrast, that of the OLS FDP is 0.1260---almost 3 times higher. Such high variability is undesirable in practice. Researchers would not like to take the risk of having 70\% false discoveries in any study.
\begin{figure}[!h]
\centering
\makebox[\textwidth][c]{\includegraphics[width=1.2\textwidth, height = 0.3\textwidth]{hist_corr.eps}}%
\vspace{-0.1in}
\caption{Histogram of the FDPs by knockoff aggregation, OLS, and Lasso with 200 replicates. $m = 5, p = 500$, and $n_i = 1500$. Sparsity level $k = 100$ and signal strength $A = 5\sqrt{2 \log p}$.}
\label{hist_fdp}
\end{figure}
|
{'timestamp': '2015-11-10T02:25:10', 'yymm': '1506', 'arxiv_id': '1506.05446', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05446'}
|
arxiv
|
\section{Introduction}
Let $\mathbb{F}_{p^{n}}$ be a finite field with $p^{n}$ elements,
where $p$ is a prime and $n$ is a positive integer. A polynomial
$f(x)\in\mathbb{F}_{p^{n}}[x]$ is called a permutation polynomial
(PP) if the associated mapping $f:c\mapsto f(c)$ from
$\mathbb{F}_{p^{n}}$ to itself is a bijection. PPs have been intensively studied in recent years due to
their important applications in cryptography, coding theory and combinatorial design theory (see \cite{Ding06,D99,L07,QTTL13,ST05}
and the references therein). For instance, Ding et al. \cite{Ding06} constructed a family of skew Hadamard difference sets via the Dickson PP of order five, which disproved the longstanding conjecture on skew Hadamard difference sets. Some recent progress on PPs can be found in
\cite{AGW11,DQWYY15,DXYY09,FH12,H15,HX05,H11,H12,LHT13,YD07,YDWP08,ZH12}.
A polynomial $f(x)\in\mathbb{F}_{p^{n}}[x]$ is called a complete
permutation polynomial (CPP) if both $f(x)$ and $f(x)+x$ are
permutations of $\mathbb{F}_{p^{n}}$. These polynomials were
introduced by Niederreiter and Robinson in \cite{NR82}. The simplest
polynomials are monomials, and for a positive integer $d$ and
$\alpha\in\mathbb{F}_{p^{n}}^{*}$, the monomial $\alpha x^{d}$ over
$\mathbb{F}_{p^{n}}$ is a CPP if and only if
$\textup{gcd}(d,q-1)=1$ and $\alpha x^{d}+x$ is a PP. We call such an integer
$d$ a CPP exponent over $\mathbb{F}_{p^{n}}$. Recently, Charpin and
Kyureghyan \cite{CK08} proved that $2^{k}+2$ is a CPP exponent over
$\mathbb{F}_{2^{2k}}$ for odd $k$. In \cite{TZHL}, a class of CPP
exponents over $\mathbb{F}_{2^{n}}$ of Niho type was given. Two new
classes of CPP exponents and a multinomial CPPs were proposed in
\cite{WLHZ}. Further results about CPPs can be found in
\cite{TZH14,WLHZ14,Z}.
In this paper, we construct four classes of monomial CPPs, one class of trinomial CPPs and two classes of permutation trinomials as follows:
\begin{enumerate}
\item Let $p$ be an odd prime, $r+1=p$ and $d=\frac{p^{rk}-1}{p^{k}-1}+1.$
Then $a^{-1}x^{d}$ is a CPP over $\mathbb{F}_{p^{rk}}$, where $a\in
\mathbb{F}_{p^{rk}}^{*}$ such that $a^{p^{k}-1}=-1$.
\item Let $n=6k$, where $k$ is a positive integer with $\textup{gcd}(k,3)=1$.
Then $d=2^{4k-1}+2^{2k-1}$ is a CPP exponent over $\mathbb{F}_{2^{n}}$. To be specific,
$a^{-1}x^{d}$ is a CPP over $\mathbb{F}_{2^{n}}$, where $a\in\{\omega^{t(2^{2k}-1)}|0< t\leq 2^{2k}+2^{4k},\ 3\nmid t\}.$
\item Let $n=4k$. Then $d=(1+2^{2k-1})(1+2^{2k})+1$ is a CPP exponent over $\mathbb{F}_{2^{n}}$.
To be specific, if $a$ is a non-cubic element of $\mathbb{F}_{2^{2k}}^{*}$, then $a^{-1}x^{d}$ is a CPP over $\mathbb{F}_{2^{n}}$.
\item Let $p$ be an odd prime and $n=4k$. Then $d=\frac{p^{4k}-1}{2}+p^{2k}$ is a CPP exponent over
$\mathbb{F}_{p^{n}}$. To be specific, $a^{-1}x^{d}$ is a CPP over $\mathbb{F}_{p^{n}}$, where $a\in\{\omega^{t(p^{2k}-1)+\frac{p^{2k}-1}{2}}:\,0\leq t\leq p^{2k}\}.$
\item For any odd prime $p$,
$f(x)=-x+x^{\frac{p^{2m}+1}{2}}+x^{\frac{p^{2m}+1}{2}p^m}$ is a CPP
over $\mathbb{F}_{p^{3m}}$.
\item Let $m>1$ be an odd integer, and write $k=\frac{m+1}{2}.$ Then for each $u\in\mathbb{F}_{2^m}^{*}$,
$f(x)=x+u^{2^{k-1}-1}x^{2^k-1}+u^{2^{k-1}}x^{2^k+1}$ is a PP over
$\mathbb{F}_{2^m}$.
\item Let $m>1$ be an odd integer such that $m=2k-1.$ Then
$f(x)=x+ux^{2^k-1}+u^{2^k}x^{2^m-2^{k+1}+2}, u\in
\mathbb{F}_{2^m}^{*},$ is a PP over
$\mathbb{F}_{2^m}$.
\end{enumerate}
The first class is a conjecture made by Wu et al. \cite{WLHZ}, and our main technique is using the AGW Criterion \cite{AGW11}. By using the additive characters over the underlying finite fields \cite{TZH14}, we give three other new classes (Class 2--Class 4) of monomial CPPs over finite fields. Classes 5, 6 and 7 are explicit constructions of PPs and CPPs through the study of the number of solutions of special equations \cite{DQWYY15,dobb}.
Functions with a low differential uniformity are interesting from
the viewpoint of cryptography as they provide good resistance to
differential attack. In \cite{BCC}, the authors
considered the differential properties of power functions and
proposed the following conjecture.
\begin{conjecture}{\rm\cite{BCC}}\label{conjecture2}
Let $n=2m$ with $m$ odd. Let $F_{d}:x\rightarrow x^d $ be the power PPs over $\mathbb{F}_{2^n}$ defined by the following
values of $d$:
\begin{enumerate}
\item[(1)] $d=2^m+2^{(m+1)/2}+1,$
\item[(2)] $d=2^{m+1}+3.$
\end{enumerate}
Then, for these values of $d$, $F_d$ is differentially 8-uniform and
all values $0,2,4,6,8$ appear in its differential spectrum.
\end{conjecture}
To determine the exact value of differential uniformity is a
difficult problem. In this paper, we make some progress towards Conjecture~\ref{conjecture2}, and prove that the differential uniformities of these
polynomials are at most $10$.
This paper is organized as follows. In Section~\ref{preliminaries}, we introduce some basic notations and related results. In Section~\ref{monomial}, four classes of monomial CPPs are given. In Section~\ref{trinomial cpp}, we give a class of trinomial CPPs. Two classes of PPs are presented in Section~\ref{trinomial pp}. Section~\ref{section6} investigates the differential properties of monomial PPs. Section~\ref{conclusion} concludes the paper.
\section{Preliminaries}\label{preliminaries}
The following notations are fixed throughout this paper.
\begin{itemize}
\item Let $p$ be a prime, $n$ be an integer, and $\mathbb{F}_{p^{n}}$ be the finite field of order $p^{n}$.
\item Let $\textup{Tr}_{r}^{n}\ :\ \mathbb{F}_{p^{n}}\mapsto\mathbb{F}_{p^{r}}$ be the trace mapping defined by
$$\textup{Tr}_{r}^{n}(x)=x+x^{p^{r}}+x^{p^{2r}}+\cdots+x^{p^{n-r}},$$
where $r|n$. For $r=1$, we get the absolute trace function mapping onto the prime field $\mathbb{F}_{p}$, which is denoted by $\textup{Tr}_{n}$.
\item Let $\textup{N}_{r}^{n}\ :\ \mathbb{F}_{p^{n}}\mapsto\mathbb{F}_{p^{r}}$ be the norm mapping defined by
$$\textup{N}_{r}^{n}(x)=xx^{p^{r}}x^{p^{2r}}\cdots x^{p^{n-r}},$$
where $r|n$. For $r=1$, we get the absolute norm function mapping onto the prime field $\mathbb{F}_{p}$, which is denoted by $\textup{N}_{n}$.
\item Let $\zeta_{p}=\textup{exp}(2\pi\sqrt{-1}/p)$ be a $p$-th root of unity, and $\chi_{n}(x)=\zeta_{p}^{\textup{Tr}_{n}(x)}$ be the canonical additive character on $\mathbb{F}_{p^{n}}$.
\end{itemize}
We first recall a criterion for PPs which can be given by using additive characters over the underlying finite field.
\begin{lemma}{\rm\cite{LN83}}
A mapping $f:\mathbb{F}_{p^{n}}\mapsto\mathbb{F}_{p^{n}}$ is a PP if and only if for every $\alpha\in\mathbb{F}_{p^{n}}^{*}$,
$$\sum_{x\in\mathbb{F}_{p^{n}}}\chi_{n}(\alpha f(x))=0.$$
\end{lemma}
Let $n,r,k$ be integers such that $n=rk$. For any $a\in
\mathbb{F}_{p^n}$, let $a_i=a^{p^{ik}}$, where $0\leq i\leq r-1$. Define
$$h_{a}(x)=x\prod_{i=0}^{r-1}(x+a_i).$$
Then we have the following lemma.
\begin{lemma}{\rm\label{hx}\cite{WLHZ}}
Let $n=rk$, and $d=\frac{p^{rk}-1}{p^{k}-1}+1$. Then $x^{d}+ax\in\mathbb{F}_{p^{n}}[x]$ is a PP over $\mathbb{F}_{p^{n}}$ if and only if $h_{a}(x)\in\mathbb{F}_{p^{k}}[x]$ is a PP over $\mathbb{F}_{p^{k}}$.
\end{lemma}
The following lemmas will also be needed in the following sections.
\begin{lemma}{\rm{\cite{AGW11}}$(${\bf AGW Criterion}$)$}\label{awg}
Let $A, S$ and $\overline{S}$ be finite sets with
$\#S=\#\overline{S}$, and let $f:A\rightarrow A,$ $h:S\rightarrow
\overline{S},$ $\lambda:A\rightarrow S,$ and
$\overline{\lambda}:A\rightarrow \overline{S}$ be maps such that
$\overline{\lambda}\circ f=h\circ\lambda.$ If both $\lambda$ and
$\overline{\lambda}$ are surjective, then the following statements
are equivalent:
\begin{enumerate}
\item $f$ is bijective;
\item $h$ is bijective from $S$ to $\overline{S}$ and $f$ is injective on $\lambda^{-1}(s)$ for each $s\in S$.
\end{enumerate}
\end{lemma}
\begin{lemma}\label{cpplem1}{\rm\cite{LN83}}
Let $p$ be an odd prime, and let $m,k$ be positive integers such
that $\frac{m}{\textup{gcd}(m,k)}$ is odd. Then $x^{p^k}+x$ is a
permutation on $\mathbb{F}_{p^m}$.
\end{lemma}
\begin{lemma}\label{lempp1}{\rm\cite{LN83}}
An irreducible polynomial over $\mathbb{F}_q$ of degree $n$ remains irreducible over $\mathbb{F}_{q^k}$ if and only if $\textup{gcd}(k,n)=1$.
\end{lemma}
\section{Four classes of monomial CPPs}\label{monomial}
\subsection{The first class of monomial CPPs}
In this subsection, we will prove the conjecture of Wu et al. \cite{WLHZ}. Before proving it, we establish the following useful lemma.
\begin{lemma}\label{clem}
Let $p$ be an odd prime and $k$ be a positive integer. Then $f(x)=x(x^2-c)^{\frac{p-1}{2}}$ is a PP over $\mathbb{F}_{p^{k}}$, where $c$ is a non-square element in $\mathbb{F}_{p^{k}}$.
\end{lemma}
\begin{proof}
We first show that $x=0$ is the only solution to $f(x)=0$. If $f(x)=0$, then $x=0$ or $(x^2-c)^{\frac{p-1}{2}}=0$. If $(x^2-c)^{\frac{p-1}{2}}=0$, then $c=x^2$, which leads to a contradiction since $c$ is a non-square element. Therefore $f(x)=0$ if and only if $x=0$.
Next, we prove that $f(x)=a$ has a unique nonzero solution for each nonzero $a\in\mathbb{F}_{p^{k}}$. Let $\lambda(x)=x^2-c$, $\overline{\lambda}(x)=x^2$ and $h(x)=(x+c)x^{p-1}$. Then it is easy to see that the following diagram commutes:
\begin{center}
$\begin{array}[c]{ccc}
\mathbb{F}_{p^{k}}^{*}&\stackrel{\lambda}{\rightarrow}&\lambda(\mathbb{F}_{p^{k}}^{*})\\
\downarrow\scriptstyle{f}&&\downarrow\scriptstyle{h}\\
\mathbb{F}_{p^{k}}^{*}&\stackrel{\overline{\lambda}}{\rightarrow}&\overline{\lambda}(\mathbb{F}_{p^{k}}^{*}).
\end{array}$
\end{center}
By Lemma \ref{awg}, it suffices to prove that $h$ is bijective and $f$ is injective on $\lambda^{-1}(s)$ for each $s\in \lambda(\mathbb{F}_{p^{k}}^{*})$. Since for each $s\in \lambda(\mathbb{F}_{p^{k}}^{*})$, $\lambda^{-1}(s)=\{\pm(c+s)^{\frac{1}{2}}\}$, and $f((c+s)^{\frac{1}{2}})\neq f(-(c+s)^{\frac{1}{2}})$, it implies that $f$ is injective on $\lambda^{-1}(s)$ for each $s\in \lambda(\mathbb{F}_{p^{k}}^{*})$.
In the following, we will verify that $h$ is bijective. Since $\#\lambda(\mathbb{F}_{p^{k}}^{*})=\#\overline{\lambda}(\mathbb{F}_{p^{k}}^{*})$, we only need to show that $h$ is injective. For any $b\in \overline{\lambda}(\mathbb{F}_{p^{k}}^{*})$, $b$ is a square element in
$\mathbb{F}_{p^k}^{*}$. We assume
\begin{equation}\label{eq:conj1}
x^p+cx^{p-1}=b
\end{equation}
has at least two distinct solutions. Setting $y=\frac{1}{x}$, the equation
\begin{equation}\label{eq:conj2}
y^p-\frac{c}{b}y-\frac{1}{b}=0
\end{equation}
has at least two distinct solutions. Assume $y_1,$ $y_2$ are two distinct solutions of Eq. (\ref{eq:conj2}). Then $y_1-y_2$ is a root of
$y^p-\frac{c}{b}y=0$, and so must be a root of $y^{p-1}-\frac{c}{b}=0.$ It
follows that $\frac{c}{b}=y_0^{p-1}$ for some $y_0\in \mathbb{F}_{p^k}$,
which is impossible since $\frac{c}{b}$ is a non-square element in $\mathbb{F}_{p^k}$.
Hence Eq. (\ref{eq:conj1}) has at most one solution in $\lambda(\mathbb{F}_{p^{k}}^{*}).$
Therefore, $h(x)$ is bijective. This completes the proof.
\end{proof}
Now we can prove the following result, which is a conjecture made by Wu et al. \cite{WLHZ}.
\begin{theorem}[\cite{WLHZ} Conjecture 4.20]
Let $p$ be an odd prime, $r+1=p$ and $d=\frac{p^{rk}-1}{p^{k}-1}+1.$
Then $a^{-1}x^{d}$ is a CPP over $\mathbb{F}_{p^{rk}}$, where $a\in
\mathbb{F}_{p^{rk}}^{*}$ such that $a^{p^{k}-1}=-1$.
\end{theorem}
\begin{proof}
Since $\textup{gcd}(p^{rk}-1,d)=1$, the monomial $x^d$ is a PP over $\mathbb{F}_{p^{rk}}$.
Note that $a^{p^k-1}=-1$. Then $a^{p^k}=-a$ and $(a^2)^{p^k-1}=1$.
By Lemma \ref{hx}, to prove the conjecture we only need to show that
$h_{a}(x)=x(x^2-a^2)^{\frac{p-1}{2}}$ is a PP over
$\mathbb{F}_{p^{k}}$ for any $k$. Let $c=a^2\in\mathbb{F}_{p^k}.$
Then $c$ is a non-square element in $\mathbb{F}_{p^k}$ since
$a\not\in \mathbb{F}_{p^k}$. Hence the result follows from Lemma
\ref{clem}.
\end{proof}
\subsection{The second class of CPPs}
In this subsection, let $p=2$ and $n=6k$ for some integer $k$
satisfying $\textup{gcd}(k,3)=1$, and $\omega$ be a fixed primitive
element of $\mathbb{F}_{2^{6k}}$. We will show that
$d=2^{4k-1}+2^{2k-1}$ is a CPP exponent over $\mathbb{F}_{2^{6k}}$.
We define the following set
\begin{equation}\label{eqn_S}
S:=\{\omega^{t(2^{2k}-1)}|0< t\leq 2^{2k}+2^{4k},\ 3\nmid t\}.
\end{equation}
\begin{lemma}\label{4.1}
For each $a\in S$, $\textup{Tr}_{2k}^{6k}(a)\neq1$.
\end{lemma}
\begin{spacing}{1.2}
\begin{proof}
If $a\in S\bigcap\mathbb{F}_{2^{2k}}$, then $\textup{Tr}_{2k}^{6k}(a)=a\neq1$. So we assume that $a\in S\backslash\mathbb{F}_{2^{2k}}$ below.
Since $3|(2^{2k}-1)$, there exists $b\in \mathbb{F}_{2^{6k}}\backslash\mathbb{F}_{2^{2k}}$ such that $b^{3}=a$.
We observe that $\textup{N}_{2k}^{6k}(a)=1$ by the definition of $S$, so $\eta:=\textup{N}_{2k}^{6k}(b) \in\mathbb{F}_{4}^*$.
Here, $\eta\neq1$, again by the definition of $S$.
Let $B(x)=x^{3}+B_{1}x^{2}+B_{2}x+B_{3}\in\mathbb{F}_{2^{2k}}[x]$ be the
minimal polynomial of $b$ over $\mathbb{F}_{2^{2k}}$. Then $B(x)$ is
irreducible over $\mathbb{F}_{2^{2k}}$, $B_1=\textup{Tr}_{2k}^{6k}(b)$ and $B_{3}=\eta$.
We can directly verify that
\begin{equation}\label{eqn_tr}
\textup{Tr}_{2k}^{6k}(a)=\textup{Tr}_{2k}^{6k}(b^{3})=B_{1}^{3}+B_{1}B_{2}+B_{3}.
\end{equation}
If $B_{1}=0$, then $\textup{Tr}_{2k}^{6k}(a)=B_{3}=\eta\neq1$, and the claim follows.
We assume that $B_{1}\ne 0$ below. Assume to the contrary that
$\textup{Tr}_{2k}^{6k}(a)=1$. Then Eq. \eqref{eqn_tr} gives that
$B_{2}=\frac{B_{1}^{3}+\eta^{2}}{B_{1}}$, and we have
\begin{align*}
B(x)&=x^{3}+B_{1}x^{2}+B_{2}x+B_{3} \\
&=x^{3}+B_{1}x^{2}+\frac{B_{1}^{3}+\eta^{2}}{B_{1}}x+B_{3} \\
&=(\eta x+B_{1})(\eta^{2}x^{2}+B_{1}x+\frac{\eta}{B_{1}}),
\end{align*}
contradicting to the fact that $B(x)$ is irreducible over $\mathbb{F}_{2^{2k}}$. This completes the proof.
\end{proof}
\end{spacing}
\begin{lemma}\label{4.2}
Fix an integer $k$ with $\textup{gcd}(k,3)=1$. Suppose $n=6k$ and $d=2^{4k-1}+2^{2k-1}$. If $v\in S$, then
$$\sum_{x\in\mathbb{F}_{2^{6k}}}\chi_{6k}(x^{d}+vx)=0.$$
\end{lemma}
\begin{proof}
Let $a$ be a primitive element of $\mathbb{F}_{8}$ with
$a^{3}+a+1=0.$ Since $\textup{gcd}(k,3)=1$, we have
$\mathbb{F}_{2^{6k}}=\mathbb{F}_{2^{2k}}(a)$. For any
$x\in\mathbb{F}_{2^{6k}}$, it can be expressed as
$$x=x_{0}+x_{1}a+x_{2}a^{2},$$
where $x_{0},x_{1},x_{2}\in\mathbb{F}_{2^{2k}}$.
Since $\textup{gcd}(k,3)=1$, we first consider the case $k\equiv1\pmod{3}$, in which $a^{2^{2k}}=a^{4}$. The first step is to compute a direct representation of $\textup{Tr}_{n}(x^{d})$ as a function of $x_{0},x_{1}$ and $x_{2}$. Note that
$\textup{Tr}_{2k}^{6k}(a)=\textup{Tr}_{2k}^{6k}(a^{2})=0$ and $\textup{Tr}_{2k}^{6k}(1)=1$. A routine computation shows that
$$\textup{Tr}_{6k}(x^{d})=\textup{Tr}_{2k}(x_{0}+x_{1}+x_{2}+x_{1}x_{2}).$$
Next, putting
$$v=v_{0}+v_{1}a+v_{2}a^{2}$$
with $v_{0},v_{1},v_{2} \in \mathbb{F}_{2^{2k}}$, we find that
$$\textup{Tr}_{6k}(vx)=\textup{Tr}_{2k}(v_{0}x_{0}+v_{1}x_{2}+v_{2}x_{1}).$$
Consequently,
$$\sum_{x\in\mathbb{F}_{2^{6k}}}\chi_{6k}(x^{d}+vx)=\sum_{x_{1},x_{2}\in\mathbb{F}_{2^{2k}}}\chi_{2k}(x_{1}+x_{2}+x_{1}x_{2}+v_{1}x_{2}+v_{2}x_{1})
\sum_{x_{0}\in\mathbb{F}_{2^{2k}}}\chi_{2k}(x_{0}+v_{0}x_{0}).$$
From Lemma \ref{4.1} we get $v_{0}\neq1$. Therefore, $\sum_{x\in\mathbb{F}_{2^{6k}}}\chi_{6k}(x^{d}+vx)=0.$
For the remaining case $k\equiv2\pmod{3}$, a similar discussion leads to $\sum_{x\in\mathbb{F}_{2^{6k}}}\chi_{6k}(x^{d}+vx)=0.$
\end{proof}
\begin{theorem}
Let $n=6k$, where $k$ is a positive integer with $\textup{gcd}(k,3)=1$.
Then $d=2^{4k-1}+2^{2k-1}$ is a CPP exponent over $\mathbb{F}_{2^{n}}$. To be specific,
if $a\in S$ with $S$ defined as in \eqref{eqn_S}, then $a^{-1}x^{d}$ is a CPP over $\mathbb{F}_{2^{n}}$.
\end{theorem}
\begin{proof}
Since $\textup{gcd}(d,2^{6k}-1)=1$, we have $x^{d}$ is a PP over
$\mathbb{F}_{2^{6k}}$. In what follows we prove that $x^{d}+ax$ is
also a PP over $\mathbb{F}_{2^{6k}}$. We only need to prove that for
each $\alpha\in\mathbb{F}_{2^{6k}}^{*}$,
$$\sum_{x\in\mathbb{F}_{2^{6k}}}\chi_{6k}(\alpha(x^{d}+ax))=0,$$
where $a\in S$. Since $\textup{gcd}(d,2^{6k}-1)=1$, each nonzero $\alpha\in\mathbb{F}_{p^{6k}}$ can be written as $\alpha=\beta^{d}$ for a unique $\beta\in\mathbb{F}_{2^{6k}}^{*}$, and we have
\begin{align*}
\sum_{x\in\mathbb{F}_{2^{6k}}}\chi_{6k}(\alpha(x^{d}+ax))&=\sum_{x\in\mathbb{F}_{2^{6k}}}\chi_{6k}((\beta x)^{d}+\beta^{d-1}a\beta x) \\
&=\sum_{x\in\mathbb{F}_{2^{6k}}}\chi_{6k}(x^{d}+\beta^{d-1}ax) \\
&=\sum_{x\in\mathbb{F}_{2^{6k}}}\chi_{6k}(x^{d}+\beta^{2^{4k-1}+2^{2k-1}-1}ax).
\end{align*}
Since $\beta^{2^{4k-1}+2^{2k-1}-1}a\in S$, it follows from Lemma
\ref{4.2} that for each $\alpha\in\mathbb{F}_{2^{6k}}^{*}$, we have
$$\sum_{x\in\mathbb{F}_{2^{6k}}}\chi_{6k}(\alpha(x^{d}+ax))=0.$$
This completes the proof.
\end{proof}
\subsection{The third class of monomial CPPs}
In this subsection, let $p=2$ and $n=4k$. We will use an analysis similar to that of the previous subsection to show that $d=(1+2^{2k-1})(1+2^{2k})+1$ is a CPP exponent over $\mathbb{F}_{2^{4k}}$.
\begin{lemma}\label{3.1}
If $v$ is a non-cubic element of $\mathbb{F}_{2^{2k}}^{*}$, then
$$\sum_{x\in\mathbb{F}_{2^{4k}}}\chi_{4k}(x^{(1+2^{2k-1})(1+2^{2k})+1}+vx)=0.$$
\end{lemma}
\begin{proof}
Using polar coordinate representation, every nonzero element $x$ of $\mathbb{F}_{2^{4k}}$ can be uniquely represented as $x=yz$ with $y\in U$ and $z\in \mathbb{F}_{2^{2k}}^{*}$, where $U=\{\lambda\in\mathbb{F}_{2^{4k}}| \lambda^{2^{2k}+1}=1\}.$ Then
\begin{align*}
\sum_{x\in\mathbb{F}_{2^{4k}}}\chi_{4k}(x^{(1+2^{2k-1})(1+2^{2k})+1}+vx)&=1+\sum_{x\in\mathbb{F}_{2^{4k}}^{*}}\chi_{4k}(x^{(1+2^{2k-1})(1+2^{2k})+1}+vx) \\
&=1+\sum_{y\in U}\sum_{z\in\mathbb{F}_{2^{2k}}^{*}}\chi_{4k}((yz)^{(1+2^{2k-1})(1+2^{2k})+1}+vyz)\\
&=-2^{2k}+\sum_{y\in U}\sum_{z\in\mathbb{F}_{2^{2k}}}\chi_{4k}(yz^{4}+vyz)\\
&=-2^{2k}+\sum_{y\in U}\sum_{z\in\mathbb{F}_{2^{2k}}}\chi_{2k}(\textup{Tr}_{2k}^{4k}(yz^{4}+vyz))\\
&=-2^{2k}+\sum_{y\in U}\sum_{z\in\mathbb{F}_{2^{2k}}}\chi_{2k}((y+y^{2^{2k}})z^{4}+(y+y^{2^{2k}})vz)\\
&=-2^{2k}+\sum_{y\in U}\sum_{z\in\mathbb{F}_{2^{2k}}}\chi_{2k}(z^{4}(y+y^{2^{2k}}+y^{4}v^{4}+y^{2^{2k+2}}v^{4}))\\
&=(N(v)-1)2^{2k},
\end{align*}
where $N(v)$ denotes the number of $y$'s in $U$ such that $y+y^{2^{2k}}+y^{4}v^{4}+y^{2^{2k+2}}v^{4}=0$, which is equivalent to
$$y+y^{-1}+y^{4}v^{4}+y^{-4}v^{4}=0,$$
that is,
$$(y+y^{-1})[1+v^{4}(y+y^{-1})^{3}]=0.$$
Since $v$ is a non-cubic element of $\mathbb{F}_{2^{2k}}^{*}$, we
get $1+v^{4}(y+y^{-1})^{3}\neq0$. Hence $y=1$ is the unique root.
Thus $N(v)=1$, and this completes the proof.
\end{proof}
\begin{theorem}
Let $n=4k$. Then $d=(1+2^{2k-1})(1+2^{2k})+1$ is a CPP exponent over $\mathbb{F}_{2^{n}}$.
To be specific, if $a$ is a non-cubic element of $\mathbb{F}_{2^{2k}}^{*}$, then $a^{-1}x^{d}$ is a CPP over $\mathbb{F}_{2^{n}}$.
\end{theorem}
\begin{proof}
It can be verified that $\textup{gcd}(d,2^{4k}-1)=1$. Thus, it suffices to prove that $x^{d}+ax$ is a PP for a non-cubic $a\in\mathbb{F}_{2^{2k}}^{*}$. Since each nonzero $\alpha\in\mathbb{F}_{2^{4k}}$ can be written as $\alpha=\beta^{d}$ for a unique $\beta\in\mathbb{F}_{2^{4k}}^{*}$, we have
\begin{align*}
\sum_{x\in\mathbb{F}_{2^{4k}}}\chi_{4k}(\alpha(x^{d}+ax))&=\sum_{x\in\mathbb{F}_{2^{4k}}}\chi_{4k}((\beta x)^{d}+\beta^{d-1}a\beta x) \\
&=\sum_{x\in\mathbb{F}_{2^{4k}}}\chi_{4k}(x^{d}+\beta^{d-1}ax) \\
&=\sum_{x\in\mathbb{F}_{2^{4k}}}\chi_{4k}(x^{d}+\beta^{(1+2^{2k-1})(1+2^{2k})}ax).
\end{align*}
Note that $\beta^{(1+2^{2k-1})(1+2^{2k})}a$ is also a non-cubic element of
$\mathbb{F}_{2^{2k}}^{*}$. For each $\alpha\in\mathbb{F}_{2^{4k}}^{*}$, we have
$$\sum_{x\in\mathbb{F}_{2^{4k}}}\chi_{4k}(\alpha(x^{d}+ax))=0,$$
by Lemma \ref{3.1}. This completes the proof.
\end{proof}
\subsection{The fourth class of monomial CPPs}
In this subsection, we study the fourth class of monomial CPPs, where $p$ is an odd prime, $n=4k$ and $d=\frac{p^{4k}-1}{2}+p^{2k}$. Let $\omega$ be a fixed primitive element of $\mathbb{F}_{p^{n}}$. Denote the conjugate of $x$ over $\mathbb{F}_{p^{n}}$ by $\overline{x}$, i.e. $\overline{x}=x^{p^{2k}}$. We also define the set
$S$ as follows:
\begin{equation}\label{eqn_S34}
S:=\{\omega^{t(p^{2k}-1)+\frac{p^{2k}-1}{2}}:\,0\leq t\leq p^{2k}\}.
\end{equation}
We first recall two lemmas.
\begin{lemma}\rm{\cite{H76}\label{2.1}}
Let $p$ be an odd prime and $d|p^{n}-1$. Let $s$ be the least positive integer
such that $d|p^{s}+1$. For each $0\leq j<d$, define the set
\[
C_{j}:=\{\omega^{di+j}\in\mathbb{F}_{p^{n}}^{*}|0\leq i<\frac{p^{n}-1}{d}\}.
\]
\begin{enumerate}
\item In the case $d$ is an even integer, and both $(p^{s}+1)/d$ and $d/2s$ are odd integers,
we have
\[\sum_{x\in\mathbb{F}_{p^{n}}}\chi_{n}(ax^{d})=\begin{cases}p^{n};&\textup{ if } a=0,\\
(-1)^{\frac{n}{2s}+1}(d-1)p^{\frac{n}{2}};&\textup{ if }a\in C_{\frac{d}{2}},\\
(-1)^{\frac{n}{2s}}p^{\frac{n}{2}};&\textup{ if }a\not\in C_{\frac{d}{2}}.\end{cases}\]
\item In all the other cases, we get
\[\sum_{x\in\mathbb{F}_{p^{n}}}\chi_{n}(ax^{d})=\begin{cases}p^{n};&\textup{ if } a=0,\\
(-1)^{\frac{n}{2s}+1}(d-1)p^{\frac{n}{2}};&\textup{ if }a\in C_{0},\\
(-1)^{\frac{n}{2s}}p^{\frac{n}{2}};&\textup{ if }a\not\in C_{0}.\end{cases}\]
\end{enumerate}
\end{lemma}
\begin{lemma}\rm{\cite{H76}\label{2.2}}
Let $d$ be an integer with $\textup{gcd}(d,p^{n}-1)=1$. Suppose that there exists an integer $i$
such that $0\leq i<n$ and $(d-p^{i})|(p^{n}-1)$. Choose an integer $N$ such that $(d-p^{i})N\equiv0\pmod{p^{n}-1}$. Then
$$\sum_{x\in\mathbb{F}_{p^{n}}}\chi_{n}(x^{d}+ax)=\frac{1}{N}\sum_{j=0}^{N-1}\sum_{y\in\mathbb{F}_{p^{n}}}\chi_{n}(y^{N}(a\omega^{j}+\omega^{djp^{-i}})).$$
\end{lemma}
As a preparation, we have the following lemmas.
\begin{lemma}\label{2.3}
If $a\in S$ with $S$ defined as in \eqref{eqn_S34}, then $\frac{a+1}{a-1}=\omega^{2s}$ for some integer $s$.
\end{lemma}
\begin{proof}
Assume to the contrary that $\frac{a+1}{a-1}=\omega^{2s+1}$ for some integer $s$. Since $a\overline{a}=-1$, we have
$$\frac{a+1}{a-1}=\frac{a-a\overline{a}}{a+a\overline{a}}=\frac{1-\overline{a}}{1+\overline{a}}=(\frac{1-a}{1+a})^{p^{2k}}=-\omega^{-(2s+1)p^{2k}}.$$
It follows that
$$\omega^{(2s+1)(p^{2k}+1)}=-1=\omega^{(p^{2k}+1)\frac{p^{2k}-1}{2}},$$
which is a contradiction. So we have $\frac{a+1}{a-1}=\omega^{2s}$
for some integer $s$.
\end{proof}
\begin{lemma}\label{2.4}
Let $p$ be an odd prime, $n=4k$ and $d=\frac{p^{4k}-1}{2}+p^{2k}$. If $a\in S$ with $S$ defined as
in \eqref{eqn_S34}, then $\sum_{x\in\mathbb{F}_{p^{n}}}\chi_{n}(x^{d}+ax)=0$.
\end{lemma}
\begin{proof}
By Lemma \ref{2.2}, we have
\begin{align*}
2\sum_{x\in\mathbb{F}_{p^{n}}}\chi_{n}(x^{d}+ax)&=\sum_{y\in\mathbb{F}_{p^{n}}}\chi_{n}(y^{2}(a+1))+\sum_{y\in\mathbb{F}_{p^{n}}}\chi_{n}(y^{2}(a\omega+\omega^{dp^{2k}})) \\
&=\sum_{y\in\mathbb{F}_{p^{n}}}\chi_{n}(y^{2}(a+1))+\sum_{y\in\mathbb{F}_{p^{n}}}\chi_{n}(y^{2}((a-1)\omega)).
\end{align*}
From Lemma \ref{2.3}, $a-1,\ a+1\in C_{0}$ or $a-1,\ a+1\in C_{1}$. Then a direct application of Lemma \ref{2.1} shows $\sum_{x\in\mathbb{F}_{p^{n}}}\chi_{n}(x^{d}+ax)=0$.
\end{proof}
We now have the following theorem.
\begin{theorem}
Let $p$ be an odd prime and $n=4k$. Then $d=\frac{p^{4k}-1}{2}+p^{2k}$ is a CPP exponent over
$\mathbb{F}_{p^{n}}$. To be specific, if $a\in S$ with $S$ defined as in \eqref{eqn_S34}, then $a^{-1}x^{d}$ is a CPP over $\mathbb{F}_{p^{n}}$.
\end{theorem}
\begin{proof}
Since $\textup{gcd}(d,p^{n}-1)=1$, for each $a\in S$, the monomial $a^{-1}x^{d}$ is a PP over $\mathbb{F}_{p^{n}}$. To finish the proof, it suffices to prove that $x^{d}+ax$ permutes $\mathbb{F}_{p^{n}}$.
The fact $\textup{gcd}(d,p^{n}-1)=1$ shows that each nonzero element $\alpha\in\mathbb{F}_{p^{n}}$ can be represented as $\alpha=\beta^{d}$ for a unique $\beta\in\mathbb{F}_{p^{n}}^{*}$. Then
\begin{align*}
\sum_{x\in\mathbb{F}_{p^{n}}}\chi_{n}(\alpha(x^{d}+ax))&=\sum_{x\in\mathbb{F}_{p^{n}}}\chi_{n}((\beta x)^{d}+\beta^{d-1}a\beta x) \\
&=\sum_{x\in\mathbb{F}_{p^{n}}}\chi_{n}(x^{d}+\beta^{d-1}ax)\\
&=\sum_{x\in\mathbb{F}_{p^{n}}}\chi_{n}(x^{d}+\beta^{(\frac{p^{2k}+1}{2}+1)(p^{2k}-1)}ax).
\end{align*}
Since $\beta^{(\frac{p^{2k}+1}{2}+1)(p^{2k}-1)}a\in S$, it follows
from Lemma \ref{2.4} that for each
$\alpha\in\mathbb{F}_{p^{n}}^{*}$, we have
$$\sum_{x\in\mathbb{F}_{p^{n}}}\chi_{n}(\alpha(x^{d}+ax))=0.$$
This completes the proof.
\end{proof}
\section{A class of trinomial CPPs}\label{trinomial cpp}
In this section, we consider a class of trinomial polynomials and show that they are CPPs.
\begin{theorem}
For any odd prime $p$,
$f(x)=-x+x^{\frac{p^{2m}+1}{2}}+x^{\frac{p^{2m}+1}{2}p^m}$ is a CPP
over $\mathbb{F}_{p^{3m}}$.
\end{theorem}
\begin{proof}
Note that
$$f(x)+x=x^{\frac{p^{2m}+1}{2}}+x^{\frac{p^{3m}+p^m}{2}}=g(x^{\frac{p^{2m}+1}{2}})$$
with $g(x)=x+x^{p^m}$. It follows that $f(x)+x$ is a PP over
$\mathbb{F}_{p^{3m}}$ if and only if $g(x)$ is so, since
$\textup{gcd}(\frac{p^{2m}+1}{2},p^{3m}-1)=1.$ By Lemma
\ref{cpplem1}, $g(x)$ is a PP over $\mathbb{F}_{p^{3m}}$, so $f(x)+x$ is a PP.
In the following, we show that $f(x)$ is a PP over $\mathbb{F}_{p^{3m}}$.
Write $h(x):=x+x^{p^m}-x^{1+p^m-p^{2m}}$, so that $f(x)=h(x^{\frac{p^{2m}+1}{2}})$. Since
$\textup{gcd}(\frac{p^{2m}+1}{2},p^{3m}-1)=1$, $f(x)$ is a PP over
$\mathbb{F}_{p^{3m}}$ if and only if $h(x)$ is a PP over
$\mathbb{F}_{p^{3m}}.$ Note that $h(0)=0$ and for $x\ne 0$,
$$h(x)=\frac{x^{1+p^{2m}}+x^{p^m+p^{2m}}-x^{1+p^m}}{x^{p^{2m}}}.$$
We first prove that $h(x)=0$ if and only if $x=0$. Suppose to the contrary that
$h(x)=0$ for some $x\ne 0$, that is,
$$x^{1+p^{2m}}+x^{p^m+p^{2m}}-x^{1+p^m}=0.$$
Raising the above equation to the $p^m$-th power and the
$p^{2m}$-th power respectively, we obtain
\begin{align*}
x^{1+p^m}+x^{1+p^{2m}}-x^{p^m+p^{2m}}&=0,\\
x^{p^m+p^{2m}}+x^{1+p^m}-x^{1+p^{2m}}&=0.
\end{align*}
Adding the above two equations together, we deduce that $2x^{1+p^m}=0$. So $x=0$,
contradicting to the assumption that $x\in\mathbb{F}_{p^{3m}}^{*}$. Thus $h(x)=0$ if and only if $x=0$.
Next, we prove that $h(x)=a$ has at most one nonzero solution for each $a\in\mathbb{F}_{p^{3m}}^{*}$, that is
\begin{equation}\label{eq:cpp2}
x^{1+p^{2m}}+x^{p^m+p^{2m}}-x^{1+p^m}=ax^{p^{2m}}
\end{equation}
has at most one nonzero solution for each $a\in
\mathbb{F}_{p^{3m}}^{*}.$ Raising both sides of Eq. \eqref{eq:cpp2} to the power of $p^m$ and $p^{2m}$ respectively, we
get
\begin{align*}
x^{1+p^m}+x^{1+p^{2m}}-x^{p^m+p^{2m}}&=a^{p^m}x,\\
x^{p^m+p^{2m}}+x^{1+p^m}-x^{1+p^{2m}}&=a^{p^{2m}}x^{p^m}.
\end{align*}
Adding the above two equations together, we obtain
\begin{equation}\label{eq:cpp5}
2x^{1+p^m}=a^{p^m}x+a^{p^{2m}}x^{p^m}.
\end{equation}
Because $x\neq0$, we have $2x^{p^m}=a^{p^m}+a^{p^{2m}}x^{p^m-1}$.
Setting $y=\frac{1}{x}$, we get
\begin{equation}\label{eq:cpp6}
y^{p^m}+a^{p^{2m}-p^m}y-2a^{-p^m}=0.
\end{equation}
If Eq. \eqref{eq:cpp6} has at least two distinct nonzero
solutions $y_1$, $y_2$ in $\mathbb{F}_{p^{3m}}$ we get $y_1-y_2\in
\mathbb{F}_{p^{3m}}$ is a root of $y^{p^m}+a^{p^{2m}-p^m}y=0$, and
so a root of $y^{p^m-1}+a^{p^{2m}-p^m}=0,$ contradicting to the fact
that $y^{p^m-1}+a^{p^{2m}-p^m}=0$ has no solution in
$\mathbb{F}_{p^{3m}}^{*}.$ Therefore, Eq. \eqref{eq:cpp6} has
at most one nonzero solution in $\mathbb{F}_{p^{3m}}.$ Hence
$h(x)=a$ has at most one nonzero solution for each nonzero $a\in
\mathbb{F}_{p^{3m}}$.
To sum up, we have shown that $h(x)$ is a PP, and thus $f(x)$ is a PP. The proof is now complete.
\end{proof}
\section{Two classes of trinomial PPs}\label{trinomial pp}
It looks difficult to give a simple characterization of trinomial PPs over finite fields. In \cite{DQWYY15}, the authors use different tricks including the multivariate method introduced by Dobbertin \cite{dobb,D99} to construct several classes of trinomial PPs. In this section, we construct two classes of trinomial PPs over $\mathbb{F}_{2^m}$ by similar techniques.
\begin{theorem}
Let $m>1$ be an odd integer, and write $k=\frac{m+1}{2}.$ Then for each $u\in\mathbb{F}_{2^m}^{*}$,
$f(x)=x+u^{2^{k-1}-1}x^{2^k-1}+u^{2^{k-1}}x^{2^k+1}$ is a PP over
$\mathbb{F}_{2^m}$.
\end{theorem}
\begin{proof}
Since $\textup{gcd}(2,2^m-1)=1$, we need only to show that
$h(x)=(f(x))^2=x^2+u^{2^{k}-2}x^{2^{k+1}-2}+u^{2^k}x^{2^{k+1}+2}$ is
a PP over $\mathbb{F}_{2^m}$. Let $\overline{u}=u^{2^k}$ and $y=x^{2^k}$.
First, we prove that $h(x)=0$ if and only if $x=0$. Clearly, if
$x=0$, then $h(x)=0$. Conversely, if there exists some
$x\in\mathbb{F}_{2^m}^{*}$ such that
\begin{equation}\label{eq:pp1}
u^{2}x^{4}+\overline{u}y^2+\overline{u}u^{2}x^{4}y^{2}=0,
\end{equation}
raising both sides of Eq. \eqref{eq:pp1} to the $2^k$-th power
gives us
$$\overline{u}^{2}y^{4}+u^{2}x^4+\overline{u}^{2}u^{2}x^{4}y^{4}=0.$$
Since $\textup{gcd}(2,2^m-1)=1$, we have
\begin{equation}\label{eq:pp2}
\overline{u}y^{2}+ux^2+\overline{u}ux^{2}y^{2}=0.
\end{equation}
Adding Eq. \eqref{eq:pp1} and Eq. \eqref{eq:pp2} together, we obtain
\begin{equation}\label{eq:pp3}
u^{2}x^{4}+ux^2+\overline{u}u^{2}x^{4}y^{2}+\overline{u}ux^{2}y^2=0,
\end{equation}
which can be factorized as $ux^2(1+ux^{2})^{1+2^k}=0$. It follows that $x^2=\frac{1}{u}$, i.e.,
$x=\frac{1}{u^{2^{m-1}}}.$ But $h(\frac{1}{u^{2^{m-1}}})=\frac{1}{u}\neq0$, which is a
contradiction. Hence $h(x)=0$ if and only if $x=0$.
Next, if $h(x)$ is not a PP, then there exist $x\in
\mathbb{F}_{2^m}^{*}$ and $a\in \mathbb{F}_{2^m}^{*}$ such that
$h(x)=h(x+ax).$ Let $b=a^{2^k}.$ It is clear that $a,b\neq0,1.$
Since $h(x)=h(x+ax)$, we have
$$\frac{u^{2}x^4+\overline{u}y^2+\overline{u}u^{2}y^{2}x^4}{u^{2}x^2}=\frac{u^{2}(a^4+1)x^4+\overline{u}(b+1)^{2}y^{2}+\overline{u}u^2(b+1)^{2}y^{2}(a+1)^{4}x^{4}}{u^{2}(a+1)^{2}x^2},$$
which simplifies to
\begin{equation}\label{eq:pp4}
A_{1}x^{2}y^{2}+A_{2}y^{2}+A_{3}x^{2}=0,
\end{equation}
with $A_{1}=(a^{2}b^{2}+a^2+b^2+b)u\overline{u}$,
$A_{2}=(b^{2}+b)\overline{u}$, and $A_{3}=(b+a^2)u$.
We claim that $A_1A_2A_3\ne 0$. If $A_{1}=0$, we get
$(b+1)^{2}a^2=b(b+1).$ Thus $a^2=\frac{b}{b+1}.$ Raising both sides
to the $2^k$-th power, we get $b^2=\frac{a^2}{a^2+1}.$ Then $b^2=b$,
which leads to $b=0$ or $1$, a contradiction. So $A_{1}\neq0$. A
similar discussion shows that $A_{2},A_{3}\neq0$.
Raising both sides of Eq. \eqref{eq:pp4} to the $2^k$-th power,
we have
\begin{equation}\label{eq:pp5}
A_{1}^{2^k}x^{4}y^{2}+A_{3}^{2^k}y^{2}+A_{2}^{2^k}x^{4}=0.
\end{equation}
By Eq. \eqref{eq:pp4} and Eq. \eqref{eq:pp5}, cancelling $y^2$, we get
\begin{equation}\label{eq:pp6}
B_{1}x^{4}+B_{2}x^{2}+B_{3}=0,
\end{equation}
where $B_{1}=A_{3}A_{1}^{2^k}+A_{1}A_{2}^{2^k}=(b^{3}(a+1)^4)\overline{u}u^3\neq0,\ B_{2}=A_{2}^{2^k+1}\neq0,\ B_{3}=A_{3}^{2^k+1}\neq0.$
Substituting $x^2=\frac{B_2}{B_1}\gamma$ into Eq. \eqref{eq:pp6}, we obtain
\begin{equation}\label{eq:pp7}
\gamma^2+\gamma+D=0,
\end{equation}
where $D=\frac{B_{1}B_{3}}{B_{2}^2}=D_1+D_{1}^{2^k}$ and $D_1=\frac{A_{1}A_{3}^{2^k+1}}{A_{2}^{2^k+2}}=\frac{A_{1}B_3}{A_{2}B_{2}}$. We also have
\begin{align*}
\textup{Tr}_{m}(D_1)&=\textup{Tr}_{m}\left(\frac{A_1}{A_2}(\frac{A_3}{A_2})^{2^k+1}\right)\\
&=\textup{Tr}_{m}\left((1+a^2+\frac{a^2}{b})\frac{(a^2+b)(a+b)^2}{a^{2}(a+1)^{2}b(b+1)}\right)\\
&=\textup{Tr}_{m}\left(\frac{(a^2+b)(a+b)^2}{a^{2}(a+1)^{2}b(b+1)}+\frac{(a^2+b)(a+b)^2}{(a+1)^{2}b(b+1)}+\frac{(a^2+b)(a+b)^2}{(a+1)^{2}b^{2}(b+1)}\right)\\
&=\textup{Tr}_{m}\left(\frac{a^2}{(a+1)^{2}b(b+1)}+\frac{1}{(a+1)^{2}}+\frac{b^2}{a^{2}(a+1)^{2}(b+1)}+\frac{a^4}{(a+1)^{2}b(b+1)}+\frac{a^2}{(a+1)^{2}}+\right.\\
&{}\left.\frac{b^2}{(a+1)^{2}(b+1)}+\mathbf{}\frac{a^4}{(a+1)^{2}b^{2}(b+1)}+\frac{a^2}{b(a+1)^{2}}+\frac{b}{(a+1)^{2}(b+1)}\right)\\
&=\textup{Tr}_{m}\left(\frac{a^2}{(a+1)^{2}b(b+1)}+\frac{a^2}{b(a+1)^{2}}+\frac{b}{(a+1)^{2}(b+1)}\right)+\textup{Tr}_{m}\left(\frac{1}{(a+1)^{2}}+\frac{a^2}{(a+1)^{2}}\right)\\
&{}+\textup{Tr}_{m}\left(\frac{b^2}{a^{2}(a+1)^{2}(b+1)}+\frac{a^4}{(a+1)^{2}b(b+1)}+\frac{b^2}{(a+1)^{2}(b+1)}+\frac{a^4}{(a+1)^{2}b^{2}(b+1)}\right)\\
&=1.
\end{align*}
Raising both sides of Eq. \eqref{eq:pp7} to the $2^i$-th power,
$0\leq i\leq d-1,$ and then summing them up, we get
\begin{equation}\label{eq:pp8}
\gamma^{2^k}=\gamma+\sum_{i=0}^{k-1}(D_1+D_1^{2^k})^{2^i}=\gamma+D_1+\textup{Tr}_{m}(D_1)=\gamma+D_1+1.
\end{equation}
It follows that
\begin{equation}\label{eq:pp9}
\gamma^{2^k+1}=D_1\gamma+D.
\end{equation}
Combining Eqs. \eqref{eq:pp4}, \eqref{eq:pp8} and \eqref{eq:pp9}, we obtain
\begin{equation}\label{eq:pp10}
C_1\gamma+C_2=0,
\end{equation}
where $C_1=A_{1}A_{2}^{2^k+2}\neq0$ and $C_2=A_{2}^{2}B_{1}\neq0.$ Thus
$\gamma=\frac{C_2}{C_1}.$ Then from Eq. \eqref{eq:pp7}, we get
$$B_{1}A_{2}^{2}+A_{1}A_{2}B_{2}=A_{1}^{2}B_{3},$$
which leads to
$$b^2(b^2+a^4)=a^4(b^4+a^2).$$
Note that $\textup{gcd}(2,2^m-1)=1$ whence
$$a^2b^2+b^2+a^2b+a^3=0.$$
Raising both sides of the above equation to the $2^k$-th power, we
get
$$a^4b^2+a^4+a^2b^2+b^3=0.$$
It follows that
$$b^2(a^4+b)=a^2(a^2+b^2)=(a^3+a^2b)(a+b)=b^2(1+a^2)(a+b).$$
Then $$b=\frac{a^3+a^2+1}{a},$$ and raising both sides of the above
equation to the $2^k$-th power, we deduce that
$$a^8+a^7+a^6+a^5+a^4+a^2+1=0.$$
Since $x^8+x^7+x^6+x^5+x^4+x^2+1$ is irreducible over
$\mathbb{F}_{2},$ by Lemma \ref{lempp1}, $x^8+x^7+x^6+x^5+x^4+x^2+1$
is irreducible over $\mathbb{F}_{2^m}.$ Hence $a\notin
\mathbb{F}_{2^m}^{*}$, which is a contradiction. This
completes the proof.
\end{proof}
\begin{theorem}
Let $m>1$ be an odd integer such that $m=2k-1.$ Then
$f(x)=x+ux^{2^k-1}+u^{2^k}x^{2^m-2^{k+1}+2}, u\in
\mathbb{F}_{2^m}^{*},$ is a PP over
$\mathbb{F}_{2^m}$.
\end{theorem}
\begin{proof}
We first prove that $f(x)=0$ if and only if $x=0$. Let
$\overline{u}=u^{2^k}$ and $y=x^{2^k}$. Clearly, if $x=0$ then $f(x)=0$.
Conversely, suppose there exists some $x\in \mathbb{F}_{2^m}^{*}$
such that
\begin{equation}\label{eq:pp11}
x^{2}y^{2}+uy^3+\overline{u}x^{4}=0.
\end{equation}
Raising both sides of the above equation to the $2^k$-th power, we
get
\begin{equation}\label{eq:pp12}
x^{4}y^{2}+u^{2}y^4+\overline{u}x^{6}=0.
\end{equation}
Multiplying both sides of Eq. \eqref{eq:pp11} by $x^2$,
we obtain
\begin{equation}\label{eq:pp13}
x^{4}y^{2}+ux^{2}y^3+\overline{u}x^{6}=0.
\end{equation}
Adding Eq. \eqref{eq:pp12} and Eq. \eqref{eq:pp13} together, we have
$$ux^{2}y^{3}+u^{2}y^4=0.$$
It follows that $x^2=uy$. So we have $x=u^{2^{k-1}+1}$, which leads
to a contradiction since $f(u^{2^{k-1}+1})=u^{2^{k-1}+1}\neq0.$ Thus
$f(x)=0$ if and only if $x=0.$
Next, let $\overline{a}=a^{2^k}.$ We will show that $f(x)=a$ has a unique nonzero solution for
each nonzero $a\in \mathbb{F}_{2^m}$. That is, for the
equation
\begin{equation}\label{eq:pp14}
x^{2}y^{2}+uy^3+\overline{u}x^{4}+axy^2=0,
\end{equation} there exists a unique solution $x\in
\mathbb{F}_{2^m}^{*}.$
Raising both sides of Eq. \eqref{eq:pp14} to the $2^k$-th power
and multiplying Eq. \eqref{eq:pp14} by $x^2,$ we get
\begin{equation}\label{eq:pp15}
x^{4}y^{2}+\overline{u}x^6+u^{2}y^{4}+\overline{a}x^{4}y=0,
\end{equation} and
\begin{equation}\label{eq:pp16}
x^{4}y^{2}+ux^{2}y^3+\overline{u}x^{6}+ax^{3}y^2=0.
\end{equation}
Summing Eq. \eqref{eq:pp15} and Eq. \eqref{eq:pp16}, and dividing by $y$, we
have
\begin{equation}\label{eq:pp17}
u^{2}y^3+ux^{2}y^2+\overline{a}x^4+ax^3y=0.
\end{equation}
Computing Eq. \eqref{eq:pp14}$\cdot u+$Eq. \eqref{eq:pp17}, and dividing by
$x$, we obtain
\begin{equation}\label{eq:pp18}
(\overline{a}+u\overline{u})x^3+ax^{2}y+auy^2=0.
\end{equation}
Raising both sides of Eq. \eqref{eq:pp18} to the $2^k$-th
power, and then adding $\overline{a}\cdot$Eq. \eqref{eq:pp14}, we have
\begin{equation}\label{eq:pp19}
(\overline{a}+\overline{u}u^2+\overline{a}u)y+a\overline{a}x=0.
\end{equation}
Solving Eqs. \eqref{eq:pp18} and \eqref{eq:pp19}, we get
\begin{equation}\label{eq:pp20}
x=\frac{a^3\overline{a}^2}{b\overline{b}},
\end{equation}
Here, $b=a^2+\overline{u}u^2+\overline{a}u$ and $\overline{b}=b^{2^k},$ which can be directly verified to be nonzero.
This completes the proof.
\end{proof}
\section{Differential properties of power functions}\label{section6}
In this section, we consider the differential uniformity of monomial PPs. We first recall the basic definitions.
\begin{definition}
Let $F$ be a function from $\mathbb{F}_{2^n}$ to $\mathbb{F}_{2^m}$. For any $a\in\mathbb{F}_{2^n}$, the derivative of $F$ with respect to $a$ is the function $D_{a}(F)$ from $\mathbb{F}_{2^n}$ into $\mathbb{F}_{2^m}$ defined by
$$D_{a}(F(x))=F(x+a)+F(x),\ x\in\mathbb{F}_{2^n}.$$
\end{definition}
The resistance to differential cryptanalysis is related to the following quantities.
\begin{definition}
Let $F$ be a function from $\mathbb{F}_{2^n}$ into $\mathbb{F}_{2^n}$. For any $a$ and $b$ in $\mathbb{F}_{2^n}$, we denote
$$\delta(a,b)=\sharp\{x\in\mathbb{F}_{2^n}|D_{a}(F(x))=b\}.$$
Then the differential uniformity of $F$ is
$$\delta(F)=\textup{max}_{a\neq0,b\in\mathbb{F}_{2^n}}\delta(a,b).$$
\end{definition}
\begin{remark}
In the case $F(x)=x^d$ is a monomial, for any nonzero $a\in \mathbb{F}_{2^n},$
the equation $(x+a)^d+x^d=b$ can be rewritten as $a^d\left((\frac{x}{a}+1)^d+(\frac{x}{a})^d\right)=b$.
This implies that $\delta(a,b)=\delta(1,b/a^d)$. Therefore, for a monomial function,
the differential properties are determined by the values $\delta(1,b), b \in \mathbb{F}_{2^n}.$
From now on, we denote the quantity $\delta(1,b)$ by $\delta(b)$ for monomial functions.
\end{remark}
The following two lemmas can be found in \cite{BRS}, which will be used later.
\begin{lemma}{\rm\cite{BRS}}\label{lem1}
For a positive integer $m$ and $a,b \in \mathbb{F}_{2^m},a\neq0$,
the quadratic equation $x^2+ax+b=0$ has solutions in
$\mathbb{F}_{2^m}$ if and only if $\textup{Tr}_{m}(\frac{b}{a^2})=0$.
\end{lemma}
\begin{lemma}{\rm\cite{BRS}}\label{lem2}
For a positive integer $m$ and $a \in \mathbb{F}_{2^m}^{*}$, the
cubic equation $x^3+x+a=0$ has
\begin{enumerate}
\item[(1)] a unique solution in $\mathbb{F}_{2^m}$ if and only if
$\textup{Tr}_{m}(a^{-1}+1)=1$;
\item[(2)] three distinct solutions in $\mathbb{F}_{2^m}$ if and only if
$p_{m}(a)=0,$ where the polynomial $p_{m}(x)$ is recursively defined
by the equations
$p_{1}(x)=p_{2}(x)=x,\ p_{k}(x)=p_{k-1}(x)+x^{2^{k-3}}p_{k-2}(x)$ for $k\geq 3;$
\item[(3)] no solution in $\mathbb{F}_{2^m}$, otherwise.
\end{enumerate}
\end{lemma}
As a preparation, we have the following lemma.
\begin{lemma}\label{lem3}
Let $n=2m$ with $m$ odd, $b \in
\mathbb{F}_{2^n}\setminus\mathbb{F}_{2^m}$ and $y \in
\mathbb{F}_{2^m}\setminus\mathbb{F}_{2}.$ Then the number of
solutions of the equation $x^4+y^2(x^2+x+1)+x+1+b=0$ is $0\textup{ or }
4.$ Moreover, if $x_0$ is a solution, then the other three solutions
are given by $x_0+1,\ x_1$ and $x_1+1,$ where $x_1$ satisfies
$x_{1}^2+x_1=x_{0}^2+x_0+1+y^2.$
\end{lemma}
\begin{proof}
If $x_0$ is a solution of equation $x^4+y^2(x^2+x+1)+x+1+b=0$, then
$x_0+1$ is also a solution. So we have
$$x^4+y^2(x^2+x+1)+x+1+b=(x^2+x+x_{0}^2+x_0)(x^2+x+x_{0}^2+x_0+1+y^2).$$
Since $\textup{Tr}_{n}(x_{0}^2+x_0+1+y^2)=0$, by
Lemma~\ref{lem1} the equation $x^2+x+x_{0}^2+x_0+1+y^2=0$ also has $2$
solutions and these two solutions are different from $x_0$ and
$x_0+1$. Hence the number of solutions of the equation
$x^4+y^2(x^2+x+1)+x+1+b=0$ is $0\textup{ or } 4.$ The second part is
obvious.
\end{proof}
We now state our result.
\begin{theorem}
Let $n=2m$ with $m$ odd and $d=2^{m+1}+3.$ Then $F_{d}:x\rightarrow
x^d$ is a permutation over $\mathbb{F}_{2^n}$ with $\delta(F_d)\leq
10$. Moreover, for $b\in\mathbb{F}_{2^{m}}$, we have $\delta(b)\in\{0,4\}$.
\end{theorem}
\begin{proof} It can be verified that $\textup{gcd}(d,2^{n}-1)=1$, so $F_{d}$ is a permutation. For each $x \in \mathbb{F}_{2^n},$ let $\overline{x}:=x^{2^m}.$ It is clear that $x+\overline{x} \in \mathbb{F}_{2^m}$ and $x\overline{x} \in \mathbb{F}_{2^m}.$ We can then verify that $$D_{1}(F_{d}(x))=(x+1)^d+x^d=(\overline{x}^2+x)(x^2+x+1)+1=(\overline{x}x)^2+((\overline{x}+x)^2+1)(x+1).$$
Then it suffices to show that for any $b \in \mathbb{F}_{2^n}$, the equation
$D_{1}(F_{d}(x))=b$ has at most $10$ solutions.
Assume that
\begin{equation}\label{6.1}
(\overline{x}x)^2+((\overline{x}+x)^2+1)(x+1)=b.
\end{equation}
Raising both sides of Eq. \eqref{6.1} to the $2^m$-th power, we get
\begin{equation}\label{6.2}
(\overline{x}x)^2+((\overline{x}+x)^2+1)(\overline{x}+1)=\overline{b}.
\end{equation}
Adding Eq. \eqref{6.1} and Eq. \eqref{6.2} together, we have
\begin{equation}\label{6.3}
((\overline{x}+x)^2+1)(\overline{x}+x)=b+\overline{b}.
\end{equation}
Setting $y:=\overline{x}+x\in \mathbb{F}_{2^m}$ and $a:=b+\overline{b}\in \mathbb{F}_{2^m},$ we obtain
\begin{equation}\label{6.4}
y^3+y+a=0.
\end{equation}
Replacing $\overline{x}=y+x$ into Eq. \eqref{6.1}, we have
\begin{equation}\label{6.5}
x^4+y^2(x^2+x+1)+x+1+b=0.
\end{equation}
Therefore, $x$ is a solution of Eq. \eqref{6.1} if and only if it is a solution to following equations
\begin{equation}\label{eqs1}
\left\{
\begin{array}{rcl}
x^4+y^2(x^2+x+1)+x+1+b=0, \\[1.0ex]
y^3+y+a=0, \\[1.0ex]
\overline{x}+x=y.
\end{array}\right.
\end{equation}
Hence $\delta(F_d)\leq 12$. Below, we consider the two cases where $a=0$ and $a\neq0$.
{\bf Case 1: $a=0$}
It is easy to see that $b \in \mathbb{F}_{2^m}$ and $0,\ 1$ are solutions of Eq. \eqref{6.4}. We consider these two cases separately.
\begin{enumerate}
\item[(1)] If $y=0$, then $x\in \mathbb{F}_{2^m}.$ Thus Eq. \eqref{eqs1} will become $x^4+x+1=b,$ which has either $0$ solution or $2$ solutions. And it has $2$ solutions if and only if $\textup{Tr}_{m}(b)=1$.
\item[(2)] If $y=1$, then Eq. \eqref{eqs1} becomes
\begin{equation}\label{eqs2}
\left\{\begin{array}{rcl}
x^4+x^2+b=0, \\[1.0ex]
\overline{x}+x=1.
\end{array}\right.
\end{equation}
Since $\textup{gcd}(2,2^n-1)=1$, equation $x^4+x^2+b=0$ is equivalent to $x^2+x+b^{2^{m-1}}=0$. Clearly it has $2$ solutions by Lemma~\ref{lem1}. Since $1=\overline{x}+x=\sum_{i=0}^{m-1}(x^2+x)^{2^i}=\textup{Tr}_{m}(b^{2^{m-1}})$ we get that Eq. \eqref{eqs2} has $2$ solutions if and only if $\textup{Tr}_{m}(b)=1$.
\end{enumerate}
Note that, for both cases, Eq. \eqref{eqs1} has two solutions if and only if $\textup{Tr}_{m}(b)=1$. Therefore, $\delta(b) \in \{0,4\}$.
{\bf Case 2: $a\neq0$}
In this case it is obvious that $b \not\in \mathbb{F}_{2^m}$ and $y \not\in
\mathbb{F}_{2}$.
By Lemma~\ref{lem2}, Eq. \eqref{6.4} has $0$, $1$ or $3$ solutions. We consider these cases separately.
\begin{enumerate}
\item[(1)] If Eq. \eqref{6.4} has no solution, then $\delta(b)=0.$
\item[(2)] If Eq. \eqref{6.4} has one solution, say $y_0$, then by Lemma~\ref{lem3}, Eq. \eqref{6.5} has 0 or 4 solutions given by $x_{11},x_{11}+1,x_{21}$ and $x_{21}+1$. However, we need $x_{i1}+\overline{x_{i1}}=y_0$ holds for $i=1,2$. Thus $\delta(b)\in \{0,2,4\}.$
\item[(3)] If Eq. \eqref{6.4} has three solutions, denoted by $y_1,y_2$ and $y_3$. Then we have $y_1+y_2+y_3=0.$ For each $y_i,\ 1\leq i\leq 3,$ by Lemma~\ref{lem3}, there are $0$ or $4$ solutions for Eq. \eqref{6.5}. So the total number of solutions for $x$ is $0,\ 4,\ 8$ or $12.$
\begin{enumerate}
\item[(i)] If the number of solutions for $x$ is $0,\ 4$ or $\ 8$, then the number of solutions to Eq. \eqref{eqs1} is at most 8. Thus $\delta(b)\in \{0,2,4,6,8\}.$
\item[(ii)] If the number of solutions for $x$ is $12$, that is, for each $y_i,\ 1\leq i\leq 3,$ there are $4$ solutions of Eq. \eqref{6.5}. Let the $12$ solutions be $\{x_{ij},x_{ij}+1 | i=1,2,3;\ j=1,2\},$ with $y_{i}$ corresponding to $x_{i1},x_{i1}+1,x_{i2}$ and $x_{i2}+1$. If $x_{i1},x_{i1}+1,x_{i2}$ and $x_{i2}+1$ are exactly the solutions of Eqs. \eqref{eqs1}, we can easily get
\begin{equation}\label{eq2}
\left\{
\begin{array}{lcl}
x_{i1}+x_{i2}+(x_{i1}+x_{i2})^{2}=1+y_{i}^{2}, \\
x_{i1}+x_{i2}\in \mathbb{F}_{2^m},
\end{array}\right.
\end{equation}
which means that the equation $t^2+t+1+y_{i}^{2}=0$ has 2 solutions over $\mathbb{F}_{2^m}.$ By Lemma~\ref{lem1}, we have $\textup{Tr}_{m}(1+y_{i}^2)=0$ so that $\textup{Tr}_{m}(y_{i})=1.$ Therefore, if $\delta(b)=12$, then $\textup{Tr}_{m}(y_{1})=\textup{Tr}_{m}(y_{2})=\textup{Tr}_{m}(y_{3})=1.$ However, $1=\textup{Tr}_{m}(y_{1})+\textup{Tr}_{m}(y_{2})+\textup{Tr}_{m}(y_{3})=\textup{Tr}_{m}(y_{1}+y_{2}+y_{3})=0$, which is a contradiction. So $\delta(b)\leq 10.$
\end{enumerate}
\end{enumerate}
Thus we obtain $\delta(F_d)\leq 10$.
\end{proof}
\begin{remark}
For $d=2^m+2^{(m+1)/2}+1,$ we can obtain $\delta(F_d)\leq 10$ in a similar way. In fact, with $m=2r-1$
and $a:=b+\overline{b}$, Eq. \eqref{eqs1} now take the following form
\begin{equation}\label{eqs3}
\left\{
\begin{array}{rcl}
x^4+(ay+1)x^2+ayx+(y^2+1)\overline{b}^{2^r}+b\overline{b}=0, \\[1.0ex]
(y+1)x^{2^r}+x^2+yx+y+1+b=0, \\[1.0ex]
y^3+(a+1)y^2+a^{2^r}y+a^{2^r}=0, \\[1.0ex]
\overline{x}+x=y.
\end{array}\right.
\end{equation}
Hence $\delta(F_d)\leq 12.$ If $b\in\mathbb{F}_{2^{m}}$, we can
easily get $\delta(b)\in\{0,4\}$. If $\delta(b)=12$ for some
$b\in\mathbb{F}_{2^{n}}\backslash\mathbb{F}_{2^{m}},$ we have
$\textup{Tr}_{m}(ay_{i})=1,$ and
$1=\textup{Tr}_{m}(ay_{1})+\textup{Tr}_{m}(ay_{2})+\textup{Tr}_{m}(ay_{3})=\textup{Tr}_{m}(a(a+1))=0$,
which is a contradiction.
\end{remark}
Hence we have the following result.
\begin{theorem}
Let $n=2m$ with $m$ odd and $d=2^m+2^{(m+1)/2}+1.$ Then $F_{d}:x\rightarrow
x^d$ is a permutation over $\mathbb{F}_{2^n}$ with $\delta(F_d)\leq
10$. Moreover, for $b\in\mathbb{F}_{2^{m}}$, we have $\delta(b)\in\{0,4\}$.
\end{theorem}
\begin{remark}
Here we give a concrete example to illustrate the idea of the proof. Let $w$ be a primitive
element of $\mathbb{F}_{2^n}$, $n=10$, $d=67$,
$b=w^{27}$ and $a=b+\overline{b}$. Then Eq. \eqref{6.4} and
Eq. \eqref{6.5} become $y^3+y+a=0$ and $x^4+y^2(x^2+x+1)+x+1+b=0$ respectively.
\begin{tabular}{c|c|c|c}
\hline
Solutions of & & Solutions of & Solutions of \\
$y^3+y+a=0$ &$\textup{Tr}_{m}(y_{i})$ &$x^4+y^2(x^2+x+1)+x+1+b=0$ & $D_{1}(F_{d}(x))=b$\\\hline
$y_1=w^{330}$ &$1$ &$\{w^{672},w^{1019};w^{619},w^{975}\}$ & $w^{226},w^{633},$ \\ \cline{1-3}
$y_2=w^{363}$ &$1$ &$\{w^{226},w^{633};w^{586},w^{903}\}$ & $w^{586},w^{903},$ \\ \cline{1-3}
$y_3=w^{924}$ &$0$ &$\{w^{129},w^{340};w^{774},w^{883}\}$ & $w^{129},w^{340}$ \\ \hline
\end{tabular}\\
In the above table, for a fixed element $b$, we obtain $3$ solutions
of Eq. \eqref{6.4}, denoted by $y_1,\ y_2$ and $\ y_3.$ For
each $y_i,$ by Eq. \eqref{6.5} we get $4$ solutions. We need to
determine whether they are satisfying $x+\overline{x}=y_i$. Since
$\textup{Tr}_{m}(y_{3})=0,$ there are at least $2$ solutions which
are not satisfying $x+\overline{x}=y_3$ (in the above example, $w^{774}$
and $w^{883}$ are not). However, for each $y_i,\ i=1,2,$ we can not
determine whether the $4$ solutions are satisfying $x+\overline{x}=y_i$
since $\textup{Tr}_{m}(y_{1})=\textup{Tr}_{m}(y_{2})=1$ (in the
above example, the four solutions corresponding to $y_1$ are not,
while the four solutions corresponding to $y_2$ are). Therefore, in
our proof we only can get $\delta(b)\leq 10,$ but in fact
$\delta(b)=6$ for this example. Thus, we need to find more detailed
conditions to characterize the solutions of the equation.
\end{remark}
\section{Conclusion}\label{conclusion}
Permutation and CPPs have important applications in cryptography. This paper demonstrates some new results on permutation and CPPs. First, by using the AGW Criterion, we proved a conjecture proposed by Wu et al. \cite{WLHZ}. Then we give three other new classes of monomial CPPs over finite fields and the main tool is additive characters over the underlying finite fields. Moreover, a class of trinomial CPPs and two classes of trinomial PPs are also presented in this paper. Finally, for $d=2^{m+1}+3$ or $2^{m}+2^{\frac{m+1}{2}}+1$, Blondeau et al. \cite{BCC} conjectured that $x^{d}$ is differentially $8$-uniform over $\mathbb{F}_{2^{n}}$, where $n=2m$. We make some progress towards this conjecture and prove that the differential uniformity of $x^{d}$ is at most $10$. It seems not easy to exclude the possibility that $\delta(b)=10$ for some $b\in\mathbb{F}_{2^{n}}\backslash\mathbb{F}_{2^{m}}$. We look forward to seeing further progress on this conjecture.
\section*{Acknowledgements}
The authors express their gratitude to the anonymous reviewers for their detailed and constructive comments which are very helpful to the improvement of the presentation of this
paper. The research of T. Feng was supported by Fundamental Research Fund for the Central Universities of China, the National Natural Science Foundation
of China under Grant No.~11201418 and Grant No.~11422112, and the Research Fund for Doctoral Programs from the Ministry of Education of
China under Grant 20120101120089. The research of G. Ge was supported by the National Natural Science Foundation of China under Grant Nos. 11431003 and 61571310.
|
{'timestamp': '2016-06-15T02:06:49', 'yymm': '1506', 'arxiv_id': '1506.05525', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05525'}
|
arxiv
|
\section{Introduction}
\IEEEPARstart{M}{ulti-objective} optimization (MOO) is a generalization of the
standard single-objective optimization to problems where multiple criteria are
defined and they conflict with each other~\cite{miettinen1999nonlinear}. In this
case, there can be multiple optimal solutions with different trade-offs between
the objectives. Since the optimal set can be continuous, an MOO problem is given
by finding samples from the optimal set, called Pareto set. However, we also
wish that the projection of the obtained samples of the Pareto set into the
objective space be well-distributed along the Pareto frontier, which is the
counterpart for the Pareto set, so that the solutions present more diverse
trade-offs.
The current state-of-the-art for MOO relies on the use of evolutionary
algorithms for finding the desired samples~\cite{deb2001multi}. One of these
algorithms is the NSGA-II~\cite{deb2002fast}, which performs non-dominance
sorting, thus ordering the proposed solutions according to their relative
dominance degree, and dividing the solution set in subsequent frontiers of
non-dominated solutions. NSGA-II also uses crowding distance, which measures how
close the nearby solutions are, to maintain diversity in the objective space.
Another well-known algorithm is the SPEA2~\cite{zitzler2001spea2}, where the
solutions have a selective pressure to move towards the Pareto frontier and also
to stay away from each other.
These algorithms are based on heuristics to define what characterizes a good set
of solutions. However, the hypervolume indicator~\cite{zitzler2007hypervolume}
defines a metric of performance for a set of solutions, thus allowing a direct
comparison of multiple distinct sets of solutions~\cite{zitzler2003performance},
with higher values indicating possible better quality. The hypervolume is
maximal at the Pareto frontier and increases if the samples are better
distributed along the frontier~\cite{auger2009theory}. Due to these properties,
it represents a good candidate to be maximized in MOO, being explicitly explored
in the SMS-EMOA~\cite{beume2007sms}, where solutions that contribute the least
to the hypervolume are discarded.
On the other hand, local search methods have been successful in single-objective
optimization (SOO) due to their efficiency in finding a local optimum for some
problems~\cite{bertsekas1999nonlinear,luenberger2008linear}, so that research
has been performed to try to adapt these methods for MOO problems. For instance,
\cite{bosman2012gradients} defined a method for finding all minimizing
directions in a MOO problem, but the proposed algorithm achieved low performance
on usual benchmark functions.
Alternatively, instead of adapting the single-objective methods to work on MOO
problems, we can create a SOO problem associated with the MOO one, such that a
good solution for the single-objective case is a good solution for the
multi-objective case. Since the hypervolume is able to describe how good a
population is, based on a single indicator, the MOO problem can be converted
into the maximization of the population's hypervolume.
Based on this idea, \cite{hypervolume_gradient1} proposed a method to compute
the hypervolume's gradient for a given population, so that the optimal search
direction for each individual could be established. However,
\cite{hypervolume_gradient2} showed that adjusting the population through
integration of the hypervolume's gradient not always work, with some initially
non-dominated points becoming dominated and others changing very little over the
integration.
In this paper, we introduce an algorithm for maximizing the hypervolume by
optimizing one point at a time, instead of adjusting a whole population at once.
The algorithm alternates between exploring the space for non-dominated solutions
and, when they are found, exploiting them using local search methods to maximize
the populations' hypervolume when only this active point can be moved.
Therefore, once the hypervolume has converged, which is guaranteed to happen
because the problem is bounded, the point is fixed in all further iterations. We
found that this restriction is enough to overcome the issues presented
in~\cite{hypervolume_gradient2} when using the hypervolume's gradient. The
proposed algorithm, called Hybrid Hypervolume Maximization Algorithm (H2MA), is
a hybrid one, since it is composed of global exploration and local exploitation
procedures, properly managed to be executed alternately.
Results over the ZDT benchmark~\cite{zdt2000a} show that the new algorithm
performs better than the state-of-the-art evolutionary algorithms, both in terms
of total hypervolume and distance to the Pareto frontier. Moreover, the
algorithm was able to work deterministically in most of the benchmark problems,
which makes it less susceptible to variations due to random number generation.
Due to the high quality of the solutions found in less function evaluations than
what is achieved by the current state-of-the-art, we consider that the new
algorithm is a viable choice for solving MOO problems. Moreover, since a single
solution is introduced at a time, the user is able to stop the algorithm when
the desired number of solutions is found, while evolutionary algorithms must
evolve the whole population at the same time.
This paper is organized as follows. Section~\ref{sec:moo} introduces the
concepts of multi-objective optimization required, including the hypervolume
indicator, and discusses the problems with the gradient-based approach for
hypervolume maximization introduced in~\cite{hypervolume_gradient2}.
Section~\ref{sec:hybrid} provides the details of the new H2MA algorithm, and
Section~\ref{sec:results} shows the comparison with the state-of-the-art
algorithms. Finally, Section~\ref{sec:conclusion} summarizes the results and
discusses future research direction.
\section{Multi-Objective Optimization and the Hypervolume Indicator}
\label{sec:moo}
A multi-objective optimization problem is described by its decision space $\mathcal{X}\xspace$
and a set of objective functions $f_i(x) \colon \mathcal{X}\xspace \to \mathcal Y_i, i \in
\{1,\ldots,M\}$, where $\mathcal Y_i \subseteq \mathbb{R}\xspace$ is the associated objective
space for each objective function~\cite{deb2014multi}. Due to the symmetry
between maximization and minimization, only the minimization problem is
considered here. Each point $x$ in the decision space has a counterpart in the
objective space $\mathcal Y = \mathcal Y_1 \times \cdots \times \mathcal Y_M$
given by $y = f(x) = (f_1(x),\ldots,f_M(x))$.
Since there are multiple objectives, a new operator for comparing solutions must
be used, since the conventional ``less than'' operator $<$ can only compare two
numbers. This operator is denoted the dominance operator and is defined as
follows.
\begin{definition}[Dominance]
\label{def:dominance}
Let $y$ and $y'$ be points in $\mathcal Y$, the objective space. Then $y$
dominates $y'$, denoted $y \prec y'$, if $y_i < y'_i$ for all $i$.
\end{definition}
From this definition, a point $y$ that dominates another point $y'$ is better
than $y'$ in all objectives. Thus, there is no reason someone would choose $y'$
over $y$, and it can be discarded, as occurs in many multi-objective
optimization algorithms~\cite{deb2014multi}. Note that there are other
definitions of the dominance operator~\cite{zitzler2003performance}, where one
considers the inequality $\le$ instead of the strict inequality $<$ used here.
However, equality in some of the coordinates may be an issue when using the
hypervolume indicator, such as when taking its
derivative~\cite{hypervolume_gradient1}. This is why the strict version is used
in this work.
Using the dominance, we can define the set of points characterized by the fact
that no other point can have better performance in all objectives.
\begin{definition}[Pareto Set and Frontier]
The Pareto set is defined by the set of all points in the decision space that
are not dominated by any other point in the decision space, when using the
objectives. That is, the Pareto set is given by $\mathcal P = \{x \in \mathcal{X}\xspace \mid
\nexists x' \in \mathcal{X}\xspace \colon f(x') \prec f(x)\}$. The Pareto frontier is the
associated set in the objective space, given by $\mathcal F = \{f(x) \mid x
\in \mathcal P\}$.
\end{definition}
\subsection{The Hypervolume Indicator}
In order to define the hypervolume indicator~\cite{zitzler2007hypervolume}, we
must first define the Nadir point, which is a point in the objective space that
is dominated by every point in a set.
\begin{definition}[Nadir Point]
\label{def:nadir}
Let $X = \{x_1,\ldots,x_N\} \in \mathcal{X}\xspace^N$ be a set of points in the decision
space. Let $z \in \mathbb{R}\xspace^M$ be a point in the objective space. Then $z$ is a valid
Nadir point if, for all $x \in X$ and $i \in \{1,\ldots,M\}$, we have that
$f_i(x) < z_i$. Using Definition~\ref{def:dominance}, this can be written as
$f(x) \prec z$.
\end{definition}
Again, it is possible to allow equality in the definition of the Nadir point,
just like in the definition of dominance. However, when equality is allowed, it
is possible for some point to have a null hypervolume, which can guide to
undesired decisions when using the hypervolume as a performance metric, since
such points would not contribute to the hypervolume and would be replaced by
other points. Using the definition of a Nadir point, we can define the
hypervolume for a set of points.
\begin{definition}[Hypervolume]
\label{def:hypervolume}
Let $X = \{x_1,\ldots,x_N\} \in \mathcal{X}\xspace^N$ be a set of points in the decision
space. Let $z \in \mathbb{R}\xspace^M$ be a valid Nadir point in the objective space. Then
the hypervolume can be defined as:
\begin{equation}
\label{eq:hypervolume}
H(X;z) = \int_{\mathbb{R}\xspace^M} 1[\exists x \in X \colon f(x) \prec y \prec
z] \text{d}y,
\end{equation}
where $1[\cdot]$ is the indicator function.
\end{definition}
The hypervolume measures how much of the objective space is dominated by a
current set $X$ and dominates the Nadir point $z$.
Fig.~\ref{fig:hypervolume_example} shows an example of the hypervolume for a set
of three non-dominated points. For each point, the shaded region represents the
area dominated by the given point, with colors combining when there is overlap.
\begin{figure}[t]
\centering
\psfrag{y1}[c][b]{$y_1$}
\psfrag{y2}[c][t]{$y_2$}
\includegraphics[width=0.6\linewidth]{hypervolume.eps}
\caption{Example of hypervolume. The non-dominated solutions in the objective
space are shown in black circles, and the Nadir point is shown in the black
square. For each non-dominated solution, the region between it and the Nadir
point is filled, with colors combining when there is overlap, and the total
hypervolume is given by the area of the shaded regions. Best viewed in color.}
\label{fig:hypervolume_example}
\end{figure}
\subsection{Gradient of the Hypervolume}
\label{sec:moo:gradient}
As stated earlier, since the hypervolume provides such a good indicator of
performance in multi-objective problems, it can be used to transform the
multi-objective problem into a single-objective one, characterized by the
maximization of the hypervolume.
Although such approach proved to be successful when using evolutionary
algorithms as the optimization method~\cite{beume2007sms}, the same did not
happen when using the hypervolume's gradient to perform the
optimization~\cite{hypervolume_gradient2}. However, it is well-known that
gradient methods have been successful in single-objective
optimization~\cite{bertsekas1999nonlinear,luenberger2008linear}, thus suggesting
that they should be a reasonable choice for multi-objective optimization devoted
to maximizing the hypervolume, since the hypervolume operator is well-defined
almost everywhere in the objective space.
The hypervolume's gradient for a set of points was introduced
in~\cite{hypervolume_gradient1}, and it can be used to compute the optimal
direction in which a given point should move to increase the hypervolume
associated with the current set of non-dominated solutions. Although the
hypervolume is not a continuously differentiable function of its arguments,
since dominated points do not contribute to the hypervolume and thus have null
gradient, the gradient can be computed whenever any two points have different
values for all objectives.
Based on this motivation, \cite{hypervolume_gradient2} used the hypervolume's
gradient as a guide for adjusting a set of points by numerical integration, that
is, performing a small step in the direction pointed by the gradient. Even
though the algorithm was able to achieve the Pareto set in some cases, it failed
to converge to efficient points when some points got stuck along the iterative
process, either because their gradients became very small or because they became
dominated by other points. Once dominated, these points do not contribute to the
hypervolume and remain fixed. This causes a major issue to using the hypervolume
gradient in practice, since dominated points can be discarded, because there is
no possibility to revert them to non-dominated points anymore, and the points
with small gradients remain almost stagnant.
If we analyze Eq.~\eqref{eq:hypervolume}, we can see that points at the border
in the objective space are the only ones that can fill some portions of the
objective space. On the other hand, points that are not at the border have less
influence in the hypervolume, since part of the area dominated by them is also
dominated by some other points. In the analysis presented
in~\cite{hypervolume_gradient2}, it is clear that the cases where some points
got stuck had higher gradients for the border points in the objective space,
which led to the dominance or decrease of contribution of some or all central
points.
To make this idea clearer, consider the example in
Fig.~\ref{fig:hypervolume_example}. If the point located at $(0.75,0.25)$
decreases its value on the second objective, it can increase the population's
hypervolume. Moreover, it is the only point that can do so without competition
for that portion of the space, since it is the point with the largest value for
the first objective. The same holds for the point at $(0.25,0.75)$ and the first
objective.
However the point located at $(0.5,0.5)$ has to compete with the other two
points to be the sole contributor for some regions. Therefore, its effect on the
hypervolume is smaller, which leads to a smaller gradient. Furthermore, if less
area is dominated by the middle point alone, which can occur during the points
adjustment as the middle one moves less, then its influence becomes even smaller
and it can become dominated.
It is important to highlight that this behavior does not happen always, but can
occur along the iterative process, as shown in~\cite{hypervolume_gradient2}.
This leads to the base hypothesis for the algorithm developed in this paper:
when using the hypervolume's gradient for optimization, the competition for
increasing the hypervolume among points should be avoided.
\section{Hybrid Hypervolume Maximization Algorithm}
\label{sec:hybrid}
From the discussion in Section~\ref{sec:moo:gradient}, one can see that the
major problem when optimizing the hypervolume directly using its gradient may be
the competition among points. Therefore, our proposed algorithm optimizes a
single solution at a time, avoiding this competition.
Theoretically, the algorithm can be described by choosing a new point that
maximizes the hypervolume when taking into account the previous points, such
that its recurring equation can be written as:
\begin{equation}
\label{eq:greedy}
x_t = \arg \max_{x \in \mathcal{X}\xspace} H(X_{t-1} \cup \{x\}),
X_t = X_{t-1} \cup \{x_t\}, t \in \mathbb N,
\end{equation}
where the initial set is given by $X_{-1} = \{\}$.
Since a single point is being optimized at a time, the optimization becomes
simpler and, as we will show in Section~\ref{sec:results}, requires less
function evaluations. Moreover, one could argue that maintaining the previous
set fixed reduces the flexibility allowed in comparison with a set where all the
points are being concurrently adjusted. Although this may be true, we will also
show in Section~\ref{sec:results} that the proposed algorithm performs well
despite this loss of flexibility.
\begin{figure}[t]
\small
\begin{algorithmic}
\Require{Objectives $f$}
\Require{Design space $\mathcal{X}\xspace$}
\Require{Nadir point $z$}
\Ensure{Set of candidate solutions $X$}
\Function{HybridGreedyOptimizer}{$f, \mathcal{X}\xspace, z$}
\State{$Regions,X$ $\gets$ \Call{CreateInitialRegion}{$f, \mathcal{X}\xspace$}}
\While{\textbf{not} \emph{stop condition} \textbf{and} $|Regions| > 0$}
\State{$R \gets Regions$.pop()}
\Comment{Removes the region with the largest volume}
\State{$x_0 \gets$ \Call{ExploreDeterministic}{$f,\mathcal{X}\xspace,R,X$}}
\If{$x_0$ is valid}
\State{$x \gets$ \Call{Exploit}{$f,\mathcal{X}\xspace,x_0,X,z$}}
\State{$NewRegions \gets$ \Call{CreateRegions}{$R,x,f$}}
\State{$Regions \gets Regions \cup NewRegions$}
\State{$X \gets X \cup \{x\}$}
\EndIf
\EndWhile
\While{\textbf{not} \emph{stop condition}}
\State{$x_0 \gets$ \Call{ExploreStochastic}{$f,\mathcal{X}\xspace,X$}}
\State{$x \gets$ \Call{Exploit}{$f,\mathcal{X}\xspace,x_0,X,z$}}
\State{$X \gets X \cup \{x\}$}
\EndWhile
\State{\Return{$X$}}
\EndFunction
\end{algorithmic}
\caption{Hybrid algorithm that performs deterministic and stochastic
exploration until a suitable solution is found, and then exploits it.}
\label{alg:main}
\end{figure}
\begin{figure}[t]
\small
\begin{algorithmic}
\Require{Objectives $f$}
\Require{Design space $\mathcal{X}\xspace$}
\Require{Current exploration region $R$}
\Require{Set of candidate solutions $X$}
\Ensure{New initial condition $x_0$}
\Function{ExploreDeterministic}{$f,\mathcal{X}\xspace,R,X$}
\State{$x_0 \gets$ \Call{Mean}{$R.X$}}
\State{Minimize $\|R.mid - f(x)\|$ from $x_0$ until some candidate $x$ is
not dominated by $X$}
\If{found non-dominated $x$}
\State{$x_0 \gets x$}
\Else
\State{$x_0 \gets$ some invalid state}
\EndIf
\State{\Return{$x_0$}}
\EndFunction
\end{algorithmic}
\caption{A deterministic exploration is performed based on some region.}
\label{alg:exploration}
\end{figure}
\begin{figure}[t]
\small
\begin{algorithmic}
\Require{Objectives $f$}
\Require{Design space $\mathcal{X}\xspace$}
\Ensure{Set of candidate solutions $X$}
\Ensure{Initial exploration region $R$}
\Function{CreateInitialRegion}{$f, \mathcal{X}\xspace$}
\State{$X \gets \{\}$}
\State{$x_0 \gets \mathcal{X}\xspace.mean$}
\Comment{Gets the average candidate}
\For{$i=1,\ldots,|f|$}
\State{$x \gets$ \Call{Minimize}{$f_i,x_0,\mathcal{X}\xspace$}}
\State{$X \gets X \cup \{x\}$}
\EndFor
\State{$R \gets$ \Call{CreateRegion}{$X,f$}}
\State{\Return{$\{R\},X$}}
\EndFunction
\end{algorithmic}
\caption{The initial region is created from the points that minimize each
objective individually.}
\label{alg:initial}
\end{figure}
The algorithm described in Eq.~\eqref{eq:greedy} is theoretically ideal, since
finding the maximum is hard in practice. Therefore, the actual algorithm
proposed is shown in Fig.~\ref{alg:main}. This algorithm performs exploration of
the objective space until a new solution that is not dominated by the previous
candidate solutions is found. When it happens, the hypervolume of the whole
set is larger than the hypervolume when considering only previous candidate
solutions.
The new candidate solution is then exploited to maximize the total hypervolume
and, after convergence, is then added to the existing set. It is important to
highlight that the exploitation phase cannot make the solution become dominated,
since that would reduce the hypervolume in comparison with the initial
condition. Therefore, the problem of points becoming dominated during the
exploitation is avoided. Furthermore, the exploitation is a traditional
single-objective optimization, so that gradient methods can be used if the
decision set $\mathcal{X}\xspace$ is continuous or hill-climbing methods can be used for
discrete $\mathcal{X}\xspace$.
Once finished the exploitation, the algorithm begins the exploration phase
again. The exploration can be deterministic, based on regions of the objective
space defined by previous solutions, or stochastic, where a stochastic
algorithm, such as an evolutionary algorithm, is used to find the new candidate.
When a non-dominated candidate is found, the algorithm turns to exploitation
again.
We highlight that the deterministic exploitation algorithm proposed is based on
the definition of these regions, but other deterministic methods can be used.
However, the algorithm must be able to establish when it is not able to provide
further improvements, so that the change to the stochastic global exploration
can be made. In the algorithm shown in Fig.~\ref{alg:main}, regions that do not
provide a valid initial condition are discarded without creating new regions, so
that eventually the algorithm can switch to the stochastic global exploration.
The algorithm for deterministic exploration is shown in
Fig.~\ref{alg:exploration}. It combines the points used to create a given region
in order to produce an initial condition and tries to minimize the distance
between its objective value and a reference point. Once a non-dominated point is
found, it is returned for exploitation. Although this simple optimization
provided good results without requiring many function evaluations, other methods
can be used to perform this exploration. Alternatively, one can also perform a
stochastic exploration instead of a deterministic one, but this may have
negative effects on the performance if the information provided by the output
(region R) is not used, since a global search would be required.
\begin{figure}[t]
\small
\begin{algorithmic}
\Require{Current explored region $R$}
\Require{Current solution $x$}
\Require{Objectives $f$}
\Ensure{New exploration regions $NewRegions$}
\Function{CreateRegions}{$R,x,f$}
\State{$NewRegions \gets \{\}$}
\For{$X'$ \textbf{in} \Call{Combinations}{$R.X,|R.X|-1$}}
\State{$R' \gets$ \Call{CreateRegion}{$X' \cup \{x\},f$}}
\State{$NewRegions \gets NewRegions \cup \{R'\}$}
\EndFor
\State{\Return{$NewRegions$}}
\EndFunction
\end{algorithmic}
\caption{New exploration regions are created by combining the current solution
with the previous region.}
\label{alg:regions}
\end{figure}
\begin{figure}[t]
\small
\begin{algorithmic}
\Require{Objectives $f$}
\Require{Set of candidate solutions $X$}
\Ensure{Exploration region $R$}
\Function{CreateRegion}{$X,f$}
\State{$V = \prod_{i=1}^{|f|} (\max_{x \in X} f_i(x) - \min_{x \in X}
f_i(x))$}
\If{$V > 0$}
\State{$R.X \gets X$}
\State{$R.mid \gets$ \Call{Mean}{$\{f(x) \mid x \in X\}$}}
\State{$R.V \gets V$}
\Else
\State{$R \gets$ null element such that $\{R\} \equiv \{\}$}
\EndIf
\State{\Return{$R$}}
\EndFunction
\end{algorithmic}
\caption{An exploration region is created from a set of candidates if the
region have some volume.}
\label{alg:region}
\end{figure}
The first region is created by finding points that minimize each objective
separately, as shown in Fig.~\ref{alg:initial}. This establishes that the
initial region will have a number of candidate solutions associated with it
equal to the number of objectives, so that the solutions are at the border of
the region.
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{0.4\linewidth}
\psfrag{p1}[c][c]{$f(x_1)$}
\psfrag{p2}[c][c]{$f(x_2)$}
\psfrag{p3}[c][c]{$f(\overline x_{12})$}
\psfrag{p4}[c][c]{$f(x')$}
\psfrag{p5}[c][c]{$\overline y_{12}$}
\psfrag{y1}[c][b]{$f_1(\cdot)$}
\psfrag{y2}[c][t]{$f_2(\cdot)$}
\psfrag{R}[c][c]{$R$}
\includegraphics[width=\linewidth]{algorithm_example1.eps}
\caption{Deterministic exploration}
\label{fig:algorithm_example:exploration}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.4\linewidth}
\psfrag{p1}[c][c]{$f(x_1)$}
\psfrag{p2}[c][c]{$f(x_2)$}
\psfrag{p4}[c][c]{$f(x')$}
\psfrag{p6}[c][c]{$f(x^*)$}
\psfrag{h1}[c][c]{$H^*$}
\psfrag{h2}[c][c]{$H'$}
\psfrag{y1}[c][b]{$f_1(\cdot)$}
\psfrag{y2}[c][t]{$f_2(\cdot)$}
\psfrag{R2}[c][c]{$R_1$}
\psfrag{R1}[c][c]{$R_2$}
\includegraphics[width=\linewidth]{algorithm_example2.eps}
\caption{Exploitation}
\label{fig:algorithm_example:exploitation}
\end{subfigure}
\caption{Deterministic exploration and exploitation steps of the new algorithm
in an example problem. The Pareto frontier is shown in the blue line, and
the regions used by the deterministic exploration are shown in yellow.}
\label{fig:algorithm_example}
\end{figure*}
When new regions are created after exploitation, we ignore the solutions that
created the region, one at a time, and replace it with the proposed new
solution, as shown in Fig.~\ref{alg:regions}, to create a new region. This
guarantees that the number of solutions for each region is kept equal to the
number of objectives.
Finally, Fig.~\ref{alg:region} shows how a region is created. If a region does
not have a volume, then at least one objective for two solutions is the same.
Although we could allow such region to exist without modifying the rest of the
algorithm, these regions tend to not provide good candidates for exploitation
and delay the change to stochastic global exploration. Furthermore, one can even
prohibit regions with volume smaller than some known constant, as they probably
will not provide good exploitation points, and the change to stochastic global
exploration happens earlier.
Fig.~\ref{fig:algorithm_example} shows a step of the algorithm in an example
problem with two objectives.
The deterministic exploration receives a
region $R$, composed of the points $x_1$ and $x_2$. The mean of the points that
compose the region is given by $\overline x_{12} = (x_1+x_2)/2$ and its
evaluation in the objective space is shown in
Fig.~\ref{fig:algorithm_example:exploration}. The mean objective of the points
that compose the region is also computed and is shown as $\overline y_{12} =
(f(x_1)+f(x_2))/2$. The deterministic exploration is then defined by the
problem
\begin{equation}
\label{eq:deterministc_exploration}
\min_{x \in \mathcal{X}\xspace} \|f(x) - \overline y_{12}\|,
\end{equation}
which uses $\overline x_{12}$ as the initial condition for the optimization.
Since $\overline y_{12}$ is guaranteed to be non-dominated by $f(x_1)$ and
$f(x_2)$, this should guide the search to the non-dominated region of the space.
While performing this optimization, some intermediary points are evaluated,
either while computing the numeric gradient or after performing a gradient
descent step. The deterministic exploration stops as soon as a non-dominated
point is found, which is given by $f(x')$ in the example in
Fig.~\ref{fig:algorithm_example:exploration}. Note that this example shows
$f(\overline x_{12})$ as being dominated by $f(x_1)$ and $f(x_2)$, but it can
also be non-dominated. In this case, $x' = \overline x_{12}$ and no optimization
step for the problem in Eq.~\eqref{eq:deterministc_exploration} is performed.
Supposing no non-dominated point $f(x')$ is found during the deterministic
exploration, the region is simply discarded, without performing an exploitation
step.
Using the point $x'$, whose $f(x')$ is non-dominated, provided by the
deterministic or stochastic exploration, the exploitation is performed.
Fig.~\ref{fig:algorithm_example:exploitation} shows the hypervolume
contributions for the initial point $x'$ and the optimal point $x^*$, which
maximizes the total hypervolume as in Eq.~\eqref{eq:greedy}. Since $x'$ is
non-dominated, its hypervolume contribution $H'$ is positive and the hypervolume
gradient relative to the objectives is non-zero. After finding $x^*$ and if $x'$
was provided by the deterministic exploration, new regions must be created
to allow further exploration. Therefore, according to Fig.~\ref{alg:regions},
the regions $R_1 = (x_1, x^*)$ and $R_2 = (x_2, x^*)$ are created for further
exploration.
This finalizes a step of the algorithm, which is repeated until the
given stop condition is not met. As at most one point is found by each step, the
stop condition can be defined based on the number of desired points.
Note that all the methods used in this algorithm assume that the optimization,
either for exploitation or for minimizing one objective alone, requires an
initial condition. This is true for hill climbing or gradient methods, but the
algorithm can easily be modified if the optimization does not require it.
\section{Experimental Results}
\label{sec:results}
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{0.48\linewidth}
\psfrag{evals}[c][b]{\# evaluations}
\psfrag{H}[c][c]{H}
\includegraphics[width=\linewidth]{hypervolume_zdt1_size_100_sms_20_check_0.eps}
\caption{Hypervolume}
\label{fig:zdt1:H}
\end{subfigure}
\begin{subfigure}[b]{0.48\linewidth}
\psfrag{evals}[c][b]{\# evaluations}
\psfrag{P}[c][c]{$\log_{10}$ P}
\includegraphics[width=\linewidth]{p_zdt1_size_100_sms_20_check_0.eps}
\caption{P-distance. Zero values not shown.}
\label{fig:zdt1:P}
\end{subfigure}
\caption{0th, 25th, 50th, 75th, and 100th percentiles every 2000 evaluations
for the all algorithms on ZDT1.}
\label{fig:zdt1}
\end{figure*}
To compare the algorithm proposed in Section~\ref{sec:hybrid}, called Hybrid
Hypervolume Maximization Algorithm (H2MA), with the existing algorithms, the ZDT
family of functions~\cite{zdt2000a} was chosen. These functions define a common
benchmark set in the multi-objective optimization literature, since they define
a wide range of problems to test different characteristics of the optimization
algorithm. All functions defined in~\cite{zdt2000a} have a continuous decision
space $\mathcal{X}\xspace$, except for the ZDT5 which has a binary space. In this paper, only
the continuous test functions were used to evaluate the performance of the new
algorithm, and their equations are shown in the appendix.
Table~\ref{tab:experiment} provides a summary of the evaluation functions, their
decision spaces, and the Nadir points used to compute the hypervolume. The Nadir
points are defined by upper bounds of the objectives, which guarantees that the
hypervolume computation is always valid, plus one, since not adding an extra
value would mean that points at the border of the frontier would have no
contribution to the hypervolume and would be avoided. In all instances, a total
of $n=30$ variables were considered, as common in the literature. The
evolutionary algorithms' and evaluation functions' implementations were given by
the PaGMO library~\cite{biscani2010global}.
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{0.48\linewidth}
\psfrag{evals}[c][b]{\# evaluations}
\psfrag{H}[c][c]{H}
\includegraphics[width=\linewidth]{hypervolume_zdt2_size_100_sms_20_check_0.eps}
\caption{Hypervolume}
\label{fig:zdt2:H}
\end{subfigure}
\begin{subfigure}[b]{0.48\linewidth}
\psfrag{evals}[c][b]{\# evaluations}
\psfrag{P}[c][c]{$\log_{10}$ P}
\includegraphics[width=\linewidth]{p_zdt2_size_100_sms_20_check_0.eps}
\caption{P-distance. Zero values not shown.}
\label{fig:zdt2:P}
\end{subfigure}
\caption{0th, 25th, 50th, 75th, and 100th percentiles every 2000 evaluations
for the all algorithms on ZDT2.}
\label{fig:zdt2}
\end{figure*}
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{0.48\linewidth}
\psfrag{evals}[c][b]{\# evaluations}
\psfrag{H}[c][c]{H}
\includegraphics[width=\linewidth]{hypervolume_zdt3_size_100_sms_20_check_0.eps}
\caption{Hypervolume}
\label{fig:zdt3:H}
\end{subfigure}
\begin{subfigure}[b]{0.48\linewidth}
\psfrag{evals}[c][b]{\# evaluations}
\psfrag{P}[c][c]{$\log_{10}$ P}
\includegraphics[width=\linewidth]{p_zdt3_size_100_sms_20_check_0.eps}
\caption{P-distance. Zero values not shown.}
\label{fig:zdt3:P}
\end{subfigure}
\caption{0th, 25th, 50th, 75th, and 100th percentiles every 2000 evaluations
for the all algorithms on ZDT3.}
\label{fig:zdt3}
\end{figure*}
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{0.48\linewidth}
\psfrag{evals}[c][b]{\# evaluations}
\psfrag{H}[c][c]{H}
\includegraphics[width=\linewidth]{hypervolume_zdt4_size_100_sms_20_check_0.eps}
\caption{Hypervolume}
\label{fig:zdt4:H}
\end{subfigure}
\begin{subfigure}[b]{0.48\linewidth}
\psfrag{evals}[c][b]{\# evaluations}
\psfrag{P}[c][c]{$\log_{10}$ P}
\includegraphics[width=\linewidth]{p_zdt4_size_100_sms_20_check_0.eps}
\caption{P-distance. Zero values not shown.}
\label{fig:zdt4:P}
\end{subfigure}
\caption{0th, 25th, 50th, 75th, and 100th percentiles every 2000 evaluations
for the all algorithms on ZDT4.}
\label{fig:zdt4}
\end{figure*}
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{0.48\linewidth}
\psfrag{evals}[c][b]{\# evaluations}
\psfrag{H}[c][c]{H}
\includegraphics[width=\linewidth]{hypervolume_zdt6_size_100_sms_20_check_0.eps}
\caption{Hypervolume}
\label{fig:zdt6:H}
\end{subfigure}
\begin{subfigure}[b]{0.48\linewidth}
\psfrag{evals}[c][b]{\# evaluations}
\psfrag{P}[c][c]{$\log_{10}$ P}
\includegraphics[width=\linewidth]{p_zdt6_size_100_sms_20_check_0.eps}
\caption{P-distance. Zero values not shown.}
\label{fig:zdt6:P}
\end{subfigure}
\caption{0th, 25th, 50th, 75th, and 100th percentiles every 2000 evaluations
for the all algorithms on ZDT6.}
\label{fig:zdt6}
\end{figure*}
\begin{table}[t]
\centering
\caption{Benchmark problems used for evaluation. See the Appendix for
Eqs.~\eqref{eq:zdt1} to~\eqref{eq:zdt6}.}
\label{tab:experiment}
\begin{tabular}{|c|c|c|c|}
\hline
Problem & Objectives & $\mathcal{X}\xspace$ & Nadir point
\\
\hline
ZDT1 & Eq.~\eqref{eq:zdt1} & $[0,1]^n$ & $(2,11)$
\\
ZDT2 & Eq.~\eqref{eq:zdt2} & $[0,1]^n$ & $(2,11)$
\\
ZDT3 & Eq.~\eqref{eq:zdt3} & $[0,1]^n$ & $(2,11)$
\\
ZDT4 & Eq.~\eqref{eq:zdt4} & $[0,1]\times[-5,5]^{n-1}$
& $(2,2+50(n-1))$
\\
ZDT6 & Eq.~\eqref{eq:zdt6} & $[0,1]^n$ & $(2,11)$
\\
\hline
\end{tabular}
\end{table}
We compare our algorithm with existing state-of-the-art multi-objective
optimization algorithms, namely NSGA-II~\cite{deb2002fast},
SPEA2~\cite{zitzler2001spea2}, and SMS-EMOA~\cite{beume2007sms}. All of them
used a population size of 100 individuals. Tests have shown that this size is
able to provide a good performance due to balance between exploration of the
space and exploitation of the individuals, with much less individuals not
providing good exploration and much more not providing good exploitation. The
SMS-EMOA can use two methods for selecting points in dominated fronts: the least
hypervolume contribution or the domination count. Both methods were tested, with
labels SMS1 and SMS2, respectively, in the following figures. Note that this
method only applies for the dominated fronts, since the domination count is zero
for all points in the non-dominated front and the least contributor method must
be used. Furthermore, the SMS-EMOA algorithm's performance presented in this
paper uses a dynamic Nadir point, which is found by adding one to the maximum
over all points in each objective, since using the Nadir points presented in
Table~\ref{tab:experiment} created a very high selective pressure, which in turn
led to poor exploration and performance.
Since the decision space and objectives are continuous, the exploitation and
deterministic exploration methods may resort to a gradient-based algorithm. In
this paper, we used the L-BFGS-B method implemented in the library
SciPy~\cite{scipy}, which is able to handle the bounds of $\mathcal{X}\xspace$ and is very
efficient to find a local optimum. As the other algorithms being compared are
evolutionary algorithms, which can only access the objective functions by
evaluating them at given points, the gradient for the L-BFGS-B is computed
numerically to avoid an unfair advantage in favor of our algorithm.
For the stochastic global exploration, we used an evolutionary algorithm with
non-dominance sorting and removal based on the number of dominating points. The
population had a minimum size of $20$ and was filled with the given set of
previous solutions $X$. If less than $20$ points were provided, the others were
created by randomly sampling the decision space $\mathcal{X}\xspace$ uniformly. Once a new point
is introduced to the non-dominated front, it is returned for exploitation
because it increases the hypervolume when added to the previous solutions $X$.
The size of this population was chosen experimentally to provide a good enough
exploration of the space toward the initial conditions for the exploitation.
This size is smaller than the population size for the pure evolutionary
algorithms because the pure evolutionary algorithm need diversity to explore and
exploit all of its population, but the stochastic part of the H2MA is already
initialized with good and diverse candidate solutions provided by the
exploitation procedure, reducing its exploration requirements.
Besides computing the solutions' hypervolume, which is the metric that the H2MA
is trying to maximize and that provides a good method for comparing solutions,
we can compute the distance between the achieved objectives and the Pareto
frontier, since the Pareto frontiers for the ZDT functions are known. This
defines the P-distance, which is zero, or close to zero due to numerical issues,
for points at the frontier.
Figs.~\ref{fig:zdt1}, \ref{fig:zdt2}, \ref{fig:zdt3}, \ref{fig:zdt4},
and~\ref{fig:zdt6} present the results for the problems ZDT1, ZDT2, ZDT3, ZDT4,
and ZDT6, respectively. A maximum of 20000 function evaluations was considered,
and the graphs show the $0$th, $25$th, $50$th, $75$th, and $100$th percentiles
for each performance indicator over 100 runs of the algorithms. Since the
P-distance is shown in log-scale, some values obtained by our proposal are
absent or partially present, because they have produced zero P-distance.
From ZDT1 to ZDT4, the H2MA never ran out of regions to explore, so the
stochastic exploration was not used and all runs have the same performance. For
the function ZDT6, the first objective, given by Eq.~\eqref{eq:zdt6:f1}, causes
some problems to the deterministic exploration.
During the creation of the first region for this problem, the mean point is used
as initial condition for optimizing each objective, as shown in
Fig.~\ref{alg:initial}. However, the first objective for ZDT6 has null
derivative when $x_1 = 0.5$. In this case, even traditional higher-order methods
would not help, since the first non-zero derivative of $f_1(x)$ is the sixth. As
the first objective does not change in this case and it also has local minima
that are very hard to overcome, the algorithm quickly switches to using
stochastic exploration. Once new regions have candidate points, the algorithm is
able to exploit them.
Besides this issue in the deterministic exploration of the problem ZDT6, the
local minima of the first objective makes some candidate solutions be
sub-optimal, increasing the P-distance as shown in Fig.~\ref{fig:zdt6:P}.
Nonetheless, the achieved P-distance is better than the evolutionary algorithms
and the $75$th percentile is zero. Moreover, Figs.~\ref{fig:zdt1:P},
\ref{fig:zdt2:P}, \ref{fig:zdt3:P}, and~\ref{fig:zdt4:P} show that the candidate
solutions are always on the Pareto frontier for the problems ZDT1 to ZDT4. This
allows the user to stop the optimization at any number of evaluations, even with
very few function evaluations, and have a reasonable expectation that the
solutions found are efficient.
When we evaluate the hypervolume indicator, we see that, for the problems ZDT1,
ZDT2, ZDT4, and ZDT6, the performance of the H2MA is much better, even for the
last one using stochastic exploration. Moreover, the H2MA's worst hypervolume
was always better than the best hypervolume for all evolutionary algorithms and
it was able to get closer to the maximum hypervolume possible with relatively
few function evaluations, being a strong indication of its efficiency.
For the problem ZDT3, whose hypervolume performance is shown in
Fig.~\ref{fig:zdt3:H}, the H2MA was generally better than the evolutionary
algorithms. The Pareto frontier for ZDT3 is composed of disconnected sets of
points, which was created to test the algorithm's ability to deal with
discontinuous frontiers. Since the exploitation algorithm used for the results
is gradient-based, it is not able to properly handle discontinuous functions,
which is the case of the hypervolume on discontinuous frontiers. However, the
deterministic exploration method is able to find points whose exploitation lay
on the different parts of the Pareto frontier, providing the expected diversity.
\begin{figure}[t]
\centering
\psfrag{analytic}[c][b]{Analytic}
\psfrag{numeric}[c][c]{Numeric}
\includegraphics[width=\linewidth]{analytic_comparison.eps}
\caption{Comparison between the number of function evaluations required to
achieve the same hypervolume using numeric or analytic gradient. The dotted
line represents a 30-fold improvement.}
\label{fig:analytic}
\end{figure}
Fig.~\ref{fig:analytic} shows a comparison between the number of function
evaluations required by the numeric and the analytic gradient to achieve the
same hypervolume on the problems ZDT1 to ZDT4. The analytic method for computing
the hypervolume's gradient is described in~\cite{hypervolume_gradient1}. The
comparison for ZDT6 is not shown due to its different scale, since many function
evaluations are used in the global stochastic exploration because the
deterministic exploration fails to find regions.
As expected, using the analytic gradient causes a 30-fold improvement in
comparison to the numeric gradient, since the number of decision variables is
30. However, the gain is not linear. This can be explained by the difference in
behavior during the deterministic exploration: the first non-dominated point
found is used to perform the exploitation, even if this point was found during
the computation of the numeric gradient. For ZDT1 and ZDT4, this causes the new
points found by the numeric gradient to be very close to the original points,
reducing its performance and increasing the improvement of using the analytic
gradient.
Moreover, a similar effect makes the ZDT3 performance to have a lower
improvement when using the analytic gradient. Since the Pareto frontier for ZDT3
is discontinuous and this causes a discontinuity in the hypervolume, these large
changes can be seen by the numeric gradient because small changes in the
variables can have large effects on the hypervolume, pulling the solution if the
difference is significant, while the analytic gradient is not able to provide
such knowledge. Nonetheless, the analytic gradient presents at least a 15-fold
improvement over the numeric one over the ZDT3.
\subsection{Analysis of the H2MA's performance}
As shown in Section~\ref{sec:results}, the proposed H2MA is able to surpass the
state-of-the-art in multi-objective optimization, based on evolutionary
algorithms. Therefore, it is important to analyze the algorithm and to discuss
why this improvement happened.
Evolutionary algorithms perform a guided exploration, with new individuals
created based on existing high-performing individuals, which allows them to
escape local minima but reduces the convergence speed. On the other hand,
traditional optimization algorithms tend to find local minima quickly, but the
optimal point achieved depends on the minima's regions of attraction.
These two kind of algorithms have complementary natures, which makes them good
candidates for creating a hybrid algorithm: the evolutionary algorithm explores
the space and provides initial conditions for the local optimization, which
then finds minima quickly. Although this does create better results, it only
explains the performance on the ZDT6 problem, since the other problems did not
enter the stochastic phase.
In order to understand the algorithm's behavior, we must keep in mind that each
new point added by the algorithm is solving a very different problem. Since the
previous points that are considered during the hypervolume optimization change
as more points are added, the objective surface for each new point is different
from the previous ones and takes into account the already achieved portion of
the hypervolume. To visualize this, supposed that the hypervolume's gradient is
defined over previously found points and one previous solution is used as the
initial condition for the gradient-based exploitation to find a new point to be
added to the solution set. Although the initial condition was a local optimum
for a previous problem, it is not a local optimum to the current problem,
because any small change that creates a non-dominated point will improve the
total hypervolume. Therefore, we do not need to worry about the new optimization
converging to a previous solution point because the problem landscape is
different and different local minima will be found, increasing the total
hypervolume. The deterministic exploration is only required because the
hypervolume's gradient is not defined at the border of the hypervolume, so a new
independent point must be found.
This explains the performance improvement over ZDT1 to ZDT4, because every added
point improves the hypervolume as much as it can do locally, so that an
improvement is guaranteed to happen. Evolutionary algorithms, on the other hand,
use function evaluations without guarantees of improvement of the total
hypervolume, since dominated solutions can be found.
Moreover, although a local optimum found during exploitation may not be an
efficient solution due to irregularities in the objective surface, the
experiments show that this is not the case most of the time, since the
P-distance of the solutions found are generally zero. This result is expected,
since the hypervolume is maximal when computed over points in the Pareto set,
and the performance on all ZDT problems provide support to this claim.
We must highlight that we are not saying that evolutionary algorithms should not
be used at all, but that they should be applied whenever traditional
optimization methods are not able to solve the problem. This is the case of the
ZDT6, for instance, where an evolutionary algorithm was required to provide
initial conditions for the exploitation. We consider very important to have
alternative methods that are better on a subset of the problems and to use them
when a problem from such subset is present. This is exactly what the H2MA does:
when the traditional optimization is not able to find an answer, which indicates
that the problem is outside of the subset with which it can deal, an
evolutionary algorithm, which is able to handle a superset class of problems, is
used until the problem becomes part of the subset again, establishing a
switching behavior that takes advantage of both algorithms.
\section{Conclusion}
\label{sec:conclusion}
This paper proposed the Hybrid Hypervolume Maximization Algorithm (H2MA) for
multi-objective optimization, which tries to maximize the hypervolume one point
at a time. It first tries to perform deterministic local exploration and, when
it gets stuck, it switches to stochastic global exploration using an
evolutionary algorithm. The optimization algorithm used during deterministic
optimization is problem-dependent and can be given by a gradient-based method,
when the decision space is continuous, or a hill-climbing method, when the
decision space is discrete. Here we have explored solely continuous decision
spaces.
The algorithm was compared with state-of-the-art algorithms for multi-objective
optimization, namely NSGA-II, SPEA2, and SMS-EMOA on the ZDT problems. Despite
using numeric gradient for the objective functions, which increases the number
of function calls, the algorithm consistently provided a higher hypervolume for
the same number of function evaluations when compared to the aforementioned
evolutionary algorithms. Only for the ZDT3 the performance was slightly reduced
due to the discontinuous nature of the Pareto frontier, which causes a
discontinuity in the hypervolume, not properly handled by gradient-based
methods.
Moreover, for all problems except for ZDT6, all the solutions found by the
algorithm were over the Pareto frontier, which makes them efficient solutions.
For the ZDT6, the median case also had all solutions over the Pareto frontier,
but the use of the stochastic exploration not always guided to a solution at the
Pareto frontier. Nonetheless, the obtained solutions were better than those
provided by the evolutionary algorithms. Moreover, the solutions provided for
ZDT1 to ZDT4 achieved high performance using only the deterministic part of the
algorithm.
Evolutionary algorithms usually have better performance when their populations
are larger, so that diverse individuals can be selected for crossover. However,
most of the time people do not require many options, so the H2MA presents itself
as an alternative choice for finding a good set of solutions at a lower
computational cost in most problems, although it does not limit the
computational burden and the number of points found. If the problem has more
reasonable objectives than ZDT6, which was designed with an extreme case in
mind, we can expect that many points will be found by the deterministic
mechanisms, which makes the algorithm more reliable. Moreover, the solutions
found should be efficient, which is characterized by a low P-distance, and
diverse on the objectives, which is characterized by a larger hypervolume when
only efficient solutions are considered.
Future work should focus on using surrogates to reduce the number of
evaluations~\cite{jin2005comprehensive,knowles2008meta,voutchkov2010multi}.
Although the H2MA is very efficient on its evaluations, the numeric gradient may
consume lots of evaluations and be unreliable for complicated functions, as
their implementation can cause numerical errors larger than the step used. Using
a surrogate, the gradient can be determined directly and less evaluations are
required.
Another important research problem is to find a new algorithm for computing the
hypervolume, since existing algorithms are mainly focused on computing the
hypervolume given a set of points~\cite{beume2009complexity}. Since the solution
set is constructed one solution at a time in the H2MA, a recursive algorithm
that computes the hypervolume of $X \cup \{x\}$ given the hypervolume of $X$
should reduce the computing requirement.
|
{'timestamp': '2015-06-18T02:18:56', 'yymm': '1506', 'arxiv_id': '1506.05424', 'language': 'en', 'url': 'https://arxiv.org/abs/1506.05424'}
|
arxiv
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.